Skip to content

Commit a4ad2c3

Browse files
Update linux_runtime_dependencies.sh
1 parent 70d3883 commit a4ad2c3

File tree

1 file changed

+57
-15
lines changed

1 file changed

+57
-15
lines changed

Diff for: scripts/install/linux_runtime_dependencies.sh

+57-15
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,67 @@
11
#!/bin/bash
22

3-
# exit when any command fails on CI
3+
# Exit when any command fails on CI
44
if [[ ! -z "$CI" ]]; then
5-
set -e
5+
set -e
66
fi
77

88
if [[ $EUID -ne 0 ]]; then
9-
echo "This script must be run as root"
10-
exit 1
9+
echo "This script must be run as root"
10+
exit 1
1111
fi
1212

13-
alias apt='apt --option="APT::Acquire::Retries=3"'
14-
apt update
15-
apt install --yes lsb-release g++ make libavcodec-extra libglu1-mesa libegl1 libxkbcommon-x11-dev libxcb-keysyms1 libxcb-image0 libxcb-icccm4 libxcb-randr0 libxcb-render-util0 libxcb-xinerama0 libxcomposite-dev libxtst6 libnss3 libxcb-cursor0
16-
if [[ -z "$DISPLAY" ]]; then
17-
apt install --yes xvfb
18-
fi
19-
20-
UBUNTU_VERSION=$(lsb_release -rs)
21-
if [[ $UBUNTU_VERSION == "22.04" || $UBUNTU_VERSION == "24.04" ]]; then
22-
apt install --yes ffmpeg
13+
# Detect the operating system
14+
if [ -f /etc/os-release ]; then
15+
. /etc/os-release
16+
OS=$ID
17+
VERSION_ID=$VERSION_ID
2318
else
24-
echo "Unsupported Linux version: dependencies may not be completely installed. Only the two latest Ubuntu LTS are supported."
19+
echo "Cannot determine the operating system."
20+
exit 1
2521
fi
22+
23+
# Function to install runtime dependencies on Ubuntu
24+
install_ubuntu_runtime_packages() {
25+
alias apt='apt --option="APT::Acquire::Retries=3"'
26+
apt update
27+
apt install --yes lsb-release g++ make libavcodec-extra libglu1-mesa libegl1 \
28+
libxkbcommon-x11-dev libxcb-keysyms1 libxcb-image0 libxcb-icccm4 libxcb-randr0 \
29+
libxcb-render-util0 libxcb-xinerama0 libxcomposite-dev libxtst6 libnss3 libxcb-cursor0
30+
31+
if [[ -z "$DISPLAY" ]]; then
32+
apt install --yes xvfb
33+
fi
34+
35+
UBUNTU_VERSION=$(lsb_release -rs)
36+
if [[ $UBUNTU_VERSION == "22.04" || $UBUNTU_VERSION == "24.04" ]]; then
37+
apt install --yes ffmpeg
38+
else
39+
echo "Unsupported Linux version: dependencies may not be completely installed. Only the two latest Ubuntu LTS are supported."
40+
fi
41+
}
42+
43+
# Function to install runtime dependencies on Fedora
44+
install_fedora_runtime_packages() {
45+
dnf install -y redhat-lsb-core gcc-c++ make mesa-libGLU libEGL \
46+
xkeyboard-config libxcb libXcomposite libXtst nss xcb-util xcb-util-image \
47+
xcb-util-keysyms xcb-util-renderutil xcb-util-wm xcb-util-cursor \
48+
ffmpeg
49+
50+
if [[ -z "$DISPLAY" ]]; then
51+
dnf install -y xorg-x11-server-Xvfb
52+
fi
53+
}
54+
55+
# Determine the operating system and call the appropriate function
56+
case "$OS" in
57+
ubuntu)
58+
install_ubuntu_runtime_packages
59+
;;
60+
fedora)
61+
install_fedora_runtime_packages
62+
;;
63+
*)
64+
echo "Unsupported operating system: $OS"
65+
exit 1
66+
;;
67+
esac

0 commit comments

Comments
 (0)