changeset 38055:917f635b5c6a

packaging: make packaging scripts less reliant on pwd The scripts currently assume they are executed from the repo root. This feels like an arbitrary restriction. Let's fix that. Differential Revision: https://phab.mercurial-scm.org/D3551
author Gregory Szorc <gregory.szorc@gmail.com>
date Sat, 12 May 2018 12:27:51 -0700
parents e5d2248dcc39
children 768bd75835d7
files contrib/packaging/builddeb contrib/packaging/dockerdeb contrib/packaging/dockerrpm
diffstat 3 files changed, 7 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/contrib/packaging/builddeb	Sat May 12 10:57:04 2018 -0700
+++ b/contrib/packaging/builddeb	Sat May 12 12:27:51 2018 -0700
@@ -6,6 +6,8 @@
 
 . $(dirname $0)/packagelib.sh
 
+ROOTDIR=$(cd $(dirname $0)/../.. > /dev/null; pwd)
+
 BUILD=1
 CLEANUP=1
 DISTID=`(lsb_release -is 2> /dev/null | tr '[:upper:]' '[:lower:]') || echo debian`
@@ -73,7 +75,7 @@
         exit 1
     fi
 
-    cp -r "$PWD"/contrib/packaging/debian debian
+    cp -r "$ROOTDIR"/contrib/packaging/debian debian
 
     sed -i.tmp "s/__VERSION__/$debver/" $changelog
     sed -i.tmp "s/__DATE__/$(date --rfc-2822)/" $changelog
@@ -82,7 +84,7 @@
 
     # remove the node from the version string
     SRCFILE="mercurial_$(echo $debver | sed "s,-$node,,").orig.tar.gz"
-    "$PWD/hg" archive $SRCFILE
+    "$ROOTDIR/hg" archive $SRCFILE
     mv $SRCFILE ..
     debuild -us -uc -i -I $DEBFLAGS
     if [ $? != 0 ]; then
--- a/contrib/packaging/dockerdeb	Sat May 12 10:57:04 2018 -0700
+++ b/contrib/packaging/dockerdeb	Sat May 12 12:27:51 2018 -0700
@@ -20,13 +20,13 @@
 # debuild only appears to be able to save built debs etc to .., so we
 # have to share the .. of the current directory with the docker
 # container and hope it's writable. Whee.
-dn=$(basename $PWD)
+dn=$(basename $ROOTDIR)
 
 if [ $(uname) = "Darwin" ] ; then
     $DOCKER run -u $DBUILDUSER --rm -v $PWD/..:/mnt $CONTAINER \
             sh -c "cd /mnt/$dn && make clean && make local"
 fi
-$DOCKER run -u $DBUILDUSER --rm -v $PWD/..:/mnt $CONTAINER \
+$DOCKER run -u $DBUILDUSER --rm -v $ROOTDIR/..:/mnt $CONTAINER \
   sh -c "cd /mnt/$dn && DEB_BUILD_OPTIONS='${DEB_BUILD_OPTIONS:=}' contrib/packaging/builddeb --build --distid $DISTID --codename $CODENAME $@"
 contrib/packaging/builddeb --cleanup --distid $DISTID --codename $CODENAME
 if [ $(uname) = "Darwin" ] ; then
--- a/contrib/packaging/dockerrpm	Sat May 12 10:57:04 2018 -0700
+++ b/contrib/packaging/dockerrpm	Sat May 12 12:27:51 2018 -0700
@@ -13,7 +13,7 @@
 initcontainer $PLATFORM
 
 RPMBUILDDIR=$ROOTDIR/packages/$PLATFORM
-contrib/packaging/buildrpm --rpmbuilddir $RPMBUILDDIR --prepare $*
+$ROOTDIR/contrib/packaging/buildrpm --rpmbuilddir $RPMBUILDDIR --prepare $*
 
 DSHARED=/mnt/shared
 $DOCKER run -e http_proxy -e https_proxy -u $DBUILDUSER --rm -v $RPMBUILDDIR:$DSHARED $CONTAINER \