Patchwork [07,of,22] buildrpm: introduce --rpmdir instead of using hardcoded rpmbuild dir

login
register
mail settings
Submitter Mads Kiilerich
Date May 20, 2014, 2:10 a.m.
Message ID <5af66dd01b59fe9be2e9.1400551802@mk-desktop>
Download mbox | patch
Permalink /patch/4829/
State Superseded
Commit 9e2e4fc524fd4f43f58793166680ae78c75a6c57
Headers show

Comments

Mads Kiilerich - May 20, 2014, 2:10 a.m.
# HG changeset patch
# User Mads Kiilerich <madski@unity3d.com>
# Date 1400551681 -7200
#      Tue May 20 04:08:01 2014 +0200
# Node ID 5af66dd01b59fe9be2e918f8f1840a9690342469
# Parent  a95a7bf9ed7ef26f622cbc01bfa28ee049fbf231
buildrpm: introduce --rpmdir instead of using hardcoded rpmbuild dir

Used as rpm _topdir when preparing spec and source and building rpms.
Matt Mackall - July 14, 2014, 11:31 p.m.
On Tue, 2014-05-20 at 04:10 +0200, Mads Kiilerich wrote:
> # HG changeset patch
> # User Mads Kiilerich <madski@unity3d.com>
> # Date 1400551681 -7200
> #      Tue May 20 04:08:01 2014 +0200
> # Node ID 5af66dd01b59fe9be2e918f8f1840a9690342469
> # Parent  a95a7bf9ed7ef26f622cbc01bfa28ee049fbf231
> buildrpm: introduce --rpmdir instead of using hardcoded rpmbuild dir

FYI, I've dropped the remainder of this set as attempts to cherry-pick
the simple bits from it were proving difficult.

Patch

diff --git a/contrib/buildrpm b/contrib/buildrpm
--- a/contrib/buildrpm
+++ b/contrib/buildrpm
@@ -12,6 +12,7 @@  if [ -z "$REV" ]; then
 else
     echo "Using \$REV=$REV for --rev" 1>&2
 fi
+RPMBUILDDIR="$PWD/rpmbuild"
 while [ "$1" ]; do
     case "$1" in
     -r | --rev )
@@ -19,6 +20,11 @@  while [ "$1" ]; do
         REV="$1"
         shift
         ;;
+    --rpmbuilddir )
+        shift
+        RPMBUILDDIR="$1"
+        shift
+        ;;
     * )
         echo "Invalid parameter $1!" 1>&2
         exit 1
@@ -45,10 +51,7 @@  HG="$PWD/hg"
 PYTHONPATH="$PWD/mercurial/pure"
 export PYTHONPATH
 
-rpmdir="$PWD/rpmbuild"
-
-rm -rf $rpmdir
-mkdir -p $rpmdir/SOURCES $rpmdir/SPECS $rpmdir/RPMS $rpmdir/SRPMS $rpmdir/BUILD
+mkdir -p $RPMBUILDDIR/SOURCES $RPMBUILDDIR/SPECS $RPMBUILDDIR/RPMS $RPMBUILDDIR/SRPMS $RPMBUILDDIR/BUILD
 
 # Builds not on the stable branch is given a 0.next prefix to make clear we don't
 # have a good approximation of a version number.
@@ -72,8 +75,8 @@  hgversion=`$HG log -r "$REV" -T '{ifeq(b
 version=${hgversion%-*}
 release=${hgversion#*-}
 
-$HG archive -r "$REV" -t tgz $rpmdir/SOURCES/mercurial-$version-$release.tar.gz
-rpmspec=$rpmdir/SPECS/mercurial.spec
+$HG archive -r "$REV" -t tgz $RPMBUILDDIR/SOURCES/mercurial-$version-$release.tar.gz
+rpmspec=$RPMBUILDDIR/SPECS/mercurial.spec
 
 (
 sed \
@@ -84,9 +87,9 @@  sed \
     -T '* {date(date|localdate, "%a %b %d %Y")} {author} {sub("-rc-1$", "-0.rc", sub(r"(?<=^\d\.\d)(?=(-rc)?-1$)", ".0", "{latesttag}-1"))}.{latesttagdistance}.{node|short}\n{if(tags,"- {tags}\n")}- {desc|firstline}\n\n'
 ) > $rpmspec
 
-rpmbuild --define "_topdir $rpmdir" -ba $rpmspec --clean
+rpmbuild --define "_topdir $RPMBUILDDIR" -ba $rpmspec --clean
 if [ $? = 0 ]; then
     echo
-    echo "Packages are in $rpmdir:"
-    ls -l $rpmdir/*RPMS/*
+    echo "Packages are in $RPMBUILDDIR:"
+    ls -l $RPMBUILDDIR/*RPMS/*
 fi