Skip to content

Commit

Permalink
[FEATURE] Ability to check/uncheck optional dependencies at once (#360)
Browse files Browse the repository at this point in the history
  • Loading branch information
PrivateN00b authored May 25, 2024
1 parent 49a3980 commit 4cd1172
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 6 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions bauh/gems/arch/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def get_default_config(self) -> dict:
'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,
Expand Down
7 changes: 3 additions & 4 deletions bauh/gems/arch/confirmation.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@
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']
Expand All @@ -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"<p>{i18n['arch.install.optdeps.request.success'].format(pkg=bold(pkgname))}</p>" \
f"<p>{i18n['arch.install.optdeps.request.body']}:</p>"

Expand Down
11 changes: 9 additions & 2 deletions bauh/gems/arch/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -2343,7 +2343,7 @@ def _install_optdeps(self, context: TransactionContext) -> bool:
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
Expand Down Expand Up @@ -2967,6 +2967,10 @@ def _get_general_settings(self, arch_config: dict) -> SettingsView:
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',
Expand Down Expand Up @@ -3075,7 +3079,7 @@ def fill_general_settings(arch_config: dict, form: FormComponent):
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

Expand All @@ -3093,6 +3097,9 @@ def fill_general_settings(arch_config: dict, form: FormComponent):

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()
Expand Down
2 changes: 2 additions & 0 deletions bauh/gems/arch/resources/locale/ca
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions bauh/gems/arch/resources/locale/en
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4cd1172

Please sign in to comment.