From d03053f58da544a70101ce0142075c6d4575aa16 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Tue, 16 Nov 2021 06:26:51 +0100 Subject: Adding notificiations for autoremovals in container update command. Signed-off-by: Daniel Baumann --- libexec/container/update | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/libexec/container/update b/libexec/container/update index 7bf5e5f..de76942 100755 --- a/libexec/container/update +++ b/libexec/container/update @@ -187,7 +187,20 @@ do case "${AUTOREMOVE}" in true) - container run -n ${NAME} -- "apt ${YES} autoremove ${PURGE}" + REMOVE_NUMBER="$(container run -n ${NAME} -- "apt \-\-simulate autoremove" | awk '/^[0-9]* upgraded, / { print $6 }')" + + case "${REMOVE_NUMBER}" in + 0) + ;; + + *) + REMOVE_PACKAGES="$(for LINE in $(container run -n ${NAME} -- "apt \-\-simulate autoremove" | grep '^ '); do echo ${LINE}; done | sed -e 's|^ ||' -e 's| $||'; echo)" + + container run -n ${NAME} -- "apt ${YES} autoremove ${PURGE}" + + Notification "removal(s)" "${REMOVE_NUMBER}" "$(echo ${REMOVE_PACKAGES})" + ;; + esac ;; esac -- cgit v1.2.3