linux

  1#!/usr/bin/bash
  2
  3set -e
  4
  5# install the wasm toolchain
  6rustup target add wasm32-wasi
  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    libasound2-dev
 17    libfontconfig-dev
 18    libwayland-dev
 19    libxkbcommon-x11-dev
 20    libssl-dev
 21    libzstd-dev
 22    libvulkan1
 23  )
 24  $maysudo "$apt" install -y "${deps[@]}"
 25  exit 0
 26fi
 27
 28# Fedora, CentOS, RHEL, etc.
 29# https://packages.fedoraproject.org/
 30dnf=$(command -v dnf || true)
 31if [[ -n $dnf ]]; then
 32  deps=(
 33    gcc
 34    g++
 35    alsa-lib-devel
 36    fontconfig-devel
 37    wayland-devel
 38    libxkbcommon-x11-devel
 39    openssl-devel
 40    libzstd-devel
 41    vulkan-loader
 42  )
 43  # libxkbcommon-x11-devel is in the crb repo
 44  $maysudo "$dnf" config-manager --set-enabled crb
 45  $maysudo "$dnf" install epel-release epel-next-release
 46
 47  $maysudo "$dnf" install -y "${deps[@]}"
 48  exit 0
 49fi
 50
 51# openSuse
 52# https://software.opensuse.org/
 53zyp=$(command -v zypper || true)
 54if [[ -n $zyp ]]; then
 55  deps=(
 56    alsa-devel
 57    fontconfig-devel
 58    wayland-devel
 59    libxkbcommon-x11-devel
 60    openssl-devel
 61    libzstd-devel
 62    vulkan-loader
 63  )
 64  $maysudo "$zyp" install -y "${deps[@]}"
 65  exit 0
 66fi
 67
 68# Arch, Manjaro, etc.
 69# https://archlinux.org/packages
 70pacman=$(command -v pacman || true)
 71if [[ -n $pacman ]]; then
 72  deps=(
 73    alsa-lib
 74    fontconfig
 75    wayland
 76    libxkbcommon-x11
 77    openssl
 78    zstd
 79  )
 80  $maysudo "$pacman" -S --needed --noconfirm "${deps[@]}"
 81  exit 0
 82fi
 83
 84# Void
 85# https://voidlinux.org/packages/
 86xbps=$(command -v xbps-install || true)
 87if [[ -n $xbps ]]; then
 88  deps=(
 89    alsa-lib-devel
 90    fontconfig-devel
 91    libxcb-devel
 92    libxkbcommon-devel
 93    libzstd-devel
 94    openssl-devel
 95    wayland-devel
 96    vulkan-loader
 97  )
 98  $maysudo "$xbps" -Syu "${deps[@]}"
 99  exit 0
100fi
101
102echo "Unsupported Linux distribution in script/linux"