2009-03-10 17:43:05 +00:00
|
|
|
#!/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
|
|
|
|
|
|
2016-01-20 16:14:21 +01:00
|
|
|
# If sources are under git control then use "git describe"
|
2009-03-10 17:43:05 +00:00
|
|
|
if test -f "${GITCHECK}"
|
|
|
|
|
then
|
2016-01-20 16:14:21 +01:00
|
|
|
if (cd "${TOPSRCDIR}" && git describe)
|
2009-03-10 17:43:05 +00:00
|
|
|
then
|
2016-01-20 16:14:21 +01:00
|
|
|
echo Getting buildid from Git >&2
|
2009-03-10 17:43:05 +00:00
|
|
|
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
|
2011-02-16 11:51:13 +00:00
|
|
|
echo 1
|
2009-03-10 17:43:05 +00:00
|
|
|
exit 0
|