2019-01-09 11:39:18 +01:00
|
|
|
#!/bin/bash
|
|
|
|
set -eu
|
2020-07-08 17:10:37 +02:00
|
|
|
shopt -s nullglob
|
2019-01-09 11:39:18 +01:00
|
|
|
|
|
|
|
if [ "${BUILD_DIST+x}" != "x" ]; then
|
|
|
|
echo "Not running in an OBS build container"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
BUILD_DATA="${BUILD_DIST/.dist/.data}"
|
2020-07-08 17:10:37 +02:00
|
|
|
if [ -e "${BUILD_DATA}" ]; then
|
|
|
|
. "${BUILD_DATA}"
|
|
|
|
|
|
|
|
# The build script renames the recipe (to strip _service:foo:), but doesn't update .data
|
|
|
|
RECIPEFILE="${RECIPEFILE##*:}"
|
|
|
|
|
2020-08-27 09:09:01 +02:00
|
|
|
if [ "${RECIPEFILE##*.}" != "kiwi" ] && [ "${RECIPEFILE}" != "Dockerfile" ] && [ "${RECIPEFILE}" != "Chart.yaml" ]; then
|
|
|
|
echo "Recipe is neither Dockerfile nor kiwi nor helm chart - exiting"
|
2020-07-08 17:10:37 +02:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
files=("${RECIPEFILE}")
|
|
|
|
else
|
|
|
|
echo "Warning: No build data found - chroot build?"
|
|
|
|
DISTURL="local"
|
|
|
|
RELEASE=0
|
|
|
|
|
|
|
|
# Guess the build recipe
|
2020-08-27 09:09:01 +02:00
|
|
|
files=(*.kiwi Dockerfile* Chart.yaml*)
|
2020-07-08 17:10:37 +02:00
|
|
|
if [ "${#files}" -eq 0 ]; then
|
2020-08-27 09:09:01 +02:00
|
|
|
echo "No kiwi or Dockerfile or helm chart found - exiting"
|
2020-07-08 17:10:37 +02:00
|
|
|
exit 0
|
|
|
|
fi
|
2019-01-09 11:39:18 +01:00
|
|
|
fi
|
|
|
|
|
2019-01-15 11:27:59 +01:00
|
|
|
[ -f /usr/lib/os-release ] && . /usr/lib/os-release
|
|
|
|
[ -f /etc/os-release ] && . /etc/os-release
|
|
|
|
|
|
|
|
# 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"
|
|
|
|
|
2020-07-08 17:10:37 +02:00
|
|
|
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[@]}"
|