Differences between revisions 2 and 3
Revision 2 as of 2013-01-01 10:14:59
Size: 1209
Editor: ?MichaelStapelberg
Comment:
Revision 3 as of 2013-01-01 10:24:00
Size: 2429
Editor: ?MichaelStapelberg
Comment:
Deletions are marked like this. Additions are marked like this.
Line 19: Line 19:

= TODO =
 * We need a new section for packages, just like Perl, Python, Ruby, …. Not sure where to file a report to get one.

= Example packaging =

`debian/rules`:
{{{
#!/usr/bin/make -f
# -*- makefile -*-
# Sample debian/rules that uses debhelper.
# This file was originally written by Joey Hess and Craig Small.
# As a special exception, when this file is copied by dh-make into a
# dh-make output file, you may use that output file without restriction.
# This special exception was added by Craig Small in version 0.37 of dh-make.

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

GOPKG := github.com/mstap/godebiancontrol
TMPGOPATH = $(CURDIR)/debian/golang-godebiancontrol/usr/lib/gocode

override_dh_auto_install:
 mkdir -p ${TMPGOPATH}/src/${GOPKG}
 tar cf - --exclude=debian . | (cd "${TMPGOPATH}/src/${GOPKG}" && tar xvf -)
 # Ensure that GOPATH is clean: It should only contain the temporary
 # /usr/src/golang containing the package we want to install and the
 # /usr/src/golang of the system we are building on. It should
 # specifically NOT contain the user’s local ~/gocode.
 GOPATH=${TMPGOPATH}:/usr/lib/gocode go install -v ${GOPKG}

%:
 dh $@
}}}

This page is about packaging golang.org libraries in Debian.

Facts

  • The go compiler (gc) needs to have the source code of a package available when compiling code that uses it. E.g. if your code uses github.com/mstap/godebiancontrol, gc needs $GOPATH/src/github.com/mstap/godebiancontrol

  • Perl uses libXX-perl for package names (e.g. libnet-inet6glue-perl for Net::INET6Glue), while Ruby switched to ruby-xx (e.g. ruby-tioga). TODO: Is there some rationale behind either decision? Which is “better”?

  • Both Perl and Ruby use /usr/lib/{perl,ruby} and store source as well as shared objects there.

Package naming

For github.com/mstap/godebiancontrol (which contains "go" already), the resulting Debian package name is golang-godebiancontrol.

Where to store go src/pkg data?

  • /usr/src: The FHS says this is for source, but we also store the compiled binaries.

  • /usr/lib/go: This directory is used by golang-go. The included src is a symlink to /usr/share/go/src. I’m not sure whether it’s a good idea to mix the namespace of $GOROOT and $GOPATH.

  • /usr/lib/golang: Too close to /usr/lib/go?

  • /usr/lib/gocode: Seems fine to me.

TODO

  • We need a new section for packages, just like Perl, Python, Ruby, …. Not sure where to file a report to get one.

Example packaging

debian/rules:

# -*- makefile -*-
# Sample debian/rules that uses debhelper.
# This file was originally written by Joey Hess and Craig Small.
# As a special exception, when this file is copied by dh-make into a
# dh-make output file, you may use that output file without restriction.
# This special exception was added by Craig Small in version 0.37 of dh-make.

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

GOPKG := github.com/mstap/godebiancontrol
TMPGOPATH = $(CURDIR)/debian/golang-godebiancontrol/usr/lib/gocode

override_dh_auto_install:
        mkdir -p ${TMPGOPATH}/src/${GOPKG}
        tar cf - --exclude=debian . | (cd "${TMPGOPATH}/src/${GOPKG}" && tar xvf -)
        # Ensure that GOPATH is clean: It should only contain the temporary
        # /usr/src/golang containing the package we want to install and the
        # /usr/src/golang of the system we are building on. It should
        # specifically NOT contain the user’s local ~/gocode.
        GOPATH=${TMPGOPATH}:/usr/lib/gocode go install -v ${GOPKG}

%:
        dh $@