Support More Linux (#18480)
- Add `script/build-docker` - Add `script/install-cmake` - Add `script/install-mold` - Improve `script/linux` - Add missing dependencies: `jq`, `git`, `tar`, `gzip` as required. - Add check for mold - Fix Redhat 8.x derivatives (RHEL, Centos, Almalinux, Rocky, Oracle, Amazon) - Fix perl libs to be Fedora only - Install the best `libstdc++` available on apt distros - ArchLinux: run `pacman -Syu` to update repos before installing. - Should work on Raspbian (untested) This make it possible to test builds on other distros using docker: ``` ./script/build-docker amazonlinux:2023 ```
This commit is contained in:
parent
432de00e89
commit
3010dfe038
7 changed files with 221 additions and 35 deletions
118
script/linux
118
script/linux
|
@ -1,15 +1,25 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -ex
|
||||
set -xeuo pipefail
|
||||
|
||||
# install the wasm toolchain
|
||||
which rustup > /dev/null 2>&1 || curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
|
||||
# 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
|
||||
|
||||
# if sudo is not installed, define an empty alias
|
||||
maysudo=$(command -v sudo || command -v doas || true)
|
||||
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"
|
||||
}
|
||||
|
||||
# Ubuntu, Debian, etc.
|
||||
# https://packages.ubuntu.com/
|
||||
# Ubuntu, Debian, Mint, Kali, Pop!_OS, Raspbian, etc.
|
||||
apt=$(command -v apt-get || true)
|
||||
if [[ -n $apt ]]; then
|
||||
deps=(
|
||||
|
@ -27,58 +37,88 @@ if [[ -n $apt ]]; then
|
|||
cmake
|
||||
clang
|
||||
jq
|
||||
git
|
||||
curl
|
||||
gettext-base
|
||||
elfutils
|
||||
libsqlite3-dev
|
||||
)
|
||||
# Ubuntu 20.04 / Debian Bullseye (including CI for release)
|
||||
if grep -q "bullseye" /etc/debian_version; then
|
||||
deps+=(
|
||||
libstdc++-10-dev
|
||||
)
|
||||
else
|
||||
deps+=(
|
||||
libstdc++-12-dev
|
||||
mold
|
||||
)
|
||||
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 )
|
||||
fi
|
||||
|
||||
$maysudo "$apt" update
|
||||
$maysudo "$apt" install -y "${deps[@]}"
|
||||
finalize
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Fedora, CentOS, RHEL, etc.
|
||||
# https://packages.fedoraproject.org/
|
||||
# Fedora, CentOS, RHEL, Alma, Amazon 2023, Oracle, etc.
|
||||
dnf=$(command -v dnf || true)
|
||||
if [[ -n $dnf ]]; then
|
||||
# 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}}"
|
||||
deps=(
|
||||
gcc
|
||||
g++
|
||||
clang
|
||||
cmake
|
||||
mold
|
||||
alsa-lib-devel
|
||||
fontconfig-devel
|
||||
wayland-devel
|
||||
libxkbcommon-x11-devel
|
||||
openssl-devel
|
||||
libzstd-devel
|
||||
# Perl dependencies are needed for openssl-sys crate see https://docs.rs/openssl/latest/openssl/
|
||||
perl-FindBin
|
||||
perl-IPC-Cmd
|
||||
perl-File-Compare
|
||||
perl-File-Copy
|
||||
vulkan-loader
|
||||
sqlite-devel
|
||||
jq
|
||||
git
|
||||
tar
|
||||
)
|
||||
|
||||
# libxkbcommon-x11-devel is in the crb repo on RHEL and CentOS, not needed for Fedora
|
||||
if ! grep -q "Fedora" /etc/redhat-release; then
|
||||
$maysudo "$dnf" config-manager --set-enabled crb
|
||||
# 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
|
||||
)
|
||||
elif grep grep -qP '^ID="(rhel|rocky|alma|centos|ol)' /etc/os-release; then
|
||||
deps+=( perl-interpreter )
|
||||
fi
|
||||
|
||||
$maysudo "$dnf" install -y "${deps[@]}"
|
||||
# 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)
|
||||
if grep -qP '^VERSION_ID="(8|9)' && grep -qP '^ID="(rhel|rocky|centos|alma|ol)' /etc/os-release; then
|
||||
$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
|
||||
fi
|
||||
|
||||
$maysudo $pkg_cmd install -y "${deps[@]}"
|
||||
finalize
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
@ -99,10 +139,14 @@ if [[ -n $zyp ]]; then
|
|||
openssl-devel
|
||||
libzstd-devel
|
||||
libvulkan1
|
||||
mold
|
||||
sqlite3-devel
|
||||
jq
|
||||
git
|
||||
tar
|
||||
gzip
|
||||
)
|
||||
$maysudo "$zyp" install -y "${deps[@]}"
|
||||
finalize
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
@ -125,8 +169,10 @@ if [[ -n $pacman ]]; then
|
|||
mold
|
||||
sqlite
|
||||
jq
|
||||
git
|
||||
)
|
||||
$maysudo "$pacman" -S --needed --noconfirm "${deps[@]}"
|
||||
$maysudo "$pacman" -Syu --needed --noconfirm "${deps[@]}"
|
||||
finalize
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
@ -153,6 +199,7 @@ if [[ -n $xbps ]]; then
|
|||
sqlite-devel
|
||||
)
|
||||
$maysudo "$xbps" -Syu "${deps[@]}"
|
||||
finalize
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
@ -162,6 +209,7 @@ emerge=$(command -v emerge || true)
|
|||
if [[ -n $emerge ]]; then
|
||||
deps=(
|
||||
app-arch/zstd
|
||||
app-misc/jq
|
||||
dev-libs/openssl
|
||||
dev-libs/wayland
|
||||
dev-util/cmake
|
||||
|
@ -174,7 +222,9 @@ if [[ -n $emerge ]]; then
|
|||
dev-db/sqlite
|
||||
)
|
||||
$maysudo "$emerge" -u "${deps[@]}"
|
||||
finalize
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "Unsupported Linux distribution in script/linux"
|
||||
exit 1
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue