[PATCH 4 of 6] buildrpm: cleanup script

Gilles Moris gilles.moris at free.fr
Fri Nov 6 03:07:20 CST 2009


 contrib/buildrpm |  31 ++++++++++---------------------
 1 files changed, 10 insertions(+), 21 deletions(-)


# HG changeset patch
# User Gilles Moris <gilles.moris at free.fr>
# Date 1257497603 -3600
# Node ID 40bf0b832e2f4336ac21833ed25911ad2d77ae4b
# Parent  28fce23ee1252d93f3f582a0e7882e5dc079c298
buildrpm: cleanup script

diff --git a/contrib/buildrpm b/contrib/buildrpm
--- a/contrib/buildrpm
+++ b/contrib/buildrpm
@@ -4,20 +4,19 @@
 #
 # Bryan O'Sullivan <bos at serpentine.com>
 #
-# Tested on
-# - Fedora 10
-# - Fedora 11
-# - Centos 5.3 (with Fedora EPEL repo for asciidoc)
 
 cd "`dirname $0`/.."
 HG="$PWD/hg"
 PYTHONPATH="$PWD/mercurial/pure"
 export PYTHONPATH
 
-root="`$HG root 2>/dev/null`"
 specfile=contrib/mercurial.spec
+if [ ! -f $specfile ]; then
+    echo "Cannot find $specfile!" 1>&2
+    exit 1
+fi
 
-if [ -z "$root" ]; then
+if [ ! -d .hg ]; then
     echo 'You are not inside a Mercurial repository!' 1>&2
     exit 1
 fi
@@ -30,17 +29,11 @@
     fi
 fi
 
-rpmdir=/tmp/"`basename $root | sed 's/ /_/'`"-rpm # FIXME: Insecure /tmp handling
+rpmdir=/tmp/"`basename $PWD | sed 's/ /_/'`"-rpm # FIXME: Insecure /tmp handling
 
-cd "$root"
 rm -rf $rpmdir
 mkdir -p $rpmdir/RPMS
-$HG clone -u . "$root" $rpmdir/BUILD
-
-if [ ! -f $specfile ]; then
-    echo "Cannot find $specfile!" 1>&2
-    exit 1
-fi
+$HG clone -u . . $rpmdir/BUILD
 
 tmpspec=/tmp/`basename "$specfile"`.$$ # FIXME: Insecure /tmp handling
 # make setup.py build the version string
@@ -56,13 +49,10 @@
     version=`echo $hgversion | sed -e 's/+.*//'`
     release='0'
 fi
-tip=`$HG -q tip`
 
-# Beat up the spec file
-sed -e 's,^Source:.*,Source: /dev/null,' \
-    -e "s,^Version:.*,Version: $version," \
+sed -e "s,^Version:.*,Version: $version," \
     -e "s,^Release:.*,Release: $release," \
-    -e "s,^%prep.*,Changeset: $tip\n\0," \
+    -e "s,^%prep.*,\n\0," \
     -e 's,^%setup.*,,' \
     $specfile > $tmpspec
 
@@ -79,9 +69,8 @@
         -e '/^\* [MTWFS][a-z][a-z] /{s/ [012][0-9]:[0-9][0-9]:[0-9][0-9] [+-][0-9]\{4\}//}' \
    >> $tmpspec
 
-rpmbuild --define "_topdir $rpmdir" -bb $tmpspec
+rpmbuild --define "_topdir $rpmdir" -bb $tmpspec --clean
 if [ $? = 0 ]; then
-    rm -rf $tmpspec $rpmdir/BUILD
     mv $rpmdir/RPMS/*/* $rpmdir && rm -r $rpmdir/RPMS
     echo
     echo "Packages are in $rpmdir:"


More information about the Mercurial-devel mailing list