Hi, I took a stab at implementing classification tags (see attached patches or [1]). These tags are intended solely as a means to classify (an aspect of) a package and are by no means an issue people need to fix. * The proposed implementation is basically a hack which abuses the "severity". * I am open to other suggestions (especially those with patches). * I have not given the colouring a lot of thought and welcome suggestions here as well. - Notably, part of the css is basically copy-waste of the "pedantic" tag, so they currently share the same colour for the description. With the patch, I also implemented two classifications tags for the sake of it: * classification-of-debian-build-system - always emitted * declared-source-format - omitted when the format is "implicit" (i.e. d/source/format is absent). These can be tested by using "-L +classification" (or "-L =classification"). Output of running on lintian itself: """ $ frontend/lintian -L =classification lintian_2.5.42_source.changes C: lintian source: classification-of-debian-build-system dh C: lintian source: declared-source-format 3.0 (native) N: 5 tags overridden (1 error, 3 warnings, 1 info) """ Thanks, ~Niels [1] https://anonscm.debian.org/git/users/nthykier/lintian.git/log/?h=support-classification-tags
From c5ebc60a6836d74977fb63782ac9a39045aaf75e Mon Sep 17 00:00:00 2001 From: Niels Thykier <niels@thykier.net> Date: Sun, 6 Mar 2016 18:01:22 +0000 Subject: [PATCH 1/3] Add support for "classification" tags Signed-off-by: Niels Thykier <niels@thykier.net> --- doc/lintian.xml | 9 ++++++--- lib/Lintian/Internal/FrontendUtil.pm | 2 +- lib/Lintian/Output.pm | 3 ++- lib/Lintian/Output/LetterQualifier.pm | 5 +++++ lib/Lintian/Profile.pm | 13 +++++++++++-- lib/Lintian/Tag/Info.pm | 7 +++++++ lib/Lintian/Tags.pm | 5 ++++- 7 files changed, 36 insertions(+), 8 deletions(-) diff --git a/doc/lintian.xml b/doc/lintian.xml index bfd0464..43601a9 100644 --- a/doc/lintian.xml +++ b/doc/lintian.xml @@ -929,9 +929,12 @@ foo [!any-i386] binary: some-tag-not-for-i386 optional-extra <term><emphasis>Severity</emphasis> (simple, optional)</term> <listitem> <para> - The value must be a valid tag severity; the severity - of the affected tags is set to this value. Note - that <emphasis>experimental</emphasis> is not a + The value must be a valid tag severity other than "classification". + The severity of the affected tags is set to this value. This + cannot be used on any tag that is defined as a "classification" tag. + </para> + <para> + Note that <emphasis>experimental</emphasis> is not a severity. </para> </listitem> diff --git a/lib/Lintian/Internal/FrontendUtil.pm b/lib/Lintian/Internal/FrontendUtil.pm index a14f523..d199c28 100644 --- a/lib/Lintian/Internal/FrontendUtil.pm +++ b/lib/Lintian/Internal/FrontendUtil.pm @@ -159,7 +159,7 @@ sub default_parallel { # Where the marked part(s) are optional values. The numbers above # the example are the capture groups. my $TAG_REGEX - = qr/([EWIXOP]): (\S+)(?: (\S+)(?:$verarchre)?)?: (\S+)(?:\s+(.*))?/o; + = qr/([EWIXOPC]): (\S+)(?: (\S+)(?:$verarchre)?)?: (\S+)(?:\s+(.*))?/o; sub split_tag { my ($tag_input) = @_; diff --git a/lib/Lintian/Output.pm b/lib/Lintian/Output.pm index d026bd7..2884d37 100644 --- a/lib/Lintian/Output.pm +++ b/lib/Lintian/Output.pm @@ -144,7 +144,8 @@ my %default_colors = ( 'E' => 'red', 'W' => 'yellow', 'I' => 'cyan', - 'P' => 'green' + 'P' => 'green', + 'C' => 'blue', ); our $GLOBAL = Lintian::Output->new; diff --git a/lib/Lintian/Output/LetterQualifier.pm b/lib/Lintian/Output/LetterQualifier.pm index 8c26620..a1926f1 100644 --- a/lib/Lintian/Output/LetterQualifier.pm +++ b/lib/Lintian/Output/LetterQualifier.pm @@ -28,6 +28,11 @@ use Lintian::Output qw(:util); use parent qw(Lintian::Output); my %codes = ( + 'classification' => { + 'wild-guess' => 'C?', + 'possible' => 'C ', + 'certain' => 'C!' + }, 'pedantic' => { 'wild-guess' => 'P?', 'possible' => 'P ', diff --git a/lib/Lintian/Profile.pm b/lib/Lintian/Profile.pm index 9a6d057..4c901a5 100644 --- a/lib/Lintian/Profile.pm +++ b/lib/Lintian/Profile.pm @@ -417,13 +417,22 @@ sub _read_profile_section { qq{Profile "$pname" contains invalid severity}, qq{"$severity" in section $sno})) - if $severity && !$SEVERITIES{$severity}; + if $severity + && (!$SEVERITIES{$severity} || $severity eq 'classification'); foreach my $tag (@tags) { croak "Unknown check $tag in $pname (section $sno)" unless $self->{'known-tags'}{$tag}; if ($severity) { - $self->{'known-tags'}{$tag}->set_severity($severity); + my $t = $self->{'known-tags'}{$tag}; + if ($t->severity(1) eq 'classification') { + croak( + join(q{ }, + qq{${tag} is a classification tag}, + q{and cannot not be assigned a severity}, + qq{(profile "$pname", section $sno)})); + } + $t->set_severity($severity); } if ($overridable != -1) { if ($overridable) { diff --git a/lib/Lintian/Tag/Info.pm b/lib/Lintian/Tag/Info.pm index 7f0844c..e84eb9f 100644 --- a/lib/Lintian/Tag/Info.pm +++ b/lib/Lintian/Tag/Info.pm @@ -43,6 +43,7 @@ our $MANUALS # Map severity/certainty levels to tag codes. our %CODES = ( + classification => { 'wild-guess' => 'C', possible => 'C', certain => 'C' }, pedantic => { 'wild-guess' => 'P', possible => 'P', certain => 'P' }, wishlist => { 'wild-guess' => 'I', possible => 'I', certain => 'I' }, minor => { 'wild-guess' => 'I', possible => 'I', certain => 'W' }, @@ -278,6 +279,12 @@ sub description { . ' ignore experimental tags that do not seem to make sense,' . ' though of course bug reports are always welcome.'); } + if ($severity eq 'classification') { + push(@text, + '', + 'This tag intended as a classification' + . ' and is <i>not</i> an issue in the package.'); + } # Format and return the output. if ($format eq 'text') { diff --git a/lib/Lintian/Tags.pm b/lib/Lintian/Tags.pm index b417556..bc24c5d 100644 --- a/lib/Lintian/Tags.pm +++ b/lib/Lintian/Tags.pm @@ -42,7 +42,8 @@ BEGIN { our $GLOBAL; # Ordered lists of severities and certainties, used for display level parsing. -our @SEVERITIES = qw(pedantic wishlist minor normal important serious); +our @SEVERITIES + = qw(classification pedantic wishlist minor normal important serious); our @CERTAINTIES = qw(wild-guess possible certain); =head1 NAME @@ -146,6 +147,8 @@ sub new { my $self = { current => undef, display_level => { + classification => + { 'wild-guess' => 0, possible => 0, certain => 0 }, wishlist => { 'wild-guess' => 0, possible => 0, certain => 0 }, minor => { 'wild-guess' => 0, possible => 0, certain => 1 }, normal => { 'wild-guess' => 0, possible => 1, certain => 1 }, -- 2.7.0
From 80640e970aee57c5f8a8f69e3387aa7f1bf20e87 Mon Sep 17 00:00:00 2001 From: Niels Thykier <niels@thykier.net> Date: Sun, 6 Mar 2016 18:32:18 +0000 Subject: [PATCH 2/3] c/debhelper: Attempt to classify build system Signed-off-by: Niels Thykier <niels@thykier.net> --- checks/debhelper.desc | 6 ++++++ checks/debhelper.pm | 18 ++++++++++++++++-- reporting/templates/lintian.css.tmpl | 10 ++++++++++ t/tests/debhelper-compat-old/desc | 3 ++- t/tests/debhelper-compat-old/tags | 1 + 5 files changed, 35 insertions(+), 3 deletions(-) diff --git a/checks/debhelper.desc b/checks/debhelper.desc index 92d1d66..78711b5 100644 --- a/checks/debhelper.desc +++ b/checks/debhelper.desc @@ -371,3 +371,9 @@ Info: The package uses one (or more) of the obsolete dh parameters Please refer to the debhelper documentation for more information. Ref: https://lists.debian.org/debian-devel-changes/2011/08/msg00519.html, debhelper(7) + +Tag: classification-of-debian-build-system +Severity: classification +Certainty: certain +Info: This is the build system that Lintian believes the package is + using. diff --git a/checks/debhelper.pm b/checks/debhelper.pm index d3fb3c5..3dcec3e 100644 --- a/checks/debhelper.pm +++ b/checks/debhelper.pm @@ -65,8 +65,7 @@ sub run { my $dhcompatvalue; my $inclcdbs = 0; - my $bdepends_noarch; - my $bdepends; + my ($bdepends_noarch, $bdepends, %build_systems); my $seen_dh = 0; my $seen_python_helper = 0; my $seen_python3_helper = 0; @@ -89,6 +88,8 @@ sub run { if (m/^\s+-?(dh_\S+)/) { my $dhcommand = $1; + $build_systems{'debhelper'} = 1 + if not exists($build_systems{'dh'}); if ($dhcommand eq 'dh_undocumented') { tag 'dh_undocumented-is-obsolete', "line $."; @@ -138,6 +139,8 @@ sub run { $seencommand = 1; $needbuilddepends = 1; } elsif (m,^\s+dh\s+,) { + $build_systems{'dh'} = 1; + delete($build_systems{'debhelper'}); $seen_dh = 1; $seencommand = 1; $needbuilddepends = 1; @@ -170,6 +173,8 @@ sub run { $seen_python_helper = -1; # maybe; we'll check that later } } elsif (m,^include\s+/usr/share/cdbs/1/rules/debhelper.mk,) { + $build_systems{'cdbs-with-debhelper.mk'} = 1; + delete($build_systems{'cdbs-without-debhelper.mk'}); $seencommand = 1; $needbuilddepends = 1; $needtomodifyscripts = 1; @@ -192,6 +197,8 @@ sub run { } elsif (m,^include\s+/usr/share/cdbs/, or m,^include\s+/usr/share/R/debian/r-cran.mk,o) { $inclcdbs = 1; + $build_systems{'cdbs-without-debhelper.mk'} = 1 + if not exists($build_systems{'cdbs-with-debhelper.mk'}); } } close($rules_fd); @@ -202,6 +209,13 @@ sub run { tag 'unused-build-dependency-on-cdbs' if ($bdepends->implies('cdbs')); } + if (%build_systems) { + my @systems = sort(keys(%build_systems)); + tag 'classification-of-debian-build-system', join(', ', @systems); + } else { + tag 'classification-of-debian-build-system', 'other'; + } + return unless $seencommand; my @pkgs = $info->binaries; diff --git a/reporting/templates/lintian.css.tmpl b/reporting/templates/lintian.css.tmpl index 8cd6af9..f6de64c 100644 --- a/reporting/templates/lintian.css.tmpl +++ b/reporting/templates/lintian.css.tmpl @@ -369,6 +369,11 @@ span.type-P { background-color: #C7EA3C; } +span.type-C { + color: #111; + background-color: blue; +} + li.type-O { color: #444; } @@ -404,6 +409,11 @@ blockquote.type-P { border: 1px solid #C7EA3C; } +blockquote.type-C { + background-color: #DFA; + border: 1px solid #C7EA3C; +} + /* * 5. Footer diff --git a/t/tests/debhelper-compat-old/desc b/t/tests/debhelper-compat-old/desc index 562d890..0b47203 100644 --- a/t/tests/debhelper-compat-old/desc +++ b/t/tests/debhelper-compat-old/desc @@ -3,7 +3,8 @@ Sequence: 6000 Version: 1.0 Description: Test for old debian/compat file Skeleton: pedantic -Options: --pedantic -I -E +Options: --pedantic -I -E -L +classification Test-Depends: debhelper (>= 9), Test-For: package-uses-old-debhelper-compat-version + classification-of-debian-build-system diff --git a/t/tests/debhelper-compat-old/tags b/t/tests/debhelper-compat-old/tags index a1195ab..82a1f80 100644 --- a/t/tests/debhelper-compat-old/tags +++ b/t/tests/debhelper-compat-old/tags @@ -1 +1,2 @@ +C: debhelper-compat-old source: classification-of-debian-build-system dh P: debhelper-compat-old source: package-uses-old-debhelper-compat-version 8 -- 2.7.0
From b7a92c5ad5a331a770d1a26b43216cea402951e4 Mon Sep 17 00:00:00 2001 From: Niels Thykier <niels@thykier.net> Date: Sun, 6 Mar 2016 18:52:22 +0000 Subject: [PATCH 3/3] c/d-src-dir: Classify the declared source format --- checks/debian-source-dir.desc | 5 +++++ checks/debian-source-dir.pm | 1 + t/tests/debian-source-dir-classifications/desc | 6 ++++++ t/tests/debian-source-dir-classifications/tags | 1 + 4 files changed, 13 insertions(+) create mode 100644 t/tests/debian-source-dir-classifications/desc create mode 100644 t/tests/debian-source-dir-classifications/tags diff --git a/checks/debian-source-dir.desc b/checks/debian-source-dir.desc index 0a94b2d..721a5a5 100644 --- a/checks/debian-source-dir.desc +++ b/checks/debian-source-dir.desc @@ -63,3 +63,8 @@ Info: The source package contains non-empty debian/source/git-patches, with a misconfigured gitpkg) and without manually exporting the patches. See the above mentioned hook file (in /usr/share/gitpkg/hooks) for information on how to manually export patches. + +Tag: declared-source-format +Severity: classification +Certainty: certain +Info: This is the source format declared in the package. diff --git a/checks/debian-source-dir.pm b/checks/debian-source-dir.pm index c9518ce..6257914 100644 --- a/checks/debian-source-dir.pm +++ b/checks/debian-source-dir.pm @@ -46,6 +46,7 @@ sub run { chomp $format; close($fd); tag 'unknown-source-format', $format unless $KNOWN_FORMATS{$format}; + tag 'declared-source-format', $format; } else { tag 'missing-debian-source-format'; } diff --git a/t/tests/debian-source-dir-classifications/desc b/t/tests/debian-source-dir-classifications/desc new file mode 100644 index 0000000..a82336f --- /dev/null +++ b/t/tests/debian-source-dir-classifications/desc @@ -0,0 +1,6 @@ +Testname: debian-source-dir-classifications +Sequence: 6000 +Version: 1.0 +Options: -L +classification -C debian-source-dir +Description: Test for d-s-d classifications tags +Test-For: declared-source-format diff --git a/t/tests/debian-source-dir-classifications/tags b/t/tests/debian-source-dir-classifications/tags new file mode 100644 index 0000000..0008e30 --- /dev/null +++ b/t/tests/debian-source-dir-classifications/tags @@ -0,0 +1 @@ +C: debian-source-dir-classifications source: declared-source-format 1.0 -- 2.7.0
Attachment:
signature.asc
Description: OpenPGP digital signature