Skip to content

Commit 710e574

Browse files
dustymabejlebon
authored andcommitted
cmd-podman-build: support --args for just printing arguments
In the case where you are running COSA via the alias/func [1] and not in a custom toolbox container then `cosa podman-build node` today won't work because running `podman` inside a rootless container doesn't really work. Add a new `--args` argument here to just tell `cosa podman-build` to set up for the build (i.e. generate tmp files and necessary arguments) and then print what would have been passed to `podman build`. This can then be used on the host to run `podman build` with something like: ``` node-build() { local args=$(cosa podman-build --args node) # Translate src/config to the location of the repo on disk. Also # tr to remove the trailing `\r` from the output. args=$(echo "$args" | tr -d '\r' | sed s,src/config,$COREOS_ASSEMBLER_CONFIG_GIT,g) set -x podman build $args set +x } ``` So you'd run `node-build` and it would do what you need for you. [1] https://github.com/coreos/coreos-assembler/blob/main/docs/building-fcos.md#define-a-bash-alias-to-run-cosa
1 parent c7662aa commit 710e574

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

src/cmd-podman-build

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/bash
2-
set -xeuo pipefail
2+
set -euo pipefail
33

44
meta=builds/latest/$(arch)/meta.json
55
name=$(jq -r .name "${meta}")
@@ -15,6 +15,15 @@ print(y["metadata"]["ocp_version"])')
1515
node_tag=localhost/${name}-${ocp_version}-${version}-node
1616
extensions_tag=localhost/${name}-${ocp_version}-${version}-extensions
1717

18+
# If a user provides args then they just want us to print
19+
# out what args to run `podman build` with and exit so they
20+
# can run podman build themselves (most likely outside the
21+
# COSA container).
22+
if [ "${1:-}" == "--args" ]; then
23+
PRINT_ARGS_AND_EXIT=1
24+
shift
25+
fi
26+
1827
target=${1:-}
1928
case "${target}" in
2029
node)
@@ -37,8 +46,14 @@ if [ -d src/yumrepos ]; then
3746
cat src/yumrepos/*.repo >> "$repos_file"
3847
fi
3948

40-
set -x
41-
podman build --from "$from" \
49+
if [ "${PRINT_ARGS_AND_EXIT:-}" == "1" ]; then
50+
cmd='echo'
51+
else
52+
cmd='podman build'
53+
set -x
54+
fi
55+
56+
$cmd --from "$from" \
4257
-t "${tag}" \
4358
-f "${containerfile}" \
4459
--secret id=yumrepos,src="$repos_file" \

0 commit comments

Comments
 (0)