From 45f3e55d602dbf253fd7b0119dc0a34394075c4c Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Sat, 6 Jul 2024 16:55:47 +0200 Subject: [PATCH] aptitude_with_progress_bar: more tweaks for the 'assume yes' in aptitude call, can't use raw bash redirects, gotta use stdin= from subprocess ... and we want only a limited number of 'yes' and not an infinite yes like the -y option does resuling in conflict resolution loops --- src/utils/system.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/utils/system.py b/src/utils/system.py index 497f6d8df..9b6de576c 100644 --- a/src/utils/system.py +++ b/src/utils/system.py @@ -284,6 +284,7 @@ def aptitude_with_progress_bar(cmd): lambda l: log_apt_status_to_progress_bar(l.rstrip()), ) + original_cmd = cmd cmd = ( f'LC_ALL=C DEBIAN_FRONTEND=noninteractive APT_LISTCHANGES_FRONTEND=none aptitude {cmd} --quiet=2 -o=Dpkg::Use-Pty=0 -o "APT::Status-Fd=$YNH_STDINFO"' ) @@ -295,12 +296,15 @@ def aptitude_with_progress_bar(cmd): logger.debug(f"Running: {cmd}") + read, write = os.pipe() + os.write(write, b"y\ny\ny") + os.close(write) ret = call_async_output(cmd, callbacks, shell=True) if log_apt_status_to_progress_bar.previous_package is not None and ret == 0: log_apt_status_to_progress_bar("done::100:Done") elif ret != 0: - raise YunohostError(f"Failed to run command 'aptitude {cmd}'", raw_msg=True) + raise YunohostError(f"Failed to run command 'aptitude {original_cmd}'", raw_msg=True) def _apt_log_line_is_relevant(line):