@@ -22,10 +22,11 @@ Usage: coreos-assembler build-with-buildah
2222 non-strict build.
2323 --skip-prune Skip prunning previous builds
2424 --parent-build=VERSION This option does nothing and is provided for backwards compatibility.
25- --force This option does nothing and is provided for backwards compatibility .
25+ --force Import a new build even if inputhash has not changed .
2626EOF
2727}
2828
29+ FORCE=
2930VERSION=
3031VERSIONARY=
3132DIRECT=
@@ -65,6 +66,7 @@ while true; do
6566 shift
6667 ;;
6768 --force)
69+ FORCE=1
6870 ;;
6971 --)
7072 shift
@@ -118,6 +120,15 @@ build_with_buildah() {
118120 exit 0
119121 fi
120122
123+ previous_inputhash=
124+ if [ -f " builds/latest/${arch} /meta.json" ]; then
125+ previous_inputhash=$( jq -r ' .["coreos-assembler.oci-imported-labels"]["com.coreos.inputhash"] // ""' \
126+ " builds/latest/${arch} /meta.json" )
127+ if [ -n " ${previous_inputhash} " ]; then
128+ echo " Previous input hash: ${previous_inputhash} "
129+ fi
130+ fi
131+
121132 # Apply autolock from another build for this version (or for another version if
122133 # explicitly provided via --autolock) if no base lockfile exists.
123134 lockfile=" manifest-lock.${arch} .json"
@@ -198,7 +209,19 @@ build_with_buildah() {
198209 env -C " ${tempdir} /src" TMPDIR=" $( realpath cache) " buildah " $@ "
199210 fi
200211
201- /usr/lib/coreos-assembler/cmd-import " ${final_ref} " ${SKIP_PRUNE: +--skip-prune}
212+ new_inputhash=$( skopeo inspect " ${final_ref} " | jq -r ' .Labels."com.coreos.inputhash"' )
213+ if [ -n " ${previous_inputhash} " ] && [ " $previous_inputhash " = " $new_inputhash " ]; then
214+ echo " Input hash unchanged ($new_inputhash )"
215+ if [ -z " $FORCE " ]; then
216+ skip_import=1
217+ else
218+ echo " Importing new build anyway (--force)"
219+ fi
220+ fi
221+
222+ if [ -z " ${skip_import:- } " ]; then
223+ /usr/lib/coreos-assembler/cmd-import " ${final_ref} " ${SKIP_PRUNE: +--skip-prune}
224+ fi
202225
203226 rm -rf " ${tempdir} "
204227}
0 commit comments