| 1 |
#!/usr/bin/make -f |
| 2 |
|
| 3 |
# We need DEB_HOST_ARCH, so include the needed makefile snippet |
| 4 |
include /usr/share/dpkg/architecture.mk |
| 5 |
# for DEB_VERSION_UPSTREAM |
| 6 |
include /usr/share/dpkg/pkg-info.mk |
| 7 |
|
| 8 |
# Ubuntu mangles png files by default, which can break the testdata. |
| 9 |
export NO_PNG_PKG_MANGLE := 1 |
| 10 |
|
| 11 |
export GOVER := $(shell echo $(DEB_VERSION_UPSTREAM) | grep -oP '^([0-9]+\.[0-9]+)') |
| 12 |
|
| 13 |
export GOROOT := $(CURDIR) |
| 14 |
export GOROOT_FINAL := /usr/lib/go-$(GOVER) |
| 15 |
export GOROOT_BOOTSTRAP := $(shell ls -d -1 /usr/lib/go-1.* | sort -n | tail -n1) |
| 16 |
|
| 17 |
export GOPATH := $(CURDIR)/gopath/ |
| 18 |
# Go 1.12 needs a build cache, otherwise the build fails. |
| 19 |
export GOCACHE := $(GOPATH)/gocache |
| 20 |
|
| 21 |
# source files generated during building. |
| 22 |
# especially zbootstrap.go has different defaultGOARM values on armhf and armel, |
| 23 |
# since the value is set from debian/helpers/goenv.sh |
| 24 |
# |
| 25 |
# see also: src/cmd/distpack/pack.go |
| 26 |
GENERATED_FILES := \ |
| 27 |
src/cmd/go/internal/cfg/zdefaultcc.go \ |
| 28 |
src/internal/runtime/sys/zversion.go \ |
| 29 |
src/time/tzdata/zzipdata.go \ |
| 30 |
src/cmd/cgo/zdefaultcc.go \ |
| 31 |
src/cmd/internal/objabi/zbootstrap.go \ |
| 32 |
src/internal/buildcfg/zbootstrap.go |
| 33 |
|
| 34 |
%: |
| 35 |
+dh $@ $(opt_no_act) |
| 36 |
|
| 37 |
gencontrol: |
| 38 |
for file in control gbp.conf watch; do \ |
| 39 |
{ \ |
| 40 |
echo '#'; \ |
| 41 |
echo '# WARNING: "debian/'$$file'" is generated via "debian/rules gencontrol" (sourced from "debian/'$$file'.in")'; \ |
| 42 |
echo '#'; \ |
| 43 |
echo; \ |
| 44 |
sed -e 's/X.Y/$(GOVER)/g' debian/$$file.in; \ |
| 45 |
} > debian/$$file; \ |
| 46 |
done |
| 47 |
|
| 48 |
# The signing key for the source tarballs is rotated yearly. |
| 49 |
update_upstream_signing_key: |
| 50 |
wget -O debian/upstream/signing-key.asc https://dl.google.com/dl/linux/linux_signing_key.pub |
| 51 |
|
| 52 |
override_dh_auto_clean: |
| 53 |
# remove autogenerated files |
| 54 |
rm -f -v $(GENERATED_FILES) |
| 55 |
# remove built objects |
| 56 |
rm -rf bin pkg |
| 57 |
# remove gopath |
| 58 |
rm -rf $(GOPATH) |
| 59 |
# remove generated files |
| 60 |
@set -e; cd debian; for x in golang-X.Y-*; do \ |
| 61 |
rm -f -v golang-$(GOVER)-$${x##golang-X.Y-}; \ |
| 62 |
done |
| 63 |
|
| 64 |
execute_after_dh_prep: |
| 65 |
dh_prep |
| 66 |
@set -e; cd debian; for x in golang-X.Y-*; do \ |
| 67 |
sed -e 's/X.Y/$(GOVER)/g' $$x > golang-$(GOVER)-$${x##golang-X.Y-}; \ |
| 68 |
done |
| 69 |
|
| 70 |
override_dh_compress-indep: |
| 71 |
dh_compress -Xusr/share/doc/golang-$(GOVER)-doc/html |
| 72 |
|
| 73 |
execute_after_dh_install-arch: |
| 74 |
cp --parent -v $(GENERATED_FILES) debian/golang-$(GOVER)-go/usr/share/go-$(GOVER)/ |
| 75 |
|
| 76 |
execute_after_dh_install-indep: |
| 77 |
# Remove generated source files, they are installed in golang-$(GOVER)-go. |
| 78 |
cd debian/golang-$(GOVER)-src/usr/share/go-$(GOVER)/ && rm -v -f $(GENERATED_FILES) |
| 79 |
# Remove Plan9 rc(1) scripts |
| 80 |
find debian/golang-$(GOVER)-src/usr/share/go-$(GOVER)/src -type f -name '*.rc' -delete |
| 81 |
# Make scripts executable which have been missed by upstream |
| 82 |
find debian/golang-$(GOVER)-src/usr/share/go-$(GOVER)/src/ \ |
| 83 |
\( -name '*.sh' -o -name '*.bash' \) \( -not -executable \) -exec chmod a+x {} \; |
| 84 |
# Change timestamp of "test" directory to one of the files in it, |
| 85 |
# because the differing timestamp is the last bit which prevents |
| 86 |
# the golang package from being reproducible. |
| 87 |
touch --reference=$(CURDIR)/debian/golang-$(GOVER)-src/usr/share/go-$(GOVER)/test/README.md \ |
| 88 |
$(CURDIR)/debian/golang-$(GOVER)-src/usr/share/go-$(GOVER)/test |
| 89 |
|
| 90 |
override_dh_strip: |
| 91 |
dh_strip -Xtestdata |
| 92 |
|
| 93 |
# Do not run dh_dwz, as there is no debug information currently. |
| 94 |
override_dh_dwz: |
| 95 |
|
| 96 |
# Some test files cannot be parsed correctly by dh_strip_nondeterminism, |
| 97 |
# because they are corrupted on purpose to test the go library. |
| 98 |
override_dh_strip_nondeterminism: |
| 99 |
dh_strip_nondeterminism \ |
| 100 |
--exclude=usr/share/go-$(GOVER)/src/image/png/testdata/invalid-trunc.png \ |
| 101 |
--exclude=usr/share/go-$(GOVER)/src/archive/zip/testdata/test-baddirsz.zip \ |
| 102 |
--exclude=usr/share/go-$(GOVER)/src/archive/zip/testdata/comment-truncated.zip |
| 103 |
|
| 104 |
override_dh_shlibdeps: |
| 105 |
dh_shlibdeps -Xtestdata -Xtest |
| 106 |
|
| 107 |
override_dh_makeshlibs: |
| 108 |
dh_makeshlibs -Xtestdata -Xtest |
| 109 |
|
| 110 |
override_dh_auto_build-arch: |
| 111 |
[ -f VERSION ] || echo "debian snapshot $(DEB_VERSION)" > VERSION |
| 112 |
|
| 113 |
cd $(CURDIR)/src \ |
| 114 |
&& $(CURDIR)/debian/helpers/goenv.sh bash ./make.bash --no-banner |
| 115 |
|
| 116 |
# rm bootstrap dir |
| 117 |
rm -rf $(CURDIR)/bootstrap |
| 118 |
|
| 119 |
ifneq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE)) |
| 120 |
# cross-building! |
| 121 |
# move "target" (host) tools to appropriate places for install |
| 122 |
# and remove "native" (build) tools/packages |
| 123 |
set -eux; \ |
| 124 |
eval "$$(debian/helpers/goenv.sh bin/go tool dist env)"; \ |
| 125 |
mv bin/$${GOOS}_$${GOARCH}/go* bin; \ |
| 126 |
rmdir bin/$${GOOS}_$${GOARCH}; \ |
| 127 |
rm -rf pkg/$${GOHOSTOS}_$${GOHOSTARCH} pkg/tool/$${GOHOSTOS}_$${GOHOSTARCH}/ |
| 128 |
endif |
| 129 |
|
| 130 |
override_dh_auto_test-arch: |
| 131 |
set -ex; \ |
| 132 |
cd src; \ |
| 133 |
export PATH="$(GOROOT)/bin:$$PATH"; \ |
| 134 |
export GO_TEST_TIMEOUT_SCALE=10; \ |
| 135 |
eval "$$(go tool dist env)"; \ |
| 136 |
bash run.bash -k -no-rebuild; |
| 137 |
# -k keep going even when error occurred |
| 138 |
# -no-rebuild don't rebuild std and cmd packages |
| 139 |
|
| 140 |
# On linux/amd64 run.bash installs some race enabled standard library |
| 141 |
# packages. Delete them again to avoid accidentally including them in |
| 142 |
# the package. |
| 143 |
set -ex; \ |
| 144 |
export PATH="$(GOROOT)/bin:$$PATH"; \ |
| 145 |
eval "$$(go tool dist env)"; \ |
| 146 |
rm -rf "$(GOROOT)/pkg/$${GOOS}_$${GOARCH}_race/" |
| 147 |
|
| 148 |
opt_no_act := |
| 149 |
ifneq (,$(findstring n,$(firstword -$(MAKEFLAGS)))) |
| 150 |
opt_no_act := --no-act |
| 151 |
endif |