From 6db6cd219e5afaf5e77dd4a1d25453f7356746e0 Mon Sep 17 00:00:00 2001 From: James Cammarata Date: Mon, 10 Nov 2014 23:45:27 -0600 Subject: [PATCH] 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 --- packaging/os/apt.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packaging/os/apt.py b/packaging/os/apt.py index e5a38e538d1..834c644ef1d 100755 --- a/packaging/os/apt.py +++ b/packaging/os/apt.py @@ -387,6 +387,7 @@ def upgrade(m, mode="yes", force=False, default_release=None, check_arg = '' apt_cmd = None + prompt_regex = None if mode == "dist": # apt-get dist-upgrade 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 apt_cmd = APTITUDE_CMD upgrade_command = "safe-upgrade" + prompt_regex = r"(^Do you want to ignore this warning and proceed anyway\?|^\*\*\*.*\[default=.*\])" if force: if apt_cmd == APT_GET_CMD: force_yes = '--force-yes' else: - force_yes = '' + force_yes = '--assume-yes --allow-untrusted' else: force_yes = '' @@ -419,7 +421,7 @@ def upgrade(m, mode="yes", force=False, default_release=None, if 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: 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):