[devscripts] 01/01: Update scripts to use Dpkg::Compression's compression_get_file_extension_regex().

James McCoy jamessan at debian.org
Tue Dec 10 01:41:45 UTC 2013


This is an automated email from the git hooks/post-receive script.

jamessan pushed a commit to branch master
in repository devscripts.

commit 12fa0d3990f307ff0946a8c0f1b7e2845f7dca3b
Author: James McCoy <jamessan at debian.org>
Date:   Mon Dec 9 20:39:29 2013 -0500

    Update scripts to use Dpkg::Compression's compression_get_file_extension_regex().
    
    This is being done via a new Devscripts::Compression module simply to
    ensure we're backward compatible with older Dpkg::Compression versions
    and to avoid repeating the same code.  Once Dpkg::Compression 1.02 is
    old enough, Devscripts::Compression can be removed and the imports
    updated accordingly.
    
    Signed-off-by: James McCoy <jamessan at debian.org>
---
 Devscripts/Compression.pm | 36 ++++++++++++++++++++++++++++++++++++
 debian/changelog          |  1 +
 scripts/debchange.pl      |  6 ++++--
 scripts/debcheckout.pl    |  6 ++++--
 scripts/debdiff.pl        |  8 +++++---
 scripts/debuild.pl        |  6 ++++--
 scripts/dget.pl           |  6 ++++--
 7 files changed, 58 insertions(+), 11 deletions(-)

diff --git a/Devscripts/Compression.pm b/Devscripts/Compression.pm
new file mode 100644
index 0000000..65080e8
--- /dev/null
+++ b/Devscripts/Compression.pm
@@ -0,0 +1,36 @@
+# Copyright James McCoy <jamessan at debian.org> 2013.
+# Modifications copyright 2002 Julian Gilbey <jdg at debian.org>
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+package Devscripts::Compression;
+
+use Dpkg::Compression;
+use Exporter qw(import);
+
+our @EXPORT = (@Dpkg::Compression::EXPORT, qw(compression_get_file_extension_regex));
+
+eval {
+    Dpkg::Compression->VERSION(1.02);
+    1;
+} or do {
+    # Ensure we have compression_get_file_extension_regex, regardless of the
+    # version of Dpkg::Compression to ease backporting.
+    *{'Devscripts::Compression::compression_get_file_extension_regex'} = sub
+    {
+	return $compression_re_file_ext;
+    };
+};
+
+1;
diff --git a/debian/changelog b/debian/changelog
index 33cbfbd..5edc89e 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -14,6 +14,7 @@ devscripts (2.13.6) UNRELEASED; urgency=medium
   * build-rdeps: Only match against package names instead of any substring of
     Build-Depends(-Indep).  (Closes: #649165)
   * debchange: Correct description of -e in --help output.  (Closes: #712030)
+  * Update scripts to use Dpkg::Compression's compression_get_file_extension_regex().
 
   [ Louis Bettens ]
   * debchange, mass-bug, bts: Replace call to date -R with strftime().
diff --git a/scripts/debchange.pl b/scripts/debchange.pl
index 69f0bd6..dd69bf1 100755
--- a/scripts/debchange.pl
+++ b/scripts/debchange.pl
@@ -39,7 +39,7 @@ use Getopt::Long qw(:config gnu_getopt);
 use File::Copy;
 use File::Basename;
 use Cwd;
-use Dpkg::Compression;
+use Devscripts::Compression;
 use Dpkg::Vendor qw(get_current_vendor);
 use lib '/usr/share/devscripts';
 use Devscripts::Debbugs;
@@ -57,6 +57,8 @@ my $modified_conf_msg;
 my %env;
 my $CHGLINE;  # used by the format O section at the end
 
+my $compression_re = compression_get_file_extension_regex();
+
 my $lpdc_broken;
 
 sub have_lpdc {
@@ -1640,7 +1642,7 @@ if ((basename(cwd()) =~ m%^\Q$PACKAGE\E-\Q$UVERSION\E$%) &&
 	}
 	# And check whether a new orig tarball exists
 	my @origs = glob("../$PACKAGE\_$new_uversion.*");
-	my $num_origs = grep { /^..\/\Q$PACKAGE\E_\Q$new_uversion\E\.orig\.tar\.$compression_re_file_ext$/ } @origs;
+	my $num_origs = grep { /^..\/\Q$PACKAGE\E_\Q$new_uversion\E\.orig\.tar\.$compression_re$/ } @origs;
 	if ($num_origs == 0) {
 	    warn "$progname warning: no orig tarball found for the new version.\n";
 	}
diff --git a/scripts/debcheckout.pl b/scripts/debcheckout.pl
index 53a3af9..366113f 100755
--- a/scripts/debcheckout.pl
+++ b/scripts/debcheckout.pl
@@ -247,12 +247,14 @@ use File::Basename;
 use File::Copy qw/copy/;
 use File::Temp qw/tempdir/;
 use Cwd;
-use Dpkg::Compression;
+use Devscripts::Compression;
 use lib '/usr/share/devscripts';
 use Devscripts::Versort;
 
 my @files = ();	  # files to checkout
 
+my $compression_re = compression_get_file_extension_regex();
+
 # <snippet from="bts.pl">
 # <!-- TODO we really need to factor out in a Perl module the
 #      configuration file parsing code -->
@@ -343,7 +345,7 @@ sub find_repo($$) {
 	} elsif ($line =~ /^Version:\s*(.*)$/i) {
 	    $version = $1;
 	    ($nonepoch_version = $version) =~ s/^\d+://;
-	} elsif ($line =~ /^ [a-f0-9]{32} \d+ (\S+)(?:_\Q$nonepoch_version\E|\.orig)\.tar\.$compression_re_file_ext$/) {
+	} elsif ($line =~ /^ [a-f0-9]{32} \d+ (\S+)(?:_\Q$nonepoch_version\E|\.orig)\.tar\.$compression_re$/) {
 	    $origtgz_name = $1;
 	} elsif ($line =~ /^$/) {
 	    push (@repos, [$version, $type, $url, $origtgz_name])
diff --git a/scripts/debdiff.pl b/scripts/debdiff.pl
index 6dde323..0ebdda4 100755
--- a/scripts/debdiff.pl
+++ b/scripts/debdiff.pl
@@ -18,7 +18,7 @@ use 5.006_000;
 use strict;
 use Cwd;
 use Dpkg::IPC;
-use Dpkg::Compression;
+use Devscripts::Compression;
 use File::Copy qw(cp move);
 use File::Basename;
 use File::Spec;
@@ -39,6 +39,8 @@ my $modified_conf_msg;
 my $exit_status = 0;
 my $dummyname = "---DUMMY---";
 
+my $compression_re = compression_get_file_extension_regex();
+
 sub usage {
     print <<"EOF";
 Usage: $progname [option]
@@ -501,7 +503,7 @@ elsif ($type eq 'dsc') {
 		if ($file =~ /\.diff\.gz$/) {
 		    $diffs[$i] = cwd() . '/' . $file;
 		}
-		elsif ($file =~ /((?:\.orig)?\.tar\.$compression_re_file_ext|\.git)$/) {
+		elsif ($file =~ /((?:\.orig)?\.tar\.$compression_re|\.git)$/) {
 		    $origs[$i] = $file;
 		}
 	    } else {
@@ -629,7 +631,7 @@ elsif ($type eq 'dsc') {
 	while ($_ = readdir(DIR)) {
 		my $unpacked = "=unpacked-tar" . $tarballs . "=";
 		my $filename = $_;
-		if ($filename =~ s/\.tar\.$compression_re_file_ext$//) {
+		if ($filename =~ s/\.tar\.$compression_re$//) {
 		    my $comp = compression_guess_from_filename($_);
 		    $tarballs++;
 		    spawn(exec => ['tar', "--$comp", '-xf', $_],
diff --git a/scripts/debuild.pl b/scripts/debuild.pl
index 233a1c5..a6d8966 100755
--- a/scripts/debuild.pl
+++ b/scripts/debuild.pl
@@ -53,7 +53,7 @@ use 5.008;
 use File::Basename;
 use filetest 'access';
 use Cwd;
-use Dpkg::Compression;
+use Devscripts::Compression;
 use IO::Handle;  # for flushing
 use vars qw(*BUILD *OLDOUT *OLDERR);  # prevent a warning
 
@@ -61,6 +61,8 @@ my $progname=basename($0);
 my $modified_conf_msg;
 my @warnings;
 
+my $compression_re = compression_get_file_extension_regex();
+
 # Predeclare functions
 sub system_withecho(@);
 sub run_hook ($$);
@@ -1222,7 +1224,7 @@ EOT
 
 	my $srcmsg;
 
-	my $ext = $compression_re_file_ext;
+	my $ext = $compression_re;
 	if (fileomitted @files, '\.deb') {
 	    # source only upload
 	    if (fileomitted @files, "\\.diff\\.$ext" and fileomitted @files, "\\.debian\\.tar\\.$ext") {
diff --git a/scripts/dget.pl b/scripts/dget.pl
index f592164..45af642 100755
--- a/scripts/dget.pl
+++ b/scripts/dget.pl
@@ -31,7 +31,7 @@ use Cwd qw(abs_path);
 use IO::Dir;
 use IO::File;
 use Digest::MD5;
-use Dpkg::Compression;
+use Devscripts::Compression;
 use Getopt::Long qw(:config gnu_getopt);
 use File::Basename;
 
@@ -45,6 +45,8 @@ my $backup_dir = "backup";
 my @dget_path = ("/var/cache/apt/archives");
 my $modified_conf_msg;
 
+my $compression_re = compression_get_file_extension_regex();
+
 # use curl if installed, wget otherwise
 if (system("command -v curl >/dev/null 2>&1") == 0) {
     $wget = "curl";
@@ -200,7 +202,7 @@ sub get_file {
     }
 
     # try apt-get if it is still not there
-    my $ext = $compression_re_file_ext;
+    my $ext = $compression_re;
     if (not -e $file and $file =~ m!^([a-z0-9][a-z0-9.+-]+)_[^/]+\.(?:diff|tar)\.$ext$!) {
 	my @cmd = ('apt-get', 'source', '--print-uris', $1);
 	my $cmd = join ' ', @cmd;

-- 
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