diff --git a/packaging/os/pkgin.py b/packaging/os/pkgin.py index f4c203e56e0..9f25094210c 100644 --- a/packaging/os/pkgin.py +++ b/packaging/os/pkgin.py @@ -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')