1
0
obs-service-kiwi_metainfo_h.../kiwi_metainfo_helper

50 lines
1.4 KiB
Plaintext
Raw Normal View History

#!/bin/bash
set -eu
shopt -s nullglob
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
RECIPEFILE="${RECIPEFILE##*:}"
if [ "${RECIPEFILE##*.}" != "kiwi" ] && [ "${RECIPEFILE}" != "Dockerfile" ] && [ "${RECIPEFILE}" != "Chart.yaml" ]; then
echo "Recipe is neither Dockerfile nor kiwi nor helm chart - 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* Chart.yaml*)
if [ "${#files}" -eq 0 ]; then
echo "No kiwi or Dockerfile or helm chart found - exiting"
exit 0
fi
fi
[ -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"
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[@]}"