From 68cd434fc1bcfa283cf374ff276c05f8fe862e9c Mon Sep 17 00:00:00 2001 From: Vinicius Moreira Date: Wed, 9 Feb 2022 10:42:58 -0300 Subject: [PATCH 01/17] bumping version to 0.9.27 --- bauh/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bauh/__init__.py b/bauh/__init__.py index 14008bec..6507afdc 100644 --- a/bauh/__init__.py +++ b/bauh/__init__.py @@ -1,4 +1,4 @@ -__version__ = '0.9.26' +__version__ = '0.9.27' __app_name__ = 'bauh' import os From 8000babec87d4bdecc3680688bff2fc5ed82740f Mon Sep 17 00:00:00 2001 From: Vinicius Moreira Date: Wed, 9 Feb 2022 10:43:47 -0300 Subject: [PATCH 02/17] [appimage] fix: displaying duplicate installed apps for some cases (search) --- CHANGELOG.md | 6 ++++++ bauh/gems/appimage/controller.py | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ec346e20..f6b68596 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.9.27] + +### Fixes +- AppImage + - search: displaying duplicate installed apps for some cases + ## [0.9.26] 2022-01-31 ### Improvements diff --git a/bauh/gems/appimage/controller.py b/bauh/gems/appimage/controller.py index 6173b828..15bc9fec 100644 --- a/bauh/gems/appimage/controller.py +++ b/bauh/gems/appimage/controller.py @@ -227,7 +227,7 @@ class AppImageManager(SoftwareManager): installed_found.append(appim) found = True - if not found and lower_words in appim.name.lower() or (appim.description and lower_words in appim.description.lower()): + if not found and (lower_words in appim.name.lower() or (appim.description and lower_words in appim.description.lower())): installed_found.append(appim) try: apps_conn.close() From 66ae8eb152bb3fca361fdaba5dfb72e9a2d4fd76 Mon Sep 17 00:00:00 2001 From: Vinicius Moreira Date: Wed, 9 Feb 2022 10:52:16 -0300 Subject: [PATCH 03/17] [arch] fix: silent crash when handling and displaying transaction sub-status --- CHANGELOG.md | 5 ++++- bauh/gems/arch/output.py | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f6b68596..20867d23 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,8 +7,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## [0.9.27] ### Fixes +- Arch + - silent crash when handling and displaying transaction sub-status + - AppImage - - search: displaying duplicate installed apps for some cases + - search: displaying duplicate installed apps for some cases ## [0.9.26] 2022-01-31 diff --git a/bauh/gems/arch/output.py b/bauh/gems/arch/output.py index b6e211f7..7cd66a06 100644 --- a/bauh/gems/arch/output.py +++ b/bauh/gems/arch/output.py @@ -57,7 +57,7 @@ class TransactionStatusHandler(Thread): else: self.watcher.change_substatus('{} {}'.format(self.i18n['uninstalling'].capitalize(), output_split[1].strip())) - elif output_split[1].lower().startswith('downloading') and (not self.names or (n for n in self.names if output_split[0].startswith(n))): + elif len(output_split) >= 2 and output_split[1].lower().startswith('downloading') and (not self.names or (n for n in self.names if output_split[0].startswith(n))): if self.downloading < self.pkgs_to_sync: perc = self.gen_percentage() self.downloading += 1 From cd9b465f898ed9d89fff91e47bd84bd0df13a22a Mon Sep 17 00:00:00 2001 From: Vinicius Moreira Date: Wed, 9 Feb 2022 11:01:21 -0300 Subject: [PATCH 04/17] [arch.output] refactoring: String formatting method --- CHANGELOG.md | 4 ++++ bauh/gems/arch/output.py | 25 +++++++++++++------------ 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 20867d23..418b2334 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## [0.9.27] +### Improvements +- code refactoring (String formatting method) + ### Fixes - Arch - silent crash when handling and displaying transaction sub-status @@ -13,6 +16,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - AppImage - search: displaying duplicate installed apps for some cases + ## [0.9.26] 2022-01-31 ### Improvements diff --git a/bauh/gems/arch/output.py b/bauh/gems/arch/output.py index 7cd66a06..b0eca16d 100644 --- a/bauh/gems/arch/output.py +++ b/bauh/gems/arch/output.py @@ -37,7 +37,7 @@ class TransactionStatusHandler(Thread): def gen_percentage(self) -> str: if self.percentage: performed = self.downloading + self.upgrading + self.installing - return '({0:.2f}%) '.format((performed / (2 * self.pkgs_to_sync)) * 100) + return f'({(performed / (2 * self.pkgs_to_sync)) * 100:.2f}%) ' else: return '' @@ -52,18 +52,19 @@ class TransactionStatusHandler(Thread): if self.pkgs_to_remove > 0: self.removing += 1 - self.watcher.change_substatus('[{}/{}] {} {}'.format(self.removing, self.pkgs_to_remove, - self.i18n['uninstalling'].capitalize(), output.split(' ')[1].strip())) + self.watcher.change_substatus(f"[{self.removing}/{self.pkgs_to_remove}] " + f"{self.i18n['uninstalling'].capitalize()} {output.split(' ')[1].strip()}") else: - self.watcher.change_substatus('{} {}'.format(self.i18n['uninstalling'].capitalize(), output_split[1].strip())) + self.watcher.change_substatus(f"{self.i18n['uninstalling'].capitalize()} {output_split[1].strip()}") elif len(output_split) >= 2 and output_split[1].lower().startswith('downloading') and (not self.names or (n for n in self.names if output_split[0].startswith(n))): if self.downloading < self.pkgs_to_sync: perc = self.gen_percentage() self.downloading += 1 - self.watcher.change_substatus('{}[{}/{}] {} {} {}'.format(perc, self.downloading, self.pkgs_to_sync, bold('[pacman]'), - self.i18n['downloading'].capitalize(), output_split[0].strip())) + self.watcher.change_substatus(f"{perc}[{self.downloading}/{self.pkgs_to_sync}] {bold('[pacman]')} " + f"{self.i18n['downloading'].capitalize()} {output_split[0].strip()}") + elif output_split[0].lower() == 'upgrading' and (not self.names or output_split[1].split('.')[0] in self.names): if self.get_performed() < self.pkgs_to_sync: perc = self.gen_percentage() @@ -72,8 +73,9 @@ class TransactionStatusHandler(Thread): performed = self.upgrading + self.installing if performed <= self.pkgs_to_sync: - self.watcher.change_substatus('{}[{}/{}] {} {}'.format(perc, performed, self.pkgs_to_sync, - self.i18n['manage_window.status.upgrading'].capitalize(), output_split[1].strip())) + self.watcher.change_substatus(f"{perc}[{performed}/{self.pkgs_to_sync}] " + f"{self.i18n['manage_window.status.upgrading'].capitalize()} {output_split[1].strip()}") + elif output_split[0].lower() == 'installing' and (not self.names or output_split[1].split('.')[0] in self.names): if self.get_performed() < self.pkgs_to_sync: perc = self.gen_percentage() @@ -82,15 +84,14 @@ class TransactionStatusHandler(Thread): performed = self.upgrading + self.installing if performed <= self.pkgs_to_sync: - self.watcher.change_substatus('{}[{}/{}] {} {}'.format(perc, performed, self.pkgs_to_sync, - self.i18n['manage_window.status.installing'].capitalize(), - output_split[1].strip())) + self.watcher.change_substatus(f"{perc}[{performed}/{self.pkgs_to_sync}] " + f"{self.i18n['manage_window.status.installing'].capitalize()} {output_split[1].strip()}") else: substatus_found = False lower_output = output.lower().strip() for msg, key in self.accepted.items(): if lower_output.startswith(msg): - self.watcher.change_substatus(self.i18n['arch.substatus.{}'.format(key)].capitalize()) + self.watcher.change_substatus(self.i18n[f'arch.substatus.{key}'].capitalize()) substatus_found = True break From ddf0b92cf72469513953f2aeccb1397cc04d2c9c Mon Sep 17 00:00:00 2001 From: Vinicius Moreira Date: Wed, 9 Feb 2022 14:14:46 -0300 Subject: [PATCH 05/17] [arch] fix: not detecting installed AUR packages anymore due to recent AUR API changes --- CHANGELOG.md | 1 + bauh/gems/arch/aur.py | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 418b2334..ed69c3b6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### Fixes - Arch - silent crash when handling and displaying transaction sub-status + - AUR: not detecting installed packages anymore due to recent AUR API changes - AppImage - search: displaying duplicate installed apps for some cases diff --git a/bauh/gems/arch/aur.py b/bauh/gems/arch/aur.py index e5054e45..09129fe8 100644 --- a/bauh/gems/arch/aur.py +++ b/bauh/gems/arch/aur.py @@ -214,8 +214,8 @@ class AURClient: return self.extract_required_dependencies(info) - def _map_names_as_queries(self, names) -> str: - return '&'.join(['arg[{}]={}'.format(i, urllib.parse.quote(n)) for i, n in enumerate(names)]) + def _map_names_as_queries(self, names: Iterable[str]) -> str: + return '&'.join(['arg[]={}'.format(urllib.parse.quote(n)) for n in names]) def read_local_index(self) -> dict: self.logger.info('Checking if the cached AUR index file exists') From 9564ce32374bdc032699df7e446911af43b58d86 Mon Sep 17 00:00:00 2001 From: Vinicius Moreira Date: Wed, 9 Feb 2022 14:24:01 -0300 Subject: [PATCH 06/17] [arch] fix: installation fails when several dependent packages conflict with the installed ones --- CHANGELOG.md | 1 + bauh/gems/arch/controller.py | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ed69c3b6..03c1b544 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/). - Arch - silent crash when handling and displaying transaction sub-status - AUR: not detecting installed packages anymore due to recent AUR API changes + - installation fails when several dependent packages conflict with the installed ones - AppImage - search: displaying duplicate installed apps for some cases diff --git a/bauh/gems/arch/controller.py b/bauh/gems/arch/controller.py index a93d9442..942d631d 100644 --- a/bauh/gems/arch/controller.py +++ b/bauh/gems/arch/controller.py @@ -1322,9 +1322,13 @@ class ArchManager(SoftwareManager): else: instances = None + provided_by_uninstalled = pacman.map_provided(pkgs=to_uninstall) + uninstalled = self._uninstall_pkgs(to_uninstall, context.root_password, context.handler, ignore_dependencies=skip_requirements) if uninstalled: + self._remove_uninstalled_from_context(provided_by_uninstalled, context) + if disk_loader: # loading package instances in case the uninstall succeeds if instances: for p in instances: @@ -1395,6 +1399,22 @@ class ArchManager(SoftwareManager): self._update_progress(context, 100) return uninstalled + def _remove_uninstalled_from_context(self, provided_by_uninstalled: Dict[str, Set[str]], context: TransactionContext): + if context.provided_map and provided_by_uninstalled: # updating the current provided context + for name, provided in provided_by_uninstalled.items(): + if name in context.provided_map: + del context.provided_map[name] + + if provided: + for exp in provided: + exp_provided = context.provided_map.get(exp) + + if exp_provided and name in exp_provided: + exp_provided.remove(name) + + if not exp_provided: + del context.provided_map[exp] + def uninstall(self, pkg: ArchPackage, root_password: str, watcher: ProcessWatcher, disk_loader: DiskCacheLoader) -> TransactionResult: self.aur_client.clean_caches() @@ -1703,6 +1723,8 @@ class ArchManager(SoftwareManager): res = self._uninstall(context=context, names={conflicting_pkg}, disk_loader=context.disk_loader, remove_unneeded=False, skip_requirements=skip_requirements) + + context.restabilish_progress() return res From e84f88d37d44dda4b0d0338b8dcc3c95dfd9d438 Mon Sep 17 00:00:00 2001 From: Vinicius Moreira Date: Thu, 10 Feb 2022 11:09:32 -0300 Subject: [PATCH 07/17] [arch] improvement: preventing AUR's installed packages from not being mapped in cases the communication with the API fails --- CHANGELOG.md | 4 +- bauh/gems/arch/aur.py | 70 ++++++++++++-------- bauh/gems/arch/controller.py | 120 +++++++++++++++++++---------------- 3 files changed, 112 insertions(+), 82 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 03c1b544..a43f0337 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## [0.9.27] ### Improvements -- code refactoring (String formatting method) +- Arch: + - preventing AUR's installed packages from not being mapped in cases the communication with the API fails + - code refactoring (String formatting method) ### Fixes - Arch diff --git a/bauh/gems/arch/aur.py b/bauh/gems/arch/aur.py index 09129fe8..7a3b62e2 100644 --- a/bauh/gems/arch/aur.py +++ b/bauh/gems/arch/aur.py @@ -112,12 +112,29 @@ class AURClient: def search(self, words: str) -> dict: return self.http_client.get_json(URL_SEARCH + words) - def get_info(self, names: Iterable[str]) -> List[dict]: + def get_info(self, names: Iterable[str]) -> Optional[List[dict]]: try: res = self.http_client.get_json(URL_INFO + self._map_names_as_queries(names)) - return res['results'] if res and res.get('results') else [] - except: - return [] + except requests.exceptions.ConnectionError: + self.logger.warning('Could not retrieve installed AUR packages API data. It seems the internet connection is off.') + return + + if res is None: + self.logger.warning("Call to AUR API's info endpoint has failed") + return + + error = res.get('error') + + if error: + self.logger.warning(f"AUR API's info endpoint returned an unexpected error: {error}") + return + + results = res.get('results') + + if results is not None: + return results + + self.logger.warning(f"AUR API's info endpoint returned an unexpected response: {res}") def map_provided(self, pkgname: str, pkgver: str, provided: Optional[Iterable[str]] = None, strip_epoch: bool = True) -> Set[str]: all_provided = {pkgname, f"{pkgname}={pkgver.split('-')[0] if strip_epoch else pkgver}"} @@ -130,31 +147,34 @@ class AURClient: return all_provided def gen_updates_data(self, names: Iterable[str]) -> Generator[Tuple[str, dict], None, None]: - for package in self.get_info(names): - pkgname, pkgver = package['Name'], package['Version'].split('-')[0] + pkgs_info = self.get_info(names) - deps = set() + if pkgs_info: + for package in pkgs_info: + pkgname, pkgver = package['Name'], package['Version'].split('-')[0] - for dtype in ('Depends', 'MakeDepends', 'CheckDepends'): - dep_set = package.get(dtype) - if dep_set: - deps.update(dep_set) + deps = set() - conflicts = set() - pkg_conflicts = package.get('Conflicts') + for dtype in ('Depends', 'MakeDepends', 'CheckDepends'): + dep_set = package.get(dtype) + if dep_set: + deps.update(dep_set) - if pkg_conflicts: - conflicts.update(pkg_conflicts) + conflicts = set() + pkg_conflicts = package.get('Conflicts') - yield pkgname, { - 'v': pkgver, - 'b': package.get('PackageBase', pkgname), - 'r': 'aur', - 'p': self.map_provided(pkgname=pkgname, pkgver=pkgver, provided=package.get('Provides'), strip_epoch=False), - 'd': deps, - 'c': conflicts, - 'ds': None, - 's': None} + if pkg_conflicts: + conflicts.update(pkg_conflicts) + + yield pkgname, { + 'v': pkgver, + 'b': package.get('PackageBase', pkgname), + 'r': 'aur', + 'p': self.map_provided(pkgname=pkgname, pkgver=pkgver, provided=package.get('Provides'), strip_epoch=False), + 'd': deps, + 'c': conflicts, + 'ds': None, + 's': None} def get_src_info(self, name: str, real_name: Optional[str] = None) -> dict: srcinfo = self.srcinfo_cache.get(name) @@ -215,7 +235,7 @@ class AURClient: return self.extract_required_dependencies(info) def _map_names_as_queries(self, names: Iterable[str]) -> str: - return '&'.join(['arg[]={}'.format(urllib.parse.quote(n)) for n in names]) + return '&'.join((f'arg[]={urllib.parse.quote(n)}' for n in names)) def read_local_index(self) -> dict: self.logger.info('Checking if the cached AUR index file exists') diff --git a/bauh/gems/arch/controller.py b/bauh/gems/arch/controller.py index 942d631d..8af0c9c8 100644 --- a/bauh/gems/arch/controller.py +++ b/bauh/gems/arch/controller.py @@ -14,7 +14,6 @@ from pwd import getpwnam from threading import Thread from typing import List, Set, Type, Tuple, Dict, Iterable, Optional, Collection, Generator -import requests from dateutil.parser import parse as parse_date from bauh import __app_name__ @@ -412,67 +411,72 @@ class ArchManager(SoftwareManager): res.update_total() return res - def _fill_aur_pkgs(self, aur_pkgs: dict, output: List[ArchPackage], disk_loader: DiskCacheLoader, internet_available: bool, + def _fill_aur_pkgs_offline(self, aur_pkgs: dict, arch_config: dict, output: List[ArchPackage], disk_loader: Optional[DiskCacheLoader]): + self.logger.info("Reading cached data from installed AUR packages") + + editable_pkgbuilds = self._read_editable_pkgbuilds() if arch_config['edit_aur_pkgbuild'] is not False else None + for name, data in aur_pkgs.items(): + pkg = ArchPackage(name=name, version=data.get('version'), + latest_version=data.get('version'), description=data.get('description'), + installed=True, repository='aur', i18n=self.i18n) + + pkg.categories = self.categories.get(pkg.name) + pkg.pkgbuild_editable = pkg.name in editable_pkgbuilds if editable_pkgbuilds is not None else None + + if disk_loader: + disk_loader.fill(pkg) + + pkg.status = PackageStatus.READY + output.append(pkg) + + def _fill_aur_pkgs(self, aur_pkgs: dict, output: List[ArchPackage], disk_loader: Optional[DiskCacheLoader], internet_available: bool, arch_config: dict, rebuild_check: Optional[Thread], rebuild_ignored: Optional[Thread], rebuild_output: Optional[Dict[str, Set[str]]]): - if internet_available: - try: - pkgsinfo = self.aur_client.get_info(aur_pkgs.keys()) - except requests.exceptions.ConnectionError: - self.logger.warning('Could not retrieve installed AUR packages API data. It seems the internet connection is off.') - self.logger.info("Reading only local AUR packages data") - return + if not internet_available: + self._fill_aur_pkgs_offline(aur_pkgs=aur_pkgs, arch_config=arch_config, + output=output, disk_loader=disk_loader) + return - if pkgsinfo: - editable_pkgbuilds = self._read_editable_pkgbuilds() if arch_config['edit_aur_pkgbuild'] is not False else None - - ignore_rebuild_check = None - if rebuild_ignored and rebuild_output is not None: - rebuild_ignored.join() - ignore_rebuild_check = rebuild_output['ignored'] - - to_rebuild = None - if rebuild_check and rebuild_output is not None: - self.logger.info("Waiting for rebuild-detector") - rebuild_check.join() - to_rebuild = rebuild_output['to_rebuild'] - - for pkgdata in pkgsinfo: - pkg = self.aur_mapper.map_api_data(pkgdata, aur_pkgs, self.categories) - pkg.pkgbuild_editable = pkg.name in editable_pkgbuilds if editable_pkgbuilds is not None else None - - if pkg.installed: - if disk_loader: - disk_loader.fill(pkg, sync=True) - - pkg.update = self._check_aur_package_update(pkg=pkg, - installed_data=aur_pkgs.get(pkg.name, {}), - api_data=pkgdata) - pkg.aur_update = pkg.update # used in 'set_rebuild_check' - - if ignore_rebuild_check is not None: - pkg.allow_rebuild = pkg.name not in ignore_rebuild_check - - if to_rebuild and not pkg.update and pkg.name in to_rebuild: - pkg.require_rebuild = True - - pkg.update_state() - - pkg.status = PackageStatus.READY - output.append(pkg) + pkgsinfo = self.aur_client.get_info(aur_pkgs.keys()) + if pkgsinfo is None: + self._fill_aur_pkgs_offline(aur_pkgs=aur_pkgs, arch_config=arch_config, output=output, disk_loader=disk_loader) + elif not pkgsinfo: + self.logger.warning("No data found for the supposed installed AUR packages returned from AUR API's info endpoint") else: editable_pkgbuilds = self._read_editable_pkgbuilds() if arch_config['edit_aur_pkgbuild'] is not False else None - for name, data in aur_pkgs.items(): - pkg = ArchPackage(name=name, version=data.get('version'), - latest_version=data.get('version'), description=data.get('description'), - installed=True, repository='aur', i18n=self.i18n) - pkg.categories = self.categories.get(pkg.name) + ignore_rebuild_check = None + if rebuild_ignored and rebuild_output is not None: + rebuild_ignored.join() + ignore_rebuild_check = rebuild_output['ignored'] + + to_rebuild = None + if rebuild_check and rebuild_output is not None: + self.logger.info("Waiting for rebuild-detector") + rebuild_check.join() + to_rebuild = rebuild_output['to_rebuild'] + + for pkgdata in pkgsinfo: + pkg = self.aur_mapper.map_api_data(pkgdata, aur_pkgs, self.categories) pkg.pkgbuild_editable = pkg.name in editable_pkgbuilds if editable_pkgbuilds is not None else None - if disk_loader: - disk_loader.fill(pkg) + if pkg.installed: + if disk_loader: + disk_loader.fill(pkg, sync=True) + + pkg.update = self._check_aur_package_update(pkg=pkg, + installed_data=aur_pkgs.get(pkg.name, {}), + api_data=pkgdata) + pkg.aur_update = pkg.update # used in 'set_rebuild_check' + + if ignore_rebuild_check is not None: + pkg.allow_rebuild = pkg.name not in ignore_rebuild_check + + if to_rebuild and not pkg.update and pkg.name in to_rebuild: + pkg.require_rebuild = True + + pkg.update_state() pkg.status = PackageStatus.READY output.append(pkg) @@ -1811,9 +1815,13 @@ class ArchManager(SoftwareManager): if len(pkgnames) != len(pkg_repos): # checking if any dep not found in the distro repos are from AUR norepos = {p for p in pkgnames if p not in pkg_repos} - for pkginfo in self.aur_client.get_info(norepos): - if pkginfo.get('Name') in norepos: - pkg_repos[pkginfo['Name']] = 'aur' + + aur_info = self.aur_client.get_info(norepos) + + if aur_info: + for pkginfo in aur_info: + if pkginfo.get('Name') in norepos: + pkg_repos[pkginfo['Name']] = 'aur' return pkg_repos From 4ae77312b7f36d75cb19e3f85e612c11b55035a9 Mon Sep 17 00:00:00 2001 From: Vinicius Moreira Date: Thu, 10 Feb 2022 11:23:15 -0300 Subject: [PATCH 08/17] [setup] improvement: able to install bauh with python/pip without enforcing requirements --- CHANGELOG.md | 3 +++ setup.py | 7 +++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a43f0337..7287f455 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - preventing AUR's installed packages from not being mapped in cases the communication with the API fails - code refactoring (String formatting method) +- Setup + - able to install bauh with python/pip without enforcing requirements through the environment variable `BAUH_SETUP_NO_REQS=1` + ### Fixes - Arch - silent crash when handling and displaying transaction sub-status diff --git a/setup.py b/setup.py index 6b6302d4..920927b9 100644 --- a/setup.py +++ b/setup.py @@ -14,8 +14,11 @@ URL = "https://github.com/vinifmor/" + NAME file_dir = os.path.dirname(os.path.abspath(__file__)) -with open(file_dir + '/requirements.txt', 'r') as f: - requirements = [line.strip() for line in f.readlines() if line] +if os.getenv('BAUH_SETUP_NO_REQS'): + requirements = [] +else: + with open(f'{file_dir}/requirements.txt', 'r') as f: + requirements = [line.strip() for line in f.readlines() if line] with open(file_dir + '/{}/__init__.py'.format(NAME), 'r') as f: From 8225efc4817ce49dd7766234936f75f37cc50702 Mon Sep 17 00:00:00 2001 From: Vinicius Moreira Date: Thu, 10 Feb 2022 11:23:53 -0300 Subject: [PATCH 09/17] [README.md] Updating Ubuntu installation title --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index da06f925..17611ad7 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ Key features ## Index 1. [Installation](#installation) - [AppImage](#inst_appimage) - - [Ubuntu-based distros (20.04)](#inst_ubuntu) + - [Ubuntu 20.04 based distros (Linux Mint, PopOS, ...)](#inst_ubuntu) - [Arch-based distros](#inst_arch) 2. [Isolated installation](#inst_iso) 3. [Desktop entry / menu shortcut](#desk_entry) @@ -56,7 +56,7 @@ Key features - Run the following command through a terminal: `chmod a+x bauh-${version}-x86_64.AppImage` (replace `${version}` by the respective downloaded version) - Launch it: `./bauh-${version}-x86_64.AppImage` -#### Ubuntu-based distros (20.04) +#### Ubuntu 20.04 based distros (Linux Mint, PopOS, ...) ##### Required dependencies @@ -66,6 +66,7 @@ Key features `sudo pip3 install bauh` + ##### Optional dependencies (they should be installed with apt-get/apt) - `timeshift`: system backup From 1ba610da9d651f627b3c6163bbcf8ecfd17276b5 Mon Sep 17 00:00:00 2001 From: Vinicius Moreira Date: Thu, 10 Feb 2022 14:29:16 -0300 Subject: [PATCH 10/17] [AppImageBuilder.yml] -~50% size reduction --- AppImageBuilder.yml | 14 +++++++------- CHANGELOG.md | 4 ++++ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/AppImageBuilder.yml b/AppImageBuilder.yml index 53463576..193a9015 100755 --- a/AppImageBuilder.yml +++ b/AppImageBuilder.yml @@ -26,7 +26,6 @@ AppDir: - python3 - python3-pip - python3-setuptools - - python3-wheel - python3-requests - python3-colorama - python3-dateutil @@ -36,19 +35,20 @@ AppDir: - python3-lxml - python3-bs4 - sqlite3 - - axel - - aria2 - wget - libfreetype6 - libfontconfig1 exclude: [] - after_bundle: - - pip3 install bauh==$BAUH_VERSION --prefix=/usr --root=AppDir + after_bundle: - mkdir -p AppDir/usr/share/icons/hicolor/scalable/apps - - cp AppDir/usr/lib/python3.8/site-packages/bauh/view/resources/img/logo.svg AppDir/usr/share/icons/hicolor/scalable/apps/bauh.svg - mkdir -p AppDir/usr/share/applications - - cp AppDir/usr/lib/python3.8/site-packages/bauh/desktop/bauh.desktop AppDir/usr/share/applications + - wget https://github.com/vinifmor/bauh/archive/${BAUH_VERSION}.tar.gz || exit 1 + - tar -xf ${BAUH_VERSION}.tar.gz || exit 1 + - cd bauh-${BAUH_VERSION} || exit 1 + - cp bauh/view/resources/img/logo.svg ../AppDir/usr/share/icons/hicolor/scalable/apps/bauh.svg || exit 1 + - cp bauh/desktop/bauh.desktop ../AppDir/usr/share/applications || exit 1 + - BAUH_SETUP_NO_REQS=1 python3 setup.py install --prefix=/usr --root=../AppDir --optimize=1 || exit 1 runtime: version: "continuous" diff --git a/CHANGELOG.md b/CHANGELOG.md index 7287f455..577ef3bc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Setup - able to install bauh with python/pip without enforcing requirements through the environment variable `BAUH_SETUP_NO_REQS=1` +- Distribution + - AppImage: -~50% size reduction (141.93 MB -> 72.20 MB) + + ### Fixes - Arch - silent crash when handling and displaying transaction sub-status From c578a62ad37abfd9aeb15d873fa7ce3660d89afd Mon Sep 17 00:00:00 2001 From: Vinicius Moreira Date: Thu, 10 Feb 2022 14:44:57 -0300 Subject: [PATCH 11/17] refactoring: moving AppImageBuilder.yml --- .gitignore | 7 +++++++ .../appimage/AppImageBuilder.yml | 0 2 files changed, 7 insertions(+) rename AppImageBuilder.yml => linux_dist/appimage/AppImageBuilder.yml (100%) diff --git a/.gitignore b/.gitignore index 755921a6..3a173d7d 100755 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,10 @@ dist *.egg-info build *.db +linux_dist/appimage/AppDir +linux_dist/appimage/appimage-builder-cache +linux_dist/appimage/*.zsync +linux_dist/appimage/*.AppImage +linux_dist/appimage/*.gz +linux_dist/appimage/bauh-* + diff --git a/AppImageBuilder.yml b/linux_dist/appimage/AppImageBuilder.yml similarity index 100% rename from AppImageBuilder.yml rename to linux_dist/appimage/AppImageBuilder.yml From 222fe0078686557964513055122d323e6024fe46 Mon Sep 17 00:00:00 2001 From: Vinicius Moreira Date: Thu, 10 Feb 2022 14:47:47 -0300 Subject: [PATCH 12/17] [CHANGELOG.md] reference to AppImageBuilder.yml changes --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 577ef3bc..72ee4e76 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,7 +15,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - able to install bauh with python/pip without enforcing requirements through the environment variable `BAUH_SETUP_NO_REQS=1` - Distribution - - AppImage: -~50% size reduction (141.93 MB -> 72.20 MB) + - AppImage: -~50% size reduction (141.93 MB -> 72.20 MB) [#1ba610da9d651f627b3c6163bbcf8ecfd17276b5](https://github.com/vinifmor/bauh/commit/1ba610da9d651f627b3c6163bbcf8ecfd17276b5) ### Fixes From 3eb27466ad33ef69513009d778951614b1aadff1 Mon Sep 17 00:00:00 2001 From: Vinicius Moreira Date: Fri, 11 Feb 2022 15:05:13 -0300 Subject: [PATCH 13/17] [AppImageBuilder.yml] fix: missing Qt components (mainly related to SVG handling) --- CHANGELOG.md | 2 +- linux_dist/appimage/AppImageBuilder.yml | 49 +++++++++++++++++-------- 2 files changed, 34 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 72ee4e76..194f4ff0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,7 +15,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - able to install bauh with python/pip without enforcing requirements through the environment variable `BAUH_SETUP_NO_REQS=1` - Distribution - - AppImage: -~50% size reduction (141.93 MB -> 72.20 MB) [#1ba610da9d651f627b3c6163bbcf8ecfd17276b5](https://github.com/vinifmor/bauh/commit/1ba610da9d651f627b3c6163bbcf8ecfd17276b5) + - AppImage: -~32% size reduction (141.93 MB -> 96.32 MB) ### Fixes diff --git a/linux_dist/appimage/AppImageBuilder.yml b/linux_dist/appimage/AppImageBuilder.yml index 193a9015..14c423dc 100755 --- a/linux_dist/appimage/AppImageBuilder.yml +++ b/linux_dist/appimage/AppImageBuilder.yml @@ -2,6 +2,14 @@ version: 1 script: - rm -rf AppDir appimage-builder-cache *.AppImage *.zsync |true - mkdir -p AppDir/usr + - mkdir -p AppDir/usr/share/icons/hicolor/scalable/apps + - mkdir -p AppDir/usr/share/applications + - wget https://github.com/vinifmor/bauh/archive/${BAUH_VERSION}.tar.gz || exit 1 + - BAUH_SETUP_NO_REQS=1 pip3 install ${BAUH_VERSION}.tar.gz --prefix=/usr --root=AppDir || exit 1 + - tar -xf ${BAUH_VERSION}.tar.gz || exit 1 + - cd bauh-${BAUH_VERSION} || exit 1 + - cp bauh/view/resources/img/logo.svg ../AppDir/usr/share/icons/hicolor/scalable/apps/bauh.svg || exit 1 + - cp bauh/desktop/bauh.desktop ../AppDir/usr/share/applications || exit 1 AppDir: @@ -14,7 +22,7 @@ AppDir: version: !ENV ${BAUH_VERSION} exec: /usr/bin/python3 exec_args: "$APPDIR/usr/bin/bauh $@" - + apt: arch: amd64 @@ -24,31 +32,40 @@ AppDir: include: - python3 - - python3-pip - - python3-setuptools - python3-requests - python3-colorama - python3-dateutil - python3-yaml - python3-packaging - - python3-pyqt5 - python3-lxml - python3-bs4 - sqlite3 - wget - - libfreetype6 - - libfontconfig1 - exclude: [] + # - libfreetype6 + # - libfontconfig1 + exclude: + - dpkg + - apt + - aptitude + - python3-pip + - python3-setuptools + - python3-distutils + - libc-bin + - libc-dev-bin + - libc6 + - libc6-dbg + - libc6-dev + + after_bundle: + - pip3 install pyqt5 --prefix=/usr --root=AppDir || exit 1 + - cd AppDir/usr/lib/python3.8/site-packages/PyQt5/Qt5/plugins || exit 1 + - rm -rf audio gamepad gamepads geoservices printsupport sceneparsers sensorgestures sensors sqldrivers texttospeech webview || exit 1 + - cd ../ + - cd lib/ || exit 1 + - rm libQt5Bluetooth.so.5 libQt5Designer.so.5 libQt5Multimedia.so.5 libQt5MultimediaGstTools.so.5 libQt5MultimediaWidgets.so.5 || exit 1 + - rm libQt5Quick3D.so.5 libQt5Quick3DAssetImport.so.5 libQt5Quick3DRender.so.5 libQt5Quick3DRuntimeRender.so.5 libQt5QuickTest.so.5 || exit 1 + - rm libQt5Quick3DUtils.so.5 libQt5PrintSupport.so.5 libQt5SerialPort.so.5 libQt5Sql.so.5 libQt5Sensors.so.5 libQt5Test.so.5 libQt5WebView.so.5 || exit 1 - after_bundle: - - mkdir -p AppDir/usr/share/icons/hicolor/scalable/apps - - mkdir -p AppDir/usr/share/applications - - wget https://github.com/vinifmor/bauh/archive/${BAUH_VERSION}.tar.gz || exit 1 - - tar -xf ${BAUH_VERSION}.tar.gz || exit 1 - - cd bauh-${BAUH_VERSION} || exit 1 - - cp bauh/view/resources/img/logo.svg ../AppDir/usr/share/icons/hicolor/scalable/apps/bauh.svg || exit 1 - - cp bauh/desktop/bauh.desktop ../AppDir/usr/share/applications || exit 1 - - BAUH_SETUP_NO_REQS=1 python3 setup.py install --prefix=/usr --root=../AppDir --optimize=1 || exit 1 runtime: version: "continuous" From babb4b56610fe3e761d5cec26a6e2d4a0351141d Mon Sep 17 00:00:00 2001 From: Vinicius Moreira Date: Fri, 11 Feb 2022 15:23:23 -0300 Subject: [PATCH 14/17] [arch] fix: crashing when no AUR package name is informed to the AUR client --- bauh/gems/arch/aur.py | 35 +++++++++++++------------- bauh/gems/arch/dependencies.py | 46 ++++++++++++++++++---------------- 2 files changed, 43 insertions(+), 38 deletions(-) diff --git a/bauh/gems/arch/aur.py b/bauh/gems/arch/aur.py index 7a3b62e2..24cab409 100644 --- a/bauh/gems/arch/aur.py +++ b/bauh/gems/arch/aur.py @@ -113,28 +113,29 @@ class AURClient: return self.http_client.get_json(URL_SEARCH + words) def get_info(self, names: Iterable[str]) -> Optional[List[dict]]: - try: - res = self.http_client.get_json(URL_INFO + self._map_names_as_queries(names)) - except requests.exceptions.ConnectionError: - self.logger.warning('Could not retrieve installed AUR packages API data. It seems the internet connection is off.') - return + if names: + try: + res = self.http_client.get_json(URL_INFO + self._map_names_as_queries(names)) + except requests.exceptions.ConnectionError: + self.logger.warning('Could not retrieve installed AUR packages API data. It seems the internet connection is off.') + return - if res is None: - self.logger.warning("Call to AUR API's info endpoint has failed") - return + if res is None: + self.logger.warning("Call to AUR API's info endpoint has failed") + return - error = res.get('error') + error = res.get('error') - if error: - self.logger.warning(f"AUR API's info endpoint returned an unexpected error: {error}") - return + if error: + self.logger.warning(f"AUR API's info endpoint returned an unexpected error: {error}") + return - results = res.get('results') + results = res.get('results') - if results is not None: - return results + if results is not None: + return results - self.logger.warning(f"AUR API's info endpoint returned an unexpected response: {res}") + self.logger.warning(f"AUR API's info endpoint returned an unexpected response: {res}") def map_provided(self, pkgname: str, pkgver: str, provided: Optional[Iterable[str]] = None, strip_epoch: bool = True) -> Set[str]: all_provided = {pkgname, f"{pkgname}={pkgver.split('-')[0] if strip_epoch else pkgver}"} @@ -195,7 +196,7 @@ class AURClient: self.logger.warning('No .SRCINFO found for {}'.format(name)) self.logger.info('Checking if {} is based on another package'.format(name)) # if was not found, it may be based on another package. - infos = self.get_info({name}) + infos = self.get_info((name,)) if infos: info = infos[0] diff --git a/bauh/gems/arch/dependencies.py b/bauh/gems/arch/dependencies.py index 34b94f4d..328d10c3 100644 --- a/bauh/gems/arch/dependencies.py +++ b/bauh/gems/arch/dependencies.py @@ -264,24 +264,26 @@ class DependenciesAnalyser: aur_search = self.aur_client.search(dep_name) if aur_search: - if dep_name == dep_exp: - version_required, exp_op = None, None - else: - split_informed_dep = self.re_dep_operator.split(dep_exp) - version_required = split_informed_dep[2] - exp_op = split_informed_dep[1] if split_informed_dep[1] != '=' else '==' + aur_results = aur_search.get('results') - for pkgname, pkgdata in self.aur_client.gen_updates_data( - (aur_res['Name'] for aur_res in aur_search['results'])): - if pkgname == dep_name or (dep_name in pkgdata['p']): - try: - if not version_required or match_required_version(pkgdata['v'], exp_op, - version_required): - yield pkgname, pkgdata - except: - self._log.warning(f"Could not compare AUR package '{pkgname}' version '{pkgdata['v']}' " - f"with the dependency expression '{dep_exp}'") - traceback.print_exc() + if aur_results: + if dep_name == dep_exp: + version_required, exp_op = None, None + else: + split_informed_dep = self.re_dep_operator.split(dep_exp) + version_required = split_informed_dep[2] + exp_op = split_informed_dep[1] if split_informed_dep[1] != '=' else '==' + + for pkgname, pkgdata in self.aur_client.gen_updates_data((aur_res['Name'] for aur_res in aur_results)): + if pkgname == dep_name or (dep_name in pkgdata['p']): + try: + if not version_required or match_required_version(pkgdata['v'], exp_op, + version_required): + yield pkgname, pkgdata + except: + self._log.warning(f"Could not compare AUR package '{pkgname}' version '{pkgdata['v']}' " + f"with the dependency expression '{dep_exp}'") + traceback.print_exc() def _fill_missing_dep(self, dep_name: str, dep_exp: str, aur_index: Iterable[str], missing_deps: Set[Tuple[str, str]], @@ -382,8 +384,9 @@ class DependenciesAnalyser: raise PackageNotFoundException(dep_exp) def _fill_aur_updates_data(self, pkgnames: Iterable[str], output_data: dict): - for pkgname, pkgdata in self.aur_client.gen_updates_data(pkgnames): - output_data[pkgname] = pkgdata + if pkgnames: + for pkgname, pkgdata in self.aur_client.gen_updates_data(pkgnames): + output_data[pkgname] = pkgdata def map_missing_deps(self, pkgs_data: Dict[str, dict], provided_map: Dict[str, Set[str]], remote_provided_map: Dict[str, Set[str]], remote_repo_map: Dict[str, str], @@ -516,8 +519,9 @@ class DependenciesAnalyser: if repo_providers_data: deps_data.update(repo_providers_data) - for pkgname, pkgdata in self.aur_client.gen_updates_data(aur_providers_no_data): - deps_data[pkgname] = pkgdata + if aur_providers_no_data: + for pkgname, pkgdata in self.aur_client.gen_updates_data(aur_providers_no_data): + deps_data[pkgname] = pkgdata if aur_data_filler: aur_data_filler.join() From 4e064aeee9b4e85ae6db40af04af045543a89451 Mon Sep 17 00:00:00 2001 From: Vinicius Moreira Date: Fri, 11 Feb 2022 15:23:50 -0300 Subject: [PATCH 15/17] [arch] refactoring: replacing some sets by tuples --- bauh/gems/arch/controller.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bauh/gems/arch/controller.py b/bauh/gems/arch/controller.py index 8af0c9c8..ca64d8c1 100644 --- a/bauh/gems/arch/controller.py +++ b/bauh/gems/arch/controller.py @@ -2414,7 +2414,7 @@ class ArchManager(SoftwareManager): if context.pkg and context.pkg.maintainer: pkg_maintainer = context.pkg.maintainer elif context.repository == 'aur': - aur_infos = self.aur_client.get_info({context.name}) + aur_infos = self.aur_client.get_info((context.name,)) pkg_maintainer = aur_infos[0].get('Maintainer') if aur_infos else None else: pkg_maintainer = context.repository @@ -3512,7 +3512,7 @@ class ArchManager(SoftwareManager): self.aur_client.clean_caches() - apidatas = self.aur_client.get_info({pkg.name}) + apidatas = self.aur_client.get_info((pkg.name,)) if not apidatas: watcher.show_message(title=self.i18n['error'], From 6eb4b5104af2144c8c2fba73ce59dcd84f4a68e0 Mon Sep 17 00:00:00 2001 From: Vinicius Moreira Date: Fri, 11 Feb 2022 15:30:13 -0300 Subject: [PATCH 16/17] [arch] fix: removing a duplicate call to checking for AUR updates --- CHANGELOG.md | 3 ++- bauh/gems/arch/dependencies.py | 4 ---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 194f4ff0..fbc30aba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,7 +22,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Arch - silent crash when handling and displaying transaction sub-status - AUR: not detecting installed packages anymore due to recent AUR API changes - - installation fails when several dependent packages conflict with the installed ones + - installation fails when several dependent packages conflict with the installed ones + - removing a duplicate call to checking for AUR updates - AppImage - search: displaying duplicate installed apps for some cases diff --git a/bauh/gems/arch/dependencies.py b/bauh/gems/arch/dependencies.py index 328d10c3..fe4d4164 100644 --- a/bauh/gems/arch/dependencies.py +++ b/bauh/gems/arch/dependencies.py @@ -519,10 +519,6 @@ class DependenciesAnalyser: if repo_providers_data: deps_data.update(repo_providers_data) - if aur_providers_no_data: - for pkgname, pkgdata in self.aur_client.gen_updates_data(aur_providers_no_data): - deps_data[pkgname] = pkgdata - if aur_data_filler: aur_data_filler.join() From fb55a1f85e5d86a53e0ed8a7641ffb8954c11fc6 Mon Sep 17 00:00:00 2001 From: Vinicius Moreira Date: Fri, 11 Feb 2022 15:48:31 -0300 Subject: [PATCH 17/17] [CHANGELOG.md] updating 0.9.27 release date --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fbc30aba..e86e19a6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ 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.9.27] +## [0.9.27] 2022-02-11 ### Improvements - Arch: