Bug#633779: lintian: validate DEP-5 debian/copyright files
The attached patch fixes a minor bug. Without it, a format like http://anonscm.debian.org/viewvc/dep/web/deps/dep5.mdwn?view=markup&pathrev=174 would trigger unversioned-copyright-format-uri. -- Jakub Wilk diff --git a/checks/source-copyright b/checks/source-copyright --- a/checks/source-copyright +++ b/checks/source-copyright @@ -107,7 +107,7 @@ } 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"; + $uri =~ m,^\?(?:\S+&)?(?:pathrev|revision)=(\d+)(?:&\S+)?$, and $version = "$version~$1"; } elsif ($uri =~ m,^http://www\.debian\.org/doc/(?:packaging-manuals/)?copyright-format/(\d+\.\d+)$,) { $version = $1;
Bug#633779: lintian: validate DEP-5 debian/copyright files
* Niels Thykier , 2011-08-22, 10:53: I renamed the check to source-copyright (from source-copyright-file, which was too long :P), fixed a few minor bugs, added tests. Hey. --- a/t/COVERAGE +++ b/t/COVERAGE @@ -1,5 +1,5 @@ -Last generated 2011-08-17 -Coverage: 697/915 (76.17%), w. legacy tests: 820/915 (89.62%) +Last generated 2011-08-21 +Coverage: 712/930 (76.56%), w. legacy tests: 835/930 (89.78%) When I run private/update-coverage after applying the patch I get +Coverage: 704/930 (75.70%), w. legacy tests: 835/930 (88.92%) plus it lists 7 new source-copyright tags that are not covered. Is a part of this patch missing? Ooops, good catch. I attach the missing bits. The patch carries 7 source-copyright tests (boilerplate-uri, missing, ood-uri [odd?], That's OOD as in Out Of Date. -- Jakub Wilk diff --git a/t/tests/source-copyright-dep5-general/debian/debian/copyright b/t/tests/source-copyright-dep5-general/debian/debian/copyright new file mode 100644 --- /dev/null +++ b/t/tests/source-copyright-dep5-general/debian/debian/copyright @@ -0,0 +1,57 @@ +Format: http://anonscm.debian.org/viewvc/dep/web/deps/dep5.mdwn?revision=174 +Upstream-Name: Doohickey +Upstream-Maintainer: J. Random Hacker +Source: http://examples.com/doohickey/source/ + +Comment: I'm a bogus paragraph. + +Files: a/*, b/* +Copyright: 2011 J. Random Hacker +License: GPL-2 + +Files: c +Copyright: 2010 J. Random Hacker + +Files: d +License: GPL-3 + +Files: 5 +License: MIT +Copyright: 2010 J. Random Hacker + +License: GPL-2 + This package 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; version 2 dated June, 1991. + . + This package 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 package; if not, write to the Free Software Foundation, Inc., 51 Franklin + St, Fifth Floor, Boston, MA 02110-1301, USA. + . + On Debian systems, the full text of the GNU General Public License version 2 + can be found in the file `/usr/share/common-licenses/GPL-2'. + +License: GPL-3 + +License: Expat + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the âSoftwareâ), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + . + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + . + THE SOFTWARE IS PROVIDED âAS ISâ, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. diff --git a/t/tests/source-copyright-dep5-general/desc b/t/tests/source-copyright-dep5-general/desc new file mode 100644 --- /dev/null +++ b/t/tests/source-copyright-dep5-general/desc @@ -0,0 +1,12 @@ +Testname: source-copyright-dep5-general +Sequence: 6000 +Version: 1.0 +Description: Test for various errors in DEP-5 copyright files +Test-For: + comma-separated-files-in-dep5-copyright + missing-field-in-dep5-copyright + missing-license-paragraph-in-dep5-copyright + missing-license-text-in-dep5-copyright + obsolete-field-in-dep5-copyright + unknown-paragraph-in-dep5-copyright + unused-license-paragraph-in-dep5-copyright diff --git a/t/tests/source-copyright-dep5-general/tags b/t/tests/source-copyright-dep5-general/tags new file mode 100644 --- /dev/null +++ b/t/tests/source-copyright-dep5-general/tags @@ -0,0 +1,8 @@ +I: source-copyright-dep5-general source: unused-license-paragraph-in-dep5-copyright paragraph 9 expat +W: source-copyright-dep5-general source: comma-separated-files-in-dep5-copyright +W: source-copyright-dep5-general source: missing-field-in-dep5-copyright paragraph 4 license +W: source-copyright-dep5-general source: missing-field-in-dep5-copyright paragraph 5 copyright +W: source-copyright-dep5-general source: missing-license-paragraph-in-dep5-copyright paragraph 6 mit +W: source-copyright-dep5-general source: missing-license-text-in-dep5-copyright paragraph 8 gpl-3 +W: source-copyright-dep5-general source: obsolete-field-in-dep5-copyright upstream-maintainer upstream-contact +W: source-copyright-dep5-general source: unk
Bug#633779: lintian: validate DEP-5 debian/copyright files
On 2011-08-21 20:50, Jakub Wilk wrote: > * Jakub Wilk , 2011-08-15, 00:36: >>> Feel free to add a new separate check if that results in more >>> maintainable code. :) >> >> Okay, updated patch attached. > > I renamed the check to source-copyright (from source-copyright-file, > which was too long :P), fixed a few minor bugs, added tests. > Hey. --- a/t/COVERAGE +++ b/t/COVERAGE @@ -1,5 +1,5 @@ -Last generated 2011-08-17 -Coverage: 697/915 (76.17%), w. legacy tests: 820/915 (89.62%) +Last generated 2011-08-21 +Coverage: 712/930 (76.56%), w. legacy tests: 835/930 (89.78%) When I run private/update-coverage after applying the patch I get +Coverage: 704/930 (75.70%), w. legacy tests: 835/930 (88.92%) plus it lists 7 new source-copyright tags that are not covered. Is a part of this patch missing? The patch carries 7 source-copyright tests (boilerplate-uri, missing, ood-uri [odd?], symlink, unknown-uri, unversioned-uri and wiki-uri) in t/tests ~Niels -- To UNSUBSCRIBE, email to debian-lint-maint-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/4e521913.3060...@thykier.net
Bug#633779: lintian: validate DEP-5 debian/copyright files
* Jakub Wilk , 2011-08-15, 00:36: Feel free to add a new separate check if that results in more maintainable code. :) Okay, updated patch attached. I renamed the check to source-copyright (from source-copyright-file, which was too long :P), fixed a few minor bugs, added tests. -- Jakub Wilk diff --git a/checks/source-copyright b/checks/source-copyright new file mode 100644 --- /dev/null +++ b/checks/source-copyright @@ -0,0 +1,232 @@ +# source-copyright-file -- lintian check script -*- perl -*- + +# Copyright (C) 2011 Jakub Wilk +# +# 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::source_copyright; + +use strict; +use warnings; + +use Lintian::Relation::Version qw(versions_compare); +use Lintian::Tags qw(tag); +use Util; + +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, $type, $info) = @_; +my $pkgs = $info->binaries; + +my $copyright_filename = $info->debfiles('copyright'); + +if (-l $copyright_filename) +{ +tag 'debian-copyright-is-symlink'; +return; +} + +if (not -f $copyright_filename) { +tag 'no-debian-copyright'; +$copyright_filename = undef; +if (keys(%$pkgs) == 1) +{ + # If debian/copyright doesn't exist, and the only a single binary + # package is built, there's a good chance that the copyright file is + # available as debian/.copyright. + $copyright_filename = $info->debfiles((keys(%$pkgs))[0] . '.copyright'); + if (not -f $copyright_filename or -l $copyright_filename) { + $copyright_filename = undef; + } +} +} + +return unless defined $copyright_filename; + +$_ = slurp_entire_file($copyright_filename); +study $_; + +my @dep5; + +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', $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 'out-of-date-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. + eval { + @dep5 = re
Bug#633779: lintian: validate DEP-5 debian/copyright files
* Niels Thykier , 2011-08-13, 13:20: Feel free to add a new separate check if that results in more maintainable code. :) Okay, updated patch attached. -- Jakub Wilk diff --git a/checks/source-copyright-file b/checks/source-copyright-file new file mode 100644 --- /dev/null +++ b/checks/source-copyright-file @@ -0,0 +1,231 @@ +# source-copyright-file -- lintian check script -*- perl -*- + +# Copyright (C) 2011 Jakub Wilk +# +# 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::source_copyright_file; + +use strict; +use warnings; + +use Lintian::Relation::Version qw(versions_compare); +use Lintian::Tags qw(tag); +use Util; + +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, $type, $info) = @_; +my $pkgs = $info->binaries; + +my $copyright_filename = $info->debfiles('copyright'); + +if (-l $copyright_filename) +{ +tag 'debian-copyright-is-symlink'; +return; +} + +if (not -f $copyright_filename) { +tag 'no-debian-copyright'; +$copyright_filename = undef; +if (keys(%$pkgs) == 1) +{ + # If debian/copyright doesn't exist, and the only a single binary + # package is built, there's a good chance that the copyright file is + # available as debian/.copyright. + $copyright_filename = $info->debfiles((keys(%$pkgs))[0] . '.copyright'); + if (not -f $copyright_filename or -l $copyright_filename) { + $copyright_filename = undef; + } +} +} + +return unless defined $copyright_filename; + +$_ = slurp_entire_file($copyright_filename); +study $_; + +my @dep5; + +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 'out-of-date-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. + eval { + @dep5 = read_dpkg_control($copyright_filename); + }; + if ($@) { + $@ =~ s/^internal error: //; + tag 'syntax-erro
Bug#633779: lintian: validate DEP-5 debian/copyright files
On 2011-08-13 00:57, Jakub Wilk wrote: > * Niels Thykier , 2011-07-18, 00:34: >>> I attached a (preliminary?) patch adding support for very basic DEP-5 >>> validation. Beware, tag descriptions could use some love. ;) >> >> Hi >> >> Thanks for looking into this. >> >> Personally I am considering if this should be moved into its own check. >> While it is related to the copyright-file check I think a DEP-5 check >> could easily deserve its own check file. >> Particularly it may keep the logic simple(r) and the DEP-5 check will >> most likely be extended in the future (e.g. to check the other >> paragraphs). > > As far as I can see, lintian currently checks only copyright files in > binary packages, not in source packages. However, to properly validate a > DEP-5 copyright file, you need access the source package. So perhaps > it'd make sense to have a source-copyright-file check and move DEP-5 > stuff there? > Hey, That could work; alternatively you can use the "$type" parameter for the check to check if you are run on a source package. Obviously that will require updating Type in checks/copyright-file.desc and possibly also "Needs-Info". Feel free to add a new separate check if that results in more maintainable code. :) ~Niels -- To UNSUBSCRIBE, email to debian-lint-maint-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/4e465e19.5090...@thykier.net
Bug#633779: lintian: validate DEP-5 debian/copyright files
* Niels Thykier , 2011-07-18, 00:34: I attached a (preliminary?) patch adding support for very basic DEP-5 validation. Beware, tag descriptions could use some love. ;) Hi Thanks for looking into this. Personally I am considering if this should be moved into its own check. While it is related to the copyright-file check I think a DEP-5 check could easily deserve its own check file. Particularly it may keep the logic simple(r) and the DEP-5 check will most likely be extended in the future (e.g. to check the other paragraphs). As far as I can see, lintian currently checks only copyright files in binary packages, not in source packages. However, to properly validate a DEP-5 copyright file, you need access the source package. So perhaps it'd make sense to have a source-copyright-file check and move DEP-5 stuff there? -- Jakub Wilk -- To UNSUBSCRIBE, email to debian-lint-maint-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/20110812225707.ga6...@jwilk.net
Bug#633779: lintian: validate DEP-5 debian/copyright files
* Jakub Wilk , 2011-07-17, 23:38: + elsif ($uri =~ m,^http://www\.debian\.org/doc/(packaging-manuals/?)copyright-format/(\d+.\d+)$,) { The regex here should be of course: m,^http://www\.debian\.org/doc/(?:packaging-manuals/)?copyright-format/(\d+\.\d+)$, -- Jakub Wilk -- To UNSUBSCRIBE, email to debian-lint-maint-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/20110718114217.ga8...@jwilk.net
Bug#633779: lintian: validate DEP-5 debian/copyright files
On 2011-07-17 23:38, Jakub Wilk wrote: > I attached a (preliminary?) patch adding support for very basic DEP-5 > validation. Beware, tag descriptions could use some love. ;) > Hi Thanks for looking into this. Personally I am considering if this should be moved into its own check. While it is related to the copyright-file check I think a DEP-5 check could easily deserve its own check file. Particularly it may keep the logic simple(r) and the DEP-5 check will most likely be extended in the future (e.g. to check the other paragraphs). ~Niels -- To UNSUBSCRIBE, email to debian-lint-maint-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/4e236382.8030...@thykier.net
Bug#633779: lintian: validate DEP-5 debian/copyright files
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'; +} +} + } # # --- 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=revision + as the format URI instead. + +Tag: unversioned-copyright-format-uri +Severity: minor +Certai
Bug#633779: lintian: validate DEP-5 debian/copyright files
Package: lintian Version: 2.5.1 Severity: wishlist I observe that quite often debian/copyright files that declare they are DEP-5-compliant, does not really follow the specification. It would be nice if lintian could warn if this is the case. Even throwing a generic control file parser at the problem would be quite effective. E.g., out of 111 DEP-5-ish debian/copyright files in Debian Python Modules Team, 19 is so broken cannot be even parsed by grep-dctrl. -- Jakub Wilk -- To UNSUBSCRIBE, email to debian-lint-maint-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/20110713162741.ga...@jwilk.net