File kiwi_metainfo_helper of Package obs-service-kiwi_metainfo_helper.10137

#!/bin/bash
set -eu

if [ "${BUILD_DIST+x}" != "x" ]; then
	echo "Not running in an OBS build container"
	exit 1
fi

BUILD_DATA="${BUILD_DIST/.dist/.data}"
. "${BUILD_DATA}"

if [ "${RECIPEFILE##*.}" != "kiwi" ]; then
	echo "Recipe is not a kiwi file - exiting"
	exit 0
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}"
openSUSE Build Service is sponsored by