]> git.proxmox.com Git - rustc.git/blob - debian/rules
Fix building with cargo 0.40.0
[rustc.git] / debian / rules
1 #!/usr/bin/make -f
2 # -*- makefile -*-
3
4 include /usr/share/dpkg/pkg-info.mk
5 include /usr/share/dpkg/vendor.mk
6 include /usr/share/dpkg/architecture.mk
7 SED_VERSION_SHORT := sed -re 's/([^.]+)\.([^.]+)\..*/\1.\2/'
8 RUST_VERSION := $(shell echo '$(DEB_VERSION_UPSTREAM)' | $(SED_VERSION_SHORT))
9 RUST_LONG_VERSION := $(shell echo '$(DEB_VERSION_UPSTREAM)' | sed -re 's/([^+]+).*/\1/')
10 LIBSTD_PKG := libstd-rust-$(RUST_VERSION)
11 # Sed expression that matches the "rustc" we have in our Build-Depends field
12 SED_RUSTC_BUILDDEP := sed -ne "/^Build-Depends:/,/^[^[:space:]\#]/{/^ *rustc:native .*,/p}" debian/control
13 # Version of /usr/bin/rustc
14 LOCAL_RUST_VERSION := $(shell rustc --version --verbose | sed -ne 's/^release: //p')
15
16 include /usr/share/dpkg/buildflags.mk
17 # TODO: more correct to use `[build] rustflags = []` list syntax in Cargo.toml
18 RUSTFLAGS = $(addprefix -C link-args=,$(LDFLAGS))
19 RUSTFLAGS += --cap-lints warn --remap-path-prefix=$(CURDIR)=/usr/src/rustc-$(RUST_LONG_VERSION)
20 # TODO: remove in rustc 1.39.0 and later
21 export CARGO_BUILD_PIPELINING = false
22 export CFLAGS CXXFLAGS CPPFLAGS LDFLAGS RUSTFLAGS
23 export CARGO_HOME = $(CURDIR)/debian/cargo
24 ifneq (,$(filter $(DEB_BUILD_ARCH), sparc64))
25 export CARGO_INCREMENTAL = 0
26 endif
27
28 # Defines DEB_*_RUST_TYPE triples
29 include debian/architecture.mk
30 export DEB_HOST_RUST_TYPE
31
32 # Uncomment this to turn on verbose mode.
33 #export DH_VERBOSE=1
34
35 DEB_DESTDIR := $(CURDIR)/debian/tmp
36
37 # Use system LLVM (comment out to use vendored LLVM)
38 LLVM_VERSION = 8
39 OLD_LLVM_VERSION = 7
40 # Make it easier to test against a custom LLVM
41 ifneq (,$(LLVM_DESTDIR))
42 LLVM_LIBRARY_PATH := $(LLVM_DESTDIR)/usr/lib/$(DEB_HOST_MULTIARCH):$(LLVM_DESTDIR)/usr/lib
43 LD_LIBRARY_PATH := $(if $(LD_LIBRARY_PATH),$(LD_LIBRARY_PATH):$(LLVM_LIBRARY_PATH),$(LLVM_LIBRARY_PATH))
44 export LD_LIBRARY_PATH
45 endif
46
47 RUSTBUILD = RUST_BACKTRACE=1 ./x.py
48 RUSTBUILD_FLAGS = --config debian/config.toml -vvv --on-fail env
49 # TODO: This should simply be "$(RUSTBUILD) test" but unfortunately this causes
50 # an insane blow up in the time it takes to run tests. See upstream #37477 for
51 # details. Upstream worked around it in #38984 but in Debian we can't take
52 # advantage of that work-around, because we want as much debuginfo as possible
53 # (so we set debuginfo-lines = true, debuginfo-only-std = false) so we have to
54 # work around it instead by disabling backtrace when running tests.
55 RUSTBUILD_TEST = ./x.py test
56 # To run a specific test, run something like:
57 # $ debian/rules override_dh_auto_test-arch \
58 # RUSTBUILD_TEST_FLAGS="src/test/run-make --test-args extern-fn-struct"
59 # See src/bootstrap/README.md for more options.
60 RUSTBUILD_TEST_FLAGS =
61
62 update-version:
63 oldver=$(shell $(SED_RUSTC_BUILDDEP) | sed -ne 's/.*(<= \(.*\)).*/\1/gp' | $(SED_VERSION_SHORT)); \
64 newver=$(RUST_VERSION); \
65 debian/update-version.sh $$oldver $$newver $(RUST_LONG_VERSION) $(CARGO_NEW)
66
67 # Below we detect how we're supposed to bootstrap the stage0 compiler. See
68 # README.Debian for more details of the cases described below.
69 #
70 PRECONFIGURE_CHECK = :
71 HAVE_BINARY_TARBALL := $(shell ls -1 stage0/*/*$(DEB_HOST_RUST_TYPE)* 2>/dev/null | wc -l)
72 DOWNLOAD_BOOTSTRAP := false
73 # allow not using the binary tarball although it exists
74 #ifneq (,$(filter $(DEB_HOST_ARCH), amd64 arm64 armhf i386 powerpc ppc64el s390x))
75 # HAVE_BINARY_TARBALL := 0
76 #endif
77 ifeq (0,$(HAVE_BINARY_TARBALL))
78 # Case A (Building from source): the extracted source tree does not include
79 # a bootstrapping tarball for the current architecture e.g. because the
80 # distro already has a rustc for this arch, or the uploader expects that
81 # this requirement be fulfilled in some other way.
82 #
83 # Case A-1: the builder did not select the "pkg.rustc.dlstage0" build profile.
84 # In this case, we use the distro's rustc - either the previous or current version.
85 ifeq (,$(findstring pkg.rustc.dlstage0,$(DEB_BUILD_PROFILES)))
86 # Make it easier to test against a custom rustc
87 ifneq (,$(RUST_DESTDIR))
88 RUST_LIBRARY_PATH := $(RUST_DESTDIR)/usr/lib/$(DEB_HOST_MULTIARCH):$(RUST_DESTDIR)/usr/lib
89 LD_LIBRARY_PATH := $(if $(LD_LIBRARY_PATH),$(LD_LIBRARY_PATH):$(RUST_LIBRARY_PATH),$(RUST_LIBRARY_PATH))
90 export LD_LIBRARY_PATH
91 endif
92 #
93 # Case A-2: the builder selected the "dlstage0" build profile.
94 # In this case, the rust build scripts will download a stage0 into stage0/ and use that.
95 # We don't need to do anything specific in this build file, so this case is empty.
96 else
97 DOWNLOAD_BOOTSTRAP := true
98 endif
99 else
100 # Case B (Bootstrapping a new distro): the extracted source tree does
101 # include a bootstrapping tarball for the current architecture; see the
102 # `source_orig-stage0` target below on how to build this.
103 #
104 # In this case, we'll bootstrap from the stage0 given in that tarball.
105 # To ensure the uploader of the .dsc didn't make a mistake, we first check
106 # that rustc isn't a Build-Depends for the current architecture.
107 ifneq (,$(shell $(SED_RUSTC_BUILDDEP)))
108 ifeq (,$(shell $(SED_RUSTC_BUILDDEP) | grep '!$(DEB_HOST_ARCH)'))
109 PRECONFIGURE_CHECK = $(error found matches for stage0/*/*$(DEB_HOST_RUST_TYPE)*, \
110 but rustc might be a Build-Depends for $(DEB_HOST_ARCH))
111 endif
112 endif
113 endif
114
115 BUILD_DOCS := true
116 ifneq (,$(findstring nodoc,$(DEB_BUILD_PROFILES)))
117 BUILD_DOCS := false
118 endif
119
120 MAKE_OPTIMISATIONS := true
121 ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
122 MAKE_OPTIMISATIONS := false
123 endif
124
125 # Build products or non-source files in src/, that shouldn't go in rust-src
126 SRC_CLEAN = src/bootstrap/bootstrap.pyc \
127 src/etc/__pycache__/
128
129 # Workaround for linux #865549
130 ifeq (0,$(shell test $$(uname -s) = "Linux" -a $$(getconf PAGESIZE) -gt 4096; echo $$?))
131 SYSTEM_WORKAROUNDS += ulimit -s $$(expr $$(getconf PAGESIZE) / 1024 '*' 256 + 8192);
132 endif
133 # Try to work around #933045
134 ifneq (,$(filter $(DEB_BUILD_ARCH), mips mipsel))
135 SYSTEM_WORKAROUNDS += export MALLOC_ARENA_MAX=1;
136 endif
137
138 %:
139 $(SYSTEM_WORKAROUNDS) dh $@ --parallel
140
141 .PHONY: build
142 build:
143 $(SYSTEM_WORKAROUNDS) dh $@ --parallel
144
145 override_dh_clean:
146 # Upstream contains a lot of these
147 dh_clean -XCargo.toml.orig
148
149 debian/config.toml: debian/config.toml.in debian/rules
150 u="$(DEB_VERSION_UPSTREAM)"; \
151 if [ "$$u" != "$${u%~beta.*+dfsg*}" ]; then channel="beta"; \
152 else channel="stable"; fi; echo $$channel; \
153 m4 -DRELEASE_CHANNEL="$$channel" \
154 -DDEB_BUILD_RUST_TYPE="$(DEB_BUILD_RUST_TYPE)" \
155 -DDEB_HOST_RUST_TYPE="$(DEB_HOST_RUST_TYPE)" \
156 -DDEB_TARGET_RUST_TYPE="$(DEB_TARGET_RUST_TYPE)" \
157 -DDEB_BUILD_GNU_TYPE="$(DEB_BUILD_GNU_TYPE)" \
158 -DDEB_HOST_GNU_TYPE="$(DEB_HOST_GNU_TYPE)" \
159 -DDEB_TARGET_GNU_TYPE="$(DEB_TARGET_GNU_TYPE)" \
160 -DMAKE_OPTIMISATIONS="$(MAKE_OPTIMISATIONS)" \
161 -DLLVM_DESTDIR="$(LLVM_DESTDIR)" \
162 -DLLVM_VERSION="$(LLVM_VERSION)" \
163 -DRUST_DESTDIR="$(RUST_DESTDIR)" \
164 "$<" > "$@"
165 if $(DOWNLOAD_BOOTSTRAP) || [ $(HAVE_BINARY_TARBALL) != 0 ]; \
166 then sed -i -e '/^rustc = /d' -e '/^cargo = /d' "$@"; fi
167 # Work around low-memory (32-bit) architectures: https://github.com/rust-lang/rust/issues/45854
168 #ifneq (,$(filter $(DEB_BUILD_ARCH), armhf armel mips mipsel powerpc powerpcspe))
169 sed -i -e 's/^debuginfo-level = .*/debuginfo-level = 0/g' "$@"
170 #endif
171
172 debian/rust-src.%: debian/rust-src.%.in
173 m4 -DRUST_LONG_VERSION="$(RUST_LONG_VERSION)" \
174 "$<" > "$@"
175
176 debian/dh_auto_configure.stamp: debian/config.toml
177 # fail the build if we have any instances of OLD_LLVM_VERSION in debian, except for debian/changelog
178 ! grep --color=always -i 'll\(..\|d\)-\?$(subst .,\.,$(OLD_LLVM_VERSION))' --exclude=changelog --exclude='*.patch' -R debian
179 # fail the build if we accidentally vendored openssl, indicates we pulled in unnecessary dependencies
180 test ! -e vendor/openssl
181 # fail the build if our version contains ~exp and we are not releasing to experimental
182 v="$(DEB_VERSION)"; test "$$v" = "$${v%~exp*}" -o "$(DEB_DISTRIBUTION)" = "experimental" -o "$(DEB_DISTRIBUTION)" = "UNRELEASED"
183 $(PRECONFIGURE_CHECK)
184 if [ -d stage0 ]; then mkdir -p build && ln -sfT ../stage0 build/cache; fi
185 # work around #842634
186 if test $$(grep "127.0.0.1\s*localhost" /etc/hosts | wc -l) -gt 1; then \
187 debian/ensure-patch -N debian/patches/d-host-duplicates.patch; fi
188 # We patched some crates so have to rm the checksums
189 find vendor -name .cargo-checksum.json -execdir "$(CURDIR)/debian/prune-checksums" "{}" ";"
190 # Link against system liblzma, see https://github.com/alexcrichton/xz2-rs/issues/16
191 echo 'fn main() { println!("cargo:rustc-link-lib=lzma"); }' > vendor/lzma-sys/build.rs
192 # We don't run ./configure because we use debian/config.toml directly
193 ln -sf debian/config.toml config.toml
194 touch "$@"
195
196 override_dh_auto_configure-arch: debian/dh_auto_configure.stamp
197 override_dh_auto_configure-indep: debian/dh_auto_configure.stamp
198 ifeq (true,$(BUILD_DOCS))
199 # Change config.toml now and not later, since that might trigger a rebuild
200 sed -i -e 's/^docs = false/docs = true/' debian/config.toml
201 endif
202
203 override_dh_auto_clean:
204 $(RM) -rf build tmp .cargo debian/cargo_home config.stamp config.mk Makefile
205 $(RM) -rf $(TEST_LOG) debian/config.toml debian/rust-src.install debian/rust-src.links debian/*.stamp
206 $(RM) -rf $(SRC_CLEAN) config.toml
207
208 debian/dh_auto_build.stamp:
209 $(RUSTBUILD) build $(RUSTBUILD_FLAGS)
210
211 override_dh_auto_build-arch: debian/dh_auto_build.stamp
212 override_dh_auto_build-indep: debian/dh_auto_build.stamp
213 $(RUSTBUILD) build $(RUSTBUILD_FLAGS) --host $(DEB_BUILD_RUST_TYPE) --target wasm32-unknown-unknown src/libstd
214 ifeq (true,$(BUILD_DOCS))
215 $(RUSTBUILD) doc $(RUSTBUILD_FLAGS)
216 endif
217
218 TEST_LOG = debian/rustc-tests.log
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.
221 FAILURES_ALLOWED = 8
222 ifneq (,$(filter $(DEB_BUILD_ARCH), ppc64 arm64 mips64el i386))
223 FAILURES_ALLOWED = 12
224 endif
225 ifneq (,$(filter $(DEB_BUILD_ARCH), mips mipsel s390x))
226 FAILURES_ALLOWED = 24
227 endif
228 ifneq (,$(filter $(DEB_BUILD_ARCH), powerpc powerpcspe sparc64 x32))
229 FAILURES_ALLOWED = 180
230 endif
231 FAILED_TESTS = grep "FAILED\|^command did not execute successfully" $(TEST_LOG) | grep -v '^test result: FAILED'
232 override_dh_auto_test-arch:
233 # ensure that rustc_llvm is actually dynamically linked to libLLVM
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
240 ifeq (, $(filter nocheck,$(DEB_BUILD_PROFILES)))
241 ifeq (, $(filter nocheck,$(DEB_BUILD_OPTIONS)))
242 { $(RUSTBUILD_TEST) --no-fail-fast $(RUSTBUILD_FLAGS) $(RUSTBUILD_TEST_FLAGS); echo $$?; } | tee -a $(TEST_LOG)
243 # test that the log has at least 1 pass, to prevent e.g. #57709
244 grep -l "^test .* \.\.\. ok$$" $(TEST_LOG)
245 echo "==== Debian rustc test report ===="; \
246 echo "Specific test failures:"; \
247 $(FAILED_TESTS); \
248 num_failures=$$($(FAILED_TESTS) | wc -l); \
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."; \
254 echo "This could happen if we failed to build the tests, or if the testsuite runner is buggy."; \
255 false; \
256 elif test "$$num_failures" -le $(FAILURES_ALLOWED); then \
257 echo "Continuing..."; \
258 else \
259 echo "Aborting the build."; \
260 echo "Check the logs further above for details."; \
261 false; \
262 fi
263 # don't continue if RUSTBUILD_TEST_FLAGS is non-empty
264 test -z "$(RUSTBUILD_TEST_FLAGS)"
265 endif
266 endif
267
268 override_dh_auto_test-indep:
269 ifeq (, $(filter nocheck,$(DEB_BUILD_PROFILES)))
270 ifeq (, $(filter nocheck,$(DEB_BUILD_OPTIONS)))
271 # TODO: test wasm32-unknown-unknown but it doesn't yet work
272 ifeq (true,$(BUILD_DOCS))
273 # Run all rules that test the docs, i.e. in step.rs that depend on default:doc
274 $(RUSTBUILD_TEST) --no-fail-fast src/tools/linkchecker $(RUSTBUILD_FLAGS)
275 endif
276 test -z "$(RUSTBUILD_TEST_FLAGS)"
277 endif
278 endif
279
280 run_rustbuild:
281 DESTDIR=$(DEB_DESTDIR) $(RUSTBUILD) $(X_CMD) $(RUSTBUILD_FLAGS) $(X_FLAGS)
282
283 debian/dh_auto_install.stamp:
284 DESTDIR=$(DEB_DESTDIR) $(RUSTBUILD) install $(RUSTBUILD_FLAGS)
285
286 mkdir -p $(DEB_DESTDIR)/usr/lib/$(DEB_HOST_MULTIARCH)/
287 mv $(DEB_DESTDIR)/usr/lib/lib*.so $(DEB_DESTDIR)/usr/lib/$(DEB_HOST_MULTIARCH)/
288
289 # Replace duplicated compile-time/run-time dylibs with symlinks
290 @set -e; \
291 for f in $(DEB_DESTDIR)/usr/lib/rustlib/$(DEB_HOST_RUST_TYPE)/lib/lib*.so; do \
292 name=$${f##*/}; \
293 if [ -f "$(DEB_DESTDIR)/usr/lib/$(DEB_HOST_MULTIARCH)/$$name" ]; then \
294 echo "ln -sf ../../../$(DEB_HOST_MULTIARCH)/$$name $$f"; \
295 ln -sf ../../../$(DEB_HOST_MULTIARCH)/$$name $$f; \
296 fi; \
297 done
298
299 touch "$@"
300
301 override_dh_auto_install-arch: debian/dh_auto_install.stamp
302 override_dh_auto_install-indep: debian/dh_auto_install.stamp
303 DESTDIR=$(DEB_DESTDIR) $(RUSTBUILD) install $(RUSTBUILD_FLAGS) --host $(DEB_BUILD_RUST_TYPE) --target wasm32-unknown-unknown src/libstd
304 ifeq (true,$(BUILD_DOCS))
305 # Brute force to remove privacy-breach-logo lintian warning.
306 # We could have updated the upstream sources but it would complexify
307 # the rebase
308 @set -e; \
309 find $(DEB_DESTDIR)/usr/share/doc/*/html -iname '*.html' | \
310 while read file; do \
311 topdir=$$(echo "$$file" | sed 's,^$(DEB_DESTDIR)/usr/share/doc/rust/html/,,; s,/[^/]*$$,/,; s,^[^/]*$$,,; s,[^/]\+/,../,g'); \
312 sed -i \
313 -e "s,https://\(doc\|www\).rust-lang.org/\(favicon.ico\|logos/rust-logo-32x32-blk.png\),$${topdir}rust-logo-32x32-blk.png," \
314 -e 's,<img src="https://img.shields.io/[^"]*" alt="\([^"]*\)" />,<span class="deb-privacy-replace--shields-io">\1</span>,g' "$$file"; \
315 done
316 find $(DEB_DESTDIR) \( -iname '*.html' -empty -o -name .lock -o -name '*.inc' \) -delete;
317 endif
318
319 override_dh_install-arch:
320 dh_install
321 dh_install -p$(LIBSTD_PKG) usr/lib/$(DEB_HOST_MULTIARCH)/
322 dh_install -plibstd-rust-dev usr/lib/rustlib/$(DEB_HOST_RUST_TYPE)/lib/
323 dh_install -prustc usr/lib/rustlib/$(DEB_HOST_RUST_TYPE)/codegen-backends/
324
325 override_dh_install-indep: debian/rust-src.install debian/rust-src.links
326 dh_install
327 dh_install -plibstd-rust-dev-wasm32-cross usr/lib/rustlib/wasm32-*/lib/
328 chmod -x \
329 debian/rust-gdb/usr/share/rust-gdb/*.py \
330 debian/rust-lldb/usr/share/rust-lldb/*.py
331 $(RM) -rf $(SRC_CLEAN:%=debian/rust-src/usr/src/rustc-$(RUST_LONG_VERSION)/%)
332 # Get rid of lintian warnings
333 find debian/rust-src/usr/src/rustc-$(RUST_LONG_VERSION) \
334 \( -name .gitignore \
335 -o -name 'LICENSE*' \
336 -o -name 'LICENCE' \
337 -o -name 'license' \
338 -o -name 'COPYING*' \
339 \) -delete
340 # Remove files that autoload remote resources, caught by lintian
341 $(RM) -rf debian/rust-src/usr/src/rustc-*/vendor/cssparser/docs/*.html
342 $(RM) -rf debian/rust-src/usr/src/rustc-*/vendor/kuchiki/docs/*.html
343 $(RM) -rf debian/rust-src/usr/src/rustc-*/vendor/url/docs/*.html
344 $(RM) -rf debian/rust-src/usr/src/rustc-*/vendor/xz2/.gitmodules
345
346 override_dh_installchangelogs:
347 dh_installchangelogs RELEASES.md
348
349 override_dh_installdocs:
350 dh_installdocs -X.tex -X.aux -X.log -X.out -X.toc
351
352 override_dh_missing:
353 dh_missing --list-missing
354
355 override_dh_compress:
356 dh_compress -X.woff
357
358 override_dh_strip:
359 # Work around #35733, #468333
360 find debian/libstd-rust-dev*/ -name '*.rlib' -execdir mv '{}' '{}.a' \;
361 # This is expected to print out lots of "File format unrecognized" warnings about
362 # rust.metadata.bin and *.deflate but the .o files inside the rlibs should be stripped
363 # Some files are still omitted because of #875780 however.
364 dh_strip -v
365 find debian/libstd-rust-dev*/ -name '*.rlib.a' -execdir sh -c 'mv "$$1" "$${1%.a}"' - '{}' \;
366
367 override_dh_makeshlibs:
368 dh_makeshlibs -V
369
370 # dh_makeshlibs doesn't support our "libfoo-version.so" naming
371 # structure, so we have to do this ourselves.
372 install -o 0 -g 0 -d debian/$(LIBSTD_PKG)/DEBIAN
373 LC_ALL=C ls debian/$(LIBSTD_PKG)/usr/lib/$(DEB_HOST_MULTIARCH)/lib*.so | \
374 sed -n 's,^.*/\(lib.*\)-\(.\+\)\.so$$,\1 \2,p' | \
375 while read name version; do \
376 echo "$$name $$version $(LIBSTD_PKG) (>= $(DEB_VERSION_UPSTREAM))"; \
377 done > debian/$(LIBSTD_PKG)/DEBIAN/shlibs
378 chmod 644 debian/$(LIBSTD_PKG)/DEBIAN/shlibs
379 chown 0:0 debian/$(LIBSTD_PKG)/DEBIAN/shlibs
380
381 override_dh_shlibdeps:
382 dh_shlibdeps -- -x$(LIBSTD_PKG)
383
384 QUILT_SPECIAL_SNOWFLAKE_RETURN_CODE = x=$$?; if [ $$x = 2 ]; then exit 0; else exit $$x; fi
385 source_orig-stage0:
386 QUILT_PATCHES=debian/patches quilt push -aq; $(QUILT_SPECIAL_SNOWFLAKE_RETURN_CODE)
387 $(MAKE) -f debian/rules clean
388 debian/make_orig-stage0_tarball.sh
389 QUILT_PATCHES=debian/patches quilt pop -aq; $(QUILT_SPECIAL_SNOWFLAKE_RETURN_CODE)
390 rm -rf .pc
391
392 get_beta_version = \
393 u="$(DEB_VERSION_UPSTREAM)"; \
394 if [ "$$u" != "$${u%~beta.*+dfsg*}" ]; then \
395 newver=$(shell echo $(RUST_VERSION) | perl -lpe 's/(\d+)\.(\d+)/$$1 . "." . ($$2)/e'); \
396 else \
397 newver=$(shell echo $(RUST_VERSION) | perl -lpe 's/(\d+)\.(\d+)/$$1 . "." . ($$2+1)/e'); \
398 fi
399
400 debian/watch-beta: debian/watch-beta.in debian/rules
401 set -e; $(get_beta_version); \
402 m4 -DOLDVER="$$oldver" -DNEWVER="$$newver.0" "$<" > "$@"
403
404 source_orig-beta: debian/watch-beta
405 uscan $(USCAN_OPTS) $(if $(USCAN_DESTDIR),--destdir=$(USCAN_DESTDIR),) --verbose --watchfile "$<"
406 set -e; $(get_beta_version); \
407 bd="$(if $(USCAN_DESTDIR),$(USCAN_DESTDIR),..)"; \
408 tar xf $$bd/rustc-$$newver.0-beta.999-src.tar.xz rustc-beta-src/version; \
409 bv="$$(sed -re 's/[0-9]+.[0-9]+.[0-9]+-beta.([0-9]+) \(.*\)/\1/g' rustc-beta-src/version)"; \
410 bash -c 'shopt -s nullglob; for i in '"$$bd"'/rustc*beta.999*; do mv $$i $${i/beta.999/beta.'"$$bv"'}; done'; \
411 rm -f rustc-beta-src/version; \
412 rmdir -p rustc-beta-src; \
413 echo "prepared rustc $$newver.0~beta.$$bv in $$bd"