[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[SCM] Debian package checker branch, master, updated. 2.5.12-52-g07e7bdc



The following commit has been merged in the master branch:
commit 07e7bdc61e0520f5b3a42030e1e7a34f0287beae
Author: Niels Thykier <niels@thykier.net>
Date:   Sat Apr 27 18:08:39 2013 +0200

    coll: use autodie and replace barewords file handles
    
    Signed-off-by: Niels Thykier <niels@thykier.net>

diff --git a/collection/ar-info b/collection/ar-info
index e891e13..7cc00dd 100755
--- a/collection/ar-info
+++ b/collection/ar-info
@@ -23,6 +23,7 @@ package Lintian::coll::ar_info;
 
 use strict;
 use warnings;
+use autodie;
 
 use lib "$ENV{LINTIAN_ROOT}/lib";
 use FileHandle;
@@ -35,14 +36,13 @@ sub collect {
 my $info = Lintian::Collect->new ($pkg, $type, $dir);
 
 if ( -e "$dir/ar-info" ) {
-    unlink "$dir/ar-info" or fail "unlink ar-info: $!";
+    unlink("$dir/ar-info");
 }
 
-open OUT, '>', "$dir/ar-info"
-    or fail("cannot open ar-info file: $!");
+open(my $out_fd, '>', "$dir/ar-info");
+
+chdir("$dir/unpacked");
 
-chdir ("$dir/unpacked")
-    or fail("cannot chdir to unpacked directory: $!");
 
 foreach my $file ($info->sorted_index) {
     next unless $file =~ m/\.a$/;
@@ -50,17 +50,17 @@ foreach my $file ($info->sorted_index) {
 
     my $opts = { pipe_out => FileHandle->new, err => '/dev/null' };
     spawn($opts, [ 'ar', 't', $file ]);
-    print OUT "$file:";
+    print {$out_fd} "$file:";
     while (defined($_ = readline($opts->{pipe_out}))) {
         chomp;
-        print OUT " $_";
+        print {$out_fd} " $_";
     }
     close($opts->{pipe_out});
-    print OUT "\n";
+    print {$out_fd} "\n";
     $opts->{harness}->finish;
 }
 
-close(OUT) or fail("cannot write ar-info: $!");
+close($out_fd);
 }
 
 collect (@ARGV) if $0 =~ m,(?:^|/)ar-info$,;
diff --git a/collection/changelog-file b/collection/changelog-file
index 6ec3fac..a9e8f61 100755
--- a/collection/changelog-file
+++ b/collection/changelog-file
@@ -23,6 +23,9 @@ package Lintian::coll::changelog_file;
 
 use strict;
 use warnings;
+use autodie;
+
+use File::Copy qw(copy);
 
 use lib "$ENV{'LINTIAN_ROOT'}/lib";
 use Lintian::Util qw(fail gunzip_file is_ancestor_of);
@@ -30,12 +33,12 @@ use Lintian::Util qw(fail gunzip_file is_ancestor_of);
 sub collect {
 my ($pkg, $type, $dir) = @_;
 
-unlink "$dir/changelog" or fail "cannot remove changelog file: $!"
+unlink("$dir/changelog")
     if -e "$dir/changelog" or -l "$dir/changelog";
 
 # Extract NEWS.Debian files as well, with similar precautious.  Ignore any
 # symlinks to other packages here; in that case, we just won't check the file.
-unlink "$dir/NEWS.Debian" or fail "cannot unlink NEWS.Debian: $!"
+unlink("$dir/NEWS.Debian")
     if -e "$dir/NEWS.Debian" or -l "$dir/NEWS.Debian";
 
 
@@ -70,10 +73,9 @@ for (@changelogs) {
 # directory or to a subdirectory we accept; anything else is replaced by an
 # intentinally broken symlink so that checks can do the right thing.
 if (defined ($chl) && -l $chl) {
-    my $link = readlink $chl or fail("cannot readlink $chl: $!");
+    my $link = readlink($chl);
     if ($link =~ /\.\./ || ($link =~ m%/% && $link !~ m%^[^/]+(?:/+[^/]+)*\z%)) {
-        symlink ("$dir/file-is-in-another-package", "$dir/changelog")
-            or fail("cannot create changelog symlink: $!");
+        symlink("$dir/file-is-in-another-package", "$dir/changelog");
         undef $chl;
     } elsif (! -f $chl) {
         undef $chl;
@@ -89,22 +91,16 @@ if (not defined $chl) {
 } elsif ($chl =~ /\.gz$/) {
     gunzip_file ($chl, "$dir/changelog");
 } elsif (-f $chl && -l $chl) {
-    local $_;
-    open (CHL, '<', $chl) or fail("cannot open $chl: $!");
-    open (COPY, '>', "$dir/changelog") or fail "cannot create changelog: $!";
-    print COPY while <CHL>;
-    close CHL;
-    close (COPY) or fail("cannot write changelog: $!");
+    copy($chl, "$dir/changelog") or fail "cannot copy $chl: $!";
 } else {
-    link ($chl, "$dir/changelog")
-        or fail("cannot link $chl to changelog: $!");
+    link($chl, "$dir/changelog");
 }
 
 if ($chl && $chl !~ m/changelog\.debian/i) {
     # Either this is a native package OR a non-native package where the
     # debian changelog is missing.  checks/changelog is not too happy
     # with the latter case, so check looks like a Debian changelog.
-    open my $fd, '<', "$dir/changelog" or fail "Opening changelog: $!";
+    open(my $fd, '<', "$dir/changelog");
     my $ok = 0;
     while ( my $line = <$fd> ) {
         next if $line =~ m/^\s*+$/o;
@@ -115,15 +111,15 @@ if ($chl && $chl !~ m/changelog\.debian/i) {
         }
         last;
     }
-    close $fd;
+    close($fd);
     # Remove it if it not the Debian changelog.
-    unlink "$dir/changelog" unless $ok;
+    unlink("$dir/changelog") unless $ok;
 }
 
 my $news = "$dir/unpacked/usr/share/doc/$pkg/NEWS.Debian.gz";
 if (-f $news) {
     if (-l $news) {
-        my $link = readlink $news or fail("cannot readlink $chl: $!");
+        my $link = readlink($news);
         if ($link =~ /\.\./ || ($link =~ m%/% && $link !~ m%^[^/]+(?:/+[^/]+)*\z%)) {
             undef $news;
         } elsif (! -f $news) {
diff --git a/collection/diffstat b/collection/diffstat
index d0edf62..910e557 100755
--- a/collection/diffstat
+++ b/collection/diffstat
@@ -54,19 +54,19 @@ return unless (-f $diff_file);
 
 gunzip_file($diff_file, "$dir/debian-patch");
 
-open(STAT, '>', "$dir/diffstat");
+open(my $out, '>', "$dir/diffstat");
 # diffstat is noisy on stderr if its stdout is not a tty.
 # Shut it up by redirecting stderr to /dev/null.
 open(STDERR, '>', '/dev/null');
-open(DIFF, '-|', 'diffstat',  '-p1', "$dir/debian-patch");
+open(my $in, '-|', 'diffstat',  '-p1', "$dir/debian-patch");
 # Copy all except last line to the STAT file
 my $previous;
-while (<DIFF>) {
-    print STAT $previous if $previous;
+while (<$in>) {
+    print {$out} $previous if $previous;
     $previous = $_;
 }
-close(DIFF);
-close(STAT);
+close($out);
+close($in);
 
 }
 

-- 
Debian package checker


Reply to: