}
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 $@
}
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
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() {
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() {