cyphesis/scripts/extract_revision.sh
Erik Ogenvik eb81c7eecb Use "git describe" for buildid.
Also removed circular dependency as well as CVS leftover script.
2016-06-22 17:06:50 +02:00

37 lines
816 B
Bash
Executable file

#!/bin/bash
TOPSRCDIR="$@"
GITCHECK="${TOPSRCDIR}/.git/config"
OLDBUILDCPP="${TOPSRCDIR}/server/buildid.cpp"
if ! test -d "${TOPSRCDIR}"
then
echo Non existent source directory \"${TOPSRCDIR}\" >&2
echo -1
exit 1
fi
# If sources are under git control then use "git describe"
if test -f "${GITCHECK}"
then
if (cd "${TOPSRCDIR}" && git describe)
then
echo Getting buildid from Git >&2
exit 0
fi
fi
# We don't seem to be under source control, so use the existing buildid.
if test -f "${OLDBUILDCPP}"
then
if grep buildId "${OLDBUILDCPP}" | head -n 1 | sed "s/^.* = \([-0-9]*\);$/\1/"
then
echo Using existing buildid >&2
exit 0
fi
fi
# We could not find any useful build ID, so mark it clearly as an error.
echo Unknown buildid >&2
echo 1
exit 0