# HG changeset patch # User Augie Fackler # Date 2015-05-07 14:28:58 # Node ID 56c64c91b42937759dfced7ca551b1d6a34a522c # Parent ab75baaf81d58121181199118d9d41f2e36c9aac packaging: extract packagelib for common code from builddeb and buildrpm 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 - -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 diff --git a/contrib/packagelib.sh b/contrib/packagelib.sh new file mode 100644 --- /dev/null +++ b/contrib/packagelib.sh @@ -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 +}