From effecb884e14461d02e0cf697eb79d2d84049a89 Mon Sep 17 00:00:00 2001 From: Chris Krycho Date: Tue, 5 Nov 2024 14:48:19 -0700 Subject: [PATCH] infra: rewrite rustup toolchain paths in update-rustc.sh As with project paths, we do not want these to have the paths from the user who runs `update-rustc.sh`, but some totally generic path. --- tools/update-rustc.sh | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/tools/update-rustc.sh b/tools/update-rustc.sh index 72d8d8917..8e674e056 100755 --- a/tools/update-rustc.sh +++ b/tools/update-rustc.sh @@ -8,8 +8,9 @@ echo 'Building book dependencies in tmp/packages...' mkdir -p tmp/packages cp -r packages/trpl tmp/packages/trpl cd tmp/packages/trpl -cargo clean > /dev/null -cargo build > /dev/null + # hide the output; if it fails, debug then. +cargo clean > /dev/null 2>&1 +cargo build > /dev/null 2>&1 cd - > /dev/null # Build the book before making any changes for comparison of the output. @@ -73,6 +74,16 @@ find -s listings -name output.txt -print0 | while IFS= read -r -d '' f; do # instead of a path to the computer of whoever is running this sed -i '' -E -e 's@(Compiling|Checking) ([^\)]*) v0.1.0 (.*)@\1 \2 v0.1.0 (file:///projects/\2)@' "${full_output_path}" + # Likewise, use a "default" installation directory for rustup's install + # location so the version of the source is not a path on the computer of + # whoever is doing the update. This does two substitutions: + # + # - Replaces the path up to `.rustup/toolchains` with `file:///home`, while + # preserving leading spaces and the `-->`. + # - Replaces the version-and-architecture-tripl with just the version, so + # e.g. `1.82-aarch64-apple-darwin` becomes `1.82`. + sed -i '' -E -e 's@^([[:space:]]*-->[[:space:]]+).*(\.rustup/toolchains/[[:digit:]]+\.[[:digit:]]+)([^/]*)@\1file:///home/\2@' "${full_output_path}" + # Restore the previous compile time, if there is one if [ -n "${compile_time}" ]; then sed -i '' -E -e "s/Finished \`(dev|test)\` profile \[unoptimized \+ debuginfo] target\(s\) in [0-9.]*/Finished \`\1\` profile [unoptimized + debuginfo] target(s) in ${compile_time}/" "${full_output_path}"