Patchwork [5,of,6,packaging] packaging: extract packagelib for common code from builddeb and buildrpm

login
register
mail settings
Submitter Augie Fackler
Date May 8, 2015, 5:10 p.m.
Message ID <eb1672b7b846324d4275.1431105008@arthedain.pit.corp.google.com>
Download mbox | patch
Permalink /patch/8975/
State Superseded
Commit 56c64c91b42937759dfced7ca551b1d6a34a522c
Headers show

Comments

Augie Fackler - May 8, 2015, 5:10 p.m.
# HG changeset patch
# User Augie Fackler <augie@google.com>
# Date 1431008938 14400
#      Thu May 07 10:28:58 2015 -0400
# Node ID eb1672b7b846324d4275b49c09d33373e3cb1920
# Parent  25e90eb8e6dd9a142d52128d13584d2d99147d7f
packaging: extract packagelib for common code from builddeb and buildrpm

Patch

diff --git a/contrib/builddeb b/contrib/builddeb
--- a/contrib/builddeb
+++ b/contrib/builddeb
@@ -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 @@  if [ ! -d .hg ]; then
     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
diff --git a/contrib/buildrpm b/contrib/buildrpm
--- a/contrib/buildrpm
+++ b/contrib/buildrpm
@@ -7,6 +7,8 @@ 
 # - CentOS 5
 # - centOS 6
 
+. $(dirname $0)/packagelib.sh
+
 BUILD=1
 RPMBUILDDIR="$PWD/rpmbuild"
 while [ "$1" ]; do
@@ -45,25 +47,8 @@  if [ ! -d .hg ]; then
     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
+gethgversion
 
-mkdir -p $RPMBUILDDIR/SOURCES $RPMBUILDDIR/SPECS $RPMBUILDDIR/RPMS $RPMBUILDDIR/SRPMS $RPMBUILDDIR/BUILD
-
-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
 if [ "$PYTHONVER" ]; then
     release=$release+$PYTHONVER
     RPMPYTHONVER=$PYTHONVER
diff --git a/contrib/packagelib.sh b/contrib/packagelib.sh
new file mode 100644
--- /dev/null
+++ b/contrib/packagelib.sh
@@ -0,0 +1,19 @@ 
+function gethgversion() {
+    make clean
+    make local
+    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
+}