1

I've been looking into building a go project into a debian package.

I've looked into dh-make-golang and I have a nice and shiny debian folder set up in my repository. When I try to use gbp buildpackage --git-pbuilder though it errors out due to all of my dependencies not being found. It seems that dh-make-golang ignores the vendor folder when it copies everything from my project's git repository, and I use govendor so all of my dependencies are in there.

How can I resolve this dependency issue and build the project as a .deb package properly? For reference, the error I am getting is:

src/github.com/project/project/project.go:15:2: cannot find package "google.golang.org/grpc/grpclog" in any of: /usr/lib/go-1.7/src/google.golang.org/grpc/grpclog (from $GOROOT) /tmp/project/obj-x86_64-linux-gnu/src/google.golang.org/grpc/grpclog (from $GOPATH)

xpt
  • 20,363
  • 37
  • 127
  • 216
baisang
  • 414
  • 6
  • 13

2 Answers2

1

Issue was a bug in dh-make-golang regarding importing vendor dependencies. It was just fixed today.

https://github.com/Debian/dh-make-golang/issues/46

baisang
  • 414
  • 6
  • 13
0

Take a look at goxc - it can do this for you!

You simply need to add a .goxc.json to the root of your directory, that looks like this

{
    "AppName": "my_app",
    "ArtifactsDest": "downloads",
    "Tasks": [
        "interpolate-source"
        "deb",
    ],
    "BuildConstraints": "linux,amd64 windows,amd64 darwin,amd64 linux,arm",
    "ResourcesInclude": "INSTALL*,README*,LICENSE*,config/*,static/*,templates/*",
    "PackageVersion": "0.9.3",
    "TaskSettings": {
        "deb": {
            "metadata": {
                "description": "my app",
                "maintainer": "me",
                "maintainer-email": "me@example.com"
            },
            "metadata-deb": {
                "Homepage": "https://example.com"
            },
            "other-mapped-files": {
                "/": "debian/",
                "/usr/share/something/static": "static/",
                "/usr/share/something/templates": "templates/"
            }
        }
    },
    "ConfigVersion": "0.9"
}

Then run goxc and it'll do all the work for you.

jaxxstorm
  • 12,422
  • 5
  • 57
  • 67
  • From the author: _"NOTE: goxc has long been in maintenance mode. Ever since Go1.5 supported simple cross-compilation, this tool lost much of its value. . . I'm very much a go user, but I myself haven't had any need for goxc for a long while."_ So, IMHO, don't waste your time checking into it, which I did following this answer. :-( – xpt May 27 '18 at 13:17