#!/bin/bash
if ! test -e $RPM_BUILD_ROOT/etc/os-release; then 
	echo "Unknown"
	exit 1
fi
. $RPM_BUILD_ROOT/etc/os-release
ARCH=$(uname -m | sed 's/i[3456]86/x86/')
case $ID in
	opensuse)
		NAME=opensuse_${VERSION_ID}
		;;
	sles)
		NAME=suse${VERSION_ID%.*}
		if test ${VERSION_ID##*.} == ${VERSION_ID}; then
			NAME=${NAME}_sp0
		else
			NAME=${NAME}_sp${VERSION_ID##*.}
		fi
		;;
	centos|redhat|rhel|ol)
		if test $ID = ol; then ID=oracle; fi
		if test $ID = rhel; then ID=redhat; fi
		NAME=${ID}${VERSION_ID}
		if test ${VERSION_ID##*.} == ${VERSION_ID}; then
			NAME=${NAME}.0
		fi
		;;
	ubuntu)
		NAME=${ID}${VERSION%% *}
		;;
	debian|fedora)
		NAME=${ID}${VERSION_ID}
		;;
	euleros)
		VER=${VERSION_ID}
		VSP=$(echo "$VERSION" | sed 's/^[^ ]* (SP\([0-9]*\)).*$/\1/')
		if test "$VSP" != "$VERSION"; then VER=${VER/\.0/.$VSP}; fi
		NAME=${ID}${VER}
		;;
	*)
		echo "Unknown-${ID}${VERSION_ID}_${ARCH}"
		exit 1
esac
echo "${NAME}_${ARCH}"

