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

This commit is contained in:
Alexandre Aubin 2024-07-06 16:55:47 +02:00 committed by Félix Piédallu
parent 54445de21a
commit 45f3e55d60

View file

@ -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):