|
1 | 1 | #!/bin/bash
|
2 | 2 |
|
3 |
| -# exit when any command fails on CI |
| 3 | +# Exit when any command fails on CI |
4 | 4 | if [[ ! -z "$CI" ]]; then
|
5 |
| - set -e |
| 5 | + set -e |
6 | 6 | fi
|
7 | 7 |
|
8 | 8 | 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 |
11 | 11 | fi
|
12 | 12 |
|
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 |
23 | 18 | 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 |
25 | 21 | 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