[PATCH 3 of 3] contrib/buildrpm: Don't require installed hg, use local hg with pure extensions

Mads Kiilerich mads at kiilerich.com
Sat Jun 20 09:08:26 CDT 2009


# HG changeset patch
# User Mads Kiilerich <mads at kiilerich.com>
# Date 1245506815 -7200
# Node ID 6945491c6c63207a2cd11215cfb46d66da295ec2
# Parent  58587751a1f156038dc1aeb14c30120beb02a71d
contrib/buildrpm: Don't require installed hg, use local hg with pure extensions

diff --git a/contrib/buildrpm b/contrib/buildrpm
--- a/contrib/buildrpm
+++ b/contrib/buildrpm
@@ -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 /' \


More information about the Mercurial-devel mailing list