[Pkg-golang-commits] [SCM] Packaging for Google Go branch, debian-sid, updated. debian/2%1.0.1-1-51-g36f57d6
Michael Stapelberg
michael at stapelberg.de
Fri Jun 7 21:44:10 UTC 2013
The following commit has been merged in the debian-sid branch:
commit 36f57d659c29f20b9a1adbda1e7a88c818d14f11
Author: Michael Stapelberg <stapelberg at debian.org>
Date: Fri Jun 7 23:18:31 2013 +0200
build golang-go-$GOOS-$GOARCH for cross compilation, update changelog
diff --git a/debian/README.Debian b/debian/README.Debian
new file mode 100644
index 0000000..5ad7f24
--- /dev/null
+++ b/debian/README.Debian
@@ -0,0 +1,21 @@
+== Cross-Compilation
+
+Go supports cross-compilation. The environment variables GOOS (e.g. linux,
+netbsd, …) and GOARCH (amd64, 386, arm) influence the resulting binary.
+
+For example, to compile helloworld for linux_386, use:
+
+ ~/gocode/src/helloworld $ GOARCH=386 go build
+ ~/gocode/src/helloworld $ file helloworld
+ helloworld: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV),
+ statically linked, not stripped
+
+If you get an error message like this:
+
+ ~/gocode/src/helloworld $ GOARCH=386 go build
+ go build runtime: linux/386 must be bootstrapped using make.bash
+
+…you are missing the appropriate golang-go-$GOOS-$GOARCH debian package,
+i.e. golang-go-linux-386 in this case.
+
+-- Michael Stapelberg <stapelberg at debian.org> Fri, 07 Jun 2013 22:34:12 +0200
diff --git a/debian/changelog b/debian/changelog
index 9dad590..1c0663f 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,15 @@
+golang (2:1.1-2) unstable; urgency=low
+
+ [ Ondřej Surý ]
+ * Promote Michael to Maintainer
+
+ [ Michael Stapelberg ]
+ * Build golang-go-$GOOS-$GOARCH packages for cross-compiling (Closes: #710090)
+ * Build race detector on linux/amd64 (only supported arch) (Closes: #710691)
+ * Switch compression to xz (50% smaller binaries)
+
+ -- Michael Stapelberg <stapelberg at debian.org> Fri, 07 Jun 2013 23:18:09 +0200
+
golang (2:1.1-1) unstable; urgency=low
* New upstream release: Go 1.1!
diff --git a/debian/control b/debian/control
index 12785bc..941c4d1 100644
--- a/debian/control
+++ b/debian/control
@@ -1,3 +1,4 @@
+# DO NOT EDIT THIS FILE. EDIT debian/control.* instead!
Source: golang
Section: devel
Priority: optional
@@ -12,7 +13,8 @@ Homepage: http://golang.org/
Package: golang-go
Architecture: i386 amd64 armel armhf
Depends: ${shlibs:Depends}, ${misc:Depends}, ${perl:Depends},
- golang-src (>= ${source:Version})
+ golang-src (>= ${source:Version}),
+ golang-go-linux-${go:Hostarch} (= ${source:Version})
Replaces: golang-weekly-go, golang-weekly-tools, golang-tools
Conflicts: golang-weekly-go, golang-weekly-tools, golang-tools
Provides: go-compiler, golang-weekly-go, golang-weekly-tools, golang-tools
@@ -145,3 +147,195 @@ Suggests: golang-go
Description: Go programming language - Vim highlighting syntax files
This package provides syntax files for the Vim editor for editing code
in Google's Go programming language.
+
+Package: golang-go-linux-amd64
+Architecture: all
+Depends: ${shlibs:Depends}, ${misc:Depends}, ${perl:Depends}
+Description: Go standard library compiled for linux_amd64
+ This package contains the Go standard library,
+ compiled for linux_amd64.
+ .
+ This package is just one of a number of packages, each providing the Go
+ standard library for a specific operating system/architecture combination.
+ Go supports cross-compilation, so each of these packages is useful on any
+ architecture.
+ .
+ The files contained in this package are independent of the host architecture,
+ that is, you can use golang-go-linux-amd64 to generate a binary for
+ linux_amd64, even though you are executing the Go compiler on linux_386.
+
+Package: golang-go-linux-arm
+Architecture: all
+Depends: ${shlibs:Depends}, ${misc:Depends}, ${perl:Depends}
+Description: Go standard library compiled for linux_arm
+ This package contains the Go standard library,
+ compiled for linux_arm.
+ .
+ This package is just one of a number of packages, each providing the Go
+ standard library for a specific operating system/architecture combination.
+ Go supports cross-compilation, so each of these packages is useful on any
+ architecture.
+ .
+ The files contained in this package are independent of the host architecture,
+ that is, you can use golang-go-linux-amd64 to generate a binary for
+ linux_amd64, even though you are executing the Go compiler on linux_386.
+
+Package: golang-go-linux-386
+Architecture: all
+Depends: ${shlibs:Depends}, ${misc:Depends}, ${perl:Depends}
+Description: Go standard library compiled for linux_386
+ This package contains the Go standard library,
+ compiled for linux_386.
+ .
+ This package is just one of a number of packages, each providing the Go
+ standard library for a specific operating system/architecture combination.
+ Go supports cross-compilation, so each of these packages is useful on any
+ architecture.
+ .
+ The files contained in this package are independent of the host architecture,
+ that is, you can use golang-go-linux-amd64 to generate a binary for
+ linux_amd64, even though you are executing the Go compiler on linux_386.
+
+Package: golang-go-freebsd-amd64
+Architecture: all
+Depends: ${shlibs:Depends}, ${misc:Depends}, ${perl:Depends}
+Description: Go standard library compiled for freebsd_amd64
+ This package contains the Go standard library,
+ compiled for freebsd_amd64.
+ .
+ This package is just one of a number of packages, each providing the Go
+ standard library for a specific operating system/architecture combination.
+ Go supports cross-compilation, so each of these packages is useful on any
+ architecture.
+ .
+ The files contained in this package are independent of the host architecture,
+ that is, you can use golang-go-linux-amd64 to generate a binary for
+ linux_amd64, even though you are executing the Go compiler on linux_386.
+
+Package: golang-go-freebsd-arm
+Architecture: all
+Depends: ${shlibs:Depends}, ${misc:Depends}, ${perl:Depends}
+Description: Go standard library compiled for freebsd_arm
+ This package contains the Go standard library,
+ compiled for freebsd_arm.
+ .
+ This package is just one of a number of packages, each providing the Go
+ standard library for a specific operating system/architecture combination.
+ Go supports cross-compilation, so each of these packages is useful on any
+ architecture.
+ .
+ The files contained in this package are independent of the host architecture,
+ that is, you can use golang-go-linux-amd64 to generate a binary for
+ linux_amd64, even though you are executing the Go compiler on linux_386.
+
+Package: golang-go-freebsd-386
+Architecture: all
+Depends: ${shlibs:Depends}, ${misc:Depends}, ${perl:Depends}
+Description: Go standard library compiled for freebsd_386
+ This package contains the Go standard library,
+ compiled for freebsd_386.
+ .
+ This package is just one of a number of packages, each providing the Go
+ standard library for a specific operating system/architecture combination.
+ Go supports cross-compilation, so each of these packages is useful on any
+ architecture.
+ .
+ The files contained in this package are independent of the host architecture,
+ that is, you can use golang-go-linux-amd64 to generate a binary for
+ linux_amd64, even though you are executing the Go compiler on linux_386.
+
+Package: golang-go-windows-amd64
+Architecture: all
+Depends: ${shlibs:Depends}, ${misc:Depends}, ${perl:Depends}
+Description: Go standard library compiled for windows_amd64
+ This package contains the Go standard library,
+ compiled for windows_amd64.
+ .
+ This package is just one of a number of packages, each providing the Go
+ standard library for a specific operating system/architecture combination.
+ Go supports cross-compilation, so each of these packages is useful on any
+ architecture.
+ .
+ The files contained in this package are independent of the host architecture,
+ that is, you can use golang-go-linux-amd64 to generate a binary for
+ linux_amd64, even though you are executing the Go compiler on linux_386.
+
+Package: golang-go-windows-386
+Architecture: all
+Depends: ${shlibs:Depends}, ${misc:Depends}, ${perl:Depends}
+Description: Go standard library compiled for windows_386
+ This package contains the Go standard library,
+ compiled for windows_386.
+ .
+ This package is just one of a number of packages, each providing the Go
+ standard library for a specific operating system/architecture combination.
+ Go supports cross-compilation, so each of these packages is useful on any
+ architecture.
+ .
+ The files contained in this package are independent of the host architecture,
+ that is, you can use golang-go-linux-amd64 to generate a binary for
+ linux_amd64, even though you are executing the Go compiler on linux_386.
+
+Package: golang-go-darwin-amd64
+Architecture: all
+Depends: ${shlibs:Depends}, ${misc:Depends}, ${perl:Depends}
+Description: Go standard library compiled for darwin_amd64
+ This package contains the Go standard library,
+ compiled for darwin_amd64.
+ .
+ This package is just one of a number of packages, each providing the Go
+ standard library for a specific operating system/architecture combination.
+ Go supports cross-compilation, so each of these packages is useful on any
+ architecture.
+ .
+ The files contained in this package are independent of the host architecture,
+ that is, you can use golang-go-linux-amd64 to generate a binary for
+ linux_amd64, even though you are executing the Go compiler on linux_386.
+
+Package: golang-go-darwin-386
+Architecture: all
+Depends: ${shlibs:Depends}, ${misc:Depends}, ${perl:Depends}
+Description: Go standard library compiled for darwin_386
+ This package contains the Go standard library,
+ compiled for darwin_386.
+ .
+ This package is just one of a number of packages, each providing the Go
+ standard library for a specific operating system/architecture combination.
+ Go supports cross-compilation, so each of these packages is useful on any
+ architecture.
+ .
+ The files contained in this package are independent of the host architecture,
+ that is, you can use golang-go-linux-amd64 to generate a binary for
+ linux_amd64, even though you are executing the Go compiler on linux_386.
+
+Package: golang-go-netbsd-amd64
+Architecture: all
+Depends: ${shlibs:Depends}, ${misc:Depends}, ${perl:Depends}
+Description: Go standard library compiled for netbsd_amd64
+ This package contains the Go standard library,
+ compiled for netbsd_amd64.
+ .
+ This package is just one of a number of packages, each providing the Go
+ standard library for a specific operating system/architecture combination.
+ Go supports cross-compilation, so each of these packages is useful on any
+ architecture.
+ .
+ The files contained in this package are independent of the host architecture,
+ that is, you can use golang-go-linux-amd64 to generate a binary for
+ linux_amd64, even though you are executing the Go compiler on linux_386.
+
+Package: golang-go-netbsd-386
+Architecture: all
+Depends: ${shlibs:Depends}, ${misc:Depends}, ${perl:Depends}
+Description: Go standard library compiled for netbsd_386
+ This package contains the Go standard library,
+ compiled for netbsd_386.
+ .
+ This package is just one of a number of packages, each providing the Go
+ standard library for a specific operating system/architecture combination.
+ Go supports cross-compilation, so each of these packages is useful on any
+ architecture.
+ .
+ The files contained in this package are independent of the host architecture,
+ that is, you can use golang-go-linux-amd64 to generate a binary for
+ linux_amd64, even though you are executing the Go compiler on linux_386.
diff --git a/debian/control b/debian/control.base
similarity index 98%
copy from debian/control
copy to debian/control.base
index 12785bc..c7a8a0b 100644
--- a/debian/control
+++ b/debian/control.base
@@ -12,7 +12,8 @@ Homepage: http://golang.org/
Package: golang-go
Architecture: i386 amd64 armel armhf
Depends: ${shlibs:Depends}, ${misc:Depends}, ${perl:Depends},
- golang-src (>= ${source:Version})
+ golang-src (>= ${source:Version}),
+ golang-go-linux-${go:Hostarch} (= ${source:Version})
Replaces: golang-weekly-go, golang-weekly-tools, golang-tools
Conflicts: golang-weekly-go, golang-weekly-tools, golang-tools
Provides: go-compiler, golang-weekly-go, golang-weekly-tools, golang-tools
diff --git a/debian/control.cross b/debian/control.cross
new file mode 100644
index 0000000..321f020
--- /dev/null
+++ b/debian/control.cross
@@ -0,0 +1,16 @@
+
+Package: golang-go- at OS@- at ARCH@
+Architecture: all
+Depends: ${shlibs:Depends}, ${misc:Depends}, ${perl:Depends}
+Description: Go standard library compiled for @OS at _@ARCH@
+ This package contains the Go standard library,
+ compiled for @OS at _@ARCH at .
+ .
+ This package is just one of a number of packages, each providing the Go
+ standard library for a specific operating system/architecture combination.
+ Go supports cross-compilation, so each of these packages is useful on any
+ architecture.
+ .
+ The files contained in this package are independent of the host architecture,
+ that is, you can use golang-go-linux-amd64 to generate a binary for
+ linux_amd64, even though you are executing the Go compiler on linux_386.
diff --git a/debian/golang-go.install b/debian/golang-go.install
index a94edb5..09db199 100644
--- a/debian/golang-go.install
+++ b/debian/golang-go.install
@@ -1,4 +1,5 @@
bin/go /usr/bin
bin/godoc /usr/bin
bin/gofmt /usr/bin
-pkg /usr/lib/go/
+pkg/obj /usr/lib/go/pkg/
+pkg/tool /usr/lib/go/pkg/
diff --git a/debian/rules b/debian/rules
index 13b18a6..0959d23 100755
--- a/debian/rules
+++ b/debian/rules
@@ -8,11 +8,22 @@ libexecdir := /usr/lib/go
datadir := /usr/share/go
bindir := /bin
+# We loop over supported operating systems and architectures multiple times,
+# so these two variables contain a centralized version of that code.
+# The variables $$os and $$arch can be used inside such a loop.
+FOR_GO_ARCH := for os in $$(echo linux freebsd windows darwin netbsd); do \
+ archs="amd64 386"; \
+ [ "$$os" = "linux" ] || [ "$$os" = "freebsd" ] && archs="amd64 arm 386"; \
+ for arch in $$(echo $$archs); do
+FOR_GO_ARCH_END := done; done
+
build-arch build-indep build clean install binary-arch binary-indep binary: debian/control
+dh --parallel $(opt_no_act) $@
override_dh_auto_clean:
rm -rf bin pkg
+ # golang-go-$os-$arch.install files are auto-generated in override_dh_install
+ rm -f debian/golang-go-*.install
rm -f debian/*+
rm -f debian/build.stamp
rm -f test/pass.out test/run.out test/times.out
@@ -31,7 +42,23 @@ endif
override_dh_compress:
dh_compress -Xusr/share/doc/$(PACKAGE)-doc/html -Xusr/share/doc/$(PACKAGE)-doc/godoc
+# Generates debian/control from debian/control.base and debian/control.cross.
+# In the latter, @OS@ and @ARCH@ are replaced with every supported combination
+# of operating system and architecture (e.g. linux_amd64, linux_386, …).
+gencontrol:
+ echo "# DO NOT EDIT THIS FILE. EDIT debian/control.* instead!" > debian/control.tmp
+ cat debian/control.base >> debian/control.tmp
+ ${FOR_GO_ARCH} \
+ sed -e "s, at OS@,$$os,g; s, at ARCH@,$$arch,g" debian/control.cross >> debian/control.tmp; \
+ ${FOR_GO_ARCH_END}
+ mv debian/control.tmp debian/control
+
override_dh_install:
+ -${FOR_GO_ARCH} \
+ echo "pkg/$${os}_$${arch} /usr/lib/go/pkg/" > debian/golang-go-$$os-$$arch.install; \
+ [ "$$arch" = "amd64" ] && [ "$$os" = "linux" ] && echo "pkg/linux_amd64_race /usr/lib/go/pkg" >> debian/golang-go-$$os-$$arch.install; \
+ echo "golang-go-$$os-$$arch: arch-independent-package-contains-binary-or-object" > debian/golang-go-$$os-$$arch.lintian-overrides; \
+ ${FOR_GO_ARCH_END}
dh_install --fail-missing
# Replace jquery in the html documentation with a symlink to libjs-jquery.
-rm $(CURDIR)/debian/golang-doc/usr/share/doc/golang-doc/html/jquery.js && \
@@ -49,6 +76,10 @@ override_dh_install:
find $(CURDIR)/debian/golang-go/usr/share/go/src -type d -delete
# Subsequently, /usr/share/go is empty, too, so remove
find $(CURDIR)/debian/golang-go/usr/share/go -type d -delete
+ # For some reason, Go cross-compiles a handful of tools: {yacc,fix,api,vet,cgo}.
+ # Delete those, as they cannot be ran anyway.
+ # This is tracked upstream at https://code.google.com/p/go/issues/detail?id=5667
+ (cd $(CURDIR)/debian/golang-go/usr/lib/go/pkg/tool && find . -depth -path "./$(GOHOSTOS)_$(GOHOSTARCH)*" -prune -o -delete)
# Touch built and installed files and directories to have same timestamp
touch $(CURDIR)/debian/golang-go/usr/lib/go/pkg
find $(CURDIR)/debian/golang-go/usr/lib/go/pkg -exec touch -r $(CURDIR)/debian/golang-go/usr/lib/go/pkg {} \;
@@ -56,17 +87,31 @@ override_dh_install:
override_dh_strip:
dh_strip -X".a" -Xgoinstall -Xgodoc -Xgoyacc -Xbin/cgo -Xebnflint -Xgofix -Xgofmt -Xgovet -Xgotest --dbg-package=$(PACKAGE)-dbg
+override_dh_prep:
+ dh_prep
+ echo 'go:Hostarch=$(GOHOSTARCH)' >> debian/golang-go.substvars
+
+override_dh_builddeb:
+ dh_builddeb -- -Zxz
+
debian/build.stamp:
rm -f debian/build.stamp
mkdir -p $(GOBIN)
- +cd src && bash ./make.bash --no-banner
+ # Build native tools first, then bootstrap all other GOOS/GOARCH combinations.
+ cd src && bash ./make.bash --no-banner
# For the race detector to work (go test -race), we need to install the
# std library with the race detector enabled. This will result in
# having an additional “architecture” directory, e.g. linux_amd64_race.
#
- # The race detector currently only works on linux/amd64. The following
- # check works precisely the same way src/race.bash does.
- -[ "$(shell uname -m)" = "x86_64" ] && [ "$(shell uname)" = "Linux" ] && $(CURDIR)/bin/go install -race std
+ # The race detector currently only works on linux/amd64. The check within
+ # the following loop works precisely the same way src/race.bash does.
+ -${FOR_GO_ARCH} \
+ export GOARCH=$$arch; \
+ export GOOS=$$os; \
+ cd src && bash ./make.bash --no-clean; \
+ [ "$$arch" = "amd64" ] && [ "$$os" = "linux" ] && $(GOBIN)/go install -race std; \
+ cd ..; \
+ ${FOR_GO_ARCH_END}
>debian/build.stamp
opt_no_act =
--
Packaging for Google Go
More information about the pkg-golang-commits
mailing list