Merge pull request #688 from thriqon/improve-package-apt

Improve __package_apt
This commit is contained in:
Darko Poljak 2018-09-12 11:53:37 +02:00 committed by GitHub
commit 690b63081f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 3 deletions

View file

@ -30,7 +30,7 @@ fi
# Except dpkg failing, if package is not known / installed
packages="$(apt-cache showpkg "$name" | sed -e "1,/Reverse Provides:/d" | cut -d ' ' -f 1) $name"
for p in $packages; do
if [ -n "$(dpkg -s "$p" 2>/dev/null | grep "^Status: install ok installed$")" ]; then
if dpkg -s "$p" 2>/dev/null | grep --quiet "^Status: install ok installed$" ; then
version=$(dpkg -s "$p" 2>/dev/null | grep "^Version:" | cut -d ' ' -f 2)
echo "present $p $version"
exit 0

View file

@ -77,10 +77,12 @@ case "$state_should" in
if [ -n "$version" ]; then
name="${name}=${version}"
fi
echo $aptget install $target_release \"$name\"
echo "$aptget install $target_release \"$name\""
echo "installed" >> "$__messages_out"
;;
absent)
echo $aptget remove $purgeparam \"$name\"
echo "$aptget remove $purgeparam \"$name\""
echo "removed" >> "$__messages_out"
;;
*)
echo "Unknown state: $state_should" >&2