From 846db7f606b4bea8d064b1c2edcb6a5ecdc4d935 Mon Sep 17 00:00:00 2001 From: Ian Kelling Date: Mon, 28 May 2018 18:45:15 -0400 Subject: [PATCH] wait for dpkg locks --- src/package-manager-abstractions | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/package-manager-abstractions b/src/package-manager-abstractions index 6d433d2..f70bf1d 100644 --- a/src/package-manager-abstractions +++ b/src/package-manager-abstractions @@ -65,14 +65,7 @@ elif command -v apt-get &>/dev/null; then if dpkg -s -- "$@" &>/dev/null; then return 0 fi - pupdate - local s; [[ $EUID != 0 ]] && s=sudo - $s apt-get -y install --purge --auto-remove "$@" - } - pi() { - if dpkg -s -- "$@" &>/dev/null; then - return 0 - fi + 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 install --purge --auto-remove "$@" @@ -82,6 +75,7 @@ elif command -v apt-get &>/dev/null; then if dpkg -s -- "$@" &>/dev/null; then return 0 fi + while fuser /var/lib/dpkg/lock &>/dev/null; do sleep 1; done pupdate local s; [[ $EUID != 0 ]] && s=sudo local f=/usr/sbin/policy-rc.d @@ -109,11 +103,13 @@ 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 --purge --auto-remove "$@" # seems slightly redundant, but it removes more stuff sometimes. $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 --purge --auto-remove "$@" -- 2.30.2