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