mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-01-21 07:55:00 +00:00
action_utils: Separate function to hold freedombox package
Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
parent
64129f9148
commit
5412bd75d7
@ -18,7 +18,7 @@ import apt.cache
|
||||
import apt_inst
|
||||
import apt_pkg
|
||||
from plinth import cfg
|
||||
from plinth.action_utils import apt_hold, run_apt_command
|
||||
from plinth.action_utils import apt_hold_freedombox, run_apt_command
|
||||
|
||||
LOCK_FILE = '/var/lib/dpkg/lock'
|
||||
|
||||
@ -93,7 +93,7 @@ def subcommand_install(arguments):
|
||||
extra_arguments += ['-o', 'Dpkg::Options::=--force-confmiss']
|
||||
|
||||
subprocess.run(['dpkg', '--configure', '-a'])
|
||||
with apt_hold():
|
||||
with apt_hold_freedombox():
|
||||
run_apt_command(['--fix-broken', 'install'])
|
||||
returncode = run_apt_command(['install'] + extra_arguments +
|
||||
arguments.packages)
|
||||
|
||||
@ -14,9 +14,9 @@ import subprocess
|
||||
import sys
|
||||
import time
|
||||
|
||||
from plinth.action_utils import (apt_hold, debconf_set_selections,
|
||||
run_apt_command, service_daemon_reload,
|
||||
service_restart)
|
||||
from plinth.action_utils import (apt_hold, apt_hold_freedombox,
|
||||
debconf_set_selections, run_apt_command,
|
||||
service_daemon_reload, service_restart)
|
||||
from plinth.modules.apache.components import check_url
|
||||
from plinth.modules.snapshot import (is_apt_snapshots_enabled, is_supported as
|
||||
snapshot_is_supported, load_augeas as
|
||||
@ -432,7 +432,7 @@ def _perform_dist_upgrade():
|
||||
|
||||
# Hold freedombox package during entire dist upgrade.
|
||||
print('Holding freedombox package...', flush=True)
|
||||
with apt_hold():
|
||||
with apt_hold_freedombox():
|
||||
print('Updating Apt cache...', flush=True)
|
||||
run_apt_command(['update'])
|
||||
|
||||
|
||||
@ -418,11 +418,8 @@ def run_apt_command(arguments):
|
||||
|
||||
|
||||
@contextmanager
|
||||
def apt_hold(packages=None, ignore_errors=False):
|
||||
def apt_hold(packages, ignore_errors=False):
|
||||
"""Prevent packages from being removed during apt operations."""
|
||||
if not packages:
|
||||
packages = ['freedombox']
|
||||
|
||||
current_hold = subprocess.check_output(['apt-mark', 'showhold'] + packages)
|
||||
try:
|
||||
yield current_hold or subprocess.run(['apt-mark', 'hold'] + packages,
|
||||
@ -431,3 +428,16 @@ def apt_hold(packages=None, ignore_errors=False):
|
||||
if not current_hold:
|
||||
subprocess.run(['apt-mark', 'unhold'] + packages,
|
||||
check=not ignore_errors)
|
||||
|
||||
|
||||
@contextmanager
|
||||
def apt_hold_freedombox():
|
||||
"""Prevent freedombox package from being removed during apt operations."""
|
||||
current_hold = subprocess.check_output(
|
||||
['apt-mark', 'showhold', 'freedombox'])
|
||||
try:
|
||||
yield current_hold or subprocess.check_call(
|
||||
['apt-mark', 'hold', 'freedombox'])
|
||||
finally:
|
||||
if not current_hold:
|
||||
subprocess.check_call(['apt-mark', 'unhold', 'freedombox'])
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user