From: Ian Kelling Date: Sun, 11 Aug 2019 23:50:11 +0000 (-0400) Subject: remove downgrades, add checkrestart X-Git-Url: https://iankelling.org/git/?a=commitdiff_plain;h=7d92a4f0b607ead76ccf488ee639a849c5ffeb83;p=distro-functions remove downgrades, add checkrestart --- diff --git a/src/package-manager-abstractions b/src/package-manager-abstractions index 34e32a6..a050be9 100644 --- a/src/package-manager-abstractions +++ b/src/package-manager-abstractions @@ -48,6 +48,12 @@ if command -v yum &> /dev/null; then } elif command -v apt-get &>/dev/null; then + pcheck() { + if dpkg -s -- "$@" | grep -Fx "Status: install ok installed" &>/dev/null; then + return 1 + fi + return 0 + } pp() { # package policy apt-cache policy $@ } @@ -72,19 +78,15 @@ elif command -v apt-get &>/dev/null; then fi } pi() { - if dpkg -s -- "$@" | grep -Fx "Status: install ok installed" &>/dev/null; then - return 0 - fi + pcheck "$@" || return 0 while fuser /var/lib/dpkg/lock &>/dev/null; do sleep 1; done pupdate local s; [[ $EUID != 0 ]] && s=sudo - $s $PI_PREFIX apt-get -y --allow-downgrades install --purge --auto-remove "$@" + $s $PI_PREFIX apt-get -y install --purge --auto-remove "$@" } pi-nostart() { - if dpkg -s -- "$@" &>/dev/null; then - return 0 - fi + pcheck "$@" || return 0 while fuser /var/lib/dpkg/lock &>/dev/null; do sleep 1; done pupdate local s; [[ $EUID != 0 ]] && s=sudo @@ -94,7 +96,7 @@ elif command -v apt-get &>/dev/null; then exit 101 EOF $s chmod +x $f - $s apt-get -y install --allow-downgrades --purge --auto-remove "$@" + $s apt-get -y install --purge --auto-remove "$@" $s rm $f } pf() { @@ -114,17 +116,19 @@ EOF pu() { local s; [[ $EUID != 0 ]] && s=sudo while fuser /var/lib/dpkg/lock &>/dev/null; do sleep 1; done - $s apt-get -y remove --allow-downgrades --purge --auto-remove "$@" + $s apt-get -y remove --purge --auto-remove "$@" # seems slightly redundant, but it removes more stuff sometimes. - $s apt-get -y --allow-downgrades autoremove + $s apt-get -y autoremove } pup() { # upgrade while fuser /var/lib/dpkg/lock &>/dev/null; do sleep 1; done pupdate local s; [[ $EUID != 0 ]] && s=sudo - $s apt-get -y dist-upgrade --allow-downgrades --purge --auto-remove "$@" - $s apt-get -y autoremove --allow-downgrades - $s checkrestart + $s apt-get -y dist-upgrade --purge --auto-remove "$@" + $s apt-get -y autoremove + if [[ -e /usr/sbin/checkrestart ]]; then + $s /usr/sbin/checkrestart -p + fi } # package info pl() {