@@ -14,16 +14,15 @@ Usage: coreos-assembler build-with-buildah
1414 `cosa build` will pivot to this script when the environment variable `COREOS_ASSEMBLER_BUILD_WITH_BUILDAH` is set.
1515
1616 The following options are supported:
17- --versionary Use the versionary script from the source config to drive version.
18- --direct Run buildah directly rather than within supermin.
17+ --version Use the versionary script from the source config to drive version.
18+ --direct Run buildah directly rather than within supermin.
1919EOF
2020}
2121
22- VERSIONARY=
2322VERSION=
2423DIRECT=
2524rc=0
26- options=$( getopt --options h,v,d --longoptions help,versionary ,direct -- " $@ " ) || rc=$?
25+ options=$( getopt --options h,v,d --longoptions help,version: ,direct -- " $@ " ) || rc=$?
2726[ $rc -eq 0 ] || {
2827 print_help
2928 exit 1
@@ -35,8 +34,9 @@ while true; do
3534 print_help
3635 exit 0
3736 ;;
38- -v | --versionary)
39- VERSIONARY=1
37+ -v | --version)
38+ shift
39+ VERSION=$1
4040 ;;
4141 -d | --direct)
4242 DIRECT=1
@@ -55,15 +55,13 @@ while true; do
5555 shift
5656done
5757
58- if [ -n " ${VERSIONARY } " ]; then
58+ if [ -z " ${VERSION } " ]; then
5959 # let error out if file does not exist
6060 VERSION=$( src/config/versionary)
61- echo " New version will be ${VERSION} "
6261fi
6362
6463build_with_buildah () {
65- VERSION=$1
66- echo " Building with container runtime (buildah)..."
64+ echo " Building with container runtime (buildah) with VERSION=${VERSION} ..."
6765
6866 tempdir=$( mktemp -d --tmpdir=tmp " build-with-buildah.XXXXXXXX" )
6967
@@ -77,14 +75,16 @@ build_with_buildah() {
7775 argsfile=build-args-${variant} .conf
7876 fi
7977
78+ if [ " $( check_build_exists " ${VERSION} " ) " == " True" ]; then
79+ echo " Build ${VERSION} already exists"
80+ exit 0
81+ fi
82+
8083 set -- build --security-opt=label=disable --cap-add=all --device /dev/fuse \
8184 --build-arg-file " $argsfile " -v " $( realpath " ${tempdir} /src" ) " :/run/src \
85+ --build-arg VERSION=" ${VERSION} " \
8286 -t oci-archive:" ${tmp_oci_archive_path} "
8387
84- if [ -n " ${VERSION} " ]; then
85- set -- " $@ " --build-arg VERSION=" ${VERSION} "
86- fi
87-
8888 if [ -n " $DIRECT " ]; then
8989 # turn on layer caching in the direct case; it wouldn't hurt in the
9090 # supermin path, but it'd be a waste of space on the rootfs
@@ -99,4 +99,4 @@ build_with_buildah() {
9999 rm -rf " ${tempdir} "
100100}
101101
102- build_with_buildah " $VERSION "
102+ build_with_buildah
0 commit comments