#!/bin/sh

v="v7.02"

if [ -d ${GIT_DIR:-.git} ] && tag=`git describe --tags`; then
	v="$tag"

	# Update the index from working tree first
	git update-index --refresh --unmerged > /dev/null

	# Does the index show uncommitted changes?
	git diff-index --exit-code HEAD > /dev/null || \
		v="$v"-dirty
else
	v="$v"-unknown
fi

echo "const char *openconnect_version_str = \"$v\";" > $1
echo "New version: $v"

#!/bin/sh

v="v7.02"

if [ -d ${GIT_DIR:-.git} ] && tag=`git describe --tags`; then
	v="$tag"

	# Update the index from working tree first
	git update-index --refresh --unmerged > /dev/null

	# Does the index show uncommitted changes?
	git diff-index --exit-code HEAD > /dev/null || \
		v="$v"-dirty
elif [ -n "$RPM_PACKAGE_VERSION" ] && [ -n "$RPM_PACKAGE_RELEASE" ]; then
	v="v$RPM_PACKAGE_VERSION-$RPM_PACKAGE_RELEASE"
else # XXX: Equivalent for .deb packages?
	v="$v"-unknown
fi

echo "const char *openconnect_version_str = \"$v\";" > $1
echo "New version: $v"

Fix 'vX.XX-unknown' when RPM package applies patches
Fix 'vX.XX-unknown' when RPM package applies patches

If the source is patched but $RPM_PACKAGE_VERSION and $RPM_PACKAGE_RELEASE
are set, then make the version string match that. It's better than just
using "-unknown", and one hopes that the packager is doing sane things.

Would be nice to do this for .deb packaging too.

Signed-off-by: David Woodhouse <b460d66aaf00c296a3db1c1d9eeafc081d5f7d70@intel.com>
