I attached a (preliminary?) patch adding support for very basic DEP-5
validation. Beware, tag descriptions could use some love. ;)
--
Jakub Wilk
diff --git a/checks/copyright-file b/checks/copyright-file
--- a/checks/copyright-file
+++ b/checks/copyright-file
@@ -24,6 +24,7 @@
use Lintian::Check qw(check_spelling);
use Lintian::Data ();
+use Lintian::Relation::Version qw(versions_compare);
use Lintian::Tags qw(tag);
use Util;
@@ -31,6 +32,16 @@
our $KNOWN_ESSENTIAL = Lintian::Data->new('fields/essential');
+my $dep5_last_normative_change = '0+svn~166';
+my $dep5_last_overhaul = '0+svn~148';
+my %dep5_renamed_fields = (
+ 'format-specification' => 'format',
+ 'maintainer' => 'upstream-contact',
+ 'upstream-maintainer' => 'upstream-contact',
+ 'contact' => 'upstream-contact',
+ 'name' => 'upstream-name',
+);
+
sub run {
my $pkg = shift;
@@ -314,6 +325,87 @@
}
}
+if (m{
+ (^ | \n)
+ (?i: format(:|[-\s]spec) )
+ (?: . | \n\s+ )*
+ (?: /dep[5s]?\b | \bDEP-?5\b | [Mm]achine-readable\s(?:license|copyright) | /copyright-format/ | CopyrightFormat | VERSIONED_FORMAT_URL )
+}x)
+{
+ # Before trying to parse the copyright as Debian control file, try to
+ # determine the format URI.
+ my $first_para = $_;
+ $first_para =~ s,^#.*,,mg;
+ $first_para =~ s,[ \t]+$,,mg;
+ $first_para =~ s,^\n+,,g;
+ $first_para =~ s,\n\n.*,\n,s;
+ $first_para =~ s,\n?[ \t]+, ,g;
+ $first_para =~ m,^Format(?:-Specification)?:\s*(.*),mi;
+ my $uri = $1;
+ $uri =~ s/^([^#\s]+)#/$1/ if defined $uri; # strip fragment identifier
+ if (defined $uri) {
+ my $original_uri = $uri;
+ my $version;
+ if ($uri =~ m,\b(?:rev=REVISION|VERSIONED_FORMAT_URL)\b,) {
+ tag 'boilerplate-copyright-format-uri';
+ }
+ elsif ($uri =~ s,http://wiki\.debian\.org/Proposals/CopyrightFormat\b,,) {
+ $version = '0~wiki';
+ $uri =~ m,^\?action=recall&rev=(\d+)$, and $version = "$version~$1";
+ }
+ elsif ($uri =~ m,^http://dep\.debian\.net/deps/dep5/?$,) {
+ $version = '0+svn';
+ }
+ elsif ($uri =~ s,^http://svn\.debian\.org/wsvn/dep/web/deps/dep5\.mdwn\b,,) {
+ $version = '0+svn';
+ $uri =~ m,^\?(?:\S+&)?rev=(\d+)(?:&\S+)?$, and $version = "$version~$1";
+ }
+ elsif ($uri =~ s,^http://anonscm\.debian\.org/viewvc/dep/web/deps/dep5\.mdwn\b,,) {
+ $version = '0+svn';
+ $uri =~ m,^\?(?:\S+&)?revision=(\d+)(?:&\S+)?$, and $version = "$version~$1";
+ }
+ elsif ($uri =~ m,^http://www\.debian\.org/doc/(packaging-manuals/?)copyright-format/(\d+.\d+)$,) {
+ $version = $1;
+ }
+ else {
+ tag 'unknown-copyright-format-uri', $original_uri;
+ }
+ if (defined $version) {
+ if ($version =~ m,wiki,) {
+ tag 'wiki-copyright-format-uri', $original_uri;
+ }
+ elsif ($version =~ m,svn$,) {
+ tag 'unversioned-copyright-format-uri', $original_uri;
+ }
+ elsif (versions_compare $version, '<<', $dep5_last_normative_change) {
+ tag 'outdated-copyright-format-uri', $original_uri;
+ }
+ if (versions_compare $version, '>=', $dep5_last_overhaul) {
+ # We are reasonably certain that we're dealing with an up-to-date
+ # DEP-5 format. Let's try to do more strict checks.
+ my @dep5;
+ eval {
+ @dep5 = read_dpkg_control('copyright');
+ };
+ if ($@) {
+ $@ =~ s/^internal error: //;
+ tag 'syntax-error-in-machine-readable-copyright', $@;
+ }
+ else {
+ $first_para = shift @dep5;
+ for my $field (keys %{$first_para}) {
+ my $renamed_to = $dep5_renamed_fields{$field};
+ tag 'machine-readable-copyright-uses-obsolete-field', $field, $renamed_to if defined $renamed_to;
+ }
+ }
+ }
+ }
+ }
+ else {
+ tag 'unknown-copyright-format-uri';
+ }
+}
+
} # </run>
# -----------------------------------
diff --git a/checks/copyright-file.desc b/checks/copyright-file.desc
--- a/checks/copyright-file.desc
+++ b/checks/copyright-file.desc
@@ -391,3 +391,63 @@
.
This file may be removed from a future version of base-files if
references to it drop sufficiently.
+
+Tag: unknown-copyright-format-uri
+Severity: normal
+Certainty: wild-guess
+Info: The copyright file appears to intended as machine-readable, but lintian
+ cannot recognize its format URI. It could be a typo for a common URI or a
+ syntax error in the first paragraph. Please file a bug against Lintian if you
+ believe that the copyright file in syntactically valid and the URI is
+ correct.
+
+Tag: boilerplate-copyright-format-uri
+Severity: normal
+Certainty: possible
+Info: TODO
+
+Tag: wiki-copyright-format-uri
+Severity: normal
+Ref: http://dep.debian.net/deps/dep5/
+Certainty: Format URI of the machine-readable possible
+Info: Format URI of the machine-readable copyright file refers to Debian Wiki.
+ .
+ Debian Wiki is not used for the format development anymore. Please use
+ http://anonscm.debian.org/viewvc/dep/web/deps/dep5.mdwn?revision=<i>revision</i>
+ as the format URI instead.
+
+Tag: unversioned-copyright-format-uri
+Severity: minor
+Certainty: possible
+Ref: http://dep.debian.net/deps/dep5/
+Info: Format URI of the machine-readable copyright file is not versioned.
+ .
+ Please use
+ http://anonscm.debian.org/viewvc/dep/web/deps/dep5.mdwn?revision=<i>revision</i>
+ as the format URI instead.
+
+Tag: outdated-copyright-format-uri
+Severity: normal
+Certainty: possible
+Ref: http://dep.debian.net/deps/dep5/
+Info: TODO
+
+Tag: syntax-error-in-machine-readable-copyright
+Severity: normal
+Certainty: possible
+Ref: http://dep.debian.net/deps/dep5/
+Info: The machine-readable copyright file didn't pass Debian control file
+ syntax check.
+
+Tag: machine-readable-copyright-uses-obsolete-field
+Severity: normal
+Certainty: possible
+Ref: http://dep.debian.net/deps/dep5/
+Info: The machine-readable copyright file uses a field, that used to be defined
+ by the specification, but has been renamed since then.
+ .
+ Please use Format instead of Format-Specification.
+ .
+ Please use Upstream-Contact instead of Contact, Maintainer or Upstream-Maintainer.
+ .
+ Please use Upstream-Name instead of Name.