Browse Source

build: Allow running scripts from outside the source tree

Guillem Jover 9 years ago
parent
commit
1e61694dcd
2 changed files with 10 additions and 4 deletions
  1. 1 1
      debian/rules
  2. 9 3
      run-script

+ 1 - 1
debian/rules

@@ -15,7 +15,7 @@ dpkg_buildflags = \
 	$(if $(call cc_version_lt,4.9),$(hardening_old)) \
 	DEB_CFLAGS_MAINT_APPEND="$(WFLAGS)" \
 	DEB_CXXFLAGS_MAINT_APPEND="$(WFLAGS)" \
-	$(CURDIR)/run-script perl $(CURDIR)/scripts/dpkg-buildflags.pl
+	$(CURDIR)/run-script perl scripts/dpkg-buildflags.pl
 
 # These are used for cross-compiling and for saving the configure script
 # from having to guess our platform (since we know it already)

+ 9 - 3
run-script

@@ -5,9 +5,15 @@ top_srcdir=`dirname $0`
 # To avoid using «readlink -f» or «realpath» we just change into the
 # desired directory and work from there.
 cd "$top_srcdir"
+cwd=`pwd`
+cd "$OLDPWD"
 
 # Set up the environment, to use local perl modules and data files.
-export PERL5LIB=`pwd`/scripts:`pwd`/dselect/methods
-export DPKG_DATADIR=`pwd`
+export PERL5LIB=$cwd/scripts:$cwd/dselect/methods
+export DPKG_DATADIR=$cwd
 
-exec "$@"
+interp=$1
+script=$2
+shift 2
+
+exec $interp "$cwd/$script" "$@"