From 9656f78020e9cafc7d84f2d394ab84b4c44e66c4 Mon Sep 17 00:00:00 2001 From: Vinicius Moreira Date: Fri, 28 Jan 2022 18:31:17 -0300 Subject: [PATCH] [arch] improvement: new property 'prefer_repository_provider' --- CHANGELOG.md | 1 + README.md | 1 + bauh/gems/arch/config.py | 3 ++- bauh/gems/arch/controller.py | 9 ++++++++ bauh/gems/arch/dependencies.py | 33 +++++++++++++++++++++++------- bauh/gems/arch/resources/locale/ca | 2 ++ bauh/gems/arch/resources/locale/de | 2 ++ bauh/gems/arch/resources/locale/en | 2 ++ bauh/gems/arch/resources/locale/es | 2 ++ bauh/gems/arch/resources/locale/fr | 2 ++ bauh/gems/arch/resources/locale/it | 2 ++ bauh/gems/arch/resources/locale/pt | 2 ++ bauh/gems/arch/resources/locale/ru | 2 ++ bauh/gems/arch/resources/locale/tr | 2 ++ bauh/gems/arch/updates.py | 3 ++- 15 files changed, 59 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f9c951f9..652349e8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - always listing repository packages as primary options when multiple providers for a given dependency are available - settings: - "Auto-define dependency providers" property renamed to "Auto-define providers by name" + - new property 'prefer_repository_provider': automatically picks the single package from the repositories among several external (AUR) available as the provider for a given dependency ### Fixes - General diff --git a/README.md b/README.md index b3d4e5bd..da06f925 100644 --- a/README.md +++ b/README.md @@ -281,6 +281,7 @@ suggest_unneeded_uninstall: false # if the dependencies apparently no longer ne 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) 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 5a88fd14..b17800e3 100644 --- a/bauh/gems/arch/config.py +++ b/bauh/gems/arch/config.py @@ -39,4 +39,5 @@ class ArchConfigManager(YAMLConfigManager): 'aur_idx_exp': 1, 'categories_exp': 24, 'aur_rebuild_detector': False, - "aur_rebuild_detector_no_bin": True} + "aur_rebuild_detector_no_bin": True, + "prefer_repository_provider": True} diff --git a/bauh/gems/arch/controller.py b/bauh/gems/arch/controller.py index f3783467..ccef1f49 100644 --- a/bauh/gems/arch/controller.py +++ b/bauh/gems/arch/controller.py @@ -2082,6 +2082,7 @@ class ArchManager(SoftwareManager): remote_provided_map=context.get_remote_provided_map(), remote_repo_map=context.get_remote_repo_map(), automatch_providers=context.config['automatch_providers'], + prefer_repository_provider=context.config['prefer_repository_provider'], watcher=context.watcher) tf = time.time() @@ -2197,6 +2198,7 @@ class ArchManager(SoftwareManager): remote_provided_map=remote_provided_map, remote_repo_map=remote_repo_map, automatch_providers=context.config['automatch_providers'], + prefer_repository_provider=context.config['prefer_repository_provider'], sort=False) if missing_deps is None: @@ -2823,6 +2825,12 @@ class ArchManager(SoftwareManager): tooltip_key='arch.config.automatch_providers.tip', value=bool(arch_config['automatch_providers']), max_width=max_width), + self._gen_bool_selector(id_='prefer_repo_provider', + label_key='arch.config.prefer_repository_provider', + tooltip_key='arch.config.prefer_repository_provider.tip', + value=bool(arch_config['prefer_repository_provider']), + max_width=max_width, + tooltip_params=['AUR']), self._gen_bool_selector(id_='check_dependency_breakage', label_key='arch.config.check_dependency_breakage', tooltip_key='arch.config.check_dependency_breakage.tip', @@ -2935,6 +2943,7 @@ class ArchManager(SoftwareManager): arch_config['mirrors_sort_limit'] = form.get_component('mirrors_sort_limit').get_int_value() arch_config['repositories_mthread_download'] = form.get_component('mthread_download').get_selected() arch_config['automatch_providers'] = form.get_single_select_component('autoprovs').get_selected() + arch_config['prefer_repository_provider'] = form.get_single_select_component('prefer_repo_provider').get_selected() arch_config['edit_aur_pkgbuild'] = form.get_single_select_component('edit_aur_pkgbuild').get_selected() arch_config['aur_remove_build_dir'] = form.get_single_select_component('aur_remove_build_dir').get_selected() arch_config['aur_build_dir'] = form.get_component('aur_build_dir').file_path diff --git a/bauh/gems/arch/dependencies.py b/bauh/gems/arch/dependencies.py index 5246edc8..34b94f4d 100644 --- a/bauh/gems/arch/dependencies.py +++ b/bauh/gems/arch/dependencies.py @@ -287,7 +287,7 @@ class DependenciesAnalyser: missing_deps: Set[Tuple[str, str]], remote_provided_map: Dict[str, Set[str]], remote_repo_map: Dict[str, str], repo_deps: Set[str], aur_deps: Set[str], deps_data: Dict[str, dict], watcher: ProcessWatcher, - automatch_providers: bool, dependent: Optional[str] = None): + automatch_providers: bool, prefer_repository_provider: bool, dependent: Optional[str] = None): repo_matches = None @@ -309,6 +309,16 @@ class DependenciesAnalyser: repo_matches.append((pkgname, repo, data)) + if prefer_repository_provider and repo_matches and len(repo_matches) == 1: + pkg_name, pkg_repo, pkg_data = repo_matches[0] + missing_deps.add((pkg_name, pkg_repo)) + repo_deps.add(pkg_name) + + if pkg_data: + deps_data[pkg_name] = pkg_data + + return + aur_matches = None if aur_index: @@ -379,7 +389,7 @@ class DependenciesAnalyser: remote_provided_map: Dict[str, Set[str]], remote_repo_map: Dict[str, str], aur_index: Iterable[str], deps_checked: Set[str], deps_data: Dict[str, dict], sort: bool, watcher: ProcessWatcher, choose_providers: bool = True, - automatch_providers: bool = False) -> Optional[List[Tuple[str, str]]]: + automatch_providers: bool = False, prefer_repository_provider: bool = False) -> Optional[List[Tuple[str, str]]]: sorted_deps = [] # it will hold the proper order to install the missing dependencies missing_deps, repo_missing, aur_missing = set(), set(), set() @@ -406,6 +416,7 @@ class DependenciesAnalyser: repo_deps=repo_missing, aur_deps=aur_missing, watcher=watcher, deps_data=deps_data, automatch_providers=automatch_providers, + prefer_repository_provider=prefer_repository_provider, dependent=p) else: version_pattern = '{}='.format(dep_name) @@ -425,6 +436,7 @@ class DependenciesAnalyser: watcher=watcher, deps_data=deps_data, automatch_providers=automatch_providers, + prefer_repository_provider=prefer_repository_provider, dependent=p) else: self._fill_missing_dep(dep_name=dep_name, dep_exp=dep, aur_index=aur_index, @@ -435,6 +447,7 @@ class DependenciesAnalyser: watcher=watcher, deps_data=deps_data, automatch_providers=automatch_providers, + prefer_repository_provider=prefer_repository_provider, dependent=p) if missing_deps: @@ -446,7 +459,8 @@ class DependenciesAnalyser: remote_provided_map=remote_provided_map, remote_repo_map=remote_repo_map, automatch_providers=automatch_providers, - choose_providers=False) + choose_providers=False, + prefer_repository_provider=prefer_repository_provider) if missing_subdeps: missing_deps.update(missing_subdeps) @@ -461,7 +475,8 @@ class DependenciesAnalyser: remote_provided_map=remote_provided_map, remote_repo_map=remote_repo_map, watcher=watcher, sort=sort, already_checked=deps_checked, aur_idx=aur_index, deps_data=deps_data, - automatch_providers=automatch_providers) + automatch_providers=automatch_providers, + prefer_repository_provider=prefer_repository_provider) return sorted_deps @@ -514,7 +529,8 @@ class DependenciesAnalyser: provided_map: Dict[str, Set[str]], remote_repo_map: Dict[str, str], already_checked: Set[str], remote_provided_map: Dict[str, Set[str]], deps_data: Dict[str, dict], aur_idx: Iterable[str], sort: bool, - watcher: ProcessWatcher, automatch_providers: bool) -> Optional[List[Tuple[str, str]]]: + watcher: ProcessWatcher, automatch_providers: bool, + prefer_repository_provider: bool) -> Optional[List[Tuple[str, str]]]: """ :param missing_deps: :param provided_map: @@ -526,6 +542,7 @@ class DependenciesAnalyser: :param sort: :param watcher: :param automatch_providers + :param prefer_repository_provider :return: all deps sorted or None if the user declined the providers options """ @@ -583,7 +600,8 @@ class DependenciesAnalyser: remote_repo_map=remote_repo_map, watcher=watcher, choose_providers=True, - automatch_providers=automatch_providers) + automatch_providers=automatch_providers, + prefer_repository_provider=prefer_repository_provider) if providers_deps is None: # it means the user called off the installation process return @@ -610,7 +628,8 @@ class DependenciesAnalyser: remote_repo_map=remote_repo_map, already_checked=already_checked, aur_idx=aur_idx, remote_provided_map=remote_provided_map, deps_data=deps_data, sort=False, watcher=watcher, - automatch_providers=automatch_providers): + automatch_providers=automatch_providers, + prefer_repository_provider=prefer_repository_provider): return if sort: diff --git a/bauh/gems/arch/resources/locale/ca b/bauh/gems/arch/resources/locale/ca index 46a3de9b..8be7d7a7 100644 --- a/bauh/gems/arch/resources/locale/ca +++ b/bauh/gems/arch/resources/locale/ca @@ -73,6 +73,8 @@ arch.config.optimize=Optimize {} arch.config.optimize.tip=La configuració optimitzada s'utilitzarà per fer més ràpida la instal·lació, actualització i reversió dels paquets, en cas contrari s'utilitzarà la configuració del sistema. arch.config.pacman_mthread_download=Multithreaded download (repositories) arch.config.pacman_mthread_download.tip=Whether the repository packages should be downloaded with a tool that works with threads (it may be faster). pacman-mirrors must be installed. +arch.config.prefer_repository_provider=Prefer repository dependencies +arch.config.prefer_repository_provider.tip=Automatically picks the single package from the repositories among several external ({}) available as the provider for a given dependency arch.config.refresh_mirrors=Refresh mirrors on startup arch.config.refresh_mirrors.tip=Refresh the package mirrors once a day on startup arch.config.repos=Repositories packages diff --git a/bauh/gems/arch/resources/locale/de b/bauh/gems/arch/resources/locale/de index e77ece8d..4e1bdb59 100644 --- a/bauh/gems/arch/resources/locale/de +++ b/bauh/gems/arch/resources/locale/de @@ -73,6 +73,8 @@ arch.config.optimize=Optimize {} arch.config.optimize.tip=Optimized settings will be used in order to make the packages installation, upgrading and downgrading faster, otherwise the system settings will be used arch.config.pacman_mthread_download=Multithreaded download (repositories) arch.config.pacman_mthread_download.tip=Whether the repository packages should be downloaded with a tool that works with threads (it may be faster). pacman-mirrors must be installed. +arch.config.prefer_repository_provider=Prefer repository dependencies +arch.config.prefer_repository_provider.tip=Automatically picks the single package from the repositories among several external ({}) available as the provider for a given dependency arch.config.refresh_mirrors=Refresh mirrors on startup arch.config.refresh_mirrors.tip=Refresh the package mirrors once a day on startup arch.config.repos=Repositories packages diff --git a/bauh/gems/arch/resources/locale/en b/bauh/gems/arch/resources/locale/en index 548cb9ee..52f192ba 100644 --- a/bauh/gems/arch/resources/locale/en +++ b/bauh/gems/arch/resources/locale/en @@ -73,6 +73,8 @@ arch.config.optimize=Optimize {} arch.config.optimize.tip=Optimized settings will be used in order to make the packages installation, upgrading and downgrading faster, otherwise the system settings will be used arch.config.pacman_mthread_download=Multi-threaded download (repositories) arch.config.pacman_mthread_download.tip=Whether the repository packages should be downloaded with a tool that works with threads (it may be faster). pacman-mirrors must be installed. +arch.config.prefer_repository_provider=Prefer repository dependencies +arch.config.prefer_repository_provider.tip=Automatically picks the single package from the repositories among several external ({}) available as the provider for a given dependency arch.config.refresh_mirrors=Refresh mirrors on startup arch.config.refresh_mirrors.tip=Refresh the package mirrors once a day on startup arch.config.repos=Repositories packages diff --git a/bauh/gems/arch/resources/locale/es b/bauh/gems/arch/resources/locale/es index b06e3408..d7075828 100644 --- a/bauh/gems/arch/resources/locale/es +++ b/bauh/gems/arch/resources/locale/es @@ -73,6 +73,8 @@ arch.config.optimize=Optimizar {} arch.config.optimize.tip=Se usará la configuración optimizada para que la instalación, actualización y reversión de los paquetes sean más rápidas, de lo contrario se usará la configuración del sistema arch.config.pacman_mthread_download=Descarga segmentada (repositorios) arch.config.pacman_mthread_download.tip=Si los paquetes de los repositorios deben descargarse con una herramienta que usa segmentación/threads (puede ser más rápido). pacman-mirrors necesita estar instalado. +arch.config.prefer_repository_provider=Preferir dependencias de repositorio +arch.config.prefer_repository_provider.tip=Elige automáticamente el paquete unico de los repositorios entre varios externos ({}) disponibles como el proveedor para una dependencia arch.config.refresh_mirrors=Actualizar espejos al iniciar arch.config.refresh_mirrors.tip=Actualiza los espejos de paquetes una vez al día al iniciar arch.config.repos=Paquetes de repositorios diff --git a/bauh/gems/arch/resources/locale/fr b/bauh/gems/arch/resources/locale/fr index 9581b967..08de8369 100644 --- a/bauh/gems/arch/resources/locale/fr +++ b/bauh/gems/arch/resources/locale/fr @@ -73,6 +73,8 @@ arch.config.optimize=Optimizer {} arch.config.optimize.tip=Utiliser des paramètres optimisés pour rendre l'installation, mise à jour et downgrade des paquets plus rapide. À défaut, les paramètres systèmes seront utilisés. arch.config.pacman_mthread_download=Téléchargement parallèle (repos) arch.config.pacman_mthread_download.tip=Si il faut utiliser un outil qui télécharge les paquets du répos en parallèle (plus rapide). pacman-mirrors doit être installé. +arch.config.prefer_repository_provider=Prefer repository dependencies +arch.config.prefer_repository_provider.tip=Automatically picks the single package from the repositories among several external ({}) available as the provider for a given dependency arch.config.refresh_mirrors=Actualiser les miroirs au démarrage arch.config.refresh_mirrors.tip=Actualiser les miroirs du paquet une fois par jour au démarrage arch.config.repos=Repos des paquets diff --git a/bauh/gems/arch/resources/locale/it b/bauh/gems/arch/resources/locale/it index 588d0852..ce97f4f6 100644 --- a/bauh/gems/arch/resources/locale/it +++ b/bauh/gems/arch/resources/locale/it @@ -73,6 +73,8 @@ arch.config.optimize=Optimize {} arch.config.optimize.tip=Verranno utilizzate le impostazioni ottimizzate per velocizzare l'installazione, l'aggiornamento e l'inversione dei pacchetti, altrimenti verranno utilizzate le impostazioni di sistema arch.config.pacman_mthread_download=Multithreaded download (repositories) arch.config.pacman_mthread_download.tip=Whether the repository packages should be downloaded with a tool that works with threads (it may be faster). pacman-mirrors must be installed. +arch.config.prefer_repository_provider=Prefer repository dependencies +arch.config.prefer_repository_provider.tip=Automatically picks the single package from the repositories among several external ({}) available as the provider for a given dependency arch.config.refresh_mirrors=Refresh mirrors on startup arch.config.refresh_mirrors.tip=Refresh the package mirrors once a day on startup arch.config.repos=Repositories packages diff --git a/bauh/gems/arch/resources/locale/pt b/bauh/gems/arch/resources/locale/pt index efb101d5..73cfce4c 100644 --- a/bauh/gems/arch/resources/locale/pt +++ b/bauh/gems/arch/resources/locale/pt @@ -72,6 +72,8 @@ arch.config.mirrors_sort_limit.tip=Define o número máximo de espelhos que ser arch.config.optimize=Otimizar {} arch.config.pacman_mthread_download=Download segmentado (repositórios) arch.config.pacman_mthread_download.tip=Se os pacotes dos repositórios devem baixados através de uma ferramenta que trabalha com segmentação/threads (pode ser mais rápido). pacman-mirrors precisa estar instalado. +arch.config.prefer_repository_provider=Preferir dependências de repositórios +arch.config.prefer_repository_provider.tip=Define automaticamente o pacote único proveniente dos repositórios entre diversos externos ({}) disponíveis como provedor de uma dependência arch.config.refresh_mirrors=Atualizar espelhos ao iniciar arch.config.refresh_mirrors.tip=Atualiza os espelhos de pacotes uma vez ao dia na inicialização arch.config.repos=Pacotes de repositórios diff --git a/bauh/gems/arch/resources/locale/ru b/bauh/gems/arch/resources/locale/ru index 6711de93..833dc173 100644 --- a/bauh/gems/arch/resources/locale/ru +++ b/bauh/gems/arch/resources/locale/ru @@ -73,6 +73,8 @@ arch.config.optimize=Оптимизация {} arch.config.optimize.tip=Оптимизированные настройки будут использоваться для ускорения установки пакетов, в противном случае будут использоваться системные настройки arch.config.pacman_mthread_download=Multithreaded download (repositories) arch.config.pacman_mthread_download.tip=Whether the repository packages should be downloaded with a tool that works with threads (it may be faster). pacman-mirrors must be installed. +arch.config.prefer_repository_provider=Prefer repository dependencies +arch.config.prefer_repository_provider.tip=Automatically picks the single package from the repositories among several external ({}) available as the provider for a given dependency arch.config.refresh_mirrors=Обновить зеркала при запуске arch.config.refresh_mirrors.tip=Обновляйте зеркала пакета один раз в день при запуске arch.config.repos=Пакеты репозиториев diff --git a/bauh/gems/arch/resources/locale/tr b/bauh/gems/arch/resources/locale/tr index 5195ea48..de807036 100644 --- a/bauh/gems/arch/resources/locale/tr +++ b/bauh/gems/arch/resources/locale/tr @@ -73,6 +73,8 @@ arch.config.optimize=Optimize {} arch.config.optimize.tip=Paketlerin kurulumunu, yükseltilmesini ve indirilmesini hızlandırmak için optimize edilmiş ayarlar kullanılacak, aksi takdirde sistem ayarları kullanılacak arch.config.pacman_mthread_download=Multithreaded download (repositories) arch.config.pacman_mthread_download.tip=Whether the repository packages should be downloaded with a tool that works with threads (it may be faster). pacman-mirrors must be installed. +arch.config.prefer_repository_provider=Prefer repository dependencies +arch.config.prefer_repository_provider.tip=Automatically picks the single package from the repositories among several external ({}) available as the provider for a given dependency arch.config.refresh_mirrors=Başlangıçta yansıları yenile arch.config.refresh_mirrors.tip=Paket yansılarını başlangıçta günde bir kez yenileyin arch.config.repos=Depo paketleri diff --git a/bauh/gems/arch/updates.py b/bauh/gems/arch/updates.py index 032af4f5..2f5113ce 100644 --- a/bauh/gems/arch/updates.py +++ b/bauh/gems/arch/updates.py @@ -227,7 +227,8 @@ class UpdatesSummarizer: remote_provided_map=context.remote_provided_map, remote_repo_map=context.remote_repo_map, watcher=self.watcher, - automatch_providers=context.arch_config['automatch_providers']) + automatch_providers=context.arch_config['automatch_providers'], + prefer_repository_provider=context.arch_config['prefer_repository_provider']) if deps is None: tf = time.time()