apt remove now recognizes the force parameter (#3756)

pull/18777/head
Erik Nadel 9 years ago committed by Matt Clay
parent 9632b47a85
commit 4619513d9e

@ -551,7 +551,7 @@ def install_deb(m, debs, cache, force, install_recommends, allow_unauthenticated
else: else:
m.exit_json(changed=changed, stdout=retvals.get('stdout',''), stderr=retvals.get('stderr',''), diff=retvals.get('diff', '')) m.exit_json(changed=changed, stdout=retvals.get('stdout',''), stderr=retvals.get('stderr',''), diff=retvals.get('diff', ''))
def remove(m, pkgspec, cache, purge=False, def remove(m, pkgspec, cache, purge=False, force=False,
dpkg_options=expand_dpkg_options(DPKG_OPTIONS), autoremove=False): dpkg_options=expand_dpkg_options(DPKG_OPTIONS), autoremove=False):
pkg_list = [] pkg_list = []
pkgspec = expand_pkgspec_from_fnmatches(m, pkgspec, cache) pkgspec = expand_pkgspec_from_fnmatches(m, pkgspec, cache)
@ -565,6 +565,11 @@ def remove(m, pkgspec, cache, purge=False,
if len(packages) == 0: if len(packages) == 0:
m.exit_json(changed=False) m.exit_json(changed=False)
else: else:
if force:
force_yes = '--force-yes'
else:
force_yes = ''
if purge: if purge:
purge = '--purge' purge = '--purge'
else: else:
@ -580,7 +585,7 @@ def remove(m, pkgspec, cache, purge=False,
else: else:
check_arg = '' check_arg = ''
cmd = "%s -q -y %s %s %s %s remove %s" % (APT_GET_CMD, dpkg_options, purge, autoremove, check_arg, packages) cmd = "%s -q -y %s %s %s %s %s remove %s" % (APT_GET_CMD, dpkg_options, purge, force_yes ,autoremove, check_arg, packages)
rc, out, err = m.run_command(cmd) rc, out, err = m.run_command(cmd)
if m._diff: if m._diff:
@ -828,7 +833,7 @@ def main():
else: else:
module.fail_json(**retvals) module.fail_json(**retvals)
elif p['state'] == 'absent': elif p['state'] == 'absent':
remove(module, packages, cache, p['purge'], dpkg_options, autoremove) remove(module, packages, cache, p['purge'], force=force_yes, dpkg_options=dpkg_options, autoremove=autoremove)
except apt.cache.LockFailedException: except apt.cache.LockFailedException:
module.fail_json(msg="Failed to lock apt for exclusive operation") module.fail_json(msg="Failed to lock apt for exclusive operation")

Loading…
Cancel
Save