1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
|
# nmu -- lintian check script -*- perl -*-
# Copyright (C) 2004 Jeroen van Wolffelaar
#
# 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, you can find it on the World Wide
# Web at http://www.gnu.org/copyleft/gpl.html, or write to the Free
# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
# MA 02110-1301, USA.
package Lintian::nmu;
use strict;
use Tags;
use Util;
sub run {
my $pkg = shift;
my $type = shift;
my $changelog_mentions_nmu = 0;
my $changelog_mentions_qa = 0;
my $uploader = undef;
# This isn't really an NMU check, but right now no other check looks at
# debian/changelog in source packages. Catch a debian/changelog file that's a
# symlink. If it was a symlink to a file we didn't unpack, bail rather than
# abort.
if (-l "debfiles/changelog") {
tag "changelog-is-symlink", "";
return 0 unless -f "debfiles/changelog";
}
open CHANGELOG, "debfiles/changelog" or fail("Failed opening changelog");
<CHANGELOG>;
my $firstline = 1;
while (<CHANGELOG>) {
if ($firstline) {
$changelog_mentions_nmu = 1
if (/\bnmu\b/i or /non-maintainer upload/i) and not /(ackno|confir)/i;
$changelog_mentions_qa = 1 if /orphan/i or /qa (?:group )?upload/i;
$firstline = 0 if /^\s+\S/;
}
if (/^ -- ([^>]+>)/) {
$uploader = $1;
last;
}
}
close CHANGELOG;
my $version = getfield("version");
my $maintainer = getfield("maintainer");
my $uploaders = getfield("uploaders");
my $version_nmuness = 0;
if ($version =~ /-[^.-]+(\.[^.-]+)?(\.[^.-]+)?$/) {
$version_nmuness = 1 if defined $1;
$version_nmuness = 2 if defined $2;
}
my $upload_is_nmu = $uploader ne $maintainer;
if (defined $uploaders) {
my @uploaders = split /,/, $uploaders;
$upload_is_nmu = 0 if grep /^\s*\Q$uploader\E\s*$/, @uploaders;
}
if ($maintainer =~ /packages\@qa.debian.org/) {
tag "orphaned-package-should-not-have-uploaders", ""
if defined $uploaders;
tag "qa-upload-has-incorrect-version-number", "$version"
if $version_nmuness;
tag "changelog-should-mention-qa", ""
if !$changelog_mentions_qa;
} else {
tag "changelog-should-mention-nmu", ""
if !$changelog_mentions_nmu && $upload_is_nmu;
tag "changelog-should-not-mention-nmu", ""
if $changelog_mentions_nmu && !$upload_is_nmu;
tag "source-nmu-has-incorrect-version-number", "$version"
if $upload_is_nmu && $version_nmuness != 1;
tag "maintainer-upload-has-incorrect-version-number", "$version"
if !$upload_is_nmu && $version_nmuness;
}
}
sub getfield {
return undef if not open FIELD, "fields/".shift;
my $field = <FIELD>;
close FIELD;
$field =~ s/\n$//;
return $field;
}
1;
# vim: ts=4 sw=4
|