D3551: packaging: make packaging scripts less reliant on pwd

indygreg (Gregory Szorc) phabricator at mercurial-scm.org
Sat May 12 17:19:32 EDT 2018


indygreg created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  The scripts currently assume they are executed from the repo root.
  This feels like an arbitrary restriction. Let's fix that.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D3551

AFFECTED FILES
  contrib/packaging/builddeb
  contrib/packaging/dockerdeb
  contrib/packaging/dockerrpm

CHANGE DETAILS

diff --git a/contrib/packaging/dockerrpm b/contrib/packaging/dockerrpm
--- a/contrib/packaging/dockerrpm
+++ b/contrib/packaging/dockerrpm
@@ -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 \
diff --git a/contrib/packaging/dockerdeb b/contrib/packaging/dockerdeb
--- a/contrib/packaging/dockerdeb
+++ b/contrib/packaging/dockerdeb
@@ -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
diff --git a/contrib/packaging/builddeb b/contrib/packaging/builddeb
--- a/contrib/packaging/builddeb
+++ b/contrib/packaging/builddeb
@@ -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,16 +75,16 @@
         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
     sed -i.tmp "s/__CODENAME__/$CODENAME/" $changelog
     rm $changelog.tmp
 
     # 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



To: indygreg, #hg-reviewers
Cc: mercurial-devel


More information about the Mercurial-devel mailing list