-
Notifications
You must be signed in to change notification settings - Fork 97
Expand file tree
/
Copy pathmake-dockerfile.sh
More file actions
executable file
·41 lines (33 loc) · 1.32 KB
/
make-dockerfile.sh
File metadata and controls
executable file
·41 lines (33 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/bin/bash
set -euo pipefail
# Fixed TZ to ensure consistency
export TZ=UTC
declare -r ROOTFS_FILE="$1"
declare -r GROUP="$2"
declare -r OUTPUTDIR="$3"
declare -r DOWNLOAD="$4"
declare -r TITLE="$5"
declare -rx SOURCE_DATE_EPOCH="$6"
# For eventual debugging purposes
echo "SOURCE_DATE_EPOCH: ${SOURCE_DATE_EPOCH}"
# Do not use these directly in the sed below - it will mask git failures
BUILD_VERSION="${BUILD_VERSION:-dev}"
CI_COMMIT_SHA="${CI_COMMIT_SHA:-$(git rev-parse HEAD)}"
# Honor SOURCE_DATE_EPOCH and delete non-determistic ldconfig auxiliary cache file for the repro GROUP
if [[ "$GROUP" == "repro" ]]; then
CREATED_TIMESTAMP=$(date -u -d "@$SOURCE_DATE_EPOCH" +%Y-%m-%dT%H:%M:%SZ)
else
CREATED_TIMESTAMP=$(date -Is)
fi
sed -e "s|TEMPLATE_ROOTFS_FILE|$ROOTFS_FILE|" \
-e "s|TEMPLATE_ROOTFS_DOWNLOAD|$DOWNLOAD|" \
-e "s|TEMPLATE_ROOTFS_HASH|$(cat $OUTPUTDIR/$ROOTFS_FILE.SHA256)|" \
-e "s|TEMPLATE_TITLE|Arch Linux $TITLE Image|" \
-e "s|TEMPLATE_VERSION_ID|$BUILD_VERSION|" \
-e "s|TEMPLATE_REVISION|$CI_COMMIT_SHA|" \
-e "s|TEMPLATE_CREATED|$CREATED_TIMESTAMP|" \
Dockerfile.template > "$OUTPUTDIR/Dockerfile.$GROUP"
if [[ "$GROUP" == "repro" ]]; then
sed -i '/VERSION_ID=.*os-release$/ s/$/ \&\& \\\n rm -f \/var\/cache\/ldconfig\/aux-cache/' \
"$OUTPUTDIR/Dockerfile.$GROUP"
fi