# HG changeset patch # User Gilles Moris # Date 2009-11-06 08:26:29 # Node ID ce145bf2ca5e527c99bc22d6357f9bf4cd7d92da # Parent 0d65e191ac4c2a3246fd12543819f3ccdd6a8a73 buildrpm: build from working dir parent and use hg version for RPM versioning Previous, RPMs was always built from tip, and the release number did not match the 'hg version' put in place for 1.4. This will enable also to this script to be able to build official tag and not only nightly build. diff --git a/contrib/buildrpm b/contrib/buildrpm --- a/contrib/buildrpm +++ b/contrib/buildrpm @@ -26,7 +26,7 @@ rpmdir=/tmp/"`basename $root | sed 's/ / cd "$root" rm -rf $rpmdir mkdir -p $rpmdir/RPMS -$HG clone "$root" $rpmdir/BUILD +$HG clone -u . "$root" $rpmdir/BUILD if [ ! -f $specfile ]; then echo "Cannot find $specfile!" 1>&2 @@ -34,11 +34,19 @@ if [ ! -f $specfile ]; then fi tmpspec=/tmp/`basename "$specfile"`.$$ # FIXME: Insecure /tmp handling -# Use the most recent tag as the version. -version=`$HG tags | python -c 'import sys; print [l for l in sys.stdin.readlines() if l[0].isdigit()][0].split()[0]'` -# Compute the release number as the difference in revision numbers -# between the tip and the most recent tag. -release=`$HG tags | python -c 'import sys; l = sys.stdin.readlines(); print int(l[0].split()[1].split(":")[0]) - int([x for x in l if x[0].isdigit()][0].split()[1].split(":")[0])'` +# make setup.py build the version string +python setup.py build_py -c -d . +hgversion=`$HG version | sed -ne 's/.*(version \(.*\))$/\1/p'` + +if echo $hgversion | grep -- '-' > /dev/null 2>&1; then + # nightly build case, version is like 1.3.1+250-20b91f91f9ca + version=`echo $hgversion | cut -d- -f1` + release=`echo $hgversion | cut -d- -f2 | sed -e 's/+.*//'` +else + # official tag, version is like 1.3.1 + version=`echo $hgversion | sed -e 's/+.*//'` + release='0' +fi tip=`$HG -q tip` # Beat up the spec file