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    libzstd-dev
 24    libvulkan1
 25    libgit2-dev
 26    make
 27  )
 28  $maysudo "$apt" install -y "${deps[@]}"
 29  exit 0
 30fi
 31
 32# Fedora, CentOS, RHEL, etc.
 33# https://packages.fedoraproject.org/
 34dnf=$(command -v dnf || true)
 35if [[ -n $dnf ]]; then
 36  deps=(
 37    gcc
 38    g++
 39    alsa-lib-devel
 40    fontconfig-devel
 41    wayland-devel
 42    libxkbcommon-x11-devel
 43    openssl-devel
 44    libzstd-devel
 45    # Perl dependencies are needed for openssl-sys crate see https://docs.rs/openssl/latest/openssl/
 46    perl-FindBin
 47    perl-IPC-Cmd
 48    perl-File-Compare
 49    perl-File-Copy
 50    vulkan-loader
 51  )
 52
 53  # libxkbcommon-x11-devel is in the crb repo on RHEL and CentOS, not needed for Fedora
 54  if ! grep -q "Fedora" /etc/redhat-release; then
 55    $maysudo "$dnf" config-manager --set-enabled crb
 56  fi
 57
 58  $maysudo "$dnf" install -y "${deps[@]}"
 59  exit 0
 60fi
 61
 62# openSUSE
 63# https://software.opensuse.org/
 64zyp=$(command -v zypper || true)
 65if [[ -n $zyp ]]; then
 66  deps=(
 67    alsa-devel
 68    fontconfig-devel
 69    wayland-devel
 70    libxkbcommon-x11-devel
 71    openssl-devel
 72    libzstd-devel
 73    libvulkan1
 74  )
 75  $maysudo "$zyp" install -y "${deps[@]}"
 76  exit 0
 77fi
 78
 79# Arch, Manjaro, etc.
 80# https://archlinux.org/packages
 81pacman=$(command -v pacman || true)
 82if [[ -n $pacman ]]; then
 83  deps=(
 84    alsa-lib
 85    fontconfig
 86    wayland
 87    libxkbcommon-x11
 88    openssl
 89    zstd
 90    pkgconf
 91  )
 92  $maysudo "$pacman" -S --needed --noconfirm "${deps[@]}"
 93  exit 0
 94fi
 95
 96# Void
 97# https://voidlinux.org/packages/
 98xbps=$(command -v xbps-install || true)
 99if [[ -n $xbps ]]; then
100  deps=(
101    alsa-lib-devel
102    fontconfig-devel
103    libxcb-devel
104    libxkbcommon-devel
105    libzstd-devel
106    openssl-devel
107    wayland-devel
108    vulkan-loader
109  )
110  $maysudo "$xbps" -Syu "${deps[@]}"
111  exit 0
112fi
113
114# Gentoo
115# https://packages.gentoo.org/
116emerge=$(command -v emerge || true)
117if [[ -n $emerge ]]; then
118  deps=(
119    app-arch/zstd
120    dev-libs/openssl
121    dev-libs/wayland
122    media-libs/alsa-lib
123    media-libs/fontconfig
124    media-libs/vulkan-loader
125    x11-libs/libxcb
126    x11-libs/libxkbcommon
127  )
128  $maysudo "$emerge" -u "${deps[@]}"
129  exit 0
130fi
131
132echo "Unsupported Linux distribution in script/linux"