1 # nmu -- lintian check script -*- perl -*-
3 # Copyright (C) 2004 Jeroen van Wolffelaar
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, you can find it on the World Wide
17 # Web at http://www.gnu.org/copyleft/gpl.html, or write to the Free
18 # Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
30 my $changelog_mentions_nmu = 0;
31 my $changelog_mentions_qa = 0;
34 # This isn't really an NMU check, but right now no other check looks at
35 # debian/changelog in source packages. Catch a debian/changelog file that's a
36 # symlink. If it was a symlink to a file we didn't unpack, bail rather than
38 if (-l "debfiles/changelog") {
39 tag "changelog-is-symlink", "";
40 return 0 unless -f "debfiles/changelog";
43 open (CHANGELOG, '<', "debfiles/changelog")
44 or fail("Failed opening changelog");
49 $changelog_mentions_nmu = 1
50 if (/\bnmu\b/i or /non-maintainer upload/i) and not /(ackno|\back\b|confir|incorporat)/i;
51 $changelog_mentions_qa = 1 if /orphan/i or /qa (?:group )?upload/i;
52 $firstline = 0 if /^\s+\S/;
54 if (/^ -- ([^>]+>)/) {
55 $uploader = canonicalize($1);
61 my $version = getfield("version");
62 my $maintainer = canonicalize(getfield("maintainer"));
63 my $uploaders = getfield("uploaders");
65 my $version_nmuness = 0;
66 if ($version =~ /-[^.-]+(\.[^.-]+)?(\.[^.-]+)?$/) {
67 $version_nmuness = 1 if defined $1;
68 $version_nmuness = 2 if defined $2;
70 if ($version =~ /\+nmu\d+$/) {
73 if ($version =~ /\+b\d+$/) {
77 my $upload_is_nmu = $uploader ne $maintainer;
78 if (defined $uploaders) {
79 my @uploaders = map { canonicalize($_) } split /,/, $uploaders;
80 $upload_is_nmu = 0 if grep /^\s*\Q$uploader\E\s*$/, @uploaders;
83 # No such thing as NMUs in Ubuntu-land.
84 if ($version =~ /ubuntu/) {
89 if ($maintainer =~ /packages\@qa.debian.org/) {
90 tag "orphaned-package-should-not-have-uploaders", ""
91 if defined $uploaders;
92 tag "qa-upload-has-incorrect-version-number", "$version"
93 if $version_nmuness == 1;
94 tag "changelog-should-mention-qa", ""
95 if !$changelog_mentions_qa;
97 tag "changelog-should-mention-nmu", ""
98 if !$changelog_mentions_nmu && $upload_is_nmu;
99 tag "changelog-should-not-mention-nmu", ""
100 if $changelog_mentions_nmu && !$upload_is_nmu;
101 tag "source-nmu-has-incorrect-version-number", "$version"
102 if $upload_is_nmu && $version_nmuness != 1;
103 tag "maintainer-upload-has-incorrect-version-number", "$version"
104 if !$upload_is_nmu && $version_nmuness;
110 return undef if not open (FIELD, '<', "fields/" . shift);
117 # Canonicalize a maintainer address with respect to case. E-mail addresses
118 # are case-insensitive in the right-hand side.
120 my ($maintainer) = @_;
121 $maintainer =~ s/(<[^>\@]+\@)([\w.-]+)>/$1 . lc ($2)/e;
128 # indent-tabs-mode: t
129 # cperl-indent-level: 8