1
0
Fabian Vogt 2020-07-08 15:10:37 +00:00 committed by Git OBS Bridge
parent 8af2e23907
commit 9225fdd96d
2 changed files with 40 additions and 14 deletions

View File

@ -1,5 +1,6 @@
#!/bin/bash
set -eu
shopt -s nullglob
if [ "${BUILD_DIST+x}" != "x" ]; then
echo "Not running in an OBS build container"
@ -7,28 +8,42 @@ if [ "${BUILD_DIST+x}" != "x" ]; then
fi
BUILD_DATA="${BUILD_DIST/.dist/.data}"
. "${BUILD_DATA}"
if [ -e "${BUILD_DATA}" ]; then
. "${BUILD_DATA}"
# The build script renames the recipe (to strip _service:foo:), but doesn't update .data
RECIPEFILE="${RECIPEFILE##*:}"
# The build script renames the recipe (to strip _service:foo:), but doesn't update .data
RECIPEFILE="${RECIPEFILE##*:}"
if [ "${RECIPEFILE##*.}" != "kiwi" ]; then
echo "Recipe is not a kiwi file - exiting"
exit 0
if [ "${RECIPEFILE##*.}" != "kiwi" ] && [ "${RECIPEFILE}" != "Dockerfile" ]; then
echo "Recipe is neither Dockerfile nor kiwi - exiting"
exit 0
fi
files=("${RECIPEFILE}")
else
echo "Warning: No build data found - chroot build?"
DISTURL="local"
RELEASE=0
# Guess the build recipe
files=(*.kiwi Dockerfile*)
if [ "${#files}" -eq 0 ]; then
echo "No kiwi or Dockerfile found - exiting"
exit 0
fi
fi
sed -i"" "s#%DISTURL%#${DISTURL}#g" "${RECIPEFILE}"
sed -i"" "s/%RELEASE%/${RELEASE}/g" "${RECIPEFILE}"
sed -i"" "s/%BUILDTIME%/$(date --utc +%FT%T.%NZ)/g" "${RECIPEFILE}"
[ -f /usr/lib/os-release ] && . /usr/lib/os-release
[ -f /etc/os-release ] && . /etc/os-release
sed -i"" "s/%OS_VERSION_ID%/${VERSION_ID}/g" "${RECIPEFILE}"
sed -i"" "s/%OS_PRETTY_NAME%/${PRETTY_NAME}/g" "${RECIPEFILE}"
# Special case for SLE X "SP 0", make sure it has .0
VERSION_ID_SP="${VERSION_ID}"
[[ "${VERSION_ID_SP%}" == *"."* ]] || VERSION_ID_SP="${VERSION_ID}.0"
sed -i"" "s/%OS_VERSION_ID_SP%/${VERSION_ID_SP}/g" "${RECIPEFILE}"
sed -i"" \
-e "s#%DISTURL%#${DISTURL}#g" \
-e "s/%RELEASE%/${RELEASE}/g" \
-e "s/%BUILDTIME%/$(date --utc +%FT%T.%NZ)/g" \
-e "s/%OS_VERSION_ID%/${VERSION_ID}/g" \
-e "s/%OS_PRETTY_NAME%/${PRETTY_NAME}/g" \
-e "s/%OS_VERSION_ID_SP%/${VERSION_ID_SP}/g" "${files[@]}"

View File

@ -1,3 +1,14 @@
-------------------------------------------------------------------
Tue Jul 7 13:53:33 UTC 2020 - Fabian Vogt <fvogt@suse.com>
- Add explicit fallback for chroot builds
- Refactor into a single sed call
-------------------------------------------------------------------
Tue May 5 09:19:56 UTC 2020 - Fabian Vogt <fvogt@suse.com>
- Also allow working on Dockerfile
-------------------------------------------------------------------
Mon May 4 13:40:20 UTC 2020 - Fabian Vogt <fvogt@suse.com>