packaging: move buildrpm to contrib/packaging/
authorGregory Szorc <gregory.szorc@gmail.com>
Sat, 12 May 2018 10:41:08 -0700
changeset 38008 b7cd9e94c259
parent 38007 c1a028d15005
child 38009 e51c91c14a07
packaging: move buildrpm to contrib/packaging/ Differential Revision: https://phab.mercurial-scm.org/D3546
Makefile
contrib/buildrpm
contrib/packaging/buildrpm
contrib/packaging/dockerrpm
--- a/Makefile	Sat May 12 10:38:36 2018 -0700
+++ b/Makefile	Sat May 12 10:41:08 2018 -0700
@@ -247,7 +247,7 @@
 
 fedora20:
 	mkdir -p packages/fedora20
-	contrib/buildrpm
+	contrib/packaging/buildrpm
 	cp rpmbuild/RPMS/*/* packages/fedora20
 	cp rpmbuild/SRPMS/* packages/fedora20
 	rm -rf rpmbuild
@@ -258,7 +258,7 @@
 
 fedora21:
 	mkdir -p packages/fedora21
-	contrib/buildrpm
+	contrib/packaging/buildrpm
 	cp rpmbuild/RPMS/*/* packages/fedora21
 	cp rpmbuild/SRPMS/* packages/fedora21
 	rm -rf rpmbuild
@@ -269,7 +269,7 @@
 
 centos5:
 	mkdir -p packages/centos5
-	contrib/buildrpm --withpython
+	contrib/packaging/buildrpm --withpython
 	cp rpmbuild/RPMS/*/* packages/centos5
 	cp rpmbuild/SRPMS/* packages/centos5
 
@@ -279,7 +279,7 @@
 
 centos6:
 	mkdir -p packages/centos6
-	contrib/buildrpm --withpython
+	contrib/packaging/buildrpm --withpython
 	cp rpmbuild/RPMS/*/* packages/centos6
 	cp rpmbuild/SRPMS/* packages/centos6
 
@@ -289,7 +289,7 @@
 
 centos7:
 	mkdir -p packages/centos7
-	contrib/buildrpm
+	contrib/packaging/buildrpm
 	cp rpmbuild/RPMS/*/* packages/centos7
 	cp rpmbuild/SRPMS/* packages/centos7
 
--- a/contrib/buildrpm	Sat May 12 10:38:36 2018 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,162 +0,0 @@
-#!/bin/bash -e
-#
-# Build a Mercurial RPM from the current repo
-#
-# Tested on
-# - Fedora 20
-# - CentOS 5
-# - centOS 6
-
-. $(dirname $0)/packaging/packagelib.sh
-
-BUILD=1
-RPMBUILDDIR="$PWD/rpmbuild"
-
-while [ "$1" ]; do
-    case "$1" in
-    --prepare )
-        shift
-        BUILD=
-        ;;
-    --withpython | --with-python)
-        shift
-        PYTHONVER=2.7.14
-        PYTHONMD5=cee2e4b33ad3750da77b2e85f2f8b724
-        ;;
-    --rpmbuilddir )
-        shift
-        RPMBUILDDIR="$1"
-        shift
-        ;;
-    * )
-        echo "Invalid parameter $1!" 1>&2
-        exit 1
-        ;;
-    esac
-done
-
-cd "`dirname $0`/.."
-
-specfile=$PWD/contrib/packaging/mercurial.spec
-if [ ! -f $specfile ]; then
-    echo "Cannot find $specfile!" 1>&2
-    exit 1
-fi
-
-if [ ! -d .hg ]; then
-    echo 'You are not inside a Mercurial repository!' 1>&2
-    exit 1
-fi
-
-gethgversion
-
-# TODO: handle distance/node set, and type set
-
-if [ -z "$type" ] ; then
-   release=1
-else
-    release=0.9_$type
-fi
-
-if [ -n "$distance" ] ; then
-    release=$release+$distance_$node
-fi
-
-if [ "$PYTHONVER" ]; then
-    release=$release+$PYTHONVER
-    RPMPYTHONVER=$PYTHONVER
-else
-    RPMPYTHONVER=%{nil}
-fi
-
-mkdir -p $RPMBUILDDIR/{SOURCES,BUILD,SRPMS,RPMS}
-$HG archive -t tgz $RPMBUILDDIR/SOURCES/mercurial-$version-$release.tar.gz
-if [ "$PYTHONVER" ]; then
-(
-    mkdir -p build
-    cd build
-    PYTHON_SRCFILE=Python-$PYTHONVER.tgz
-    [ -f $PYTHON_SRCFILE ] || curl -Lo $PYTHON_SRCFILE http://www.python.org/ftp/python/$PYTHONVER/$PYTHON_SRCFILE
-    if [ "$PYTHONMD5" ]; then
-        echo "$PYTHONMD5 $PYTHON_SRCFILE" | md5sum -w -c
-    fi
-    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
-    DOCUTILSMD5=`sed -ne "s/^%global docutilsmd5 //p" $specfile`
-    if [ "$DOCUTILSMD5" ]; then
-        echo "$DOCUTILSMD5 $DOCUTILS_SRCFILE" | md5sum -w -c
-    fi
-    ln -f $DOCUTILS_SRCFILE $RPMBUILDDIR/SOURCES/$DOCUTILS_SRCFILE
-)
-fi
-
-mkdir -p $RPMBUILDDIR/SPECS
-rpmspec=$RPMBUILDDIR/SPECS/mercurial.spec
-
-sed -e "s,^Version:.*,Version: $version," \
-    -e "s,^Release:.*,Release: $release," \
-    $specfile > $rpmspec
-
-echo >> $rpmspec
-echo "%changelog" >> $rpmspec
-
-if echo $version | grep '+' > /dev/null 2>&1; then
-    latesttag="`echo $version | sed -e 's/+.*//'`"
-    $HG log -r .:"$latesttag" -fM \
-        --template '{date|hgdate}\t{author}\t{desc|firstline}\n' | python -c '
-import sys, time
-
-def datestr(date, format):
-    return time.strftime(format, time.gmtime(float(date[0]) - date[1]))
-
-changelog = []
-for l in sys.stdin.readlines():
-    tok = l.split("\t")
-    hgdate = tuple(int(v) for v in tok[0].split())
-    changelog.append((datestr(hgdate, "%F"), tok[1], hgdate, tok[2]))
-prevtitle = ""
-for l in sorted(changelog, reverse=True):
-    title = "* %s %s" % (datestr(l[2], "%a %b %d %Y"), l[1])
-    if prevtitle != title:
-        prevtitle = title
-        print
-        print title
-    print "- %s" % l[3].strip()
-' >> $rpmspec
-
-else
-
-    $HG log \
-         --template '{date|hgdate}\t{author}\t{desc|firstline}\n' \
-         .hgtags | python -c '
-import sys, time
-
-def datestr(date, format):
-    return time.strftime(format, time.gmtime(float(date[0]) - date[1]))
-
-for l in sys.stdin.readlines():
-    tok = l.split("\t")
-    hgdate = tuple(int(v) for v in tok[0].split())
-    print "* %s %s\n- %s" % (datestr(hgdate, "%a %b %d %Y"), tok[1], tok[2])
-' >> $rpmspec
-
-fi
-
-sed -i \
-    -e "s/^%define withpython.*$/%define withpython $RPMPYTHONVER/" \
-    $rpmspec
-
-if [ "$BUILD" ]; then
-    rpmbuild --define "_topdir $RPMBUILDDIR" -ba $rpmspec --clean
-    if [ $? = 0 ]; then
-        echo
-        echo "Built packages for $version-$release:"
-        find $RPMBUILDDIR/*RPMS/ -type f -newer $rpmspec
-    fi
-else
-    echo "Prepared sources for $version-$release $rpmspec are in $RPMBUILDDIR/SOURCES/ - use like:"
-    echo "rpmbuild --define '_topdir $RPMBUILDDIR' -ba $rpmspec --clean"
-fi
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/contrib/packaging/buildrpm	Sat May 12 10:41:08 2018 -0700
@@ -0,0 +1,162 @@
+#!/bin/bash -e
+#
+# Build a Mercurial RPM from the current repo
+#
+# Tested on
+# - Fedora 20
+# - CentOS 5
+# - centOS 6
+
+. $(dirname $0)/packagelib.sh
+
+BUILD=1
+RPMBUILDDIR="$PWD/rpmbuild"
+
+while [ "$1" ]; do
+    case "$1" in
+    --prepare )
+        shift
+        BUILD=
+        ;;
+    --withpython | --with-python)
+        shift
+        PYTHONVER=2.7.14
+        PYTHONMD5=cee2e4b33ad3750da77b2e85f2f8b724
+        ;;
+    --rpmbuilddir )
+        shift
+        RPMBUILDDIR="$1"
+        shift
+        ;;
+    * )
+        echo "Invalid parameter $1!" 1>&2
+        exit 1
+        ;;
+    esac
+done
+
+cd "`dirname $0`/../.."
+
+specfile=$PWD/contrib/packaging/mercurial.spec
+if [ ! -f $specfile ]; then
+    echo "Cannot find $specfile!" 1>&2
+    exit 1
+fi
+
+if [ ! -d .hg ]; then
+    echo 'You are not inside a Mercurial repository!' 1>&2
+    exit 1
+fi
+
+gethgversion
+
+# TODO: handle distance/node set, and type set
+
+if [ -z "$type" ] ; then
+   release=1
+else
+    release=0.9_$type
+fi
+
+if [ -n "$distance" ] ; then
+    release=$release+$distance_$node
+fi
+
+if [ "$PYTHONVER" ]; then
+    release=$release+$PYTHONVER
+    RPMPYTHONVER=$PYTHONVER
+else
+    RPMPYTHONVER=%{nil}
+fi
+
+mkdir -p $RPMBUILDDIR/{SOURCES,BUILD,SRPMS,RPMS}
+$HG archive -t tgz $RPMBUILDDIR/SOURCES/mercurial-$version-$release.tar.gz
+if [ "$PYTHONVER" ]; then
+(
+    mkdir -p build
+    cd build
+    PYTHON_SRCFILE=Python-$PYTHONVER.tgz
+    [ -f $PYTHON_SRCFILE ] || curl -Lo $PYTHON_SRCFILE http://www.python.org/ftp/python/$PYTHONVER/$PYTHON_SRCFILE
+    if [ "$PYTHONMD5" ]; then
+        echo "$PYTHONMD5 $PYTHON_SRCFILE" | md5sum -w -c
+    fi
+    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
+    DOCUTILSMD5=`sed -ne "s/^%global docutilsmd5 //p" $specfile`
+    if [ "$DOCUTILSMD5" ]; then
+        echo "$DOCUTILSMD5 $DOCUTILS_SRCFILE" | md5sum -w -c
+    fi
+    ln -f $DOCUTILS_SRCFILE $RPMBUILDDIR/SOURCES/$DOCUTILS_SRCFILE
+)
+fi
+
+mkdir -p $RPMBUILDDIR/SPECS
+rpmspec=$RPMBUILDDIR/SPECS/mercurial.spec
+
+sed -e "s,^Version:.*,Version: $version," \
+    -e "s,^Release:.*,Release: $release," \
+    $specfile > $rpmspec
+
+echo >> $rpmspec
+echo "%changelog" >> $rpmspec
+
+if echo $version | grep '+' > /dev/null 2>&1; then
+    latesttag="`echo $version | sed -e 's/+.*//'`"
+    $HG log -r .:"$latesttag" -fM \
+        --template '{date|hgdate}\t{author}\t{desc|firstline}\n' | python -c '
+import sys, time
+
+def datestr(date, format):
+    return time.strftime(format, time.gmtime(float(date[0]) - date[1]))
+
+changelog = []
+for l in sys.stdin.readlines():
+    tok = l.split("\t")
+    hgdate = tuple(int(v) for v in tok[0].split())
+    changelog.append((datestr(hgdate, "%F"), tok[1], hgdate, tok[2]))
+prevtitle = ""
+for l in sorted(changelog, reverse=True):
+    title = "* %s %s" % (datestr(l[2], "%a %b %d %Y"), l[1])
+    if prevtitle != title:
+        prevtitle = title
+        print
+        print title
+    print "- %s" % l[3].strip()
+' >> $rpmspec
+
+else
+
+    $HG log \
+         --template '{date|hgdate}\t{author}\t{desc|firstline}\n' \
+         .hgtags | python -c '
+import sys, time
+
+def datestr(date, format):
+    return time.strftime(format, time.gmtime(float(date[0]) - date[1]))
+
+for l in sys.stdin.readlines():
+    tok = l.split("\t")
+    hgdate = tuple(int(v) for v in tok[0].split())
+    print "* %s %s\n- %s" % (datestr(hgdate, "%a %b %d %Y"), tok[1], tok[2])
+' >> $rpmspec
+
+fi
+
+sed -i \
+    -e "s/^%define withpython.*$/%define withpython $RPMPYTHONVER/" \
+    $rpmspec
+
+if [ "$BUILD" ]; then
+    rpmbuild --define "_topdir $RPMBUILDDIR" -ba $rpmspec --clean
+    if [ $? = 0 ]; then
+        echo
+        echo "Built packages for $version-$release:"
+        find $RPMBUILDDIR/*RPMS/ -type f -newer $rpmspec
+    fi
+else
+    echo "Prepared sources for $version-$release $rpmspec are in $RPMBUILDDIR/SOURCES/ - use like:"
+    echo "rpmbuild --define '_topdir $RPMBUILDDIR' -ba $rpmspec --clean"
+fi
--- a/contrib/packaging/dockerrpm	Sat May 12 10:38:36 2018 -0700
+++ b/contrib/packaging/dockerrpm	Sat May 12 10:41:08 2018 -0700
@@ -13,7 +13,7 @@
 initcontainer $PLATFORM
 
 RPMBUILDDIR=$ROOTDIR/packages/$PLATFORM
-contrib/buildrpm --rpmbuilddir $RPMBUILDDIR --prepare $*
+contrib/packaging/buildrpm --rpmbuilddir $RPMBUILDDIR --prepare $*
 
 DSHARED=/mnt/shared
 $DOCKER run -e http_proxy -e https_proxy -u $DBUILDUSER --rm -v $RPMBUILDDIR:$DSHARED $CONTAINER \