[arch] improvement -> upgrade summary: displaying the reason a given package must be installed

This commit is contained in:
Vinicius Moreira
2020-08-04 15:35:15 -03:00
parent d288c30484
commit 4400e60622
4 changed files with 16 additions and 3 deletions

View File

@@ -5,6 +5,13 @@ 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/). The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
## [0.9.7] 2020 ## [0.9.7] 2020
### Improvements
- Arch
- upgrade summary: displaying the reason a given package must be installed
<p align="center">
<img src="https://raw.githubusercontent.com/vinifmor/bauh/staging/pictures/releases/0.9.7/arch_install_reason.png">
</p>
### Fixes ### Fixes
- Arch - Arch
- not able to upgrade a package that explicitly defines a conflict with itself (e.g: grub) - not able to upgrade a package that explicitly defines a conflict with itself (e.g: grub)

View File

@@ -334,7 +334,7 @@ class UpdatesSummarizer:
context.aur_index.update(names) context.aur_index.update(names)
self.logger.info("AUR index loaded on the context") self.logger.info("AUR index loaded on the context")
def _map_requirement(self, pkg: ArchPackage, context: UpdateRequirementsContext, installed_sizes: Dict[str, int] = None) -> UpgradeRequirement: def _map_requirement(self, pkg: ArchPackage, context: UpdateRequirementsContext, installed_sizes: Dict[str, int] = None, to_install: bool = False, to_upgrade: Set[str] = None) -> UpgradeRequirement:
requirement = UpgradeRequirement(pkg) requirement = UpgradeRequirement(pkg)
if pkg.repository != 'aur': if pkg.repository != 'aur':
@@ -347,6 +347,11 @@ class UpdatesSummarizer:
if current_size is not None and data['s']: if current_size is not None and data['s']:
requirement.extra_size = data['s'] - current_size requirement.extra_size = data['s'] - current_size
if to_install and context.pkgs_data and context.to_update:
names = context.pkgs_data[pkg.name].get('p', {pkg.name})
required_by = ','.join([p for p in to_upgrade if p != pkg.name and context.pkgs_data[p]['d'] and any([n for n in names if n in context.pkgs_data[p]['d']])])
requirement.reason = '{}: {}'.format(self.i18n['arch.info.required by'].capitalize(), required_by if required_by else '?')
return requirement return requirement
def summarize(self, pkgs: List[ArchPackage], root_password: str, arch_config: dict) -> UpgradeRequirements: def summarize(self, pkgs: List[ArchPackage], root_password: str, arch_config: dict) -> UpgradeRequirements:
@@ -422,6 +427,7 @@ class UpdatesSummarizer:
res.cannot_upgrade = [d for d in context.cannot_upgrade.values()] res.cannot_upgrade = [d for d in context.cannot_upgrade.values()]
if context.to_install: if context.to_install:
res.to_install = [self._map_requirement(p, context) for p in context.to_install.values()] to_upgrade = {r.pkg.name for r in res.to_upgrade} if res.to_upgrade else None
res.to_install = [self._map_requirement(p, context, to_install=True, to_upgrade=to_upgrade) for p in context.to_install.values()]
return res return res

View File

@@ -236,7 +236,7 @@ class UpgradeSelected(AsyncAction):
return FormComponent(label=self.i18n['action.update.cannot_update_label'], components=comps) return FormComponent(label=self.i18n['action.update.cannot_update_label'], components=comps)
def _gen_to_install_form(self, reqs: List[UpgradeRequirement]) -> Tuple[FormComponent, Tuple[int, int]]: def _gen_to_install_form(self, reqs: List[UpgradeRequirement]) -> Tuple[FormComponent, Tuple[int, int]]:
opts = [self._req_as_option(r) for r in reqs] opts = [self._req_as_option(r, custom_tooltip=r.reason) for r in reqs]
comps = [MultipleSelectComponent(label='', options=opts, default_options=set(opts))] comps = [MultipleSelectComponent(label='', options=opts, default_options=set(opts))]
required_size, extra_size = self._sum_pkgs_size(reqs) required_size, extra_size = self._sum_pkgs_size(reqs)

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB