Skip to content

Commit 90abf0a

Browse files
gvatsal60Copilot
andauthored
Update .update.sh
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 88151b8 commit 90abf0a

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

.update.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,11 +195,14 @@ update_os_pkg() {
195195
print_err "Error: Update failed."
196196
fi
197197
# Remove orphaned packages if any exist
198-
if [ -n "$("${PKG_MGR_CMD}" -Qdtq)" ]; then
199-
if ! ("${PKG_MGR_CMD}" -Rns $("${PKG_MGR_CMD}" -Qdtq)); then
198+
ORPHANS=$("${PKG_MGR_CMD}" -Qdtq)
199+
rc=$?
200+
if [ $rc -eq 0 ] && [ -n "${ORPHANS}" ]; then
201+
if ! ("${PKG_MGR_CMD}" -Rns ${ORPHANS}); then
200202
print_err "Error: Failed to remove orphaned packages."
201203
fi
202-
fi
204+
elif [ $rc -ne 1 ]; then
205+
print_err "Error: Failed to detect orphaned packages (exit code $rc)."
203206
;;
204207
*)
205208
print_err "Error: Unsupported or unrecognized Linux distribution: ${ADJUSTED_ID}"

0 commit comments

Comments
 (0)