[gems.arch] fix: not properly mapping all provided packages by the system when checking for upgrade requirements

This commit is contained in:
Vinicius Moreira
2022-11-11 17:41:40 -03:00
parent 70e66c6b7c
commit 9433c2910f
3 changed files with 20 additions and 3 deletions

View File

@@ -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/).
## NEXT
### Fixes
- Arch
- not properly mapping all provided packages by the system when checking for upgrade requirements
## [0.10.4] 2022-11-05
### Improvements

View File

@@ -539,7 +539,7 @@ def fill_provided_map(key: str, val: str, output: dict):
def map_provided(remote: bool = False, pkgs: Iterable[str] = None) -> Optional[Dict[str, Set[str]]]:
output = run_cmd('pacman -{}i {}'.format('S' if remote else 'Q', ' '.join(pkgs) if pkgs else ''))
output = run_cmd(f"pacman -{'S' if remote else 'Q'}i {' '.join(pkgs) if pkgs else ''}")
if output:
provided_map = {}
@@ -559,7 +559,7 @@ def map_provided(remote: bool = False, pkgs: Iterable[str] = None) -> Optional[D
latest_version = val.split('=')[0]
elif field == 'Provides':
fill_provided_map(latest_name, latest_name, provided_map)
fill_provided_map('{}={}'.format(latest_name, latest_version), latest_name, provided_map)
fill_provided_map(f'{latest_name}={latest_version}', latest_name, provided_map)
if val != 'None':
for w in val.split(' '):

View File

@@ -43,6 +43,17 @@ class UpdateRequirementsContext:
self.remote_repo_map = remote_repo_map
self.aur_supported = aur_supported
def update_provided_map(self, update: Dict[str, Set[str]]):
if self.provided_map is None:
self.provided_map = {**update}
else:
for key, val in update.items():
if key not in self.provided_map:
self.provided_map[key] = val
elif val:
current_val = self.provided_map[key]
current_val.update(val)
class UpdatesSummarizer:
@@ -318,7 +329,7 @@ class UpdatesSummarizer:
installed_to_query = {*context.installed}.difference(installed_to_ignore)
if installed_to_query:
context.provided_map.update(pacman.map_provided(remote=False, pkgs=installed_to_query))
context.update_provided_map(pacman.map_provided(remote=False, pkgs=installed_to_query))
tf = time.time()
self.logger.info("Filling provided names took {0:.2f} seconds".format(tf - ti))