mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-05-27 10:44:33 +00:00
upgrades: Hold tt-rss during dist upgrade, if available
Performs this hold separately from the others, and ignore errors only for tt-rss. Signed-off-by: James Valleroy <jvalleroy@mailbox.org> Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
parent
a9914128f3
commit
566a1bd243
@ -425,6 +425,8 @@ def _perform_dist_upgrade():
|
|||||||
'Holding packages with conffile prompts: ' +
|
'Holding packages with conffile prompts: ' +
|
||||||
', '.join(packages_with_prompts) + '...', flush=True)
|
', '.join(packages_with_prompts) + '...', flush=True)
|
||||||
with apt_hold(packages_with_prompts):
|
with apt_hold(packages_with_prompts):
|
||||||
|
print('Holding tt-rss package if available...', flush=True)
|
||||||
|
with apt_hold(['tt-rss'], ignore_errors=True):
|
||||||
print('Running apt full-upgrade...', flush=True)
|
print('Running apt full-upgrade...', flush=True)
|
||||||
run_apt_command(['full-upgrade'])
|
run_apt_command(['full-upgrade'])
|
||||||
|
|
||||||
|
|||||||
@ -413,7 +413,7 @@ def run_apt_command(arguments):
|
|||||||
|
|
||||||
|
|
||||||
@contextmanager
|
@contextmanager
|
||||||
def apt_hold(packages=None):
|
def apt_hold(packages=None, ignore_errors=False):
|
||||||
"""Prevent packages from being removed during apt operations."""
|
"""Prevent packages from being removed during apt operations."""
|
||||||
if not packages:
|
if not packages:
|
||||||
packages = ['freedombox']
|
packages = ['freedombox']
|
||||||
@ -421,7 +421,8 @@ def apt_hold(packages=None):
|
|||||||
current_hold = subprocess.check_output(['apt-mark', 'showhold'] + packages)
|
current_hold = subprocess.check_output(['apt-mark', 'showhold'] + packages)
|
||||||
try:
|
try:
|
||||||
yield current_hold or subprocess.run(['apt-mark', 'hold'] + packages,
|
yield current_hold or subprocess.run(['apt-mark', 'hold'] + packages,
|
||||||
check=True)
|
check=not ignore_errors)
|
||||||
finally:
|
finally:
|
||||||
if not current_hold:
|
if not current_hold:
|
||||||
subprocess.run(['apt-mark', 'unhold'] + packages, check=True)
|
subprocess.run(['apt-mark', 'unhold'] + packages,
|
||||||
|
check=not ignore_errors)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user