From d8d1ca85dfef130d641727a2794a265a3521eff1 Mon Sep 17 00:00:00 2001 From: Jeff Rizzo Date: Wed, 6 May 2015 11:41:12 -0700 Subject: [PATCH] Support both new and old pkgin versions by testing if '-p' flag exists. --- packaging/os/pkgin.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) 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')