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,
28 # Used to match Ubuntu distribution names in target distributions.
31 my $dists = Maemian::Data->new('changelog-file/ubuntu-dists');
32 my $string = join ('|', 'ubuntu', $dists->all);
33 $UBUNTU_REGEX = qr/$string/o;
42 my $changelog_mentions_nmu = 0;
43 my $changelog_mentions_local = 0;
44 my $changelog_mentions_qa = 0;
46 # This isn't really an NMU check, but right now no other check looks at
47 # debian/changelog in source packages. Catch a debian/changelog file that's a
48 # symlink. If it was a symlink to a file we didn't unpack, bail rather than
50 if (-l "debfiles/changelog") {
51 tag "changelog-is-symlink", "";
52 return 0 unless -f "debfiles/changelog";
55 # Get some data from the changelog file.
56 my ($entry) = $info->changelog->data;
57 my $distribution = $entry->Distribution;
58 my $uploader = canonicalize($entry->Maintainer);
59 my $changes = $entry->Changes;
60 $changes =~ s/^(\s*\n)+//;
61 my $firstline = (split('\n', $changes))[0];
63 # Check the first line for QA and NMU mentions.
65 local $_ = $firstline;
66 if (/\bnmu\b/i or /non-maintainer upload/i) {
67 unless (/(ackno|\back\b|confir|incorporat).*(\bnmu\b|non-maintainer)/i) {
68 $changelog_mentions_nmu = 1;
71 $changelog_mentions_local = 1 if /\blocal\s+package\b/i;
72 $changelog_mentions_qa = 1 if /orphan/i or /qa (?:group )?upload/i;
75 my $version = $info->field("version");
76 my $maintainer = canonicalize($info->field("maintainer"));
77 my $uploaders = $info->field("uploaders");
79 my $version_nmuness = 0;
80 my $version_local = 0;
81 if ($version =~ /-[^.-]+(\.[^.-]+)?(\.[^.-]+)?$/) {
82 $version_nmuness = 1 if defined $1;
83 $version_nmuness = 2 if defined $2;
85 if ($version =~ /\+nmu\d+$/) {
88 if ($version =~ /\+b\d+$/) {
91 if ($version =~ /local/i) {
95 my $upload_is_nmu = $uploader ne $maintainer;
96 if (defined $uploaders) {
97 my @uploaders = map { canonicalize($_) } split /,/, $uploaders;
98 $upload_is_nmu = 0 if grep /^\s*\Q$uploader\E\s*$/, @uploaders;
101 # No such thing as NMUs in Ubuntu-land.
102 if ($version =~ /$UBUNTU_REGEX/ or $distribution =~ /$UBUNTU_REGEX/) {
104 $version_nmuness = 0;
107 if ($maintainer =~ /packages\@qa.debian.org/) {
108 tag "orphaned-package-should-not-have-uploaders", ""
109 if defined $uploaders;
110 tag "qa-upload-has-incorrect-version-number", "$version"
111 if $version_nmuness == 1;
112 tag "changelog-should-mention-qa", ""
113 if !$changelog_mentions_qa;
115 # Local packages may be either NMUs or not.
116 unless ($changelog_mentions_local || $version_local) {
117 tag "changelog-should-mention-nmu", ""
118 if !$changelog_mentions_nmu && $upload_is_nmu;
119 tag "source-nmu-has-incorrect-version-number", "$version"
120 if $upload_is_nmu && $version_nmuness != 1;
122 tag "changelog-should-not-mention-nmu", ""
123 if $changelog_mentions_nmu && !$upload_is_nmu;
124 tag "maintainer-upload-has-incorrect-version-number", "$version"
125 if !$upload_is_nmu && $version_nmuness;
130 # Canonicalize a maintainer address with respect to case. E-mail addresses
131 # are case-insensitive in the right-hand side.
133 my ($maintainer) = @_;
134 $maintainer =~ s/(<[^>\@]+\@)([\w.-]+)>/$1 . lc ($2)/e;
141 # indent-tabs-mode: t
142 # cperl-indent-level: 8