From ef5210b46831d1af1b16c2075aae62ab51f0fc60 Mon Sep 17 00:00:00 2001 From: Vinicius Moreira Date: Mon, 2 Dec 2019 11:36:05 -0300 Subject: [PATCH] [fix][aur] not finding some dependencies declared as files instead of the package names --- CHANGELOG.md | 6 ++++++ README.md | 2 +- bauh/__init__.py | 2 +- bauh/gems/arch/confirmation.py | 2 +- bauh/gems/arch/controller.py | 26 ++++++++++++-------------- bauh/gems/arch/pacman.py | 22 +++++++++++++++++++++- bauh/gems/arch/resources/locale/ca | 3 ++- bauh/gems/arch/resources/locale/de | 3 ++- bauh/gems/arch/resources/locale/en | 3 ++- bauh/gems/arch/resources/locale/es | 3 ++- bauh/gems/arch/resources/locale/it | 3 ++- bauh/gems/arch/resources/locale/pt | 3 ++- 12 files changed, 54 insertions(+), 24 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1d7145b3..c51e57c4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). +## [0.7.4] 2019-12 +### Fixes +- AUR: + - not finding some dependencies declared as files instead of the package names (e.g: dolphin-emu-git ) + + ## [0.7.3] 2019-11-29 ### Improvements - Not breaking the application when a i18n (translation) key was not found diff --git a/README.md b/README.md index 3f151152..09dadc67 100644 --- a/README.md +++ b/README.md @@ -123,7 +123,7 @@ will be pre-downloaded faster ( it does **NOT** modify your **pacman** settings b) same as previous, but related to **COMPRESSXZ** definition ( if '--threads=0' is not defined ) Obs: this feature can be disabled through the environment variable **BAUH_ARCH_OPTIMIZE=0** - ( For more information about these optimizations, have a look at [Makepkg](https://wiki.archlinux.org/index.php/Makepkg) + ( For more information about these optimizations, have a look at [Makepkg](https://wiki.archlinux.org/index.php/Makepkg) ) - Arch package memory-indexer running every 20 minutes. This memory index is used when AUR Api cannot handle the amount of results found for a given search. It can be disabled via the environment variable **BAUH_ARCH_AUR_INDEX_UPDATER=0**. - If some of your installed packages are not categorized, send an e-mail to **bauh4linux@gmail.com** informing their names and categories in the following format: ```name=category1[,category2,category3,...]``` diff --git a/bauh/__init__.py b/bauh/__init__.py index 932ff985..d3a4efa3 100644 --- a/bauh/__init__.py +++ b/bauh/__init__.py @@ -1,4 +1,4 @@ -__version__ = '0.7.3' +__version__ = '0.7.4' __app_name__ = 'bauh' import os diff --git a/bauh/gems/arch/confirmation.py b/bauh/gems/arch/confirmation.py index b1526e23..054acdeb 100644 --- a/bauh/gems/arch/confirmation.py +++ b/bauh/gems/arch/confirmation.py @@ -25,7 +25,7 @@ def request_optional_deps(pkgname: str, pkg_mirrors: dict, watcher: ProcessWatch default_options=None) install = watcher.request_confirmation(title=i18n['arch.install.optdeps.request.title'], - body='

{}

'.format(i18n['arch.install.optdeps.request.body'].format(bold(pkgname)) + ':'), + body='

{}.

{}.

'.format(i18n['arch.install.optdeps.request.body'].format(bold(pkgname)), i18n['arch.install.optdeps.request.help']), components=[view_opts], confirmation_label=i18n['install'], deny_label=i18n['cancel']) diff --git a/bauh/gems/arch/controller.py b/bauh/gems/arch/controller.py index e9078613..53e7bfb8 100644 --- a/bauh/gems/arch/controller.py +++ b/bauh/gems/arch/controller.py @@ -355,21 +355,18 @@ class ArchManager(SoftwareManager): if os.path.exists(temp_dir): shutil.rmtree(temp_dir) - def _install_deps(self, deps: Set[str], pkg_mirrors: dict, root_password: str, handler: ProcessHandler, change_progress: bool = False) -> str: + def _install_deps(self, pkg_mirrors: dict, root_password: str, handler: ProcessHandler, change_progress: bool = False) -> str: """ - :param deps: :param pkg_mirrors: :param root_password: :param handler: :return: not installed dependency """ - progress_increment = int(100 / len(deps)) + progress_increment = int(100 / len(pkg_mirrors)) progress = 0 self._update_progress(handler.watcher, 1, change_progress) - for pkgname in deps: - - mirror = pkg_mirrors[pkgname] + for pkgname, mirror in pkg_mirrors.items(): handler.watcher.change_substatus(self.i18n['arch.install.dependency.install'].format(bold('{} ()'.format(pkgname, mirror)))) if mirror == 'aur': installed = self._install_from_aur(pkgname=pkgname, maintainer=None, root_password=root_password, handler=handler, dependency=True, change_progress=False) @@ -387,7 +384,7 @@ class ArchManager(SoftwareManager): def _map_mirrors(self, pkgnames: Set[str]) -> dict: pkg_mirrors = pacman.get_mirrors(pkgnames) # getting mirrors set - if len(pkgnames) != pkg_mirrors: # checking if any dep not found in the distro mirrors are from AUR + if len(pkgnames) != len(pkg_mirrors): # checking if any dep not found in the distro mirrors are from AUR nomirrors = {p for p in pkgnames if p not in pkg_mirrors} for pkginfo in self.aur_client.get_info(nomirrors): if pkginfo.get('Name') in nomirrors: @@ -470,10 +467,11 @@ class ArchManager(SoftwareManager): depnames = {RE_SPLIT_VERSION.split(dep)[0] for dep in check_res['missing_deps']} dep_mirrors = self._map_mirrors(depnames) - for dep in depnames: # cheking if a dependency could not be found in any mirror - if dep not in dep_mirrors: - message.show_dep_not_found(dep, self.i18n, handler.watcher) - return False + if len(depnames) != len(dep_mirrors): # cheking if a dependency could not be found in any mirror + for dep in depnames: + if dep not in dep_mirrors: + message.show_dep_not_found(dep, self.i18n, handler.watcher) + return False handler.watcher.change_substatus(self.i18n['arch.missing_deps_found'].format(bold(pkgname))) @@ -481,7 +479,7 @@ class ArchManager(SoftwareManager): handler.watcher.print(self.i18n['action.cancelled']) return False - dep_not_installed = self._install_deps(depnames, dep_mirrors, root_password, handler, change_progress=False) + dep_not_installed = self._install_deps(dep_mirrors, root_password, handler, change_progress=False) if dep_not_installed: message.show_dep_not_installed(handler.watcher, pkgname, dep_not_installed, self.i18n) @@ -525,14 +523,14 @@ class ArchManager(SoftwareManager): pkg_mirrors = self._map_mirrors(to_install) if pkg_mirrors: - final_optdeps = {dep: {'desc': odeps.get(dep), 'mirror': pkg_mirrors.get(dep)} for dep in to_install if dep in pkg_mirrors} + final_optdeps = {dep: {'desc': odeps.get(dep), 'mirror': pkg_mirrors.get(dep)} for dep, mirror in pkg_mirrors.items()} deps_to_install = confirmation.request_optional_deps(pkgname, final_optdeps, handler.watcher, self.i18n) if not deps_to_install: return True else: - dep_not_installed = self._install_deps(deps_to_install, pkg_mirrors, root_password, handler, change_progress=True) + dep_not_installed = self._install_deps(pkg_mirrors, root_password, handler, change_progress=True) if dep_not_installed: message.show_optdep_not_installed(dep_not_installed, handler.watcher, self.i18n) diff --git a/bauh/gems/arch/pacman.py b/bauh/gems/arch/pacman.py index 9e8e8d4d..11c551da 100644 --- a/bauh/gems/arch/pacman.py +++ b/bauh/gems/arch/pacman.py @@ -1,6 +1,6 @@ import re from threading import Thread -from typing import List, Set +from typing import List, Set, Tuple from bauh.commons.system import run_cmd, new_subprocess, new_root_subprocess, SystemProcess @@ -13,6 +13,17 @@ def is_enabled() -> bool: return res and not res.strip().startswith('which ') +def get_mirror(pkg: str) -> Tuple[str, str]: + res = run_cmd('pacman -Ss {}'.format(pkg)) + + if res: + lines = res.split('\n') + + if lines: + data = lines[0].split('/') + return data[1].split(' ')[0], data[0] + + def get_mirrors(pkgs: Set[str]) -> dict: pkgre = '|'.join(pkgs).replace('+', r'\+').replace('.', r'\.') @@ -26,6 +37,15 @@ def get_mirrors(pkgs: Set[str]) -> dict: if p in match: mirrors[p] = match.split('/')[0] + not_found = {pkg for pkg in pkgs if pkg not in mirrors} + + if not_found: # if there are any not found, try to find via the single method: + for dep in not_found: + mirror_data = get_mirror(dep) + + if mirror_data: + mirrors[mirror_data[0]] = mirror_data[1] + return mirrors diff --git a/bauh/gems/arch/resources/locale/ca b/bauh/gems/arch/resources/locale/ca index 2c408d43..4ccf68ca 100644 --- a/bauh/gems/arch/resources/locale/ca +++ b/bauh/gems/arch/resources/locale/ca @@ -79,7 +79,8 @@ arch.install.dependency.install.error=No s’ha pogut instal·lar el paquet depe arch.uninstall.required_by=No es pot desinstal·lar {} perquè és necessari per al funcionament dels paquets següents arch.uninstall.required_by.advice=Heu de desinstal·lar-los abans de desinstal·lar {} arch.install.optdeps.request.title=Dependències opcionals -arch.install.optdeps.request.body={} s’ha instal·lat correctament. Hi ha paquets opcionals associats que potser voldreu instal·lar (marqueu els que voleu) +arch.install.optdeps.request.body={} s’ha instal·lat correctament. Hi ha paquets opcionals associats que potser voldreu instal·lar +arch.install.optdeps.request.help=Marqueu els que voleu arch.install.optdep.error=No s’ha pogut instal·lar el paquet opcional {} arch.optdeps.checking=S’estan comprovant les dependències opcionals de {} arch.warning.disabled=Sembla que no s’ha instal·lat {}. No podreu gestionar paquets Arch/AUR. diff --git a/bauh/gems/arch/resources/locale/de b/bauh/gems/arch/resources/locale/de index ac71a2a5..5315ead8 100644 --- a/bauh/gems/arch/resources/locale/de +++ b/bauh/gems/arch/resources/locale/de @@ -47,7 +47,8 @@ arch.install.dependency.install.error=Paket {} konnte nicht installiert werden. arch.uninstall.required_by={} konnte nicht deinstalliert werden, da es für die folgenden Pakete benötigt wird. arch.uninstall.required_by.advice=Deinstalliere sie zuerst, bevor du {} deinstalliert arch.install.optdeps.request.title=Optionale Abhängigkeiten -arch.install.optdeps.request.body={} wurde erfolgreich installiert! Es gibt optionale zugehörige Pakete welche du vielleicht auch installieren möchtest (wähle entsprechende aus) +arch.install.optdeps.request.body={} wurde erfolgreich installiert! Es gibt optionale zugehörige Pakete welche du vielleicht auch installieren möchtest +arch.install.optdeps.request.help=Wähle entsprechende aus arch.install.optdep.error=Optionales Paket {} konnte nicht installiert werden arch.optdeps.checking={} optionale Abhängigkeiten überprüfen arch.warning.disabled={} scheint nicht intstalliert zu sein. Die Verwaltung von Arch / AUR Pakten wird nicht möglich sein. diff --git a/bauh/gems/arch/resources/locale/en b/bauh/gems/arch/resources/locale/en index f51ffcfc..9dfa9425 100644 --- a/bauh/gems/arch/resources/locale/en +++ b/bauh/gems/arch/resources/locale/en @@ -47,7 +47,8 @@ arch.install.dependency.install.error=Could not install dependent package {}. In arch.uninstall.required_by={} cannot be uninstalled because it is necessary for these following packages to work arch.uninstall.required_by.advice=Uninstall them first before uninstalling {}. arch.install.optdeps.request.title=Optional dependencies -arch.install.optdeps.request.body={} was succesfully installed ! There are some optional associated packages that you might want to install ( check those you want ) +arch.install.optdeps.request.body={} was succesfully installed ! There are some optional associated packages that you might want to install +arch.install.optdeps.request.help=Check those you want arch.install.optdep.error=Could not install the optional package {} arch.optdeps.checking=Checking {} optional dependencies arch.warning.disabled={} seems not to be installed. It will not be possible to manage Arch / AUR packages. diff --git a/bauh/gems/arch/resources/locale/es b/bauh/gems/arch/resources/locale/es index 60e47c41..4a14dfc6 100644 --- a/bauh/gems/arch/resources/locale/es +++ b/bauh/gems/arch/resources/locale/es @@ -79,7 +79,8 @@ arch.install.dependency.install.error=No se pudo instalar el paquete dependiente arch.uninstall.required_by=No se puede desinstalar {} porque es necesario para que los siguientes paquetes funcionen arch.uninstall.required_by.advice=Debe desinstalarlos primero antes de desinstalar {} arch.install.optdeps.request.title=Dependencias opcionales -arch.install.optdeps.request.body=¡{} se instaló correctamente! Hay algunos paquetes opcionales asociados que es posible que desee instalar ( marque los que desee ) +arch.install.optdeps.request.body=¡{} se instaló correctamente! Hay algunos paquetes opcionales asociados que es posible que desee instalar +arch.install.optdeps.request.help=Marque los que desee arch.install.optdep.error=No se pudo instalar el paquete opcional {} arch.optdeps.checking=Verificando las dependencias opcionales de {} arch.warning.disabled={} parece no estar instalado. No será posible administrar paquetes Arch / AUR. diff --git a/bauh/gems/arch/resources/locale/it b/bauh/gems/arch/resources/locale/it index c4acadde..483d7e53 100644 --- a/bauh/gems/arch/resources/locale/it +++ b/bauh/gems/arch/resources/locale/it @@ -47,7 +47,8 @@ arch.install.dependency.install.error=Impossibile installare il pacchetto dipend arch.uninstall.required_by={} non può essere disinstallato perché è necessario che i seguenti pacchetti funzionino arch.uninstall.required_by.advice= Uninstall them first before uninstalling {}. arch.install.optdeps.request.title=Dipendenze opzionali -arch.install.optdeps.request.body={} è stato installato con successo! Ci sono alcuni pacchetti associati opzionali che potresti voler installare (controlla quelli che vuoi) +arch.install.optdeps.request.body={} è stato installato con successo! Ci sono alcuni pacchetti associati opzionali che potresti voler installare +arch.install.optdeps.request.help=Controlla quelli che vuoi arch.install.optdep.error=Impossibile installare il pacchetto opzionale {} arch.optdeps.checking=Verifica di {} dipendenze opzionali arch.warning.disabled={} sembra non essere installato. Non sarà possibile gestire i pacchetti Arch/AUR. diff --git a/bauh/gems/arch/resources/locale/pt b/bauh/gems/arch/resources/locale/pt index 8315cbd4..cc952077 100644 --- a/bauh/gems/arch/resources/locale/pt +++ b/bauh/gems/arch/resources/locale/pt @@ -79,7 +79,8 @@ arch.install.dependency.install.error=Não foi possível instalar o pacote depen arch.uninstall.required_by={} não pode ser desinstalado porque ele é necessário para o funcionamento dos seguintes pacotes arch.uninstall.required_by.advice=Desinstale eles primeiro antes de desinstalar {} arch.install.optdeps.request.title=Dependências opcionais -arch.install.optdeps.request.body={} foi instalado com sucesso ! Existem alguns pacotes associados opcionais que você talvez queira instalar ( marque os desejados ) +arch.install.optdeps.request.body={} foi instalado com sucesso ! Existem alguns pacotes opcionais associados que você talvez queira instalar +arch.install.optdeps.request.help=Marque os desejados arch.install.optdep.error=Não foi possível instalar o pacote opcional {} arch.optdeps.checking=Verificando as dependências opcionais de {} arch.warning.disabled={} parece não estar instalado. Não será possível gerenciar pacotes Arch / AUR.