From 4fed488c35ab12f856384c03892e3cfed20f143a Mon Sep 17 00:00:00 2001 From: Johannes 'josch' Schauer Date: Wed, 8 Jan 2020 15:33:49 +0100 Subject: [PATCH] when re-execing itself, keep Devel::Cover options --- coverage.sh | 29 +---------------------------- mmdebstrap | 20 +++++++++++++++++--- 2 files changed, 18 insertions(+), 31 deletions(-) diff --git a/coverage.sh b/coverage.sh index 09c5540..42856ab 100755 --- a/coverage.sh +++ b/coverage.sh @@ -49,7 +49,7 @@ if [ ! -e shared/mmdebstrap ] || [ mmdebstrap -nt shared/mmdebstrap ]; then fi starttime= -total=123 +total=115 skipped=0 runtests=0 i=1 @@ -1851,33 +1851,6 @@ END ./run_null.sh runtests=$((runtests+1)) fi - # Devel::Cover doesn't survive mmdebstrap re-exec-ing itself - # with fakechroot, thus, we do an additional run where we - # explicitly run mmdebstrap with fakechroot from the start - if [ "$mode" = "fakechroot" ]; then - print_header "mode=$mode,variant=$variant: create tarball (ver 2)" - cat << END > shared/test.sh -#!/bin/sh -set -eu -export LC_ALL=C.UTF-8 -[ "\$(id -u)" -eq 0 ] && ! id -u user > /dev/null 2>&1 && adduser --gecos user --disabled-password user -prefix= -[ "\$(id -u)" -eq 0 ] && prefix="runuser -u user --" -\$prefix fakechroot fakeroot $CMD --mode=$mode --variant=$variant $DEFAULT_DIST /tmp/debian-chroot.tar $mirror -{ tar -tf /tmp/debian-chroot.tar; - printf "./etc/ld.so.cache\n./var/cache/ldconfig/\n"; - [ "$variant" != "essential" ] && printf "./etc/.pwd.lock\n"; -} | sort | diff -u "./$variant.txt" - -rm /tmp/debian-chroot.tar -END - if [ "$HAVE_QEMU" = "yes" ]; then - ./run_qemu.sh - runtests=$((runtests+1)) - else - ./run_null.sh - runtests=$((runtests+1)) - fi - fi done # some variants are equal and some are strict superset of the last # special case of the buildd variant: nothing is a superset of it diff --git a/mmdebstrap b/mmdebstrap index b7607bd..debb03f 100755 --- a/mmdebstrap +++ b/mmdebstrap @@ -84,6 +84,8 @@ my @devfiles = ( # 3 -> debug output my $verbosity_level = 1; +my $is_covering = !!(eval 'Devel::Cover::get_coverage()'); + sub debug { if ($verbosity_level < 3) { return; @@ -977,7 +979,11 @@ sub run_hooks($$) { # we execute ourselves under sh to avoid having to # implement a clever parser of the quoting used in $script # for the filenames - exec 'sh', '-c', "$PROGRAM_NAME --hook-helper \"\$1\" \"\$2\" \"\$3\" \"\$4\" \"\$5\" $script", + my $prefix = ""; + if($is_covering) { + $prefix = "$EXECUTABLE_NAME -MDevel::Cover=-silent,-nogcov "; + } + exec 'sh', '-c', "$prefix$PROGRAM_NAME --hook-helper \"\$1\" \"\$2\" \"\$3\" \"\$4\" \"\$5\" $script", 'exec', $options->{root}, $options->{mode}, $name, (defined $options->{qemu} ? "qemu-$options->{qemu}" : 'env', $verbosity_level); } waitpid($pid, 0); @@ -2299,7 +2305,11 @@ sub main() { } elsif (system('fakechroot --version>/dev/null') == 0) { # the next fallback is fakechroot # exec ourselves again but within fakechroot - exec 'fakechroot', 'fakeroot', $PROGRAM_NAME, @ARGVORIG; + my @prefix = (); + if($is_covering) { + @prefix = ($EXECUTABLE_NAME, '-MDevel::Cover=-silent,-nogcov'); + } + exec 'fakechroot', 'fakeroot', @prefix, $PROGRAM_NAME, @ARGVORIG; } elsif (system('proot --version>/dev/null') == 0) { # and lastly, proot $options->{mode} = 'proot'; @@ -2322,7 +2332,11 @@ sub main() { error "need working fakechroot binary"; } else { # exec ourselves again but within fakechroot - exec 'fakechroot', 'fakeroot', $PROGRAM_NAME, @ARGVORIG; + my @prefix = (); + if($is_covering) { + @prefix = ($EXECUTABLE_NAME, '-MDevel::Cover=-silent,-nogcov'); + } + exec 'fakechroot', 'fakeroot', @prefix, $PROGRAM_NAME, @ARGVORIG; } } elsif ($options->{mode} eq 'unshare') { if (!test_unshare(1)) {