| 1 |
#! /bin/sh
|
| 2 |
# Copyright 2007 Gentoo Foundation
|
| 3 |
# Distributed under the terms of the GNU General Public License v2
|
| 4 |
# Author: Michael Haubenwallner <haubi@gentoo.org>
|
| 5 |
|
| 6 |
set -e
|
| 7 |
|
| 8 |
versioning_done=no
|
| 9 |
|
| 10 |
while [ "x$1" != x ]; do
|
| 11 |
arg=$1
|
| 12 |
shift
|
| 13 |
case "x${arg}" in
|
| 14 |
x--version=*)
|
| 15 |
echo "x${arg}" | sed -e 's,^x--version=,,' > version
|
| 16 |
versioning_done=yes
|
| 17 |
;;
|
| 18 |
esac
|
| 19 |
done
|
| 20 |
svnurl='$HeadURL$'
|
| 21 |
|
| 22 |
mainversion=`grep 'AC_INIT(toolchain-prefix-wrapper,[0-9\.]*svnversion)' configure.ac | sed -e 's/.*([^,]*,\([^),]*\)\.svnversion\>.*)/\1/'`
|
| 23 |
if [ "x${mainversion}" != x ]; then
|
| 24 |
# configure.ac indicates to define the package-version automagically
|
| 25 |
if [ "x${versioning_done}" != xyes ] && [ -d .svn ] ; then
|
| 26 |
# we are in an svn sandbox:
|
| 27 |
# then we need to determine the version out of svn keyword 'HeadURL'.
|
| 28 |
case "${svnurl}" in
|
| 29 |
*'/trunk/'*)
|
| 30 |
# is snapshot from trunk:
|
| 31 |
# version is mainversion + '.' + [last-committed] svn revision
|
| 32 |
svn status -v | cut -c19-26 | sort -rn | { read v ; echo "${mainversion}.${v}" ;} > version
|
| 33 |
versioning_done=yes
|
| 34 |
;;
|
| 35 |
*'/branches/'*)
|
| 36 |
# is snapshot from branch:
|
| 37 |
# version is branch-number + '.' + [last-committed] svn revision
|
| 38 |
( echo -n "${svnurl}" \
|
| 39 |
| sed -e "s,-branch/bootstrap \\\$,,; s,.*/,," -e "s,^.*-,,"
|
| 40 |
svn status -v | cut -c19-26 | sort -rn | { read v ; echo ".${v}" ;}
|
| 41 |
) > version
|
| 42 |
versioning_done=yes
|
| 43 |
;;
|
| 44 |
esac
|
| 45 |
fi
|
| 46 |
if [ "x${versioning_done}" != xyes ]; then
|
| 47 |
case "${svnurl}" in
|
| 48 |
*'/tags/'*)
|
| 49 |
# is tag: version is tag number
|
| 50 |
( echo "${svnurl}" \
|
| 51 |
| sed -e "s,/bootstrap \\\$,,; s,.*-,,"
|
| 52 |
) > version
|
| 53 |
versioning_done=yes
|
| 54 |
;;
|
| 55 |
*)
|
| 56 |
if [ -r version ]; then
|
| 57 |
# we reuse the 'version' determined during packaging from svn.
|
| 58 |
versioning_done=yes
|
| 59 |
fi
|
| 60 |
;;
|
| 61 |
esac
|
| 62 |
fi
|
| 63 |
if [ "x${versioning_done}" != xyes ]; then
|
| 64 |
echo "error: no 'version' file and unknown svnurl '${svnurl}'" >&2
|
| 65 |
echo "error: cannot determine package version" >&2
|
| 66 |
exit 1
|
| 67 |
fi
|
| 68 |
else
|
| 69 |
# configure.ac defines the version, keep 'version' empty.
|
| 70 |
: > version
|
| 71 |
fi
|
| 72 |
set +x
|
| 73 |
|
| 74 |
echo "mkdir -p build-aux"
|
| 75 |
mkdir -p build-aux
|
| 76 |
echo "aclocal"
|
| 77 |
aclocal
|
| 78 |
echo "autoheader"
|
| 79 |
autoheader
|
| 80 |
echo "automake --add-missing --copy --foreign"
|
| 81 |
automake --add-missing --copy --foreign
|
| 82 |
echo "autoconf"
|
| 83 |
autoconf
|
| 84 |
|
| 85 |
if [ -s version ]; then
|
| 86 |
version=`cat version`
|
| 87 |
eval `grep '^PACKAGE_VERSION=' configure | head -n 1`
|
| 88 |
if [ "${version}" != "${PACKAGE_VERSION}" ]; then
|
| 89 |
(
|
| 90 |
echo '--- configure'
|
| 91 |
echo '+++ configure'
|
| 92 |
grep "\<${PACKAGE_VERSION}\>" configure \
|
| 93 |
| awk '{print "@@ -1,1 +1,1 @@"; print "-" $0; print "+" $0}' \
|
| 94 |
| sed -e "s|\(^+.*\)\<${PACKAGE_VERSION}\>|\1${version}|"
|
| 95 |
) | patch --no-backup-if-mismatch configure -
|
| 96 |
fi
|
| 97 |
fi
|
| 98 |
|