mirror of
https://github.com/zed-industries/zed.git
synced 2026-11-19 06:59:22 +01:00
5db8ed0c65
Cherry-pick of #66841 to preview ---- ## Summary Add the Clarkson Ubuntu mirror fallback used by Delta, restricted to GitHub Actions. Append it to existing Namespace archive and security mirror lists before installing Linux dependencies. This intentionally does not rewrite direct source URLs. CI will test whether the existing runner configuration is sufficient. Local developer runs remain unchanged. ## Validation - `bash -n script/linux` - `git diff --check` - Real-runner dependency installation is being checked by PR CI. Release Notes: - N/A Co-authored-by: Cole Miller <cole@zed.dev>
307 lines
7.9 KiB
Bash
Executable File
307 lines
7.9 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
set -xeuo pipefail
|
|
|
|
# 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
|
|
|
|
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
|
|
cat <<EOF
|
|
Finished installing Linux dependencies with script/linux
|
|
EOF
|
|
}
|
|
|
|
# Ubuntu, Debian, Mint, Kali, Pop!_OS, Raspbian, etc.
|
|
apt=$(command -v apt-get || true)
|
|
if [[ -n $apt ]]; then
|
|
if [[ "${GITHUB_ACTIONS:-}" == "true" ]]; then
|
|
# Namespace's Ubuntu sources use these mirror lists; other runners may not.
|
|
for mirror_file in /etc/apt/apt-mirrors.txt /etc/apt/apt-security-mirrors.txt; do
|
|
if [[ -f "$mirror_file" ]] && ! grep -Fxq 'https://mirror.clarkson.edu/ubuntu/' "$mirror_file"; then
|
|
printf '\n%s\n' 'https://mirror.clarkson.edu/ubuntu/' | \
|
|
$maysudo tee -a "$mirror_file" > /dev/null
|
|
fi
|
|
done
|
|
fi
|
|
|
|
deps=(
|
|
gcc
|
|
g++
|
|
libasound2-dev
|
|
libfontconfig-dev
|
|
libgit2-dev
|
|
libglib2.0-dev
|
|
libssl-dev
|
|
libva-dev
|
|
libvulkan1
|
|
libwayland-dev
|
|
libx11-xcb-dev
|
|
libxkbcommon-x11-dev
|
|
libzstd-dev
|
|
make
|
|
cmake
|
|
clang
|
|
lld
|
|
llvm
|
|
jq
|
|
git
|
|
curl
|
|
gettext-base
|
|
elfutils
|
|
libsqlite3-dev
|
|
musl-tools
|
|
musl-dev
|
|
build-essential
|
|
pipewire
|
|
xdg-desktop-portal
|
|
)
|
|
if (grep -qP 'PRETTY_NAME="(Debian|Raspbian).+13' /etc/os-release); then
|
|
# libstdc++-14-dev is in build-essential
|
|
true
|
|
elif (grep -qP 'PRETTY_NAME="(Linux Mint 22|.+24\.(04|10))' /etc/os-release); then
|
|
deps+=( libstdc++-14-dev )
|
|
elif (grep -qP 'PRETTY_NAME="((Debian|Raspbian).+12|Linux Mint 21|.+22\.04)' /etc/os-release); then
|
|
deps+=( libstdc++-12-dev )
|
|
elif (grep -qP 'PRETTY_NAME="((Debian|Raspbian).+11|Linux Mint 20|.+20\.04)' /etc/os-release); then
|
|
# Ubuntu 20.04 ships clang-10 and libstdc++-10 which lack adequate C++20
|
|
# support for building webrtc-sys (requires -std=c++20, lambdas in
|
|
# unevaluated contexts from clang 17+, and working std::ranges in the
|
|
# stdlib).
|
|
# Note: the prebuilt libwebrtc.a is compiled with libstdc++, so we must
|
|
# use libstdc++ (not libc++) to avoid ABI mismatches at link time.
|
|
|
|
# libstdc++-11-dev (headers with working pointer_traits/contiguous_range)
|
|
# is only available from the ubuntu-toolchain-r PPA. Add the source list
|
|
# and GPG key manually instead of using add-apt-repository, whose HKP
|
|
# keyserver lookups (port 11371) frequently time out in CI.
|
|
$maysudo "$apt" install -y curl gnupg
|
|
codename=$(lsb_release -cs)
|
|
# Launchpad's HTTPS frontend can return 503 while HTTP still works. APT's
|
|
# mirror transport falls back for both indexes and packages, preserving
|
|
# signature and hash verification.
|
|
printf '%s\tpriority:%s\n' \
|
|
'https://ppa.launchpadcontent.net/ubuntu-toolchain-r/test/ubuntu' 1 \
|
|
'http://ppa.launchpadcontent.net/ubuntu-toolchain-r/test/ubuntu' 2 | \
|
|
$maysudo tee /etc/apt/ubuntu-toolchain-r-test.mirrors > /dev/null
|
|
echo "deb mirror+file:/etc/apt/ubuntu-toolchain-r-test.mirrors $codename main" | \
|
|
$maysudo tee /etc/apt/sources.list.d/ubuntu-toolchain-r-test.list > /dev/null
|
|
curl -fsSL 'https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x1E9377A2BA9EF27F' | \
|
|
sed -n '/-----BEGIN PGP PUBLIC KEY BLOCK-----/,/-----END PGP PUBLIC KEY BLOCK-----/p' | \
|
|
$maysudo gpg --dearmor -o /etc/apt/trusted.gpg.d/ubuntu-toolchain-r-test.gpg
|
|
deps+=( clang-18 lld-18 libstdc++-11-dev )
|
|
fi
|
|
|
|
$maysudo "$apt" update
|
|
$maysudo "$apt" install -y "${deps[@]}"
|
|
|
|
finalize
|
|
exit 0
|
|
fi
|
|
|
|
# Fedora, CentOS, RHEL, Alma, Amazon 2023, Oracle, etc.
|
|
dnf=$(command -v dnf || true)
|
|
# 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=(
|
|
musl-gcc
|
|
gcc
|
|
clang
|
|
lld
|
|
cmake
|
|
alsa-lib-devel
|
|
fontconfig-devel
|
|
glib2-devel
|
|
libva-devel
|
|
wayland-devel
|
|
libxcb-devel
|
|
libxkbcommon-x11-devel
|
|
openssl-devel
|
|
libzstd-devel
|
|
vulkan-loader
|
|
sqlite-devel
|
|
pipewire
|
|
xdg-desktop-portal
|
|
jq
|
|
git
|
|
tar
|
|
)
|
|
# 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
|
|
)
|
|
elif grep -qP '^ID="?(rhel|rocky|alma|centos|ol)' /etc/os-release; then
|
|
deps+=( perl-interpreter )
|
|
fi
|
|
|
|
# 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)' /etc/os-release && 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
|
|
|
|
# openSUSE
|
|
# https://software.opensuse.org/
|
|
zyp=$(command -v zypper || true)
|
|
if [[ -n $zyp ]]; then
|
|
deps=(
|
|
alsa-devel
|
|
clang
|
|
lld
|
|
cmake
|
|
fontconfig-devel
|
|
gcc
|
|
libva-devel
|
|
gcc-c++
|
|
glib2-devel
|
|
git
|
|
gzip
|
|
jq
|
|
libvulkan1
|
|
libX11-devel
|
|
libxcb-devel
|
|
libxkbcommon-devel
|
|
libxkbcommon-x11-devel
|
|
libzstd-devel
|
|
make
|
|
openssl-devel
|
|
sqlite3-devel
|
|
tar
|
|
wayland-devel
|
|
xcb-util-devel
|
|
pipewire
|
|
xdg-desktop-portal
|
|
)
|
|
$maysudo "$zyp" install -y "${deps[@]}"
|
|
finalize
|
|
exit 0
|
|
fi
|
|
|
|
# Arch, Manjaro, etc.
|
|
# https://archlinux.org/packages
|
|
pacman=$(command -v pacman || true)
|
|
if [[ -n $pacman ]]; then
|
|
deps=(
|
|
gcc
|
|
clang
|
|
lld
|
|
musl
|
|
cmake
|
|
alsa-lib
|
|
fontconfig
|
|
glib2
|
|
libva
|
|
wayland
|
|
libgit2
|
|
libxcb
|
|
libxkbcommon-x11
|
|
llvm
|
|
openssl
|
|
zstd
|
|
pkgconf
|
|
sqlite
|
|
pipewire
|
|
xdg-desktop-portal
|
|
jq
|
|
git
|
|
)
|
|
$maysudo "$pacman" -Syu --needed --noconfirm "${deps[@]}"
|
|
finalize
|
|
exit 0
|
|
fi
|
|
|
|
# Void
|
|
# https://voidlinux.org/packages/
|
|
xbps=$(command -v xbps-install || true)
|
|
if [[ -n $xbps ]]; then
|
|
deps=(
|
|
gettext-devel
|
|
clang
|
|
lld
|
|
cmake
|
|
jq
|
|
elfutils-devel
|
|
gcc
|
|
alsa-lib-devel
|
|
fontconfig-devel
|
|
glib-devel
|
|
libva-devel
|
|
libxcb-devel
|
|
libxkbcommon-devel
|
|
libzstd-devel
|
|
openssl-devel
|
|
wayland-devel
|
|
vulkan-loader
|
|
sqlite-devel
|
|
pipewire
|
|
xdg-desktop-portal
|
|
)
|
|
$maysudo "$xbps" -Syu "${deps[@]}"
|
|
finalize
|
|
exit 0
|
|
fi
|
|
|
|
# Gentoo
|
|
# https://packages.gentoo.org/
|
|
emerge=$(command -v emerge || true)
|
|
if [[ -n $emerge ]]; then
|
|
deps=(
|
|
app-arch/zstd
|
|
app-misc/jq
|
|
dev-libs/glib
|
|
dev-libs/openssl
|
|
dev-libs/wayland
|
|
dev-build/cmake
|
|
llvm-core/lld
|
|
media-libs/alsa-lib
|
|
media-libs/fontconfig
|
|
media-libs/libva
|
|
media-libs/vulkan-loader
|
|
x11-libs/libxcb
|
|
x11-libs/libxkbcommon
|
|
dev-db/sqlite
|
|
media-video/pipewire
|
|
sys-apps/xdg-desktop-portal
|
|
)
|
|
$maysudo "$emerge" -u "${deps[@]}"
|
|
finalize
|
|
exit 0
|
|
fi
|
|
|
|
echo "Unsupported Linux distribution in script/linux"
|
|
exit 1
|