linux

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