packages: Keep existing hold if already set

Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
James Valleroy 2020-04-04 17:03:23 -04:00
parent 10c6ee13da
commit 907912d3a6
No known key found for this signature in database
GPG Key ID: 77C0C75E7B650808

View File

@ -58,10 +58,14 @@ def parse_arguments():
@contextmanager
def _apt_hold():
"""Do not allow freedombox package to be removed during package install."""
current_hold = subprocess.check_output(
['apt-mark', 'showhold', 'freedombox'])
try:
yield subprocess.run(['apt-mark', 'hold', 'freedombox'], check=True)
yield current_hold or subprocess.run(
['apt-mark', 'hold', 'freedombox'], check=True)
finally:
subprocess.run(['apt-mark', 'unhold', 'freedombox'], check=True)
if not current_hold:
subprocess.run(['apt-mark', 'unhold', 'freedombox'], check=True)
def _run_apt_command(arguments):