mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-11-29 08:25:10 +00:00
apt: Run apt-get -f install before other commands
Run `apt-get --fix-broken install` before installing package or manual update. This will attempt to correct broken dependencies. Tests: - Install a package without its dependencies using `dpkg -i`. - Both app install and manual update successfully recover from this situation. Signed-off-by: James Valleroy <jvalleroy@mailbox.org> Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
1 parent
bf53fd8b17
commit
5424e1e23f
3 files changed
+28
-23
No files matched your search
@@ -197,6 +197,7 @@ def webserver_disable(name, kind='config', apply_changes=True):
|
||||
|
||||
class WebserverChange(object):
|
||||
"""Context to restart/reload Apache after configuration changes."""
|
||||
|
||||
def __init__(self):
|
||||
"""Initialize the context object state."""
|
||||
self.actions_required = set()
|
||||
@@ -388,3 +389,23 @@ def is_disk_image():
|
||||
- Installing packages on a Debian machine using apt.
|
||||
"""
|
||||
return os.path.exists('/var/lib/freedombox/is-freedombox-disk-image')
|
||||
|
||||
|
||||
def run_apt_command(arguments):
|
||||
"""Run apt-get with provided arguments."""
|
||||
# Ask apt-get to output its progress to file descriptor 3.
|
||||
command = [
|
||||
'apt-get', '--assume-yes', '--quiet=2', '--option', 'APT::Status-Fd=3'
|
||||
] + arguments
|
||||
|
||||
# Duplicate stdout to file descriptor 3 for this process.
|
||||
os.dup2(1, 3)
|
||||
|
||||
# Pass on file descriptor 3 instead of closing it. Close stdout
|
||||
# so that regular output is ignored.
|
||||
env = os.environ.copy()
|
||||
env['DEBIAN_FRONTEND'] = 'noninteractive'
|
||||
process = subprocess.run(command, stdin=subprocess.DEVNULL,
|
||||
stdout=subprocess.DEVNULL, close_fds=False,
|
||||
env=env)
|
||||
return process.returncode
|
||||
Reference in new issue
Block a user