Skip to content

Commit 7fc7a6c

Browse files
authored
Merge pull request #422 from leoberbert/fix-update
🐛 fix: Correção de Update
2 parents bf746d7 + 84b1765 commit 7fc7a6c

3 files changed

Lines changed: 15 additions & 4 deletions

File tree

p3/linuxtoys.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
# The libs directory is always at the same location relative to this entry point
1010
linuxtoys_dir = os.path.dirname(os.path.abspath(__file__))
1111
os.environ['SCRIPT_DIR'] = linuxtoys_dir
12+
13+
# UPD_SERVICE runs from a headless systemd unit and must follow the CLI path.
14+
if os.environ.get('UPD_SERVICE') == '1':
15+
os.environ['EASY_CLI'] = '1'
1216

1317
# --- VERIFY LIBRARIES EXIST ---
1418
# Safeguard: ensure the lib directory is present

p3/scripts/sysup.sh

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
source "$SCRIPT_DIR/libs/linuxtoys.lib"
99
_lang_
10+
sudo_rq
1011

1112
needs_reboot() {
1213
if is_fedora; then
@@ -57,10 +58,16 @@ elif is_debian || is_ubuntu; then
5758
fi
5859
fi
5960
elif is_arch || is_cachy; then
60-
sudo pacman -Rns $(pacman -Qdtq) --noconfirm || fatal "Failed to remove orphaned packages"
61+
orphaned_packages=$(pacman -Qdtq 2>/dev/null || true)
62+
if [[ -n "$orphaned_packages" ]]; then
63+
sudo pacman -Rns --noconfirm $orphaned_packages || fatal "Failed to remove orphaned packages"
64+
fi
6165
sudo pacman -Syu --noconfirm || fatal "Failed to upgrade packages"
6266
elif is_suse; then
63-
sudo zypper rm --clean-deps $(zypper packages --unneeded | awk '/^i/{print $5}') -y || fatal "Failed to remove orphaned packages"
67+
orphaned_packages=$(zypper packages --unneeded | awk '/^i/{print $5}')
68+
if [[ -n "$orphaned_packages" ]]; then
69+
sudo zypper rm --clean-deps $orphaned_packages -y || fatal "Failed to remove orphaned packages"
70+
fi
6471
sudo zypper dup -y || fatal "Failed to upgrade packages"
6572
elif is_solus; then
6673
sudo eopkg rmo -y || fatal "Failed to remove orphaned packages"
@@ -74,4 +81,4 @@ if needs_reboot; then
7481
{ [ "$UPD_SERVICE" = "1" ] && notify-send "$sysup_rebootreq" --icon=system-reboot --urgency=critical --app-name="LinuxToys Update"; } || zeninf "$sysup_rebootreq"
7582
else
7683
{ [ "$UPD_SERVICE" = "1" ] && echo "$sysup_completed"; } || zeninf "$sysup_completed"
77-
fi
84+
fi

resources/sysup/linuxtoys-update.service

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ After=network.target
44

55
[Service]
66
Type=oneshot
7-
ExecStart=/usr/bin/env UPD_SERVICE=1 linuxtoys
7+
ExecStart=/usr/bin/env EASY_CLI=1 UPD_SERVICE=1 linuxtoys

0 commit comments

Comments
 (0)