#!/usr/bin/make -f # This file is in the public domain. # You may freely use, modify, distribute, and relicense it. export GOVER := $(shell perl -w -mDpkg::Version -e 'Dpkg::Version->new(`dpkg-parsechangelog -SVersion`)->version() =~ /^([0-9]+\.[0-9]+)/ && print("$$1\n")') export GOROOT := $(CURDIR) export GOROOT_FINAL := /usr/lib/go-$(GOVER) # We need DEB_HOST_ARCH, so include the needed makefile snippet include /usr/share/dpkg/architecture.mk RUN_TESTS := true # armel: ??? # ppc64: ??? ifneq (,$(filter armel ppc64,$(DEB_HOST_ARCH))) RUN_TESTS := false endif ifneq (,$(findstring nocheck,$(DEB_BUILD_OPTIONS))) RUN_TESTS := false endif %: +dh $@ $(opt_no_act) gencontrol: for file in control gbp.conf source/lintian-overrides watch; do \ { \ echo '#'; \ echo '# WARNING: "debian/'$$file'" is generated via "debian/rules gencontrol" (sourced from "debian/'$$file'.in")'; \ echo '#'; \ echo; \ sed -e 's/X.Y/$(GOVER)/g' debian/$$file.in; \ } > debian/$$file; \ done override_dh_auto_clean: gencontrol # remove autogenerated files rm -f \ src/cmd/cgo/zdefaultcc.go \ src/cmd/go/zdefaultcc.go \ src/cmd/internal/obj/zbootstrap.go \ src/runtime/internal/sys/zversion.go # remove built objects rm -rf bin pkg @set -e; cd debian; for x in golang-X.Y-*; do \ rm -f -v golang-$(GOVER)-$${x##golang-X.Y-}; \ done override_dh_prep: dh_prep @set -e; cd debian; for x in golang-X.Y-*; do \ sed -e 's/X.Y/$(GOVER)/g' $$x > golang-$(GOVER)-$${x##golang-X.Y-}; \ done override_dh_auto_test-arch: ifeq (true, $(RUN_TESTS)) set -ex; \ cd src; \ export PATH="$(GOROOT)/bin:$$PATH"; \ eval "$$(go tool dist env)"; \ bash run.bash -k -no-rebuild; # -k keep going even when error occurred # -no-rebuild don't rebuild std and cmd packages # On linux/amd64 run.bash installs some race enabled standard library # packages. Delete them again to avoid accidentally including them in # the package. set -ex; \ export PATH="$(GOROOT)/bin:$$PATH"; \ eval "$$(go tool dist env)"; \ rm -rf "$(GOROOT)/pkg/$${GOOS}_$${GOARCH}_race/" else # skip the tests on platforms where they fail endif # Remove GOCACHE files rm -rf pkg/obj override_dh_compress-indep: dh_compress -Xusr/share/doc/golang-$(GOVER)-doc/html -Xusr/share/doc/golang-$(GOVER)-doc/favicon.ico override_dh_install-indep: dh_install --fail-missing override_dh_install-arch: dh_install --fail-missing # Remove Plan9 rc(1) scripts find debian/golang-$(GOVER)-src/usr/share/go-$(GOVER)/src -type f -name '*.rc' -delete # Remove empty /usr/share/go-$(GOVER)/src from golang-$(GOVER)-go, it is provided by golang-$(GOVER)-src find debian/golang-$(GOVER)-go/usr/share/go-$(GOVER)/src -type d -delete # Touch built and installed files and directories to have same timestamp touch debian/golang-$(GOVER)-go/usr/lib/go-$(GOVER)/pkg find debian/golang-$(GOVER)-go/usr/lib/go-$(GOVER)/pkg -exec touch -r $(CURDIR)/debian/golang-$(GOVER)-go/usr/lib/go-$(GOVER)/pkg {} \; # Make two scripts executable which have been missed by upstream chmod a+x debian/golang-$(GOVER)-src/usr/share/go-$(GOVER)/src/cmp.bash chmod a+x debian/golang-$(GOVER)-src/usr/share/go-$(GOVER)/src/runtime/mknacl.sh override_dh_strip: dh_strip -Xtestdata override_dh_strip_nondeterminism: dh_strip_nondeterminism -Xtestdata override_dh_shlibdeps: dh_shlibdeps -Xtestdata -Xtest override_dh_auto_build-arch: [ -f VERSION ] || echo "debian snapshot +$$(dpkg-parsechangelog -SVersion)" > VERSION 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