2024-05-09 21:44:31 +00:00
|
|
|
#!/usr/bin/env bash
|
2024-03-19 18:22:26 +00:00
|
|
|
|
2024-09-30 21:46:21 +00:00
|
|
|
set -xeuo pipefail
|
2024-01-30 02:04:15 +00:00
|
|
|
|
2024-09-30 21:46:21 +00:00
|
|
|
# if root or if sudo/unavailable, define an empty variable
|
|
|
|
if [ "$(id -u)" -eq 0 ]
|
|
|
|
then maysudo=''
|
|
|
|
else maysudo="$(command -v sudo || command -v doas || true)"
|
|
|
|
fi
|
2024-03-21 03:00:02 +00:00
|
|
|
|
2024-09-30 21:46:21 +00:00
|
|
|
function finalize {
|
|
|
|
# after packages install (curl, etc), get the rust toolchain
|
|
|
|
which rustup > /dev/null 2>&1 || curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
|
|
|
|
# verify the mold situation
|
|
|
|
if ! command -v mold >/dev/null 2>&1; then
|
|
|
|
echo "Warning: Mold binaries are unavailable on your system." >&2
|
|
|
|
echo " Builds will be slower without mold. Try: scripts/install-mold" >&2
|
|
|
|
fi
|
|
|
|
echo "Finished installing Linux dependencies with script/linux"
|
|
|
|
}
|
2024-01-30 02:04:15 +00:00
|
|
|
|
2024-09-30 21:46:21 +00:00
|
|
|
# Ubuntu, Debian, Mint, Kali, Pop!_OS, Raspbian, etc.
|
2024-01-30 02:04:15 +00:00
|
|
|
apt=$(command -v apt-get || true)
|
|
|
|
if [[ -n $apt ]]; then
|
2024-02-05 07:08:05 +00:00
|
|
|
deps=(
|
2024-04-30 22:01:07 +00:00
|
|
|
gcc
|
|
|
|
g++
|
2024-02-05 07:08:05 +00:00
|
|
|
libasound2-dev
|
|
|
|
libfontconfig-dev
|
2024-02-14 22:50:11 +00:00
|
|
|
libwayland-dev
|
2024-02-15 19:58:47 +00:00
|
|
|
libxkbcommon-x11-dev
|
2024-02-28 23:06:11 +00:00
|
|
|
libssl-dev
|
2024-03-03 19:21:36 +00:00
|
|
|
libzstd-dev
|
2024-03-11 15:29:06 +00:00
|
|
|
libvulkan1
|
2024-04-22 19:05:12 +00:00
|
|
|
libgit2-dev
|
2024-06-06 03:58:37 +00:00
|
|
|
make
|
2024-09-17 18:07:50 +00:00
|
|
|
cmake
|
2024-06-12 21:16:05 +00:00
|
|
|
clang
|
2024-06-13 14:36:18 +00:00
|
|
|
jq
|
2024-09-30 21:46:21 +00:00
|
|
|
git
|
|
|
|
curl
|
2024-06-13 14:36:18 +00:00
|
|
|
gettext-base
|
2024-06-14 02:05:58 +00:00
|
|
|
elfutils
|
2024-06-21 23:32:32 +00:00
|
|
|
libsqlite3-dev
|
2024-02-05 07:08:05 +00:00
|
|
|
)
|
2024-09-30 21:46:21 +00:00
|
|
|
if (grep -qP 'PRETTY_NAME="(.+24\.04)' /etc/os-release); then
|
|
|
|
deps+=( mold libstdc++-14-dev )
|
|
|
|
elif (grep -qP 'PRETTY_NAME="((Debian|Raspbian).+12|.+22\.04)' /etc/os-release); then
|
|
|
|
deps+=( mold libstdc++-12-dev )
|
|
|
|
elif (grep -qP 'PRETTY_NAME="((Debian|Raspbian).+11|.+20\.04)' /etc/os-release); then
|
|
|
|
deps+=( libstdc++-10-dev )
|
2024-09-30 21:02:19 +00:00
|
|
|
fi
|
|
|
|
|
2024-09-18 18:28:00 +00:00
|
|
|
$maysudo "$apt" update
|
2024-01-30 02:04:15 +00:00
|
|
|
$maysudo "$apt" install -y "${deps[@]}"
|
2024-09-30 21:46:21 +00:00
|
|
|
finalize
|
2024-01-30 02:04:15 +00:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2024-09-30 21:46:21 +00:00
|
|
|
# Fedora, CentOS, RHEL, Alma, Amazon 2023, Oracle, etc.
|
2024-01-30 02:04:15 +00:00
|
|
|
dnf=$(command -v dnf || true)
|
2024-09-30 21:46:21 +00:00
|
|
|
# Old Redhat (yum only): Amazon Linux 2, Oracle Linux 7, etc.
|
|
|
|
yum=$(command -v yum || true)
|
|
|
|
|
|
|
|
if [[ -n $dnf ]] || [[ -n $yum ]]; then
|
|
|
|
pkg_cmd="${dnf:-${yum}}"
|
2024-02-05 07:08:05 +00:00
|
|
|
deps=(
|
2024-03-21 03:00:02 +00:00
|
|
|
gcc
|
2024-06-12 21:16:05 +00:00
|
|
|
clang
|
2024-09-17 18:07:50 +00:00
|
|
|
cmake
|
2024-02-05 07:08:05 +00:00
|
|
|
alsa-lib-devel
|
|
|
|
fontconfig-devel
|
2024-02-14 22:50:11 +00:00
|
|
|
wayland-devel
|
2024-02-15 19:58:47 +00:00
|
|
|
libxkbcommon-x11-devel
|
2024-02-21 21:57:39 +00:00
|
|
|
openssl-devel
|
2024-03-03 19:21:36 +00:00
|
|
|
libzstd-devel
|
2024-03-11 15:29:06 +00:00
|
|
|
vulkan-loader
|
2024-06-21 23:32:32 +00:00
|
|
|
sqlite-devel
|
2024-09-30 21:46:21 +00:00
|
|
|
jq
|
|
|
|
git
|
|
|
|
tar
|
2024-02-05 07:08:05 +00:00
|
|
|
)
|
2024-09-30 21:46:21 +00:00
|
|
|
# perl used for building openssl-sys crate. See: https://docs.rs/openssl/latest/openssl/
|
|
|
|
if grep -qP '^ID="(fedora)' /etc/os-release; then
|
|
|
|
deps+=(
|
|
|
|
perl-FindBin
|
|
|
|
perl-IPC-Cmd
|
|
|
|
perl-File-Compare
|
|
|
|
perl-File-Copy
|
|
|
|
mold
|
|
|
|
)
|
2024-10-06 18:47:48 +00:00
|
|
|
elif grep -qP '^ID="(rhel|rocky|alma|centos|ol)' /etc/os-release; then
|
2024-09-30 21:46:21 +00:00
|
|
|
deps+=( perl-interpreter )
|
|
|
|
fi
|
2024-03-25 18:14:11 +00:00
|
|
|
|
2024-09-30 21:46:21 +00:00
|
|
|
# gcc-c++ is g++ on RHEL8 and 8.x clones
|
|
|
|
if grep -qP '^ID="(rhel|rocky|alma|centos|ol)' /etc/os-release \
|
|
|
|
&& grep -qP '^VERSION_ID="8' /etc/os-release; then
|
|
|
|
deps+=( gcc-c++ )
|
|
|
|
else
|
|
|
|
deps+=( g++ )
|
|
|
|
fi
|
|
|
|
|
|
|
|
# libxkbcommon-x11-devel is in a non-default repo on RHEL 8.x/9.x (except on AmazonLinux)
|
2024-10-06 18:47:48 +00:00
|
|
|
if grep -qP '^VERSION_ID="(8|9)' /etc/os-release && grep -qP '^ID="(rhel|rocky|centos|alma|ol)' /etc/os-release; then
|
2024-09-30 21:46:21 +00:00
|
|
|
$maysudo dnf install -y 'dnf-command(config-manager)'
|
|
|
|
if grep -qP '^PRETTY_NAME="(AlmaLinux 8|Rocky Linux 8)' /etc/os-release; then
|
|
|
|
$maysudo dnf config-manager --set-enabled powertools
|
|
|
|
elif grep -qP '^PRETTY_NAME="((AlmaLinux|Rocky|CentOS Stream) 9|Red Hat.+(8|9))' /etc/os-release; then
|
|
|
|
$maysudo dnf config-manager --set-enabled crb
|
|
|
|
elif grep -qP '^PRETTY_NAME="Oracle Linux Server 8' /etc/os-release; then
|
|
|
|
$maysudo dnf config-manager --set-enabled ol8_codeready_builder
|
|
|
|
elif grep -qP '^PRETTY_NAME="Oracle Linux Server 9' /etc/os-release; then
|
|
|
|
$maysudo dnf config-manager --set-enabled ol9_codeready_builder
|
|
|
|
else
|
|
|
|
echo "Unexpected distro" && grep 'PRETTY_NAME' /etc/os-release && exit 1
|
|
|
|
fi
|
2024-03-25 18:14:11 +00:00
|
|
|
fi
|
2024-03-21 03:00:02 +00:00
|
|
|
|
2024-09-30 21:46:21 +00:00
|
|
|
$maysudo $pkg_cmd install -y "${deps[@]}"
|
|
|
|
finalize
|
2024-01-30 02:04:15 +00:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2024-05-27 00:14:09 +00:00
|
|
|
# openSUSE
|
2024-02-21 23:01:33 +00:00
|
|
|
# https://software.opensuse.org/
|
|
|
|
zyp=$(command -v zypper || true)
|
|
|
|
if [[ -n $zyp ]]; then
|
|
|
|
deps=(
|
2024-06-13 17:45:39 +00:00
|
|
|
gcc
|
|
|
|
gcc-c++
|
|
|
|
clang
|
|
|
|
make
|
2024-09-17 18:07:50 +00:00
|
|
|
cmake
|
2024-02-21 23:01:33 +00:00
|
|
|
alsa-devel
|
|
|
|
fontconfig-devel
|
|
|
|
wayland-devel
|
|
|
|
libxkbcommon-x11-devel
|
|
|
|
openssl-devel
|
2024-03-03 19:21:36 +00:00
|
|
|
libzstd-devel
|
2024-05-27 00:14:09 +00:00
|
|
|
libvulkan1
|
2024-06-21 23:32:32 +00:00
|
|
|
sqlite3-devel
|
2024-09-30 21:46:21 +00:00
|
|
|
jq
|
|
|
|
git
|
|
|
|
tar
|
|
|
|
gzip
|
2024-02-21 23:01:33 +00:00
|
|
|
)
|
|
|
|
$maysudo "$zyp" install -y "${deps[@]}"
|
2024-09-30 21:46:21 +00:00
|
|
|
finalize
|
2024-02-21 23:01:33 +00:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2024-01-30 02:04:15 +00:00
|
|
|
# Arch, Manjaro, etc.
|
2024-02-05 07:08:05 +00:00
|
|
|
# https://archlinux.org/packages
|
2024-01-30 02:04:15 +00:00
|
|
|
pacman=$(command -v pacman || true)
|
|
|
|
if [[ -n $pacman ]]; then
|
2024-02-05 07:08:05 +00:00
|
|
|
deps=(
|
2024-06-13 17:45:39 +00:00
|
|
|
gcc
|
|
|
|
clang
|
2024-09-17 18:07:50 +00:00
|
|
|
cmake
|
2024-02-05 07:08:05 +00:00
|
|
|
alsa-lib
|
|
|
|
fontconfig
|
2024-02-14 22:50:11 +00:00
|
|
|
wayland
|
2024-06-12 20:16:27 +00:00
|
|
|
libgit2
|
2024-02-15 19:58:47 +00:00
|
|
|
libxkbcommon-x11
|
2024-02-21 21:57:39 +00:00
|
|
|
openssl
|
2024-03-03 21:26:09 +00:00
|
|
|
zstd
|
2024-05-06 20:21:54 +00:00
|
|
|
pkgconf
|
2024-06-13 07:47:37 +00:00
|
|
|
mold
|
2024-06-21 23:32:32 +00:00
|
|
|
sqlite
|
2024-06-27 15:58:53 +00:00
|
|
|
jq
|
2024-09-30 21:46:21 +00:00
|
|
|
git
|
2024-02-05 07:08:05 +00:00
|
|
|
)
|
2024-09-30 21:46:21 +00:00
|
|
|
$maysudo "$pacman" -Syu --needed --noconfirm "${deps[@]}"
|
|
|
|
finalize
|
2024-01-30 02:04:15 +00:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2024-03-02 00:47:59 +00:00
|
|
|
# Void
|
|
|
|
# https://voidlinux.org/packages/
|
|
|
|
xbps=$(command -v xbps-install || true)
|
|
|
|
if [[ -n $xbps ]]; then
|
|
|
|
deps=(
|
2024-09-17 00:46:49 +00:00
|
|
|
gettext-devel
|
|
|
|
clang
|
2024-09-17 18:07:50 +00:00
|
|
|
cmake
|
2024-09-17 00:46:49 +00:00
|
|
|
jq
|
|
|
|
elfutils-devel
|
|
|
|
gcc
|
2024-03-02 00:47:59 +00:00
|
|
|
alsa-lib-devel
|
|
|
|
fontconfig-devel
|
2024-03-05 17:16:08 +00:00
|
|
|
libxcb-devel
|
2024-03-02 00:47:59 +00:00
|
|
|
libxkbcommon-devel
|
2024-03-03 19:21:36 +00:00
|
|
|
libzstd-devel
|
2024-03-05 17:16:08 +00:00
|
|
|
openssl-devel
|
|
|
|
wayland-devel
|
2024-03-11 15:29:06 +00:00
|
|
|
vulkan-loader
|
2024-06-13 07:47:37 +00:00
|
|
|
mold
|
2024-06-21 23:32:32 +00:00
|
|
|
sqlite-devel
|
2024-03-02 00:47:59 +00:00
|
|
|
)
|
|
|
|
$maysudo "$xbps" -Syu "${deps[@]}"
|
2024-09-30 21:46:21 +00:00
|
|
|
finalize
|
2024-03-02 00:47:59 +00:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2024-04-29 23:08:22 +00:00
|
|
|
# Gentoo
|
|
|
|
# https://packages.gentoo.org/
|
|
|
|
emerge=$(command -v emerge || true)
|
|
|
|
if [[ -n $emerge ]]; then
|
|
|
|
deps=(
|
|
|
|
app-arch/zstd
|
2024-09-30 21:46:21 +00:00
|
|
|
app-misc/jq
|
2024-04-29 23:08:22 +00:00
|
|
|
dev-libs/openssl
|
|
|
|
dev-libs/wayland
|
2024-09-17 18:07:50 +00:00
|
|
|
dev-util/cmake
|
2024-04-29 23:08:22 +00:00
|
|
|
media-libs/alsa-lib
|
|
|
|
media-libs/fontconfig
|
|
|
|
media-libs/vulkan-loader
|
|
|
|
x11-libs/libxcb
|
|
|
|
x11-libs/libxkbcommon
|
2024-06-13 07:47:37 +00:00
|
|
|
sys-devel/mold
|
2024-06-21 23:32:32 +00:00
|
|
|
dev-db/sqlite
|
2024-04-29 23:08:22 +00:00
|
|
|
)
|
|
|
|
$maysudo "$emerge" -u "${deps[@]}"
|
2024-09-30 21:46:21 +00:00
|
|
|
finalize
|
2024-04-29 23:08:22 +00:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2024-01-30 02:04:15 +00:00
|
|
|
echo "Unsupported Linux distribution in script/linux"
|
2024-09-30 21:46:21 +00:00
|
|
|
exit 1
|