Fabian Vogt
aa0d7cd11f
- 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
29 lines
902 B
Bash
29 lines
902 B
Bash
#!/bin/bash
|
|
set -eu
|
|
|
|
file="Dockerfile"
|
|
|
|
if [ "${BUILD_DIST+x}" != "x" ]; then
|
|
echo "Not running in an OBS build container"
|
|
exit 1
|
|
fi
|
|
|
|
BUILD_DATA="${BUILD_DIST/.dist/.data}"
|
|
if [ -e "${BUILD_DATA}" ]; then
|
|
. "${BUILD_DATA}"
|
|
|
|
# The build script renames the recipe (to strip _service:foo:), but doesn't update .data
|
|
file="${RECIPEFILE##*:}"
|
|
|
|
if [[ ! "${file}" =~ ^Dockerfile.* ]]; then
|
|
echo "Recipe ${file} is not a Dockerfile - exiting"
|
|
exit 0
|
|
fi
|
|
fi
|
|
|
|
# Note: Avoid assigning to $1 etc. as that converts whitespace (field separators) to single spaces.
|
|
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' "${file}" |