Bug#648777: lintian: Generalize distribution check

November 14th, 2011 - 06:20 pm ET by Daniel Dehennin | Report spam


Package: lintian
Version: 2.5.3
Severity: wishlist

Dear Maintainer,

I propose a patch to generalize the distribution check, permitting to
easily configure the list of allowed distributions.

The idea here is to add a file under 'data/changelog-file/' with a name
ending in '-dists'.

This file contains regular expressions to test against the distribution
name.

git pull git://git.baby-gnu.net/lintian dad/generalize-distribution-check

I attach the patches for review.

Regards.


filename01-Generaliste-distribution-name-check.patch

From 8cfbd1853607d9e171d9dde2fca4837f3f24c2ed Mon Sep 17 00:00:00 2001
From: Daniel Dehennin <daniel.dehennin@baby-gnu.org>
Date: Mon, 14 Nov 2011 23:57:36 +0100
Subject: [PATCH] Generaliste distribution name check.

This patch allow to create a new data/changelog-file/<something>-dists
file to add new valid distribution regexps.

* checks/changes-file: Build an array of distribution regexp and test
distribution fiedl against each one.

* data/changelog-file/debian-dists: Define full regexp instead of only
base distribution.

* data/changelog-file/ubuntu-dists: Ditoo.

checks/changes-file | 41 ++++++++++++++++++-
data/changelog-file/debian-dists | 18 ++++++++--
data/changelog-file/ubuntu-dists | 16 +++++++-
3 files changed, 37 insertions(+), 38 deletions(-)

diff --git a/checks/changes-file b/checks/changes-file
index 5192130..0091860 100644
a/checks/changes-file
+++ b/checks/changes-file
@@ -26,12 +26,17 @@ use Util;
use Lintian::Tags qw(tag);
use Lintian::Check qw(check_maintainer);

-my $DEBIAN_DISTS = Lintian::Data->new ('changelog-file/debian-dists');
-my $UBUNTU_REGEX;
+use Path::Class;
+
+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 $changelog_dir = dir($ENV{LINTIAN_ROOT}, 'data', 'changelog-file');
+ while (my $filename = $changelog_dir->next()) {
+ next if $filename->is_dir() or $filename !~ m/.*-dists$/;
+ my $distrib_dists = Lintian::Data->new(file('changelog-file', $filename->basename));
+ my $reg_str = join('|', $distrib_dists->all);
+ push @DISTRIBUTION_REGEX, qr/$reg_str/;
+ }
}

sub run {
@@ -57,22 +62,16 @@ 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');
+ my $bad = 1;
+ foreach my $dist_regex (@DISTRIBUTION_REGEX) {
+ if ($distribution =~ m/$dist_regex/) {
+ $bad=0;
+ last;
+ }
+ }
+ if ($bad) {
+ tag 'bad-ubuntu-distribution-in-changes-file', $distribution;
}
}

diff --git a/data/changelog-file/debian-dists b/data/changelog-file/debian-dists
index 589df1c..499b962 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))?
1.7.7.2





Debian Release: wheezy/sid
APT prefers unstable
APT policy: (500, 'unstable'), (90, 'experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 3.0.0-rc5+hati.1 (SMP w/2 CPU cores; PREEMPT)
Locale: LANG=fr_FR.UTF-8, LC_CTYPE=fr_FR.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

Versions of packages lintian depends on:
ii binutils 2.21.90.20111025-1
ii bzip2 1.0.5-7
ii diffstat 1.54-1
ii file 5.09-2
ii gettext 0.18.1.1-5
ii intltool-debian 0.35.0+20060710.1
ii libapt-pkg-perl 0.1.25
ii libclass-accessor-perl 0.34-1
ii libdpkg-perl 1.16.1.1
ii libemail-valid-perl 0.185-1
ii libipc-run-perl 0.90-1
ii libparse-debianchangelog-perl 1.2.0-1
ii libtimedate-perl 1.2000-1
ii liburi-perl 1.59-1
ii locales 2.13-21
ii man-db 2.6.0.2-3
ii patchutils 0.3.2-1
ii perl [libdigest-sha-perl] 5.12.4-6
ii unzip 6.0-5

lintian recommends no packages.

Versions of packages lintian suggests:
ii binutils-multiarch <none>
ii dpkg-dev 1.16.1.1
ii libhtml-parser-perl 3.69-1
ii libtext-template-perl <none>
ii man-db 2.6.0.2-3
ii xz-utils 5.1.1alpha+20110809-3


Daniel Dehennin
Récupérer ma clef GPG:
gpg --keyserver pgp.mit.edu --recv-keys 0x6A2540D1






To UNSUBSCRIBE, email to debian-bugs-dist-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
email Follow the discussionReplies 2 repliesReplies Make a reply

Replies

#1 Daniel Dehennin
December 03rd, 2011 - 03:40 pm ET | Report spam

Hello,

Here is an improvement of the patch:

git pull git://git.baby-gnu.org/lintian dad/bad-vendor-distribution-in-changes-file

The changes from the previous patch are:

- Keep the ubuntu specific tag "bad-ubuntu-distribution-in-changes-file"
for backward compatibility

- Add the new "bad-vendor-distribution-in-changes-file" for vendor
specific distribution checks.
To test for vendor specific distribution, the version number must
contain the vendor or distribution name, for example:
* 1.2-ubuntu1
* 2.4+squeeze2
The name of the vendor is extracted for the
changelog-file/<vendor>-dists filename.

- Add tests on changes file, the test pass here

Regards.

From ac668a689735a9291fc6cc9bbaf143452b5f668f Mon Sep 17 00:00:00 2001
From: Daniel Dehennin
Date: Sat, 3 Dec 2011 20:55:29 +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.

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 based version number.

* 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-vendor-distribution-in-changes-file".

* t/changes/changes-bad-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-distribution.changes.in: Sample changes
file with the faulty "wispy" distribution.

* t/changes/changes-bad-distribution.tags: The tag must be
"bad-distribution-in-changes-file".

* checks/changes-file: Use a hash of vendor => regexp to check the
distribution name.
Keep the logic of checking vendor or distribution based version number.

* checks/changes-file.desc (Tag): Rename
"bad-ubuntu-distribution-in-changes-file" to
"bad-vendor-distribution-in-changes-file" and update description.

* data/changelog-file/debian-dists: Define full regexp instead of only
base distribution.

* data/changelog-file/ubuntu-dists: Ditoo.

checks/changes-file | 43 ++++++++++
checks/changes-file.desc | 12 +++++
data/changelog-file/debian-dists | 18 ++++-
data/changelog-file/ubuntu-dists | 16 ++++-
.../changes-bad-debian-distribution.changes.in | 12 +++++
t/changes/changes-bad-debian-distribution.desc | 6 +++
t/changes/changes-bad-debian-distribution.tags | 1 +
t/changes/changes-bad-distribution.changes.in | 12 +++++
t/changes/changes-bad-distribution.desc | 6 +++
t/changes/changes-bad-distribution.tags | 1 +
10 files changed, 90 insertions(+), 37 deletions(-)
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-distribution.changes.in
create mode 100644 t/changes/changes-bad-distribution.desc
create mode 100644 t/changes/changes-bad-distribution.tags

diff --git a/checks/changes-file b/checks/changes-file
index 5192130..4ecd14f 100644
a/checks/changes-file
+++ b/checks/changes-file
@@ -26,12 +26,18 @@ use Util;
use Lintian::Tags qw(tag);
use Lintian::Check qw(check_maintainer);

-my $DEBIAN_DISTS = Lintian::Data->new ('changelog-file/debian-dists');
-my $UBUNTU_REGEX;
+use Path::Class;
+
+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 $changelog_dir = dir($ENV{LINTIAN_ROOT}, 'data', 'changelog-file');
+ while (my $filename = $changelog_dir->next()) {
+ next if $filename->is_dir() or $filename !~ m/.*-dists$/;
+ (my $vendor = $filename->basename) =~ s/^(.*)-dists$/$1/xms;
+ my $distrib_dists = Lintian::Data->new(file('changelog-file', $filename->basename));
+ my $reg_str = join('|', $distrib_dists->all);
+ $DISTRIBUTION_REGEX{$vendor} = qr/$reg_str/;
+ }
}

sub run {
@@ -57,21 +63,18 @@ 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
+ next if ($distribution eq 'UNRELEASED');
+
+ # Vendor specific version?
+ my @vendors = grep { $info->field('version') =~ m/$_|$DISTRIBUTION_REGEX{$_}/xms } keys %DISTRIBUTION_REGEX;
+ if (@vendors and ! grep {$distribution =~ m/$_|$DISTRIBUTION_REGEX{$_}/xms } @vendors) {
+ if ($vendors[0] eq 'ubuntu') {
+ tag 'bad-ubuntu-distribution-in-changes-file', $distribution;
+ } else {
+ tag 'bad-vendor-distribution-in-changes-file', $distribution;
+ }
+ }
+ elsif (! grep { $distribution =~ m/$_|$DISTRIBUTION_REGEX{$_}/xms } keys %DISTRIBUTION_REGEX) {
tag 'bad-distribution-in-changes-file', $distribution;
}
}
diff --git a/checks/changes-file.desc b/checks/changes-file.desc
index ec1391e..dfcc8fe 100644
a/checks/changes-file.desc
+++ b/checks/changes-file.desc
@@ -44,6 +44,18 @@ Info: You've specified an unknown target distribution for your upload in
distribution should be one of precise, oneiric, natty, maverick, lucid,
karmic, hardy, or dapper.

+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 version string suggests this package is for a specific vendor
+ but did not match the distributions list for that vendor.
+ .
+ Please check the vendor distribution list under
+ <tt>LINTIAN_ROOT/data/changelog-file/</tt>
+
Tag: multiple-distributions-in-changes-file
Severity: important
Certainty: possible
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/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..f10252a
/dev/null
+++ b/t/changes/changes-bad-debian-distribution.desc
@@ -0,0 +1,6 @@
+Testname: changes-bad-debian-distribution
+Sequence: 6000
+Version: 1.0+lenny2
+Description: Test for invalid Debian distribution
+Test-For:
+ bad-vendor-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..f7f7782
/dev/null
+++ b/t/changes/changes-bad-debian-distribution.tags
@@ -0,0 +1 @@
+E: changes-bad-debian-distribution changes: bad-vendor-distribution-in-changes-file wispy
diff --git a/t/changes/changes-bad-distribution.changes.in b/t/changes/changes-bad-distribution.changes.in
new file mode 100644
index 0000000..7d78256
/dev/null
+++ b/t/changes/changes-bad-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-distribution.desc b/t/changes/changes-bad-distribution.desc
new file mode 100644
index 0000000..4699575
/dev/null
+++ b/t/changes/changes-bad-distribution.desc
@@ -0,0 +1,6 @@
+Testname: changes-bad-distribution
+Sequence: 6000
+Version: 1.0
+Description: Test for invalid non vendor specific distribution
+Test-For:
+ bad-distribution-in-changes-file
diff --git a/t/changes/changes-bad-distribution.tags b/t/changes/changes-bad-distribution.tags
new file mode 100644
index 0000000..ee2d25f
/dev/null
+++ b/t/changes/changes-bad-distribution.tags
@@ -0,0 +1 @@
+E: changes-bad-distribution changes: bad-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





To UNSUBSCRIBE, email to
with a subject of "unsubscribe". Trouble? Contact

Similar topics