Accepting request 1179155 from isv:Rancher:Elemental:Dev
- Support Docker.FLAVOR in _multibuild (boo#1225985) OBS-URL: https://build.opensuse.org/request/show/1179155 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Tools/obs-service-docker_label_helper?expand=0&rev=13
This commit is contained in:
parent
490d2e1694
commit
aa0d7cd11f
@ -1,6 +1,8 @@
|
||||
#!/bin/bash
|
||||
set -eu
|
||||
|
||||
file="Dockerfile"
|
||||
|
||||
if [ "${BUILD_DIST+x}" != "x" ]; then
|
||||
echo "Not running in an OBS build container"
|
||||
exit 1
|
||||
@ -11,10 +13,10 @@ if [ -e "${BUILD_DATA}" ]; then
|
||||
. "${BUILD_DATA}"
|
||||
|
||||
# The build script renames the recipe (to strip _service:foo:), but doesn't update .data
|
||||
RECIPEFILE="${RECIPEFILE##*:}"
|
||||
file="${RECIPEFILE##*:}"
|
||||
|
||||
if [ "${RECIPEFILE}" != "Dockerfile" ]; then
|
||||
echo "Recipe is not a Dockerfile - exiting"
|
||||
if [[ ! "${file}" =~ ^Dockerfile.* ]]; then
|
||||
echo "Recipe ${file} is not a Dockerfile - exiting"
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
@ -24,4 +26,4 @@ gawk -i inplace '
|
||||
match($0, /^# labelprefix=(.*)$/, m) { labelprefix=m[1]; next }
|
||||
labelprefix != "" && match($0, /^(PREFIXED)?LABEL[[:space:]]+[^=]*\.([^.=]*)=(.*)$/, m) { printf "LABEL %s.%s=%s\n", labelprefix, m[2], m[3]; gsub(/^PREFIXEDLABEL/, "LABEL") }
|
||||
match($0, /^# endlabelprefix/) { labelprefix=""; next }
|
||||
1' Dockerfile
|
||||
1' "${file}"
|
@ -1,3 +1,8 @@
|
||||
-------------------------------------------------------------------
|
||||
Fri Jun 7 08:31:35 UTC 2024 - Andrea Mazzotti <andrea.mazzotti@suse.com>
|
||||
|
||||
- Support Docker.FLAVOR in _multibuild (boo#1225985)
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Wed Mar 1 07:54:19 UTC 2023 - Fabian Vogt <fvogt@suse.com>
|
||||
|
||||
|
39
test.sh
39
test.sh
@ -57,3 +57,42 @@ LABEL org.opensuse.nano.whitespace="Two spaces. One tab."
|
||||
LABEL test.whitespace="Two spaces. One tab."
|
||||
LABEL not.expanded.label="example"
|
||||
EOF
|
||||
|
||||
# Test _multibuild
|
||||
cat >Dockerfile.FLAVOR <<EOF
|
||||
# labelprefix=org.opensuse.nano
|
||||
LABEL org.opencontainers.image.title="Example container."
|
||||
# endlabelprefix
|
||||
EOF
|
||||
|
||||
export BUILD_DIST="$tmpdir/test_multibuild/.build/build.dist"
|
||||
mkdir -p "$tmpdir/test_multibuild/.build"
|
||||
cat >"$tmpdir/test_multibuild/.build/build.data" <<EOF
|
||||
RECIPEFILE=_service:obs_scm:Dockerfile.FLAVOR
|
||||
EOF
|
||||
sh "${script}"
|
||||
|
||||
diff -u Dockerfile.FLAVOR - <<EOF
|
||||
LABEL org.opensuse.nano.title="Example container."
|
||||
LABEL org.opencontainers.image.title="Example container."
|
||||
EOF
|
||||
|
||||
# Test _multibuild when not a Dockerfile.*
|
||||
cat >NotADockerfile <<EOF
|
||||
# labelprefix=org.opensuse.nano
|
||||
LABEL org.opencontainers.image.title="Example container."
|
||||
# endlabelprefix
|
||||
EOF
|
||||
|
||||
export BUILD_DIST="$tmpdir/test_multibuild/.build/build.dist"
|
||||
mkdir -p "$tmpdir/test_multibuild/.build"
|
||||
cat >"$tmpdir/test_multibuild/.build/build.data" <<EOF
|
||||
RECIPEFILE=_service:obs_scm:NotADockerfile
|
||||
EOF
|
||||
sh "${script}"
|
||||
|
||||
diff -u NotADockerfile - <<EOF
|
||||
# labelprefix=org.opensuse.nano
|
||||
LABEL org.opencontainers.image.title="Example container."
|
||||
# endlabelprefix
|
||||
EOF
|
||||
|
Loading…
Reference in New Issue
Block a user