Files
system76-embedded-controller/scripts/deps.sh
Tim Crawford d60a8e4c8e scripts: Remove explicit rustup self update
Commit 17f8e37ed5 ("Convert toolchain file to TOML syntax") switched
from the bare toolchain file to the TOML-based one for better management
of the toolchain and components used.

Commit 1cb61e6918 ("deps.sh: Update rustup or inform user of env
vars") added an explicit `rustup self update` because there were still
cases, a year later, of people not having a rustup new enough to support
the TOML-based toolchain file.

Now 2 years after that, it should be safe to drop the explicit self
update. The TOML format has widespread adoption and rustup now self
updates by default. This should allow distro-provided rustup, which
disables the self update feature, to work if it is already installed in
place of the one downloaded from https://rustup.rs.

Signed-off-by: Tim Crawford <tcrawford@system76.com>
2024-03-18 14:20:31 -06:00

95 lines
2.0 KiB
Bash
Executable File

#!/usr/bin/env bash
# SPDX-License-Identifier: GPL-3.0-only
set -eE
function msg {
echo -e "\x1B[1m$*\x1B[0m" >&2
}
trap 'msg "\x1B[31mFailed to install dependencies!"' ERR
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 \
avr-libc \
avrdude \
clang-format \
curl \
gcc \
gcc-avr \
libc-dev \
libhidapi-dev \
libudev-dev \
make \
pkgconf \
sdcc \
shellcheck \
xxd
elif [[ "${ID}" =~ "fedora" ]] || [[ "${ID_LIKE}" =~ "fedora" ]]; then
sudo dnf install \
--assumeyes \
avr-gcc \
avr-libc \
avrdude \
clang-tools-extra \
curl \
gcc \
make \
sdcc \
ShellCheck \
systemd-devel \
vim-common
elif [[ "${ID}" =~ "arch" ]] || [[ "${ID_LIKE}" =~ "arch" ]]; then
sudo pacman -S \
--noconfirm \
avr-gcc \
avr-libc \
avrdude \
clang \
curl \
gcc \
make \
pkgconf \
sdcc \
shellcheck \
systemd-libs \
vim
else
msg "Please add support for your distribution to:"
msg "scripts/deps.sh"
exit 1
fi
msg "Initializing submodules"
git submodule update --init --recursive
msg "Installing git hooks"
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"
fi
msg "Installing pinned Rust toolchain and components"
rustup show
if [[ $RUSTUP_NEW_INSTALL = 1 ]]; then
msg "rustup was just installed. Ensure cargo is on the PATH with:"
echo -e " source ~/.cargo/env\n"
fi
msg "\x1B[32mSuccessfully installed dependencies"