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