package: lintian
tags: patch

Dear lintian maintainers,

Please consider the attached patch to add a check for the changes file of
uploads to backports. The patch introduces 2 new tags:

backports-changes-missing, for uploads that don't include multiple changelog
entries in the changes file (this is a very common cause for rejects).

backports-upload-has-incorrect-version-number, if the version number doesn't
end in ~bpoXX+N, where XX corresponds with the version number of the base
distribution.

Cheers,

Ivo

>From b1a71aec2888f53d80e20f8fa05c903113a707f1 Mon Sep 17 00:00:00 2001
From: Ivo De Decker <ivo.dedec...@ugent.be>
Date: Sun, 15 Dec 2013 16:17:46 +0100
Subject: [PATCH] add checks for backports version number and changes

---
 checks/changes-file.desc | 17 +++++++++++++++++
 checks/changes-file.pm   | 46 ++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 63 insertions(+)

diff --git a/checks/changes-file.desc b/checks/changes-file.desc
index 402c338..5db7939 100644
--- a/checks/changes-file.desc
+++ b/checks/changes-file.desc
@@ -122,3 +122,20 @@ Certainty: certain
 Info: The Changed-By address includes localhost(.localdomain), which is
  an invalid e-mail address.
 Ref: policy 5.6.2
+
+Tag: backports-changes-missing
+Severity: serious
+# if there are no false positives, this could possibly be increased
+Certainty: possible
+Info: The changes file only has changelog entries from a single version. For
+ backports, all changes since (old)stable or the previous backport should be
+ listed (usually by adding the '-v' option to the build).
+Ref: http://backports.debian.org/Contribute/
+
+Tag: backports-upload-has-incorrect-version-number
+Severity: serious
+Certainty: certain
+Info: The version number doesn't comply with the standard backport version
+ rules. It should end in ~bpoXX+N, where XX refers to the version number of
+ the base distribution.
+Ref: http://backports.debian.org/Contribute/
diff --git a/checks/changes-file.pm b/checks/changes-file.pm
index 137439c..02b8288 100644
--- a/checks/changes-file.pm
+++ b/checks/changes-file.pm
@@ -64,6 +64,52 @@ sub run {
                                    |updates
                                    |security
                                    |volatile)$//xsmo;
+
+                    if ($distribution =~ /backports/) {
+                        my $bpo1 = 1;
+                        if ($info->field('version') =~ m/~bpo(\d+)\+(\d+)$/) {
+                            my $distnumber = $1;
+                            my $bpoversion = $2;
+                            if (
+                                ($dist eq "squeeze" && $distnumber ne "60") ||
+                                ($dist eq "wheezy" && $distnumber ne "70") ||
+                                # TODO version number for jessie?
+                                ($dist eq "jessie" && $distnumber !~ /^8/)
+                                ) {
+                                tag 'backports-upload-has-incorrect-version-number',
+                                    $info->field('version'),
+                                    $distribution;
+                            }
+                            $bpo1 = 0 if ($bpoversion > 1);
+                        } else {
+                            print $info->field('version')."\n";
+                            tag 'backports-upload-has-incorrect-version-number',
+                                $info->field('version');
+                        }
+                        # for a ~bpoXX+2 or greater version, there
+                        # probably will be only a single changelog entry
+                        if ($bpo1) {
+                            my $changes_versions = 0;
+                            foreach my $change_line (split("\n", $info->field('changes'))) {
+                                # from Parse/DebianChangelog.pm
+                                # the changelog entries in the changes file are in a
+                                # different format than in the changelog, so the standard
+                                # parsers don't work. We just need to know if there is
+                                # info for more than 1 entry, so we just copy part of the
+                                # parse code here
+                                if ($change_line =~ m/^\s*(?<Source>\w[-+0-9a-z.]*) \((?<Version>[^\(\) \t]+)\)(?<Distribution>(?:\s+[-+0-9a-z.]+)+)\;\s*(?<kv>.*)$/i) {
+                                    $changes_versions++;
+                                }
+                            }
+                            # only complain if there is a single entry,
+                            # if we didn't find any changelog entry, there is
+                            # probably something wrong with the parsing, so we
+                            # don't emit a tag
+                            if ($changes_versions == 1) {
+                                tag 'backports-changes-missing';
+                            }
+                        }
+                    }
                 }
                 if (!$KNOWN_DISTS->known($dist)) {
                     # bad distribution entry
-- 
1.8.5.1

Reply via email to