Skip to content

Commit bb7443a

Browse files
committed
cmdlib.sh: factor out COSA_BUILD_WITH_BUILDAH check
Prep for next patch.
1 parent c34e2b7 commit bb7443a

File tree

3 files changed

+23
-11
lines changed

3 files changed

+23
-11
lines changed

src/cmd-build

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
#!/usr/bin/env bash
22
set -euo pipefail
33

4-
if [ -n "${COSA_BUILD_WITH_BUILDAH:-}" ]; then
5-
exec /usr/lib/coreos-assembler/cmd-build-with-buildah "$@"
6-
fi
7-
84
dn=$(dirname "$0")
95
# shellcheck source=src/cmdlib.sh
106
. "${dn}"/cmdlib.sh
117

8+
if should_build_with_buildah; then
9+
info 'redirecting to build-with-buildah'
10+
exec /usr/lib/coreos-assembler/cmd-build-with-buildah "$@"
11+
fi
12+
1213
print_help() {
1314
cat 1>&2 <<'EOF'
1415
Usage: coreos-assembler build --help

src/cmd-fetch

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ dn=$(dirname "$0")
55
# shellcheck source=src/cmdlib.sh
66
. "${dn}"/cmdlib.sh
77

8+
if should_build_with_buildah; then
9+
# shellcheck disable=SC2016
10+
info 'fetch is not useful when building with buildah'
11+
info 'skipping fetch'
12+
exit 0
13+
fi
14+
815
FILE=cache/pkgcache-repo
916
if [ -d "${FILE}" ]
1017
then
@@ -96,13 +103,6 @@ if [ $# -ne 0 ]; then
96103
fatal "ERROR: Too many arguments"
97104
fi
98105

99-
if [ -n "${COSA_BUILD_WITH_BUILDAH:-}" ]; then
100-
# shellcheck disable=SC2016
101-
info 'fetch is not useful when using $COSA_BUILD_WITH_BUILDAH'
102-
info 'Skipping fetch'
103-
exit 0
104-
fi
105-
106106
prepare_build
107107

108108
lock_args=

src/cmdlib.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,17 @@ yaml2json() {
148148
python3 -c 'import sys, json, yaml; json.dump(yaml.safe_load(sys.stdin), sys.stdout, sort_keys=True)' < "$1" > "$2"
149149
}
150150

151+
should_build_with_buildah() {
152+
if [ -n "${COSA_BUILD_WITH_BUILDAH:-}" ]; then
153+
if [ "${COSA_BUILD_WITH_BUILDAH:-}" = 1 ]; then
154+
return 0
155+
else
156+
return 1
157+
fi
158+
fi
159+
return 1
160+
}
161+
151162
prepare_build() {
152163
preflight
153164
preflight_kvm

0 commit comments

Comments
 (0)