Skip to content

Commit d2b49da

Browse files
committed
cmd-build-with-buildah: add --autolock
This matches `cosa build` support for it and is actively used by both RHCOS and FCOS (rawhide). Long-term I think this will become obsolete by hermetic builds in Konflux which will require us to always have in-tree lockfiles.
1 parent 195cc81 commit d2b49da

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

src/cmd-build-with-buildah

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,18 @@ Usage: coreos-assembler build-with-buildah
1717
--version=VERSION Use the given version instead of using versionary.
1818
--versionary Generate non-development version using versionary.
1919
--direct Run buildah directly rather than within supermin.
20+
--autolock=VERSION If no base lockfile used, create one from any arch build of `VERSION`.
21+
Note this is automatically enabled when adding to an existing multi-arch
22+
non-strict build.
2023
EOF
2124
}
2225

2326
VERSION=
2427
VERSIONARY=
2528
DIRECT=
29+
AUTOLOCK_VERSION=
2630
rc=0
27-
options=$(getopt --options h,d --longoptions help,version:,versionary,direct -- "$@") || rc=$?
31+
options=$(getopt --options h,d --longoptions help,version:,versionary,direct,autolock: -- "$@") || rc=$?
2832
[ $rc -eq 0 ] || {
2933
print_help
3034
exit 1
@@ -46,6 +50,10 @@ while true; do
4650
-d | --direct)
4751
DIRECT=1
4852
;;
53+
--autolock)
54+
shift;
55+
AUTOLOCK_VERSION=$1
56+
;;
4957
--)
5058
shift
5159
break
@@ -94,6 +102,18 @@ build_with_buildah() {
94102
exit 0
95103
fi
96104

105+
# Apply autolock from another build for this version (or for another version if
106+
# explicitly provided via --autolock) if no base lockfile exists.
107+
lockfile="manifest-lock.${arch}.json"
108+
if [ ! -f "src/config/${lockfile}" ] && { [ -n "${VERSION}" ] || [ -n "${AUTOLOCK_VERSION}" ]; }; then
109+
autolockfile=$(tmprepo=tmp/repo; workdir=.;
110+
generate_autolock "${AUTOLOCK_VERSION:-${VERSION}}")
111+
if [ -n "${autolockfile}" ]; then
112+
echo "Injecting autolock-generated ${lockfile}..."
113+
cp "${autolockfile}" "${tempdir}/src/${lockfile}"
114+
fi
115+
fi
116+
97117
set -- build --security-opt=label=disable --cap-add=all --device /dev/fuse \
98118
--build-arg-file "$argsfile" -v "$(realpath "${tempdir}/src")":/run/src \
99119
--build-arg VERSION="${VERSION}" \

0 commit comments

Comments
 (0)