experimental old/new eatmydata support switch
authorThorsten Glaser <t.glaser@tarent.de>
Mon, 17 Nov 2014 13:53:16 +0000 (14:53 +0100)
committerThorsten Glaser <t.glaser@tarent.de>
Mon, 17 Nov 2014 13:53:16 +0000 (14:53 +0100)
mksh/debian-dev/c

index af38003..abcc13d 100644 (file)
 # c lenny/i386 DEB_BUILD_OPTIONS=parallel=4 linux32 --build foo*.dsc
 
 unset LANGUAGE
+export LC_ALL=C
 DIST=$1
-eatmydata=eatmydata
-case $DIST {
-(sarge|sarge/i386|etch|etch/i386|etch/amd64)
-       eatmydata=
+
+# attempt to divine which eatmydata method to use; cf. #765579
+# parts taken from MirBSD-contrib pbuilderrc
+BASEPATH=/var/cache/pbuilder/base.cow-${DIST%/*}
+ARCHSUFFIX=
+if [[ $DIST = */* ]]; then
+       build_ARCHITECTURE=$(dpkg --print-architecture)
+       [[ ${DIST##*/} = "$build_ARCHITECTURE" ]] || ARCHSUFFIX=-${DIST##*/}
+fi
+BASEPATH+=$ARCHSUFFIX${CUSTOM:+-$CUSTOM}/
+# look into the chroot
+if [[ -e ${BASEPATH}usr/lib/libeatmydata/libeatmydata.so ]]; then
+       # know old method (26-2)
+       eatmydata=LD_PRELOAD=/usr/lib/libeatmydata/libeatmydata.so
+else
+       # assume new method (82-3)
+       eatmydata=LD_PRELOAD=libeatmydata.so
+fi
+# disable for some distros without either
+case ${DIST%/*} {
+(sarge|sarge-*|etch|etch-*)
+       eatmydata=LD_PRELOAD=
        ;;
 }
-eatmydata= #765579
+
+# construct command line
 set -A cmd env "DIST=$DIST" LANG=C LC_CTYPE=C LC_NUMERIC=C \
     LC_TIME=C LC_COLLATE=C LC_MONETARY=C LC_MESSAGES=C LC_PAPER=C \
     LC_NAME=C LC_ADDRESS=C LC_TELEPHONE=C LC_MEASUREMENT=C \