File kiwi_label_helper of Package obs-service-kiwi_label_helper

#!/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" ]; then
		echo "Recipe is not a kiwi file - 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)
	if [ "${#files}" -eq 0 ]; then
		echo "No kiwi recipe - exiting"
		exit 0
	fi
fi

for file in "${files[@]}"; do
	tmp="$(mktemp)"
	if ! xsltproc /usr/lib/kiwi_label_helper/label_helper.xsl "${file}" >> "${tmp}"; then
		rm "${tmp}"
		echo "xsltproc failed"
		exit 1
	fi

	mv -f "${tmp}" "${file}"
done
openSUSE Build Service is sponsored by