mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-11-29 08:25:10 +00:00
package: Add functions for removing packages
Functions needed to spot and remove installed conflicting packages before installation of apps. - Remove all packages in a single operation as this way apt can search for solutions to conflicts more easily. - Use type hints rather than a lot of type checking. Type hints shall later be enforced using offline checking (with mypy) or at runtime (with enforce, etc.). Signed-off-by: Fioddor Superconcentrado <fioddor@gmail.com> [sunil: Run single remove operation on all packages] [sunil: Use type hints instead of extensive type checking] [sunil: Trim down the test case as it would only succeed after install] Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org> package
This commit is contained in:
1 parent
cb539cf1e8
commit
24f7ffe3cf
3 files changed
+77
-1
No files matched your search
+12
-1
@@ -48,6 +48,11 @@ def parse_arguments():
|
||||
'module', help='name of module for which package is being installed')
|
||||
subparser.add_argument('packages', nargs='+',
|
||||
help='list of packages to install')
|
||||
|
||||
subparser = subparsers.add_parser('remove', help='remove the package(s)')
|
||||
subparser.add_argument('--packages', required=True,
|
||||
help='List of packages to remove', nargs='+')
|
||||
|
||||
subparsers.add_parser('is-package-manager-busy',
|
||||
help='Return whether package manager is busy')
|
||||
subparser = subparsers.add_parser(
|
||||
@@ -100,6 +105,11 @@ def subcommand_install(arguments):
|
||||
sys.exit(returncode)
|
||||
|
||||
|
||||
def subcommand_remove(arguments):
|
||||
"""Remove apt package(s)."""
|
||||
sys.exit(run_apt_command(['remove'] + arguments.packages))
|
||||
|
||||
|
||||
def _assert_managed_packages(module, packages):
|
||||
"""Check that list of packages are in fact managed by module."""
|
||||
cfg.read()
|
||||
@@ -116,7 +126,8 @@ def _assert_managed_packages(module, packages):
|
||||
def subcommand_is_package_manager_busy(_):
|
||||
"""Check whether package manager is busy.
|
||||
|
||||
An exit code of zero indicates that package manager is busy."""
|
||||
An exit code of zero indicates that package manager is busy.
|
||||
"""
|
||||
if not is_package_manager_busy():
|
||||
sys.exit(-1)
|
||||
|
||||
|
||||
Reference in new issue
Block a user