On Wed, Apr 15, 2020 at 7:06 PM Michael Vogt <m...@ubuntu.com> wrote:
>
> On Wed, Apr 15, 2020 at 06:21:16PM +0800, Shengjing Zhu wrote:
> > On Wed, Apr 15, 2020 at 4:54 PM Michael Vogt <m...@ubuntu.com> wrote:
> > >
> > > Package: dh-golang
> > > Version: 1.48
> > >
> > > It would be nice if dh-golang would support setting go buildtags.
> > >
> > > My use-case is a relatively large go application (snapd). It has a
> > > buildtag (nosecboot) to exclude parts that are only relevant for
> > > embedded systems. Right now I workaround this by removing files but
> > > that is a bit of a ugly workaround.
> >
> > I think you cat override dh_auto_* target, like:
> >
> > override_dh_auto_build:
> >        dh_auto_build -- -tags nosecboot
> >
> > Real examples are:
> > https://salsa.debian.org/go-team/packages/runc/-/blob/master/debian/rules#L12
>
> Thank you for your quick and reply and your suggestion! Yes, this
> works and it is what I was doing so far and it works in most cases.
>
> However it seems like it's not enough for some cases (like the latest
> changes in snapd).
>
> There are bits inside dh_golang that use "go list -f ..." without
> considering tags and AFAICT with no way to add awareness for build
> tags.
>
> So in my case go list will also include the files that have the
> "!secboot" tag which have extra go dependencies that are not available
> in debian. This then makes the build fail.
>
> Let me give an example, suppose we have foo.go:
> """
> // +build !nosecboot
>
> package foo
> import "unavailable.pkg/in/debian"
> """"
>
> then "go list -f" will pickup the unavailalbe import (I hope this
> explanation makes sense, happy to expand or give more concrete
> examples). If there is a workaround for this, I would love to learn it
> :)
>

TIL the go command respects the GOFLAGS env.
So if you set GOFLAGS='-tags=nosecboot', it will ignore this foo.go.

> Thanks,
>  Michael

-- 
Shengjing Zhu

Reply via email to