42d1a9
#!/bin/sh
42d1a9
42d1a9
# Adjusts the configuration options to build the variants correctly
42d1a9
42d1a9
test -n "$RHTEST" && exit 0
42d1a9
42d1a9
DEBUGBUILDSENABLED=$1
42d1a9
if [ -z "$DEBUGBUILDSENABLED" ]; then
42d1a9
	exit 1
42d1a9
fi
42d1a9
42d1a9
if [ -z "$FLAVOR" ]; then
42d1a9
	FLAVOR=rhel
42d1a9
fi
42d1a9
42d1a9
if [ "$FLAVOR" = "fedora" ]; then
42d1a9
	SECONDARY=rhel
42d1a9
else
42d1a9
	SECONDARY=fedora
42d1a9
fi
42d1a9
42d1a9
# The +1 is to remove the - at the end of the SPECPACKAGE_NAME string
42d1a9
specpackage_name_len=$((${#SPECPACKAGE_NAME} + 1))
42d1a9
for i in "${SPECPACKAGE_NAME}"*-"$FLAVOR".config; do
42d1a9
	# shellcheck disable=SC3057
42d1a9
	NEW=${SPECPACKAGE_NAME}-"$SPECRPMVERSION"-$(echo "${i:$specpackage_name_len}" | sed s/-"$FLAVOR"//)
42d1a9
	mv "$i" "$NEW"
42d1a9
done
42d1a9
42d1a9
rm -f kernel-*-"$SECONDARY".config
42d1a9
42d1a9
if [ "$DEBUGBUILDSENABLED" -eq 0 ]; then
42d1a9
	for i in "${SPECPACKAGE_NAME}"-*debug*.config; do
42d1a9
		base=$(echo "$i" | sed -r s/-?debug//g)
42d1a9
		NEW=${SPECPACKAGE_NAME}-$(echo "$base" | cut -d - -f2-)
42d1a9
		mv "$i" "$NEW"
42d1a9
	done
42d1a9
fi