Closed alexeypetrenko closed 9 years ago
Current implementation of isPackageInstalled returns 0 for all packages regardless of their state (installed or not).
isPackageInstalled
0
Here is the apt-cache policy command output for cases when package is installed and not installed
apt-cache policy
Installed:
$ apt-cache policy apache2 apache2: Installed: 2.4.7-1ubuntu4.1 Candidate: 2.4.7-1ubuntu4.1 Version table: *** 2.4.7-1ubuntu4.1 0 500 http://fi.archive.ubuntu.com/ubuntu/ trusty-updates/main amd64 Packages 500 http://security.ubuntu.com/ubuntu/ trusty-security/main amd64 Packages 100 /var/lib/dpkg/status 2.4.7-1ubuntu4 0 500 http://fi.archive.ubuntu.com/ubuntu/ trusty/main amd64 Packages
Not installed:
$ apt-cache policy apache2 apache2: Installed: (none) Candidate: 2.4.7-1ubuntu4.1 Version table: 2.4.7-1ubuntu4.1 0 500 http://fi.archive.ubuntu.com/ubuntu/ trusty-updates/main amd64 Packages 500 http://security.ubuntu.com/ubuntu/ trusty-security/main amd64 Packages 2.4.7-1ubuntu4 0 500 http://fi.archive.ubuntu.com/ubuntu/ trusty/main amd64 Packages
As one can see text Installed is presented in both outputs. So, apt-cache policy $1 | grep Installed exit code would be the same for both cases.
Installed
apt-cache policy $1 | grep Installed
As a fix for this problem I suggest to remove all lines matching none before looking for Installed.
none
Very nice spot, thank you!
A little bit off topic, but could you give me CONTRIBUTOR medal? My username is f0VM.
CONTRIBUTOR
Woops, missed this. Sure thing :+1:
Current implementation of
isPackageInstalled
returns0
for all packages regardless of their state (installed or not).Here is the
apt-cache policy
command output for cases when package is installed and not installedInstalled:
Not installed:
As one can see text
Installed
is presented in both outputs. So,apt-cache policy $1 | grep Installed
exit code would be the same for both cases.As a fix for this problem I suggest to remove all lines matching
none
before looking forInstalled
.