| ... | ... |
@@ -932,7 +932,7 @@ function is_package_installed() {
|
| 932 | 932 |
fi |
| 933 | 933 |
|
| 934 | 934 |
if [[ "$os_PACKAGE" = "deb" ]]; then |
| 935 |
- dpkg -l "$@" > /dev/null 2> /dev/null |
|
| 935 |
+ dpkg -s "$@" > /dev/null 2> /dev/null |
|
| 936 | 936 |
elif [[ "$os_PACKAGE" = "rpm" ]]; then |
| 937 | 937 |
rpm --quiet -q "$@" |
| 938 | 938 |
else |
| ... | ... |
@@ -367,3 +367,25 @@ if [[ "$VAL" -ne 0 ]]; then |
| 367 | 367 |
else |
| 368 | 368 |
echo "is_package_installed() on non-existing package failed" |
| 369 | 369 |
fi |
| 370 |
+ |
|
| 371 |
+# test against removed package...was a bug on Ubuntu |
|
| 372 |
+if is_ubuntu; then |
|
| 373 |
+ PKG=cowsay |
|
| 374 |
+ if ! (dpkg -s $PKG >/dev/null 2>&1); then |
|
| 375 |
+ # it was never installed...set up the condition |
|
| 376 |
+ sudo apt-get install -y cowsay >/dev/null 2>&1 |
|
| 377 |
+ fi |
|
| 378 |
+ if (dpkg -s $PKG >/dev/null 2>&1); then |
|
| 379 |
+ # remove it to create the 'un' status |
|
| 380 |
+ sudo dpkg -P $PKG >/dev/null 2>&1 |
|
| 381 |
+ fi |
|
| 382 |
+ |
|
| 383 |
+ # now test the installed check on a deleted package |
|
| 384 |
+ is_package_installed $PKG |
|
| 385 |
+ VAL=$? |
|
| 386 |
+ if [[ "$VAL" -ne 0 ]]; then |
|
| 387 |
+ echo "OK" |
|
| 388 |
+ else |
|
| 389 |
+ echo "is_package_installed() on deleted package failed" |
|
| 390 |
+ fi |
|
| 391 |
+fi |