This is an automated email from the git hooks/post-receive script. nomeata pushed a commit to branch master in repository devscripts.
commit 02a6fa0a23a2cb879858b14ca206481bc50ed298 Author: Joachim Breitner <[email protected]> Date: Mon Mar 17 23:36:47 2014 +0100 Reimplement Excluded-Files for zipfiles by calling "zip -d" to remove the files from the zipfile. --- scripts/uscan.pl | 61 +++++++++++++++++++++++++++++++++++++------------------- test/test_uscan | 16 +++++++++++---- 2 files changed, 52 insertions(+), 25 deletions(-) diff --git a/scripts/uscan.pl b/scripts/uscan.pl index 932d452..7ece0e3 100755 --- a/scripts/uscan.pl +++ b/scripts/uscan.pl @@ -1547,33 +1547,52 @@ EOF && $data->{'format'} =~ m{^$okformat/?$} && $data->{'files-excluded'}) { + my @excluded = ($data->{"files-excluded"} =~ /(?:\A|\G\s+)((?:\\.|[^\\\s])+)/g); + # un-escape + @excluded = map { s/\\(.)/$1/g; s?/+$??; $_ } @excluded; + + # get list of files contained in the tarball + my @files; if ( $newfile_base =~ /^(.*)\.(zip|jar)$/ ) { - uscan_warn "$progname: $destdir/$newfile_base is not a tarfile, cannot exclude files from it. Consider running uscan with \"--repack\"\n"; + my $files; + spawn(exec => ['zipinfo','-1',"$destdir/$newfile_base"], + to_string => \$files, + wait_child => 1); + @files = split /^/, $files; + chomp @files; } else { - my @excluded = ($data->{"files-excluded"} =~ /(?:\A|\G\s+)((?:\\.|[^\\\s])+)/g); - # un-escape - @excluded = map { s/\\(.)/$1/g; s?/+$??; $_ } @excluded; - - # get list of files contained in the tarball my $files; spawn(exec => ['tar', '-t', '-a', '-f', "$destdir/$newfile_base"], to_string => \$files, wait_child => 1); + @files = split /^/, $files; + chomp @files; + } - my @to_delete; - for my $filename (split /^/, $files) { - chomp($filename); - $filename =~ s!/+$!!; - my $do_exclude = 0; - for my $exclude (@excluded) { - if (Text::Glob::match_glob($exclude, $filename)) { - $do_exclude = 1; - } - } - push @to_delete, $filename if $do_exclude; + # find out what to delete + my @to_delete; + for my $filename (@files) { + my $do_exclude = 0; + for my $exclude (@excluded) { + $do_exclude ||= + Text::Glob::match_glob($exclude, $filename) || + Text::Glob::match_glob($exclude."/", $filename) || + Text::Glob::match_glob($exclude."/*", $filename); } - - if (@to_delete) { + push @to_delete, $filename if $do_exclude; + } + # ensure files are mentioned before the directory they live in + # (otherwise tar complains) + @to_delete = sort {$b cmp $a} @to_delete; + + # actually delete something + if (@to_delete) { + if ( $newfile_base =~ /^(.*)\.(zip|jar)$/ ) { + my $newfile_base_dfsg = "$1${excludesuffix}.$2" ; + copy "$destdir/$newfile_base", "$destdir/$newfile_base_dfsg"; + spawn(exec => ['zip','-d','--no-wild',"$destdir/$newfile_base_dfsg", @to_delete], + wait_child => 1); + } else { my $newfile_base_dfsg = "${pkg}_${newversion}${excludesuffix}.orig.tar" ; $symlink = 'files-excluded'; # prevent symlinking or renaming @@ -1588,9 +1607,9 @@ EOF ,wait_child => 1); my $suffix = compression_get_property($comp, "file_ext"); compress_archive("$fname", "$destdir/$newfile_base_dfsg.$suffix", $comp); - } else { - print "-- No files to be excluded -- no need for repacking.\n" if $verbose; } + } else { + print "-- No files to be excluded -- no need for repacking.\n" if $verbose; } } } diff --git a/test/test_uscan b/test/test_uscan index 6aab953..ac548b5 100755 --- a/test/test_uscan +++ b/test/test_uscan @@ -26,7 +26,6 @@ fi cleanup(){ kill -9 $(cat $TMPDIR/repo/pid) rm -rf $TMPDIR - } trap cleanup 1 2 3 13 15 @@ -209,13 +208,22 @@ END touch $TMPDIR/repo/exclude-dir/file ( cd $TMPDIR/repo ; - zip $PKG-1.zip * ; + zip -r $PKG-1.zip * ; python -m SimpleHTTPServer $PORT & echo $! > pid ) - OUTPUT=$( (cd $TMPDIR/$PKG ; $COMMAND) 2>&1 | fgrep 'cannot exclude files from it') + OUTPUT=$( (cd $TMPDIR/$PKG ; $COMMAND) 2>&1) assertTrue 'zipfile not downloaded' "[ -f $TMPDIR/$PKG-1.zip ]" - assertNotNull 'Expected error message missing' "$OUTPUT" + assertTrue 'zipfile not copied to +dfsg' "[ -f $TMPDIR/$PKG-1+dfsg.zip ]" + CONTENTS="$(zipinfo -1 $TMPDIR/$PKG-1+dfsg.zip)" + assertTrue 'file that must be present is excluded in the zip file' \ + $(containsName "$CONTENTS" include-this) + assertFalse 'file that must be excluded is present in the zip file' \ + $(containsName "$CONTENTS" exclude-this) + assertFalse "dir that must be excluded is present in the zip file" \ + $(containsName "$CONTENTS" exclude-dir) + assertFalse "path with whitespace that must be excluded is present" \ + $(containsName "$CONTENTS" "; echo baz; #/") cleanup -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/collab-maint/devscripts.git _______________________________________________ devscripts-devel mailing list [email protected] http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/devscripts-devel
