Patchwork [03,of,10,v2] buildrpm: introduce --rpmdir instead of using hardcoded rpmbuild dir

login
register
mail settings
Submitter Mads Kiilerich
Date Aug. 31, 2014, 11:41 a.m.
Message ID <0aefc4c4bd0cf27abcc6.1409485293@localhost.localdomain>
Download mbox | patch
Permalink /patch/5658/
State Accepted
Headers show

Comments

Mads Kiilerich - Aug. 31, 2014, 11:41 a.m.
# HG changeset patch
# User Mads Kiilerich <madski@unity3d.com>
# Date 1409485253 -7200
#      Sun Aug 31 13:40:53 2014 +0200
# Node ID 0aefc4c4bd0cf27abcc6188f5a1889180469f907
# Parent  d433fd9465cdb06d52a7dd3f1b1bee65462aee6f
buildrpm: introduce --rpmdir instead of using hardcoded rpmbuild dir

Used as rpm _topdir when preparing spec and source and building rpms.

Patch

diff --git a/contrib/buildrpm b/contrib/buildrpm
--- a/contrib/buildrpm
+++ b/contrib/buildrpm
@@ -8,6 +8,7 @@ 
 # - centOS 6
 
 BUILD=1
+RPMBUILDDIR="$PWD/rpmbuild"
 while [ "$1" ]; do
     case "$1" in
     --prepare )
@@ -18,6 +19,11 @@  while [ "$1" ]; do
         shift
         PYTHONVER=2.7.8
         ;;
+    --rpmbuilddir )
+        shift
+        RPMBUILDDIR="$1"
+        shift
+        ;;
     * )
         echo "Invalid parameter $1!" 1>&2
         exit 1
@@ -44,10 +50,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
 
 hgversion=`$HG version | sed -ne 's/.*(version \(.*\))$/\1/p'`
 
@@ -67,22 +70,22 @@  else
     RPMPYTHONVER=%{nil}
 fi
 
-$HG archive -t tgz $rpmdir/SOURCES/mercurial-$version-$release.tar.gz
+$HG archive -t tgz $RPMBUILDDIR/SOURCES/mercurial-$version-$release.tar.gz
 if [ "$PYTHONVER" ]; then
 (
     cd build
     PYTHON_SRCFILE=Python-$PYTHONVER.tgz
     [ -f $PYTHON_SRCFILE ] || curl -Lo $PYTHON_SRCFILE http://www.python.org/ftp/python/$PYTHONVER/$PYTHON_SRCFILE
-    ln -f $PYTHON_SRCFILE $rpmdir/SOURCES/$PYTHON_SRCFILE
+    ln -f $PYTHON_SRCFILE $RPMBUILDDIR/SOURCES/$PYTHON_SRCFILE
 
     DOCUTILSVER=`sed -ne "s/^%global docutilsname docutils-//p" $specfile`
     DOCUTILS_SRCFILE=docutils-$DOCUTILSVER.tar.gz
     [ -f $DOCUTILS_SRCFILE ] || curl -Lo $DOCUTILS_SRCFILE http://downloads.sourceforge.net/project/docutils/docutils/$DOCUTILSVER/$DOCUTILS_SRCFILE
-    ln -f $DOCUTILS_SRCFILE $rpmdir/SOURCES/$DOCUTILS_SRCFILE
+    ln -f $DOCUTILS_SRCFILE $RPMBUILDDIR/SOURCES/$DOCUTILS_SRCFILE
 )
 fi
 
-rpmspec=$rpmdir/SPECS/mercurial.spec
+rpmspec=$RPMBUILDDIR/SPECS/mercurial.spec
 
 sed -e "s,^Version:.*,Version: $version," \
     -e "s,^Release:.*,Release: $release," \
@@ -138,13 +141,13 @@  sed -i \
     $rpmspec
 
 if [ "$BUILD" ]; then
-    rpmbuild --define "_topdir $rpmdir" -ba $rpmspec --clean
+    rpmbuild --define "_topdir $RPMBUILDDIR" -ba $rpmspec --clean
     if [ $? = 0 ]; then
         echo
         echo "Built packages for $version-$release:"
-        find $rpmdir/*RPMS/ -type f -newer $rpmspec
+        find $RPMBUILDDIR/*RPMS/ -type f -newer $rpmspec
     fi
 else
-    echo "Prepared sources for $version-$release $rpmspec are in $rpmdir/SOURCES/ - use like:"
-    echo "rpmbuild --define '_topdir $rpmdir' -ba $rpmspec --clean"
+    echo "Prepared sources for $version-$release $rpmspec are in $RPMBUILDDIR/SOURCES/ - use like:"
+    echo "rpmbuild --define '_topdir $RPMBUILDDIR' -ba $rpmspec --clean"
 fi