mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-07 00:04:15 +02:00
[gems.arch] fix: not considering some conflict expressions when retrieving upgrade requirements
This commit is contained in:
@@ -15,6 +15,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|||||||
- some desktop entries not being displayed on the desktop environment menu (requires the AppImage to be reinstalled) [#287](https://github.com/vinifmor/bauh/issues/287)
|
- some desktop entries not being displayed on the desktop environment menu (requires the AppImage to be reinstalled) [#287](https://github.com/vinifmor/bauh/issues/287)
|
||||||
- Arch
|
- Arch
|
||||||
- not detecting some package replacements when upgrading due to conflict information having logic operators (e.g: `at-spi2-core: 2.44.1 -> 2.46.0` should replace the installed `at-spi2-atk: 2.38`)
|
- not detecting some package replacements when upgrading due to conflict information having logic operators (e.g: `at-spi2-core: 2.44.1 -> 2.46.0` should replace the installed `at-spi2-atk: 2.38`)
|
||||||
|
- not considering some conflict expressions when retrieving upgrade requirements (it could lead to a system breakage depending on the conflict)
|
||||||
- Debian
|
- Debian
|
||||||
- not properly handling packages with names ending with `:i386` [#298](https://github.com/vinifmor/bauh/issues/298)
|
- not properly handling packages with names ending with `:i386` [#298](https://github.com/vinifmor/bauh/issues/298)
|
||||||
- Packaging
|
- Packaging
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import shutil
|
|||||||
import traceback
|
import traceback
|
||||||
from io import StringIO
|
from io import StringIO
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
from typing import List, Set, Tuple, Dict, Iterable, Optional, Any, Pattern
|
from typing import List, Set, Tuple, Dict, Iterable, Optional, Any, Pattern, Collection
|
||||||
|
|
||||||
from colorama import Fore
|
from colorama import Fore
|
||||||
|
|
||||||
@@ -1081,3 +1081,18 @@ def map_available_packages() -> Optional[Dict[str, Any]]:
|
|||||||
'r': package_data[0].strip(),
|
'r': package_data[0].strip(),
|
||||||
'i': len(package_data) == 4 and 'installed' in package_data[3]}
|
'i': len(package_data) == 4 and 'installed' in package_data[3]}
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
|
||||||
|
def map_installed(pkgs: Optional[Collection[str]] = None) -> Optional[Dict[str, str]]:
|
||||||
|
output = run_cmd(f"pacman -Q {' '.join({*pkgs} if pkgs else '')}".strip(), print_error=False)
|
||||||
|
|
||||||
|
if output:
|
||||||
|
res = dict()
|
||||||
|
for raw_line in output.split("\n"):
|
||||||
|
line = raw_line.strip()
|
||||||
|
|
||||||
|
if line:
|
||||||
|
pkg_version = line.split(" ")
|
||||||
|
if len(pkg_version) == 2:
|
||||||
|
res[pkg_version[0]] = pkg_version[1]
|
||||||
|
return res
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ class UpdateRequirementsContext:
|
|||||||
aur_to_update: Dict[str, ArchPackage], repo_to_install: Dict[str, ArchPackage],
|
aur_to_update: Dict[str, ArchPackage], repo_to_install: Dict[str, ArchPackage],
|
||||||
aur_to_install: Dict[str, ArchPackage], to_install: Dict[str, ArchPackage],
|
aur_to_install: Dict[str, ArchPackage], to_install: Dict[str, ArchPackage],
|
||||||
pkgs_data: Dict[str, dict], cannot_upgrade: Dict[str, UpgradeRequirement],
|
pkgs_data: Dict[str, dict], cannot_upgrade: Dict[str, UpgradeRequirement],
|
||||||
to_remove: Dict[str, UpgradeRequirement], installed_names: Set[str], provided_map: Dict[str, Set[str]],
|
to_remove: Dict[str, UpgradeRequirement], installed_names: Dict[str, str], provided_map: Dict[str, Set[str]],
|
||||||
aur_index: Set[str], arch_config: dict, remote_provided_map: Dict[str, Set[str]], remote_repo_map: Dict[str, str],
|
aur_index: Set[str], arch_config: dict, remote_provided_map: Dict[str, Set[str]], remote_repo_map: Dict[str, str],
|
||||||
root_password: Optional[str], aur_supported: bool):
|
root_password: Optional[str], aur_supported: bool):
|
||||||
self.to_update = to_update
|
self.to_update = to_update
|
||||||
@@ -33,7 +33,7 @@ class UpdateRequirementsContext:
|
|||||||
self.pkgs_data = pkgs_data
|
self.pkgs_data = pkgs_data
|
||||||
self.cannot_upgrade = cannot_upgrade
|
self.cannot_upgrade = cannot_upgrade
|
||||||
self.root_password = root_password
|
self.root_password = root_password
|
||||||
self.installed_names = installed_names
|
self.installed = installed_names
|
||||||
self.provided_map = provided_map
|
self.provided_map = provided_map
|
||||||
self.to_remove = to_remove
|
self.to_remove = to_remove
|
||||||
self.to_install = to_install
|
self.to_install = to_install
|
||||||
@@ -150,13 +150,20 @@ class UpdatesSummarizer:
|
|||||||
if data['c']:
|
if data['c']:
|
||||||
for c in data['c']:
|
for c in data['c']:
|
||||||
if c:
|
if c:
|
||||||
pkg_name = DependenciesAnalyser.re_dep_operator().split(c)[0]
|
name_op_exp = DependenciesAnalyser.re_dep_operator().split(c)
|
||||||
if pkg_name != p and pkg_name in context.installed_names:
|
conflict_name = name_op_exp[0]
|
||||||
# source = provided_map[c]
|
|
||||||
root_conflict[pkg_name] = p
|
|
||||||
|
|
||||||
if (p, pkg_name) in root_conflict.items():
|
if conflict_name != p:
|
||||||
mutual_conflicts[pkg_name] = p
|
conflict_version = context.installed.get(conflict_name)
|
||||||
|
|
||||||
|
if conflict_version:
|
||||||
|
if len(name_op_exp) == 1 or match_required_version(conflict_version,
|
||||||
|
name_op_exp[1],
|
||||||
|
name_op_exp[2]):
|
||||||
|
root_conflict[conflict_name] = p
|
||||||
|
|
||||||
|
if (p, conflict_name) in root_conflict.items():
|
||||||
|
mutual_conflicts[conflict_name] = p
|
||||||
|
|
||||||
if mutual_conflicts:
|
if mutual_conflicts:
|
||||||
for pkg1, pkg2 in mutual_conflicts.items():
|
for pkg1, pkg2 in mutual_conflicts.items():
|
||||||
@@ -280,8 +287,8 @@ class UpdatesSummarizer:
|
|||||||
ti = time.time()
|
ti = time.time()
|
||||||
self.logger.info("Filling provided names")
|
self.logger.info("Filling provided names")
|
||||||
|
|
||||||
if not context.installed_names:
|
if not context.installed:
|
||||||
context.installed_names = pacman.list_installed_names()
|
context.installed = pacman.map_installed()
|
||||||
|
|
||||||
installed_to_ignore = set()
|
installed_to_ignore = set()
|
||||||
|
|
||||||
@@ -307,8 +314,8 @@ class UpdatesSummarizer:
|
|||||||
if len(split_provided) > 1 and split_provided[0] != p:
|
if len(split_provided) > 1 and split_provided[0] != p:
|
||||||
pacman.fill_provided_map(split_provided[0], pkgname, context.provided_map)
|
pacman.fill_provided_map(split_provided[0], pkgname, context.provided_map)
|
||||||
|
|
||||||
if installed_to_ignore: # filling the provided names of the installed
|
if context.installed and installed_to_ignore: # filling the provided names of the installed
|
||||||
installed_to_query = context.installed_names.difference(installed_to_ignore)
|
installed_to_query = {*context.installed}.difference(installed_to_ignore)
|
||||||
|
|
||||||
if installed_to_query:
|
if installed_to_query:
|
||||||
context.provided_map.update(pacman.map_provided(remote=False, pkgs=installed_to_query))
|
context.provided_map.update(pacman.map_provided(remote=False, pkgs=installed_to_query))
|
||||||
@@ -376,7 +383,7 @@ class UpdatesSummarizer:
|
|||||||
remote_repo_map = pacman.map_repositories()
|
remote_repo_map = pacman.map_repositories()
|
||||||
context = UpdateRequirementsContext(to_update={}, repo_to_update={}, aur_to_update={}, repo_to_install={},
|
context = UpdateRequirementsContext(to_update={}, repo_to_update={}, aur_to_update={}, repo_to_install={},
|
||||||
aur_to_install={}, to_install={}, pkgs_data={}, cannot_upgrade={},
|
aur_to_install={}, to_install={}, pkgs_data={}, cannot_upgrade={},
|
||||||
to_remove={}, installed_names=set(), provided_map={}, aur_index=set(),
|
to_remove={}, installed_names=dict(), provided_map={}, aur_index=set(),
|
||||||
arch_config=arch_config, root_password=root_password,
|
arch_config=arch_config, root_password=root_password,
|
||||||
remote_provided_map=remote_provided_map, remote_repo_map=remote_repo_map,
|
remote_provided_map=remote_provided_map, remote_repo_map=remote_repo_map,
|
||||||
aur_supported=self.aur_supported)
|
aur_supported=self.aur_supported)
|
||||||
@@ -606,7 +613,7 @@ class UpdatesSummarizer:
|
|||||||
for r in reqs:
|
for r in reqs:
|
||||||
if r in transaction_pkgs:
|
if r in transaction_pkgs:
|
||||||
reqs_in_transaction.add(r)
|
reqs_in_transaction.add(r)
|
||||||
elif r in context.installed_names:
|
elif r in context.installed:
|
||||||
reqs_not_in_transaction.add(r)
|
reqs_not_in_transaction.add(r)
|
||||||
|
|
||||||
if not reqs_not_in_transaction and not reqs_in_transaction:
|
if not reqs_not_in_transaction and not reqs_in_transaction:
|
||||||
|
|||||||
Reference in New Issue
Block a user