[SCM] Debian package checker branch, master, updated. 2.5.1-172-g7220ab2
The following commit has been merged in the master branch:
commit 7220ab25c0bc41030c760d22bc604be4edb715e4
Author: Niels Thykier <niels@thykier.net>
Date: Wed Aug 3 18:58:45 2011 +0200
Added 4th arg to L::Data::new and refactored c/control-files
Lintian::Data::new now accepts a 4th optional parameter, which is
expected to be a code sub to pre-process the key/value pairs.
Using this, the static tables from checks/control-files have been
refactored into data-files.
diff --git a/checks/control-files b/checks/control-files
index 8c2ac88..92b1f6c 100644
--- a/checks/control-files
+++ b/checks/control-files
@@ -25,30 +25,13 @@ use warnings;
use Util;
use Lintian::Tags qw(tag);
-my %ctrl_deb =
- (clilibs => 0644,
- config => 0755,
- control => 0644,
- conffiles => 0644,
- md5sums => 0644,
- postinst => 0755,
- preinst => 0755,
- postrm => 0755,
- prerm => 0755,
- shlibs => 0644,
- symbols => 0644,
- templates => 0644,
- triggers => 0644);
-
-my %ctrl_udeb =
- (config => 0755,
- control => 0644,
- isinstallable => 0755,
- menutest => 0755,
- postinst => 0755,
- shlibs => 0644,
- symbols => 0644,
- templates => 0644);
+sub octify {
+ my (undef, $val) = @_;
+ return oct($val);
+}
+
+my $DEB_PERMISSIONS = Lintian::Data->new('control-files/deb-permissions', qr/\s++/o, \&octify);
+my $UDEB_PERMISSIONS = Lintian::Data->new('control-files/udeb-permissions', qr/\s++/o, \&octify);
sub run {
@@ -56,8 +39,8 @@ my $pkg = shift;
my $type = shift;
my $info = shift;
-my %ctrl = $type eq 'udeb' ? %ctrl_udeb : %ctrl_deb;
-my %ctrl_alt = $type eq 'udeb' ? %ctrl_deb : %ctrl_udeb;
+my $ctrl = $type eq 'udeb' ? $UDEB_PERMISSIONS : $DEB_PERMISSIONS;
+my $ctrl_alt = $type eq 'udeb' ? $DEB_PERMISSIONS : $UDEB_PERMISSIONS;
# process control-index file
my $cindex = $info->control_index;
@@ -66,13 +49,13 @@ foreach my $file (sort keys %$cindex) {
my $cindex_info = $cindex->{$file};
my $owner;
my $operm;
+ my $experm;
-
- next if $file eq './';
+ next if $file eq '';
# valid control file?
- unless ( exists $ctrl{$file} ) {
- if ( exists $ctrl_alt{$file} ) {
+ unless ( $ctrl->known($file) ) {
+ if ( $ctrl_alt->known($file) ) {
tag 'not-allowed-control-file', $file;
next;
} else {
@@ -81,6 +64,8 @@ foreach my $file (sort keys %$cindex) {
}
}
+ $experm = $ctrl->value($file);
+
# I'm not sure about the udeb case
if ($type ne 'udeb' and $cindex_info->{size} == 0) {
tag 'control-file-is-empty', $file;
@@ -94,9 +79,9 @@ foreach my $file (sort keys %$cindex) {
$operm = $cindex_info->{operm};
# correct permissions?
- unless ($operm == $ctrl{$file}) {
+ unless ($operm == $experm) {
tag 'control-file-has-bad-permissions',
- sprintf('%s %04o != %04o',$file,$operm,$ctrl{$file});
+ sprintf('%s %04o != %04o', $file, $operm, $experm);
}
$owner = $cindex_info->{owner} . '/' . $cindex_info->{group};
diff --git a/data/control-files/deb-permissions b/data/control-files/deb-permissions
new file mode 100644
index 0000000..7e21e40
--- /dev/null
+++ b/data/control-files/deb-permissions
@@ -0,0 +1,17 @@
+# Manually maintained list of files in a deb control.tar.gz along
+# with their expected permissions.
+#
+
+clilibs 0644
+config 0755
+control 0644
+conffiles 0644
+md5sums 0644
+postinst 0755
+preinst 0755
+postrm 0755
+prerm 0755
+shlibs 0644
+symbols 0644
+templates 0644
+triggers 0644
\ No newline at end of file
diff --git a/data/control-files/udeb-permissions b/data/control-files/udeb-permissions
new file mode 100644
index 0000000..b6b06f4
--- /dev/null
+++ b/data/control-files/udeb-permissions
@@ -0,0 +1,12 @@
+# Manually maintained list of files in a udeb control.tar.gz along
+# with their expected permissions.
+#
+
+config 0755
+control 0644
+isinstallable 0755
+menutest 0755
+postinst 0755
+shlibs 0644
+symbols 0644
+templates 0644
diff --git a/debian/changelog b/debian/changelog
index aa8c3a1..73fab96 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -40,6 +40,8 @@ lintian (2.5.2) UNRELEASED; urgency=low
* checks/circular-deps.desc:
+ [NT] Fixed typo; thanks to Nicolás Alvarez for the report
and patch. (Closes: #630925)
+ * checks/control-files:
+ + [NT] Refactored static tables into data-files.
* checks/copyright-file:
+ [NT] Stricten one of the regexes for catching left over
helper templates. This should prevent false-positives for
@@ -172,6 +174,8 @@ lintian (2.5.2) UNRELEASED; urgency=low
+ [NT] Updated to handle source packages and with support for
multi tarball source packages.
+ * data/control-files/{,u}deb-permissions:
+ + [NT] Added files.
* data/fields/*:
+ [NT] Added new files based on data variables from checks/fields.
* data/fields/obsolete-packages:
@@ -239,6 +243,9 @@ lintian (2.5.2) UNRELEASED; urgency=low
+ [NT] Added support for appending output to files without
truncating them first via the new out_append and
err_append options.
+ * lib/Lintian/Data.pm:
+ + [NT] Let new take an optional fourth argument, a code sub,
+ that can be used to pre-process the value.
* lib/Lintian/{Internal/FrontendUtil,Profile}.pm:
+ [NT] New files.
* lib/Lintian/ProcessablePool.pm:
diff --git a/lib/Lintian/Data.pm b/lib/Lintian/Data.pm
index 98a7bc2..bf40577 100644
--- a/lib/Lintian/Data.pm
+++ b/lib/Lintian/Data.pm
@@ -30,7 +30,7 @@ use Carp qw(croak);
{
my %data;
sub new {
- my ($class, $type, $separator) = @_;
+ my ($class, $type, $separator, $code) = @_;
croak('no data type specified') unless $type;
unless (exists $data{$type}) {
my $dir = $ENV{LINTIAN_ROOT} . '/data';
@@ -45,6 +45,7 @@ use Carp qw(croak);
my ($key, $val);
if (defined $separator) {
($key, $val) = split(/$separator/, $_, 2);
+ $val = $code->($key, $val) if $code;
} else {
($key, $val) = ($_ => 1);
}
@@ -115,7 +116,7 @@ easily editable files.
=over 4
-=item new(TYPE [,SEPARATOR])
+=item new(TYPE [,SEPARATOR[, CODE]])
Creates a new Lintian::Data object for the given TYPE. TYPE is a partial
path relative to the F<data> directory and should correspond to a file in
@@ -126,6 +127,11 @@ exception.
If SEPARATOR is given, it will be used as a regular expression for splitting
the lines into key/value pairs.
+If CODE is also given, it is assumed to be a sub that will pre-process
+the key/value pairs. The sub will be called once for each key/pair
+value with the key as the first and the value as the second argument.
+The value returned is will be used as the value for the key.
+
A given file will only be loaded once. If new() is called again with the
same TYPE argument, the data previously loaded will be reused, avoiding
multiple file reads.
--
Debian package checker
Reply to: