Support both new and old pkgin versions by testing if '-p' flag exists.

pull/18777/head
Jeff Rizzo 10 years ago committed by Matt Clay
parent d73aa9d428
commit 81a646ddaf

@ -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')

Loading…
Cancel
Save