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