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

[SCM] Debian package checker branch, master, updated. 2.5.10-23-g85b8dce



The following commit has been merged in the master branch:
commit 867f001b19297d2ddd8f94d1ad17d0f911b7d997
Author: Niels Thykier <niels@thykier.net>
Date:   Wed Jul 11 20:11:53 2012 +0200

    c/*: Use $info->lab_data_path to access files in the lab
    
    Signed-off-by: Niels Thykier <niels@thykier.net>

diff --git a/checks/apache2 b/checks/apache2
index af75bd1..759c13c 100644
--- a/checks/apache2
+++ b/checks/apache2
@@ -179,7 +179,8 @@ sub check_module_package {
 sub check_maintainer_scripts {
     my ($info) = @_;
 
-    open my $fd, '<', 'control-scripts' or fail "cannot open lintian control-scripts file: $!";
+    open my $fd, '<', $info->lab_data_path ('control-scripts')
+        or fail "cannot open lintian control-scripts file: $!";
 
     while (<$fd>)
     {
diff --git a/checks/changelog-file b/checks/changelog-file
index c0e39f4..718e3d8 100644
--- a/checks/changelog-file
+++ b/checks/changelog-file
@@ -142,12 +142,13 @@ if ($#doc_files < 0) {
 # Check a NEWS.Debian file if we have one.  Save the parsed version of the
 # flie for later checks against the changelog file.
 my $news;
-if (-f 'NEWS.Debian') {
-    my $line = file_is_encoded_in_non_utf8('NEWS.Debian', $type, $pkg);
+my $dnews = $info->lab_data_path ('NEWS.Debian');
+if (-f $dnews) {
+    my $line = file_is_encoded_in_non_utf8 ($dnews, $type, $pkg);
     if ($line) {
         tag 'debian-news-file-uses-obsolete-national-encoding', "at line $line"
     }
-    my $changes = Parse::DebianChangelog->init( { infile => 'NEWS.Debian', quiet => 1 } );
+    my $changes = Parse::DebianChangelog->init( { infile => $dnews, quiet => 1 } );
     if (my @errors = $changes->get_parse_errors) {
         for (@errors) {
             tag 'syntax-error-in-debian-news-file', "line $_->[1]", "\"$_->[2]\"";
@@ -239,22 +240,23 @@ if ($native_pkg) {
     }
 }
 
+my $dchpath = $info->lab_data_path ('changelog');
 # Everything below involves opening and reading the changelog file, so bail
 # with a warning at this point if all we have is a symlink.  Ubuntu permits
 # such symlinks, so their profile will suppress this tag.
-if (-l 'changelog') {
+if (-l $dchpath) {
     tag 'debian-changelog-file-is-a-symlink';
     return 0;
 }
 
 # Bail at this point if the changelog file doesn't exist.  We will have
 # already warned about this.
-unless (-f 'changelog') {
+unless (-f $dchpath) {
     return 0;
 }
 
 # check that changelog is UTF-8 encoded
-my $line = file_is_encoded_in_non_utf8('changelog', $type, $pkg);
+my $line = file_is_encoded_in_non_utf8 ($dchpath, $type, $pkg);
 if ($line) {
     tag 'debian-changelog-file-uses-obsolete-national-encoding', "at line $line"
 }
@@ -269,7 +271,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);
+my $chloff = check_dch ($pkg, $type, $dchpath);
 
 my @entries = $changelog->data;
 if (@entries) {
@@ -406,14 +408,14 @@ if (@entries) {
 # the first line of text in the first entry.
 #
 sub check_dch {
-    my ($pkg, $type) = @_;
+    my ($pkg, $type, $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 (IN, '<', 'changelog')
+    open IN, '<', $path
         or fail("cannot find changelog for $type package $pkg");
     my ($prefix, $suffix);
     my $lineno = 0;
diff --git a/checks/changes-file b/checks/changes-file
index 0c7a749..d4249c5 100644
--- a/checks/changes-file
+++ b/checks/changes-file
@@ -91,7 +91,7 @@ if ($info->field('changed-by')) {
 }
 
 my $files = $info->files;
-my $path = readlink('changes');
+my $path = readlink ($info->lab_data_path ('changes'));
 $path =~ s#/[^/]+$##;
 foreach my $file (keys %$files) {
     my $file_info = $files->{$file};
diff --git a/checks/copyright-file b/checks/copyright-file
index b89543c..627a1fd 100644
--- a/checks/copyright-file
+++ b/checks/copyright-file
@@ -100,14 +100,15 @@ if (not $found) {
       unless $pkg eq 'perl';
 }
 
+my $dcopy = $info->lab_data_path ('copyright');
 # check that copyright is UTF-8 encoded
-my $line = file_is_encoded_in_non_utf8('copyright', $type, $pkg);
+my $line = file_is_encoded_in_non_utf8 ($dcopy, $type, $pkg);
 if ($line) {
     tag 'debian-copyright-file-uses-obsolete-national-encoding', "at line $line"
 }
 
 # check contents of copyright file
-$_ = slurp_entire_file('copyright');
+$_ = slurp_entire_file ($dcopy);
 study $_;
 
 if (m,\r,) {
diff --git a/checks/cruft b/checks/cruft
index ece468f..ff67730 100644
--- a/checks/cruft
+++ b/checks/cruft
@@ -196,8 +196,9 @@ for my $file (@EOL_TERMINATORS_FILES) {
 # isn't just tar cruft.
 for my $file (keys %ERRORS) {
     my $tag = $ERRORS{$file};
-    if (-s $file) {
-        open(ERRORS, '<', $file) or fail("cannot open $file: $!");
+    my $path = $info->lab_data_path ($file);
+    if (-s $path) {
+        open ERRORS, '<', $path or fail "cannot open $file: $!";
         local $_;
         while (<ERRORS>) {
             chomp;
diff --git a/checks/deb-format b/checks/deb-format
index cab533b..dcca0b2 100644
--- a/checks/deb-format
+++ b/checks/deb-format
@@ -36,10 +36,12 @@ my $pkg = shift;
 my $type = shift;
 my $info = shift;
 
+my $deb = $info->lab_data_path ('deb');
+
 # Run ar t on the *.deb file.  deb will be a symlink to it.
 my $okay = 0;
 my $opts = {};
-my $success = spawn($opts, ['ar', 't', 'deb']);
+my $success = spawn ($opts, ['ar', 't', $deb]);
 if ($success) {
     my @members = split("\n", ${ $opts->{out} });
     if (@members != 3) {
@@ -80,7 +82,7 @@ if ($success) {
 # permitted in the archive yet.
 if ($okay) {
     $opts = {};
-    $success = spawn($opts, ['ar', 'p', 'deb', 'debian-binary']);
+    $success = spawn ($opts, ['ar', 'p', $deb, 'debian-binary']);
     if (not $success) {
         tag 'malformed-deb-archive', "can't read debian-binary member";
     } elsif (${ $opts->{out} } !~ /^2\.\d+\n/) {
@@ -94,8 +96,9 @@ if ($okay) {
 # just tar noise that doesn't represent an actual problem.
 for my $file (keys %ERRORS) {
     my $tag = $ERRORS{$file};
-    if (-s $file) {
-        open(ERRORS, '<', $file) or fail("cannot open $file: $!");
+    my $path = $info->lab_data_path ($file);
+    if (-s $path) {
+        open ERRORS, '<', $path or fail "cannot open $file: $!";
         local $_;
         while (<ERRORS>) {
             chomp;
diff --git a/checks/debian-readme b/checks/debian-readme
index 2d46f19..2ae459c 100644
--- a/checks/debian-readme
+++ b/checks/debian-readme
@@ -29,9 +29,10 @@ sub run {
 
 my $pkg = shift;
 my $type = shift;
+my $info = shift;
 my $readme = '';
 
-if (open(IN, '<', 'README.Debian')) {
+if (open (IN, '<', $info->lab_data_path ('README.Debian'))) {
     local $_;
     while (<IN>) {
         if (m,/usr/doc\b,) {
diff --git a/checks/init.d b/checks/init.d
index 99d6958..be04e91 100644
--- a/checks/init.d
+++ b/checks/init.d
@@ -68,6 +68,8 @@ my $pkg = shift;
 my $type = shift;
 my $info = shift;
 
+my $initd_dir = $info->lab_data_path ('init.d');
+
 my $postinst = $info->control('postinst');
 my $preinst = $info->control('preinst');
 my $postrm = $info->control('postrm');
@@ -171,36 +173,38 @@ if (open(IN, '<', $conffiles)) {
     close(IN);
 }
 
-for (keys %initd_postinst) {
-    next if /^\$/;
-    my $initd_file = "init.d/$_";
+foreach my $initd_file (keys %initd_postinst) {
+    next unless $initd_file;
+    my $initd_path = "$initd_dir/$initd_file";
 
     # init.d scripts have to be marked as conffiles unless they're symlinks.
-    unless ($conffiles{"/etc/init.d/$_"} or $conffiles{"etc/init.d/$_"}
-            or -l $initd_file) {
-        tag 'init.d-script-not-marked-as-conffile', "etc/init.d/$_";
+    unless ($conffiles{"/etc/init.d/$initd_file"} or $conffiles{"etc/init.d/$initd_file"}
+            or -l $initd_path) {
+        tag 'init.d-script-not-marked-as-conffile', "etc/init.d/$initd_file";
     }
 
     # Check if file exists in package and check the script for other issues if
     # it was included in the package.
-    if (-f $initd_file) {
-        check_init($initd_file);
-    } elsif (not -l $initd_file) {
-        tag 'init.d-script-not-included-in-package', "etc/init.d/$_";
+    if (-f $initd_path) {
+        check_init ($initd_file, $initd_path);
+    } elsif (not -l $initd_path) {
+        tag 'init.d-script-not-included-in-package', "etc/init.d/$initd_file";
     }
 }
 
 # files actually installed in /etc/init.d should match our list :-)
-opendir(INITD, 'init.d') or fail("cannot read init.d directory: $!");
-for (readdir(INITD)) {
-    my $script = $_;
+opendir INITD, $initd_dir
+    or fail "cannot read init.d directory: $!";
+for my $script (readdir(INITD)) {
     my $tagname = 'script-in-etc-init.d-not-registered-via-update-rc.d';
     next if grep {$script eq $_} qw(. .. README skeleton rc rcS);
 
+    my $script_path = "$initd_dir/$script";
+
     # In an upstart system, such as Ubuntu, init scripts are symlinks to
     # upstart-job which are not registered with update-rc.d.
-    if (-l "init.d/$_") {
-        my $target = readlink("init.d/$_");
+    if (-l $script_path) {
+        my $target = readlink ($script_path);
         if ($target =~ m,(?:\A|/)lib/init/upstart-job\z,) {
             $tagname = 'upstart-job-in-etc-init.d-not-registered-via-update-rc.d';
         }
@@ -212,7 +216,7 @@ for (readdir(INITD)) {
     # that we get more complete Lintian coverage in the first pass.
     unless ($initd_postinst{$script}) {
         tag $tagname, "etc/init.d/$script";
-        check_init("init.d/$script") if -f "init.d/$script";
+        check_init ($script, $script_path) if -f $script_path;
     }
 }
 closedir(INITD);
@@ -220,18 +224,18 @@ closedir(INITD);
 }
 
 sub check_init {
-    my ($initd_file) = @_;
+    my ($initd_file, $initd_path) = @_;
 
     # In an upstart system, such as Ubuntu, init scripts are symlinks to
     # upstart-job.  It doesn't make sense to check the syntax of upstart-job,
     # so skip the checks of the init script itself in that case.
-    if (-l $initd_file) {
-        my $target = readlink($initd_file);
+    if (-l $initd_path) {
+        my $target = readlink ($initd_path);
         if ($target =~ m,(?:\A|/)lib/init/upstart-job\z,) {
             return;
         }
     }
-    open(IN, '<', $initd_file)
+    open IN, '<', $initd_path
         or fail("cannot open init.d file $initd_file: $!");
     my (%tag, %lsb);
     my $in_file_test = 0;
diff --git a/checks/menu-format b/checks/menu-format
index fcee4e9..5c3df12 100644
--- a/checks/menu-format
+++ b/checks/menu-format
@@ -331,12 +331,13 @@ my $info = shift;
 my $proc = shift;
 my $group = shift;
 
+my $mdir = $info->lab_data_path ('menu');
 my @menufiles;
-opendir (MENUDIR, 'menu/lib') or fail('cannot read menu/lib file directory.');
-push @menufiles, map { "menu/lib/$_" } readdir(MENUDIR);
+opendir MENUDIR, "$mdir/lib" or fail 'cannot read menu/lib file directory';
+push @menufiles, map { "$mdir/lib/$_" } readdir (MENUDIR);
 closedir MENUDIR;
-opendir (MENUDIR, 'menu/share') or fail('cannot read menu/share file directory.');
-push @menufiles, map { "menu/share/$_" } readdir(MENUDIR);
+opendir MENUDIR, "$mdir/share" or fail 'cannot read menu/share file directory';
+push @menufiles, map { "$mdir/share/$_" } readdir (MENUDIR);
 closedir MENUDIR;
 
 # Find the desktop files in the package for verification.
@@ -370,7 +371,7 @@ foreach my $menufile (@menufiles) {
 
     my $basename = basename $menufile;
     my $fullname = "usr/share/menu/$basename";
-    $fullname = "usr/lib/menu/$basename" if $menufile =~ m,^menu/lib/,o;
+    $fullname = "usr/lib/menu/$basename" if $menufile =~ m,^\Q$mdir\E/lib/,;
 
     next if $basename eq 'README'; # README is a special case
 
diff --git a/checks/menus b/checks/menus
index 01be751..af093b2 100644
--- a/checks/menus
+++ b/checks/menus
@@ -128,7 +128,8 @@ for my $file ($info->sorted_index) {
             $local_file =~ s,^etc/menu-methods/,,;
             $menumethod_file = $file;
 
-            open(MM, '<', "menu/methods/$local_file") or fail("cannot open menu-method file $local_file: $!");
+            open MM, '<', $info->lab_data_path ("menu/methods/$local_file")
+                or fail "cannot open menu-method file $local_file: $!";
             while (<MM>) {
                 chomp;
                 if (m,^!include menu.h,o) {
@@ -184,12 +185,14 @@ if ($prerm{'calls-installdocs'} or $prerm{'calls-installdocs-r'}) {
 # check consistency
 # docbase file?
 if ($docbase_file) {
-    opendir DOCBASEDIR, 'doc-base' or fail("cannot read doc-base directory.");
+    opendir DOCBASEDIR, $info->lab_data_path ('doc-base')
+        or fail "cannot read doc-base directory";
     my $dbfile;
     while (defined ($dbfile = readdir DOCBASEDIR)) {
+        my $dbpath = $info->lab_data_path ("doc-base/$dbfile");
         # don't try to parse executables, plus we already warned about it
-        next if -x "doc-base/$dbfile";
-        check_doc_base_file($dbfile, $pkg, $type, \%all_files, \%all_links);
+        next if -x $dbfile;
+        check_doc_base_file ($dbfile, $dbpath, $pkg, $type, \%all_files, \%all_links);
     }
     closedir DOCBASEDIR;
 } elsif ($documentation) {
@@ -233,15 +236,15 @@ if ($anymenu_file) {
 # -----------------------------------
 
 sub check_doc_base_file {
-    my ($dbfile, $pkg, $type, $all_files, $all_links) = @_;
+    my ($dbfile, $dbpath, $pkg, $type, $all_files, $all_links) = @_;
 
-    my $line = file_is_encoded_in_non_utf8("doc-base/$dbfile", $type, $pkg);
+    my $line = file_is_encoded_in_non_utf8 ($dbpath, $type, $pkg);
     if ($line) {
         tag 'doc-base-file-uses-obsolete-national-encoding', "$dbfile:$line";
     }
 
-    open (IN, '<', "doc-base/$dbfile")
-        or fail("cannot open doc-base file $dbfile for reading.");
+    open IN, '<', $dbpath
+        or fail "cannot open doc-base file doc-base/$dbfile for reading";
 
     my (@files, $field, @vals);
     my $knownfields = \%KNOWN_DOCBASE_MAIN_FIELDS;
diff --git a/checks/ocaml b/checks/ocaml
index 26d4eb7..5ba796a 100644
--- a/checks/ocaml
+++ b/checks/ocaml
@@ -40,7 +40,8 @@ my $info = shift;
 
 # Collect information about .a files from ar-info dump
 my %provided_o;
-open ARINFO, '<', 'ar-info' or fail "opening ar-info: $!";
+open ARINFO, '<', $info->lab_data_path ('ar-info')
+    or fail "opening ar-info: $!";
 while (<ARINFO>) {
     chomp;
     if (/^(?:\.\/)?([^:]+): (.*)$/) {
diff --git a/checks/scripts b/checks/scripts
index bc0dc69..8a770ec 100644
--- a/checks/scripts
+++ b/checks/scripts
@@ -421,7 +421,7 @@ foreach (keys %executable) {
                  );
 }
 
-open(SCRIPTS, '<', 'control-scripts')
+open SCRIPTS, '<', $info->lab_data_path ('control-scripts')
     or fail("cannot open lintian control-scripts file: $!");
 
 # Handle control scripts.  This is an edited version of the code for
diff --git a/debian/changelog b/debian/changelog
index 2beb7df..a029bf5 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -7,6 +7,9 @@ lintian (2.5.11) UNRELEASED; urgency=low
       - apparently-truncated-elf-binary
       - data.tar.xz-member-without-dpkg-pre-depends
 
+  * checks/*:
+    + [NT] Remove assumption that lintian will chdir into the
+      the lab before calling the check.
   * checks/binaries{,.desc}:
     + [NT] Merge apparently-truncated-elf-binary into
       apparently-corrupted-elf-binary.

-- 
Debian package checker


Reply to: