14

The original question, Packaging Go application for Debian, was asked over three years ago, when Go was statically linking executables.

Now, with the new Go 1.5 Release, whose release note says,

Changes to the linker enable distributing Go packages as shared libraries to link into Go programs, and building Go packages into archives or shared libraries that may be linked into or loaded by C programs

I headed to Debian GoPackaging wiki, but only to find out that it has not been updated to Go 1.5 yet, maybe the wiki is not maintained, or maybe not, but,

I just want to know, if I want to package a tool that depends on nothing but the official Go packages, how should I take advantage of the shared libraries, instead of building my app into a humongous statically linked executable?

I know the official answer may take some time, but I can wait.

Thanks to Braiam's answer, I moved a bit further.

  • I followed the blog to the step head -100 debian/**/*, but my output is completely different from the blog's. Mine is just the following. Anyone knows why and how to fix?

    $ head -100 debian/**/*
    3.0 (quilt)
    
  • I tried to run gbp buildpackage --git-pbuilder but bumped into error:

    gbp:info: Building with (cowbuilder) for sid
    Base directory /var/cache/pbuilder/base.cow does not exist
    gbp:error: 'git-pbuilder' failed: it exited with 1
    
  • I checked and verified that I already have cowbuilder & pbuilder installed:

    ii cowbuilder  amd64 pbuilder running on cowdancer
    ii pbuilder  all personal package builder for Debian packages
    

What's wrong? This pbuilder thing is new to me as I build Debian/Ubuntu Package with Docker.

Braiam
  • 1
  • 11
  • 47
  • 78
xpt
  • 20,363
  • 37
  • 127
  • 216
  • 4
    I think Debian itself needs to work this out: assuming they switch to dynamic linking, I imagine they'd add a Go stdlib package, and you build against that version of the stdlib and make it a dependency of your .deb. If you require 1.5 to build (or just really want it for whatever reason) and Debian hasn't adopted it or written rules for it yet I'm not sure just what you do. – twotwotwo Aug 23 '15 at 21:57
  • 2
    It's not clear you can depend on it yet: it looks like Debian unstable is still on 1.4.2. Ubuntu has updated to 1.5rc1 in wily, but doesn't install a shared library version of the standard lib, so you'll probably need to depend on static linking for a while longer. – James Henstridge Aug 24 '15 at 03:40
  • 1
    It adds an extra level but [godeb](https://github.com/niemeyer/godeb) works quite fine for me. At least it leaves you in control. – zoliton Oct 16 '15 at 08:45
  • well, as of today [Debian go](https://tracker.debian.org/pkg/golang) is `1.5.1`. – umläute Nov 02 '15 at 20:57
  • Good to know, and the [Debian GoPackaging wiki](https://wiki.debian.org/MichaelStapelberg/GoPackaging) is already mentioning *"Example binary + library packaging"*. But that's about it, much more details need to be put in. – xpt Nov 03 '15 at 20:51

1 Answers1

1

The easiest method is to use dh-make-golang and verify/correct the autogenerated files. Otherwise you must follow Debian Packaging Guide and create debian/* directory and editing the control and rules file to match the examples.

Braiam
  • 1
  • 11
  • 47
  • 78
  • @xpt have you created a debian package before? dh-golang helper is just a piece of, well, the entire packaging procedure. I recommend using debuild instead (adding the dh-golang package to the build-dependencies). If you tell me what you are trying to create the package of, I could give you a more precise advice. – Braiam Feb 04 '16 at 16:27
  • That'd be super, thanks a lot @Braiam. Yes, I maintain several Debian packages myself, two of which are in the official Debian repo. Let's start with https://github.com/suntong/ffcvt/, which does not require any third part libs or its own (like https://github.com/suntong/easygen). Thanks! – xpt Feb 07 '16 at 00:26
  • @xpt I did a very basic branch with the debian directory here https://github.com/braiam/ffcvt/tree/debian, will check easygen now. – Braiam Feb 07 '16 at 13:59
  • @xpt I was an idiot. After packaging both I discovered this https://people.debian.org/~stapelberg/2015/07/27/dh-make-golang.html... – Braiam Feb 07 '16 at 14:55
  • OP updated with new info (but forgot to mention that the build is done in docker and I don't have a Debian host to try building within). Thx – xpt Feb 14 '16 at 14:10
  • @xpt ugh... that may complicate stuff. – Braiam Feb 14 '16 at 14:30
  • I don't have a Debian host to do the building within the near future, but I managed to created a Ubuntu 15.10 (wily) env, but get the exact same problem as above, from within the Ubuntu Wily itself using `dh-make-golang` and `gbp buildpackage --git-pbuilder`, not within docker. Could you get a brand new Ubuntu Wily env and try it there please? (I bet the problem is the same for both Debian and Ubuntu, when the system is brand new. There must be some steps you've done but I didn't do to my brand new system) Thx. – xpt Feb 15 '16 at 07:19