@@ -23,10 +23,11 @@ Usage: coreos-assembler build-with-buildah
23
23
--skip-prune Skip pruning previous builds.
24
24
--strict Only allow installing locked packages when using lockfiles.
25
25
--parent-build=VERSION This option does nothing and is provided for backwards compatibility.
26
- --force This option does nothing and is provided for backwards compatibility .
26
+ --force Import a new build even if inputhash has not changed .
27
27
EOF
28
28
}
29
29
30
+ FORCE=
30
31
VERSION=
31
32
VERSIONARY=
32
33
DIRECT=
@@ -70,6 +71,7 @@ while true; do
70
71
shift
71
72
;;
72
73
--force)
74
+ FORCE=1
73
75
;;
74
76
--)
75
77
shift
@@ -123,6 +125,15 @@ build_with_buildah() {
123
125
exit 0
124
126
fi
125
127
128
+ previous_inputhash=
129
+ if [ -f " builds/latest/${arch} /meta.json" ]; then
130
+ previous_inputhash=$( jq -r ' .["coreos-assembler.oci-imported-labels"]["com.coreos.inputhash"] // ""' \
131
+ " builds/latest/${arch} /meta.json" )
132
+ if [ -n " ${previous_inputhash} " ]; then
133
+ echo " Previous input hash: ${previous_inputhash} "
134
+ fi
135
+ fi
136
+
126
137
# Apply autolock from another build for this version (or for another version if
127
138
# explicitly provided via --autolock) if no base lockfile exists.
128
139
lockfile=" manifest-lock.${arch} .json"
@@ -207,7 +218,19 @@ build_with_buildah() {
207
218
env -C " ${tempdir} /src" TMPDIR=" $( realpath cache) " buildah " $@ "
208
219
fi
209
220
210
- /usr/lib/coreos-assembler/cmd-import " ${final_ref} " ${SKIP_PRUNE: +--skip-prune}
221
+ new_inputhash=$( skopeo inspect " ${final_ref} " | jq -r ' .Labels."com.coreos.inputhash"' )
222
+ if [ -n " ${previous_inputhash} " ] && [ " $previous_inputhash " = " $new_inputhash " ]; then
223
+ echo " Input hash unchanged ($new_inputhash )"
224
+ if [ -z " $FORCE " ]; then
225
+ skip_import=1
226
+ else
227
+ echo " Importing new build anyway (--force)"
228
+ fi
229
+ fi
230
+
231
+ if [ -z " ${skip_import:- } " ]; then
232
+ /usr/lib/coreos-assembler/cmd-import " ${final_ref} " ${SKIP_PRUNE: +--skip-prune}
233
+ fi
211
234
212
235
rm -rf " ${tempdir} "
213
236
}
0 commit comments