Skip to content

Commit

Permalink
Use distro provided rustup
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
crawfxrd committed Dec 4, 2024
1 parent 85da2d2 commit 8d83eed
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 21 deletions.
5 changes: 2 additions & 3 deletions docs/dev-env.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
36 changes: 18 additions & 18 deletions scripts/deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,47 +14,43 @@ 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 \
libhidapi-dev \
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 \
Expand All @@ -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:"
Expand Down

0 comments on commit 8d83eed

Please sign in to comment.