[SCM] Debian package checker branch, master, updated. 2.5.12-58-g53d6323
The following commit has been merged in the master branch:
commit 561af2cb644a039195609281674dc4b82031013f
Author: Niels Thykier <niels@thykier.net>
Date: Tue Apr 30 17:09:42 2013 +0200
checks/*: use autodie + replace bareword file handles
Signed-off-by: Niels Thykier <niels@thykier.net>
diff --git a/checks/debian-readme b/checks/debian-readme
index e3d14ed..4e80a3f 100644
--- a/checks/debian-readme
+++ b/checks/debian-readme
@@ -21,6 +21,7 @@
package Lintian::debian_readme;
use strict;
use warnings;
+use autodie;
use Lintian::Check qw(check_spelling);
use Lintian::Tags qw(tag);
@@ -31,16 +32,14 @@ my ($pkg, undef, $info, undef, $group) = @_;
my $readme = '';
-if (open (IN, '<', $info->lab_data_path ('README.Debian'))) {
- local $_;
- while (<IN>) {
- if (m,/usr/doc\b,) {
- tag 'readme-debian-mentions-usr-doc', "line $.";
- }
- $readme .= $_;
+open(my $fd, '<', $info->lab_data_path ('README.Debian'));
+while (my $line = <$fd>) {
+ if ($line =~ m,/usr/doc\b,) {
+ tag 'readme-debian-mentions-usr-doc', "line $.";
}
- close(IN);
+ $readme .= $line;
}
+close($fd);
my @template =
('Comments regarding the Package',
diff --git a/checks/manpages b/checks/manpages
index 7995494..abf9219 100644
--- a/checks/manpages
+++ b/checks/manpages
@@ -210,7 +210,7 @@ foreach my $file ($info->sorted_index) {
# negatives. When man-db is fixed, this limitation should be
# removed.
if ($path =~ m,/man/man\d/,) {
- my $pid = open LEXGROG, '-|';
+ my $pid = open(my $lexgrog_fd, '-|');
if (not defined $pid) {
fail "fork (lexgrog) failed: $!";
} elsif ($pid == 0) {
@@ -219,16 +219,16 @@ foreach my $file ($info->sorted_index) {
exec 'lexgrog', $path
or fail "exec lexgrog failed: $!";
}
- my $desc = <LEXGROG>;
+ my $desc = <$lexgrog_fd>;
$desc =~ s/^[^:]+: \"(.*)\"$/$1/;
if ($desc =~ /(\S+)\s+-\s+manual page for \1/i) {
tag 'manpage-has-useless-whatis-entry', $file;
} elsif ($desc =~ /\S+\s+-\s+programs? to do something/i) {
tag 'manpage-is-dh_make-template', $file;
}
- 1 while <LEXGROG>;
+ 1 while <$lexgrog_fd>;
eval {
- close(LEXGROG);
+ close($lexgrog_fd);
};
if (my $err = $@) {
# Problem closing the pipe?
diff --git a/checks/md5sums b/checks/md5sums
index a16e571..cbca317 100644
--- a/checks/md5sums
+++ b/checks/md5sums
@@ -21,9 +21,9 @@
package Lintian::md5sums;
use strict;
use warnings;
+use autodie;
use Lintian::Tags qw(tag);
-use Lintian::Util qw(fail);
sub run {
@@ -67,18 +67,17 @@ if (-z $control) {
}
# read in md5sums control file
-open(C, '<', $control)
- or fail("cannot open md5sums control file $control: $!");
-while (<C>) {
- chop;
- next if m/^\s*$/;
- if (m{^([a-f0-9]+)\s*(?:\./)?(\S.*)$} && length($1) == 32) {
+open(my $fd, '<', $control);
+while (my $line = <$fd>) {
+ chop($line);
+ next if $line =~ m/^\s*$/;
+ if ($line =~ m{^([a-f0-9]+)\s*(?:\./)?(\S.*)$} && length($1) == 32) {
$control_entry{$2} = $1;
} else {
tag 'malformed-md5sums-control-file', "line $.";
}
}
-close(C);
+close($fd);
for my $file (keys %control_entry) {
diff --git a/checks/ocaml b/checks/ocaml
index 6767fdf..ba5f664 100644
--- a/checks/ocaml
+++ b/checks/ocaml
@@ -22,6 +22,7 @@ package Lintian::ocaml;
use strict;
use warnings;
+use autodie;
use File::Basename;
use Lintian::Collect::Binary ();
@@ -38,20 +39,19 @@ my ($pkg, undef, $info) = @_;
# Collect information about .a files from ar-info dump
my %provided_o;
-open ARINFO, '<', $info->lab_data_path ('ar-info')
- or fail "opening ar-info: $!";
-while (<ARINFO>) {
- chomp;
- if (/^(?:\.\/)?([^:]+): (.*)$/) {
+open(my $fd, '<', $info->lab_data_path ('ar-info'));
+while (my $line = <$fd>) {
+ chomp($line);
+ if ($line =~ /^(?:\.\/)?([^:]+): (.*)$/) {
my ($filename, $contents) = ($1, $2);
my $dirname = dirname($filename);
- foreach (split m/ /o, $contents) {
+ for my $entry (split m/ /o, $contents) {
# Note: a .o may be legitimately in several different .a
- $provided_o{"$dirname/$_"} = $filename;
+ $provided_o{"$dirname/$entry"} = $filename;
}
}
}
-close ARINFO;
+close($fd);
# is it a library package?
my $is_lib_package = 0;
diff --git a/checks/rules b/checks/rules
index 6a0bb19..f117254 100644
--- a/checks/rules
+++ b/checks/rules
@@ -16,12 +16,13 @@
package Lintian::rules;
use strict;
use warnings;
+use autodie;
use List::MoreUtils qw(any);
use Lintian::Data;
use Lintian::Tags qw(tag);
-use Lintian::Util qw(fail is_ancestor_of rstrip);
+use Lintian::Util qw(is_ancestor_of rstrip);
our $PYTHON_DEPEND = 'python | python-dev | python-all | python-all-dev';
our $PYTHON3_DEPEND = 'python3 | python3-dev | python3-all | python3-all-dev';
@@ -121,11 +122,11 @@ if (-l $rules) {
my $architecture = $info->field('architecture') || '';
-open(RULES, '<', $rules) or fail("Failed opening rules: $!");
+open(my $rules_fd, '<', $rules);
# Check for required #!/usr/bin/make -f opening line. Allow -r or -e; a
# strict reading of Policy doesn't allow either, but they seem harmless.
-my $start = <RULES>;
+my $start = <$rules_fd>;
tag 'debian-rules-not-a-makefile'
unless $start =~ m%^\#!\s*/usr/bin/make\s+-[re]?f[re]?\s*$%;
@@ -152,8 +153,8 @@ my %debhelper_group;
my $maybe_skipping;
my $uses_makefile_pl = 0;
my %variables;
-while (<RULES>) {
- while (s,\\$,, and defined (my $cont = <RULES>)) {
+while (<$rules_fd>) {
+ while (s,\\$,, and defined (my $cont = <$rules_fd>)) {
$_ .= $cont;
}
next if /^\s*\#/;
@@ -352,7 +353,7 @@ while (<RULES>) {
}
}
}
-close RULES;
+close($rules_fd);
unless ($includes) {
my $rec = 0;
diff --git a/checks/watch-file b/checks/watch-file
index 26c0a5a..2d14318 100644
--- a/checks/watch-file
+++ b/checks/watch-file
@@ -23,11 +23,12 @@
package Lintian::watch_file;
use strict;
use warnings;
+use autodie;
use Lintian::Collect;
use Lintian::Tags qw(tag);
-use Lintian::Util qw(fail is_ancestor_of);
+use Lintian::Util qw(is_ancestor_of);
sub run {
@@ -64,10 +65,10 @@ if ($version =~ /(alpha|beta|rc)/i) {
# Gather information from the watch file and look for problems we can
# diagnose on the first time through.
-open(WATCH, '<', $wfile) or fail("cannot open watch file: $!");
+open(my $fd, '<', $wfile);
local $_;
my ($watchver, %dversions);
-while (<WATCH>) {
+while (<$fd>) {
$template = 1 if m/^\s*\#\s*Example watch control file for uscan/io;
next if /^\s*\#/;
next if /^\s*$/;
@@ -77,8 +78,8 @@ while (<WATCH>) {
chomp;
if (s/(?<!\\)\\$//) {
# This is caught by uscan.
- last if eof(WATCH);
- $_ .= <WATCH>;
+ last if eof($fd);
+ $_ .= <$fd>;
goto CHOMP;
}
@@ -151,7 +152,7 @@ while (<WATCH>) {
}
}
}
-close WATCH;
+close($fd);
tag 'debian-watch-contains-dh_make-template' if ($template);
--
Debian package checker
Reply to: