@@ -5,7 +5,9 @@ export PYTHONDONTWRITEBYTECODE=1
55
66platform=" ${1:? native platform is required} "
77shift
8- [[ " $# " -eq 0 ]] || { echo " usage: scripts/tooling/$platform .sh" >&2 ; exit 64; }
8+ ci=false
9+ if [[ " ${1:- } " == --ci ]]; then ci=true; shift ; fi
10+ [[ " $# " -eq 0 ]] || { echo " usage: scripts/tooling/$platform .sh [--ci]" >&2 ; exit 64; }
911machine=" ${platform% -linux} "
1012[[ " $machine " != powerpc64le ]] || machine=ppc64le
1113case " $platform " in
@@ -21,9 +23,11 @@ cd "$REPO_ROOT"
2123# Ubuntu Server supplies Python; install it from the selected archive if absent.
2224# Read only the two bootstrap strings before the full TOML reader is available.
2325catalog=" $REPO_ROOT /.config/tooling.toml"
24- bootstrap_value () { sed -n ' /^\[linux\]$/,/^\[/s/^' " $1 " ' = "\([^"]*\)"$/\1/p' " $catalog " ; }
26+ linux_section=linux
27+ [[ " $ci " == false ]] || linux_section=linux-ci
28+ bootstrap_value () { sed -n ' /^\[' " ${2:- $linux_section } " ' \]$/,/^\[/s/^' " $1 " ' = "\([^"]*\)"$/\1/p' " $catalog " ; }
2529ubuntu=" $( bootstrap_value ubuntu) "
26- snapshot=" $( bootstrap_value snapshot) "
30+ snapshot=" $( bootstrap_value snapshot linux ) "
2731# shellcheck source=/dev/null
2832source /etc/os-release
2933[[ " $ID " == ubuntu && " $VERSION_ID " == " $ubuntu " ]] || {
@@ -53,9 +57,11 @@ apt=("${sudo_cmd[@]}" env DEBIAN_FRONTEND=noninteractive apt-get "${apt_options[
5357" ${apt[@]} " update
5458catalog_get () { python3 " $SCRIPT_DIR /catalog.py" get " $@ " ; }
5559python3 " $SCRIPT_DIR /catalog.py" validate
56- mapfile -t packages < <( catalog_get linux packages)
57- mapfile -t native_packages < <( catalog_get " $platform " packages)
58- packages+=(" ${native_packages[@]} " )
60+ mapfile -t packages < <( catalog_get " $linux_section " packages)
61+ if [[ " $ci " == false ]]; then
62+ mapfile -t native_packages < <( catalog_get " $platform " packages)
63+ packages+=(" ${native_packages[@]} " )
64+ fi
5965# Exact candidates come from the selected snapshot, including repeat installations.
6066pinned_packages=()
6167for package in " ${packages[@]} " ; do
6672" ${apt[@]} " install -y --allow-downgrades " ${pinned_packages[@]} "
6773
6874prefix=" $HOME /.local/share/rscrypto-tooling"
69- mkdir -p " $prefix /bin "
75+ mkdir -p " $prefix "
7076python3 " $SCRIPT_DIR /catalog.py" download " $platform " rustup " $temporary /rustup-init"
7177chmod +x " $temporary /rustup-init"
7278host=" $( catalog_get " $platform " rust-host) "
7379channel=" $( python3 " $SCRIPT_DIR /../lib/toolchain.py" ) "
7480" $temporary /rustup-init" -y --no-modify-path --default-host " $host " --default-toolchain none
75- export PATH=" $HOME /.cargo/bin:$PATH "
76- mapfile -t components < <( catalog_get " $platform " components)
81+ cargo_bin=" ${CARGO_HOME:- $HOME / .cargo} /bin"
82+ export PATH=" $cargo_bin :$PATH "
83+ components=()
84+ if [[ " $ci " == false ]]; then mapfile -t components < <( catalog_get " $platform " components) ; fi
7785component_args=()
7886for component in " ${components[@]} " ; do component_args+=(--component " $component " ); done
7987python3 " $SCRIPT_DIR /../lib/toolchain.py" --install " $host " " ${component_args[@]} "
8088export RUSTUP_TOOLCHAIN=" $channel "
8189# Archive tools retain their complete directory layouts, including LLVM and Zig libraries.
82- python3 " $SCRIPT_DIR /catalog.py" install-archives " $platform " " $prefix " > " $temporary /archives"
90+ if [[ " $ci " == true ]]; then
91+ : > " $temporary /archives"
92+ if [[ " $platform " == aarch64-linux || " $platform " == x86_64-linux ]]; then
93+ directory=" $( python3 " $SCRIPT_DIR /catalog.py" install-archive " $platform " cargo-binstall " $prefix " ) "
94+ printf ' cargo-binstall\t%s\n' " $directory " > " $temporary /archives"
95+ fi
96+ else
97+ python3 " $SCRIPT_DIR /catalog.py" install-archives " $platform " " $prefix " > " $temporary /archives"
98+ fi
8399tool_paths=()
84100while IFS=$' \t ' read -r name directory; do
85101 if [[ -d " $directory /bin" ]]; then tool_paths+=(" $directory /bin" ); else tool_paths+=(" $directory " ); fi
86102 if [[ " $name " == llvm ]]; then export LIBCLANG_PATH=" $directory /lib" ; fi
87103done < " $temporary /archives"
88- PATH=" $( IFS=:; echo " ${tool_paths[*]} " ) :$prefix /bin:$HOME /.cargo/bin:$PATH "
89- export PATH
90- mapfile -t cargo_tools < <( catalog_get " $platform " cargo)
104+ tool_paths+=(" $cargo_bin " )
105+ path_prefix=" $( IFS=:; echo " ${tool_paths[*]} " ) "
106+ export PATH=" $path_prefix :$PATH "
107+ tool_section=" $platform "
108+ [[ " $ci " == false ]] || tool_section=ci
109+ mapfile -t cargo_tools < <( catalog_get " $tool_section " cargo)
91110for tool in " ${cargo_tools[@]} " ; do
92111 version=" $( catalog_get cargo " $tool " ) "
93112 # Cargo's install registry verifies exact installed package versions on reruns.
@@ -99,23 +118,25 @@ for tool in "${cargo_tools[@]}"; do
99118 cargo +" $channel " install --locked --target " $( catalog_get " $platform " rust-host) " --version " $version " " $tool "
100119 fi
101120done
102- if [[ " $platform " != aarch64-linux && " $platform " != x86_64-linux ]]; then
121+ if [[ " $ci " == false && " $ platform" != aarch64-linux && " $platform " != x86_64-linux ]]; then
103122 env -u RUSTC_WRAPPER -u CARGO_ENCODED_RUSTFLAGS \
104123 cargo +" $channel " install --locked --target " $( catalog_get " $platform " rust-host) " --version " $( catalog_get versions cargo-rail) " cargo-rail
105124fi
106125
107126# Persistent paths are shared by interactive shells and non-interactive Bash recipes.
108127environment=" $prefix /environment.sh"
109128{
110- printf " export PATH=%q:\"\$ PATH\" \n" " $( IFS=: ; echo " ${tool_paths[*]} " ) : $prefix /bin: $HOME /.cargo/bin "
129+ printf " export PATH=%q:\"\$ PATH\" \n" " $path_prefix "
111130 if [[ -n " ${LIBCLANG_PATH:- } " ]]; then printf ' export LIBCLANG_PATH=%q\n' " $LIBCLANG_PATH " ; fi
112131} > " $environment "
113- for startup in " $HOME /.profile" " $HOME /.bashrc" ; do
114- line=" source \" $environment \" "
115- touch " $startup "
116- grep -Fxq " $line " " $startup " || printf ' \n%s\n' " $line " >> " $startup "
117- done
118- if [[ " $platform " == aarch64-linux || " $platform " == x86_64-linux ]]; then
132+ if [[ " $ci " == false ]]; then
133+ for startup in " $HOME /.profile" " $HOME /.bashrc" ; do
134+ line=" source \" $environment \" "
135+ touch " $startup "
136+ grep -Fxq " $line " " $startup " || printf ' \n%s\n' " $line " >> " $startup "
137+ done
138+ fi
139+ if [[ " $ci " == false && ( " $platform " == aarch64-linux || " $platform " == x86_64-linux ) ]]; then
119140# Linux profiling is available to the runner account, including non-root perf/samply.
120141" ${sudo_cmd[@]} " tee /etc/sysctl.d/99-rscrypto-profiling.conf > /dev/null << 'CONF '
121142kernel.perf_event_paranoid = -1
@@ -132,6 +153,6 @@ samply --version
132153fi
133154clang --version
134155cmake --version
135- cargo rail --version
156+ if [[ " $ci " == false ]] ; then cargo rail --version; fi
136157cargo nextest --version
137- printf ' Installed %s tooling. New shells load %s. \n' " $platform " " $environment "
158+ printf ' Installed %s tooling. Load with: source "%s" \n' " $platform " " $environment "
0 commit comments