diff contrib/buildrpm @ 22436:96d95b75a63b

buildrpm: introduce --withpython for building rpms that includes Python 2.7
author Mads Kiilerich <madski@unity3d.com>
date Thu, 15 May 2014 01:50:11 +0200
parents 4c4385eb26bc
children 9e2e4fc524fd
line wrap: on
line diff
--- a/contrib/buildrpm	Sun Aug 31 12:51:06 2014 +0200
+++ b/contrib/buildrpm	Thu May 15 01:50:11 2014 +0200
@@ -14,6 +14,10 @@
         shift
         BUILD=
         ;;
+    --withpython | --with-python)
+        shift
+        PYTHONVER=2.7.8
+        ;;
     * )
         echo "Invalid parameter $1!" 1>&2
         exit 1
@@ -23,7 +27,7 @@
 
 cd "`dirname $0`/.."
 
-specfile=contrib/mercurial.spec
+specfile=$PWD/contrib/mercurial.spec
 if [ ! -f $specfile ]; then
     echo "Cannot find $specfile!" 1>&2
     exit 1
@@ -56,8 +60,28 @@
     version=`echo $hgversion | sed -e 's/+.*//'`
     release='0'
 fi
+if [ "$PYTHONVER" ]; then
+    release=$release+$PYTHONVER
+    RPMPYTHONVER=$PYTHONVER
+else
+    RPMPYTHONVER=%{nil}
+fi
 
 $HG archive -t tgz $rpmdir/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
+
+    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
+)
+fi
+
 rpmspec=$rpmdir/SPECS/mercurial.spec
 
 sed -e "s,^Version:.*,Version: $version," \
@@ -109,6 +133,10 @@
 
 fi
 
+sed -i \
+    -e "s/^%define withpython.*$/%define withpython $RPMPYTHONVER/" \
+    $rpmspec
+
 if [ "$BUILD" ]; then
     rpmbuild --define "_topdir $rpmdir" -ba $rpmspec --clean
     if [ $? = 0 ]; then