Chris Bailey 2 weeks ago committed by GitHub
commit 788eeb3e48
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -703,6 +703,8 @@ def mark_installed_manually(m, packages):
cmd = "%s unmarkauto %s" % (apt_mark_cmd_path, ' '.join(packages))
rc, out, err = m.run_command(cmd)
check_locked_error(out, err)
if rc != 0:
m.fail_json(msg="'%s' failed: %s" % (cmd, err), stdout=out, stderr=err, rc=rc)
@ -822,6 +824,9 @@ def install(m, pkgspec, cache, upgrade=False, default_release=None,
changed = APT_GET_ZERO not in out
data = dict(changed=changed, stdout=out, stderr=err, diff=diff)
check_locked_error(out, err)
if rc:
status = False
data = dict(msg="'%s' failed: %s" % (cmd, err), stdout=out, stderr=err, rc=rc)
@ -936,6 +941,8 @@ def install_deb(
else:
stderr = err
check_locked_error(stdout, stderr)
if rc == 0:
m.exit_json(changed=True, stdout=stdout, stderr=stderr, diff=diff)
else:
@ -1002,6 +1009,9 @@ def remove(m, pkgspec, cache, purge=False, force=False,
diff = parse_diff(out)
else:
diff = {}
check_locked_error(out, err)
if rc:
m.fail_json(msg="'apt-get remove %s' failed: %s" % (packages, err), stdout=out, stderr=err, rc=rc)
m.exit_json(changed=True, stdout=out, stderr=err, diff=diff)
@ -1037,6 +1047,9 @@ def cleanup(m, purge=False, force=False, operation=None,
diff = parse_diff(out)
else:
diff = {}
check_locked_error(out, err)
if rc:
m.fail_json(msg="'apt-get %s' failed: %s" % (operation, err), stdout=out, stderr=err, rc=rc)
@ -1150,6 +1163,9 @@ def upgrade(m, mode="yes", force=False, default_release=None,
diff = parse_diff(out)
else:
diff = {}
check_locked_error(out, err)
if rc:
m.fail_json(msg="'%s %s' failed: %s" % (apt_cmd, upgrade_command, err), stdout=out, rc=rc)
if (apt_cmd == APT_GET_CMD and APT_GET_ZERO in out) or (apt_cmd == APTITUDE_CMD and APTITUDE_ZERO in out):
@ -1542,5 +1558,10 @@ def main():
module.fail_json(msg='Unexpected code path taken, we really should have exited before, this is a bug')
def check_locked_error(stdout, stderr):
if ("lock was locked" in stderr or "lock was locked" in stdout):
raise apt.cache.LockFailedException
if __name__ == "__main__":
main()

Loading…
Cancel
Save