From 9deec489a03b111be993eafcdccd38234fce158f Mon Sep 17 00:00:00 2001 From: RJ Trujillo Date: Thu, 14 Dec 2023 14:20:54 -0700 Subject: [PATCH] fix(flatpak-manager): Don't install packages that are already present or remove packages that aren't there --- .../shared/usr/bin/bazzite-flatpak-manager | 26 ++++++++++++------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/system_files/desktop/shared/usr/bin/bazzite-flatpak-manager b/system_files/desktop/shared/usr/bin/bazzite-flatpak-manager index 2f4f393d8e..f54c02d58b 100755 --- a/system_files/desktop/shared/usr/bin/bazzite-flatpak-manager +++ b/system_files/desktop/shared/usr/bin/bazzite-flatpak-manager @@ -21,22 +21,30 @@ fi # Ensure Flathub is enabled flatpak remote-modify --system --enable flathub -# Lists of flatpaks +# Installed flatpaks FLATPAK_LIST=$(flatpak list --columns=application) -INSTALL_LIST=$(cat /usr/share/ublue-os/bazzite/flatpak/install) -REMOVE_LIST=$(cat /usr/share/ublue-os/bazzite/flatpak/remove) + +# Flatpak list files +INSTALL_LIST_FILE="/usr/share/ublue-os/bazzite/flatpak/install" +REMOVE_LIST_FILE="/usr/share/ublue-os/bazzite/flatpak/remove" # Install flatpaks in list -if [[ -n $INSTALL_LIST ]]; then - if ! flatpak install --system --noninteractive flathub ${INSTALL_LIST[@]}; then - # exit on error - exit 1 +if [[ -f $INSTALL_LIST_FILE ]]; then + INSTALL_LIST=$(echo $FLATPAK_LIST | grep -vf - $INSTALL_LIST_FILE) + if [[ -n $INSTALL_LIST ]]; then + if ! flatpak install --system --noninteractive flathub ${INSTALL_LIST[@]}; then + # exit on error + exit 1 + fi fi fi # Remove flatpaks in list -if [[ -n $REMOVE_LIST ]]; then - flatpak remove --system --noninteractive ${REMOVE_LIST[@]} +if [[ -f $REMOVE_LIST_FILE ]]; then + REMOVE_LIST=$(echo $FLATPAK_LIST | grep -f - $REMOVE_LIST_FILE) + if [[ -n $REMOVE_LIST ]]; then + flatpak remove --system --noninteractive ${REMOVE_LIST[@]} + fi fi mkdir -p /etc/bazzite