Use new prompt detection in run_command to detect aptitude prompts
Also adds flags to aptitude command when force=yes is used, in order to bypass the prompts given for untrusted packages. Fixes #31
This commit is contained in:
parent
f2ee976a69
commit
6db6cd219e
1 changed files with 4 additions and 2 deletions
|
@ -387,6 +387,7 @@ def upgrade(m, mode="yes", force=False, default_release=None,
|
||||||
check_arg = ''
|
check_arg = ''
|
||||||
|
|
||||||
apt_cmd = None
|
apt_cmd = None
|
||||||
|
prompt_regex = None
|
||||||
if mode == "dist":
|
if mode == "dist":
|
||||||
# apt-get dist-upgrade
|
# apt-get dist-upgrade
|
||||||
apt_cmd = APT_GET_CMD
|
apt_cmd = APT_GET_CMD
|
||||||
|
@ -399,12 +400,13 @@ def upgrade(m, mode="yes", force=False, default_release=None,
|
||||||
# aptitude safe-upgrade # mode=yes # default
|
# aptitude safe-upgrade # mode=yes # default
|
||||||
apt_cmd = APTITUDE_CMD
|
apt_cmd = APTITUDE_CMD
|
||||||
upgrade_command = "safe-upgrade"
|
upgrade_command = "safe-upgrade"
|
||||||
|
prompt_regex = r"(^Do you want to ignore this warning and proceed anyway\?|^\*\*\*.*\[default=.*\])"
|
||||||
|
|
||||||
if force:
|
if force:
|
||||||
if apt_cmd == APT_GET_CMD:
|
if apt_cmd == APT_GET_CMD:
|
||||||
force_yes = '--force-yes'
|
force_yes = '--force-yes'
|
||||||
else:
|
else:
|
||||||
force_yes = ''
|
force_yes = '--assume-yes --allow-untrusted'
|
||||||
else:
|
else:
|
||||||
force_yes = ''
|
force_yes = ''
|
||||||
|
|
||||||
|
@ -419,7 +421,7 @@ def upgrade(m, mode="yes", force=False, default_release=None,
|
||||||
if default_release:
|
if default_release:
|
||||||
cmd += " -t '%s'" % (default_release,)
|
cmd += " -t '%s'" % (default_release,)
|
||||||
|
|
||||||
rc, out, err = m.run_command(cmd)
|
rc, out, err = m.run_command(cmd, prompt_regex=prompt_regex)
|
||||||
if rc:
|
if rc:
|
||||||
m.fail_json(msg="'%s %s' failed: %s" % (apt_cmd, upgrade_command, err), stdout=out)
|
m.fail_json(msg="'%s %s' failed: %s" % (apt_cmd, upgrade_command, err), stdout=out)
|
||||||
if (apt_cmd == APT_GET_CMD and APT_GET_ZERO in out) or (apt_cmd == APTITUDE_CMD and APTITUDE_ZERO in out):
|
if (apt_cmd == APT_GET_CMD and APT_GET_ZERO in out) or (apt_cmd == APTITUDE_CMD and APTITUDE_ZERO in out):
|
||||||
|
|
Loading…
Reference in a new issue