Debian Codegraph @

debian/rules

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