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

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



[Niels Thykier]
> Thanks for working on this and to Jakub for the excellent review! :)

Yes, very good.  I hope to solve a real problem for Debian Med, where
the package maintainers do not notice the upstream/metadata file is
broken before the upload and a cron job start failing when the blends
pages are generated. :)

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

Ah, very good.  And it is working too. :)

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

Changed.

I fixed the code for the rest of your comments too.  Here is a new
version.
--
Happy hacking
Petter Reinholdtsen
>From be76c32c550f26a6d10be71812dd94bddda1c0a9 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   | 53 +++++++++++++++++++++++++++++++++++++++++++
 profiles/debian/main.profile  |  3 ++-
 3 files changed, 75 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..5f3c2c5
--- /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-is-not-a-file
+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, 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..1a2217e
--- /dev/null
+++ b/checks/upstream-metadata.pm
@@ -0,0 +1,53 @@
+# 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::Tags qw(tag);
+
+use YAML::XS;
+
+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::XS::LoadFile($yamlfile->fs_path()); };
+        if (!$yaml) {
+            tag('upstream-metadata-yaml-invalid');
+        }
+    } else {
+        tag('upstream-metadata-is-not-a-file');
+    }
+    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


Reply to: