|
|
|
@ -171,11 +171,20 @@ def get_version(pacman_output):
|
|
|
|
|
"""Take pacman -Qi or pacman -Si output and get the Version"""
|
|
|
|
|
lines = pacman_output.split('\n')
|
|
|
|
|
for line in lines:
|
|
|
|
|
if 'Version' in line:
|
|
|
|
|
if line.startswith('Version '):
|
|
|
|
|
return line.split(':')[1].strip()
|
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_name(module, pacman_output):
|
|
|
|
|
"""Take pacman -Qi or pacman -Si output and get the package name"""
|
|
|
|
|
lines = pacman_output.split('\n')
|
|
|
|
|
for line in lines:
|
|
|
|
|
if line.startswith('Name '):
|
|
|
|
|
return line.split(':')[1].strip()
|
|
|
|
|
module.fail_json(msg="get_name: fail to retrieve package name from pacman output")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def query_package(module, pacman_path, name, state="present"):
|
|
|
|
|
"""Query the package status in both the local system and the repository. Returns a boolean to indicate if the package is installed, a second
|
|
|
|
|
boolean to indicate if the package is up-to-date and a third boolean to indicate whether online information were available
|
|
|
|
@ -186,6 +195,12 @@ def query_package(module, pacman_path, name, state="present"):
|
|
|
|
|
if lrc != 0:
|
|
|
|
|
# package is not installed locally
|
|
|
|
|
return False, False, False
|
|
|
|
|
else:
|
|
|
|
|
# a non-zero exit code doesn't always mean the package is installed
|
|
|
|
|
# for example, if the package name queried is "provided" by another package
|
|
|
|
|
installed_name = get_name(module, lstdout)
|
|
|
|
|
if installed_name != name:
|
|
|
|
|
return False, False, False
|
|
|
|
|
|
|
|
|
|
# get the version installed locally (if any)
|
|
|
|
|
lversion = get_version(lstdout)
|
|
|
|
|