[devscripts] 02/02: dd-list: Read compressed sources files
James McCoy
jamessan at debian.org
Mon Oct 5 03:00:04 UTC 2015
This is an automated email from the git hooks/post-receive script.
jamessan pushed a commit to branch master
in repository devscripts.
commit ff54d8b42da8d306c8fbcbd14d2ff605a64b3d35
Author: James McCoy <jamessan at debian.org>
Date: Sun Oct 4 22:57:59 2015 -0400
dd-list: Read compressed sources files
Add a new -z/--uncompress switch which can be used to indicate that the
--dctrl input or sources files are compressed. This will automatically
be handled for sources files with typical naming (i.e., *.gz or *.bz2).
Signed-off-by: James McCoy <jamessan at debian.org>
---
debian/changelog | 4 ++++
scripts/dd-list.1 | 8 +++++++-
scripts/dd-list.pl | 43 +++++++++++++++++++++++++++++++++++++++----
3 files changed, 50 insertions(+), 5 deletions(-)
diff --git a/debian/changelog b/debian/changelog
index 490bf1c..234012e 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -41,6 +41,10 @@ devscripts (2.15.9) UNRELEASED; urgency=medium
+ Omit information from stanzas with “Extra-Source-Only: yes”.
+ Use only the information from the most recent version of a package
within each sources file. (Closes: #788820)
+ + Enable reading sources data from gz or bzip2 compressed files. If the
+ --dctrl switch is being used, the -z switch is needed to enabled
+ decompression. Compressed files specified with the -s switch will
+ automatically be handled if using a .gz/.bz2 extension.
[ Dominique Dumont ]
* licensecheck:
diff --git a/scripts/dd-list.1 b/scripts/dd-list.1
index b0d253e..dfda038 100644
--- a/scripts/dd-list.1
+++ b/scripts/dd-list.1
@@ -74,9 +74,15 @@ of each listed package.
If no \fISource:\fP line is given, the \fIPackage:\fP name is used for
output, which might be a binary package name.
.TP
+.BR \-z ", " \-\-uncompress
+Try to uncompress the \-\-dctrl input before parsing. Supported compression
+formats are gz and bzip2.
+.TP
\fB\-s\fR, \fB\-\-sources\fR \fISources_file\fR
Read package information from the specified \fISources_file\fRs. This can be
-given multiple times.
+given multiple times. The files can be gz or bzip2 compressed. If the
+filename does not end in \fI.gz\fR or \fI.bz2\fR, then the \fB-z\fR option
+must be used.
.IP
If no \fISources_file\fRs are specified, any files matching
\fI/var/lib/apt/lists/*_source_Sources\fR will be used.
diff --git a/scripts/dd-list.pl b/scripts/dd-list.pl
index 8c4d168..fb5721f 100755
--- a/scripts/dd-list.pl
+++ b/scripts/dd-list.pl
@@ -26,6 +26,16 @@ use FileHandle;
use Getopt::Long qw(:config gnu_getopt);
use Dpkg::Version;
+my $uncompress;
+
+BEGIN {
+ $uncompress = eval {
+ require IO::Uncompress::AnyUncompress;
+ IO::Uncompress::AnyUncompress->import('$AnyUncompressError');
+ 1;
+ };
+}
+
my $version='###VERSION###';
sub normalize_package {
@@ -54,10 +64,14 @@ Usage: dd-list [options] [package ...]
-d, --dctrl
Read package list in Debian control data from standard input.
+ -z, --uncompress
+ Try to uncompress the --dctrl input before parsing. Supported
+ compression formats are gz and bzip2.
+
-s, --sources SOURCES_FILE
Read package information from given SOURCES_FILE instead of all files
matching /var/lib/apt/lists/*_source_Sources. Can be specified
- multiple times.
+ multiple times. The files can be gz or bzip2 compressed.
-u, --uploaders
Also list Uploaders of packages, not only the listed Maintainers
@@ -79,6 +93,7 @@ my $use_stdin=0;
my $use_dctrl=0;
my $source_files=[];
my $show_uploaders=1;
+my $opt_uncompress=0;
my $print_binary=0;
GetOptions(
"help|h" => sub { help(); exit },
@@ -86,6 +101,7 @@ GetOptions(
"dctrl|d" => \$use_dctrl,
"sources|s:s@" => \$source_files,
"uploaders|u!" => \$show_uploaders,
+ 'z|uncompress' => \$opt_uncompress,
"print-binary|b" => \$print_binary,
"version" => sub { print "dd-list version $version\n" })
or do {
@@ -93,6 +109,11 @@ or do {
exit(1);
};
+if ($opt_uncompress && !$uncompress) {
+ warn "You must have the libio-compress-perl package installed to use the -z option.\n";
+ exit 1;
+}
+
my %dict;
my $errors=0;
my %package_name;
@@ -194,7 +215,15 @@ sub parsefh
}
if ($use_dctrl) {
- parsefh(\*STDIN, 'STDIN');
+ my $fh;
+ if ($uncompress) {
+ $fh = IO::Uncompress::AnyUncompress->new('-')
+ or die "E: Unable to decompress STDIN: $AnyUncompressError\n";
+ }
+ else {
+ $fh = \*STDIN;
+ }
+ parsefh($fh, 'STDIN');
}
else {
my @packages;
@@ -217,9 +246,15 @@ else {
}
foreach my $source (@{$source_files}) {
- my $fh = FileHandle->new("<$source");
+ my $fh;
+ if ($opt_uncompress || ($uncompress && $source =~ m/\.(?:gz|bz2)$/)) {
+ $fh = IO::Uncompress::AnyUncompress->new($source);
+ }
+ else {
+ $fh = FileHandle->new("<$source");
+ }
unless (defined $fh) {
- warn "E: Couldn't open $fh\n";
+ warn "E: Couldn't open $source\n";
$errors = 1;
next;
}
--
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