Daniel Dehennin <daniel.dehen...@baby-gnu.org> writes: Hello,
A new version of the patch rebased on top of master HEAD[1], two branches 1. A standalone branch which requires the patch from #652114 git pull git://git.baby-gnu.net/lintian dad/rebased-on-ddad0c6/bad-vendor-distribution-in-changes-file 2. A combined branch git pull git://git.baby-gnu.net/lintian dad/export-profile-for-checks+bad-vendor-distribution-in-changes-file Here is the patch against master for review (branch 2). Regards. Footnotes: [1] ddad0c63e5a2921d1590a58cf4009215020bd8d2 From 11cb7996dae884b1308f8d798d8b95f68ecfa3a3 Mon Sep 17 00:00:00 2001 From: Daniel Dehennin <daniel.dehen...@baby-gnu.org> Date: Wed, 14 Dec 2011 23:19:45 +0100 Subject: [PATCH] Generalize distribution name check: bad-vendor-distribution-in-changes-file. This patch allow to create a new data/changelog-file/<something>-dists file to add new valid distribution regexps. It use the lintian profiles mechanism to restrict the list of distribution to thoses of the current vendor and vendors it "Extends". Add the new "bad-vendor-distribution-in-changes-file" tag to catch non vendor specific distribution missmatch. Keep the backward compatibility "bad-ubuntu-distribution-in-changes-file" for ubuntu and "bad-distribution-in-changes-file" for debian. * profiles/test/main.profile: Fake profile to test the "bad-vendor-distribution-in-changes-file" tag. * t/changes/changes-bad-debian-distribution.desc: New test to check bad Debian distribution name. The version contains a Debian specific distribution to select the proper vendor. * t/changes/changes-bad-debian-distribution.changes.in: Sample changes file with the faulty "wispy" distribution. * t/changes/changes-bad-debian-distribution.tags: The tag must be "bad-distribution-in-changes-file". * t/changes/changes-bad-vendor-distribution.desc: New test to check bad cross vendor distribution name, all distribution for all vendors are tested. The version does not contain any vendor specific distribution name. * t/changes/changes-bad-vendor-distribution.changes.in: Sample changes file with the faulty "wispy" distribution. * t/changes/changes-bad-vendor-distribution.tags: The tag must be "bad-vendor-distribution-in-changes-file". * t/changes/changes-bad-ubuntu-distribution.desc (Profile): Use "ubuntu/main" to select the ubuntu tag. * checks/changes-file: Use a hash of vendor => regexp to check the distribution name. Use profile to check for debian and ubuntu vendors. * checks/changes-file.desc (Tag): Add note to check the profile and vendor distributions. Add the "bad-vendor-distribution-in-changes-file" for vendors other than debian and ubuntu. * data/changelog-file/debian-dists: Define full regexp instead of only base distribution. * data/changelog-file/ubuntu-dists: Ditoo. --- checks/changes-file | 61 +++++++++++++------- checks/changes-file.desc | 36 +++++++++++- data/changelog-file/debian-dists | 18 +++--- data/changelog-file/ubuntu-dists | 16 +++--- profiles/test/main.profile | 3 + .../changes-bad-debian-distribution.changes.in | 12 ++++ t/changes/changes-bad-debian-distribution.desc | 7 ++ t/changes/changes-bad-debian-distribution.tags | 1 + t/changes/changes-bad-ubuntu-distribution.desc | 1 + .../changes-bad-vendor-distribution.changes.in | 12 ++++ t/changes/changes-bad-vendor-distribution.desc | 7 ++ t/changes/changes-bad-vendor-distribution.tags | 1 + 12 files changed, 134 insertions(+), 41 deletions(-) create mode 100644 profiles/test/main.profile create mode 100644 t/changes/changes-bad-debian-distribution.changes.in create mode 100644 t/changes/changes-bad-debian-distribution.desc create mode 100644 t/changes/changes-bad-debian-distribution.tags create mode 100644 t/changes/changes-bad-vendor-distribution.changes.in create mode 100644 t/changes/changes-bad-vendor-distribution.desc create mode 100644 t/changes/changes-bad-vendor-distribution.tags diff --git a/checks/changes-file b/checks/changes-file index 5192130..60445bb 100644 --- a/checks/changes-file +++ b/checks/changes-file @@ -25,13 +25,37 @@ use warnings; use Util; use Lintian::Tags qw(tag); use Lintian::Check qw(check_maintainer); +use Lintian::Profile; -my $DEBIAN_DISTS = Lintian::Data->new ('changelog-file/debian-dists'); -my $UBUNTU_REGEX; +use Path::Class; + +my @vendors; +my %DISTRIBUTION_REGEX; { - my $ubuntu_dists = Lintian::Data->new ('changelog-file/ubuntu-dists'); - my $reg_str = join('|', $ubuntu_dists->all); - $UBUNTU_REGEX = qr/$reg_str/o; + my @profile_dirs = ("$ENV{'HOME'}/.lintian/profiles/", + '/etc/lintian/profiles/', + "$ENV{'LINTIAN_ROOT'}/profiles/"); + if ($ENV{LINTIAN_PROFILE}) { + @vendors = ("$ENV{LINTIAN_PROFILE}"); + my $profile = Lintian::Profile->new($ENV{LINTIAN_PROFILE}, [@profile_dirs]); + + my %seen; + push @vendors, map { m!([^/]+).*!; "$1"} + grep {m!([^/]+).*!; ! $seen{$1}++ } reverse @{$profile->parents}; + } else { + my $changelog_dir = dir($ENV{LINTIAN_ROOT}, 'data', 'changelog-file'); + while (my $filename = $changelog_dir->next()) { + next if $filename->is_dir() or $filename->basename !~ m/^(.*)-dists$/; + push @vendors, $1; + } + } + + foreach my $vendor (@vendors) { + next if ! -f file($ENV{LINTIAN_ROOT}, 'data', 'changelog-file', "${vendor}-dists"); + my $dists = Lintian::Data->new(file('changelog-file', "${vendor}-dists")); + my $reg_str = join('|', $dists->all); + $DISTRIBUTION_REGEX{$vendor} = qr/$reg_str/; + } } sub run { @@ -57,22 +81,17 @@ if (!$info->field('description') && $info->field('architecture') ne 'source') { if (defined $info->field('distribution')) { my @distributions = split /\s+/o, $info->field('distribution'); for my $distribution (@distributions) { - if ($distribution eq 'UNRELEASED') { - # ignore - } elsif ($info->field('version') =~ m/ubuntu|$UBUNTU_REGEX/o - or $distribution =~ m/$UBUNTU_REGEX/o) { - if ($distribution !~ m/^(?:$UBUNTU_REGEX)(?:-(?:proposed|updates|backports|security))?$/o ) { - tag 'bad-ubuntu-distribution-in-changes-file', - $distribution; - } - } elsif (! ($DEBIAN_DISTS->known ($distribution) - or ($distribution =~ /^\w+-backports$/) - or ($distribution =~ /^\w+-proposed-updates$/) - or ($distribution =~ /^\w+-security$/) - or ($distribution =~ /^\w+-volatile$/)) - ) { - # bad distribution entry - tag 'bad-distribution-in-changes-file', $distribution; + next if ($distribution eq 'UNRELEASED'); + + if (! grep { $distribution =~ m/$DISTRIBUTION_REGEX{$_}/xms } keys %DISTRIBUTION_REGEX) { + # Vendor specific version? + if ($ENV{'LINTIAN_PROFILE'} =~ m/debian/) { + tag 'bad-distribution-in-changes-file', $distribution; + } elsif ($ENV{'LINTIAN_PROFILE'} =~ m/ubuntu/) { + tag 'bad-ubuntu-distribution-in-changes-file', $distribution; + } else { + tag 'bad-vendor-distribution-in-changes-file', $distribution; + } } } diff --git a/checks/changes-file.desc b/checks/changes-file.desc index ec1391e..a4c25ba 100644 --- a/checks/changes-file.desc +++ b/checks/changes-file.desc @@ -32,6 +32,13 @@ Info: You've specified an unknown target distribution for your upload in Note that the distributions <tt>non-free</tt> and <tt>contrib</tt> are no longer valid. You'll have to use distribution <tt>unstable</tt> and <tt>Section: non-free/xxx</tt> or <tt>Section: contrib/xxx</tt> instead. + . + Please check the your profile under + <tt>$HOME/.lintian/profiles/</tt>, or <tt>/etc/lintian/profiles/</tt> + or <tt>LINTIAN_ROOT/profiles/</tt>. + . + Please check the vendor distribution list under + <tt>LINTIAN_ROOT/data/changelog-file/</tt> Ref: policy 5.6.14 Tag: bad-ubuntu-distribution-in-changes-file @@ -40,9 +47,32 @@ Certainty: certain Info: You've specified an unknown target distribution for your upload in the <tt>debian/changelog</tt> file. . - Your version string suggests this package is for Ubuntu, so your - distribution should be one of precise, oneiric, natty, maverick, lucid, - karmic, hardy, or dapper. + Your profile suggests this package is for Ubuntu, so your + distribution should be one of precise, oneiric, natty, maverick, + lucid, karmic, hardy, or dapper. + . + Please check the your profile under + <tt>$HOME/.lintian/profiles/</tt>, or <tt>/etc/lintian/profiles/</tt> + or <tt>LINTIAN_ROOT/profiles/</tt>. + . + Please check the vendor distribution list under + <tt>LINTIAN_ROOT/data/changelog-file/</tt> + +Tag: bad-vendor-distribution-in-changes-file +Severity: important +Certainty: certain +Info: You've specified an unknown target distribution for your upload in + the <tt>debian/changelog</tt> file. + . + Your profile suggests this package is for a specific vendor + but did not match the distributions list for that vendor. + . + Please check the your profile under + <tt>$HOME/.lintian/profiles/</tt>, or <tt>/etc/lintian/profiles/</tt> + or <tt>LINTIAN_ROOT/profiles/</tt>. + . + Please check the vendor distribution list under + <tt>LINTIAN_ROOT/data/changelog-file/</tt> Tag: multiple-distributions-in-changes-file Severity: important diff --git a/data/changelog-file/debian-dists b/data/changelog-file/debian-dists index 589df1c..f5313f8 100644 --- a/data/changelog-file/debian-dists +++ b/data/changelog-file/debian-dists @@ -2,15 +2,15 @@ # aliases # Codenames -lenny -squeeze -wheezy -sid +lenny(?:-(?:backports|proposed-updates|security|volatile))? +squeeze(?:-(?:backports|proposed-updates|security|volatile))? +wheezy(?:-(?:backports|proposed-updates|security|volatile))? +sid(?:-(?:backports|proposed-updates|security|volatile))? # Aliases -oldstable -stable -testing -unstable -experimental +oldstable(?:-(?:backports|proposed-updates|security|volatile))? +stable(?:-(?:backports|proposed-updates|security|volatile))? +testing(?:-(?:backports|proposed-updates|security|volatile))? +unstable(?:-(?:backports|proposed-updates|security|volatile))? +experimental(?:-(?:backports|proposed-updates|security|volatile))? diff --git a/data/changelog-file/ubuntu-dists b/data/changelog-file/ubuntu-dists index 0948ec9..e1517c9 100644 --- a/data/changelog-file/ubuntu-dists +++ b/data/changelog-file/ubuntu-dists @@ -1,11 +1,11 @@ # A list of Ubuntu distributions, used to suppress some checks for Ubuntu # packages and to validate Ubuntu distributions. -dapper -hardy -karmic -lucid -maverick -natty -oneiric -precise +dapper(?:-(?:proposed|updates|backports|security))? +hardy(?:-(?:proposed|updates|backports|security))? +karmic(?:-(?:proposed|updates|backports|security))? +lucid(?:-(?:proposed|updates|backports|security))? +maverick(?:-(?:proposed|updates|backports|security))? +natty(?:-(?:proposed|updates|backports|security))? +oneiric(?:-(?:proposed|updates|backports|security))? +precise(?:-(?:proposed|updates|backports|security))? diff --git a/profiles/test/main.profile b/profiles/test/main.profile new file mode 100644 index 0000000..c750dd5 --- /dev/null +++ b/profiles/test/main.profile @@ -0,0 +1,3 @@ +# This profile is for Lintian test only +Profile: test/main +Extends: debian/main diff --git a/t/changes/changes-bad-debian-distribution.changes.in b/t/changes/changes-bad-debian-distribution.changes.in new file mode 100644 index 0000000..7d78256 --- /dev/null +++ b/t/changes/changes-bad-debian-distribution.changes.in @@ -0,0 +1,12 @@ +Format: 1.8 +Date: {$date} +Source: {$srcpkg} +Binary: {$srcpkg} +Architecture: source all +Version: {$version} +Distribution: wispy +Urgency: low +Maintainer: {$author} +Changed-By: {$author} +Description: + {$srcpkg} - {$description} diff --git a/t/changes/changes-bad-debian-distribution.desc b/t/changes/changes-bad-debian-distribution.desc new file mode 100644 index 0000000..580449e --- /dev/null +++ b/t/changes/changes-bad-debian-distribution.desc @@ -0,0 +1,7 @@ +Testname: changes-bad-debian-distribution +Sequence: 6000 +Version: 1.0+lenny2 +Profile: debian/main +Description: Test for invalid Debian distribution +Test-For: + bad-distribution-in-changes-file diff --git a/t/changes/changes-bad-debian-distribution.tags b/t/changes/changes-bad-debian-distribution.tags new file mode 100644 index 0000000..172bb9c --- /dev/null +++ b/t/changes/changes-bad-debian-distribution.tags @@ -0,0 +1 @@ +E: changes-bad-debian-distribution changes: bad-distribution-in-changes-file wispy diff --git a/t/changes/changes-bad-ubuntu-distribution.desc b/t/changes/changes-bad-ubuntu-distribution.desc index e9d19c4..3bf439a 100644 --- a/t/changes/changes-bad-ubuntu-distribution.desc +++ b/t/changes/changes-bad-ubuntu-distribution.desc @@ -1,6 +1,7 @@ Testname: changes-bad-ubuntu-distribution Sequence: 6000 Version: 1.0+ubuntu2 +Profile: ubuntu/main Description: Test for invalid Ubuntu distribution Test-For: bad-ubuntu-distribution-in-changes-file diff --git a/t/changes/changes-bad-vendor-distribution.changes.in b/t/changes/changes-bad-vendor-distribution.changes.in new file mode 100644 index 0000000..7d78256 --- /dev/null +++ b/t/changes/changes-bad-vendor-distribution.changes.in @@ -0,0 +1,12 @@ +Format: 1.8 +Date: {$date} +Source: {$srcpkg} +Binary: {$srcpkg} +Architecture: source all +Version: {$version} +Distribution: wispy +Urgency: low +Maintainer: {$author} +Changed-By: {$author} +Description: + {$srcpkg} - {$description} diff --git a/t/changes/changes-bad-vendor-distribution.desc b/t/changes/changes-bad-vendor-distribution.desc new file mode 100644 index 0000000..fd49891 --- /dev/null +++ b/t/changes/changes-bad-vendor-distribution.desc @@ -0,0 +1,7 @@ +Testname: changes-bad-vendor-distribution +Sequence: 6000 +Version: 1.0 +Profile: test/main +Description: Test for invalid vendor specific distribution +Test-For: + bad-vendor-distribution-in-changes-file diff --git a/t/changes/changes-bad-vendor-distribution.tags b/t/changes/changes-bad-vendor-distribution.tags new file mode 100644 index 0000000..d7db9b7 --- /dev/null +++ b/t/changes/changes-bad-vendor-distribution.tags @@ -0,0 +1 @@ +E: changes-bad-vendor-distribution changes: bad-vendor-distribution-in-changes-file wispy -- 1.7.7.3 -- Daniel Dehennin Récupérer ma clef GPG: gpg --keyserver pgp.mit.edu --recv-keys 0x6A2540D1
pgpYSgfK18sRr.pgp
Description: PGP signature