[SCM] Debian package checker branch, master, updated. 2.1.4-5-gf8d6a2a
The following commit has been merged in the master branch:
commit 64482a24e771ed9f97483febab9f7119ad865eb1
Author: Russ Allbery <rra@debian.org>
Date: Sat Jan 10 10:48:30 2009 -0800
Move maintainer checks into a Lintian::Check module
* checks/fields:
+ [RA] Use check_maintainer from Lintian::Check.
* lib/Lintian/Check.pm:
+ [RA] New module collecting checks run from multiple places.
Move check_maint from checks/fields to check_maintainer in Lintian::Check.
This is preparation for doing the same checks on *.changes files.
diff --git a/checks/fields b/checks/fields
index 0a650ac..9f15aa4 100644
--- a/checks/fields
+++ b/checks/fields
@@ -30,7 +30,9 @@ use common_data;
use Dep;
use Tags;
use Util;
+
use Lintian::Data;
+use Lintian::Check qw(check_maintainer);
# The allowed Python dependencies currently. This is the list of alternatives
# that, either directly or through transitive dependencies that can be relied
@@ -252,9 +254,9 @@ for my $f (qw(maintainer uploaders)) {
$maintainer =~ s/^\s*(.+?)\s*$/$1/; #Remove leading and trailing whitespace
if ($f eq "uploaders") {
- check_maint($_, "uploader") for (split /\s*,\s*/, $maintainer);
+ check_maintainer($_, "uploader") for (split /\s*,\s*/, $maintainer);
} else {
- check_maint($maintainer, $f);
+ check_maintainer($maintainer, $f);
if ($type eq 'source'
&& $maintainer =~ /\@lists(\.alioth)?\.debian\.org\b/
&& ! defined $info->field('uploaders')) {
@@ -971,46 +973,6 @@ sub unfold {
}
}
-sub check_maint {
- my ($maintainer, $f) = @_;
- $maintainer =~ /^([^<\s]*(?:\s+[^<\s]+)*)?(\s*)(?:<(.+)>)?(.*)$/,
- my ($name, $del, $mail, $crap) = ($1, $2, $3, $4);
-
- if (!$mail && $name =~ m/@/) { # name probably missing and address has no <>
- $mail = $name;
- $name = undef;
- }
-
- tag "$f-address-malformed", "$maintainer" if $crap;
- tag "$f-address-looks-weird", "$maintainer" if ! $del && $name && $mail;
-
- # Wookey really only has one name. If we get more of these, consider
- # removing the check.
- if (! $name) {
- tag "$f-name-missing", "$maintainer";
- } elsif ($name !~ /^\S+\s+\S+/ && $name ne 'Wookey') {
- tag "$f-not-full-name", "$name";
- }
-
- #This should be done with Email::Valid:
- if (!$mail) {
- tag "$f-address-missing", "$maintainer";
- } else {
- tag "$f-address-malformed", "$maintainer"
- unless ($mail =~ /^[^()<>@,;:\\"[\]]+@(\S+\.)+\S+/); #"
-
- tag "$f-address-is-on-localhost", "$maintainer"
- if ($mail =~ /(?:localhost|\.localdomain|\.localnet)$/);
-
- tag "wrong-debian-qa-address-set-as-maintainer", "$maintainer"
- if ($f eq "maintainer" && $mail eq 'debian-qa@lists.debian.org');
-
- tag "wrong-debian-qa-group-name", "$maintainer"
- if ($f eq "maintainer" && $mail eq 'packages@qa.debian.org' &&
- $name ne 'Debian QA Group');
- }
-}
-
1;
# Local Variables:
diff --git a/debian/changelog b/debian/changelog
index c364396..b1de393 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -8,12 +8,17 @@ lintian (2.1.5) UNRELEASED; urgency=low
* checks/control-file{,.desc}:
+ [RA] Tag (severity: wishlist) duplicate short or long descriptions
in packages built from the same source. (Closes: #30020)
+ * checks/fields:
+ + [RA] Use check_maintainer from Lintian::Check.
* checks/rules:
+ [RA] Consider a define command to be the end of a list of target
commands, avoiding binary-arch-rules-but-pkg-is-arch-indep false
positives when an empty rule is followed by a definition.
(Closes: #510869)
+ * lib/Lintian/Check.pm:
+ + [RA] New module collecting checks run from multiple places.
+
-- Russ Allbery <rra@debian.org> Mon, 05 Jan 2009 10:41:18 -0800
lintian (2.1.4) unstable; urgency=low
diff --git a/lib/Lintian/Check.pm b/lib/Lintian/Check.pm
new file mode 100644
index 0000000..a8539ad
--- /dev/null
+++ b/lib/Lintian/Check.pm
@@ -0,0 +1,194 @@
+# -*- perl -*-
+# Lintian::Check -- Lintian checks shared between multiple scripts
+
+# Copyright (C) 2008 Russ Allbery
+# Copyright (C) 2004 Marc Brockschmidt
+# Copyright (C) 1998 Richard Braakman
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the Free
+# Software Foundation; either version 2 of the License, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+# more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# this program. If not, see <http://www.gnu.org/licenses/>.
+
+package Lintian::Check;
+
+use strict;
+use warnings;
+
+use Exporter ();
+use Tags qw(tag);
+
+our @ISA = qw(Exporter);
+our @EXPORT = qw(check_maintainer);
+
+=head1 NAME
+
+Lintian::Check -- Lintian checks shared between multiple scripts
+
+=head1 SYNOPSIS
+
+ use Lintian::Check qw(check_maintainer);
+
+ check_maintainer ($maintainer, $field);
+
+=head1 DESCRIPTION
+
+This module provides functions to do some Lintian checks that need to be
+done in multiple places. There are certain low-level checks, such as
+validating a maintainer name and e-mail address or checking spelling,
+which apply in multiple situations and should be done in multiple checks
+scripts or in checks scripts and the Lintian front-end.
+
+The functions provided by this module issue tags directly, usually either
+taking the tag name to issue as an argument or dynamically constructing
+the tag name based on function parameters. The caller is responsible for
+ensuring that all tags are declared in the relevant *.desc file with
+proper descriptions and other metadata. The possible tags issued by each
+function are described in the documentation for that function.
+
+=head1 FUNCTIONS
+
+=over 4
+
+=item check_maintainer(MAINTAINER, FIELD)
+
+Checks the maintainer name and address MAINTAINER for Policy compliance
+and other issues. FIELD is the context in which the maintainer name and
+address was seen and should be one of C<maintainer> (the Maintainer field
+in a control file), C<uploader> (the Uploaders field in a control file),
+or C<changes> (the Changed-By field in a changes file).
+
+The following tags may be issued by this function. The string C<%s> in
+the tags below will be replaced with the value of FIELD.
+
+=over 4
+
+=item %s-address-is-on-localhost
+
+The e-mail address portion of MAINTAINER is at C<localhost> or some other
+similar domain.
+
+=item %s-address-looks-weird
+
+MAINTAINER may be syntactically correct, but it isn't conventionally
+formatted. Currently this tag is only issued for missing whitespace
+between the name and the address.
+
+=item %s-address-malformed
+
+MAINTAINER doesn't fit the basic syntax of a maintainer name and address
+as specified in Policy.
+
+=item %s-address-missing
+
+MAINTAINER does not contain an e-mail address in angle brackets (<>).
+
+=item %s-name-missing
+
+MAINTAINER does not contain a full name before the address, or the e-mail
+address was not in angle brackets.
+
+=item %s-not-full-name
+
+The name portion of MAINTAINER is a single word. This tag is not issued
+for a FIELD of C<changes>.
+
+=item wrong-debian-qa-address-set-as-maintainer
+
+MAINTAINER appears to be the Debian QA Group, but the e-mail address
+portion is wrong for orphaned packages. This tag is only issued for a
+FIELD of C<maintainer>.
+
+=item wrong-debian-qa-group-name
+
+MAINTAINER appears to be the Debian QA Group, but the name portion is not
+C<Debian QA Group>. This tag is only issued for a FIELD of C<maintainer>.
+
+=back
+
+The last two tags are issued here rather than in a location more specific
+to checks of the Maintainer control field because they take advantage of
+the parsing done by the rest of the function.
+
+=cut
+
+sub check_maintainer {
+ my ($maintainer, $field) = @_;
+
+ # Do the initial parse.
+ $maintainer =~ /^([^<\s]*(?:\s+[^<\s]+)*)?(\s*)(?:<(.+)>)?(.*)$/;
+ my ($name, $del, $mail, $extra) = ($1, $2, $3, $4);
+ if (not $mail and $name =~ m/@/) {
+ # Name probably missing and address has no <>.
+ $mail = $name;
+ $name = undef;
+ }
+
+ # Some basic tests.
+ tag "$field-address-malformed", $maintainer
+ if $extra;
+ tag "$field-address-looks-weird", $maintainer
+ if (not $del and $name and $mail);
+
+ # Wookey really only has one name. If we get more of these, consider
+ # removing the check. Skip the full name check for changes files as it's
+ # not important there; we'll get it from the debian/control checks if
+ # needed.
+ if (not $name) {
+ tag "$field-name-missing", $maintainer;
+ } elsif ($name !~ /^\S+\s+\S+/ and $name ne 'Wookey') {
+ tag "$field-not-full-name", $name
+ if $field ne 'changes';
+ }
+
+ # This should really be done with Email::Valid.
+ if (not $mail) {
+ tag "$field-address-missing", $maintainer;
+ } else {
+ if ($mail !~ /^[^()<>@,;:\\\"\[\]]+@(\S+\.)+\S+/) {
+ tag "$field-address-malformed", $maintainer;
+ }
+ if ($mail =~ /(?:localhost|\.localdomain|\.localnet)$/) {
+ tag "$field-address-is-on-localhost", $maintainer;
+ }
+
+ # Some additional checks that we only do for maintainer fields.
+ if ($field eq 'maintainer') {
+ if ($mail eq 'debian-qa@lists.debian.org') {
+ tag 'wrong-debian-qa-address-set-as-maintainer', $maintainer;
+ } elsif ($mail eq 'packages@qa.debian.org') {
+ tag 'wrong-debian-qa-group-name', $maintainer
+ if ($name ne 'Debian QA Group');
+ }
+ }
+ }
+}
+
+=back
+
+=head1 AUTHOR
+
+Originally written by Russ Allbery <rra@debian.org> for Lintian. Based on
+code from checks scripts by Marc Brockschmidt and Richard Braakman.
+
+=head1 SEE ALSO
+
+lintian(1)
+
+=cut
+
+1;
+
+# Local Variables:
+# indent-tabs-mode: nil
+# cperl-indent-level: 4
+# End:
+# vim: syntax=perl sw=4 sts=4 ts=4 et shiftround
diff --git a/lib/Util.pm b/lib/Util.pm
index aa29c76..bea8da5 100644
--- a/lib/Util.pm
+++ b/lib/Util.pm
@@ -262,7 +262,6 @@ sub perm2oct {
return $o;
}
-
sub delete_dir {
return spawn(undef, ['rm', '-rf', '--', @_]);
}
@@ -300,3 +299,9 @@ sub fail {
}
1;
+
+# Local Variables:
+# indent-tabs-mode: t
+# cperl-indent-level: 4
+# End:
+# vim: syntax=perl sw=4 ts=8
--
Debian package checker
Reply to: