[devscripts] 01/02: uscan: Use compression_guess_from_filename instead of custom regexes
Joachim Breitner
nomeata at moszumanska.debian.org
Sun Mar 16 11:47:08 UTC 2014
This is an automated email from the git hooks/post-receive script.
nomeata pushed a commit to branch master
in repository devscripts.
commit 883c82b99dd0642928585a16aa14f68e75eee319
Author: Joachim Breitner <nomeata at debian.org>
Date: Sun Mar 16 12:16:01 2014 +0100
uscan: Use compression_guess_from_filename instead of custom regexes
---
scripts/uscan.pl | 87 +++++++++++++++++++++++++-------------------------------
test/test_uscan | 1 +
2 files changed, 39 insertions(+), 49 deletions(-)
diff --git a/scripts/uscan.pl b/scripts/uscan.pl
index 5b786ae..80445aa 100755
--- a/scripts/uscan.pl
+++ b/scripts/uscan.pl
@@ -34,7 +34,7 @@ use List::Util qw/first/;
use filetest 'access';
use Getopt::Long qw(:config gnu_getopt);
use lib '/usr/share/devscripts';
-use Devscripts::Compression qw/compression_get_file_extension_regex compression_get_property/;
+use Devscripts::Compression qw/compression_guess_from_filename compression_get_file_extension_regex compression_get_property/;
use Devscripts::Versort;
use Text::ParseWords;
BEGIN {
@@ -1598,59 +1598,48 @@ EOF
}
}
- my @renames = (
- [qr/\.(tar\.gz|tgz)$/, 'gz'],
- [qr/\.(tar\.bz2|tbz2?)$/, 'bz2'],
- [qr/\.tar\.lzma|tlz(?:ma?)?$/, 'lzma'],
- [qr/\.(tar\.xz|txz)$/, 'xz'],
- );
-
- my ($renamed_base);
- foreach my $pair (@renames) {
- if ($newfile_base !~ $pair->[0]) {
- next;
- }
-
- my ($pattern, $suffix) = @{$pair};
- $renamed_base = "${pkg}_${newversion}.orig.tar.$suffix";
+ my $compression = compression_guess_from_filename($newfile_base);
+ unless ($compression) {
+ uscan_die("Cannot determine compression method of $newfile_base");
+ }
+ my $suffix = compression_get_property($compression, "file_ext");
+ my $renamed_base = "${pkg}_${newversion}.orig.tar.$suffix";
+ if ($symlink eq 'symlink') {
+ symlink $newfile_base, "$destdir/$renamed_base";
+ } elsif ($symlink eq 'rename') {
+ move "$destdir/$newfile_base", "$destdir/$renamed_base";
+ }
+ if ($verbose) {
+ print "-- Successfully downloaded updated package $newfile_base\n";
if ($symlink eq 'symlink') {
- symlink $newfile_base, "$destdir/$renamed_base";
+ print " and symlinked $renamed_base to it\n";
} elsif ($symlink eq 'rename') {
- move "$destdir/$newfile_base", "$destdir/$renamed_base";
+ print " and renamed it as $renamed_base\n";
+ } elsif ($symlink eq 'files-excluded') {
+ print " and removed files from it in ${pkg}_${newversion}${excludesuffix}.orig.tar.$suffix\n";
}
- if ($verbose) {
- print "-- Successfully downloaded updated package $newfile_base\n";
- if ($symlink eq 'symlink') {
- print " and symlinked $renamed_base to it\n";
- } elsif ($symlink eq 'rename') {
- print " and renamed it as $renamed_base\n";
- } elsif ($symlink eq 'files-excluded') {
- print " and removed files from it in ${pkg}_${newversion}${excludesuffix}.orig.tar.$suffix\n";
- }
- } elsif ($dehs) {
- my $msg = "Successfully downloaded updated package $newfile_base";
- $dehs_tags{'target'} = "$renamed_base";
- if ($symlink eq 'symlink') {
- $msg .= " and symlinked $renamed_base to it";
- } elsif ($symlink eq 'rename') {
- $msg .= " and renamed it as $renamed_base";
- } elsif ($symlink eq 'files-excluded') {
- $msg .= " and removed files from it in ${pkg}_${newversion}${excludesuffix}.orig.tar.$suffix\n";
- } else {
- $dehs_tags{'target'} = $newfile_base;
- }
- dehs_msg($msg);
+ } elsif ($dehs) {
+ my $msg = "Successfully downloaded updated package $newfile_base";
+ $dehs_tags{'target'} = "$renamed_base";
+ if ($symlink eq 'symlink') {
+ $msg .= " and symlinked $renamed_base to it";
+ } elsif ($symlink eq 'rename') {
+ $msg .= " and renamed it as $renamed_base";
+ } elsif ($symlink eq 'files-excluded') {
+ $msg .= " and removed files from it in ${pkg}_${newversion}${excludesuffix}.orig.tar.$suffix\n";
} else {
- print "$pkg: Successfully downloaded updated package $newfile_base\n";
- if ($symlink eq 'symlink') {
- print " and symlinked $renamed_base to it\n";
- } elsif ($symlink eq 'rename') {
- print " and renamed it as $renamed_base\n";
- } elsif ($symlink eq 'files-excluded') {
- print " and removed files from it in ${pkg}_${newversion}${excludesuffix}.orig.tar.$suffix\n";
- }
+ $dehs_tags{'target'} = $newfile_base;
+ }
+ dehs_msg($msg);
+ } else {
+ print "$pkg: Successfully downloaded updated package $newfile_base\n";
+ if ($symlink eq 'symlink') {
+ print " and symlinked $renamed_base to it\n";
+ } elsif ($symlink eq 'rename') {
+ print " and renamed it as $renamed_base\n";
+ } elsif ($symlink eq 'files-excluded') {
+ print " and removed files from it in ${pkg}_${newversion}${excludesuffix}.orig.tar.$suffix\n";
}
- last;
}
# Do whatever the user wishes to do
diff --git a/test/test_uscan b/test/test_uscan
index cb0020e..64293fa 100755
--- a/test/test_uscan
+++ b/test/test_uscan
@@ -78,6 +78,7 @@ END
# Test matching with escaped characters
printf ' ;\ echo\ baz;\ #\n' >> $TMPDIR/$PKG/debian/copyright
+
mkdir -p $TMPDIR/repo
touch $TMPDIR/repo/include-this
touch $TMPDIR/repo/exclude-this
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/collab-maint/devscripts.git
More information about the devscripts-devel
mailing list