From 4cd1172eda15b2a8d56106e8627af5d495fc0361 Mon Sep 17 00:00:00 2001 From: NoobKozlegeny <89228376+NoobKozlegeny@users.noreply.github.com> Date: Sat, 25 May 2024 13:30:16 +0200 Subject: [PATCH] [FEATURE] Ability to check/uncheck optional dependencies at once (#360) --- README.md | 1 + bauh/gems/arch/config.py | 1 + bauh/gems/arch/confirmation.py | 7 +++---- bauh/gems/arch/controller.py | 11 +++++++++-- bauh/gems/arch/resources/locale/ca | 2 ++ bauh/gems/arch/resources/locale/en | 2 ++ 6 files changed, 18 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 161d064d..38cd83b5 100644 --- a/README.md +++ b/README.md @@ -296,6 +296,7 @@ aur_idx_exp: 1 # It defines the period (in HOURS) for the AUR index stored in d check_dependency_breakage: true # if, during the verification of the update requirements, specific versions of dependencies must also be checked. Example: package A depends on version 1.0 of B. If A and B were selected to upgrade, and B would be upgrade to 2.0, then B would be excluded from the transaction. Default: true. suggest_unneeded_uninstall: false # if the dependencies apparently no longer necessary associated with the uninstalled packages should be suggested for uninstallation. When this property is enabled it automatically disables the property 'suggest_optdep_uninstall'. Default: false (to prevent new users from making mistakes) suggest_optdep_uninstall: false # if the optional dependencies associated with uninstalled packages should be suggested for uninstallation. Only the optional dependencies that are not dependencies of other packages will be suggested. Default: false (to prevent new users from making mistakes) +suggest_optdep_select: Selects all or no optional dependencies when installing packages categories_exp: 24 # It defines the expiration time (in HOURS) of the packages categories mapping file stored in disc. Use 0 so that it is always updated during initialization. aur_rebuild_detector: true # it checks if packages built with old library versions require to be rebuilt. If a package needs to be rebuilt, it will be marked for update ('rebuild-detector' must be installed). Default: true. prefer_repository_provider: true # when there is just one repository provider for a given a dependency and several from AUR, it will be automatically picked. diff --git a/bauh/gems/arch/config.py b/bauh/gems/arch/config.py index 615499b5..de35348d 100644 --- a/bauh/gems/arch/config.py +++ b/bauh/gems/arch/config.py @@ -36,6 +36,7 @@ class ArchConfigManager(YAMLConfigManager): 'check_dependency_breakage': True, 'suggest_unneeded_uninstall': False, 'suggest_optdep_uninstall': False, + "suggest_optdep_select": True, 'aur_idx_exp': 1, 'categories_exp': 24, 'aur_rebuild_detector': False, diff --git a/bauh/gems/arch/confirmation.py b/bauh/gems/arch/confirmation.py index d8aa23d9..5fe05bad 100644 --- a/bauh/gems/arch/confirmation.py +++ b/bauh/gems/arch/confirmation.py @@ -10,12 +10,11 @@ from bauh.commons.view_utils import get_human_size_str from bauh.gems.arch import ROOT_DIR, get_repo_icon_path, get_icon_path, pacman from bauh.view.util.translation import I18n - def _get_repo_icon(repository: str): return resource.get_path('img/{}.svg'.format('arch' if repository == 'aur' else 'repo'), ROOT_DIR) -def request_optional_deps(pkgname: str, pkg_repos: dict, watcher: ProcessWatcher, i18n: I18n) -> Set[str]: +def request_optional_deps(pkgname: str, pkg_repos: dict, watcher: ProcessWatcher, i18n: I18n, is_optdep_download: bool) -> Set[str]: opts = [] repo_deps = [p for p, data in pkg_repos.items() if data['repository'] != 'aur'] @@ -31,8 +30,8 @@ def request_optional_deps(pkgname: str, pkg_repos: dict, watcher: ProcessWatcher view_opts = MultipleSelectComponent(label='', options=opts, - default_options=set(opts)) - + default_options=set(opts) if is_optdep_download else None) + msg = f"
{i18n['arch.install.optdeps.request.success'].format(pkg=bold(pkgname))}
" \ f"{i18n['arch.install.optdeps.request.body']}:
" diff --git a/bauh/gems/arch/controller.py b/bauh/gems/arch/controller.py index 02b43bba..cba9b674 100644 --- a/bauh/gems/arch/controller.py +++ b/bauh/gems/arch/controller.py @@ -2343,7 +2343,7 @@ class ArchManager(SoftwareManager, SettingsController): if repo_mapping: final_optdeps = {dep: {'desc': odeps.get(dep), 'repository': repo_mapping.get(dep)} for dep, repository in repo_mapping.items() if repo_mapping.get(dep)} - deps_to_install = confirmation.request_optional_deps(context.name, final_optdeps, context.watcher, self.i18n) + deps_to_install = confirmation.request_optional_deps(context.name, final_optdeps, context.watcher, self.i18n, context.config['suggest_optdep_select']) if not deps_to_install: return True @@ -2967,6 +2967,10 @@ class ArchManager(SoftwareManager, SettingsController): label_key='arch.config.suggest_optdep_uninstall', tooltip_key='arch.config.suggest_optdep_uninstall.tip', value=bool(arch_config['suggest_optdep_uninstall'])), + self._gen_bool_selector(id_='suggest_optdep_select', + label_key='arch.config.suggest_optdep_select', + tooltip_key='arch.config.suggest_optdep_select.tip', + value=bool(arch_config['suggest_optdep_select'])), self._gen_bool_selector(id_='ref_mirs', label_key='arch.config.refresh_mirrors', tooltip_key='arch.config.refresh_mirrors.tip', @@ -3075,7 +3079,7 @@ class ArchManager(SoftwareManager, SettingsController): arch_config['refresh_mirrors_startup'] = form.get_component('ref_mirs', SingleSelectComponent).get_selected() arch_config['mirrors_sort_limit'] = form.get_component('mirrors_sort_limit', TextInputComponent).get_int_value() arch_config['automatch_providers'] = form.get_component('autoprovs', SingleSelectComponent).get_selected() - + sync_dbs_startup = form.get_component('sync_dbs_start', SingleSelectComponent).get_selected() arch_config['sync_databases_startup'] = sync_dbs_startup @@ -3093,6 +3097,9 @@ class ArchManager(SoftwareManager, SettingsController): sug_unneeded_uni = form.get_component('suggest_unneeded_uninstall', SingleSelectComponent).get_selected() arch_config['suggest_unneeded_uninstall'] = sug_unneeded_uni + + sug_optdep_download = form.get_component('suggest_optdep_select', SingleSelectComponent).get_selected() + arch_config['suggest_optdep_select'] = sug_optdep_download arch_config['categories_exp'] = form.get_component('arch_cats_exp', TextInputComponent).get_int_value() arch_config['suggestions_exp'] = form.get_component('arch_sugs_exp', TextInputComponent).get_int_value() diff --git a/bauh/gems/arch/resources/locale/ca b/bauh/gems/arch/resources/locale/ca index 1cf570e4..9c91b084 100644 --- a/bauh/gems/arch/resources/locale/ca +++ b/bauh/gems/arch/resources/locale/ca @@ -88,6 +88,8 @@ arch.config.suggest_optdep_uninstall=Uninstall optional dependencies arch.config.suggest_optdep_uninstall.tip=If the optional dependencies associated with uninstalled packages should be suggested for uninstallation. Only the optional dependencies that are not dependencies of other packages will be suggested. arch.config.suggest_unneeded_uninstall=Uninstall unneeded dependencies arch.config.suggest_unneeded_uninstall.tip=If the dependencies apparently no longer necessary associated with the uninstalled packages should be suggested for uninstallation. When this property is enabled it automatically disables the property {}. +arch.config.suggest_optdep_select=Download optional dependencies +arch.config.suggest_optdep_select.tip=Selects all or no optional dependencies when installing packages arch.config.suggestions_exp=Suggestions expiration arch.config.suggestions_exp.tip=It defines the period (in hours) in which the suggestions stored in disc will be considered up to date. Use 0 if you always want to update them. arch.config.sync_dbs=Synchronize packages databases diff --git a/bauh/gems/arch/resources/locale/en b/bauh/gems/arch/resources/locale/en index 8caf6bad..0978904a 100644 --- a/bauh/gems/arch/resources/locale/en +++ b/bauh/gems/arch/resources/locale/en @@ -88,6 +88,8 @@ arch.config.suggest_optdep_uninstall=Uninstall optional dependencies arch.config.suggest_optdep_uninstall.tip=If the optional dependencies associated with uninstalled packages should be suggested for uninstallation. Only the optional dependencies that are not dependencies of other packages will be suggested. arch.config.suggest_unneeded_uninstall=Uninstall unneeded dependencies arch.config.suggest_unneeded_uninstall.tip=If the dependencies apparently no longer necessary associated with the uninstalled packages should be suggested for uninstallation. When this property is enabled it automatically disables the property {}. +arch.config.suggest_optdep_select=Download optional dependencies +arch.config.suggest_optdep_select.tip=Selects all or no optional dependencies when installing packages arch.config.suggestions_exp=Suggestions expiration arch.config.suggestions_exp.tip=It defines the period (in hours) in which the suggestions stored in disc will be considered up to date. Use 0 if you always want to update them. arch.config.sync_dbs=Synchronize packages databases