From a1fa8049cc6a5009a257355d2138d9727e91754e Mon Sep 17 00:00:00 2001
From: Libretto <>
Date: Sun, 21 Apr 2024 22:31:32 +0200
Subject: [PATCH] Add build dependencies for more distros

---
 automation_tools/install_dependencies.sh     | 29 ++++++++++++++++++--
 developer_toolbox/build_retrodeck_locally.sh |  3 --
 2 files changed, 26 insertions(+), 6 deletions(-)

diff --git a/automation_tools/install_dependencies.sh b/automation_tools/install_dependencies.sh
index 91503927..66edb4a6 100755
--- a/automation_tools/install_dependencies.sh
+++ b/automation_tools/install_dependencies.sh
@@ -1,6 +1,29 @@
 #!/bin/bash
-# This scritp is installing the required dependencies to correctly run the pipeline and buold the flatpak
+# This script is installing the required dependencies to correctly run the pipeline and build the flatpak
+
+# rpm-ostree must be checked before dnf because a dnf (wrapper) command also works on rpm-ostree distros (not what we want)
+for pkg_manager in apt pacman rpm-ostree dnf; do
+  command -v "$pkg_manager" &> /dev/null && result="$pkg_manager" && break
+done
+
+case $result in
+  apt)
+    sudo apt install -y flatpak flatpak-builder p7zip-full xmlstarlet bzip2 curl jq
+    ;;
+  pacman)
+    sudo pacman -S --noconfirm flatpak flatpak-builder p7zip xmlstarlet bzip2
+    ;;
+  rpm-ostree)
+    echo "When using a distro with rpm-ostree, you shouldn't build directly on the host. Try using a distrobox."
+    exit 1
+    ;;
+  dnf)
+    sudo dnf install -y flatpak flatpak-builder p7zip p7zip-plugins xmlstarlet bzip2 curl
+    ;;
+  *)
+    echo "Package manager $result not supported. Please open an issue."
+    ;;
+esac
 
-sudo apt install -y flatpak flatpak-builder p7zip-full xmlstarlet bzip2 curl jq
 flatpak remote-add --user --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
-flatpak remote-add --user --if-not-exists flathub-beta https://flathub.org/beta-repo/flathub-beta.flatpakrepo
\ No newline at end of file
+flatpak remote-add --user --if-not-exists flathub-beta https://flathub.org/beta-repo/flathub-beta.flatpakrepo
diff --git a/developer_toolbox/build_retrodeck_locally.sh b/developer_toolbox/build_retrodeck_locally.sh
index 9682e3bd..85b9e90e 100755
--- a/developer_toolbox/build_retrodeck_locally.sh
+++ b/developer_toolbox/build_retrodeck_locally.sh
@@ -2,9 +2,6 @@
 
 # WARNING: run this script from the project root folder, not from here!!
 
-# TODO: FEDORA
-# sudo dnf install -y flatpak flatpak-builder p7zip p7zip-plugins xmlstarlet bzip2 curl
-
 git submodule update --init --recursive
 
 export GITHUB_WORKSPACE="."