[pkg-go] Bug#891184: [PATCH] Add missing-xs-go-import-path-for-golang-package

Michael Stapelberg stapelberg at debian.org
Fri Feb 23 07:42:30 UTC 2018


Package: lintian
Version: 2.5.72
Severity: wishlist
Tags: patch

Please review and merge the attached patch. Thanks!

-- System Information:
Debian Release: buster/sid
  APT prefers testing
  APT policy: (990, 'testing'), (500, 'unstable-debug'), (500, 'testing-debug'), (500, 'unstable')
Architecture: amd64 (x86_64)
Foreign Architectures: i386, armel, mipsel, arm64

Kernel: Linux 4.13.0-1-amd64 (SMP w/12 CPU cores)
Locale: LANG=de_DE.UTF-8, LC_CTYPE=de_DE.UTF-8 (charmap=UTF-8), LANGUAGE=de_DE.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages lintian depends on:
ii  binutils                          2.29.1-6
ii  bzip2                             1.0.6-8.1
ii  diffstat                          1.61-1+b1
ii  dpkg                              1.19.0.5
ii  file                              1:5.32-1
ii  gettext                           0.19.8.1-4
ii  intltool-debian                   0.35.0+20060710.4
ii  libapt-pkg-perl                   0.1.33
ii  libarchive-zip-perl               1.59-1
ii  libclass-accessor-perl            0.51-1
ii  libclone-perl                     0.38-2+b2
ii  libdpkg-perl                      1.19.0.5
ii  libemail-valid-perl               1.202-1
ii  libfile-basedir-perl              0.07-1
ii  libipc-run-perl                   0.96-1
ii  liblist-moreutils-perl            0.416-1+b3
ii  libparse-debianchangelog-perl     1.2.0-12
ii  libperl5.22 [libdigest-sha-perl]  5.22.2-5
ii  libperl5.26 [libdigest-sha-perl]  5.26.1-3
ii  libtext-levenshtein-perl          0.13-1
ii  libtimedate-perl                  2.3000-2
ii  liburi-perl                       1.72-2
ii  libxml-simple-perl                2.24-1
ii  libyaml-libyaml-perl              0.63-2+b2
ii  man-db                            2.7.6.1-2
ii  patchutils                        0.3.4-2
ii  perl                              5.26.1-3
ii  t1utils                           1.41-1
ii  xz-utils                          5.2.2-1.3

Versions of packages lintian recommends:
pn  libperlio-gzip-perl  <none>

Versions of packages lintian suggests:
pn  binutils-multiarch     <none>
ii  dpkg-dev               1.19.0.5
ii  libhtml-parser-perl    3.72-3+b2
ii  libtext-template-perl  1.47-1

-- no debconf information
-------------- next part --------------
>From 17d3d7cfde705c91b39d09aef556705f340fbd05 Mon Sep 17 00:00:00 2001
From: Michael Stapelberg <stapelberg at debian.org>
Date: Fri, 23 Feb 2018 08:38:27 +0100
Subject: [PATCH] add missing-xs-go-import-path-for-golang-package

---
 checks/control-file.desc                           | 25 ++++++++++++++
 checks/control-file.pm                             |  8 +++--
 t/tests/binaries-golang/desc                       |  4 ++-
 t/tests/binaries-golang/tags                       |  1 +
 .../debian/Makefile                                | 16 +++++++++
 .../debian/basic.c                                 | 12 +++++++
 .../debian/debian/control.in                       | 40 ++++++++++++++++++++++
 t/tests/control-file-golang-xs-go-import-path/desc |  5 +++
 t/tests/control-file-golang-xs-go-import-path/tags |  0
 9 files changed, 108 insertions(+), 3 deletions(-)
 create mode 100644 t/tests/control-file-golang-xs-go-import-path/debian/Makefile
 create mode 100644 t/tests/control-file-golang-xs-go-import-path/debian/basic.c
 create mode 100644 t/tests/control-file-golang-xs-go-import-path/debian/debian/control.in
 create mode 100644 t/tests/control-file-golang-xs-go-import-path/desc
 create mode 100644 t/tests/control-file-golang-xs-go-import-path/tags

diff --git a/checks/control-file.desc b/checks/control-file.desc
index 3e6485f79..6e6963690 100644
--- a/checks/control-file.desc
+++ b/checks/control-file.desc
@@ -374,3 +374,28 @@ Info: This package builds a binary arch:all package which incorrectly
  .
  Please remove the <tt>Built-Using</tt> line from your package
  definition.
+
+Tag: missing-xs-go-import-path-for-golang-package
+Severity: wishlist
+Certainty: certain
+Info: This source package does not specify a <tt>XS-Go-Import-Path</tt>
+ control field.
+ .
+ The <tt>XS-Go-Import-Path</tt> makes available the import path of the Go
+ package to the Debian archive in an easily machine-readable form.
+ .
+ This is used in various tooling, such as <tt>dh-make-golang(1)</tt> to
+ resolve dependencies and avoid accidental duplication in the archive,
+ or in https://pkg-go.alioth.debian.org/ci.html.
+ .
+ For packages using <tt>dh-golang</tt>, the field should be set to the same
+ value as the <tt>DH_GOPKG</tt> variable in <tt>debian/rules</tt>. In fact,
+ <tt>dh-golang</tt> will automatically set <tt>DH_GOPKG</tt> to the
+ <tt>XS-Go-Import-Path</tt> value.
+ .
+ For packages which do not use <tt>dh-golang</tt>, or whose upstream does
+ not publish the source in a way that is compatible with <tt>go get</tt>
+ and hence does not have a canonical import path, it is preferred to
+ set a fake import path. Contact the pkg-go team at
+ https://pkg-go.alioth.debian.org/ for more specific advice in your
+ specific situation.
diff --git a/checks/control-file.pm b/checks/control-file.pm
index 84a82bd60..ccd688d76 100644
--- a/checks/control-file.pm
+++ b/checks/control-file.pm
@@ -427,9 +427,9 @@ sub run {
           unless $relation->implies('${gir:Depends}');
     }
 
-    # Verify that golang binary packages set Built-Using (except for arch:all
-    # library packages).
     if ($info->relation('build-depends')->implies('golang-go | golang-any')) {
+        # Verify that golang binary packages set Built-Using (except for
+        # arch:all library packages).
         foreach my $bin (@package_names) {
             my $bu = $info->binary_field($bin, 'built-using');
             my $arch = $info->binary_field($bin, 'architecture');
@@ -442,6 +442,10 @@ sub run {
                 }
             }
         }
+
+        if (!defined($info->source_field('xs-go-import-path'))) {
+            tag 'missing-xs-go-import-path-for-golang-package';
+        }
     }
 
     return;
diff --git a/t/tests/binaries-golang/desc b/t/tests/binaries-golang/desc
index 8c34704e5..22caa4c5f 100644
--- a/t/tests/binaries-golang/desc
+++ b/t/tests/binaries-golang/desc
@@ -4,4 +4,6 @@ Extra-Build-Depends: golang-go (>= 2:1.1.1-4)
 Description: Misc errors related to golang binaries
 Architecture: any
 Test-Against: statically-linked-binary
-Test-For: missing-built-using-field-for-golang-package
+Test-For:
+ missing-built-using-field-for-golang-package
+ missing-xs-go-import-path-for-golang-package
diff --git a/t/tests/binaries-golang/tags b/t/tests/binaries-golang/tags
index 9c49736ad..f2de898ae 100644
--- a/t/tests/binaries-golang/tags
+++ b/t/tests/binaries-golang/tags
@@ -1 +1,2 @@
 I: binaries-golang source: missing-built-using-field-for-golang-package binaries-golang
+I: binaries-golang source: missing-xs-go-import-path-for-golang-package
diff --git a/t/tests/control-file-golang-xs-go-import-path/debian/Makefile b/t/tests/control-file-golang-xs-go-import-path/debian/Makefile
new file mode 100644
index 000000000..f04b342de
--- /dev/null
+++ b/t/tests/control-file-golang-xs-go-import-path/debian/Makefile
@@ -0,0 +1,16 @@
+NOPIE_CFLAGS = $(filter-out -fPIE,$(CFLAGS))
+NOPIE_LDFLAGS = $(filter-out -fPIE -pie,$(LDFLAGS))
+COMPILE:= $(CC) $(NOPIE_CFLAGS) $(CPPFLAGS) $(NOPIE_LDFLAGS)
+
+all:
+	# static version
+	$(COMPILE) -static -o basic.static basic.c
+
+install:
+	install -d $(DESTDIR)/usr/lib/foo/
+	install -m 755 basic.static $(DESTDIR)/usr/lib/foo/static
+
+clean distclean:
+	rm -f basic
+
+check test:
diff --git a/t/tests/control-file-golang-xs-go-import-path/debian/basic.c b/t/tests/control-file-golang-xs-go-import-path/debian/basic.c
new file mode 100644
index 000000000..7dea5a030
--- /dev/null
+++ b/t/tests/control-file-golang-xs-go-import-path/debian/basic.c
@@ -0,0 +1,12 @@
+#include <stdio.h>
+
+int
+main(void)
+{
+    char t[10];
+    printf("Hello world!\n");
+    /* Bad choice for reading from stdin, but it forces a stack
+       protector, so meh.
+     */
+    gets (t);
+}
diff --git a/t/tests/control-file-golang-xs-go-import-path/debian/debian/control.in b/t/tests/control-file-golang-xs-go-import-path/debian/debian/control.in
new file mode 100644
index 000000000..b4a9a7c34
--- /dev/null
+++ b/t/tests/control-file-golang-xs-go-import-path/debian/debian/control.in
@@ -0,0 +1,40 @@
+Source: {$source}
+Section: net
+Priority: optional
+Maintainer: {$author}
+Standards-Version: {$standards_version}
+Build-Depends: {$build_depends},
+ golang-go (>= 2:1.1.1-4)
+XS-Go-Import-Path: github.com/Debian/lintian-test-package
+
+Package: {$source}
+Architecture: {$architecture}
+Depends: $\{misc:Depends\}
+Built-Using: $\{misc:Built-Using\}
+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.  It may
+ be an empty package.
+
+Package: {$source}-dev
+Architecture: all
+Depends: $\{misc:Depends\}
+Description: {$description} (dev)
+ 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.  It may
+ be an empty package.
+ .
+ This package contains the source.
+
+Package: {$source}-clean-dev
+Architecture: all
+Depends: $\{misc:Depends\}
+Description: {$description} (clean dev)
+ 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.  It may
+ be an empty package.
+ .
+ This package contains the source, without a built-using tag.
diff --git a/t/tests/control-file-golang-xs-go-import-path/desc b/t/tests/control-file-golang-xs-go-import-path/desc
new file mode 100644
index 000000000..c3bf96513
--- /dev/null
+++ b/t/tests/control-file-golang-xs-go-import-path/desc
@@ -0,0 +1,5 @@
+Testname: control-file-golang-xs-go-import-path
+Version: 1.0
+Description: False-positive test for XS-Go-Import field
+Architecture: any
+Test-Against: missing-xs-go-import-path-for-golang-package
diff --git a/t/tests/control-file-golang-xs-go-import-path/tags b/t/tests/control-file-golang-xs-go-import-path/tags
new file mode 100644
index 000000000..e69de29bb
-- 
2.15.1



More information about the Pkg-go-maintainers mailing list