Patch version 2 attached, now passes `debian/rules runtests`. On Wed, 21 Sep 2016 at 18:45:00 +0000, Niels Thykier wrote: > In checks/gir.desc: > +Reference: file:///usr/share/doc/gobject-introspection/policy.txt > ^^^^^^^^^ > > The field is "Ref" (consistent error)
Fixed in v2, and I removed file:// as Jakub requested. > Can give undef warnings if someone was "evil" enough to make the paths a > file or a symlink. Trivial work-around is to change the path end with a > slash (e.g. 'usr/share/gir-1.0/'). Fixed as suggested in v2. I also hardened it against missing fields (debs::fields-general-missing), and adjusted the expected result for tests::fields-wrong-section because typelib-missing-gir-depends is now reported for that test's package gir1.2-fields-wrong-section-0.1 (this check correctly guesses that it was meant to be GIR but lacks ${gir:Depends}). S
>From db1c11b68bea95eec09b3d9398ff7b6ec8774925 Mon Sep 17 00:00:00 2001 From: Simon McVittie <s...@debian.org> Date: Wed, 21 Sep 2016 21:49:57 +0100 Subject: [PATCH] Add checks for GObject-Introspection --- checks/gir.desc | 89 ++++++++++++++ checks/gir.pm | 135 +++++++++++++++++++++ profiles/debian/main.profile | 2 +- t/tests/gir/debian/Makefile | 7 ++ t/tests/gir/debian/debian/control.in | 81 +++++++++++++ t/tests/gir/debian/debian/gir1.2-bad.install | 2 + t/tests/gir/debian/debian/gir1.2-good-42.install | 1 + .../gir/debian/debian/gir1.2-perfect-42.install | 1 + t/tests/gir/debian/debian/libgood-42-0.install | 1 + t/tests/gir/debian/debian/libgood-42-dev.install | 2 + t/tests/gir/debian/debian/libperfect-42-0.install | 1 + .../gir/debian/debian/libperfect-42-dev.install | 2 + .../debian/usr/lib/girepository-1.0/Bad-23.typelib | 1 + .../usr/lib/girepository-1.0/Good-42.typelib | 1 + t/tests/gir/debian/usr/lib/libgood-42-0-dummy | 0 t/tests/gir/debian/usr/lib/libgood-42-dev-dummy | 0 t/tests/gir/debian/usr/share/gir-1.0/Bad-23.gir | 1 + t/tests/gir/debian/usr/share/gir-1.0/Good-42.gir | 1 + .../gir/debian/usr/share/gir-1.0/Perfect-42.gir | 1 + t/tests/gir/desc | 12 ++ t/tests/gir/post_test | 1 + t/tests/gir/tags | 9 ++ 22 files changed, 350 insertions(+), 1 deletion(-) create mode 100644 checks/gir.desc create mode 100644 checks/gir.pm create mode 100644 t/tests/gir/debian/Makefile create mode 100644 t/tests/gir/debian/debian/control.in create mode 100644 t/tests/gir/debian/debian/gir1.2-bad.install create mode 100644 t/tests/gir/debian/debian/gir1.2-good-42.install create mode 100644 t/tests/gir/debian/debian/gir1.2-perfect-42.install create mode 100644 t/tests/gir/debian/debian/libgood-42-0.install create mode 100644 t/tests/gir/debian/debian/libgood-42-dev.install create mode 100644 t/tests/gir/debian/debian/libperfect-42-0.install create mode 100644 t/tests/gir/debian/debian/libperfect-42-dev.install create mode 100644 t/tests/gir/debian/usr/lib/girepository-1.0/Bad-23.typelib create mode 100644 t/tests/gir/debian/usr/lib/girepository-1.0/Good-42.typelib create mode 100644 t/tests/gir/debian/usr/lib/libgood-42-0-dummy create mode 100644 t/tests/gir/debian/usr/lib/libgood-42-dev-dummy create mode 100644 t/tests/gir/debian/usr/share/gir-1.0/Bad-23.gir create mode 100644 t/tests/gir/debian/usr/share/gir-1.0/Good-42.gir create mode 100644 t/tests/gir/debian/usr/share/gir-1.0/Perfect-42.gir create mode 100644 t/tests/gir/desc create mode 100644 t/tests/gir/post_test create mode 100644 t/tests/gir/tags diff --git a/checks/gir.desc b/checks/gir.desc new file mode 100644 index 0000000..611b4ac --- /dev/null +++ b/checks/gir.desc @@ -0,0 +1,89 @@ +Check-Script: gir +Author: Simon McVittie <s...@debian.org> +Type: binary, source +Info: Checks for GObject-Introspection mini-policy compliance +Needs-Info: unpacked, bin-pkg-control + +Tag: gir-section-not-libdevel +Severity: normal +Certainty: certain +Info: GObject-Introspection XML files + (<tt>/usr/share/gir-1.0/Foo-23.gir</tt>) must be made available in + a development package in the <tt>libdevel</tt> section of the archive. + This is normally the same <tt>libfoo-dev</tt> package that contains + other development files. +Ref: /usr/share/doc/gobject-introspection/policy.txt + +Tag: gir-in-arch-all-package +Severity: normal +Certainty: certain +Info: GObject-Introspection XML files + (<tt>/usr/share/gir-1.0/Foo-23.gir</tt>) must be made available in + an architecture-dependent package of the same source. +Ref: /usr/share/doc/gobject-introspection/policy.txt + +Tag: gir-missing-typelib-dependency +Severity: normal +Certainty: possible +Info: Development packages that contain GObject-Introspection XML files + (<tt>/usr/share/gir-1.0/Foo-23.gir</tt>) must depend on the package + containing the corresponding binary typelib, which is conventionally named + <tt>gir1.2-foo-23</tt>. The dependency must be strictly versioned + (for example <tt>gir1.2-foo-23 (= ${binary:Version})</tt> when using + debhelper). + . + Please ignore and override this tag if the typelib is shipped in a package + whose name does not match the typelib's machine-readable name, and the + development package correctly depends on that package instead. For example, + <tt>gir1.2-glib-2.0</tt> is named for the <tt>GLib-2.0</tt> typelib, but + also contains the <tt>GObject-2.0</tt> and <tt>Gio-2.0</tt> typelibs, so + it is correct that <tt>libglib2.0-dev</tt> depends on + <tt>gir1.2-glib-2.0</tt> but not on <tt>gir1.2-gobject-2.0</tt> or + <tt>gir1.2-gio-2.0</tt>. +Ref: /usr/share/doc/gobject-introspection/policy.txt + +Tag: typelib-package-name-does-not-match +Severity: normal +Certainty: possible +Info: GObject-Introspection binary typelibs (<tt>Foo-23.typelib</tt>) + should normally be made available in a package named gir1.2-foo-23. + . + Please ignore and override this tag if the typelib is deliberately shipped + in a package whose name does not match the typelib's machine-readable name. + For example, <tt>gir1.2-glib-2.0</tt> is named for the <tt>GLib-2.0</tt> + typelib, but also contains the <tt>GObject-2.0</tt> and <tt>Gio-2.0</tt> + typelibs; this is unconventional, but is allowed. +Ref: /usr/share/doc/gobject-introspection/policy.txt + +Tag: typelib-section-not-introspection +Severity: normal +Certainty: certain +Info: GObject-Introspection binary typelibs (<tt>Foo-23.typelib</tt>) + should be made available in a GObject-Introspection package + in the <tt>introspection</tt> section of the archive, + normally named <tt>gir1.2-foo-23</tt>. +Ref: /usr/share/doc/gobject-introspection/policy.txt + +Tag: typelib-in-arch-all-package +Severity: serious +Certainty: certain +Info: GObject-Introspection binary typelibs + (<tt>Foo-23.typelib</tt>) are architecture-dependent, therefore + they must appear in architecture-dependent packages. +Ref: /usr/share/doc/gobject-introspection/policy.txt + +Tag: typelib-not-in-multiarch-directory +Severity: wishlist +Certainty: certain +Info: Public GObject-Introspection binary typelibs + (<tt>Foo-23.typelib</tt>) should be installed in the multi-arch + directory <tt>/usr/lib/MULTIARCH-TUPLE/girepository-1.0</tt>. + +Tag: typelib-missing-gir-depends +Severity: normal +Certainty: certain +Info: GObject-Introspection binary typelibs + (<tt>Foo-23.typelib</tt>) can depend on other typelibs. To generate + appropriate dependencies in the binary package, they must have + <tt>Depends: ${gir:Depends}</tt> in the control file. +Ref: /usr/share/doc/gobject-introspection/policy.txt diff --git a/checks/gir.pm b/checks/gir.pm new file mode 100644 index 0000000..085c6ce --- /dev/null +++ b/checks/gir.pm @@ -0,0 +1,135 @@ +# gir -- lintian check script for GObject-Introspection -*- perl -*- +# +# Copyright © 2012 Arno Töll +# Copyright © 2014 Collabora Ltd. +# Copyright © 2016 Simon McVittie +# +# 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::gir; + +use strict; +use warnings; +use autodie; + +use Lintian::Tags qw(tag); + +my $MA_DIRS = Lintian::Data->new('common/multiarch-dirs', qr/\s++/); + +sub run { + my ($pkg, $type, $info, $proc, $group) = @_; + + if ($type eq 'source') { + _run_source($pkg, $type, $info, $proc, $group); + } else { + _run_binary($pkg, $type, $info, $proc, $group); + } + + return; +} + +sub _run_source { + my (undef, undef, $info) = @_; + + foreach my $bin ($info->binaries) { + if ($bin =~ m/^gir1\.2-/) { + if ( + not $info->binary_relation($bin, 'strong') + ->implies('${gir:Depends}')) { + tag('typelib-missing-gir-depends', $bin); + } + } + } + + return; +} + +sub _run_binary { + my ($pkg, undef, $info, $proc, $group) = @_; + my @girs; + my @typelibs; + my $section = $info->field('section', 'NONE'); + my $madir = $MA_DIRS->value($proc->pkg_arch); + # Slightly contrived, but it might be Architecture: all, in which + # case this is the best we can do + $madir = '${DEB_HOST_MULTIARCH}' unless defined $madir; + + if (my $xmldir = $info->index_resolved_path('usr/share/gir-1.0/')) { + push @girs, $xmldir->children; + } + + if (my $dir = $info->index_resolved_path('usr/lib/girepository-1.0/')) { + push @typelibs, $dir->children; + foreach my $typelib ($dir->children) { + tag('typelib-not-in-multiarch-directory', + $typelib,"usr/lib/$madir/girepository-1.0"); + } + } + + if (my $dir= $info->index_resolved_path("usr/lib/$madir/girepository-1.0")) + { + push @typelibs, $dir->children; + } + + if ($section ne 'libdevel') { + foreach my $gir (@girs) { + tag('gir-section-not-libdevel', $gir, $section); + } + } + + if ($section ne 'introspection') { + foreach my $typelib (@typelibs) { + tag('typelib-section-not-introspection', $typelib, $section); + } + } + + if ($info->field('architecture') eq 'all') { + foreach my $gir (@girs) { + tag('gir-in-arch-all-package', $gir); + } + foreach my $typelib (@typelibs) { + tag('typelib-in-arch-all-package', $typelib); + } + } + + foreach my $gir (@girs) { + my $expected = 'gir1.2-' . lc($gir->basename); + $expected =~ s/\.gir$//; + my $version = $info->field('version'); + if (not $info->relation('strong')->implies("$expected (= $version)")) { + tag('gir-missing-typelib-dependency', $gir, $expected); + } + } + + foreach my $typelib (@typelibs) { + my $expected = 'gir1.2-' . lc($typelib->basename); + $expected =~ s/\.typelib$//; + if ($pkg ne $expected) { + tag('typelib-package-name-does-not-match', $typelib, $expected); + } + } + + 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 8cc7ce9..15b435d 100644 --- a/profiles/debian/main.profile +++ b/profiles/debian/main.profile @@ -5,7 +5,7 @@ Enable-Tags-From-Check: apache2, application-not-library, automake, binaries, changelog-file, changes-file, conffiles, control-file, control-files, copyright-file, cruft, dbus, deb-format, debconf, debhelper, debian-readme, debian-source-dir, description, duplicate-files, fields, filename-length, files, - group-checks, huge-usr-share, infofiles, init.d, java, lintian, manpages, + gir, 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, upstream-metadata, usrmerge, version-substvars, diff --git a/t/tests/gir/debian/Makefile b/t/tests/gir/debian/Makefile new file mode 100644 index 0000000..a91332d --- /dev/null +++ b/t/tests/gir/debian/Makefile @@ -0,0 +1,7 @@ +multiarch := $(shell dpkg-architecture -qDEB_HOST_ARCH) + +all: + install -d usr/lib/$(multiarch)/girepository-1.0 + cp usr/lib/libgood-42-dev-dummy usr/lib/$(multiarch)/libperfect-42-dev-dummy + cp usr/lib/libgood-42-0-dummy usr/lib/$(multiarch)/libperfect-42-0-dummy + cp usr/lib/girepository-1.0/Good-42.typelib usr/lib/$(multiarch)/girepository-1.0/Perfect-42.typelib diff --git a/t/tests/gir/debian/debian/control.in b/t/tests/gir/debian/debian/control.in new file mode 100644 index 0000000..71ed548 --- /dev/null +++ b/t/tests/gir/debian/debian/control.in @@ -0,0 +1,81 @@ +Source: {$source} +Priority: extra +Section: libs +Maintainer: {$author} +Standards-Version: {$standards_version} +Build-Depends: {$build_depends} + +Package: gir1.2-bad +Section: misc +Architecture: all +Depends: $\{shlibs:Depends\}, $\{misc:Depends\} +Description: {$description} + This is a test package designed to exercise some feature or tag of + Lintian. It is part of the Lintian test suite and may do very odd + things. It should not be installed like a regular package. + . + This package gets GObject-Introspection wrong in various ways. + +Package: gir1.2-good-42 +Section: introspection +Architecture: any +Depends: $\{gir:Depends\}, $\{shlibs:Depends\}, $\{misc:Depends\}, libgood-42-0 +Description: {$description} - GIR + This is a test package designed to exercise some feature or tag of + Lintian. It is part of the Lintian test suite and may do very odd + things. It should not be installed like a regular package. + . + This contains the GObject-Introspection typelib. + +Package: libgood-42-dev +Section: libdevel +Architecture: any +Depends: $\{shlibs:Depends\}, $\{misc:Depends\}, gir1.2-good-42 (= $\{binary:Version\}), libgood-42-0 (= $\{binary:Version\}) +Description: {$description} - development + This is a test package designed to exercise some feature or tag of + Lintian. It is part of the Lintian test suite and may do very odd + things. It should not be installed like a regular package. + . + This contains the development files. + +Package: libgood-42-0 +Architecture: any +Depends: $\{shlibs:Depends\}, $\{misc:Depends\} +Description: {$description} - shared library + This is a test package designed to exercise some feature or tag of + Lintian. It is part of the Lintian test suite and may do very odd + things. It should not be installed like a regular package. + . + This is the shared library. + +Package: gir1.2-perfect-42 +Section: introspection +Architecture: any +Depends: $\{gir:Depends\}, $\{shlibs:Depends\}, $\{misc:Depends\}, libperfect-42-0 +Description: {$description} - GIR with multiarch + This is a test package designed to exercise some feature or tag of + Lintian. It is part of the Lintian test suite and may do very odd + things. It should not be installed like a regular package. + . + This contains the GObject-Introspection typelib, with multiarch. + +Package: libperfect-42-dev +Section: libdevel +Architecture: any +Depends: $\{shlibs:Depends\}, $\{misc:Depends\}, gir1.2-perfect-42 (= $\{binary:Version\}), libperfect-42-0 (= $\{binary:Version\}) +Description: {$description} - development with multiarch + This is a test package designed to exercise some feature or tag of + Lintian. It is part of the Lintian test suite and may do very odd + things. It should not be installed like a regular package. + . + This contains the development files, with multiarch. + +Package: libperfect-42-0 +Architecture: any +Depends: $\{shlibs:Depends\}, $\{misc:Depends\} +Description: {$description} - shared library with multiarch + This is a test package designed to exercise some feature or tag of + Lintian. It is part of the Lintian test suite and may do very odd + things. It should not be installed like a regular package. + . + This is the shared library, with multiarch. diff --git a/t/tests/gir/debian/debian/gir1.2-bad.install b/t/tests/gir/debian/debian/gir1.2-bad.install new file mode 100644 index 0000000..c83626e --- /dev/null +++ b/t/tests/gir/debian/debian/gir1.2-bad.install @@ -0,0 +1,2 @@ +usr/lib/girepository-1.0/Bad-23.typelib +usr/share/gir-1.0/Bad-23.gir diff --git a/t/tests/gir/debian/debian/gir1.2-good-42.install b/t/tests/gir/debian/debian/gir1.2-good-42.install new file mode 100644 index 0000000..5f80ac4 --- /dev/null +++ b/t/tests/gir/debian/debian/gir1.2-good-42.install @@ -0,0 +1 @@ +usr/lib/girepository-1.0/Good-42.typelib diff --git a/t/tests/gir/debian/debian/gir1.2-perfect-42.install b/t/tests/gir/debian/debian/gir1.2-perfect-42.install new file mode 100644 index 0000000..195f200 --- /dev/null +++ b/t/tests/gir/debian/debian/gir1.2-perfect-42.install @@ -0,0 +1 @@ +usr/lib/*/girepository-1.0/Perfect-42.typelib diff --git a/t/tests/gir/debian/debian/libgood-42-0.install b/t/tests/gir/debian/debian/libgood-42-0.install new file mode 100644 index 0000000..5bff9aa --- /dev/null +++ b/t/tests/gir/debian/debian/libgood-42-0.install @@ -0,0 +1 @@ +usr/lib/libgood-42-0-dummy diff --git a/t/tests/gir/debian/debian/libgood-42-dev.install b/t/tests/gir/debian/debian/libgood-42-dev.install new file mode 100644 index 0000000..ae66896 --- /dev/null +++ b/t/tests/gir/debian/debian/libgood-42-dev.install @@ -0,0 +1,2 @@ +usr/share/gir-1.0/Good-42.gir +usr/lib/libgood-42-dev-dummy diff --git a/t/tests/gir/debian/debian/libperfect-42-0.install b/t/tests/gir/debian/debian/libperfect-42-0.install new file mode 100644 index 0000000..75b60a2 --- /dev/null +++ b/t/tests/gir/debian/debian/libperfect-42-0.install @@ -0,0 +1 @@ +usr/lib/*/libperfect-42-0-dummy diff --git a/t/tests/gir/debian/debian/libperfect-42-dev.install b/t/tests/gir/debian/debian/libperfect-42-dev.install new file mode 100644 index 0000000..7d0a75b --- /dev/null +++ b/t/tests/gir/debian/debian/libperfect-42-dev.install @@ -0,0 +1,2 @@ +usr/share/gir-1.0/Perfect-42.gir +usr/lib/*/libperfect-42-dev-dummy diff --git a/t/tests/gir/debian/usr/lib/girepository-1.0/Bad-23.typelib b/t/tests/gir/debian/usr/lib/girepository-1.0/Bad-23.typelib new file mode 100644 index 0000000..64fba42 --- /dev/null +++ b/t/tests/gir/debian/usr/lib/girepository-1.0/Bad-23.typelib @@ -0,0 +1 @@ +not really a typelib diff --git a/t/tests/gir/debian/usr/lib/girepository-1.0/Good-42.typelib b/t/tests/gir/debian/usr/lib/girepository-1.0/Good-42.typelib new file mode 100644 index 0000000..64fba42 --- /dev/null +++ b/t/tests/gir/debian/usr/lib/girepository-1.0/Good-42.typelib @@ -0,0 +1 @@ +not really a typelib diff --git a/t/tests/gir/debian/usr/lib/libgood-42-0-dummy b/t/tests/gir/debian/usr/lib/libgood-42-0-dummy new file mode 100644 index 0000000..e69de29 diff --git a/t/tests/gir/debian/usr/lib/libgood-42-dev-dummy b/t/tests/gir/debian/usr/lib/libgood-42-dev-dummy new file mode 100644 index 0000000..e69de29 diff --git a/t/tests/gir/debian/usr/share/gir-1.0/Bad-23.gir b/t/tests/gir/debian/usr/share/gir-1.0/Bad-23.gir new file mode 100644 index 0000000..59e267d --- /dev/null +++ b/t/tests/gir/debian/usr/share/gir-1.0/Bad-23.gir @@ -0,0 +1 @@ +not really GIR diff --git a/t/tests/gir/debian/usr/share/gir-1.0/Good-42.gir b/t/tests/gir/debian/usr/share/gir-1.0/Good-42.gir new file mode 100644 index 0000000..59e267d --- /dev/null +++ b/t/tests/gir/debian/usr/share/gir-1.0/Good-42.gir @@ -0,0 +1 @@ +not really GIR diff --git a/t/tests/gir/debian/usr/share/gir-1.0/Perfect-42.gir b/t/tests/gir/debian/usr/share/gir-1.0/Perfect-42.gir new file mode 100644 index 0000000..59e267d --- /dev/null +++ b/t/tests/gir/debian/usr/share/gir-1.0/Perfect-42.gir @@ -0,0 +1 @@ +not really GIR diff --git a/t/tests/gir/desc b/t/tests/gir/desc new file mode 100644 index 0000000..c340b8a --- /dev/null +++ b/t/tests/gir/desc @@ -0,0 +1,12 @@ +Testname: gir +Version: 1.0 +Description: test GObject-Introspection +Test-For: + gir-section-not-libdevel + gir-in-arch-all-package + gir-missing-typelib-dependency + typelib-package-name-does-not-match + typelib-section-not-introspection + typelib-in-arch-all-package + typelib-not-in-multiarch-directory + typelib-missing-gir-depends diff --git a/t/tests/gir/post_test b/t/tests/gir/post_test new file mode 100644 index 0000000..56d219b --- /dev/null +++ b/t/tests/gir/post_test @@ -0,0 +1 @@ +s, usr/lib/[^/${}]+/girepository-1.0$, usr/lib/MULTIARCH/girepository-1.0, diff --git a/t/tests/gir/tags b/t/tests/gir/tags new file mode 100644 index 0000000..4350bd6 --- /dev/null +++ b/t/tests/gir/tags @@ -0,0 +1,9 @@ +E: gir1.2-bad: typelib-in-arch-all-package usr/lib/girepository-1.0/Bad-23.typelib +I: gir1.2-bad: typelib-not-in-multiarch-directory usr/lib/girepository-1.0/Bad-23.typelib usr/lib/${DEB_HOST_MULTIARCH}/girepository-1.0 +I: gir1.2-good-42: typelib-not-in-multiarch-directory usr/lib/girepository-1.0/Good-42.typelib usr/lib/MULTIARCH/girepository-1.0 +W: gir source: typelib-missing-gir-depends gir1.2-bad +W: gir1.2-bad: gir-in-arch-all-package usr/share/gir-1.0/Bad-23.gir +W: gir1.2-bad: gir-missing-typelib-dependency usr/share/gir-1.0/Bad-23.gir gir1.2-bad-23 +W: gir1.2-bad: gir-section-not-libdevel usr/share/gir-1.0/Bad-23.gir misc +W: gir1.2-bad: typelib-package-name-does-not-match usr/lib/girepository-1.0/Bad-23.typelib gir1.2-bad-23 +W: gir1.2-bad: typelib-section-not-introspection usr/lib/girepository-1.0/Bad-23.typelib misc -- 2.9.3