Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: flatpak-manager exit and retry on failure #583

Merged
merged 3 commits into from
Oct 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions usr/bin/ublue-system-flatpak-manager
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ if [[ -f $VER_FILE && $VER = $VER_RAN ]]; then
exit 0
fi

notify-send "Flatpak installer" "Currently installing system flatpaks" --app-name="Flatpak installer" -u NORMAL

# Remove fedora flatpak repo
if grep -qz 'fedora' <<< $(flatpak remotes); then
flatpak remote-delete --user fedora --force
Expand All @@ -27,13 +25,14 @@ REMOVE_LIST=$(cat /etc/flatpak/system/remove)
if [[ -n $INSTALL_LIST ]]; then
for flatpak in $INSTALL_LIST; do
if grep -qvz $flatpak <<< $FLATPAK_LIST; then
flatpak install --system --noninteractive flathub $flatpak
if ! flatpak install --system --noninteractive flathub $flatpak; then
# exit on error
exit 1
fi
fi
done
fi

notify-send "Flatpak installer" "Finished installing system flatpaks" --app-name="Flatpak installer" -u NORMAL

# Remove flatpaks in list
if [[ -n $REMOVE_LIST ]]; then
for flatpak in $REMOVE_LIST; do
Expand All @@ -51,12 +50,17 @@ if grep -qz 'fedora' <<< $(flatpak remotes); then

FEDORA_FLATPAKS=$(flatpak list --columns=application,origin | grep -w 'fedora' | awk '{print $1}')
for flatpak in $FEDORA_FLATPAKS; do
flatpak remove --system --noninteractive $flatpak
if ! flatpak remove --system --noninteractive $flatpak; then
# exit on error
exit 1
fi
done
fi

# Disable the system variant of the flathub repo
flatpak remote-modify flathub --disable --system

notify-send "Flatpak installer" "Finished installing system flatpaks" --app-name="Flatpak installer" -u NORMAL

mkdir -p /etc/ublue
echo $VER > $VER_FILE
17 changes: 10 additions & 7 deletions usr/bin/ublue-user-flatpak-manager
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,30 @@ FLATPAK_LIST=$(flatpak list --columns=application)
INSTALL_LIST=$(cat /etc/flatpak/user/install)
REMOVE_LIST=$(cat /etc/flatpak/user/remove)

notify-send "Flatpak installer" "Currently installing user flatpaks" --app-name="Flatpak installer" -u NORMAL

# Install flatpaks in list
if [[ -n $INSTALL_LIST ]]; then
for flatpak in $INSTALL_LIST; do
if grep -qvz $flatpak <<< $FLATPAK_LIST; then
flatpak install --user --noninteractive flathub $flatpak
if ! flatpak install --user --noninteractive flathub $flatpak; then
# exit on error
exit 1
fi
fi
done
fi

notify-send "Flatpak installer" "Finished installing user flatpaks" --app-name="Flatpak installer" -u NORMAL


# Remove flatpaks in list
if [[ -n $REMOVE_LIST ]]; then
for flatpak in $REMOVE_LIST; do
if grep -qz $flatpak <<< $FLATPAK_LIST; then
flatpak remove --user --noninteractive $flatpak
if ! flatpak remove --user --noninteractive $flatpak; then
# exit on error
exit 1
fi
fi
done
fi

notify-send "Flatpak installer" "Finished installing user flatpaks" --app-name="Flatpak installer" -u NORMAL

echo $VER > $VER_FILE
2 changes: 2 additions & 0 deletions usr/lib/systemd/system/ublue-system-flatpak-manager.service
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ After=network-online.target ublue-system-setup.service
Type=oneshot
ExecStart=/usr/bin/ublue-system-flatpak-manager
Restart=on-failure
RestartSec=30
StartLimitInterval=0

[Install]
WantedBy=multi-user.target
2 changes: 2 additions & 0 deletions usr/lib/systemd/user/ublue-user-flatpak-manager.service
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ After=network-online.target
Type=oneshot
ExecStart=/usr/bin/ublue-user-flatpak-manager
Restart=on-failure
RestartSec=30
StartLimitInterval=0

[Install]
WantedBy=default.target