mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-05-20 10:34:30 +00:00
package: Add option to skip recommends
Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
parent
745632d872
commit
c511dab7ff
@ -38,6 +38,9 @@ def parse_arguments():
|
|||||||
subparsers.add_parser('update', help='update the package lists')
|
subparsers.add_parser('update', help='update the package lists')
|
||||||
|
|
||||||
subparser = subparsers.add_parser('install', help='install packages')
|
subparser = subparsers.add_parser('install', help='install packages')
|
||||||
|
subparser.add_argument(
|
||||||
|
'--skip-recommends', action='store_true',
|
||||||
|
help='whether to skip installing recommended packages')
|
||||||
subparser.add_argument(
|
subparser.add_argument(
|
||||||
'module', help='name of module for which package is being installed')
|
'module', help='name of module for which package is being installed')
|
||||||
subparser.add_argument('packages', nargs='+',
|
subparser.add_argument('packages', nargs='+',
|
||||||
@ -82,7 +85,11 @@ def subcommand_install(arguments):
|
|||||||
print('Access check failed:', exception, file=sys.stderr)
|
print('Access check failed:', exception, file=sys.stderr)
|
||||||
sys.exit(99)
|
sys.exit(99)
|
||||||
|
|
||||||
_run_apt_command(['install'] + arguments.packages)
|
if arguments.skip_recommends:
|
||||||
|
_run_apt_command(
|
||||||
|
['install', '--no-install-recommends'] + arguments.packages)
|
||||||
|
else:
|
||||||
|
_run_apt_command(['install'] + arguments.packages)
|
||||||
|
|
||||||
|
|
||||||
def _assert_managed_packages(module, packages):
|
def _assert_managed_packages(module, packages):
|
||||||
|
|||||||
@ -69,7 +69,7 @@ class Transaction(object):
|
|||||||
self.percentage = 0
|
self.percentage = 0
|
||||||
self.stderr = None
|
self.stderr = None
|
||||||
|
|
||||||
def install(self):
|
def install(self, skip_recommends=False):
|
||||||
"""Run an apt-get transaction to install given packages.
|
"""Run an apt-get transaction to install given packages.
|
||||||
|
|
||||||
FreedomBox Service (Plinth) needs to be running as root when calling
|
FreedomBox Service (Plinth) needs to be running as root when calling
|
||||||
@ -79,7 +79,12 @@ class Transaction(object):
|
|||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
self._run_apt_command(['update'])
|
self._run_apt_command(['update'])
|
||||||
self._run_apt_command(['install', self.module_name] +
|
if skip_recommends:
|
||||||
|
self._run_apt_command(
|
||||||
|
['install', '--skip-recommends', self.module_name] +
|
||||||
|
self.package_names)
|
||||||
|
else:
|
||||||
|
self._run_apt_command(['install', self.module_name] +
|
||||||
self.package_names)
|
self.package_names)
|
||||||
except subprocess.CalledProcessError as exception:
|
except subprocess.CalledProcessError as exception:
|
||||||
logger.exception('Error installing package: %s', exception)
|
logger.exception('Error installing package: %s', exception)
|
||||||
|
|||||||
@ -100,7 +100,7 @@ class Helper(object):
|
|||||||
self.is_finished = True
|
self.is_finished = True
|
||||||
self.current_operation = None
|
self.current_operation = None
|
||||||
|
|
||||||
def install(self, package_names):
|
def install(self, package_names, skip_recommends=False):
|
||||||
"""Install a set of packages marking progress."""
|
"""Install a set of packages marking progress."""
|
||||||
if self.allow_install is False:
|
if self.allow_install is False:
|
||||||
# Raise error if packages are not already installed.
|
# Raise error if packages are not already installed.
|
||||||
@ -119,7 +119,7 @@ class Helper(object):
|
|||||||
'step': 'install',
|
'step': 'install',
|
||||||
'transaction': transaction,
|
'transaction': transaction,
|
||||||
}
|
}
|
||||||
transaction.install()
|
transaction.install(skip_recommends)
|
||||||
|
|
||||||
def call(self, step, method, *args, **kwargs):
|
def call(self, step, method, *args, **kwargs):
|
||||||
"""Call an arbitrary method during setup and note down its stage."""
|
"""Call an arbitrary method during setup and note down its stage."""
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user