summaryrefslogtreecommitdiff
path: root/debian/rules
diff options
context:
space:
mode:
Diffstat (limited to 'debian/rules')
-rwxr-xr-xdebian/rules53
1 files changed, 49 insertions, 4 deletions
diff --git a/debian/rules b/debian/rules
index 13b18a6c8..0959d236e 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,@OS@,$$os,g; s,@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 =