mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
openbsd_pkg: sync package_latest().
This diff syncs package_latest() with the changes to package_present(). I have not managed to figure out how to handle the cornercases where stderr is set but the command has not failed, so leave a FIXME blob for other adventurers.
This commit is contained in:
parent
0e4e6e8a84
commit
af52cd6ec1
1 changed files with 13 additions and 5 deletions
|
@ -183,16 +183,24 @@ def package_latest(name, installed_state, specific_version, module):
|
|||
else:
|
||||
changed = False
|
||||
|
||||
# 'pkg_add -u' returns 0 even when something strange happened, stderr
|
||||
# should be empty if everything went fine.
|
||||
if stderr:
|
||||
rc=1
|
||||
# FIXME: This part is problematic. Based on the issues mentioned (and
|
||||
# handled) in package_present() it is not safe to blindly trust stderr
|
||||
# as an indicator that the command failed, and in the case with
|
||||
# empty installpath directories this will break.
|
||||
#
|
||||
# For now keep this safeguard here, but ignore it if we managed to
|
||||
# parse out a successful update above. This way we will report a
|
||||
# successful run when we actually modify something but fail
|
||||
# otherwise.
|
||||
if changed != True:
|
||||
if stderr:
|
||||
rc=1
|
||||
|
||||
return (rc, stdout, stderr, changed)
|
||||
|
||||
else:
|
||||
# If package was not installed at all just make it present.
|
||||
return package_present(name, installed_state, module)
|
||||
return package_present(name, installed_state, specific_version, module)
|
||||
|
||||
# Function used to make sure a package is not installed.
|
||||
def package_absent(name, installed_state, module):
|
||||
|
|
Loading…
Reference in a new issue