From 8d83eedca3f03c12a7baa8e555b095879b13b2d0 Mon Sep 17 00:00:00 2001 From: Tim Crawford Date: Tue, 3 Dec 2024 19:39:24 -0700 Subject: [PATCH] Use distro provided rustup This removes the need to download and run a shell script to set up the environment. The distro is instead trusted to provide a valid binary. Fedora has a package called "rustup", but it really is just the rustup-init binary [1]. Additionally handle the behavior changes for rustup 1.28.0, which removes implicit toolchain installation but adds support for installing from `rust-toolchain.toml`. [1]: https://src.fedoraproject.org/rpms/rustup Signed-off-by: Tim Crawford --- docs/dev-env.md | 5 ++--- scripts/deps.sh | 36 ++++++++++++++++++------------------ 2 files changed, 20 insertions(+), 21 deletions(-) diff --git a/docs/dev-env.md b/docs/dev-env.md index f98398536..0ba77765f 100644 --- a/docs/dev-env.md +++ b/docs/dev-env.md @@ -20,11 +20,10 @@ toolset. A complete list of dependencies can be seen in `scripts/deps.sh`. -### Cargo +### Cargo (Rust) rustup manages the [Rust] toolchain, which includes cargo. Cargo is required -for building the tools. It is the only part of the development toolset that is -not installed through distro packages. +for building the tools. ### GNU Make diff --git a/scripts/deps.sh b/scripts/deps.sh index e87e088ab..a1f7177c1 100755 --- a/scripts/deps.sh +++ b/scripts/deps.sh @@ -14,12 +14,9 @@ source /etc/os-release msg "Installing system build dependencies" if [[ "${ID}" =~ "debian" ]] || [[ "${ID_LIKE}" =~ "debian" ]]; then sudo apt-get update - sudo apt-get install \ - --no-install-recommends \ - --yes \ + sudo apt-get install --no-install-recommends --yes \ avr-libc \ avrdude \ - curl \ gcc \ gcc-avr \ libc-dev \ @@ -27,34 +24,33 @@ if [[ "${ID}" =~ "debian" ]] || [[ "${ID_LIKE}" =~ "debian" ]]; then libudev-dev \ make \ pkgconf \ + rustup \ sdcc \ shellcheck \ uncrustify \ xxd elif [[ "${ID}" =~ "fedora" ]] || [[ "${ID_LIKE}" =~ "fedora" ]]; then - sudo dnf install \ - --assumeyes \ + sudo dnf install --assumeyes \ avr-gcc \ avr-libc \ avrdude \ - curl \ gcc \ make \ + rust \ sdcc \ ShellCheck \ systemd-devel \ uncrustify \ vim-common elif [[ "${ID}" =~ "arch" ]] || [[ "${ID_LIKE}" =~ "arch" ]]; then - sudo pacman -S \ - --noconfirm \ + sudo pacman -S --noconfirm \ avr-gcc \ avr-libc \ avrdude \ - curl \ gcc \ make \ pkgconf \ + rustup \ sdcc \ shellcheck \ systemd-libs \ @@ -74,17 +70,21 @@ make git-config RUSTUP_NEW_INSTALL=0 if ! command -v rustup >/dev/null 2>&1; then - RUSTUP_NEW_INSTALL=1 - msg "Installing Rust" - curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs \ - | sh -s -- -y --default-toolchain none - - msg "Loading Rust environment" - source "${HOME}/.cargo/env" + # Fedora "rustup" package really just installs "rustup-init" + if command -v rustup-init >/dev/null 2>&1; then + RUSTUP_NEW_INSTALL=1 + msg "Installing Rust" + rustup-init -y \ + --default-toolchain none \ + --profile minimal \ + --no-update-default-toolchain + . "${HOME}/.cargo/env" + fi fi msg "Installing pinned Rust toolchain and components" -rustup show +# Ref: https://github.com/rust-lang/rustup/issues/3635 +rustup show active-toolchain || rustup toolchain install if [[ $RUSTUP_NEW_INSTALL = 1 ]]; then msg "rustup was just installed. Ensure cargo is on the PATH with:"