linux

  1#!/usr/bin/env bash
  2
  3set -ex
  4
  5# install the wasm toolchain
  6which rustup > /dev/null 2>&1 || curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
  7
  8# if sudo is not installed, define an empty alias
  9maysudo=$(command -v sudo || command -v doas || true)
 10
 11# Ubuntu, Debian, etc.
 12# https://packages.ubuntu.com/
 13apt=$(command -v apt-get || true)
 14if [[ -n $apt ]]; then
 15  deps=(
 16    gcc
 17    g++
 18    libasound2-dev
 19    libfontconfig-dev
 20    libwayland-dev
 21    libxkbcommon-x11-dev
 22    libssl-dev
 23    libstdc++-12-dev
 24    libzstd-dev
 25    libvulkan1
 26    libgit2-dev
 27    make
 28  )
 29  $maysudo "$apt" install -y "${deps[@]}"
 30  exit 0
 31fi
 32
 33# Fedora, CentOS, RHEL, etc.
 34# https://packages.fedoraproject.org/
 35dnf=$(command -v dnf || true)
 36if [[ -n $dnf ]]; then
 37  deps=(
 38    gcc
 39    g++
 40    alsa-lib-devel
 41    fontconfig-devel
 42    wayland-devel
 43    libxkbcommon-x11-devel
 44    openssl-devel
 45    libzstd-devel
 46    # Perl dependencies are needed for openssl-sys crate see https://docs.rs/openssl/latest/openssl/
 47    perl-FindBin
 48    perl-IPC-Cmd
 49    perl-File-Compare
 50    perl-File-Copy
 51    vulkan-loader
 52  )
 53
 54  # libxkbcommon-x11-devel is in the crb repo on RHEL and CentOS, not needed for Fedora
 55  if ! grep -q "Fedora" /etc/redhat-release; then
 56    $maysudo "$dnf" config-manager --set-enabled crb
 57  fi
 58
 59  $maysudo "$dnf" install -y "${deps[@]}"
 60  exit 0
 61fi
 62
 63# openSUSE
 64# https://software.opensuse.org/
 65zyp=$(command -v zypper || true)
 66if [[ -n $zyp ]]; then
 67  deps=(
 68    alsa-devel
 69    fontconfig-devel
 70    wayland-devel
 71    libxkbcommon-x11-devel
 72    openssl-devel
 73    libzstd-devel
 74    libvulkan1
 75  )
 76  $maysudo "$zyp" install -y "${deps[@]}"
 77  exit 0
 78fi
 79
 80# Arch, Manjaro, etc.
 81# https://archlinux.org/packages
 82pacman=$(command -v pacman || true)
 83if [[ -n $pacman ]]; then
 84  deps=(
 85    alsa-lib
 86    fontconfig
 87    wayland
 88    libxkbcommon-x11
 89    openssl
 90    zstd
 91    pkgconf
 92  )
 93  $maysudo "$pacman" -S --needed --noconfirm "${deps[@]}"
 94  exit 0
 95fi
 96
 97# Void
 98# https://voidlinux.org/packages/
 99xbps=$(command -v xbps-install || true)
100if [[ -n $xbps ]]; then
101  deps=(
102    alsa-lib-devel
103    fontconfig-devel
104    libxcb-devel
105    libxkbcommon-devel
106    libzstd-devel
107    openssl-devel
108    wayland-devel
109    vulkan-loader
110  )
111  $maysudo "$xbps" -Syu "${deps[@]}"
112  exit 0
113fi
114
115# Gentoo
116# https://packages.gentoo.org/
117emerge=$(command -v emerge || true)
118if [[ -n $emerge ]]; then
119  deps=(
120    app-arch/zstd
121    dev-libs/openssl
122    dev-libs/wayland
123    media-libs/alsa-lib
124    media-libs/fontconfig
125    media-libs/vulkan-loader
126    x11-libs/libxcb
127    x11-libs/libxkbcommon
128  )
129  $maysudo "$emerge" -u "${deps[@]}"
130  exit 0
131fi
132
133echo "Unsupported Linux distribution in script/linux"