[Pkg-golang-commits] [golang] 01/01: Refactor "debian/rules" to utilize debhelper more effectively, especially for arch vs indep building
Tianon Gravi
tianon at debian.org
Fri Sep 25 20:04:49 UTC 2015
This is an automated email from the git hooks/post-receive script.
tianon pushed a commit to branch debian-experimental
in repository golang.
commit 463632177297882e99ae317670075a73802591ee
Author: Tianon Gravi <tianon at debian.org>
Date: Fri Sep 25 13:04:33 2015 -0700
Refactor "debian/rules" to utilize debhelper more effectively, especially for arch vs indep building
Also, move "dpkg-architecture" to "GOOS"/"GOARCH" code into a simple shell script for easier maintenance.
---
debian/changelog | 4 ++
debian/helpers/goenv.sh | 54 ++++++++++++++++
debian/rules | 165 ++++++++++--------------------------------------
3 files changed, 91 insertions(+), 132 deletions(-)
diff --git a/debian/changelog b/debian/changelog
index c36eecf..2f889bc 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -14,6 +14,10 @@ golang (2:1.5.1-1~exp1) UNRELEASED; urgency=low
* Add more supported arches to "debian/rules" code for detecting
appropriate GOARCH/GOHOSTARCH values; thanks mwhudson and tpot!
(Closes: #799907)
+ * Refactor "debian/rules" to utilize debhelper more effectively, especially
+ for arch vs indep building.
+ * Move "dpkg-architecture" to "GOOS"/"GOARCH" code into a simple shell script
+ for easier maintenance.
-- Tianon Gravi <tianon at debian.org> Wed, 22 Jul 2015 21:55:56 -0700
diff --git a/debian/helpers/goenv.sh b/debian/helpers/goenv.sh
new file mode 100755
index 0000000..f9973bc
--- /dev/null
+++ b/debian/helpers/goenv.sh
@@ -0,0 +1,54 @@
+#!/bin/sh
+set -e
+
+# build machine
+# The machine the package is built on.
+#
+# host machine
+# The machine the package is built for.
+
+__goos__deb_arch_os() {
+ case "$1" in
+ kfreebsd) echo freebsd ;;
+ linux) echo "$1" ;;
+ *) echo >&2 "error: unrecongized DEB_*_ARCH_OS: $1"; exit 1 ;;
+ esac
+}
+
+__goarch__deb_arch_cpu() {
+ case "$1" in
+ amd64|arm|arm64|ppc64) echo "$1" ;;
+ i386) echo 386 ;;
+ ppc64el) echo ppc64le ;;
+ *) echo >&2 "error: unrecongized DEB_*_ARCH_CPU: $1"; exit 1 ;;
+ esac
+}
+
+export GOHOSTOS="$(__goos__deb_arch_os "$(dpkg-architecture -qDEB_BUILD_ARCH_OS 2>/dev/null)")"
+export GOOS="$(__goos__deb_arch_os "$(dpkg-architecture -qDEB_HOST_ARCH_OS 2>/dev/null)")"
+
+export GOHOSTARCH="$(__goarch__deb_arch_cpu "$(dpkg-architecture -qDEB_BUILD_ARCH_CPU 2>/dev/null)")"
+export GOARCH="$(__goarch__deb_arch_cpu "$(dpkg-architecture -qDEB_HOST_ARCH_CPU 2>/dev/null)")"
+
+if [ -z "$GOHOSTOS" -o -z "$GOOS" -o -z "$GOHOSTARCH" -o -z "$GOARCH" ]; then
+ exit 1
+fi
+
+# Always use the 387 floating point unit instead of sse2. This is important to
+# ensure that the binaries we build (both when compiling golang on the buildds
+# and when users cross-compile for 386) can actually run on older CPUs (where
+# old means e.g. an AMD Athlon XP 2400+). See http://bugs.debian.org/753160 and
+# https://code.google.com/p/go/issues/detail?id=8152
+export GO386=387
+
+unset GOARM
+if [ "$GOARCH" = 'arm' ]; then
+ # start with GOARM=5 for maximum compatibility (see note about GO386 above)
+ GOARM=5
+ case "$(dpkg-architecture -qDEB_HOST_ARCH 2>/dev/null)" in
+ armhf) GOARM=6 ;;
+ esac
+fi
+export GOARM
+
+eval "$@"
diff --git a/debian/rules b/debian/rules
index c5a0d8e..9b27569 100755
--- a/debian/rules
+++ b/debian/rules
@@ -6,159 +6,60 @@ libexecdir := /usr/lib/go
datadir := /usr/share/go
bindir := /bin
-build-arch build-indep build clean install binary-arch binary-indep binary: debian/control
+export GOROOT := $(CURDIR)
+export GOROOT_FINAL := $(libexecdir)
+
+%:
+dh --parallel $(opt_no_act) $@
override_dh_auto_clean:
+ # remove autogenerated files
+ rm -f \
+ src/cmd/cgo/zdefaultcc.go \
+ src/cmd/go/zdefaultcc.go \
+ src/cmd/internal/obj/zbootstrap.go \
+ src/runtime/zversion.go
+ # remove built objects
rm -rf bin pkg
- rm -f debian/*+
- rm -f debian/build.stamp
- rm -f test/pass.out test/run.out test/times.out
- rm -rf debian/home
-
-override_dh_auto_build: debian/build.stamp
-override_dh_auto_test:
-ifeq ($(RUN_TEST), true)
- cd $(CURDIR)/src && \
- $(CURDIR)/debian/test.bash $(GOROOT)/pkg/tool/$(GOHOSTOS)_$(GOHOSTARCH);
-else
- :
-endif
+override_dh_auto_test-arch:
+ set -ex; \
+ cd src; \
+ export PATH="$(GOROOT)/bin:$$PATH"; \
+ eval "$$(go tool dist env)"; \
+ bash run.bash --no-rebuild;
-override_dh_compress:
+override_dh_compress-indep:
dh_compress -Xusr/share/doc/golang-doc/html -Xusr/share/doc/golang-doc/godoc
-override_dh_install:
- # Install the native runtime/cgo.a to the golang-go package.
- # runtime/cgo is only built for the native architecture, but the
- # golang-go-OS-ARCH packages are built on one particular buildd, which
- # might either be i386 or amd64.
- echo "listing of $$(pwd):"; ls -hlR .
- echo "listing of GOBIN: ($(GOBIN))"; ls -hlR $(GOBIN)
- for file in pkg/*/runtime/cgo.a; do \
- mkdir -p $(CURDIR)/debian/golang-go/usr/lib/go/$$(dirname $$file); \
- mv $$file $(CURDIR)/debian/golang-go/usr/lib/go/$$file; \
- done
+override_dh_install-arch:
dh_install --fail-missing
# Remove Plan9 rc(1) scripts
- find $(CURDIR)/debian/golang-src/usr/share/go/src -type f -name "*.rc" -delete
+ find debian/golang-src/usr/share/go/src -type f -name '*.rc' -delete
# Remove empty /usr/share/go/src from golang-go, it is provided by golang-src
- find $(CURDIR)/debian/golang-go/usr/share/go/src -type d -delete
+ find debian/golang-go/usr/share/go/src -type d -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 {} \;
+ touch debian/golang-go/usr/lib/go/pkg
+ find debian/golang-go/usr/lib/go/pkg -exec touch -r $(CURDIR)/debian/golang-go/usr/lib/go/pkg {} \;
+
+override_dh_install-indep:
+ dh_install --fail-missing
override_dh_strip:
# strip disabled as golang upstream doesn't support it and it makes go
# crash. See http://bugs.debian.org/717172
-override_dh_builddeb:
- dh_builddeb -- -Zxz
-
override_dh_shlibdeps:
dh_shlibdeps -Xtestdata -Xtest
-debian/build.stamp:
+override_dh_auto_build-arch:
[ -f VERSION ] || echo "debian snapshot +$$(dpkg-parsechangelog -SVersion)" > VERSION
- rm -f debian/build.stamp
- mkdir -p $(GOBIN)
- export GOROOT_BOOTSTRAP=$$(env -i go env GOROOT) && cd src && bash ./make.bash --no-banner
- >debian/build.stamp
-
-opt_no_act =
-RUN_TEST := true
-
-ifneq (,$(filter noopt,$(DEB_BUILD_OPTIONS)))
- $(warning no support for disabling optimization)
-endif
+ export GOROOT_BOOTSTRAP=$$(env -i go env GOROOT) \
+ && cd src \
+ && $(CURDIR)/debian/helpers/goenv.sh \
+ bash ./make.bash --no-banner
+opt_no_act :=
ifneq (,$(findstring n,$(MAKEFLAGS)))
- opt_no_act = --no-act
-endif
-
-ifneq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
- RUN_TEST := false
+opt_no_act := --no-act
endif
-
-GOROOT := $(CURDIR)
-GOROOT_FINAL := $(libexecdir)
-GOBIN := $(CURDIR)$(bindir)
-GOARM :=
-
-# Always use the 387 floating point unit instead of sse2. This is important to
-# ensure that the binaries we build (both when compiling golang on the buildds
-# and when users cross-compile for 386) can actually run on older CPUs (where
-# old means e.g. an AMD Athlon XP 2400+). See http://bugs.debian.org/753160 and
-# https://code.google.com/p/go/issues/detail?id=8152
-GO386 := 387
-
-DEB_HOST_ARCH := $(shell dpkg-architecture -qDEB_HOST_ARCH 2>/dev/null)
-DEB_HOST_ARCH_OS := $(shell dpkg-architecture -qDEB_HOST_ARCH_OS 2>/dev/null)
-DEB_HOST_ARCH_CPU := $(shell dpkg-architecture -qDEB_HOST_ARCH_CPU 2>/dev/null)
-DEB_BUILD_ARCH_OS := $(shell dpkg-architecture -qDEB_BUILD_ARCH_OS 2>/dev/null)
-DEB_BUILD_ARCH_CPU := $(shell dpkg-architecture -qDEB_BUILD_ARCH_CPU 2>/dev/null)
-
-ifeq ($(DEB_BUILD_ARCH_OS), kfreebsd)
- RUN_TEST := false
- GOHOSTOS := freebsd
-else ifeq ($(DEB_BUILD_ARCH_OS), linux)
- GOHOSTOS := linux
-else
- $(error unrecongized build host kernel $(DEB_BUILD_ARCH_OS)!)
-endif
-
-ifeq ($(DEB_HOST_ARCH_OS), kfreebsd)
- RUN_TEST := false
- GOOS := freebsd
-else ifeq ($(DEB_HOST_ARCH_OS), linux)
- GOOS := linux
-else
- $(error unrecognized kernel $(DEB_HOST_ARCH_OS)!)
-endif
-
-ifeq ($(DEB_BUILD_ARCH_CPU), i386)
- GOHOSTARCH := 386
-else ifeq ($(DEB_BUILD_ARCH_CPU), amd64)
- GOHOSTARCH := amd64
-else ifeq ($(DEB_BUILD_ARCH_CPU), arm)
- GOHOSTARCH := arm
-else ifeq ($(DEB_BUILD_ARCH_CPU), arm64)
- GOHOSTARCH := arm64
-else ifeq ($(DEB_BUILD_ARCH_CPU), ppc64)
- GOHOSTARCH := ppc64
-else ifeq ($(DEB_BUILD_ARCH_CPU), ppc64el)
- GOHOSTARCH := ppc64le
-else
- $(error unrecognized build host instruction set $(DEB_BUILD_ARCH_CPU)!)
-endif
-
-ifeq ($(DEB_HOST_ARCH_CPU), i386)
- GOARCH := 386
-else ifeq ($(DEB_HOST_ARCH_CPU), amd64)
- GOARCH := amd64
-else ifeq ($(DEB_HOST_ARCH_CPU), arm)
- RUN_TEST := false
- GOARCH := arm
-# set GOARM to lowest-common-denominator for each arch
-# see notes about GO386 above for details
-ifeq ($(DEB_HOST_ARCH), armel)
- GOARM := 5
-else ifeq ($(DEB_HOST_ARCH), armhf)
- GOARM := 6
-else
- $(error unrecognized arm architecture $(DEB_HOST_ARCH) ($(shell uname -m))!)
-endif
-else ifeq ($(DEB_HOST_ARCH_CPU), arm64)
- GOARCH := arm64
-else ifeq ($(DEB_HOST_ARCH_CPU), ppc64)
- GOARCH := ppc64
-else ifeq ($(DEB_HOST_ARCH_CPU), ppc64el)
- GOARCH := ppc64le
-else
- $(error unrecognized instruction set $(DEB_HOST_ARCH_CPU)!)
-endif
-
-export GOROOT GOROOT_FINAL GOOS GOARCH GOARM GOBIN GOHOSTARCH GOHOSTOS GO386
-
-.PHONY: build clean install binary-arch binary-indep binary
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-golang/golang.git
More information about the pkg-golang-commits
mailing list