packaging: extract packagelib for common code from builddeb and buildrpm
authorAugie Fackler <augie@google.com>
Thu, 07 May 2015 10:28:58 -0400
changeset 24972 56c64c91b429
parent 24971 ab75baaf81d5
child 24973 4c4d0012db4f
packaging: extract packagelib for common code from builddeb and buildrpm
contrib/builddeb
contrib/buildrpm
contrib/packagelib.sh
--- a/contrib/builddeb	Wed May 06 13:13:54 2015 -0400
+++ b/contrib/builddeb	Thu May 07 10:28:58 2015 -0400
@@ -4,6 +4,8 @@
 #
 # Tested on Jessie (stable as of original script authoring.)
 
+. $(dirname $0)/packagelib.sh
+
 BUILD=1
 DEBBUILDDIR="$PWD/debbuild"
 while [ "$1" ]; do
@@ -34,23 +36,7 @@
     exit 1
 fi
 
-# build local hg and use it
-python setup.py build_py -c -d .
-HG="$PWD/hg"
-
-$HG version > /dev/null || { echo 'abort: hg version failed!'; exit 1 ; }
-
-hgversion=`$HG version | sed -ne 's/.*(version \(.*\))$/\1/p'`
-
-if echo $hgversion | grep -- '-' > /dev/null 2>&1; then
-    # nightly build case, version is like 1.3.1+250-20b91f91f9ca
-    version=`echo $hgversion | cut -d- -f1`
-    release=`echo $hgversion | cut -d- -f2 | sed -e 's/+.*//'`
-else
-    # official tag, version is like 1.3.1
-    version=`echo $hgversion | sed -e 's/+.*//'`
-    release='0'
-fi
+gethgversion
 
 cp -r $PWD/contrib/debian $DEBBUILDDIR/DEBIAN
 chmod -R 0755 $DEBBUILDDIR/DEBIAN
--- a/contrib/buildrpm	Wed May 06 13:13:54 2015 -0400
+++ b/contrib/buildrpm	Thu May 07 10:28:58 2015 -0400
@@ -7,6 +7,8 @@
 # - CentOS 5
 # - centOS 6
 
+. $(dirname $0)/packagelib.sh
+
 BUILD=1
 RPMBUILDDIR="$PWD/rpmbuild"
 while [ "$1" ]; do
@@ -45,25 +47,8 @@
     exit 1
 fi
 
-# build local hg and use it
-python setup.py build_py -c -d .
-HG="$PWD/hg"
-PYTHONPATH="$PWD/mercurial/pure"
-export PYTHONPATH
-
-mkdir -p $RPMBUILDDIR/SOURCES $RPMBUILDDIR/SPECS $RPMBUILDDIR/RPMS $RPMBUILDDIR/SRPMS $RPMBUILDDIR/BUILD
-
-hgversion=`$HG version | sed -ne 's/.*(version \(.*\))$/\1/p'`
+gethgversion
 
-if echo $hgversion | grep -- '-' > /dev/null 2>&1; then
-    # nightly build case, version is like 1.3.1+250-20b91f91f9ca
-    version=`echo $hgversion | cut -d- -f1`
-    release=`echo $hgversion | cut -d- -f2 | sed -e 's/+.*//'`
-else
-    # official tag, version is like 1.3.1
-    version=`echo $hgversion | sed -e 's/+.*//'`
-    release='0'
-fi
 if [ "$PYTHONVER" ]; then
     release=$release+$PYTHONVER
     RPMPYTHONVER=$PYTHONVER
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/contrib/packagelib.sh	Thu May 07 10:28:58 2015 -0400
@@ -0,0 +1,19 @@
+gethgversion() {
+    make clean
+    make local || make local PURE=--pure
+    HG="$PWD/hg"
+
+    $HG version > /dev/null || { echo 'abort: hg version failed!'; exit 1 ; }
+
+    hgversion=`$HG version | sed -ne 's/.*(version \(.*\))$/\1/p'`
+
+    if echo $hgversion | grep -- '-' > /dev/null 2>&1; then
+        # nightly build case, version is like 1.3.1+250-20b91f91f9ca
+        version=`echo $hgversion | cut -d- -f1`
+        release=`echo $hgversion | cut -d- -f2 | sed -e 's/+.*//'`
+    else
+        # official tag, version is like 1.3.1
+        version=`echo $hgversion | sed -e 's/+.*//'`
+        release='0'
+    fi
+}