[SCM] Debian package checker branch, master, updated. 2.5.9-20-g88fb52b
The following commit has been merged in the master branch:
commit 88fb52b9927be6aaece6c826861458cede0eb56d
Author: Niels Thykier <niels@thykier.net>
Date: Sat Apr 14 13:57:36 2012 +0200
L::Util: transparently use PerlIO::gzip for if available
PerlIO::gzip has the advantage of not being a separate process
(removing the need for fork+exec).
Signed-off-by: Niels Thykier <niels@thykier.net>
diff --git a/checks/files b/checks/files
index 34043f3..96adf81 100644
--- a/checks/files
+++ b/checks/files
@@ -26,7 +26,7 @@ use File::Basename;
use Lintian::Data;
use Lintian::Tags qw(tag);
-use Lintian::Util qw(fail);
+use Lintian::Util qw(fail open_gz);
my $FONT_PACKAGES = Lintian::Data->new ('files/fonts', qr/\s++/);
my $TRIPLETS = Lintian::Data->new ('files/triplets', qr/\s++/);
@@ -427,8 +427,10 @@ foreach my $file ($info->sorted_index) {
if ($file =~ m,.gz$, and $index_info->size <= 276
and $index_info->is_file
and $info->file_info->{$file} =~ m/gzip compressed/) {
- my $f = quotemeta($info->unpacked($file));
- unless (`gzip -dc $f`) {
+ my $fd = open_gz ($info->unpacked ($file)) or fail "open $file: $!";
+ my $f = <$fd>;
+ close $fd;
+ unless (length $f) {
tag 'zero-byte-file-in-doc-directory', $file;
}
}
diff --git a/debian/changelog b/debian/changelog
index f947e1f..02862db 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -8,6 +8,8 @@ lintian (2.5.10) UNRELEASED; urgency=low
* checks/changes-file.desc:
+ [NT] Fix typo in tag description. Thanks to Luca
Falavigna for spotting it.
+ * checks/files:
+ + [NT] Use new gzip decompressor from L::Util.
* checks/java{,.desc}:
+ [NT] Catch unknown Java class versions.
+ [NT] Catch uses of Java7 byte code as an experimental
@@ -42,6 +44,7 @@ lintian (2.5.10) UNRELEASED; urgency=low
or lzma. (Closes: #678775)
+ [NT] Add missing suggests for lzma packages. lzma is
only used for source packages compressed with lzma.
+ + [NT] Add suggests on libperlio-gzip-perl.
* frontend/lintian:
+ [NT] Check if some collections can be skipped for existing
@@ -52,8 +55,13 @@ lintian (2.5.10) UNRELEASED; urgency=low
level 2 (or higher).
+ [NT] Load lintian's libraries earlier.
+ * lib/Lintian/Collect/[Binary,Package}.pm:
+ + [NT] Use new gzip decompressor from L::Util.
* lib/Lintian/CollScript.pm:
+ [NT] New file.
+ * lib/Lintian/Util.pm:
+ + [NT] Add gzip decompressor preferring libperlio-perl if
+ available, but with fallback to a "fork+exec" of gzip.
-- Niels Thykier <niels@thykier.net> Sun, 17 Jun 2012 23:25:06 +0200
diff --git a/debian/control b/debian/control
index 902937a..1265b43 100644
--- a/debian/control
+++ b/debian/control
@@ -87,6 +87,7 @@ Depends: binutils,
Suggests: binutils-multiarch,
dpkg-dev,
libhtml-parser-perl,
+ libperlio-gzip-perl,
libtext-template-perl,
lzma,
man-db (>= 2.5.1-1),
diff --git a/lib/Lintian/Collect/Binary.pm b/lib/Lintian/Collect/Binary.pm
index dfae5e9..5945cdc 100644
--- a/lib/Lintian/Collect/Binary.pm
+++ b/lib/Lintian/Collect/Binary.pm
@@ -28,7 +28,7 @@ use Lintian::Relation;
use Carp qw(croak);
use Parse::DebianChangelog;
-use Lintian::Util qw(fail);
+use Lintian::Util qw(fail open_gz);
# Initialize a new binary package collect object. Takes the package name,
# which is currently unused.
@@ -101,7 +101,7 @@ sub strings {
open my $fd, '<', '/dev/null';
return $fd;
}
- open my $fd, '-|', 'gzip', '-dc', "$real.gz" or fail "open ${file}.gz: $!";
+ my $fd = open_gz ("$real.gz") or fail "open ${file}.gz: $!";
return $fd;
}
diff --git a/lib/Lintian/Collect/Package.pm b/lib/Lintian/Collect/Package.pm
index 4edbad8..e9ee707 100644
--- a/lib/Lintian/Collect/Package.pm
+++ b/lib/Lintian/Collect/Package.pm
@@ -25,7 +25,7 @@ use base 'Lintian::Collect';
use Carp qw(croak);
use Lintian::Path;
-use Lintian::Util qw(perm2oct);
+use Lintian::Util qw(open_gz perm2oct);
# Returns the path to the dir where the package is unpacked
# or a file therein (see pod below)
@@ -44,7 +44,7 @@ sub file_info {
my %file_info;
local $_;
# sub file_info Needs-Info file-info
- open my $idx, '-|', 'gzip', '-dc', "$base_dir/file-info.gz"
+ my $idx = open_gz ("$base_dir/file-info.gz")
or croak "cannot open $base_dir/file-info.gz: $!";
while (<$idx>) {
chomp;
@@ -124,10 +124,10 @@ sub _fetch_index_data {
my %rhlinks;
my @sorted;
local $_;
- open my $idx, '-|', 'gzip', '-dc', "$base_dir/${index}.gz"
+ my $idx = open_gz ("$base_dir/${index}.gz")
or croak "cannot open index file $base_dir/${index}.gz: $!";
if ($indexown) {
- open $num_idx, '-|', 'gzip', '-dc', "$base_dir/${indexown}.gz"
+ $num_idx = open_gz ("$base_dir/${indexown}.gz")
or croak "cannot open index file $base_dir/${indexown}.gz: $!";
}
while (<$idx>) {
diff --git a/lib/Lintian/Util.pm b/lib/Lintian/Util.pm
index d9714c7..0f32802 100644
--- a/lib/Lintian/Util.pm
+++ b/lib/Lintian/Util.pm
@@ -39,6 +39,13 @@ BEGIN {
constants => [qw(DCTRL_DEBCONF_TEMPLATE DCTRL_NO_COMMENTS)]
);
+ eval { require PerlIO::gzip };
+ if ($@) {
+ *open_gz = \&__open_gz_ext;
+ } else {
+ *open_gz = \&__open_gz_pio;
+ }
+
@EXPORT_OK = (qw(
visit_dpkg_paragraph
parse_dpkg_control
@@ -52,6 +59,7 @@ BEGIN {
delete_dir
copy_dir
gunzip_file
+ open_gz
touch_file
perm2oct
check_path
@@ -749,6 +757,30 @@ sub gunzip_file {
['gzip', '-dc', $in]);
}
+
+=item open_gz (FILE)
+
+Opens a handle that reads from the GZip compressed FILE.
+
+Note: The handle may be a pipe from an external processes.
+
+=cut
+
+# Preferred implementation of open_gz (used if the perlio layer
+# is available)
+sub __open_gz_pio {
+ my ($file) = @_;
+ open my $fd, '<:gzip', $file or return;
+ return $fd;
+}
+
+# Fallback implementation of open_gz
+sub __open_gz_ext {
+ my ($file) = @_;
+ open my $fd, '-|', 'gzip', '-dc', $file or return;
+ return $fd;
+}
+
=item touch_File (FILE)
Updates the "mtime" of FILE. If FILE does not exist, it will be
--
Debian package checker
Reply to: