[SCM] Debian package checker branch, master, updated. 2.5.12-62-g11f19a0
The following commit has been merged in the master branch:
commit 11f19a0c3eebfe460574de22acc065b7d2bb545b
Author: Niels Thykier <niels@thykier.net>
Date: Tue Apr 30 19:58:14 2013 +0200
checks/*: Use autodie in all checks
Signed-off-by: Niels Thykier <niels@thykier.net>
diff --git a/checks/apache2 b/checks/apache2
index ae148f9..fd6d3ab 100644
--- a/checks/apache2
+++ b/checks/apache2
@@ -22,6 +22,7 @@ package Lintian::apache2;
use strict;
use warnings;
+use autodie;
use File::Basename;
use Lintian::Collect::Binary ();
@@ -176,8 +177,7 @@ sub check_module_package {
sub check_maintainer_scripts {
my ($info) = @_;
- open my $fd, '<', $info->lab_data_path ('control-scripts')
- or fail "cannot open lintian control-scripts file: $!";
+ open(my $fd, '<', $info->lab_data_path('control-scripts'));
while (<$fd>)
{
@@ -191,7 +191,7 @@ sub check_maintainer_scripts {
# Don't try to parse the file if it does not appear to be a shell script
next if $interpreter !~ m/sh\b/;
- open my $sfd, '<', $filename or fail "cannot open maintainer script $filename: $!";
+ open(my $sfd, '<', $filename);
while (<$sfd>) {
# skip comments
next if substr ($_, 0, $-[0]) =~ /#/;
@@ -212,10 +212,10 @@ sub check_maintainer_scripts {
# That's going to be complicated. Or not possible without grammar
# parser.
}
- close $sfd;
+ close($sfd);
}
- close $fd;
+ close($fd);
}
@@ -226,7 +226,7 @@ sub inspect_conf_file {
my $filename = $info->unpacked ($file);
# Don't follow links
return if -l $filename;
- open my $fd, '<', $filename or fail "cannot open configuration file $filename: $!";
+ open(my $fd, '<', $filename);
while (<$fd>) {
for my $directive ('Order', 'Satisfy', 'Allow', 'Deny', '<(|/)Limit.*?>', '<(|/)LimitExcept.*?>') {
@@ -249,7 +249,7 @@ sub inspect_conf_file {
}
}
- close $fd;
+ close($fd);
}
diff --git a/checks/binaries b/checks/binaries
index a8436ba..bbc9ec7 100644
--- a/checks/binaries
+++ b/checks/binaries
@@ -22,6 +22,7 @@
package Lintian::binaries;
use strict;
use warnings;
+use autodie;
use Lintian::Check qw(check_spelling);
use Lintian::Data;
diff --git a/checks/changelog-file b/checks/changelog-file
index e009a9c..96d2e46 100644
--- a/checks/changelog-file
+++ b/checks/changelog-file
@@ -21,6 +21,7 @@
package Lintian::changelog_file;
use strict;
use warnings;
+use autodie;
use Encode qw(decode);
use List::Util qw(first);
@@ -30,11 +31,11 @@ use Parse::DebianChangelog;
use Lintian::Check qw(check_spelling);
use Lintian::Relation::Version qw(versions_gt);
use Lintian::Tags qw(tag);
-use Lintian::Util qw(fail file_is_encoded_in_non_utf8);
+use Lintian::Util qw(file_is_encoded_in_non_utf8);
sub run {
-my ($pkg, $type, $info, undef, $group) = @_;
+my ($pkg, undef, $info, undef, $group) = @_;
my $found_html=0;
my $found_text=0;
@@ -248,7 +249,7 @@ if (my @errors = $changelog->get_parse_errors) {
# Check for some things in the raw changelog file and compute the
# "offset" to the first line of the first entry. We use this to
# report the line number of "too-long" lines. (#657402)
-my $chloff = check_dch ($pkg, $type, $dchpath);
+my $chloff = check_dch($dchpath);
my @entries = $changelog->data;
if (@entries) {
@@ -386,18 +387,17 @@ if (@entries) {
# the first line of text in the first entry.
#
sub check_dch {
- my ($pkg, $type, $path) = @_;
+ my ($path) = @_;
# emacs only looks at the last "local variables" in a file, and only at
# one within 3000 chars of EOF and on the last page (^L), but that's a bit
# pesky to replicate. Demanding a match of $prefix and $suffix ought to
# be enough to avoid false positives.
- open my $fd, '<', $path
- or fail("cannot find changelog for $type package $pkg");
my ($prefix, $suffix);
my $lineno = 0;
my ($estart, $tstart) = (0, 0);
+ open(my $fd, '<', $path);
while (<$fd>) {
unless ($tstart) {
@@ -423,7 +423,7 @@ sub check_dch {
tag 'debian-changelog-file-contains-obsolete-user-emacs-settings';
}
}
- close $fd;
+ close($fd);
return $lineno;
}
diff --git a/checks/changes-file b/checks/changes-file
index f704f6f..f0214b9 100644
--- a/checks/changes-file
+++ b/checks/changes-file
@@ -21,6 +21,7 @@
package Lintian::changes_file;
use strict;
use warnings;
+use autodie;
use Lintian::Tags qw(tag);
use Lintian::Check qw(check_maintainer);
diff --git a/checks/control-file b/checks/control-file
index 67f8d2a..b9a41ed 100644
--- a/checks/control-file
+++ b/checks/control-file
@@ -21,6 +21,7 @@
package Lintian::control_file;
use strict;
use warnings;
+use autodie;
use List::MoreUtils qw(any);
use List::Util qw(first);
@@ -28,7 +29,7 @@ use List::Util qw(first);
use Lintian::Data ();
use Lintian::Relation ();
use Lintian::Tags qw(tag);
-use Lintian::Util qw(fail file_is_encoded_in_non_utf8 read_dpkg_control
+use Lintian::Util qw(file_is_encoded_in_non_utf8 read_dpkg_control
rstrip strip);
# The list of libc packages, used for checking for a hard-coded dependency
@@ -55,8 +56,7 @@ if ($line) {
# Nag about dh_make Vcs comment only once
my $seen_vcs_comment = 0;
-open my $fd, '<', $dcontrol
- or fail "Couldn't read debfiles/control: $!";
+open(my $fd, '<', $dcontrol);
while (<$fd>) {
s/\s*\n$//;
@@ -86,7 +86,7 @@ while (<$fd>) {
}
}
}
-close $fd;
+close($fd);
eval {
# check we can parse it, but ignore the result - we will fetch
diff --git a/checks/control-files b/checks/control-files
index 175a4ff..90ede4b 100644
--- a/checks/control-files
+++ b/checks/control-files
@@ -21,6 +21,7 @@
package Lintian::control_files;
use strict;
use warnings;
+use autodie;
use Lintian::Tags qw(tag);
diff --git a/checks/copyright-file b/checks/copyright-file
index a7b22e4..4078c9d 100644
--- a/checks/copyright-file
+++ b/checks/copyright-file
@@ -21,6 +21,7 @@
package Lintian::copyright_file;
use strict;
use warnings;
+use autodie;
use Encode qw(decode);
use List::MoreUtils qw(any);
@@ -28,7 +29,7 @@ use List::MoreUtils qw(any);
use Lintian::Check qw(check_spelling);
use Lintian::Data ();
use Lintian::Tags qw(tag);
-use Lintian::Util qw(fail slurp_entire_file file_is_encoded_in_non_utf8);
+use Lintian::Util qw(slurp_entire_file file_is_encoded_in_non_utf8);
our $KNOWN_ESSENTIAL = Lintian::Data->new('fields/essential');
diff --git a/checks/cruft b/checks/cruft
index 7dd0ad0..b003ecb 100644
--- a/checks/cruft
+++ b/checks/cruft
@@ -25,6 +25,7 @@
package Lintian::cruft;
use strict;
use warnings;
+use autodie;
use v5.10;
use feature qw(switch);
@@ -170,7 +171,7 @@ for my $file ($info->sorted_index) {
my $path = $info->unpacked ($file);
my $marker = 0;
next unless -f $path and not -l $path;
- open my $fd, '<', $path or fail "Opening $file: $!";
+ open(my $fd, '<', $path);
while ( my $line = <$fd> ) {
next unless $line =~ m/^#/o;
if ($marker && $line =~ m/^#BZ[h0][0-9]/o) {
@@ -181,7 +182,7 @@ for my $file ($info->sorted_index) {
# We could probably stop here, but just in case
$marker = 0 if $line =~ m/^#<==/o;
}
- close $fd;
+ close($fd);
}
tag 'source-contains-waf-binary', $file unless $ok;
}
@@ -203,7 +204,7 @@ for my $file (keys %ERRORS) {
my $tag = $ERRORS{$file};
my $path = $info->lab_data_path ($file);
if (-s $path) {
- open(my $fd, '<', $path) or fail "cannot open $file: $!";
+ open(my $fd, '<', $path);
local $_;
while (<$fd>) {
chomp;
@@ -235,7 +236,7 @@ for my $file (keys %ERRORS) {
sub check_diffstat {
my ($diffstat, $warned) = @_;
my $saw_file;
- open(my $fd, '<', $diffstat) or fail("cannot open $diffstat: $!");
+ open(my $fd, '<', $diffstat);
local $_;
while (<$fd>) {
my ($file) = (m,^\s+(.*?)\s+\|,)
@@ -281,7 +282,7 @@ sub check_diffstat {
tag 'diff-contains-substvars', $file;
}
}
- close($fd) or fail("error reading diffstat file: $!");
+ close($fd);
# If there was nothing in the diffstat output, there was nothing in the
# diff, which is probably a mistake.
@@ -405,7 +406,7 @@ sub find_cruft {
tag 'configure-generated-file-in-source', $name;
}
} elsif ($name =~ m,^(.+/)?config.(?:guess|sub)$, and not $atdinbd) {
- open(my $fd, '<', $basename) or fail "can't open $name: $!";
+ open(my $fd, '<', $basename);
while (<$fd>) {
last if $. > 10; # it's on the 6th line, but be a bit more lenient
if (/^(?:timestamp|version)='((\d+)-(\d+).*)'$/) {
@@ -425,7 +426,7 @@ sub find_cruft {
} elsif ($name =~ m,^(.+/)?ltconfig$, and not $ltinbd) {
tag 'ancient-libtool', $name;
} elsif ($name =~ m,^(.+/)?ltmain\.sh$, and not $ltinbd) {
- open(my $fd, '<', $basename) or fail "can't open $name: $!";
+ open(my $fd, '<', $basename);
while (<$fd>) {
if (/^VERSION=[\"\']?(1\.(\d)\.(\d+)(?:-(\d))?)/) {
my ($version, $major, $minor, $debian) = ($1, $2, $3, $4);
@@ -447,7 +448,7 @@ sub find_cruft {
# test license problem is source file (only text file)
if (-T $basename) {
- open my $F, '<', $basename or fail "can't open $name: $!";
+ open(my $F, '<', $basename);
binmode ($F);
my @queue = ('', '');
@@ -457,7 +458,7 @@ sub find_cruft {
# for efficiency. We store two blocks in @queue and the whole
# string to match in $block. Please emit license tags only once
# per file
- while (read ($F, my $window, BLOCKSIZE)) {
+ while (read($F, my $window, BLOCKSIZE)) {
my $block;
shift @queue;
push @queue, $window;
@@ -519,7 +520,7 @@ sub find_cruft {
}
}
}
- close $F or fail "can not close opened file $name: $!";
+ close($F);
}
}
diff --git a/checks/deb-format b/checks/deb-format
index b86fc25..5e53853 100644
--- a/checks/deb-format
+++ b/checks/deb-format
@@ -18,10 +18,10 @@
package Lintian::deb_format;
use strict;
use warnings;
+use autodie;
use Lintian::Command qw(spawn);
use Lintian::Tags qw(tag);
-use Lintian::Util qw(fail);
# The files that contain error messages from tar, which we'll check and issue
# tags for if they contain something unexpected, and their corresponding tags.
@@ -97,7 +97,7 @@ for my $file (keys %ERRORS) {
my $tag = $ERRORS{$file};
my $path = $info->lab_data_path ($file);
if (-s $path) {
- open my $fd, '<', $path or fail "cannot open $file: $!";
+ open(my $fd, '<', $path);
while ( my $line = <$fd> ) {
chomp ($line);
$line =~ s,^(?:[/\w]+/)?tar: ,,;
@@ -111,7 +111,7 @@ for my $file (keys %ERRORS) {
}
tag $tag, $line;
}
- close $fd;
+ close($fd);
}
}
diff --git a/checks/debconf b/checks/debconf
index cd4a4a5..79ce105 100644
--- a/checks/debconf
+++ b/checks/debconf
@@ -21,10 +21,11 @@
package Lintian::debconf;
use strict;
use warnings;
+use autodie;
use Lintian::Relation;
use Lintian::Tags qw(tag);
-use Lintian::Util qw(fail read_dpkg_control :constants $PKGNAME_REGEX);
+use Lintian::Util qw(read_dpkg_control :constants $PKGNAME_REGEX);
# From debconf-devel(7), section 'THE TEMPLATES FILE', up to date with debconf
# version 1.5.24. Added indices for cdebconf (indicates sort order for
@@ -118,8 +119,7 @@ my $ctrl_config = $info->control('config');
my $ctrl_templates = $info->control('templates');
if ( -f $preinst and not -l $preinst) {
- open(my $fd, '<', $preinst)
- or fail "open preinst: $!";
+ open(my $fd, '<', $preinst);
while (<$fd>) {
s/\#.*//; # Not perfect for Perl, but should be OK
if (m,/usr/share/debconf/confmodule, or
@@ -367,8 +367,7 @@ for my $file (qw(config prerm postrm preinst postinst)) {
my $isdefault='';
my $usesseen='';
- open(my $fd, '<', $path)
- or fail "open $file: $!";
+ open(my $fd, '<', $path);
# Only check scripts.
my $fl = <$fd>;
unless ($fl && $fl =~ /^\#!/) {
@@ -518,7 +517,7 @@ if ($usespreinst) {
return 0 if ($pkg eq 'debconf') || ($type eq 'udeb');
foreach my $filename (sort keys %{$info->scripts}) {
- open(my $fd, '<', $info->unpacked($filename)) or fail("cannot open $filename: $!");
+ open(my $fd, '<', $info->unpacked($filename));
while (<$fd>) {
s/#.*//; # Not perfect for Perl, but should be OK
if (m,/usr/share/debconf/confmodule, or
diff --git a/checks/debhelper b/checks/debhelper
index 70eff97..9672635 100644
--- a/checks/debhelper
+++ b/checks/debhelper
@@ -21,12 +21,12 @@
package Lintian::debhelper;
use strict;
use warnings;
-use autodie qw(opendir closedir);
+use autodie;
use Lintian::Data;
use Lintian::Relation;
use Lintian::Tags qw(tag);
-use Lintian::Util qw(fail is_ancestor_of slurp_entire_file strip strip);
+use Lintian::Util qw(is_ancestor_of slurp_entire_file strip strip);
# If compat is less than or equal to this, then a missing version
# for this level is only a pedantic issue.
@@ -90,7 +90,7 @@ if ( ! -f "$droot/rules" || !is_ancestor_of($droot, "$droot/rules")) {
return;
}
-open(my $rules_fd, '<', "$droot/rules") or fail("cannot read debian/rules: $!");
+open(my $rules_fd, '<', "$droot/rules");
while (<$rules_fd>) {
while (s,\\$,, and defined (my $cont = <$rules_fd>)) {
@@ -306,9 +306,8 @@ for my $file (sort(readdir($dirfd))) {
# They need to have #DEBHELPER# in their scripts. Search for scripts
# that look like maintainer scripts and make sure the token is there.
my $binpkg = $1 || '';
- open(my $fd, '<', "$droot/$file")
- or fail("Can't open debfiles/$file: $!");
my $seentag = '';
+ open(my $fd, '<', "$droot/$file");
while (<$fd>) {
if (m/\#DEBHELPER\#/) {
$seentag = 1;
@@ -370,8 +369,7 @@ for my $file (sort(readdir($dirfd))) {
# do not allow any form for wildcards.
next if $level < 3;
- open(my $fd, '<', "$droot/$file")
- or fail("Can't open debfiles/$file: $!");
+ open(my $fd, '<', "$droot/$file");
local $_;
while (<$fd>) {
next if /^\s*$/;
@@ -499,9 +497,8 @@ sub _check_dh_exec {
tag 'dh-exec-private-helper', $pkgpath;
}
- open (my $fd, '<', $fspath)
- or fail ("Can't open $pkgpath: $!");
my ($dhe_subst, $dhe_install) = (0, 0);
+ open(my $fd, '<', $fspath);
while (<$fd>) {
if (/\$\{([^\}]+)\}/) {
my $sv = $1;
@@ -513,7 +510,7 @@ sub _check_dh_exec {
}
$dhe_install = 1 if / => /;
}
- close $fd;
+ close($fd);
if ( ! ( $dhe_subst || $dhe_install ) ) {
tag 'dh-exec-script-without-dh-exec-features', $pkgpath;
@@ -530,8 +527,8 @@ sub _shebang_cmd {
my ($pkgpath, $fspath) = @_;
my $magic;
my $cmd = '';
- open my $fd, '<', $fspath or fail "opening $pkgpath: $!";
- if (read $fd, $magic, 2) {
+ open(my $fd, '<', $fspath);
+ if (read($fd, $magic, 2)) {
if ($magic eq '#!') {
$cmd = <$fd>;
@@ -543,7 +540,7 @@ sub _shebang_cmd {
strip ($cmd);
}
}
- close $fd;
+ close($fd);
# We are not checking if it is an ELF executable. While debhelper
diff --git a/checks/debian-source-dir b/checks/debian-source-dir
index a8f4450..c6dc0c7 100644
--- a/checks/debian-source-dir
+++ b/checks/debian-source-dir
@@ -21,7 +21,7 @@
package Lintian::debian_source_dir;
use strict;
use warnings;
-use autodie qw(open opendir close closedir);
+use autodie;
use List::MoreUtils qw(any);
@@ -43,7 +43,7 @@ if ( ! -l "$dsrc/format" && -e "$dsrc/format") {
open(my $fd, '<', "$dsrc/format");
my $format = <$fd>;
chomp $format;
- close $fd;
+ close($fd);
tag 'unknown-source-format', $format unless $KNOWN_FORMATS{$format};
} else {
tag 'missing-debian-source-format';
diff --git a/checks/description b/checks/description
index 2d1d340..413d68b 100644
--- a/checks/description
+++ b/checks/description
@@ -19,8 +19,9 @@
# MA 02110-1301, USA.
package Lintian::description;
-use warnings;
use strict;
+use warnings;
+use autodie;
use Encode qw(decode);
diff --git a/checks/duplicate-files b/checks/duplicate-files
index a38dd20..bf6346b 100644
--- a/checks/duplicate-files
+++ b/checks/duplicate-files
@@ -21,6 +21,7 @@
package Lintian::duplicate_files;
use strict;
use warnings;
+use autodie;
use List::MoreUtils qw(any);
diff --git a/checks/fields b/checks/fields
index e435734..81f83a2 100644
--- a/checks/fields
+++ b/checks/fields
@@ -25,6 +25,7 @@
package Lintian::fields;
use strict;
use warnings;
+use autodie;
use Dpkg::Version qw(version_check);
use List::MoreUtils qw(any true);
diff --git a/checks/filename-length b/checks/filename-length
index 3d58574..5735827 100644
--- a/checks/filename-length
+++ b/checks/filename-length
@@ -21,6 +21,7 @@
package Lintian::filename_length;
use strict;
use warnings;
+use autodie;
use Lintian::Tags qw(tag);
use Lintian::Util qw(strip);
diff --git a/checks/files b/checks/files
index 692314c..d63c110 100644
--- a/checks/files
+++ b/checks/files
@@ -21,6 +21,7 @@
package Lintian::files;
use strict;
use warnings;
+use autodie;
use File::Basename;
@@ -348,8 +349,7 @@ foreach my $file ($info->sorted_index) {
#----------------- /etc/php5/conf.d
elsif ($file =~ m,^etc/php5/conf.d/.+\.ini$,) {
if ($index_info->is_file) {
- open(my $fd, '<', $info->unpacked($index_info))
- or fail("cannot open .ini file: $!");
+ open(my $fd, '<', $info->unpacked($index_info));
while (<$fd>) {
next unless (m/^\s*#/);
tag 'obsolete-comments-style-in-php-ini', $file;
@@ -418,7 +418,7 @@ foreach my $file ($info->sorted_index) {
and $info->file_info ($file) =~ m/gzip compressed/) {
my $fd = open_gz ($info->unpacked($index_info)) or fail "open $file: $!";
my $f = <$fd>;
- close $fd;
+ close($fd);
unless (defined $f and length $f) {
tag 'zero-byte-file-in-doc-directory', $file;
}
@@ -797,8 +797,7 @@ foreach my $file ($info->sorted_index) {
{
my $dep = $info->relation('strong');
if ($index_info->is_file && $file =~ m,\.pm$, && !$dep->implies ('libperl4-corelibs-perl | perl (<< 5.12.3-7)')) {
- open(my $fd, '<', $info->unpacked($index_info))
- or fail("cannot open .pm file: $!");
+ open(my $fd, '<', $info->unpacked($index_info));
while (<$fd>) {
if (/(?:do|require)\s+(?:'|")(abbrev|assert|bigfloat|bigint|bigrat|cacheout|complete|ctime|dotsh|exceptions|fastcwd|find|finddepth|flush|getcwd|getopt|getopts|hostname|importenv|look|newgetopt|open2|open3|pwd|shellwords|stat|syslog|tainted|termcap|timelocal|validate)\.pl(?:'|")/) {
tag 'perl-module-uses-perl4-libs-without-dep', "$file:$. ${1}.pl";
@@ -999,8 +998,7 @@ foreach my $file ($info->sorted_index) {
# ---------------- embedded Feedparser library
if ($file =~ m,/feedparser\.py$, and $pkg ne 'python-feedparser') {
- open(my $fd, '<', $info->unpacked($index_info))
- or fail("cannot open feedparser.py file: $!");
+ open(my $fd, '<', $info->unpacked($index_info));
while (<$fd>) {
if (m,Universal feed parser,) {
tag 'embedded-feedparser-library', $file;
@@ -1013,8 +1011,7 @@ foreach my $file ($info->sorted_index) {
# ---------------- embedded PEAR modules
foreach my $pearmodule (@pearmodules) {
if ($file =~ m,/$pearmodule->[0], and $pkg ne $pearmodule->[1]) {
- open(my $fd, '<', $info->unpacked($index_info))
- or fail("cannot open PHP file: $!");
+ open(my $fd, '<', $info->unpacked($index_info));
while (<$fd>) {
if (m,/pear[/.],i) {
tag 'embedded-pear-module', $file;
@@ -1044,8 +1041,8 @@ foreach my $file ($info->sorted_index) {
my $finfo = $info->file_info ($file) || '';
if ($finfo =~ m/PostScript Type 1 font program data/) {
my $path = $info->unpacked($index_info);
- open my $t1pipe, '-|', 't1disasm', $path or fail "Can't pipe from t1disasm: $!";
my $foundadobeline = 0;
+ open(my $t1pipe, '-|', 't1disasm', $path);
while (my $line = <$t1pipe>) {
if ($foundadobeline) {
if ($line =~ m/^[%\s]*All\s*Rights\s*Reserved\.?\s*$/i) {
@@ -1066,7 +1063,7 @@ foreach my $file ($info->sorted_index) {
last;
}
}
- close $t1pipe or fail "could not close pipe: $! $?";
+ close($t1pipe);
}
}
@@ -1086,8 +1083,8 @@ foreach my $file ($info->sorted_index) {
tag 'gz-file-not-gzip', $file;
} elsif ($isma_same && $file !~ m/\Q$arch\E/o) {
my $path = $info->unpacked($index_info);
- open my $fd, '<', $path or fail "opening $file: $!";
my $buff;
+ open(my $fd, '<', $path);
# We need to read at least 8 bytes
if (sysread($fd, $buff, 1024) >= 8) {
# Extract the flags and the mtime.
@@ -1100,7 +1097,7 @@ foreach my $file ($info->sorted_index) {
} else {
fail "reading $file: $!";
}
- close $fd;
+ close($fd);
}
}
diff --git a/checks/group-checks b/checks/group-checks
index b3af658..d682993 100644
--- a/checks/group-checks
+++ b/checks/group-checks
@@ -21,6 +21,7 @@
package Lintian::group_checks;
use strict;
use warnings;
+use autodie;
use Lintian::Data;
use Lintian::Relation;
diff --git a/checks/huge-usr-share b/checks/huge-usr-share
index 5c8e7ab..2ef48e4 100644
--- a/checks/huge-usr-share
+++ b/checks/huge-usr-share
@@ -21,6 +21,7 @@
package Lintian::huge_usr_share;
use strict;
use warnings;
+use autodie;
use Lintian::Tags qw(tag);
diff --git a/checks/infofiles b/checks/infofiles
index 581ca87..8fd4c77 100644
--- a/checks/infofiles
+++ b/checks/infofiles
@@ -22,6 +22,7 @@
package Lintian::infofiles;
use strict;
use warnings;
+use autodie;
use Lintian::Tags qw(tag);
use Lintian::Util qw(fail open_gz);
@@ -89,7 +90,7 @@ foreach my $file ($info->sorted_index) {
$start = 1 if /^START-INFO-DIR-ENTRY\b/;
$end = 1 if /^END-INFO-DIR-ENTRY\b/;
}
- close $fd;
+ close($fd);
tag 'info-document-missing-dir-section', $file unless $section;
tag 'info-document-missing-dir-entry', $file unless $start && $end;
}
diff --git a/checks/init.d b/checks/init.d
index 6d882fc..a05184a 100644
--- a/checks/init.d
+++ b/checks/init.d
@@ -21,14 +21,13 @@
package Lintian::init_d;
use strict;
use warnings;
-use autodie qw(opendir closedir);
+use autodie;
use File::Basename qw(dirname);
use List::MoreUtils qw(any none);
use Lintian::Data;
use Lintian::Tags qw(tag);
-use Lintian::Util qw(fail);
# A list of valid LSB keywords. The value is 0 if optional and 1 if required.
my %lsb_keywords = (provides => 1,
@@ -91,8 +90,7 @@ my $exclude_r = qr/if\s+\[\s+-x\s+\S*update-rc\.d/;
# read postinst control file
if ( -f $postinst and not -l $postinst) {
- open(my $fd, '<', $postinst)
- or fail "open postinst: $!";
+ open(my $fd, '<', $postinst);
while (<$fd>) {
next if /$exclude_r/o;
s/\#.*$//o;
@@ -113,8 +111,7 @@ if ( -f $postinst and not -l $postinst) {
# read preinst control file
if ( -f $preinst and not -l $preinst) {
- open(my $fd, '<', $preinst)
- or fail "open preinst: $!";
+ open(my $fd, '<', $preinst);
while (<$fd>) {
next if /$exclude_r/o;
s/\#.*$//o;
@@ -130,8 +127,7 @@ if ( -f $preinst and not -l $preinst) {
# read postrm control file
if ( -f $postrm and not -l $postrm) {
- open(my $fd, '<', $postrm)
- or fail "open postrm: $!";
+ open(my $fd, '<', $postrm);
while (<$fd>) {
next if /$exclude_r/o;
s/\#.*$//o;
@@ -149,8 +145,7 @@ if ( -f $postrm and not -l $postrm) {
# read prerm control file
if ( -f $prerm and not -l $prerm) {
- open(my $fd, '<', $prerm)
- or fail "open prerm: $!";
+ open(my $fd, '<', $prerm);
while (<$fd>) {
next if /$exclude_r/o;
s/\#.*$//o;
@@ -238,11 +233,10 @@ sub check_init {
return;
}
}
- open(my $fd, '<', $initd_path)
- or fail("cannot open init.d file $initd_file: $!");
my (%tag, %lsb);
my $in_file_test = 0;
my %needs_fs = ('remote' => 0, 'local' => 0);
+ open(my $fd, '<', $initd_path);
while (defined(my $l = <$fd>)) {
if ($. == 1 && $l =~ m,^\#!\s*(/usr/[^\s]+),) {
tag 'init.d-script-uses-usr-interpreter', "etc/init.d/$initd_file $1";
diff --git a/checks/java b/checks/java
index 93a773d..5a22eef 100644
--- a/checks/java
+++ b/checks/java
@@ -21,6 +21,7 @@
package Lintian::java;
use strict;
use warnings;
+use autodie;
use List::MoreUtils qw(any none);
diff --git a/checks/manpages b/checks/manpages
index abf9219..d0aacbf 100644
--- a/checks/manpages
+++ b/checks/manpages
@@ -21,7 +21,7 @@
package Lintian::manpages;
use strict;
use warnings;
-use autodie qw(open close chdir);
+use autodie;
use File::Basename;
use List::MoreUtils qw(any none);
@@ -211,9 +211,7 @@ foreach my $file ($info->sorted_index) {
# removed.
if ($path =~ m,/man/man\d/,) {
my $pid = open(my $lexgrog_fd, '-|');
- if (not defined $pid) {
- fail "fork (lexgrog) failed: $!";
- } elsif ($pid == 0) {
+ if ($pid == 0) {
clean_env;
open(STDERR, '>&', \*STDOUT);
exec 'lexgrog', $path
@@ -252,11 +250,9 @@ foreach my $file ($info->sorted_index) {
push @cmd, $path;
}
my ($read, $write);
- pipe ($read, $write) or fail "pipe failed: $!";
- my $pid = fork;
- if (not defined $pid) {
- fail "fork failed: $!";
- } elsif ($pid == 0) {
+ pipe($read, $write);
+ my $pid = fork();
+ if ($pid == 0) {
clean_env;
close STDOUT;
close $read;
diff --git a/checks/menu-format b/checks/menu-format
index 9b2b055..87967df 100644
--- a/checks/menu-format
+++ b/checks/menu-format
@@ -35,14 +35,14 @@
package Lintian::menu_format;
use strict;
use warnings;
-use autodie qw(opendir closedir);
+use autodie;
use File::Basename;
use List::MoreUtils qw(any);
use Lintian::Data;
use Lintian::Tags qw(tag);
-use Lintian::Util qw(fail is_ancestor_of);
+use Lintian::Util qw(is_ancestor_of);
# This is a list of all tags that should be in every menu item.
my @req_tags=qw(needs section title command);
@@ -215,7 +215,7 @@ my @menufiles;
for my $dir ("$mdir/lib", "$mdir/share") {
opendir(my $dirfd, $dir);
push(@menufiles, map { "$dir/$_" } readdir($dirfd));
- close($dirfd);
+ closedir($dirfd);
}
# Find the desktop files in the package for verification.
@@ -255,8 +255,7 @@ foreach my $menufile (@menufiles) {
next if !is_ancestor_of($mdir, $menufile);
my $menufile_line ='';
- open(my $fd, '<', $menufile) or
- fail("cannot open menu file $menufile for reading.");
+ open(my $fd, '<', $menufile);
# line below is commented out in favour of the while loop
# do { $_=<IN>; } while defined && (m/^\s* \#/ || m/^\s*$/);
while (<$fd>) {
@@ -566,10 +565,11 @@ sub verify_icon {
return;
}
- open(my $fd, '<', $iconfile) or fail "open $iconfile: $!";
-
my $parse = 'XPM header';
my $line;
+
+ open(my $fd, '<', $iconfile);
+
do { defined ($line = <$fd>) or goto parse_error; }
until ($line =~ /\/\*\s*XPM\s*\*\//);
@@ -599,10 +599,9 @@ parse_error:
sub verify_desktop_file {
my ($desktopfile, $file, $pkg, $info) = @_;
my %vals;
- open(my $fd, '<', $info->unpacked($file))
- or fail("cannot open desktop file $file: $!");
my ($line, $saw_first, $warned_cr);
my @pending;
+ open(my $fd, '<', $info->unpacked($file));
while (defined ($line = <$fd>)) {
chomp $line;
next if ($line =~ m/^\s*\#/ or $line =~ m/^\s*$/);
diff --git a/checks/menus b/checks/menus
index 7cbba10..8b24ef4 100644
--- a/checks/menus
+++ b/checks/menus
@@ -23,12 +23,12 @@
package Lintian::menus;
use strict;
use warnings;
-use autodie qw(opendir closedir);
+use autodie;
use Lintian::Check qw(check_spelling check_spelling_picky $known_shells_regex);
use Lintian::Data;
use Lintian::Tags qw(tag);
-use Lintian::Util qw(fail file_is_encoded_in_non_utf8 strip);
+use Lintian::Util qw(file_is_encoded_in_non_utf8 strip);
# Supported documentation formats for doc-base files.
our %known_doc_base_formats = map { $_ => 1 }
@@ -119,8 +119,7 @@ for my $file ($info->sorted_index) {
$local_file =~ s,^etc/menu-methods/,,;
$menumethod_file = $file;
- open(my $fd, '<', $info->lab_data_path ("menu/methods/$local_file"))
- or fail "cannot open menu-method file $local_file: $!";
+ open(my $fd, '<', $info->lab_data_path("menu/methods/$local_file"));
while (<$fd>) {
chomp;
if (m,^!include menu.h,o) {
@@ -142,7 +141,6 @@ for my $file ($info->sorted_index) {
}
}
}
-close IN;
# prerm scripts should not call update-menus
if ($prerm{'calls-updatemenus'}) {
@@ -235,15 +233,14 @@ sub check_doc_base_file {
tag 'doc-base-file-uses-obsolete-national-encoding', "$dbfile:$line";
}
- open(my $fd, '<', $dbpath)
- or fail "cannot open doc-base file doc-base/$dbfile for reading";
-
my (@files, $field, @vals);
my $knownfields = \%KNOWN_DOCBASE_MAIN_FIELDS;
$line = 0; # global
my %sawfields = (); # local for each section of control file
my %sawformats = (); # global for control file
+ open(my $fd, '<', $dbpath);
+
while (<$fd>) {
chomp;
@@ -574,8 +571,7 @@ sub check_script {
# control files are regular files and not symlinks, pipes etc.
return if -l $spath or not -f $spath;
- open(my $fd, '<', $spath) or
- fail("cannot open maintainer script control/$script for reading: $!");
+ open(my $fd, '<', $spath);
$interp = <$fd>;
$interp = '' unless defined $interp;
if ($interp =~ m,^\#\!\s*/bin/$known_shells_regex,) {
diff --git a/checks/nmu b/checks/nmu
index 547aef9..c71984a 100644
--- a/checks/nmu
+++ b/checks/nmu
@@ -21,6 +21,7 @@
package Lintian::nmu;
use strict;
use warnings;
+use autodie;
use List::MoreUtils qw(any);
use List::Util qw(first);
diff --git a/checks/ocaml b/checks/ocaml
index ba5f664..e23373a 100644
--- a/checks/ocaml
+++ b/checks/ocaml
@@ -28,7 +28,6 @@ use File::Basename;
use Lintian::Collect::Binary ();
use Lintian::Relation ();
use Lintian::Tags qw(tag);
-use Lintian::Util qw(fail);
# The maximum number of *.cmi files to show individually.
our $MAX_CMI = 3;
diff --git a/checks/patch-systems b/checks/patch-systems
index 0cacd3f..dca2e6d 100644
--- a/checks/patch-systems
+++ b/checks/patch-systems
@@ -22,6 +22,7 @@
package Lintian::patch_systems;
use strict;
use warnings;
+use autodie;
use Lintian::Tags qw(tag);
use Lintian::Util qw(fail is_ancestor_of strip);
@@ -62,8 +63,7 @@ sub run {
my $list_uses_cpp = 0;
if (-f "$dpdir/00options"
&& is_ancestor_of($droot, "$dpdir/00options")) {
- open(my $fd, '<', "$dpdir/00options")
- or fail "open 00options: $!";
+ open(my $fd, '<', "$dpdir/00options");
while(<$fd>) {
if (/DPATCH_OPTION_CPP=1/) {
$list_uses_cpp = 1;
@@ -75,8 +75,7 @@ sub run {
foreach my $listfile (glob("$dpdir/00list*")) {
my @patches;
if ( -f $listfile and is_ancestor_of($droot, $listfile)) {
- open(my $fd, '<', $listfile)
- or fail "open $listfile: $!";
+ open(my $fd, '<', $listfile);
while(<$fd>) {
chomp;
next if (/^\#/); #ignore comments or CPP directive
@@ -103,8 +102,9 @@ sub run {
tag 'dpatch-index-references-non-existent-patch', $patch_file;
next;
}
- if (open(my $fd, '<', "$dpdir/$patch_file")) {
+ if (-f "$dpdir/$patch_file") {
my $has_comment = 0;
+ open(my $fd, '<', "$dpdir/$patch_file");
while (<$fd>) {
#stop if something looking like a patch starts:
last if /^---/;
@@ -132,9 +132,10 @@ sub run {
} elsif (! -r "$dpdir/series") {
tag 'quilt-build-dep-but-no-series-file' unless $quilt_format;
} else {
- if (open(my $series_fd, '<', "$dpdir/series")) {
+ if (-f "$dpdir/series") {
my @patches;
my @badopts;
+ open(my $series_fd, '<', "$dpdir/series");
while (my $patch = <$series_fd>) {
strip ($patch); # Strip leading/trailing spaces
$patch =~ s/(?:^|\s+)#.*$//; # Strip comment
@@ -162,8 +163,9 @@ sub run {
tag 'quilt-series-references-non-existent-patch', $patch_file;
next;
}
- if (open(my $patch_fd, '<', "$dpdir/$patch_file")) {
+ if (-f "$dpdir/$patch_file") {
my $has_description = 0;
+ open(my $patch_fd, '<', "$dpdir/$patch_file");
while (<$patch_fd>) {
# stop if something looking like a patch starts:
last if /^---/;
@@ -227,13 +229,13 @@ sub run {
tag 'more-than-one-patch-system';
}
my @direct;
- open(my $fd, '<', $info->diffstat) or fail("cannot open diffstat file: $!");
+ open(my $fd, '<', $info->diffstat);
while (<$fd>) {
my ($file) = (m,^\s+(.*?)\s+\|,)
or fail("syntax error in diffstat file: $_");
push (@direct, $file) if ($file !~ m,^debian/,);
}
- close($fd) or fail("error reading diffstat file: $!");
+ close($fd);
if (@direct) {
my $files = (@direct > 1) ? "$direct[0] and $#direct more" : $direct[0];
@@ -254,15 +256,14 @@ sub check_patch {
# in the debian/* directory, but as of 2010-01-01, all cases where the
# first level of the patch path is "debian/" in the archive are false
# positives.
- open(my $fd, '-|', 'lsdiff', '--strip=1', "$dpdir/$patch_file")
- or fail('cannot fork lsdiff');
+ open(my $fd, '-|', 'lsdiff', '--strip=1', "$dpdir/$patch_file");
while (<$fd>) {
chomp;
if (m|^(?:\./)?debian/|o) {
tag 'patch-modifying-debian-files', $patch_file, $_;
}
}
- close($fd) or fail("cannot close pipe to lsdiff on $patch_file: $!");
+ close($fd);
}
1;
diff --git a/checks/po-debconf b/checks/po-debconf
index 057d100..a2587f3 100644
--- a/checks/po-debconf
+++ b/checks/po-debconf
@@ -21,10 +21,10 @@
package Lintian::po_debconf;
use strict;
use warnings;
-use autodie qw(opendir closedir);
+use autodie;
use Lintian::Tags qw(tag);
-use Lintian::Util qw(fail is_ancestor_of system_env);
+use Lintian::Util qw(is_ancestor_of system_env);
sub run {
@@ -45,16 +45,14 @@ for my $file (readdir($dirfd)) {
if ($file =~ m/^(.+\.)?templates(\..+)?$/) {
if ($file =~ m/templates\.\w\w(_\w\w)?$/) {
push (@lang_templates, $file);
- open(my $fd, '<', "$debfiles/$file")
- or fail("Can't open debfiles/$file file.");
+ open(my $fd, '<', "$debfiles/$file");
while (<$fd>) {
tag 'untranslatable-debconf-templates', "$file: $."
if (m/^Description: (.+)/i and $1 !~/for internal use/);
}
close($fd);
} else {
- open(my $fd, '<', "$debfiles/$file")
- or fail("Can't open debfiles/$file file.");
+ open(my $fd, '<', "$debfiles/$file");
my $in_template = 0;
while (<$fd>) {
tag 'translated-default-field', "$file: $."
@@ -103,8 +101,7 @@ for (@lang_templates) {
my $missing_files = 0;
if ( -f "$debfiles/po/POTFILES.in" and not -l "$debfiles/po/POTFILES.in") {
- open(my $fd, '<', "$debfiles/po/POTFILES.in")
- or fail("Can't open debfiles/po/POTFILES.in.");
+ open(my $fd, '<', "$debfiles/po/POTFILES.in");
while (<$fd>) {
chomp;
next if /^\s*\#/;
@@ -143,8 +140,7 @@ while (defined(my $file=readdir($po_dirfd))) {
$_ = '';
# skip suspicious "files"
next if -l "$debfiles/po/$file" || ! -f "$debfiles/po/$file";
- open(my $fd, '<', "$debfiles/po/$file")
- or fail("Can't open debfiles/po/$file file.");
+ open(my $fd, '<', "$debfiles/po/$file");
while (<$fd>) {
if (/Language\-Team:.*debian-i18n\@lists\.debian\.org/i) {
tag 'debconf-translation-using-general-list', $file;
diff --git a/checks/scripts b/checks/scripts
index ecc1f24..3449b3b 100644
--- a/checks/scripts
+++ b/checks/scripts
@@ -25,6 +25,7 @@
package Lintian::scripts;
use strict;
use warnings;
+use autodie;
use List::MoreUtils qw(any);
@@ -349,7 +350,7 @@ for my $filename (sort keys %{$info->scripts}) {
# Check for obsolete perl libraries
if ($base eq 'perl' &&
!$str_deps->implies ('libperl4-corelibs-perl | perl (<< 5.12.3-7)')) {
- open(my $fd, '<', $path) or fail("could not open script $path");
+ open(my $fd, '<', $path);
while (<$fd>) {
if (/(?:do|require)\s+(?:'|")(abbrev|assert|bigfloat|bigint|bigrat|cacheout|complete|ctime|dotsh|exceptions|fastcwd|find|finddepth|flush|getcwd|getopt|getopts|hostname|importenv|look|newgetopt|open2|open3|pwd|shellwords|stat|syslog|tainted|termcap|timelocal|validate)\.pl(?:'|")/) {
tag 'script-uses-perl4-libs-without-dep', "$filename:$. ${1}.pl";
@@ -439,8 +440,7 @@ foreach (keys %executable) {
);
}
-open(my $ctrl_fd, '<', $info->lab_data_path('control-scripts'))
- or fail("cannot open lintian control-scripts file: $!");
+open(my $ctrl_fd, '<', $info->lab_data_path('control-scripts'));
# Handle control scripts. This is an edited version of the code for
# normal scripts above, because there were just enough differences to
@@ -528,8 +528,7 @@ while (<$ctrl_fd>) {
}
# now scan the file contents themselves
- open(my $fd, '<', $filename)
- or fail("cannot open maintainer script $filename for reading: $!");
+ open(my $fd, '<', $filename);
my %warned;
my ($saw_init, $saw_invoke, $saw_debconf, $saw_bange, $saw_sete, $has_code);
@@ -1015,10 +1014,10 @@ for my $divert (keys %added_diversions) {
sub script_is_evil_and_wrong {
my ($filename) = @_;
my $ret = 0;
- open(my $fd, '<', $filename) or fail("cannot open $filename: $!");
my $i = 0;
my $var = '0';
my $backgrounded = 0;
+ open(my $fd, '<', $filename);
local $_;
while (<$fd>) {
chomp;
@@ -1079,12 +1078,10 @@ sub script_is_evil_and_wrong {
# -n option to check syntax, discarding output and returning the exit status.
sub check_script_syntax {
my ($interpreter, $script) = @_;
- my $pid = fork;
- if (!defined $pid) {
- fail("cannot fork: $!");
- } elsif ($pid == 0) {
- open STDOUT, '>', '/dev/null' or fail("cannot reopen stdout: $!");
- open STDERR, '>&STDOUT' or fail("cannot reopen stderr: $!");
+ my $pid = fork();
+ if ($pid == 0) {
+ open(STDOUT, '>', '/dev/null');
+ open(STDERR, '>&', \*STDOUT);
exec $interpreter, '-n', $script
or fail("cannot exec $interpreter: $!");
} else {
diff --git a/checks/shared-libs b/checks/shared-libs
index 4faac14..e062058 100644
--- a/checks/shared-libs
+++ b/checks/shared-libs
@@ -21,6 +21,7 @@
package Lintian::shared_libs;
use strict;
use warnings;
+use autodie;
use File::Basename;
use List::MoreUtils qw(any none);
@@ -166,8 +167,7 @@ for my $cur_file ($info->sorted_index) {
tag 'sharedobject-in-library-directory-missing-soname', $cur_file;
} elsif ($cur_file =~ m/\.la$/ and not defined $cur_file_data->link) {
local $_;
- open(my $fd, '<', $info->unpacked($cur_file_data))
- or fail("Could not open $cur_file for reading!");
+ open(my $fd, '<', $info->unpacked($cur_file_data));
while(<$fd>) {
next unless (m/^(libdir)='(.+?)'$/) or (m/^(dependency_libs)='(.+?)'$/);
my ($field, $value) = ($1, $2);
@@ -337,8 +337,7 @@ if (-l $shlibsf) {
} else {
my %shlibs_control_used;
my @shlibs_depends;
- open(my $fd, '<', $shlibsf)
- or fail("cannot open control/shlibs for reading: $!");
+ open(my $fd, '<', $shlibsf);
while (<$fd>) {
chop;
next if m/^\s*$/ or /^#/;
@@ -416,7 +415,7 @@ if (-l $symbolsf) {
unless is_nss_plugin ($shlib);
}
}
-} elsif (open(my $fd, '<', $symbolsf)) {
+} elsif (-f $symbolsf) {
my $version_wo_rev = $version;
$version_wo_rev =~ s/^(.+)-([^-]+)$/$1/;
my ($full_version_count, $full_version_sym) = (0, undef);
@@ -429,6 +428,7 @@ if (-l $symbolsf) {
my $warned = 0;
my $symbol_count = 0;
+ open(my $fd, '<', $symbolsf);
while (<$fd>) {
chomp;
next if m/^\s*$/ or /^#/;
diff --git a/checks/source-copyright b/checks/source-copyright
index d714472..275c228 100644
--- a/checks/source-copyright
+++ b/checks/source-copyright
@@ -22,13 +22,14 @@ package Lintian::source_copyright;
use strict;
use warnings;
+use autodie;
use List::MoreUtils qw(any);
use Text::Levenshtein qw(distance);
use Lintian::Relation::Version qw(versions_compare);
use Lintian::Tags qw(tag);
-use Lintian::Util qw(parse_dpkg_control slurp_entire_file fail);
+use Lintian::Util qw(parse_dpkg_control slurp_entire_file);
my $dep5_last_normative_change = '0+svn~166';
my $dep5_last_overhaul = '0+svn~148';
@@ -133,9 +134,9 @@ if ($contents =~ m{
# We are reasonably certain that we're dealing with an up-to-date
# DEP-5 format. Let's try to do more strict checks.
eval {
- open my $fd, '<', \$contents or fail "open <string>: $!";
+ open(my $fd, '<', \$contents);
@dep5 = parse_dpkg_control ($fd, 0, \@lines);
- close $fd;
+ close($fd);
};
if ($@) {
chomp $@;
diff --git a/checks/standards-version b/checks/standards-version
index 655847c..2757c54 100644
--- a/checks/standards-version
+++ b/checks/standards-version
@@ -23,6 +23,7 @@ package Lintian::standards_version;
use strict;
use warnings;
+use autodie;
use POSIX qw(strftime);
use List::Util qw(first);
diff --git a/checks/symlinks b/checks/symlinks
index d568707..7aeefe4 100644
--- a/checks/symlinks
+++ b/checks/symlinks
@@ -21,6 +21,7 @@
package Lintian::symlinks;
use strict;
use warnings;
+use autodie;
use File::Basename qw(dirname);
use Lintian::Tags qw(tag);
diff --git a/checks/testsuite b/checks/testsuite
index 3673f93..b28b04f 100644
--- a/checks/testsuite
+++ b/checks/testsuite
@@ -21,6 +21,7 @@ package Lintian::testsuite;
use strict;
use warnings;
+use autodie;
use Lintian::Tags qw(tag);
use Lintian::Util qw(
diff --git a/checks/version-substvars b/checks/version-substvars
index 7a1141f..2cdb592 100644
--- a/checks/version-substvars
+++ b/checks/version-substvars
@@ -37,6 +37,7 @@
package Lintian::version_substvars;
use strict;
use warnings;
+use autodie;
use Lintian::Relation qw(:constants);
use Lintian::Tags qw(tag);
--
Debian package checker
Reply to: