From ca9a84007261037bb715df5a59c618dd22ca9669 Mon Sep 17 00:00:00 2001 From: fiftydinar <65243233+fiftydinar@users.noreply.github.com> Date: Wed, 23 Oct 2024 20:15:54 +0200 Subject: [PATCH] chore(default-flatpaks): Remove flatpaks first & then install --- .../default-flatpaks/v1/system-flatpak-setup | 28 +++++++++---------- .../default-flatpaks/v1/user-flatpak-setup | 28 +++++++++---------- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/modules/default-flatpaks/v1/system-flatpak-setup b/modules/default-flatpaks/v1/system-flatpak-setup index 163175c..c62a502 100755 --- a/modules/default-flatpaks/v1/system-flatpak-setup +++ b/modules/default-flatpaks/v1/system-flatpak-setup @@ -207,6 +207,20 @@ function notify-send-uninstall { sudo -u "$user_name" DBUS_SESSION_BUS_ADDRESS=unix:path="$xdg_runtime_path"/bus notify-send "Flatpak Installer" "Finished uninstall of system flatpaks:\n$REMOVE_LIST" --app-name="Flatpak Installer" -u NORMAL } +# Remove flatpaks in list +if [[ -f $REMOVE_LIST_FILE ]] || [[ -f $USER_REMOVE_LIST_FILE ]]; then + REMOVE_LIST=$(comm -12 <(echo "$COMBINED_REMOVE_LIST" | sort) <(echo "$FLATPAK_LIST" | sort)) + if [[ -n $REMOVE_LIST ]] && [[ ! $NOTIFICATIONS == "true" ]]; then + echo "Removing system flatpaks from config list" + flatpak uninstall --system --noninteractive ${REMOVE_LIST[@]} + elif [[ -n $REMOVE_LIST ]] && [[ $NOTIFICATIONS == "true" ]]; then + echo "Removing system flatpaks from config list" + notify-send-pre-uninstall + flatpak uninstall --system --noninteractive ${REMOVE_LIST[@]} + notify-send-uninstall + fi +fi + # Install flatpaks in list if [[ -f $INSTALL_LIST_FILE ]] || [[ -f $USER_INSTALL_LIST_FILE ]]; then if [[ -n $FLATPAK_LIST ]]; then @@ -232,17 +246,3 @@ if [[ -f $INSTALL_LIST_FILE ]] || [[ -f $USER_INSTALL_LIST_FILE ]]; then fi fi fi - -# Remove flatpaks in list -if [[ -f $REMOVE_LIST_FILE ]] || [[ -f $USER_REMOVE_LIST_FILE ]]; then - REMOVE_LIST=$(comm -12 <(echo "$COMBINED_REMOVE_LIST" | sort) <(echo "$FLATPAK_LIST" | sort)) - if [[ -n $REMOVE_LIST ]] && [[ ! $NOTIFICATIONS == "true" ]]; then - echo "Removing system flatpaks from config list" - flatpak uninstall --system --noninteractive ${REMOVE_LIST[@]} - elif [[ -n $REMOVE_LIST ]] && [[ $NOTIFICATIONS == "true" ]]; then - echo "Removing system flatpaks from config list" - notify-send-pre-uninstall - flatpak uninstall --system --noninteractive ${REMOVE_LIST[@]} - notify-send-uninstall - fi -fi diff --git a/modules/default-flatpaks/v1/user-flatpak-setup b/modules/default-flatpaks/v1/user-flatpak-setup index 5e241e8..b2ef9b8 100755 --- a/modules/default-flatpaks/v1/user-flatpak-setup +++ b/modules/default-flatpaks/v1/user-flatpak-setup @@ -158,6 +158,20 @@ MAINTAINER_REMOVE_LIST=$(comm -23 <(sort "$REMOVE_LIST_FILE") <(sort "$USER_INST COMBINED_INSTALL_LIST=$(cat <(echo "$MAINTAINER_INSTALL_LIST") "$USER_INSTALL_LIST_FILE" | grep -v -E '^#|^$' | awk '!seen[$0]++') COMBINED_REMOVE_LIST=$(cat <(echo "$MAINTAINER_REMOVE_LIST") "$USER_REMOVE_LIST_FILE" | grep -v -E '^#|^$' | awk '!seen[$0]++') +# Remove flatpaks in list +if [[ -f $REMOVE_LIST_FILE ]] || [[ -f $USER_REMOVE_LIST_FILE ]]; then + REMOVE_LIST=$(comm -12 <(echo "$COMBINED_REMOVE_LIST" | sort) <(echo "$FLATPAK_LIST" | sort)) + if [[ -n $REMOVE_LIST ]] && [[ ! $NOTIFICATIONS == "true" ]]; then + echo "Removing user flatpaks from config list" + flatpak uninstall --user --noninteractive ${REMOVE_LIST[@]} + elif [[ -n $REMOVE_LIST ]] && [[ $NOTIFICATIONS == "true" ]]; then + echo "Removing user flatpaks from config list" + notify-send "Flatpak Installer" "Started uninstall of some user flatpaks" --app-name="Flatpak Installer" -u NORMAL + flatpak uninstall --user --noninteractive ${REMOVE_LIST[@]} + notify-send "Flatpak Installer" "Finished uninstall of user flatpaks:\n$REMOVE_LIST" --app-name="Flatpak Installer" -u NORMAL + fi +fi + # Install flatpaks in list if [[ -f $INSTALL_LIST_FILE ]] || [[ -f $USER_INSTALL_LIST_FILE ]]; then if [[ -n $FLATPAK_LIST ]]; then @@ -183,17 +197,3 @@ if [[ -f $INSTALL_LIST_FILE ]] || [[ -f $USER_INSTALL_LIST_FILE ]]; then fi fi fi - -# Remove flatpaks in list -if [[ -f $REMOVE_LIST_FILE ]] || [[ -f $USER_REMOVE_LIST_FILE ]]; then - REMOVE_LIST=$(comm -12 <(echo "$COMBINED_REMOVE_LIST" | sort) <(echo "$FLATPAK_LIST" | sort)) - if [[ -n $REMOVE_LIST ]] && [[ ! $NOTIFICATIONS == "true" ]]; then - echo "Removing user flatpaks from config list" - flatpak uninstall --user --noninteractive ${REMOVE_LIST[@]} - elif [[ -n $REMOVE_LIST ]] && [[ $NOTIFICATIONS == "true" ]]; then - echo "Removing user flatpaks from config list" - notify-send "Flatpak Installer" "Started uninstall of some user flatpaks" --app-name="Flatpak Installer" -u NORMAL - flatpak uninstall --user --noninteractive ${REMOVE_LIST[@]} - notify-send "Flatpak Installer" "Finished uninstall of user flatpaks:\n$REMOVE_LIST" --app-name="Flatpak Installer" -u NORMAL - fi -fi