-
Notifications
You must be signed in to change notification settings - Fork 3
/
_3_chunk_rpm_ostree.sh
executable file
·62 lines (53 loc) · 1.65 KB
/
_3_chunk_rpm_ostree.sh
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/env bash
if [ $(id -u) -ne 0 ]; then
echo "Run as superuser"
exit 1
fi
if [ -z "$OUT_NAME" ]; then
echo "OUT_NAME is empty"
exit 1
fi
if [ -z "$OUT_REF" ]; then
echo "OUT_REF is empty"
exit 1
fi
set -e
PREV_ARG=""
if [ -z "$PREV_NAME" ]; then
echo "Warning: PREV_NAME is empty. Will not use previous build to avoid layer shifts."
else
echo "Using previous manifest $PREV_NAME to avoid layer shifts."
if [ -d $PREV_NAME.manifest.raw.json ]; then
echo "Previous build $PREV_NAME does not exist."
exit 1
fi
PREV_ARG="--previous-build-manifest ${PREV_NAME}.manifest.raw.json"
fi
# This file creates a container based on the ostree repository
# with tag $OUT_TAG
MAX_LAYERS=${MAX_LAYERS:=40}
OUT_TAG=${OUT_TAG:=master}
RPM_OSTREE=${RPM_OSTREE:=rpm-ostree}
# Login for uploading
if [[ $OUT_REF == registry* && -f auth.json ]]; then
base_url=$(echo $OUT_REF | cut -d':' -f2 | cut -d'/' -f1)
echo Logging in to $base_url
if ! skopeo login --authfile auth.json ${base_url}; then
echo "Failed to authenticate with skopeo"
exit 1
fi
fi
echo Creating archive with ref ${OUT_REF}
${RPM_OSTREE} compose \
container-encapsulate \
--repo=repo ${OUT_TAG} \
--max-layers ${MAX_LAYERS} \
--write-contentmeta-json ${OUT_NAME}.contentmeta.json \
${PREV_ARG} \
${OUT_REF}
echo Created archive with ref ${OUT_REF}
echo Writing manifests to ./$OUT_NAME.manifest.json, ./$OUT_NAME.manifest.raw.json
skopeo inspect ${OUT_REF} > ${OUT_NAME}.manifest.json
skopeo inspect --raw ${OUT_REF} > ${OUT_NAME}.manifest.raw.json
# Reset perms to make the files usable
chmod 666 ${OUT_NAME}* -R