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

[SCM] Debian package checker branch, master, updated. 2.5.7-20-gfab8798



The following commit has been merged in the master branch:
commit fab87985e8cd03bbb1cddb67d1199c55b081f4a2
Author: Niels Thykier <niels@thykier.net>
Date:   Wed May 23 18:27:13 2012 +0200

    c/source-copyright: Read the copyright-file once
    
    If the file needs to be parsed a DEP-5 copyirght file, then make perl
    read from the scalar rather than re-reading the file.
    
    As a side-effect, use a named variable for the contents.
    
    Signed-off-by: Niels Thykier <niels@thykier.net>

diff --git a/checks/source-copyright b/checks/source-copyright
index 969781d..fea9e44 100644
--- a/checks/source-copyright
+++ b/checks/source-copyright
@@ -25,7 +25,7 @@ use warnings;
 
 use Lintian::Relation::Version qw(versions_compare);
 use Lintian::Tags qw(tag);
-use Lintian::Util qw(read_dpkg_control slurp_entire_file);
+use Lintian::Util qw(parse_dpkg_control slurp_entire_file fail);
 
 my $dep5_last_normative_change = '0+svn~166';
 my $dep5_last_overhaul = '0+svn~148';
@@ -65,13 +65,13 @@ if (not -f $copyright_filename) {
 
 return unless defined $copyright_filename;
 
-$_ = slurp_entire_file($copyright_filename);
-study $_;
+my $contents = slurp_entire_file ($copyright_filename);
+study $contents;
 
 my @dep5;
 my @lines;
 
-if (m{
+if ($contents =~ m{
     (^ | \n)
     (?i: format(:|[-\s]spec) )
     (?: . | \n\s+ )*
@@ -80,7 +80,7 @@ if (m{
 {
     # Before trying to parse the copyright as Debian control file, try to
     # determine the format URI.
-    my $first_para = $_;
+    my $first_para = $contents;
     $first_para =~ s,^#.*,,mg;
     $first_para =~ s,[ \t]+$,,mg;
     $first_para =~ s,^\n+,,g;
@@ -130,7 +130,9 @@ if (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 {
-                    @dep5 = read_dpkg_control($copyright_filename, 0, \@lines);
+                    open my $fd, '<', \$contents or fail "open <string>: $!";
+                    @dep5 = parse_dpkg_control ($fd, 0, \@lines);
+                    close $fd;
                 };
                 if ($@) {
                     chomp $@;
diff --git a/debian/changelog b/debian/changelog
index 29b2ec3..f6d4341 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -23,6 +23,10 @@ lintian (2.5.8) UNRELEASED; urgency=low
   * checks/shared-libs:
     + [NT] Fix false positive "dev-pkg-without-shlib-symlink"
       for shared libraries using "libtool -release X.Y".
+  * checks/source-copyright:
+    + [NT] Use the in-memory contents of the copyright file
+      instead of re-reading the file when parsing it as a
+      DEP-5 copyright file.
 
   * debian/control:
     + [NT] Add versioned Build-Depends on dpkg-dev (>= 1.16.1~)

-- 
Debian package checker


Reply to: