bullseye->bookworm: 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
parent 2763e04012
commit 0f34d7e10f
2 changed files with 9 additions and 7 deletions

View file

@ -178,16 +178,14 @@ class MyMigration(Migration):
aptitude_with_progress_bar(f"hold yunohost moulinette ssowat yunohost-admin {' '.join(apps_packages)}")
# Dirty hack to be able to remove rspamd because it's causing too many issues due to libluajit ...
command = (
f"sed -i /var/lib/dpkg/status -e 's@rspamd, @@g'"
)
command = "sed -i /var/lib/dpkg/status -e 's@rspamd, @@g'"
logger.debug(f"Running: {command}")
os.system(command)
aptitude_with_progress_bar("upgrade cron rspamd- libluajit-5.1-2- --show-why -y -o APT::Force-LoopBreak=1 -o Dpkg::Options::='--force-confold'")
aptitude_with_progress_bar("upgrade cron rspamd- libluajit-5.1-2- --show-why -o APT::Force-LoopBreak=1 -o Dpkg::Options::='--force-confold'")
# FIXME : find a way to simulate and validate the upgrade first
aptitude_with_progress_bar("full-upgrade --show-why -y -o Dpkg::Options::='--force-confold' <<< 'y\ny\ny'")
aptitude_with_progress_bar("full-upgrade --show-why -o Dpkg::Options::='--force-confold'")
# Force regenconf of nsswitch because for some reason
# /etc/nsswitch.conf is reset despite the --force-confold? It's a
@ -222,7 +220,7 @@ class MyMigration(Migration):
aptitude_with_progress_bar(f"unhold yunohost moulinette ssowat yunohost-admin {' '.join(apps_packages)}")
# FIXME : find a way to simulate and validate the upgrade first
aptitude_with_progress_bar("full-upgrade --show-why yunohost yunohost-admin moulinette ssowat -y -o Dpkg::Options::='--force-confold'")
aptitude_with_progress_bar("full-upgrade --show-why yunohost yunohost-admin moulinette ssowat -o Dpkg::Options::='--force-confold'")
#cmd = "LC_ALL=C"
#cmd += " DEBIAN_FRONTEND=noninteractive"

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