Skip to content

Commit

Permalink
0.9.18
Browse files Browse the repository at this point in the history
  • Loading branch information
vinifmor authored Jun 18, 2021
2 parents abaffcb + a9b36e8 commit 09af533
Show file tree
Hide file tree
Showing 18 changed files with 179 additions and 125 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.18] 2021-06-18
### Fixes
- Arch
- install/upgrade/downgrade: some dependencies not being matched during comparisons between numeric and alphanumeric versions


## [0.9.17] 2021-06-16
### Improvements
- general: replacing subprocess commands to detect installed CLIs by Python faster calls (**shutil.which**)
Expand Down
2 changes: 1 addition & 1 deletion bauh/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = '0.9.17'
__version__ = '0.9.18'
__app_name__ = 'bauh'

import os
Expand Down
4 changes: 2 additions & 2 deletions bauh/api/abstract/download.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
from abc import ABC, abstractmethod
from typing import Iterable, List
from typing import Iterable, List, Optional

from bauh.api.abstract.handler import ProcessWatcher


class FileDownloader(ABC):

@abstractmethod
def download(self, file_url: str, watcher: ProcessWatcher, output_path: str, cwd: str, root_password: str = None, substatus_prefix: str = None, display_file_size: bool = True, max_threads: int = None, known_size: int = None) -> bool:
def download(self, file_url: str, watcher: Optional[ProcessWatcher], output_path: str, cwd: str, root_password: str = None, substatus_prefix: str = None, display_file_size: bool = True, max_threads: int = None, known_size: int = None) -> bool:
"""
:param file_url:
:param watcher:
Expand Down
2 changes: 1 addition & 1 deletion bauh/gems/arch/aur.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ def read_index(self) -> Iterable[str]:
def clean_caches(self):
self.srcinfo_cache.clear()

def map_update_data(self, pkgname: str, latest_version: str, srcinfo: dict = None) -> dict:
def map_update_data(self, pkgname: str, latest_version: Optional[str], srcinfo: Optional[dict] = None) -> dict:
info = self.get_src_info(pkgname) if not srcinfo else srcinfo

provided = set()
Expand Down
6 changes: 3 additions & 3 deletions bauh/gems/arch/confirmation.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Set, List, Tuple, Dict
from typing import Set, List, Tuple, Dict, Optional

from bauh.api.abstract.handler import ProcessWatcher
from bauh.api.abstract.view import MultipleSelectComponent, InputOption, FormComponent, SingleSelectComponent, \
Expand Down Expand Up @@ -44,7 +44,7 @@ def request_optional_deps(pkgname: str, pkg_repos: dict, watcher: ProcessWatcher
return {o.value for o in view_opts.values}


def request_install_missing_deps(pkgname: str, deps: List[Tuple[str, str]], watcher: ProcessWatcher, i18n: I18n) -> bool:
def request_install_missing_deps(pkgname: Optional[str], deps: List[Tuple[str, str]], watcher: ProcessWatcher, i18n: I18n) -> bool:
msg = '<p>{}</p>'.format(i18n['arch.missing_deps.body'].format(name=bold(pkgname) if pkgname else '', deps=bold(str(len(deps)))))

opts = []
Expand Down Expand Up @@ -101,4 +101,4 @@ def request_providers(providers_map: Dict[str, Set[str]], repo_map: Dict[str, st
confirmation_label=i18n['proceed'].capitalize(),
deny_label=i18n['cancel'].capitalize()):

return {s.get_selected() for s in form.components}
return {s.get_selected() for s in form.components if isinstance(s, SingleSelectComponent)}
16 changes: 5 additions & 11 deletions bauh/gems/arch/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from math import floor
from pathlib import Path
from threading import Thread
from typing import List, Set, Type, Tuple, Dict, Iterable, Optional
from typing import List, Set, Type, Tuple, Dict, Iterable, Optional, Collection

import requests
from dateutil.parser import parse as parse_date
Expand Down Expand Up @@ -927,7 +927,7 @@ def _map_dependencies_breakage(self, output: str) -> List[ViewComponent]:
else:
return [TextComponent(output)]

def list_related(self, pkgs: Iterable[str], all_pkgs: Iterable[str], data: Dict[str, dict], related: Set[str], provided_map: Dict[str, Set[str]]) -> Set[str]:
def list_related(self, pkgs: Collection[str], all_pkgs: Collection[str], data: Dict[str, dict], related: Set[str], provided_map: Dict[str, Set[str]]) -> Set[str]:
related.update(pkgs)

deps = set()
Expand Down Expand Up @@ -1261,7 +1261,7 @@ def _uninstall_pkgs(self, pkgs: Iterable[str], root_password: str, handler: Proc

return all_uninstalled

def _request_uninstall_confirmation(self, to_uninstall: Iterable[str], required: Iterable[str], watcher: ProcessWatcher) -> bool:
def _request_uninstall_confirmation(self, to_uninstall: Collection[str], required: Collection[str], watcher: ProcessWatcher) -> bool:
reqs = [InputOption(label=p, value=p, icon_path=get_icon_path(), read_only=True) for p in required]
reqs_select = MultipleSelectComponent(options=reqs, default_options=set(reqs), label="", max_per_line=1 if len(reqs) < 4 else 3)

Expand Down Expand Up @@ -1291,7 +1291,7 @@ def _request_unncessary_uninstall_confirmation(self, unnecessary: Iterable[str],
window_cancel=False):
return {*reqs_select.get_selected_values()}

def _request_all_unncessary_uninstall_confirmation(self, pkgs: Iterable[str], context: TransactionContext):
def _request_all_unncessary_uninstall_confirmation(self, pkgs: Collection[str], context: TransactionContext):
reqs = [InputOption(label=p, value=p, icon_path=get_icon_path(), read_only=True) for p in pkgs]
reqs_select = MultipleSelectComponent(options=reqs, default_options=set(reqs), label="", max_per_line=1)

Expand Down Expand Up @@ -1738,12 +1738,6 @@ def _request_conflict_resolution(self, pkg: str, conflicting_pkg: str, context:
return res

def _install_deps(self, context: TransactionContext, deps: List[Tuple[str, str]]) -> Iterable[str]:
"""
:param pkgs_repos:
:param root_password:
:param handler:
:return: not installed dependency
"""
progress_increment = int(100 / len(deps))
progress = 0
self._update_progress(context, 1)
Expand Down Expand Up @@ -1820,7 +1814,7 @@ def _install_deps(self, context: TransactionContext, deps: List[Tuple[str, str]]

self._update_progress(context, 100)

def _map_repos(self, pkgnames: Iterable[str]) -> dict:
def _map_repos(self, pkgnames: Collection[str]) -> dict:
pkg_repos = pacman.get_repositories(pkgnames) # getting repositories set

if len(pkgnames) != len(pkg_repos): # checking if any dep not found in the distro repos are from AUR
Expand Down
42 changes: 15 additions & 27 deletions bauh/gems/arch/dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@
from threading import Thread
from typing import Set, List, Tuple, Dict, Iterable, Optional

from packaging.version import parse as parse_version

from bauh.api.abstract.handler import ProcessWatcher
from bauh.gems.arch import pacman, message, sorting, confirmation
from bauh.gems.arch.aur import AURClient
from bauh.gems.arch.exceptions import PackageNotFoundException
from bauh.gems.arch.util import clean_version
from bauh.gems.arch.version import match_required_version
from bauh.view.util.translation import I18n


Expand Down Expand Up @@ -140,8 +138,7 @@ def get_missing_subdeps(self, name: str, repository: str, srcinfo: dict = None)
return missing
return missing

def map_known_missing_deps(self, known_deps: Dict[str, str], watcher: ProcessWatcher, check_subdeps: bool = True) -> \
List[Tuple[str, str]]:
def map_known_missing_deps(self, known_deps: Dict[str, str], watcher: ProcessWatcher, check_subdeps: bool = True) -> Optional[List[Tuple[str, str]]]:
sorted_deps = [] # it will hold the proper order to install the missing dependencies

repo_deps, aur_deps = set(), set()
Expand Down Expand Up @@ -220,7 +217,7 @@ def _fill_missing_dep(self, dep_name: str, dep_exp: str, aur_index: Iterable[str
matched_providers = set()
split_informed_dep = self.re_dep_operator.split(dep_exp)
try:
version_required = parse_version(clean_version(split_informed_dep[2]))
version_required = split_informed_dep[2]
exp_op = split_informed_dep[1] if split_informed_dep[1] != '=' else '=='

for p in providers:
Expand All @@ -230,9 +227,9 @@ def _fill_missing_dep(self, dep_name: str, dep_exp: str, aur_index: Iterable[str
split_dep = self.re_dep_operator.split(provided_exp)

if len(split_dep) == 3 and split_dep[0] == dep_name:
version_provided = parse_version(clean_version(split_dep[2]))
version_provided = split_dep[2]

if eval('version_provided {} version_required'.format(exp_op)):
if match_required_version(version_provided, exp_op, version_required):
matched_providers.add(p)
break

Expand Down Expand Up @@ -270,17 +267,17 @@ def _fill_missing_dep(self, dep_name: str, dep_exp: str, aur_index: Iterable[str
self.__raise_dependency_not_found(dep_exp, watcher)
else:
try:
dep_version = parse_version(clean_version(dep_info[0]['Version']))
dep_version = dep_info[0]['Version']
except:
traceback.print_exc()
self.__raise_dependency_not_found(dep_exp, watcher)
return self.__raise_dependency_not_found(dep_exp, watcher)

split_informed_dep = self.re_dep_operator.split(dep_exp)
try:
version_required = parse_version(clean_version(split_informed_dep[2]))
exp_op = split_informed_dep[1] if split_informed_dep[1] != '=' else '=='
version_required = split_informed_dep[2]
exp_op = split_informed_dep[1].strip()

if eval('dep_version {} version_required'.format(exp_op)):
if match_required_version(dep_version, exp_op, version_required):
aur_deps.add(dep_name)
missing_deps.add((dep_name, 'aur'))
except:
Expand Down Expand Up @@ -334,20 +331,11 @@ def map_missing_deps(self, pkgs_data: Dict[str, dict], provided_map: Dict[str, S
version_found = [p for p in provided_map if p.startswith(version_pattern)]

if version_found:
version_found = clean_version(version_found[0].split('=')[1])
version_required = clean_version(dep_split[2])

try:
version_found = parse_version(version_found)
version_required = parse_version(version_required)

op = dep_split[1] if dep_split[1] != '=' else '=='
match = eval('version_found {} version_required'.format(op))
except:
match = False
traceback.print_exc()
version_found = version_found[0].split('=')[1]
version_required = dep_split[2]
op = dep_split[1].strip()

if not match:
if not match_required_version(version_found, op, version_required):
self._fill_missing_dep(dep_name=dep_name, dep_exp=dep, aur_index=aur_index,
missing_deps=missing_deps,
remote_provided_map=remote_provided_map,
Expand Down Expand Up @@ -422,7 +410,7 @@ def fill_providers_deps(self, missing_deps: List[Tuple[str, str]],
provided_map: Dict[str, Set[str]], remote_repo_map: Dict[str, str],
already_checked: Set[str], remote_provided_map: Dict[str, Set[str]],
deps_data: Dict[str, dict], aur_idx: Iterable[str], sort: bool,
watcher: ProcessWatcher, automatch_providers: bool) -> List[Tuple[str, str]]:
watcher: ProcessWatcher, automatch_providers: bool) -> Optional[List[Tuple[str, str]]]:
"""
:param missing_deps:
:param provided_map:
Expand Down
26 changes: 2 additions & 24 deletions bauh/gems/arch/mapper.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import logging
import os
import traceback
from typing import Optional

from colorama import Fore
from packaging.version import parse as parse_version

from bauh.api.abstract.model import PackageStatus
from bauh.api.http import HttpClient
from bauh.gems.arch.model import ArchPackage
from bauh.gems.arch.version import normalize_version
from bauh.view.util.translation import I18n

URL_PKG_DOWNLOAD = 'https://aur.archlinux.org/{}'
Expand Down Expand Up @@ -64,26 +61,7 @@ def fill_api_data(self, pkg: ArchPackage, api_data: dict, fill_version: bool = T
@staticmethod
def check_version_update(version: str, latest_version: str) -> bool:
if version and latest_version and version != latest_version:
try:
ver_epoch, latest_epoch = version.split(':'), latest_version.split(':')

if len(ver_epoch) > 1 and len(latest_epoch) > 1:
parsed_ver_epoch, parsed_latest_epoch = parse_version(ver_epoch[0]), parse_version(latest_epoch[0])

if parsed_ver_epoch == parsed_latest_epoch:
return parse_version(''.join(ver_epoch[1:])) < parse_version(''.join(latest_epoch[1:]))
else:
return parsed_ver_epoch < parsed_latest_epoch
elif len(ver_epoch) > 1 and len(latest_epoch) == 1:
return False
elif len(ver_epoch) == 1 and len(latest_epoch) > 1:
return True
else:
return parse_version(version) < parse_version(latest_version)
except:
print('{}Version: {}. Latest version: {}{}'.format(Fore.RED, version, latest_version, Fore.RESET))
traceback.print_exc()
return False
return normalize_version(latest_version) > normalize_version(version)

return False

Expand Down
12 changes: 6 additions & 6 deletions bauh/gems/arch/pacman.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
from bauh.commons.util import size_to_byte
from bauh.gems.arch.exceptions import PackageNotFoundException, PackageInHoldException

RE_DEPS = re.compile(r'[\w\-_]+:[\s\w_\-\.]+\s+\[\w+\]')
RE_OPTDEPS = re.compile(r'[\w\._\-]+\s*:')
RE_DEPS = re.compile(r'[\w\-_]+:[\s\w_\-.]+\s+\[\w+]')
RE_OPTDEPS = re.compile(r'[\w._\-]+\s*:')
RE_DEP_NOTFOUND = re.compile(r'error:.+\'(.+)\'')
RE_DEP_OPERATORS = re.compile(r'[<>=]')
RE_INSTALLED_FIELDS = re.compile(r'(Name|Description|Version|Install Date|Validated By)\s*:\s*(.+)')
RE_INSTALLED_SIZE = re.compile(r'Installed Size\s*:\s*([0-9,\.]+)\s(\w+)\n?', re.IGNORECASE)
RE_DOWNLOAD_SIZE = re.compile(r'Download Size\s*:\s*([0-9,\.]+)\s(\w+)\n?', re.IGNORECASE)
RE_INSTALLED_SIZE = re.compile(r'Installed Size\s*:\s*([0-9,.]+)\s(\w+)\n?', re.IGNORECASE)
RE_DOWNLOAD_SIZE = re.compile(r'Download Size\s*:\s*([0-9,.]+)\s(\w+)\n?', re.IGNORECASE)
RE_UPDATE_REQUIRED_FIELDS = re.compile(r'(\bProvides\b|\bInstalled Size\b|\bConflicts With\b)\s*:\s(.+)\n')
RE_REMOVE_TRANSITIVE_DEPS = re.compile(r'removing\s([\w\-_]+)\s.+required\sby\s([\w\-_]+)\n?')
RE_AVAILABLE_MIRRORS = re.compile(r'.+\s+OK\s+.+\s+(\d+:\d+)\s+.+(http.+)')
Expand Down Expand Up @@ -251,7 +251,7 @@ def check_missing(names: Set[str]) -> Set[str]:
return not_installed


def read_repository_from_info(name: str) -> str:
def read_repository_from_info(name: str) -> Optional[str]:
info = new_subprocess(['pacman', '-Si', name])

not_found = False
Expand Down Expand Up @@ -459,7 +459,7 @@ def get_databases() -> Set[str]:
with open('/etc/pacman.conf') as f:
conf_str = f.read()

return {db for db in re.findall(r'[\n|\s]+\[(\w+)\]', conf_str) if db != 'options'}
return {db for db in re.findall(r'[\n|\s]+\[(\w+)]', conf_str) if db != 'options'}


def can_refresh_mirrors() -> bool:
Expand Down
4 changes: 2 additions & 2 deletions bauh/gems/arch/sorting.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Dict, Set, Iterable, Tuple, List
from typing import Dict, Set, Tuple, List, Collection


def __add_dep_to_sort(pkgname: str, pkgs_data: Dict[str, dict], sorted_names: dict, not_sorted: Set[str],
Expand Down Expand Up @@ -35,7 +35,7 @@ def __add_dep_to_sort(pkgname: str, pkgs_data: Dict[str, dict], sorted_names: di
return idx


def sort(pkgs: Iterable[str], pkgs_data: Dict[str, dict], provided_map: Dict[str, Set[str]] = None) -> List[Tuple[str, str]]:
def sort(pkgs: Collection[str], pkgs_data: Dict[str, dict], provided_map: Dict[str, Set[str]] = None) -> List[Tuple[str, str]]:
sorted_list, sorted_names, not_sorted = [], set(), set()
provided = provided_map if provided_map else {}

Expand Down
12 changes: 3 additions & 9 deletions bauh/gems/arch/updates.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
from threading import Thread
from typing import Dict, Set, List, Tuple, Iterable, Optional

from packaging.version import parse as parse_version

from bauh.api.abstract.controller import UpgradeRequirements, UpgradeRequirement
from bauh.api.abstract.handler import ProcessWatcher
from bauh.gems.arch import pacman, sorting
Expand All @@ -14,6 +12,7 @@
from bauh.gems.arch.exceptions import PackageNotFoundException
from bauh.gems.arch.model import ArchPackage
from bauh.gems.arch.pacman import RE_DEP_OPERATORS
from bauh.gems.arch.version import match_required_version
from bauh.view.util.translation import I18n


Expand Down Expand Up @@ -367,7 +366,7 @@ def _map_requirement(self, pkg: ArchPackage, context: UpdateRequirementsContext,

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) -> Optional[UpgradeRequirements]:
res = UpgradeRequirements([], [], [], [])

remote_provided_map = pacman.map_provided(remote=True)
Expand Down Expand Up @@ -726,16 +725,11 @@ def _add_dependency_breakage(self, pkgname: str, pkgdeps: Optional[Set[str]], pr
if versions:
op = ''.join(RE_DEP_OPERATORS.findall(dep))

if op == '=':
op = '=='

version_match = False

for v in versions:
try:
provided_version, required_version = parse_version(v), parse_version(dep_split[1])

if eval('provided_version {} required_version'.format(op)):
if match_required_version(current_version=v, operator=op, required_version=dep_split[1]):
version_match = True
break
except:
Expand Down
12 changes: 0 additions & 12 deletions bauh/gems/arch/util.py

This file was deleted.

Loading

0 comments on commit 09af533

Please sign in to comment.