diff contrib/packaging/builddeb @ 38013: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 e51c91c14a07
children f9c5f7b048b0
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