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:
James Valleroy authored and Sunil Mohan Adapa committed 2021-01-10 20:44:03 -08:00
1 parent a9914128f3
commit 566a1bd243
2 files changed
+8 -5

No files matched your search

+4 -3
View File
@@ -413,7 +413,7 @@ def run_apt_command(arguments):
@contextmanager
def apt_hold(packages=None):
def apt_hold(packages=None, ignore_errors=False):
"""Prevent packages from being removed during apt operations."""
if not packages:
packages = ['freedombox']
@@ -421,7 +421,8 @@ def apt_hold(packages=None):
current_hold = subprocess.check_output(['apt-mark', 'showhold'] + packages)
try:
yield current_hold or subprocess.run(['apt-mark', 'hold'] + packages,
check=True)
check=not ignore_errors)
finally:
if not current_hold:
subprocess.run(['apt-mark', 'unhold'] + packages, check=True)
subprocess.run(['apt-mark', 'unhold'] + packages,
check=not ignore_errors)