[SCM] Debian package checker branch, master, updated. 2.2.10-81-gf594b61
The following commit has been merged in the master branch:
commit 42c89c0aeb6bcdb2789a9d97eaf012a7037748dd
Author: Raphael Geissert <atomo64@gmail.com>
Date: Sat May 2 14:36:12 2009 -0500
Test for correct Unpack-Level values
diff --git a/checks/debhelper.desc b/checks/debhelper.desc
index 268dae2..b8805e8 100644
--- a/checks/debhelper.desc
+++ b/checks/debhelper.desc
@@ -2,7 +2,7 @@ Check-Script: debhelper
Author: Joey Hess <joeyh@debian.org>
Abbrev: dh
Type: source
-Unpack-Level: 2
+Unpack-Level: 1
Info: This looks for common mistakes in debhelper source packages.
Needs-Info: debfiles, source-control-file
diff --git a/checks/menu-format.desc b/checks/menu-format.desc
index ae5db97..416123f 100644
--- a/checks/menu-format.desc
+++ b/checks/menu-format.desc
@@ -3,7 +3,7 @@ Author: Joey Hess <joeyh@master.debian.org>
Abbrev: mnf
Needs-Info: menu-files
Type: binary
-Unpack-Level: 1
+Unpack-Level: 2
Info: This script validates the format of menu files.
Tag: old-format-menu-file
diff --git a/checks/menus.desc b/checks/menus.desc
index 517c514..6043add 100644
--- a/checks/menus.desc
+++ b/checks/menus.desc
@@ -2,7 +2,7 @@ Check-Script: menus
Author: Christian Schwarz <schwarz@debian.org>
Abbrev: men
Type: binary
-Unpack-Level: 1
+Unpack-Level: 2
Needs-Info: doc-base-files
Tag: postinst-should-not-set-usr-doc-link
diff --git a/checks/po-debconf.desc b/checks/po-debconf.desc
index 6707793..bd8d41a 100644
--- a/checks/po-debconf.desc
+++ b/checks/po-debconf.desc
@@ -2,7 +2,7 @@ Check-Script: po-debconf
Author: Denis Barbier <barbier@linuxfr.org>
Abbrev: pd
Type: source
-Unpack-Level: 2
+Unpack-Level: 1
Info: This looks for common mistakes in packages using po-debconf.
Needs-Info: debfiles
diff --git a/t/scripts/needs-info.t b/t/scripts/unpack-level.t
old mode 100755
new mode 100644
similarity index 61%
copy from t/scripts/needs-info.t
copy to t/scripts/unpack-level.t
index 104193f..0b0abf3
--- a/t/scripts/needs-info.t
+++ b/t/scripts/unpack-level.t
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/perl -w
# Copyright (C) 2009 by Raphael Geissert <atomo64@gmail.com>
# Copyright (C) 2009 Russ Allbery <rra@debian.org>
@@ -19,7 +19,7 @@
use strict;
use Test::More;
-use Util qw(read_dpkg_control);
+use Util qw(read_dpkg_control slurp_entire_file);
# Find all of the desc files in either collection or checks. We'll do one
# check per description.
@@ -27,18 +27,37 @@ our @DESCS = (<$ENV{LINTIAN_ROOT}/collection/*.desc>,
<$ENV{LINTIAN_ROOT}/checks/*.desc>);
plan tests => scalar(@DESCS);
-# For each desc file, load the first stanza of the file and check that all of
-# its Needs-Info script references exist.
+my @l2refs = (
+ qr<unpacked/>,
+ qr<unpacked-errors>,
+ qr<chdir\s*\(\s*["']unpacked/?['"]\s*\)>,
+);
+
+# For each desc file, load the first stanza of the file and check that if
+# the unpack level is one no reference to unpack/ should be made, and if
+# it is level two then there should be a reference
for my $desc (@DESCS) {
my ($header) = read_dpkg_control($desc);
- my @needs = split(/\s*,\s*/, $header->{'needs-info'} || '');
- my @missing;
- for my $coll (@needs) {
- unless (-f "$ENV{LINTIAN_ROOT}/collection/$coll") {
- push(@missing, $coll);
- }
+
+ if ($desc =~ m/lintian\.desc$/) {
+ ok(1, "lintian.desc has valid unpack-level");
+ next;
+ }
+
+ my $level = $header->{'unpack-level'};
+ chomp $level;
+ my ($file) = split(/\.desc$/, $desc);
+ my $code = slurp_entire_file($file);
+ my $requiredlevel = 1;
+
+ for my $l2ref (@l2refs) {
+ if ($code =~ m/$l2ref/) {
+ $requiredlevel = 2;
+ last;
+ }
}
my $short = $desc;
$short =~ s/^\Q$ENV{LINTIAN_ROOT}//;
- is(join(', ', @missing), '', "$short has valid needs-info");
+
+ ok($level eq $requiredlevel, "$short has valid unpack-level ($level eq $requiredlevel)");
}
--
Debian package checker
Reply to: