]> git.proxmox.com Git - rustc.git/blame - debian/rules
Update upstream source from tag 'upstream/1.46.0_beta.2+dfsg1'
[rustc.git] / debian / rules
CommitLineData
be771b38
LB
1#!/usr/bin/make -f
2# -*- makefile -*-
3
b59979d9 4include /usr/share/dpkg/pkg-info.mk
6472c211 5include /usr/share/dpkg/vendor.mk
d75d48d6 6include /usr/share/dpkg/architecture.mk
b5dfb68c
XL
7SED_VERSION_SHORT := sed -re 's/([^.]+)\.([^.]+)\..*/\1.\2/'
8RUST_VERSION := $(shell echo '$(DEB_VERSION_UPSTREAM)' | $(SED_VERSION_SHORT))
9RUST_LONG_VERSION := $(shell echo '$(DEB_VERSION_UPSTREAM)' | sed -re 's/([^+]+).*/\1/')
10LIBSTD_PKG := libstd-rust-$(RUST_VERSION)
11# Sed expression that matches the "rustc" we have in our Build-Depends field
12SED_RUSTC_BUILDDEP := sed -ne "/^Build-Depends:/,/^[^[:space:]\#]/{/^ *rustc:native .*,/p}" debian/control
2da5f2f9
XL
13# Version of /usr/bin/rustc
14LOCAL_RUST_VERSION := $(shell rustc --version --verbose | sed -ne 's/^release: //p')
b5dfb68c 15
7d40d3e1 16include /usr/share/dpkg/buildflags.mk
4888e768 17# TODO: more correct to use `[build] rustflags = []` list syntax in Cargo.toml
9197bf09 18RUSTFLAGS = $(addprefix -C link-args=,$(LDFLAGS))
6d9b8aba 19RUSTFLAGS += --cap-lints warn
7d40d3e1 20export CFLAGS CXXFLAGS CPPFLAGS LDFLAGS RUSTFLAGS
ca38e697 21export CARGO_HOME = $(CURDIR)/debian/cargo
b59979d9 22
525ff0f9
AL
23# Defines DEB_*_RUST_TYPE triples
24include debian/architecture.mk
693daed7 25export DEB_HOST_RUST_TYPE
525ff0f9 26
be771b38
LB
27# Uncomment this to turn on verbose mode.
28#export DH_VERBOSE=1
29
8354de7a 30DEB_DESTDIR := $(CURDIR)/debian/tmp
525ff0f9 31
525ff0f9 32# Use system LLVM (comment out to use vendored LLVM)
61821631
XL
33LLVM_VERSION = 10
34OLD_LLVM_VERSION = 9
2b7c35b5
XL
35# Make it easier to test against a custom LLVM
36ifneq (,$(LLVM_DESTDIR))
56548b60
XL
37LLVM_LIBRARY_PATH := $(LLVM_DESTDIR)/usr/lib/$(DEB_HOST_MULTIARCH):$(LLVM_DESTDIR)/usr/lib
38LD_LIBRARY_PATH := $(if $(LD_LIBRARY_PATH),$(LD_LIBRARY_PATH):$(LLVM_LIBRARY_PATH),$(LLVM_LIBRARY_PATH))
2b7c35b5
XL
39export LD_LIBRARY_PATH
40endif
2b7c35b5 41
5fe59560 42RUSTBUILD = RUST_BACKTRACE=1 python3 src/bootstrap/bootstrap.py
33416cd4 43RUSTBUILD_FLAGS = --config debian/config.toml -vvv --on-fail env
8978aae4 44RUSTBUILD_TEST = $(RUSTBUILD) test --no-fail-fast
0d3674eb
XL
45# To run a specific test, run something like:
46# $ debian/rules override_dh_auto_test-arch \
47# RUSTBUILD_TEST_FLAGS="src/test/run-make --test-args extern-fn-struct"
48# See src/bootstrap/README.md for more options.
49RUSTBUILD_TEST_FLAGS =
1c8ac2b0 50
25f1c2fe
XL
51update-version:
52 oldver=$(shell $(SED_RUSTC_BUILDDEP) | sed -ne 's/.*(<= \(.*\)).*/\1/gp' | $(SED_VERSION_SHORT)); \
0bf22a45
XL
53 newver=$(RUST_VERSION); \
54 debian/update-version.sh $$oldver $$newver $(RUST_LONG_VERSION) $(CARGO_NEW)
25f1c2fe 55
427dce5b
XL
56# Below we detect how we're supposed to bootstrap the stage0 compiler. See
57# README.Debian for more details of the cases described below.
58#
427dce5b 59PRECONFIGURE_CHECK = :
75be2bb3 60HAVE_BINARY_TARBALL := $(shell ls -1 stage0/*/*$(DEB_HOST_RUST_TYPE)* 2>/dev/null | wc -l)
5861ebac 61DOWNLOAD_BOOTSTRAP := false
571f0d20
MK
62# allow not using the binary tarball although it exists
63#ifneq (,$(filter $(DEB_HOST_ARCH), amd64 arm64 armhf i386 powerpc ppc64el s390x))
64# HAVE_BINARY_TARBALL := 0
65#endif
66ifeq (0,$(HAVE_BINARY_TARBALL))
16dfb283
XL
67 # Case A (Building from source): the extracted source tree does not include
68 # a bootstrapping tarball for the current architecture e.g. because the
69 # distro already has a rustc for this arch, or the uploader expects that
70 # this requirement be fulfilled in some other way.
427dce5b
XL
71 #
72 # Case A-1: the builder did not select the "pkg.rustc.dlstage0" build profile.
73 # In this case, we use the distro's rustc - either the previous or current version.
74 ifeq (,$(findstring pkg.rustc.dlstage0,$(DEB_BUILD_PROFILES)))
56548b60
XL
75 # Make it easier to test against a custom rustc
76 ifneq (,$(RUST_DESTDIR))
77 RUST_LIBRARY_PATH := $(RUST_DESTDIR)/usr/lib/$(DEB_HOST_MULTIARCH):$(RUST_DESTDIR)/usr/lib
78 LD_LIBRARY_PATH := $(if $(LD_LIBRARY_PATH),$(LD_LIBRARY_PATH):$(RUST_LIBRARY_PATH),$(RUST_LIBRARY_PATH))
79 export LD_LIBRARY_PATH
80 endif
427dce5b
XL
81 #
82 # Case A-2: the builder selected the "dlstage0" build profile.
75be2bb3 83 # In this case, the rust build scripts will download a stage0 into stage0/ and use that.
b9a40c91 84 # We don't need to do anything specific in this build file, so this case is empty.
5861ebac
XL
85 else
86 DOWNLOAD_BOOTSTRAP := true
87 endif
427dce5b 88else
16dfb283
XL
89 # Case B (Bootstrapping a new distro): the extracted source tree does
90 # include a bootstrapping tarball for the current architecture; see the
75be2bb3 91 # `source_orig-stage0` target below on how to build this.
427dce5b
XL
92 #
93 # In this case, we'll bootstrap from the stage0 given in that tarball.
94 # To ensure the uploader of the .dsc didn't make a mistake, we first check
16dfb283 95 # that rustc isn't a Build-Depends for the current architecture.
25f1c2fe
XL
96 ifneq (,$(shell $(SED_RUSTC_BUILDDEP)))
97 ifeq (,$(shell $(SED_RUSTC_BUILDDEP) | grep '!$(DEB_HOST_ARCH)'))
75be2bb3 98 PRECONFIGURE_CHECK = $(error found matches for stage0/*/*$(DEB_HOST_RUST_TYPE)*, \
16dfb283
XL
99 but rustc might be a Build-Depends for $(DEB_HOST_ARCH))
100 endif
427dce5b 101 endif
1c8ac2b0
SL
102endif
103
5861ebac 104BUILD_DOCS := true
120b4d47 105ifneq (,$(findstring nodoc,$(DEB_BUILD_PROFILES)))
5861ebac 106 BUILD_DOCS := false
1c8ac2b0 107endif
005427f4
XL
108ifneq (,$(findstring nodoc,$(DEB_BUILD_OPTIONS)))
109 BUILD_DOCS := false
110endif
1c8ac2b0 111
8d2dc69d
XL
112BUILD_WASM := true
113ifneq (,$(findstring nowasm,$(DEB_BUILD_PROFILES)))
114 BUILD_WASM := false
115endif
116
5861ebac 117MAKE_OPTIMISATIONS := true
1c8ac2b0 118ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
5861ebac 119 MAKE_OPTIMISATIONS := false
1c8ac2b0
SL
120endif
121
35329365 122# Build products or non-source files in src/, that shouldn't go in rust-src
9a2ab7ea 123SRC_CLEAN = src/bootstrap/bootstrap.pyc \
35329365 124 src/etc/__pycache__/
1c8ac2b0 125
96a6ef5f
XL
126# Try to work around #933045
127ifneq (,$(filter $(DEB_BUILD_ARCH), mips mipsel))
128 SYSTEM_WORKAROUNDS += export MALLOC_ARENA_MAX=1;
129endif
170f9149 130
be771b38 131%:
170f9149 132 $(SYSTEM_WORKAROUNDS) dh $@ --parallel
be771b38 133
04c12273
XL
134.PHONY: build
135build:
170f9149 136 $(SYSTEM_WORKAROUNDS) dh $@ --parallel
04c12273 137
de1de54b 138override_dh_clean:
cf0b146d
XL
139 # Upstream contains a lot of these
140 dh_clean -XCargo.toml.orig
de1de54b 141
b49766ad
XL
142debian/config.toml: debian/config.toml.in debian/rules
143 u="$(DEB_VERSION_UPSTREAM)"; \
144 if [ "$$u" != "$${u%~beta.*+dfsg*}" ]; then channel="beta"; \
145 else channel="stable"; fi; echo $$channel; \
ec028c2e
XL
146 m4 -DRELEASE_CHANNEL="$$channel" \
147 -DDEB_BUILD_RUST_TYPE="$(DEB_BUILD_RUST_TYPE)" \
01dc6ef4
XL
148 -DDEB_HOST_RUST_TYPE="$(DEB_HOST_RUST_TYPE)" \
149 -DDEB_TARGET_RUST_TYPE="$(DEB_TARGET_RUST_TYPE)" \
ec028c2e
XL
150 -DDEB_BUILD_GNU_TYPE="$(DEB_BUILD_GNU_TYPE)" \
151 -DDEB_HOST_GNU_TYPE="$(DEB_HOST_GNU_TYPE)" \
152 -DDEB_TARGET_GNU_TYPE="$(DEB_TARGET_GNU_TYPE)" \
5861ebac 153 -DMAKE_OPTIMISATIONS="$(MAKE_OPTIMISATIONS)" \
2b7c35b5 154 -DLLVM_DESTDIR="$(LLVM_DESTDIR)" \
666f0397 155 -DLLVM_VERSION="$(LLVM_VERSION)" \
5861ebac 156 -DRUST_DESTDIR="$(RUST_DESTDIR)" \
01dc6ef4 157 "$<" > "$@"
7ee10b55
XL
158 if $(DOWNLOAD_BOOTSTRAP) || [ $(HAVE_BINARY_TARBALL) != 0 ]; \
159 then sed -i -e '/^rustc = /d' -e '/^cargo = /d' "$@"; fi
e8cad677 160# Work around low-memory (32-bit) architectures: https://github.com/rust-lang/rust/issues/45854
8978aae4 161ifneq (,$(filter $(DEB_BUILD_ARCH), armhf armel mips mipsel powerpc powerpcspe))
bae0839e 162 sed -i -e 's/^debuginfo-level = .*/debuginfo-level = 0/g' "$@"
8978aae4 163endif
01dc6ef4 164
b5dfb68c
XL
165debian/rust-src.%: debian/rust-src.%.in
166 m4 -DRUST_LONG_VERSION="$(RUST_LONG_VERSION)" \
167 "$<" > "$@"
168
3bdf427a 169debian/dh_auto_configure.stamp: debian/config.toml
5617e1bd 170 # fail the build if we have any instances of OLD_LLVM_VERSION in debian, except for debian/changelog
6b21bfff 171 ! grep --color=always -i 'll\(..\|d\)-\?$(subst .,\.,$(OLD_LLVM_VERSION))' --exclude=changelog --exclude=copyright --exclude='*.patch' --exclude-dir='.debhelper' -R debian
c54b4d09
XL
172 # fail the build if we accidentally vendored openssl, indicates we pulled in unnecessary dependencies
173 test ! -e vendor/openssl
e133b084 174 # fail the build if our version contains ~exp and we are not releasing to experimental
b49766ad 175 v="$(DEB_VERSION)"; test "$$v" = "$${v%~exp*}" -o "$(DEB_DISTRIBUTION)" = "experimental" -o "$(DEB_DISTRIBUTION)" = "UNRELEASED"
427dce5b 176 $(PRECONFIGURE_CHECK)
75be2bb3 177 if [ -d stage0 ]; then mkdir -p build && ln -sfT ../stage0 build/cache; fi
3281855a
XL
178 # work around #842634
179 if test $$(grep "127.0.0.1\s*localhost" /etc/hosts | wc -l) -gt 1; then \
ed6f7eed 180 debian/ensure-patch -N debian/patches/d-host-duplicates.patch; fi
4a099bab
XL
181 # allow beta builds
182 sed -i -e 's/dev: 1/#dev: 1/g' src/stage0.txt
98955da7 183 # We patched some crates so have to rm the checksums
94bd9ad3 184 find vendor -name .cargo-checksum.json -execdir "$(CURDIR)/debian/prune-checksums" "{}" +
6b0d97fc 185 # Link against system liblzma, see https://github.com/alexcrichton/xz2-rs/issues/16
f56f18fe 186 echo 'fn main() { println!("cargo:rustc-link-lib=lzma"); }' > vendor/lzma-sys/build.rs
5861ebac
XL
187 # We don't run ./configure because we use debian/config.toml directly
188 ln -sf debian/config.toml config.toml
3bdf427a
XL
189 touch "$@"
190
191override_dh_auto_configure-arch: debian/dh_auto_configure.stamp
192override_dh_auto_configure-indep: debian/dh_auto_configure.stamp
193ifeq (true,$(BUILD_DOCS))
194# Change config.toml now and not later, since that might trigger a rebuild
195 sed -i -e 's/^docs = false/docs = true/' debian/config.toml
196endif
1c8ac2b0 197
11c430be 198override_dh_auto_clean:
ca38e697 199 $(RM) -rf build tmp .cargo debian/cargo_home config.stamp config.mk Makefile
3bdf427a 200 $(RM) -rf $(TEST_LOG) debian/config.toml debian/rust-src.install debian/rust-src.links debian/*.stamp
5b2524c4 201 $(RM) -rf $(SRC_CLEAN) config.toml
11c430be 202
809d6012 203debian/dh_auto_build.stamp:
04c12273 204 $(RUSTBUILD) build $(RUSTBUILD_FLAGS)
ea192313 205
809d6012
XL
206override_dh_auto_build-arch: debian/dh_auto_build.stamp
207override_dh_auto_build-indep: debian/dh_auto_build.stamp
8d2dc69d 208ifeq (true,$(BUILD_WASM))
8978aae4 209 $(RUSTBUILD) build $(RUSTBUILD_FLAGS) \
910f03de
XL
210 --host $(DEB_BUILD_RUST_TYPE) \
211 --target wasm32-unknown-unknown,wasm32-wasi \
212 src/libstd
8d2dc69d 213endif
5861ebac 214ifeq (true,$(BUILD_DOCS))
04c12273
XL
215 $(RUSTBUILD) doc $(RUSTBUILD_FLAGS)
216endif
217
3a774f0f 218TEST_LOG = debian/rustc-tests.log
356c70ca
XL
219# This is advertised as "5 tests failed" in README.Debian because our counting
220# method is imprecise and in practise we count some failures twice.
0b9f599a 221FAILURES_ALLOWED = 8
be0ee34e 222ifneq (,$(filter $(DEB_BUILD_ARCH), ppc64 arm64 mips64el i386))
6404b712 223 FAILURES_ALLOWED = 12
fa6232de 224endif
bed23ba6 225ifneq (,$(filter $(DEB_BUILD_ARCH), mips mipsel s390x))
15f51d41 226 FAILURES_ALLOWED = 24
ab330327 227endif
bed23ba6 228ifneq (,$(filter $(DEB_BUILD_ARCH), powerpc powerpcspe riscv64 sparc64 x32))
617a87c6 229 FAILURES_ALLOWED = 180
734d072d 230endif
01620f26 231FAILED_TESTS = grep "FAILED\|^command did not execute successfully" $(TEST_LOG) | grep -v '^test result: FAILED' | grep -v 'FAILED (allowed)'
7958f3db 232override_dh_auto_test-arch:
91d3be64 233 # ensure that rustc_llvm is actually dynamically linked to libLLVM
347f6206
XL
234 set -e; find build/*/stage2/lib/rustlib/* -name '*rustc_llvm*.so' | \
235 while read x; do \
236 stat -c '%s %n' "$$x"; \
237 objdump -p "$$x" | grep -q "NEEDED.*LLVM"; \
238 test "$$(stat -c %s "$$x")" -lt 6000000; \
239 done
68e7eb97 240ifeq (, $(filter nocheck,$(DEB_BUILD_PROFILES)))
7958f3db 241ifeq (, $(filter nocheck,$(DEB_BUILD_OPTIONS)))
8978aae4 242 { $(RUSTBUILD_TEST) $(RUSTBUILD_FLAGS) $(RUSTBUILD_TEST_FLAGS); echo $$?; } | tee -a $(TEST_LOG)
91d3be64 243 # test that the log has at least 1 pass, to prevent e.g. #57709
bbceb41b 244 grep -l "^test .* \.\.\. ok$$" $(TEST_LOG)
2c22371f
XL
245 echo "==== Debian rustc test report ===="; \
246 echo "Specific test failures:"; \
3a774f0f 247 $(FAILED_TESTS); \
873d1fa5 248 num_failures=$$($(FAILED_TESTS) | wc -l); \
2c22371f
XL
249 exit_code=$$(tail -n1 $(TEST_LOG)); \
250 echo "Summary: exit code $$exit_code, counted $$num_failures tests failed."; \
251 echo -n "$(FAILURES_ALLOWED) maximum allowed. "; \
252 if test "$$num_failures" -eq 0 -a "$$exit_code" -ne 0; then \
253 echo "Aborting just in case, because we missed counting some test failures."; \
6404b712 254 echo "This could happen if we failed to build the tests, or if the testsuite runner is buggy."; \
2c22371f
XL
255 false; \
256 elif test "$$num_failures" -le $(FAILURES_ALLOWED); then \
3a774f0f
XL
257 echo "Continuing..."; \
258 else \
259 echo "Aborting the build."; \
260 echo "Check the logs further above for details."; \
261 false; \
262 fi
0d3674eb
XL
263# don't continue if RUSTBUILD_TEST_FLAGS is non-empty
264 test -z "$(RUSTBUILD_TEST_FLAGS)"
e408bc2c 265endif
68e7eb97 266endif
becfe001 267
04c12273 268override_dh_auto_test-indep:
68e7eb97 269ifeq (, $(filter nocheck,$(DEB_BUILD_PROFILES)))
7958f3db 270ifeq (, $(filter nocheck,$(DEB_BUILD_OPTIONS)))
8d2dc69d 271ifeq (true,$(BUILD_WASM))
8978aae4 272 # Ignore failures in these tests, but run them so we see what it's like
005427f4 273 -PATH=$(CURDIR)/debian/bin:$(PATH) $(RUSTBUILD_TEST) $(RUSTBUILD_FLAGS) $(RUSTBUILD_TEST_FLAGS) \
910f03de
XL
274 --host $(DEB_BUILD_RUST_TYPE) \
275 --target wasm32-unknown-unknown,wasm32-wasi \
276 src/libstd
8d2dc69d 277endif
aa14b88a 278ifeq (true,$(BUILD_DOCS))
8978aae4
XL
279 # Run all rules that test the docs, i.e. that depend on default:doc
280 $(RUSTBUILD_TEST) $(RUSTBUILD_FLAGS) src/tools/linkchecker
7958f3db 281endif
aa14b88a 282 test -z "$(RUSTBUILD_TEST_FLAGS)"
7958f3db 283endif
68e7eb97 284endif
04c12273 285
bf52bd52
XL
286run_rustbuild:
287 DESTDIR=$(DEB_DESTDIR) $(RUSTBUILD) $(X_CMD) $(RUSTBUILD_FLAGS) $(X_FLAGS)
288
3bdf427a 289debian/dh_auto_install.stamp:
6a9e99e9 290 DESTDIR=$(DEB_DESTDIR) $(RUSTBUILD) install $(RUSTBUILD_FLAGS)
525ff0f9
AL
291
292 mkdir -p $(DEB_DESTDIR)/usr/lib/$(DEB_HOST_MULTIARCH)/
293 mv $(DEB_DESTDIR)/usr/lib/lib*.so $(DEB_DESTDIR)/usr/lib/$(DEB_HOST_MULTIARCH)/
6fce0a99 294
1261b4b3 295 # Replace duplicated compile-time/run-time dylibs with symlinks
525ff0f9
AL
296 @set -e; \
297 for f in $(DEB_DESTDIR)/usr/lib/rustlib/$(DEB_HOST_RUST_TYPE)/lib/lib*.so; do \
298 name=$${f##*/}; \
299 if [ -f "$(DEB_DESTDIR)/usr/lib/$(DEB_HOST_MULTIARCH)/$$name" ]; then \
300 echo "ln -sf ../../../$(DEB_HOST_MULTIARCH)/$$name $$f"; \
301 ln -sf ../../../$(DEB_HOST_MULTIARCH)/$$name $$f; \
302 fi; \
1261b4b3
AL
303 done
304
3bdf427a
XL
305 touch "$@"
306
307override_dh_auto_install-arch: debian/dh_auto_install.stamp
308override_dh_auto_install-indep: debian/dh_auto_install.stamp
8d2dc69d 309ifeq (true,$(BUILD_WASM))
453f6ddc 310 DESTDIR=$(DEB_DESTDIR) $(RUSTBUILD) install $(RUSTBUILD_FLAGS) \
910f03de
XL
311 --host $(DEB_BUILD_RUST_TYPE) \
312 --target wasm32-unknown-unknown,wasm32-wasi \
313 src/libstd
8d2dc69d 314endif
5861ebac 315ifeq (true,$(BUILD_DOCS))
6fce0a99
SL
316 # Brute force to remove privacy-breach-logo lintian warning.
317 # We could have updated the upstream sources but it would complexify
318 # the rebase
b556761e 319 @set -e; \
450ac6ae 320 find $(DEB_DESTDIR)/usr/share/doc/*/html -iname '*.html' | \
1add0b94 321 while read file; do \
b556761e 322 topdir=$$(echo "$$file" | sed 's,^$(DEB_DESTDIR)/usr/share/doc/rust/html/,,; s,/[^/]*$$,/,; s,^[^/]*$$,,; s,[^/]\+/,../,g'); \
450ac6ae
XL
323 sed -i \
324 -e "s,https://\(doc\|www\).rust-lang.org/\(favicon.ico\|logos/rust-logo-32x32-blk.png\),$${topdir}rust-logo-32x32-blk.png," \
325 -e 's,<img src="https://img.shields.io/[^"]*" alt="\([^"]*\)" />,<span class="deb-privacy-replace--shields-io">\1</span>,g' "$$file"; \
1add0b94 326 done
b125a683
MO
327 find $(DEB_DESTDIR) \( -iname '*.html' -empty -o -name .lock -o -name '*.inc' \) -delete;
328endif
329
cf9ecdde 330override_dh_install-arch:
6fce0a99 331 dh_install
525ff0f9 332 dh_install -p$(LIBSTD_PKG) usr/lib/$(DEB_HOST_MULTIARCH)/
cd17b70a 333 dh_install -plibstd-rust-dev usr/lib/rustlib/$(DEB_HOST_RUST_TYPE)/lib/
525ff0f9 334
b5dfb68c 335override_dh_install-indep: debian/rust-src.install debian/rust-src.links
a0022868 336 dh_install
8d2dc69d 337ifeq (true,$(BUILD_WASM))
809d6012 338 dh_install -plibstd-rust-dev-wasm32-cross usr/lib/rustlib/wasm32-*/lib/
8d2dc69d 339endif
525ff0f9
AL
340 chmod -x \
341 debian/rust-gdb/usr/share/rust-gdb/*.py \
342 debian/rust-lldb/usr/share/rust-lldb/*.py
b5dfb68c 343 $(RM) -rf $(SRC_CLEAN:%=debian/rust-src/usr/src/rustc-$(RUST_LONG_VERSION)/%)
f40dfcc0 344 # Get rid of lintian warnings
b5dfb68c 345 find debian/rust-src/usr/src/rustc-$(RUST_LONG_VERSION) \
f40dfcc0
XL
346 \( -name .gitignore \
347 -o -name 'LICENSE*' \
348 -o -name 'LICENCE' \
349 -o -name 'license' \
350 -o -name 'COPYING*' \
351 \) -delete
8d3e3cd2 352 # Remove files that autoload remote resources, caught by lintian
f56f18fe
XL
353 $(RM) -rf debian/rust-src/usr/src/rustc-*/vendor/cssparser/docs/*.html
354 $(RM) -rf debian/rust-src/usr/src/rustc-*/vendor/kuchiki/docs/*.html
355 $(RM) -rf debian/rust-src/usr/src/rustc-*/vendor/url/docs/*.html
356 $(RM) -rf debian/rust-src/usr/src/rustc-*/vendor/xz2/.gitmodules
1c8ac2b0 357
bc0aa84e
AL
358override_dh_installchangelogs:
359 dh_installchangelogs RELEASES.md
360
361override_dh_installdocs:
362 dh_installdocs -X.tex -X.aux -X.log -X.out -X.toc
363
5c515547
XL
364override_dh_missing:
365 dh_missing --list-missing
366
eef1f4e3
AL
367override_dh_compress:
368 dh_compress -X.woff
369
b676ddf6
XL
370# The below override is disabled on advice from #debian-devel, because:
371# - only shared libs get the "split dbgsym package" treatment by dh_strip;
372# static libs simply get their debuginfo discarded
373# - strip(1) sometimes breaks wasm libs
374#
375#override_dh_strip:
376# # Work around #35733, #468333
377# find debian/libstd-rust-dev*/ -name '*.rlib' -execdir mv '{}' '{}.a' \;
378# # This is expected to print out lots of "File format unrecognized" warnings about
379# # rust.metadata.bin and *.deflate but the .o files inside the rlibs should be stripped
380# # Some files are still omitted because of #875780 however.
381# dh_strip -v
382# find debian/libstd-rust-dev*/ -name '*.rlib.a' -execdir sh -c 'mv "$$1" "$${1%.a}"' - '{}' \;
d2456730 383
f6fae01b
XL
384override_dh_dwz:
385 # otherwise rustc gets an empty multifile which lintian errors on, causing
386 # FTP auto-reject. this is a work-around, the lintian bug is #955752
387 dh_dwz --no-dwz-multifile
388
525ff0f9
AL
389override_dh_makeshlibs:
390 dh_makeshlibs -V
391
392 # dh_makeshlibs doesn't support our "libfoo-version.so" naming
393 # structure, so we have to do this ourselves.
394 install -o 0 -g 0 -d debian/$(LIBSTD_PKG)/DEBIAN
33766656 395 LC_ALL=C ls debian/$(LIBSTD_PKG)/usr/lib/$(DEB_HOST_MULTIARCH)/lib*.so | \
525ff0f9
AL
396 sed -n 's,^.*/\(lib.*\)-\(.\+\)\.so$$,\1 \2,p' | \
397 while read name version; do \
398 echo "$$name $$version $(LIBSTD_PKG) (>= $(DEB_VERSION_UPSTREAM))"; \
399 done > debian/$(LIBSTD_PKG)/DEBIAN/shlibs
400 chmod 644 debian/$(LIBSTD_PKG)/DEBIAN/shlibs
401 chown 0:0 debian/$(LIBSTD_PKG)/DEBIAN/shlibs
402
403override_dh_shlibdeps:
404 dh_shlibdeps -- -x$(LIBSTD_PKG)
427dce5b
XL
405
406QUILT_SPECIAL_SNOWFLAKE_RETURN_CODE = x=$$?; if [ $$x = 2 ]; then exit 0; else exit $$x; fi
75be2bb3 407source_orig-stage0:
16dfb283
XL
408 QUILT_PATCHES=debian/patches quilt push -aq; $(QUILT_SPECIAL_SNOWFLAKE_RETURN_CODE)
409 $(MAKE) -f debian/rules clean
75be2bb3 410 debian/make_orig-stage0_tarball.sh
16dfb283
XL
411 QUILT_PATCHES=debian/patches quilt pop -aq; $(QUILT_SPECIAL_SNOWFLAKE_RETURN_CODE)
412 rm -rf .pc
15ab0b38 413
0a1981fb
XL
414get_beta_version = \
415 u="$(DEB_VERSION_UPSTREAM)"; \
416 if [ "$$u" != "$${u%~beta.*+dfsg*}" ]; then \
417 newver=$(shell echo $(RUST_VERSION) | perl -lpe 's/(\d+)\.(\d+)/$$1 . "." . ($$2)/e'); \
418 else \
15ab0b38 419 newver=$(shell echo $(RUST_VERSION) | perl -lpe 's/(\d+)\.(\d+)/$$1 . "." . ($$2+1)/e'); \
0a1981fb
XL
420 fi
421
422debian/watch-beta: debian/watch-beta.in debian/rules
423 set -e; $(get_beta_version); \
15ab0b38
XL
424 m4 -DOLDVER="$$oldver" -DNEWVER="$$newver.0" "$<" > "$@"
425
426source_orig-beta: debian/watch-beta
d377cbf5 427 uscan $(USCAN_OPTS) $(if $(USCAN_DESTDIR),--destdir=$(USCAN_DESTDIR),) --verbose --watchfile "$<"
0a1981fb 428 set -e; $(get_beta_version); \
d377cbf5
XL
429 bd="$(if $(USCAN_DESTDIR),$(USCAN_DESTDIR),..)"; \
430 tar xf $$bd/rustc-$$newver.0-beta.999-src.tar.xz rustc-beta-src/version; \
0a1981fb 431 bv="$$(sed -re 's/[0-9]+.[0-9]+.[0-9]+-beta.([0-9]+) \(.*\)/\1/g' rustc-beta-src/version)"; \
d377cbf5 432 bash -c 'shopt -s nullglob; for i in '"$$bd"'/rustc*beta.999*; do mv $$i $${i/beta.999/beta.'"$$bv"'}; done'; \
3af75deb
XL
433 rm -f rustc-beta-src/version; \
434 rmdir -p rustc-beta-src; \
d377cbf5 435 echo "prepared rustc $$newver.0~beta.$$bv in $$bd"