[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#813904: lintian: Check if upstream/metadata files are well formed



Petter Reinholdtsen:
> [Jakub Wilk]
>> Hi Petter!
> 
> Hi.  Thank you very much for taking the time to review the code.  It is
> very valuable.
> 

Hi,

Thanks for working on this and to Jakub for the excellent review! :)

>>  [...]
>>> +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?
> 

The YAML modules are hopelessly poorly documented.  However, YAML::XS
does have a "LoadFile" method.

>[...]
> 
> See attached updated version.
> 
>>From c103de5fe45d5fb7800fef25c0bc2da77be31734 Mon Sep 17 00:00:00 2001
> From: Petter Reinholdtsen <pere@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 <pere@hungry.com>
> +Type: source
> +Needs-Info: unpacked
> +Info: This script checks the upstream/metadata file for problems.
> +
> +Tag: upstream-metadata-not-readable

I think we use "<foo>-is-not-a-file".  At least that is the term used in
the systemd check.

> +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
                                           ^^^^^^^^^^^
Missing a word there (or a word too much)?

> + 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 @@
> +[...]
> +
> +package Lintian::upstream_metadata;
> +
> +use strict;
> +use warnings;
> +
> +use Lintian::Data;
   ^^^^^^^^^^^^^^^^^

Redundant module?

> +use Lintian::Tags qw(tag);
> +
> +use YAML;
> +use Data::Dumper;
   ^^^^^^^^^^^^^^^^^

Redundant module?

> +
> +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;
> +
> +[...]

Attachment: signature.asc
Description: OpenPGP digital signature


Reply to: