[Jakub Wilk] > Hi Petter! Hi. Thank you very much for taking the time to review the code. It is very valuable.
> AFAICS, you only need "unpacked" for this check. Right. Fixed.n > <tt>...</tt> is not strictly necessary. The only consumer of Info from > the first stanza is private/generate-lintian-pod, which already knows > that strings containing slashes are filenames, and highlights them the > same way as <tt>-ed strings. Ok. Removed. > I'd add "Ref"s to DEP-12 and to the YAML specification here. I added a DEP-12 ref, but do not know which URL to use for the YML specification, so that will have to be fixed later. :) >>+use YAML; > > Linian already uses YAML::XS in lib/Lintian/Util.pm, so I wonder if > we should use this instead. (See bug #784639 for rationale for using > this particular module.) Hm, perhaps. I have no strong opinion here, but picked one with a pure perl implementationn and a function to load a file. Could not find a file loading function in YAML::XS. Am I looking for the wrong thing, or do I have to read the file myself? > This makes perlcritic[0] upset: Heh, can't please all critics, but I modified the code to keep perlcritica happy. See attached updated version. >From c103de5fe45d5fb7800fef25c0bc2da77be31734 Mon Sep 17 00:00:00 2001 From: Petter Reinholdtsen <p...@hungry.com> Date: Sat, 6 Feb 2016 15:50:09 +0100 Subject: [PATCH] Add draft lintian check for debian/upstream/metadata. --- checks/upstream-metadata.desc | 20 ++++++++++++++++ checks/upstream-metadata.pm | 55 +++++++++++++++++++++++++++++++++++++++++++ profiles/debian/main.profile | 3 ++- 3 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 checks/upstream-metadata.desc create mode 100644 checks/upstream-metadata.pm diff --git a/checks/upstream-metadata.desc b/checks/upstream-metadata.desc new file mode 100644 index 0000000..bdb3204 --- /dev/null +++ b/checks/upstream-metadata.desc @@ -0,0 +1,20 @@ +Check-Script: upstream-metadata +Author: Petter Reinholdtsen <p...@hungry.com> +Type: source +Needs-Info: unpacked +Info: This script checks the upstream/metadata file for problems. + +Tag: upstream-metadata-not-readable +Severity: normal +Certainty: certain +Ref: http://dep.debian.net/deps/dep12/ +Info: The DEP 12 metadata file in the source is not readable. This + could be caused by a dangling symlink, but or that the name is used + by some none file directory entry. + +Tag: upstream-metadata-yaml-invalid +Severity: normal +Certainty: certain +Ref: http://dep.debian.net/deps/dep12/ +Info: The DEP 12 metadata file is not well formed. The formatting + need to be adjusted to match the YAML specification. diff --git a/checks/upstream-metadata.pm b/checks/upstream-metadata.pm new file mode 100644 index 0000000..9ff82f3 --- /dev/null +++ b/checks/upstream-metadata.pm @@ -0,0 +1,55 @@ +# upstream-metadata -- lintian check script -*- perl -*- + +# Copyright © 2016 Petter Reinholdtsen +# +# 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::upstream_metadata; + +use strict; +use warnings; + +use Lintian::Data; +use Lintian::Tags qw(tag); + +use YAML; +use Data::Dumper; + +sub run { + my (undef, undef, $info) = @_; + my $yamlfile = $info->index_resolved_path('debian/upstream/metadata'); + return if not $yamlfile; + + if ($yamlfile->is_open_ok()) { + my $yaml; + eval { $yaml = YAML::LoadFile($yamlfile->fs_path()); }; + if (!$yaml) { + tag('upstream-metadata-yaml-invalid'); + } + } else { + tag('upstream-metadata-not-readable'); + } + return; +} + +1; + +# Local Variables: +# indent-tabs-mode: nil +# cperl-indent-level: 4 +# End: +# vim: syntax=perl sw=4 sts=4 sr et diff --git a/profiles/debian/main.profile b/profiles/debian/main.profile index 92adb0d..6476de2 100644 --- a/profiles/debian/main.profile +++ b/profiles/debian/main.profile @@ -8,6 +8,7 @@ Enable-Tags-From-Check: apache2, application-not-library, automake, binaries, group-checks, huge-usr-share, infofiles, init.d, java, lintian, manpages, md5sums, menu-format, menus, nmu, obsolete-sites, ocaml, patch-systems, phppear, po-debconf, rules, scripts, shared-libs, source-copyright, standards-version, - symlinks, systemd, testsuite, usrmerge, version-substvars, watch-file + symlinks, systemd, testsuite, upstream-metadata, usrmerge, version-substvars, + watch-file Disable-Tags: hardening-no-stackprotector -- 2.1.4 -- Happy hacking Petter Reinholdtsen