control: tags -1 + patch

On Thu, Feb 22, 2018 at 9:58 AM, Chris Lamb <la...@debian.org> wrote:

> Hi Michael,
>
> > >
> > > +Tag: golang-missing-built-using
> > > +Tag: golang-built-using-on-arch-all
> > >
> > > These seem quite "clumsy" wordings and difficult to understand when
> > > out of context - can you try expanding them a little?
> >
> > Can you make a suggestion as to how they would be clearer please?
>
> Hm. The difficult part of parsing it is the "built using" proper noun.
> I don't have any thing I love but have you tried adding more nouns,
> etc.? For example, golang-package-missing-built-using-{header,field}?
> Or missing-built-using-X-for-golang-package. Or golang-built-using-
> field-on-arch-all-package? Or arch-all-golang-package-{with,but}-built-
> using-{field,header}. Or something.  :)
>

Thanks, done.


>
> > > +            if ($arch eq 'all
> > >  […]
> > > +            if ($arch ne 'all'
> […]
> > What would you consider cleaner? It seems fine to me.
>
> I don't have a concrete example but my gut tells me there is a cleaner
> structure that uses the fact that if $arch is "all", we don't need to
> check 2 lines down that it is not "all". Again, nothing concrete but
> some kind of "else" statement? :p
>

Done.


>
> > > Are we missing a Test-Depends in the "desc" file too? :)
> > >
> > Not sure what you mean?
>
> Tests have a "/desc" file with Test-For, Test-Against etc. I am
> querying whether this file should also have something along the
> lines of:
>
>   t/tests/elpa/desc:
>   5:Test-Depends: dh-elpa
>
> (Just a question, I don't have the answer to hand..!)
>

The README file states:

------------------------------------------------------------
-------------------

Sometimes tests requires certain packages that are not available in the
current stable.  In this case, you can use:

    Test-Depends: <dpkg depends field>

------------------------------------------------------------
-------------------

I don’t think that applies to this change.



>
>
> Best wishes,
>
> --
>       ,''`.
>      : :'  :     Chris Lamb
>      `. `'`      la...@debian.org / chris-lamb.co.uk
>        `-
>



-- 
Best regards,
Michael
From f82f483a31ed1b66102d0ab52e1a2a3ba6bb9cce Mon Sep 17 00:00:00 2001
From: Michael Stapelberg <stapelb...@debian.org>
Date: Thu, 22 Feb 2018 09:11:20 +0100
Subject: [PATCH] Add built-using checks

---
 checks/control-file.desc                           | 23 +++++++++++++
 checks/control-file.pm                             | 18 ++++++++++
 t/tests/binaries-golang/desc                       |  1 +
 t/tests/binaries-golang/tags                       |  1 +
 .../debian/Makefile                                | 16 +++++++++
 .../control-file-golang-built-using/debian/basic.c | 12 +++++++
 .../debian/debian/control.in                       | 40 ++++++++++++++++++++++
 t/tests/control-file-golang-built-using/desc       |  6 ++++
 t/tests/control-file-golang-built-using/tags       |  1 +
 9 files changed, 118 insertions(+)
 create mode 100644 t/tests/control-file-golang-built-using/debian/Makefile
 create mode 100644 t/tests/control-file-golang-built-using/debian/basic.c
 create mode 100644 t/tests/control-file-golang-built-using/debian/debian/control.in
 create mode 100644 t/tests/control-file-golang-built-using/desc
 create mode 100644 t/tests/control-file-golang-built-using/tags

diff --git a/checks/control-file.desc b/checks/control-file.desc
index 2b2516bfc..49c8a8c0b 100644
--- a/checks/control-file.desc
+++ b/checks/control-file.desc
@@ -350,3 +350,26 @@ Info: This package builds a binary package containing at least one path
  Please specify (eg.) <tt>Rules-Requires-Root: binary-targets</tt> in
  the <tt>debian/control</tt> source stanza.
 Ref: /usr/share/doc/dpkg-dev/rootless-builds.txt.gz
+
+Tag: missing-built-using-field-for-golang-package
+Severity: wishlist
+Certainty: certain
+Info: This package builds a binary package which does not include
+ <tt>${misc:Built-Using}</tt> in its <tt>Built-Using</tt> control field.
+ .
+ The <tt>${misc:Built-Using}</tt> substvar is populated by <tt>dh-golang(1)</tt>
+ and used for scheduling binNMUs.
+ .
+ Please add the following line to your package definition:
+ .
+ <tt>Built-Using: ${misc:Built-Using}</tt>
+
+Tag: built-using-field-on-arch-all-package
+Severity: wishlist
+Certainty: certain
+Info: This package builds a binary arch:all package which incorrectly
+ specifies a Built-Using control field.
+ .
+ <tt>Built-Using</tt> only applies to architecture-specific packages.
+ .
+ Please remove the <tt>Built-Using</tt> line from your package definition.
diff --git a/checks/control-file.pm b/checks/control-file.pm
index f2a97b24d..e1b117471 100644
--- a/checks/control-file.pm
+++ b/checks/control-file.pm
@@ -427,6 +427,24 @@ 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')) {
+        foreach my $bin (@package_names) {
+            my $bu = $info->binary_field($bin, 'built-using');
+            my $arch = $info->binary_field($bin, 'architecture');
+            if ($arch eq 'all') {
+                if (defined($bu)) {
+                    tag 'built-using-field-on-arch-all-package', $bin;
+                }
+            } else {
+                if (!defined($bu) || $bu !~ /\$\{misc:Built-Using\}/) {
+                    tag 'missing-built-using-field-for-golang-package', $bin;
+                }
+            }
+        }
+    }
+
     return;
 }
 
diff --git a/t/tests/binaries-golang/desc b/t/tests/binaries-golang/desc
index 0a13b1901..8c34704e5 100644
--- a/t/tests/binaries-golang/desc
+++ b/t/tests/binaries-golang/desc
@@ -4,3 +4,4 @@ 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
diff --git a/t/tests/binaries-golang/tags b/t/tests/binaries-golang/tags
index e69de29bb..9c49736ad 100644
--- a/t/tests/binaries-golang/tags
+++ b/t/tests/binaries-golang/tags
@@ -0,0 +1 @@
+I: binaries-golang source: missing-built-using-field-for-golang-package binaries-golang
diff --git a/t/tests/control-file-golang-built-using/debian/Makefile b/t/tests/control-file-golang-built-using/debian/Makefile
new file mode 100644
index 000000000..f04b342de
--- /dev/null
+++ b/t/tests/control-file-golang-built-using/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-built-using/debian/basic.c b/t/tests/control-file-golang-built-using/debian/basic.c
new file mode 100644
index 000000000..7dea5a030
--- /dev/null
+++ b/t/tests/control-file-golang-built-using/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-built-using/debian/debian/control.in b/t/tests/control-file-golang-built-using/debian/debian/control.in
new file mode 100644
index 000000000..136a3cb65
--- /dev/null
+++ b/t/tests/control-file-golang-built-using/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)
+
+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\}
+Built-Using: $\{misc:Built-Using\}
+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-built-using/desc b/t/tests/control-file-golang-built-using/desc
new file mode 100644
index 000000000..38e6ac0a0
--- /dev/null
+++ b/t/tests/control-file-golang-built-using/desc
@@ -0,0 +1,6 @@
+Testname: control-file-golang-built-using
+Version: 1.0
+Description: False-positive test for Built-Using field
+Architecture: any
+Test-Against: missing-built-using-field-for-golang-package
+Test-For: built-using-field-on-arch-all-package
diff --git a/t/tests/control-file-golang-built-using/tags b/t/tests/control-file-golang-built-using/tags
new file mode 100644
index 000000000..d352eadc4
--- /dev/null
+++ b/t/tests/control-file-golang-built-using/tags
@@ -0,0 +1 @@
+I: control-file-golang-built-using source: built-using-field-on-arch-all-package control-file-golang-built-using-dev
-- 
2.15.1

Reply via email to