@@ -14,16 +14,15 @@ Usage: coreos-assembler build-with-buildah
14
14
`cosa build` will pivot to this script when the environment variable `COREOS_ASSEMBLER_BUILD_WITH_BUILDAH` is set.
15
15
16
16
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.
19
19
EOF
20
20
}
21
21
22
- VERSIONARY=
23
22
VERSION=
24
23
DIRECT=
25
24
rc=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=$?
27
26
[ $rc -eq 0 ] || {
28
27
print_help
29
28
exit 1
@@ -35,8 +34,9 @@ while true; do
35
34
print_help
36
35
exit 0
37
36
;;
38
- -v | --versionary)
39
- VERSIONARY=1
37
+ -v | --version)
38
+ shift
39
+ VERSION=$1
40
40
;;
41
41
-d | --direct)
42
42
DIRECT=1
@@ -55,15 +55,13 @@ while true; do
55
55
shift
56
56
done
57
57
58
- if [ -n " ${VERSIONARY } " ]; then
58
+ if [ -z " ${VERSION } " ]; then
59
59
# let error out if file does not exist
60
60
VERSION=$( src/config/versionary)
61
- echo " New version will be ${VERSION} "
62
61
fi
63
62
64
63
build_with_buildah () {
65
- VERSION=$1
66
- echo " Building with container runtime (buildah)..."
64
+ echo " Building with container runtime (buildah) with VERSION=${VERSION} ..."
67
65
68
66
tempdir=$( mktemp -d --tmpdir=tmp " build-with-buildah.XXXXXXXX" )
69
67
@@ -77,14 +75,16 @@ build_with_buildah() {
77
75
argsfile=build-args-${variant} .conf
78
76
fi
79
77
78
+ if [ " $( check_build_exists " ${VERSION} " ) " == " True" ]; then
79
+ echo " Build ${VERSION} already exists"
80
+ exit 0
81
+ fi
82
+
80
83
set -- build --security-opt=label=disable --cap-add=all --device /dev/fuse \
81
84
--build-arg-file " $argsfile " -v " $( realpath " ${tempdir} /src" ) " :/run/src \
85
+ --build-arg VERSION=" ${VERSION} " \
82
86
-t oci-archive:" ${tmp_oci_archive_path} "
83
87
84
- if [ -n " ${VERSION} " ]; then
85
- set -- " $@ " --build-arg VERSION=" ${VERSION} "
86
- fi
87
-
88
88
if [ -n " $DIRECT " ]; then
89
89
# turn on layer caching in the direct case; it wouldn't hurt in the
90
90
# supermin path, but it'd be a waste of space on the rootfs
@@ -99,4 +99,4 @@ build_with_buildah() {
99
99
rm -rf " ${tempdir} "
100
100
}
101
101
102
- build_with_buildah " $VERSION "
102
+ build_with_buildah
0 commit comments