changeset 8869:d244ee52ac30

contrib/buildrpm: Don't require installed hg, use local hg with pure extensions
author Mads Kiilerich <mads@kiilerich.com>
date Sat, 20 Jun 2009 16:06:55 +0200
parents 8c97115547cc
children c3e4d3c1d48b
files contrib/buildrpm
diffstat 1 files changed, 10 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/contrib/buildrpm	Sat Jun 20 16:06:55 2009 +0200
+++ b/contrib/buildrpm	Sat Jun 20 16:06:55 2009 +0200
@@ -9,13 +9,11 @@
 # - Fedora 11
 # - Centos 5.3 (with Fedora EPEL repo for asciidoc)
 
-if hg --version > /dev/null 2>&1; then :
-else
-    echo 'hg command not available!' 1>&2
-    exit 1
-fi
+HG="`dirname $0`/../hg"
+PYTHONPATH="`dirname $0`/../mercurial/pure"
+export PYTHONPATH
 
-root="`hg root 2>/dev/null`"
+root="`$HG root 2>/dev/null`"
 specfile=contrib/mercurial.spec
 
 if [ -z "$root" ]; then
@@ -28,7 +26,7 @@
 cd "$root"
 rm -rf $rpmdir
 mkdir -p $rpmdir/RPMS
-hg clone "$root" $rpmdir/BUILD
+$HG clone "$root" $rpmdir/BUILD
 
 if [ ! -f $specfile ]; then
     echo "Cannot find $specfile!" 1>&2
@@ -37,11 +35,11 @@
 
 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]'`
+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])'`
-tip=`hg -q tip`
+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])'`
+tip=`$HG -q tip`
 
 # Beat up the spec file
 sed -e 's,^Source:.*,Source: /dev/null,' \
@@ -53,11 +51,11 @@
 
 cat <<EOF >> $tmpspec
 %changelog
-* `date +'%a %b %d %Y'` `hg showconfig ui.username` $version-$release
+* `date +'%a %b %d %Y'` `$HG showconfig ui.username` $version-$release
 - Automatically built via $0
 
 EOF
-hg log \
+$HG log \
      --template '* {date|rfc822date} {author}\n- {desc|firstline}\n\n' \
      .hgtags \
   | sed -e 's/^\(\* [MTWFS][a-z][a-z]\), \([0-3][0-9]\) \([A-Z][a-z][a-z]\) /\1 \3 \2 /' \