Merge pull request #454 from jeffrizzo/pkgin-fix

Support both new and old pkgin versions by testing if '-p' flag exists.
This commit is contained in:
Brian Coca 2015-05-08 15:51:24 -04:00
commit b89532cd21

View file

@ -76,9 +76,19 @@ def query_package(module, pkgin_path, name):
* False - not installed or not found
"""
# test whether '-p' (parsable) flag is supported.
rc, out, err = module.run_command("%s -p -v" % pkgin_path)
if rc == 0:
pflag = '-p'
splitchar = ';'
else:
pflag = ''
splitchar = ' '
# Use "pkgin search" to find the package. The regular expression will
# only match on the complete name.
rc, out, err = module.run_command("%s search \"^%s$\"" % (pkgin_path, name))
rc, out, err = module.run_command("%s %s search \"^%s$\"" % (pkgin_path, pflag, name))
# rc will not be 0 unless the search was a success
if rc == 0:
@ -93,7 +103,7 @@ def query_package(module, pkgin_path, name):
# '<' - installed but out of date
# '=' - installed and up to date
# '>' - installed but newer than the repository version
pkgname_with_version, raw_state = out.split(' ')[0:2]
pkgname_with_version, raw_state = out.split(splitchar)[0:2]
# Strip version
# (results in sth like 'gcc47-libs')