@@ -23,10 +23,11 @@ Usage: coreos-assembler build-with-buildah
2323 --skip-prune Skip pruning previous builds.
2424 --strict Only allow installing locked packages when using lockfiles.
2525 --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 .
2727EOF
2828}
2929
30+ FORCE=
3031VERSION=
3132VERSIONARY=
3233DIRECT=
@@ -70,6 +71,7 @@ while true; do
7071 shift
7172 ;;
7273 --force)
74+ FORCE=1
7375 ;;
7476 --)
7577 shift
@@ -123,6 +125,15 @@ build_with_buildah() {
123125 exit 0
124126 fi
125127
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+
126137 # Apply autolock from another build for this version (or for another version if
127138 # explicitly provided via --autolock) if no base lockfile exists.
128139 lockfile=" manifest-lock.${arch} .json"
@@ -207,7 +218,19 @@ build_with_buildah() {
207218 env -C " ${tempdir} /src" TMPDIR=" $( realpath cache) " buildah " $@ "
208219 fi
209220
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
211234
212235 rm -rf " ${tempdir} "
213236}
0 commit comments