diff --git a/CHANGELOG.md b/CHANGELOG.md index 18a32f04..e08d4826 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,10 +7,14 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## [0.9.11] ### New system requirements - **python-dateutil**: better Python library for date handling (install the equivalent package for your Linux distribution before upgrading bauh) +- **git**: for AUR support. ### Improvements - Arch - - AUR: upgrade checking now considers modification dates as well (needed because not all AUR packages follow versioning standards) + - AUR: + - upgrade checking now considers modification dates as well (needed because not all AUR packages follow versioning standards) + - downgrade: using the cached package commit (if available) to determine the correct version to downgrade to (otherwise only the version will be used -> old behavior) + - history: using the cached package commit (if available) to properly determine the current version (otherwise only the version will be used -> old behavior) - the task responsible for generating a local AUR index is displayed on the initialization dialog - info window: - date fields format changed to numbers (e.g: Thu Dec 17 17:19:55 2020 -> 2020-12-17 17:19:55) @@ -20,10 +24,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - some installed applications cannot be launched by their desktop entries (regression from **0.9.10**) [#155](https://github.com/vinifmor/bauh/issues/155). If any of your installed AppImages are affected by this issue, just reinstall them. - Arch - some operations are keeping the wrong substatus during specific scenarios + - not able to install a package that replaces another (regression introduced in **0.9.9**) + - displaying installed packages that have been removed from AUR when AUR supported is disabled - Flatpak - crashing for Flatpak 1.6.5 when there are updates [#145](https://github.com/vinifmor/bauh/issues/145) - history: not highlighting the correct version (regression introduced **0.9.9**) + ## [0.9.10] 2020-12-11 ### Features - Web diff --git a/bauh/commons/system.py b/bauh/commons/system.py index c053a94c..f96342c1 100644 --- a/bauh/commons/system.py +++ b/bauh/commons/system.py @@ -322,11 +322,11 @@ def check_enabled_services(*names: str) -> Dict[str, bool]: return {s: status[i].strip().lower() == 'enabled' for i, s in enumerate(names) if s} -def execute(cmd: str, shell: bool = False, cwd: Optional[str] = None) -> Tuple[int, str]: +def execute(cmd: str, shell: bool = False, cwd: Optional[str] = None, output: bool = True) -> Tuple[int, Optional[str]]: p = subprocess.run(args=cmd.split(' ') if not shell else [cmd], - stdout=subprocess.PIPE, - stderr=subprocess.STDOUT, + stdout=subprocess.PIPE if output else subprocess.DEVNULL, + stderr=subprocess.STDOUT if output else subprocess.DEVNULL, shell=shell, cwd=cwd) - return p.returncode, p.stdout.decode() + return p.returncode, p.stdout.decode() if p.stdout else None diff --git a/bauh/gems/arch/aur.py b/bauh/gems/arch/aur.py index fcd1ef95..0d53eb15 100644 --- a/bauh/gems/arch/aur.py +++ b/bauh/gems/arch/aur.py @@ -7,7 +7,7 @@ from typing import Set, List, Iterable, Dict, Optional import requests from bauh.api.http import HttpClient -from bauh.gems.arch import AUR_INDEX_FILE +from bauh.gems.arch import AUR_INDEX_FILE, git from bauh.gems.arch.exceptions import PackageNotFoundException URL_INFO = 'https://aur.archlinux.org/rpc/?v=5&type=info&' @@ -256,3 +256,7 @@ class AURClient: def fill_update_data(self, output: Dict[str, dict], pkgname: str, latest_version: str, srcinfo: dict = None): data = self.map_update_data(pkgname=pkgname, latest_version=latest_version, srcinfo=srcinfo) output[pkgname] = data + + +def is_supported(arch_config: dict) -> bool: + return arch_config['aur'] and git.is_installed() diff --git a/bauh/gems/arch/controller.py b/bauh/gems/arch/controller.py index 6129151a..1581e7b9 100644 --- a/bauh/gems/arch/controller.py +++ b/bauh/gems/arch/controller.py @@ -51,7 +51,6 @@ from bauh.gems.arch.worker import AURIndexUpdater, ArchDiskCacheUpdater, ArchCom RefreshMirrors URL_GIT = 'https://aur.archlinux.org/{}.git' -URL_PKG_DOWNLOAD = 'https://aur.archlinux.org/cgit/aur.git/snapshot/{}.tar.gz' URL_SRC_INFO = 'https://aur.archlinux.org/cgit/aur.git/plain/.SRCINFO?h=' RE_SPLIT_VERSION = re.compile(r'([=><]+)') @@ -66,7 +65,7 @@ RE_DEPENDENCY_BREAKAGE = re.compile(r'\n?::\s+installing\s+(.+\s\(.+\))\sbreaks\ class TransactionContext: - def __init__(self, name: str = None, base: str = None, maintainer: str = None, watcher: ProcessWatcher = None, + def __init__(self, aur_supported: bool, name: str = None, base: str = None, maintainer: str = None, watcher: ProcessWatcher = None, handler: ProcessHandler = None, dependency: bool = None, skip_opt_deps: bool = False, root_password: str = None, build_dir: str = None, project_dir: str = None, change_progress: bool = False, arch_config: dict = None, install_files: Set[str] = None, repository: str = None, pkg: ArchPackage = None, @@ -75,7 +74,9 @@ class TransactionContext: missing_deps: List[Tuple[str, str]] = None, installed: Set[str] = None, removed: Dict[str, SoftwarePackage] = None, disk_loader: DiskCacheLoader = None, disk_cache_updater: Thread = None, new_pkg: bool = False, custom_pkgbuild_path: str = None, - pkgs_to_build: Set[str] = None, last_modified: Optional[int] = None): + pkgs_to_build: Set[str] = None, last_modified: Optional[int] = None, + commit: Optional[str] = None): + self.aur_supported = aur_supported self.name = name self.base = base self.maintainer = maintainer @@ -106,13 +107,15 @@ class TransactionContext: self.pkgs_to_build = pkgs_to_build self.previous_change_progress = change_progress self.last_modified = last_modified + self.commit = commit @classmethod - def gen_context_from(cls, pkg: ArchPackage, arch_config: dict, root_password: str, handler: ProcessHandler) -> "TransactionContext": + def gen_context_from(cls, pkg: ArchPackage, arch_config: dict, root_password: str, handler: ProcessHandler, aur_supported: Optional[bool] = None) -> "TransactionContext": return cls(name=pkg.name, base=pkg.get_base_name(), maintainer=pkg.maintainer, repository=pkg.repository, arch_config=arch_config, watcher=handler.watcher, handler=handler, skip_opt_deps=True, change_progress=True, root_password=root_password, dependency=False, - installed=set(), removed={}, new_pkg=not pkg.installed, last_modified=pkg.last_modified) + installed=set(), removed={}, new_pkg=not pkg.installed, last_modified=pkg.last_modified, + aur_supported=aur_supported if aur_supported is not None else (pkg.repository == 'aur' or aur.is_supported(arch_config))) def get_base_name(self): return self.base if self.base else self.name @@ -122,7 +125,7 @@ class TransactionContext: def clone_base(self): return TransactionContext(watcher=self.watcher, handler=self.handler, root_password=self.root_password, - arch_config=self.config, installed=set(), removed={}) + arch_config=self.config, installed=set(), removed={}, aur_supported=self.aur_supported) def gen_dep_context(self, name: str, repository: str): dep_context = self.clone_base() @@ -148,7 +151,7 @@ class TransactionContext: def get_aur_idx(self, aur_client: AURClient) -> Set[str]: if self.aur_idx is None: - if self.config['aur']: + if self.aur_supported: self.aur_idx = aur_client.read_index() else: self.aur_idx = set() @@ -333,12 +336,11 @@ class ArchManager(SoftwareManager): database.register_sync(self.logger) return True - def _upgrade_search_result(self, apidata: dict, installed_pkgs: Dict[str, ArchPackage], downgrade_enabled: bool, res: SearchResult, disk_loader: DiskCacheLoader): + def _upgrade_search_result(self, apidata: dict, installed_pkgs: Dict[str, ArchPackage], res: SearchResult): pkg = installed_pkgs.get(apidata['Name']) if not pkg: pkg = self.aur_mapper.map_api_data(apidata, None, self.categories) - pkg.downgrade_enabled = downgrade_enabled if pkg.installed: res.installed.append(pkg) @@ -363,7 +365,6 @@ class ArchManager(SoftwareManager): repo_pkgs = [] for name, data in repo_search.items(): pkg = ArchPackage(name=name, i18n=self.i18n, **data) - pkg.downgrade_enabled = True repo_pkgs.append(pkg) if repo_pkgs: @@ -386,9 +387,8 @@ class ArchManager(SoftwareManager): read_installed.join() aur_installed = {p.name: p for p in installed if p.repository == 'aur'} - downgrade_enabled = git.is_installed() for pkgdata in api_res['results']: - self._upgrade_search_result(pkgdata, aur_installed, downgrade_enabled, res, disk_loader) + self._upgrade_search_result(pkgdata, aur_installed, res) else: # if there are no results from the API (it could be because there were too many), tries the names index: if self.index_aur: @@ -410,18 +410,18 @@ class ArchManager(SoftwareManager): if pkgsinfo: read_installed.join() aur_installed = {p.name: p for p in installed if p.repository == 'aur'} - downgrade_enabled = git.is_installed() for pkgdata in pkgsinfo: - self._upgrade_search_result(pkgdata, aur_installed, downgrade_enabled, res, disk_loader) + self._upgrade_search_result(pkgdata, aur_installed, res) def search(self, words: str, disk_loader: DiskCacheLoader, limit: int = -1, is_url: bool = False) -> SearchResult: if is_url: return SearchResult([], [], 0) arch_config = read_config() + aur_supported = aur.is_supported(arch_config) - if not any([arch_config['repositories'], arch_config['aur']]): + if not any([arch_config['repositories'], aur_supported]): return SearchResult([], [], 0) installed = [] @@ -433,14 +433,14 @@ class ArchManager(SoftwareManager): res = SearchResult([], [], 0) - if not any((arch_config['aur'], arch_config['repositories'])): + if not any([aur_supported, arch_config['repositories']]): return res mapped_words = self.get_semantic_search_map().get(words) final_words = mapped_words or words aur_search = None - if arch_config['aur']: + if aur_supported: aur_search = Thread(target=self._search_in_aur_and_fill, args=(final_words, disk_loader, read_installed, installed, res), daemon=True) aur_search.start() @@ -455,7 +455,6 @@ class ArchManager(SoftwareManager): def _fill_aur_pkgs(self, aur_pkgs: dict, output: List[ArchPackage], disk_loader: DiskCacheLoader, internet_available: bool, arch_config: dict): - downgrade_enabled = git.is_installed() if internet_available: try: @@ -465,7 +464,6 @@ class ArchManager(SoftwareManager): editable_pkgbuilds = self._read_editable_pkgbuilds() if arch_config['edit_aur_pkgbuild'] is not False else None for pkgdata in pkgsinfo: pkg = self.aur_mapper.map_api_data(pkgdata, aur_pkgs, self.categories) - pkg.downgrade_enabled = downgrade_enabled pkg.pkgbuild_editable = pkg.name in editable_pkgbuilds if editable_pkgbuilds is not None else None if pkg.installed: @@ -491,7 +489,6 @@ class ArchManager(SoftwareManager): installed=True, repository='aur', i18n=self.i18n) pkg.categories = self.categories.get(pkg.name) - pkg.downgrade_enabled = downgrade_enabled pkg.pkgbuild_editable = pkg.name in editable_pkgbuilds if editable_pkgbuilds is not None else None if disk_loader: @@ -517,7 +514,7 @@ class ArchManager(SoftwareManager): def _fill_repo_updates(self, updates: dict): updates.update(pacman.list_repository_updates()) - def _fill_repo_pkgs(self, repo_pkgs: dict, pkgs: list, disk_loader: DiskCacheLoader): + def _fill_repo_pkgs(self, repo_pkgs: dict, pkgs: list, aur_supported: bool, disk_loader: DiskCacheLoader): updates = {} thread_updates = Thread(target=self._fill_repo_updates, args=(updates,), daemon=True) @@ -543,7 +540,6 @@ class ArchManager(SoftwareManager): installed=True, repository=pkgrepo, categories=self.categories.get(name)) - pkg.downgrade_enabled = False if updates: update_version = updates.get(pkg.name) @@ -553,9 +549,10 @@ class ArchManager(SoftwareManager): pkg.update = True if disk_loader: - disk_loader.fill(pkg) + disk_loader.fill(pkg, sync=True) - pkgs.append(pkg) + if aur_supported or pkg.repository != 'aur': # this case happens when a package was removed from AUR + pkgs.append(pkg) def _wait_for_disk_cache(self): if self.disk_cache_updater and self.disk_cache_updater.is_alive(): @@ -563,10 +560,12 @@ class ArchManager(SoftwareManager): self.disk_cache_updater.join() self.logger.info("Disk cache ready") - def read_installed(self, disk_loader: DiskCacheLoader, limit: int = -1, only_apps: bool = False, pkg_types: Set[Type[SoftwarePackage]] = None, internet_available: bool = None, names: Iterable[str] = None, wait_disk_cache: bool = True) -> SearchResult: + def read_installed(self, disk_loader: Optional[DiskCacheLoader], limit: int = -1, only_apps: bool = False, pkg_types: Set[Type[SoftwarePackage]] = None, internet_available: bool = None, names: Iterable[str] = None, wait_disk_cache: bool = True) -> SearchResult: self.aur_client.clean_caches() arch_config = read_config() + aur_supported = aur.is_supported(arch_config) + installed = pacman.map_installed(names=names) aur_pkgs, repo_pkgs = None, None @@ -585,11 +584,10 @@ class ArchManager(SoftwareManager): if repo_pkgs is not None: repo_pkgs[pkg] = installed['not_signed'][pkg] - if arch_config['aur']: + if aur_supported and installed['not_signed']: del installed['not_signed'][pkg] - if arch_config['aur']: - aur_pkgs = installed['not_signed'] + aur_pkgs = installed['not_signed'] if aur_supported else None pkgs = [] if repo_pkgs or aur_pkgs: @@ -604,7 +602,7 @@ class ArchManager(SoftwareManager): map_threads.append(t) if repo_pkgs: - t = Thread(target=self._fill_repo_pkgs, args=(repo_pkgs, pkgs, disk_loader), daemon=True) + t = Thread(target=self._fill_repo_pkgs, args=(repo_pkgs, pkgs, aur_supported, disk_loader), daemon=True) t.start() map_threads.append(t) @@ -622,6 +620,11 @@ class ArchManager(SoftwareManager): return SearchResult(pkgs, None, len(pkgs)) def _downgrade_aur_pkg(self, context: TransactionContext): + if context.commit: + self.logger.info("Package '{}' current commit {}".format(context.name, context.commit)) + else: + self.logger.warning("Package '{}' has no commit associated with it. Downgrading will only compare versions.".format(context.name)) + context.build_dir = '{}/build_{}'.format(get_build_dir(context.config), int(time.time())) try: @@ -632,10 +635,10 @@ class ArchManager(SoftwareManager): context.handler.watcher.change_progress(10) base_name = context.get_base_name() context.watcher.change_substatus(self.i18n['arch.clone'].format(bold(context.name))) - clone = context.handler.handle(SystemProcess(subproc=new_subprocess(['git', 'clone', URL_GIT.format(base_name)], - cwd=context.build_dir), check_error_output=False)) + cloned, _ = context.handler.handle_simple(git.clone_as_process(url=URL_GIT.format(base_name), cwd=context.build_dir)) context.watcher.change_progress(30) - if clone: + + if cloned: context.watcher.change_substatus(self.i18n['arch.downgrade.reading_commits']) clone_path = '{}/{}'.format(context.build_dir, base_name) context.project_dir = clone_path @@ -644,16 +647,38 @@ class ArchManager(SoftwareManager): logs = git.log_shas_and_timestamps(clone_path) context.watcher.change_progress(40) - if not logs: + if not logs or len(logs) == 1: context.watcher.show_message(title=self.i18n['arch.downgrade.error'], - body=self.i18n['arch.downgrade.impossible'].format( - context.name), + body=self.i18n['arch.downgrade.impossible'].format(context.name), type_=MessageType.ERROR) return False + if context.commit: + target_commit, target_commit_timestamp = None, None + for idx, log in enumerate(logs): + if context.commit == log[0] and idx + 1 < len(logs): + target_commit = logs[idx + 1][0] + target_commit_timestamp = logs[idx + 1][1] + break + + if not target_commit: + self.logger.warning("Could not find '{}' target commit to revert to".format(context.name)) + else: + context.watcher.change_substatus(self.i18n['arch.downgrade.version_found']) + checkout_proc = new_subprocess(['git', 'checkout', target_commit], cwd=clone_path) + if not context.handler.handle(SystemProcess(checkout_proc, check_error_output=False)): + context.watcher.print("Could not rollback to current version's commit") + return False + + context.watcher.change_substatus(self.i18n['arch.downgrade.install_older']) + context.last_modified = target_commit_timestamp + context.commit = target_commit + return self._build(context) + + # trying to downgrade by version comparison + commit_found, commit_date = None, None srcfields = {'pkgver', 'pkgrel', 'epoch'} - commit_found, commit_date = None, None for idx in range(1, len(logs)): commit, date = logs[idx][0], logs[idx][1] with open(srcinfo_path) as f: @@ -671,10 +696,7 @@ class ArchManager(SoftwareManager): else: current_version = '{}-{}'.format(version, release) - if current_version == context.get_version(): - # current version found - commit_found, commit_date = commit, date - elif commit_found: + if commit_found: context.watcher.change_substatus(self.i18n['arch.downgrade.version_found']) checkout_proc = new_subprocess(['git', 'checkout', commit_found], cwd=clone_path) if not context.handler.handle(SystemProcess(checkout_proc, check_error_output=False)): @@ -687,9 +709,12 @@ class ArchManager(SoftwareManager): return False break + elif current_version == context.get_version(): # current version found: + commit_found, commit_date = commit, date context.watcher.change_substatus(self.i18n['arch.downgrade.install_older']) context.last_modified = commit_date + context.commit = commit_found return self._build(context) finally: if os.path.exists(context.build_dir) and context.config['aur_remove_build_dir']: @@ -755,12 +780,17 @@ class ArchManager(SoftwareManager): if self._is_database_locked(handler, root_password): return False + arch_config = read_config() + aur_supported = pkg.repository == 'aur' or aur.is_supported(arch_config) context = TransactionContext(name=pkg.name, base=pkg.get_base_name(), skip_opt_deps=True, change_progress=True, dependency=False, repository=pkg.repository, pkg=pkg, - arch_config=read_config(), watcher=watcher, handler=handler, root_password=root_password, - installed=set(), removed={}) + arch_config=arch_config, watcher=watcher, handler=handler, root_password=root_password, + installed=set(), removed={}, + aur_supported=aur_supported, + commit=pkg.commit) - self._sync_databases(context.config, root_password, handler) + self._sync_databases(arch_config=context.config, aur_supported=aur_supported, + root_password=root_password, handler=handler) watcher.change_progress(5) @@ -1075,7 +1105,10 @@ class ArchManager(SoftwareManager): return False arch_config = read_config() - self._sync_databases(arch_config=arch_config, root_password=root_password, handler=handler) + aur_supported = bool(aur_pkgs) or aur.is_supported(arch_config) + + self._sync_databases(arch_config=arch_config, aur_supported=aur_supported, + root_password=root_password, handler=handler) if repo_pkgs: if not self._upgrade_repo_pkgs(to_upgrade=[p.name for p in repo_pkgs], @@ -1111,7 +1144,7 @@ class ArchManager(SoftwareManager): self.aur_mapper.fill_last_modified(pkg=pkg, api_data=apidata[0]) context = TransactionContext.gen_context_from(pkg=pkg, arch_config=arch_config, - root_password=root_password, handler=handler) + root_password=root_password, handler=handler, aur_supported=True) context.change_progress = False try: @@ -1340,6 +1373,7 @@ class ArchManager(SoftwareManager): def uninstall(self, pkg: ArchPackage, root_password: str, watcher: ProcessWatcher, disk_loader: DiskCacheLoader) -> TransactionResult: self.aur_client.clean_caches() + handler = ProcessHandler(watcher) if self._is_database_locked(handler, root_password): @@ -1352,7 +1386,8 @@ class ArchManager(SoftwareManager): watcher=watcher, root_password=root_password, handler=handler, - removed=removed), + removed=removed, + aur_supported=pkg.repository == 'aur' or aur.is_supported(arch_config)), remove_unneeded=arch_config['suggest_unneeded_uninstall'], names={pkg.name}, disk_loader=disk_loader) # to be able to return all uninstalled packages @@ -1372,6 +1407,9 @@ class ArchManager(SoftwareManager): info = pacman.get_info_dict(pkg.name) self._parse_dates_string_from_info(pkg.name, info) + if pkg.commit: + info['commit'] = pkg.commit + if pkg.last_modified: info['last_modified'] = self._parse_timestamp(ts=pkg.last_modified, error_msg="Could not parse AUR package '{}' 'last_modified' field ({})".format(pkg.name, pkg.last_modified)) @@ -1464,6 +1502,12 @@ class ArchManager(SoftwareManager): return self._get_info_repo_pkg(pkg) def _get_history_aur_pkg(self, pkg: ArchPackage) -> PackageHistory: + + if pkg.commit: + self.logger.info("Package '{}' current commit {}".format(pkg.name, pkg.commit)) + else: + self.logger.warning("Package '{}' has no commit associated with it. Current history status may not be correct.".format(pkg.name)) + arch_config = read_config() temp_dir = '{}/build_{}'.format(get_build_dir(arch_config), int(time.time())) @@ -1479,24 +1523,34 @@ class ArchManager(SoftwareManager): if not os.path.exists(srcinfo_path): return PackageHistory.empyt(pkg) - commits = git.list_commits(clone_path) + logs = git.log_shas_and_timestamps(clone_path) - if commits: - srcfields = {'pkgver', 'pkgrel'} + if logs: + srcfields = {'epoch', 'pkgver', 'pkgrel'} history, status_idx = [], -1 - for idx, commit in enumerate(commits): + for idx, log in enumerate(logs): + commit, timestamp = log[0], log[1] + with open(srcinfo_path) as f: pkgsrc = aur.map_srcinfo(string=f.read(), pkgname=pkg.name, fields=srcfields) - if status_idx < 0 and '{}-{}'.format(pkgsrc.get('pkgver'), pkgsrc.get('pkgrel')) == pkg.version: - status_idx = idx + epoch, version, release = pkgsrc.get('epoch'), pkgsrc.get('pkgver'), pkgsrc.get('pkgrel') - history.append({'1_version': pkgsrc['pkgver'], '2_release': pkgsrc['pkgrel'], - '3_date': commit['date']}) # the number prefix is to ensure the rendering order + pkgver = '{}:{}'.format(epoch, version) if epoch is not None else version + current_version = '{}-{}'.format(pkgver, release) - if idx + 1 < len(commits): - if not run_cmd('git reset --hard ' + commits[idx + 1]['commit'], cwd=clone_path): + if status_idx < 0: + if pkg.commit: + status_idx = idx if pkg.commit == commit else -1 + else: + status_idx = idx if current_version == pkg.version else -1 + + history.append({'1_version': pkgver, '2_release': release, + '3_date': datetime.fromtimestamp(timestamp)}) # the number prefix is to ensure the rendering order + + if idx + 1 < len(logs): + if not run_cmd('git reset --hard ' + logs[idx + 1][0], cwd=clone_path): break return PackageHistory(pkg=pkg, history=history, pkg_status_idx=status_idx) @@ -1842,6 +1896,12 @@ class ArchManager(SoftwareManager): if pkgbuilt: self.__fill_aur_output_files(context) + self.logger.info("Reading '{}' cloned repository current commit".format(context.name)) + context.commit = git.get_current_commit(context.project_dir) + + if not context.commit: + self.logger.error("Could not read '{}' cloned repository current commit".format(context.name)) + if self._install(context=context): self._save_pkgbuild(context) @@ -2273,6 +2333,7 @@ class ArchManager(SoftwareManager): repository=context.repository, maintainer=pkg_maintainer, last_modified=context.last_modified, + commit=context.commit, categories=self.categories.get(context.name))} if context.missing_deps: aur_deps = {dep[0] for dep in context.missing_deps if dep[1] == 'aur'} @@ -2374,29 +2435,21 @@ class ArchManager(SoftwareManager): if build_dir: base_name = context.get_base_name() - file_url = URL_PKG_DOWNLOAD.format(base_name) - file_name = file_url.split('/')[-1] - context.watcher.change_substatus('{} {}'.format(self.i18n['arch.downloading.package'], bold(file_name))) - download = context.handler.handle(SystemProcess(new_subprocess(['wget', file_url], cwd=context.build_dir), check_error_output=False)) + context.watcher.change_substatus(self.i18n['arch.clone'].format(bold(base_name))) + cloned = context.handler.handle_simple(git.clone_as_process(url=URL_GIT.format(base_name), cwd=context.build_dir, depth=1)) - if download: - self._update_progress(context, 30) - context.watcher.change_substatus('{} {}'.format(self.i18n['arch.uncompressing.package'], bold(base_name))) - uncompress = context.handler.handle(SystemProcess(new_subprocess(['tar', 'xvzf', '{}.tar.gz'.format(base_name)], cwd=context.build_dir))) + if cloned: self._update_progress(context, 40) - - if uncompress: - context.project_dir = '{}/{}'.format(context.build_dir, base_name) - - return self._build(context) + context.project_dir = '{}/{}'.format(context.build_dir, base_name) + return self._build(context) finally: if os.path.exists(context.build_dir) and context.config['aur_remove_build_dir']: context.handler.handle(SystemProcess(new_subprocess(['rm', '-rf', context.build_dir]))) return False - def _sync_databases(self, arch_config: dict, root_password: str, handler: ProcessHandler, change_substatus: bool = True): - if bool(arch_config['sync_databases']) and database.should_sync(arch_config, handler, self.logger): + def _sync_databases(self, arch_config: dict, aur_supported: bool, root_password: str, handler: ProcessHandler, change_substatus: bool = True): + if bool(arch_config['sync_databases']) and database.should_sync(arch_config, aur_supported, handler, self.logger): if change_substatus: handler.watcher.change_substatus(self.i18n['arch.sync_databases.substatus']) @@ -2408,7 +2461,7 @@ class ArchManager(SoftwareManager): handler.watcher.change_substatus(self.i18n['arch.sync_databases.substatus.error']) def _optimize_makepkg(self, arch_config: dict, watcher: Optional[ProcessWatcher]): - if arch_config['aur'] and arch_config['optimize'] and not os.path.exists(CUSTOM_MAKEPKG_FILE): + if arch_config['optimize'] and not os.path.exists(CUSTOM_MAKEPKG_FILE): watcher.change_substatus(self.i18n['arch.makepkg.optimizing']) ArchCompilationOptimizer(arch_config=arch_config, i18n=self.i18n, logger=self.context.logger).optimize() @@ -2431,7 +2484,8 @@ class ArchManager(SoftwareManager): install_context.skip_opt_deps = False install_context.disk_loader = disk_loader - self._sync_databases(arch_config=install_context.config, root_password=root_password, handler=handler) + self._sync_databases(arch_config=install_context.config, aur_supported=install_context.aur_supported, + root_password=root_password, handler=handler) if pkg.repository == 'aur': res = self._install_from_aur(install_context) @@ -2477,12 +2531,6 @@ class ArchManager(SoftwareManager): self.logger.warning("Could not load all installed packages. Missing: {}".format(missing)) removed = [*install_context.removed.values()] if install_context.removed else [] - - if installed: - downgrade_enabled = self.is_downgrade_enabled() - for p in installed: - p.downgrade_enabled = downgrade_enabled - return TransactionResult(success=res, installed=installed, removed=removed) def _install_from_repository(self, context: TransactionContext) -> bool: @@ -2533,13 +2581,6 @@ class ArchManager(SoftwareManager): except FileNotFoundError: return False - def is_downgrade_enabled(self) -> bool: - try: - new_subprocess(['git', '--version']) - return True - except FileNotFoundError: - return False - def cache_to_disk(self, pkg: ArchPackage, icon_bytes: bytes, only_icon: bool): pass @@ -2550,7 +2591,8 @@ class ArchManager(SoftwareManager): if arch_config['refresh_mirrors_startup'] and mirrors.should_sync(self.logger): return True - return arch_config['sync_databases_startup'] and database.should_sync(arch_config, None, self.logger) + aur_supported = (pkg and pkg.repository == 'aur') or aur.is_supported(arch_config) + return arch_config['sync_databases_startup'] and database.should_sync(arch_config, aur_supported, None, self.logger) return action != SoftwareAction.SEARCH @@ -2565,21 +2607,24 @@ class ArchManager(SoftwareManager): def prepare(self, task_manager: TaskManager, root_password: str, internet_available: bool): arch_config = read_config(update_file=True) - if arch_config['aur']: + if internet_available: + self.index_aur = AURIndexUpdater(context=self.context, taskman=task_manager) # must all execute to properly determine the installed packages (even that AUR is disabled) + self.index_aur.start() + + aur_supported = aur.is_supported(arch_config) + + if aur_supported: ArchCompilationOptimizer(arch_config, self.i18n, self.context.logger, task_manager).start() - if internet_available: - self.index_aur = AURIndexUpdater(context=self.context, taskman=task_manager) - self.index_aur.start() - - if arch_config['aur'] or arch_config['repositories']: + if aur_supported or arch_config['repositories']: self.disk_cache_updater = ArchDiskCacheUpdater(task_man=task_manager, arch_config=arch_config, i18n=self.i18n, logger=self.context.logger, controller=self, internet_available=internet_available, - aur_indexer=self.index_aur) + aur_indexer=self.index_aur, + aur_supported=aur_supported) self.disk_cache_updater.start() CategoriesDownloader(id_='Arch', http_client=self.context.http_client, logger=self.context.logger, @@ -2597,7 +2642,7 @@ class ArchManager(SoftwareManager): sort_limit=arch_config['mirrors_sort_limit']) refresh_mirrors.start() - if internet_available and (refresh_mirrors or (arch_config['sync_databases_startup'] and database.should_sync(arch_config, None, self.logger))): + if internet_available and (refresh_mirrors or (arch_config['sync_databases_startup'] and database.should_sync(arch_config, aur_supported, None, self.logger))): SyncDatabases(taskman=task_manager, root_password=root_password, i18n=self.i18n, logger=self.logger, refresh_mirrors=refresh_mirrors).start() @@ -2839,10 +2884,20 @@ class ArchManager(SoftwareManager): def get_upgrade_requirements(self, pkgs: List[ArchPackage], root_password: str, watcher: ProcessWatcher) -> UpgradeRequirements: self.aur_client.clean_caches() arch_config = read_config() - self._sync_databases(arch_config=arch_config, root_password=root_password, handler=ProcessHandler(watcher), change_substatus=False) - self.aur_client.clean_caches() + + aur_supported = aur.is_supported(arch_config) + + self._sync_databases(arch_config=arch_config, aur_supported=aur_supported, + root_password=root_password, handler=ProcessHandler(watcher), change_substatus=False) + + summarizer = UpdatesSummarizer(aur_client=self.aur_client, + aur_supported=aur_supported, + i18n=self.i18n, + logger=self.logger, + deps_analyser=self.deps_analyser, + watcher=watcher) try: - return UpdatesSummarizer(self.aur_client, self.i18n, self.logger, self.deps_analyser, watcher).summarize(pkgs, root_password, arch_config) + return summarizer.summarize(pkgs, root_password, arch_config) except PackageNotFoundException: pass # when nothing is returned, the upgrade is called off by the UI diff --git a/bauh/gems/arch/database.py b/bauh/gems/arch/database.py index 8e3ff6d5..b07b8a61 100644 --- a/bauh/gems/arch/database.py +++ b/bauh/gems/arch/database.py @@ -5,6 +5,7 @@ import traceback from datetime import datetime from logging import Logger from pathlib import Path +from typing import Optional from bauh.api.constants import CACHE_PATH from bauh.commons.system import ProcessHandler @@ -12,8 +13,8 @@ from bauh.commons.system import ProcessHandler SYNC_FILE = '{}/arch/db_sync'.format(CACHE_PATH) -def should_sync(arch_config: dict, handler: ProcessHandler, logger: logging.Logger): - if arch_config['aur'] or arch_config['repositories']: +def should_sync(arch_config: dict, aur_supported: bool, handler: Optional[ProcessHandler], logger: logging.Logger): + if aur_supported or arch_config['repositories']: if os.path.exists(SYNC_FILE): with open(SYNC_FILE) as f: sync_file = f.read() diff --git a/bauh/gems/arch/git.py b/bauh/gems/arch/git.py index 92387bab..5ae7de0b 100644 --- a/bauh/gems/arch/git.py +++ b/bauh/gems/arch/git.py @@ -2,15 +2,12 @@ from datetime import datetime from typing import List, Tuple, Optional from bauh.commons import system -from bauh.commons.system import new_subprocess +from bauh.commons.system import new_subprocess, SimpleProcess def is_installed() -> bool: - try: - new_subprocess(['git', '--version']) - return True - except FileNotFoundError: - return False + code, _ = system.execute(cmd='which git', output=False) + return code == 0 def list_commits(proj_dir: str) -> List[dict]: @@ -30,6 +27,17 @@ def list_commits(proj_dir: str) -> List[dict]: return commits +def get_current_commit(repo_path: str) -> Optional[str]: + code, output = system.execute(cmd='git log -1 --format=%H', shell=True, cwd=repo_path) + + if code == 0: + for line in output.strip().split('\n'): + line_strip = line.strip() + + if line_strip: + return line_strip + + def log_shas_and_timestamps(repo_path: str) -> Optional[List[Tuple[str, int]]]: code, output = system.execute(cmd='git log --format="%H %at"', shell=True, cwd=repo_path) @@ -43,3 +51,12 @@ def log_shas_and_timestamps(repo_path: str) -> Optional[List[Tuple[str, int]]]: logs.append((line_split[0].strip(), int(line_split[1].strip()))) return logs + + +def clone_as_process(url: str, cwd: Optional[str], depth: int = -1) -> SimpleProcess: + cmd = ['git', 'clone', url] + + if depth > 0: + cmd.append('--depth={}'.format(depth)) + + return SimpleProcess(cmd=cmd, cwd=cwd) diff --git a/bauh/gems/arch/model.py b/bauh/gems/arch/model.py index c013d1d3..563d38c4 100644 --- a/bauh/gems/arch/model.py +++ b/bauh/gems/arch/model.py @@ -5,7 +5,7 @@ from bauh.commons import resource from bauh.gems.arch import ROOT_DIR, ARCH_CACHE_PATH from bauh.view.util.translation import I18n -CACHED_ATTRS = {'command', 'icon_path', 'repository', 'maintainer', 'desktop_entry', 'categories', 'last_modified'} +CACHED_ATTRS = {'command', 'icon_path', 'repository', 'maintainer', 'desktop_entry', 'categories', 'last_modified', 'commit'} ACTIONS_AUR_ENABLE_PKGBUILD_EDITION = [CustomSoftwareAction(i18n_label_key='arch.action.enable_pkgbuild_edition', i18n_status_key='arch.action.enable_pkgbuild_edition.status', @@ -30,7 +30,7 @@ class ArchPackage(SoftwarePackage): maintainer: str = None, url_download: str = None, pkgbuild: str = None, repository: str = None, desktop_entry: str = None, installed: bool = False, srcinfo: dict = None, dependencies: Set[str] = None, categories: List[str] = None, i18n: I18n = None, update_ignored: bool = False, arch: str = None, - pkgbuild_editable: bool = None, install_date: Optional[int] = None): + pkgbuild_editable: bool = None, install_date: Optional[int] = None, commit: Optional[str] = None): super(ArchPackage, self).__init__(name=name, version=version, latest_version=latest_version, description=description, installed=installed, categories=categories) @@ -45,7 +45,6 @@ class ArchPackage(SoftwarePackage): self.repository = repository self.command = None self.icon_path = None - self.downgrade_enabled = False self.desktop_entry = desktop_entry self.src_info = srcinfo self.dependencies = dependencies @@ -55,6 +54,7 @@ class ArchPackage(SoftwarePackage): self.view_name = name # name displayed on the view self.pkgbuild_editable = pkgbuild_editable # if the PKGBUILD can be edited by the user (only for AUR) self.install_date = install_date + self.commit = commit # only for AUR for downgrading purposes @staticmethod def disk_cache_path(pkgname: str): @@ -75,7 +75,7 @@ class ArchPackage(SoftwarePackage): return bool(self.url_download) if self.repository == 'aur' else True def can_be_downgraded(self): - return self.installed and self.downgrade_enabled and self.repository == 'aur' + return self.installed and self.repository == 'aur' def get_type(self): return 'aur' if self.repository == 'aur' else 'arch_repo' diff --git a/bauh/gems/arch/pacman.py b/bauh/gems/arch/pacman.py index 4b426e3b..b929f266 100644 --- a/bauh/gems/arch/pacman.py +++ b/bauh/gems/arch/pacman.py @@ -1031,7 +1031,7 @@ def map_replaces(names: Iterable[str], remote: bool = False) -> Dict[str, Set[st elif latest_name and replaces is not None: res[latest_name] = replaces - latest_name, replaces = None, None, None + latest_name, replaces = None, None elif latest_name and replaces is not None: replaces.update((d for d in l.strip().split(' ') if d)) diff --git a/bauh/gems/arch/resources/locale/ca b/bauh/gems/arch/resources/locale/ca index 78256d86..8226144f 100644 --- a/bauh/gems/arch/resources/locale/ca +++ b/bauh/gems/arch/resources/locale/ca @@ -32,7 +32,7 @@ arch.checking.deps=S’estan comprovant les dependències de {} arch.checking.missing_deps=Verificació de les dependències que falten de {} arch.clone=S’està clonant el dipòsit {} de l’AUR arch.config.aur=AUR packages -arch.config.aur.tip=It allows to manage AUR packages +arch.config.aur.tip=It allows to manage AUR packages. git must be installed. arch.config.automatch_providers=Auto-define dependency providers arch.config.automatch_providers.tip=It automatically chooses which provider will be used for a package dependency when both names are equal. arch.config.aur_build_dir=Build directory (AUR) @@ -106,7 +106,6 @@ arch.downgrade.reading_commits=S’estan llegint les revisions del dipòsit arch.downgrade.repo_pkg.no_versions=No s'ha trobat cap versió antiga al disc arch.downgrade.searching_stored=Cerqueu versions antigues al disc arch.downgrade.version_found=S’ha trobat la versió actual del paquet -arch.downloading.package=S’està baixant el paquet arch.info.00_pkg_build=PKGBUILD arch.info.01_id=identificació arch.info.02_name=nom @@ -222,7 +221,6 @@ arch.task.mirrors=Refreshing mirrors arch.task.optimizing=Optimizing {} arch.task.sync_databases.waiting=Waiting for {} arch.task.sync_sb.status=Actualitzen {} -arch.uncompressing.package=S’està descomprimint el paquet arch.uninstall.clean_cached.error=No s'ha pogut eliminar {} versions antigues que es troba al disc arch.uninstall.clean_cached.substatus=Eliminació de versions antigues del disc arch.uninstall.error.hard_dep_in_hold=It is not possible to uninstall {} because one of its dependencies is marked as "InHold" @@ -254,7 +252,7 @@ arch.upgrade.success=Package {} successfully upgraded arch.upgrade.upgrade_aur_pkgs=Upgrading AUR packages arch.upgrade.upgrade_repo_pkgs=Upgrading packages from repositories arch.warning.disabled=Sembla que no s’ha instal·lat {}. No podreu gestionar paquets Arch/AUR. -arch.warning.git=Sembla que no s’ha instal·lat {}. No podreu revertir les versions de paquets Arch/AUR. +arch.warning.git={} seems not to be installed. It will not be possible to manage AUR packages. arch_repo.history.1_version=versió arch_repo.history.2_release=publicació arch_repo.history.3_date=data diff --git a/bauh/gems/arch/resources/locale/de b/bauh/gems/arch/resources/locale/de index ae1ecd98..1121223a 100644 --- a/bauh/gems/arch/resources/locale/de +++ b/bauh/gems/arch/resources/locale/de @@ -32,7 +32,7 @@ arch.checking.deps={} Abhängigkeiten überprüfen arch.checking.missing_deps=Überprüfen der fehlenden Abhängigkeiten von {} arch.clone=AUR Repository {} wird kopiert arch.config.aur=AUR packages -arch.config.aur.tip=It allows to manage AUR packages +arch.config.aur.tip=It allows to manage AUR packages. git must be installed. arch.config.automatch_providers=Auto-define dependency providers arch.config.automatch_providers.tip=It automatically chooses which provider will be used for a package dependency when both names are equal. arch.config.aur_build_dir=Build directory (AUR) @@ -106,7 +106,6 @@ arch.downgrade.reading_commits=Repository Commits lesen arch.downgrade.repo_pkg.no_versions=No old version found on disk arch.downgrade.searching_stored=Looking for old versions on disk arch.downgrade.version_found=Aktuelle Paketversion gefunden -arch.downloading.package=Paket herunterladen arch.info.00_pkg_build=pkgbuild arch.info.01_id=Ich würde arch.info.02_name=Name @@ -222,7 +221,6 @@ arch.task.mirrors=Refreshing mirrors arch.task.optimizing=Optimizing {} arch.task.sync_databases.waiting=Waiting for {} arch.task.sync_sb.status=Updating {} -arch.uncompressing.package=Paket entpacken arch.uninstall.clean_cached.error=It was not possible to remove old {} versions found on disk arch.uninstall.clean_cached.substatus=Removing old versions from disk arch.uninstall.error.hard_dep_in_hold=It is not possible to uninstall {} because one of its dependencies is marked as "InHold" @@ -254,7 +252,7 @@ arch.upgrade.success=Package {} successfully upgraded arch.upgrade.upgrade_aur_pkgs=Upgrading AUR packages arch.upgrade.upgrade_repo_pkgs=Upgrading packages from repositories arch.warning.disabled={} scheint nicht intstalliert zu sein. Die Verwaltung von Arch / AUR Pakten wird nicht möglich sein. -arch.warning.git={} scheint nicht installiert zu sein. Es wird nicht möglich sein, AUR Pakete zu downgraden. +arch.warning.git={} seems not to be installed. It will not be possible to manage AUR packages. arch_repo.history.1_version=Version arch_repo.history.2_release=Release arch_repo.history.3_date=Datum diff --git a/bauh/gems/arch/resources/locale/en b/bauh/gems/arch/resources/locale/en index 830b05db..5b14be01 100644 --- a/bauh/gems/arch/resources/locale/en +++ b/bauh/gems/arch/resources/locale/en @@ -32,7 +32,7 @@ arch.checking.deps=Checking {} dependencies arch.checking.missing_deps=Verifying missing dependencies of {} arch.clone=Cloning the AUR repository {} arch.config.aur=AUR packages -arch.config.aur.tip=It allows to manage AUR packages +arch.config.aur.tip=It allows to manage AUR packages. git must be installed. arch.config.automatch_providers=Auto-define dependency providers arch.config.automatch_providers.tip=It automatically chooses which provider will be used for a package dependency when both names are equal. arch.config.aur_build_dir=Build directory (AUR) @@ -106,7 +106,6 @@ arch.downgrade.reading_commits=Reading the repository commits arch.downgrade.repo_pkg.no_versions=No old version found on disk arch.downgrade.searching_stored=Looking for old versions on disk arch.downgrade.version_found=Current package version found -arch.downloading.package=Downloading the package arch.info.00_pkg_build=pkgbuild arch.info.01_id=id arch.info.02_name=name @@ -222,7 +221,6 @@ arch.task.mirrors=Refreshing mirrors arch.task.optimizing=Optimizing {} arch.task.sync_databases.waiting=Waiting for {} arch.task.sync_sb.status=Updating {} -arch.uncompressing.package=Uncompressing the package arch.uninstall.clean_cached.error=It was not possible to remove old {} versions found on disk arch.uninstall.clean_cached.substatus=Removing old versions from disk arch.uninstall.error.hard_dep_in_hold=It is not possible to uninstall {} because one of its dependencies is marked as "InHold" @@ -254,7 +252,7 @@ arch.upgrade.success=Package {} successfully upgraded arch.upgrade.upgrade_aur_pkgs=Upgrading AUR packages arch.upgrade.upgrade_repo_pkgs=Upgrading packages from repositories arch.warning.disabled={} seems not to be installed. It will not be possible to manage Arch / AUR packages. -arch.warning.git={} seems not to be installed. It will not be possible to downgrade AUR packages. +arch.warning.git={} seems not to be installed. It will not be possible to manage AUR packages. arch_repo.history.1_version=version arch_repo.history.2_release=release arch_repo.history.3_date=date diff --git a/bauh/gems/arch/resources/locale/es b/bauh/gems/arch/resources/locale/es index 7a5c2038..5782d4be 100644 --- a/bauh/gems/arch/resources/locale/es +++ b/bauh/gems/arch/resources/locale/es @@ -32,7 +32,7 @@ arch.checking.deps=Verificando las dependencias de {} arch.checking.missing_deps=Verificando las dependencias faltantes de {} arch.clone=Clonando el repositorio {} de AUR arch.config.aur=Paquetes de AUR -arch.config.aur.tip=Permite gestionar paquetes del AUR +arch.config.aur.tip=Permite gestionar paquetes del AUR. git debe estar instalado. arch.config.automatch_providers=Autodefinir proveedores de dependencia arch.config.automatch_providers.tip=Elige automáticamente qué proveedor se usará para una dependencia de paquete cuando ambos nombres son iguales. arch.config.aur_build_dir=Directorio de compilación (AUR) @@ -106,7 +106,6 @@ arch.downgrade.reading_commits=Leyendo los commits del repositorio arch.downgrade.repo_pkg.no_versions=No se encontró una versión anterior en el disco arch.downgrade.searching_stored=Buscando versiones antiguas en el disco arch.downgrade.version_found=Version actual del paquete encontrada -arch.downloading.package=Descargando el paquete arch.info.00_pkg_build=pkgbuild arch.info.01_id=id arch.info.02_name=nombre @@ -222,7 +221,6 @@ arch.task.mirrors=Actualizando espejos arch.task.optimizing=Optimizando {} arch.task.sync_databases.waiting=Esperando por {} arch.task.sync_sb.status=Actualizando {} -arch.uncompressing.package=Descomprimindo el paquete arch.uninstall.clean_cached.error=No fue posible eliminar versiones antiguas de {} encontradas en disco arch.uninstall.clean_cached.substatus=Eliminando versiones antiguas del disco arch.uninstall.error.hard_dep_in_hold=No es posible desinstalar {} porque una de sus dependencias está bloqueada (InHold) @@ -254,7 +252,7 @@ arch.upgrade.success=Paquete {} actualizado con éxito arch.upgrade.upgrade_aur_pkgs=Actualizando paquetes de AUR arch.upgrade.upgrade_repo_pkgs=Actualizando paquetes de repositorios arch.warning.disabled={} parece no estar instalado. No será posible administrar paquetes Arch / AUR. -arch.warning.git={} parece no estar instalado. No será posible revertir las versiones de paquetes Arch / AUR. +arch.warning.git={} parece no estar instalado. No será posible administrar paquetes del AUR. arch_repo.history.1_version=versión arch_repo.history.2_release=lanzamiento arch_repo.history.3_date=fecha diff --git a/bauh/gems/arch/resources/locale/fr b/bauh/gems/arch/resources/locale/fr index 2f9201e8..66703409 100644 --- a/bauh/gems/arch/resources/locale/fr +++ b/bauh/gems/arch/resources/locale/fr @@ -32,7 +32,7 @@ arch.checking.deps=Vérification des dépendances de {} arch.checking.missing_deps=Vérification des dépendances manquantes de {} arch.clone=Copie du dépôt AUR {} arch.config.aur=Paquêts AUR -arch.config.aur.tip=Permet la gestion des paquets AUR +arch.config.aur.tip=Permet la gestion des paquets AUR. git doit être installé. arch.config.automatch_providers=Définition automatique des fournisseurs de dépendances arch.config.automatch_providers.tip=Choisit automatiquement le fournisseur de dépendances d'un paquet en cas de noms identiques arch.config.aur_build_dir=Répertoire de compilation (AUR) @@ -106,7 +106,6 @@ arch.downgrade.reading_commits=Lecture des commits du dépôt arch.downgrade.repo_pkg.no_versions=Aucune version antérieure trouvée sur le disque arch.downgrade.searching_stored=Recherche de version antérieure sur le disque arch.downgrade.version_found=Version actuelle du paquet trouvée -arch.downloading.package=Téléchargement du paquet arch.info.00_pkg_build=pkgbuild arch.info.01_id=id arch.info.02_name=nom @@ -222,7 +221,6 @@ arch.task.mirrors=Mise à jour des miroirs arch.task.optimizing=Optimisation {} arch.task.sync_databases.waiting=Attente de {} arch.task.sync_sb.status=Mise à jour {} -arch.uncompressing.package=Décompression du paquet arch.uninstall.clean_cached.error=Impossible de supprimer les anciennes version de {} trouvées sur le disque arch.uninstall.clean_cached.substatus=Suppression des anciennes versions arch.uninstall.error.hard_dep_in_hold=Impossible de désinstaller {} une de ses dépendances est marquée "InHold" @@ -254,7 +252,7 @@ arch.upgrade.success=Paquet {} mis à jour avec succès arch.upgrade.upgrade_aur_pkgs=Mise à jour des paquets AUR arch.upgrade.upgrade_repo_pkgs=Mise à jour des paquets de dépots arch.warning.disabled={} n'a pas l'air d'être installé. Il ne sera pas possible de gérer les paquets Arch / AUR. -arch.warning.git={} n'a pas l'air d'être installé. Il ne sera pas possible de downgrader les paquets AUR. +arch.warning.git={} seems not to be installed. It will not be possible to manage AUR packages. arch_repo.history.1_version=version arch_repo.history.2_release=livraison arch_repo.history.3_date=date diff --git a/bauh/gems/arch/resources/locale/it b/bauh/gems/arch/resources/locale/it index e018140b..40259ec5 100644 --- a/bauh/gems/arch/resources/locale/it +++ b/bauh/gems/arch/resources/locale/it @@ -32,7 +32,7 @@ arch.checking.deps=Verifica di {} dipendenze arch.checking.missing_deps=Verifica delle dipendenze mancanti di {} arch.clone=Clonazione del repository AUR {} arch.config.aur=AUR packages -arch.config.aur.tip=It allows to manage AUR packages +arch.config.aur.tip=It allows to manage AUR packages. git must be installed. arch.config.automatch_providers=Auto-define dependency providers arch.config.automatch_providers.tip=It automatically chooses which provider will be used for a package dependency when both names are equal. arch.config.aur_build_dir=Build directory (AUR) @@ -106,7 +106,6 @@ arch.downgrade.reading_commits=Reading the repository commits arch.downgrade.repo_pkg.no_versions=Nessuna versione precedente trovata sul disco arch.downgrade.searching_stored=Ricerca di versioni precedenti su disco arch.downgrade.version_found=Trovata la versione del pacchetto corrente -arch.downloading.package=Download del pacchetto arch.info.00_pkg_build=pkgbuild arch.info.01_id=id arch.info.02_name=nome @@ -222,7 +221,6 @@ arch.task.mirrors=Aggiornando i mirror arch.task.optimizing=Ottimizzando {} arch.task.sync_databases.waiting=Waiting for {} arch.task.sync_sb.status=Aggiornando {} -arch.uncompressing.package=Non comprimere il pacchetto arch.uninstall.clean_cached.error=Non è stato possibile rimuovere le vecchie {} versioni trovate sul disco arch.uninstall.clean_cached.substatus=Rimozione di versioni precedenti dal disco arch.uninstall.error.hard_dep_in_hold=It is not possible to uninstall {} because one of its dependencies is marked as "InHold" @@ -254,7 +252,7 @@ arch.upgrade.success=Package {} successfully upgraded arch.upgrade.upgrade_aur_pkgs=Upgrading AUR packages arch.upgrade.upgrade_repo_pkgs=Upgrading packages from repositories arch.warning.disabled={} sembra non essere installato. Non sarà possibile gestire i pacchetti Arch/AUR. -arch.warning.git={} sembra non essere installato. Non sarà possibile effettuare il downgrade dei pacchetti AUR. +arch.warning.git={} seems not to be installed. It will not be possible to manage AUR packages. arch_repo.history.1_version=versione arch_repo.history.2_release=rilascio arch_repo.history.3_date=data diff --git a/bauh/gems/arch/resources/locale/pt b/bauh/gems/arch/resources/locale/pt index 8ed4bcf8..809d175f 100644 --- a/bauh/gems/arch/resources/locale/pt +++ b/bauh/gems/arch/resources/locale/pt @@ -32,7 +32,7 @@ arch.checking.deps=Verificando as dependências de {} arch.checking.missing_deps=Verificando dependências ausentes de {} arch.clone=Clonando o repositório {} do AUR arch.config.aur=Pacotes do AUR -arch.config.aur.tip=Permite gerenciar pacotes dos AUR +arch.config.aur.tip=Permite gerenciar pacotes dos AUR. git precisa estar instalado. arch.config.automatch_providers=Auto-definir provedores de dependências arch.config.automatch_providers.tip=Escolhe automaticamente qual provedor será utilizado para determinada dependência de um pacote caso os nomes de ambos sejam iguais. arch.config.aur_build_dir=Diretório de construção (AUR) @@ -105,7 +105,6 @@ arch.downgrade.reading_commits=Lendo os commits do repositório arch.downgrade.repo_pkg.no_versions=Nenhuma versão antiga encontrada no disco arch.downgrade.searching_stored=Procurando versões antigas no disco arch.downgrade.version_found=Versão atual do pacote encontrada -arch.downloading.package=Baixando o pacote arch.info.00_pkg_build=pkgbuild arch.info.01_id=id arch.info.02_name=nome @@ -221,7 +220,6 @@ arch.task.mirrors=Atualizando espelhos arch.task.optimizing=Otimizando {} arch.task.sync_databases.waiting=Aguardando por {} arch.task.sync_sb.status=Atualizando {} -arch.uncompressing.package=Descompactando o pacote arch.uninstall.clean_cached.error=Não foi possível remover versões antigas de {} encontradas em disco arch.uninstall.clean_cached.substatus=Removendo versões antigas do disco arch.uninstall.error.hard_dep_in_hold=Não é possível desinstalar {} pois uma de suas dependências está bloqueada (InHold) @@ -253,7 +251,7 @@ arch.upgrade.success=Pacote {} atualizado com sucesso arch.upgrade.upgrade_aur_pkgs=Atualizando pacotes do AUR arch.upgrade.upgrade_repo_pkgs=Atualizando pacotes dos repositórios arch.warning.disabled={} parece não estar instalado. Não será possível gerenciar pacotes Arch / AUR. -arch.warning.git={} parece não estar instalado. Não será possível reverter versões de pacotes Arch / AUR. +arch.warning.git={} parece não estar instalado. Não será possível gerenciar pacotes do AUR. arch_repo.history.1_version=versão arch_repo.history.2_release=lançamento arch_repo.history.3_date=data diff --git a/bauh/gems/arch/resources/locale/ru b/bauh/gems/arch/resources/locale/ru index 5641aa7d..4eefc357 100644 --- a/bauh/gems/arch/resources/locale/ru +++ b/bauh/gems/arch/resources/locale/ru @@ -32,7 +32,7 @@ arch.checking.deps=Проверка зависимостей {} arch.checking.missing_deps=Проверка отсутствующих зависимостей {} arch.clone=Клонирование AUR-репозитория {} arch.config.aur=пакеты AUR -arch.config.aur.tip=Это позволяет управлять пакетами AUR +arch.config.aur.tip=Это позволяет управлять пакетами AUR. git должен быть установлен. arch.config.automatch_providers=Auto-define dependency providers arch.config.automatch_providers.tip=It automatically chooses which provider will be used for a package dependency when both names are equal. arch.config.aur_build_dir=Build directory (AUR) @@ -106,7 +106,6 @@ arch.downgrade.reading_commits=Чтение коммитов репозитор arch.downgrade.repo_pkg.no_versions=No old version found on disk arch.downgrade.searching_stored=Looking for old versions on disk arch.downgrade.version_found=Найдена текущая версия пакета -arch.downloading.package=Загрузка пакета arch.info.00_pkg_build=PKGBUILD arch.info.01_id=Идентификатор arch.info.02_name=Имя @@ -222,7 +221,6 @@ arch.task.mirrors=Обновление зеркал arch.task.optimizing=Optimizing {} arch.task.sync_databases.waiting=Waiting for {} arch.task.sync_sb.status=Updating {} -arch.uncompressing.package=Распаковка пакета arch.uninstall.clean_cached.error=It was not possible to remove old {} versions found on disk arch.uninstall.clean_cached.substatus=Removing old versions from disk arch.uninstall.error.hard_dep_in_hold=It is not possible to uninstall {} because one of its dependencies is marked as "InHold" @@ -254,7 +252,7 @@ arch.upgrade.success=Package {} successfully upgraded arch.upgrade.upgrade_aur_pkgs=Upgrading AUR packages arch.upgrade.upgrade_repo_pkgs=Upgrading packages from repositories arch.warning.disabled={} кажется, не установлен. Управлять пакетами Arch / AUR будет невозможно. -arch.warning.git={} кажется, не установлен. Понижение версии пакетов AUR невозможно. +arch.warning.git={} seems not to be installed. It will not be possible to manage AUR packages. arch_repo.history.1_version=version arch_repo.history.2_release=release arch_repo.history.3_date=date diff --git a/bauh/gems/arch/resources/locale/tr b/bauh/gems/arch/resources/locale/tr index ce8290b1..71440d55 100644 --- a/bauh/gems/arch/resources/locale/tr +++ b/bauh/gems/arch/resources/locale/tr @@ -32,7 +32,7 @@ arch.checking.deps={} bağımlılıkları kontrol ediliyor arch.checking.missing_deps={} eksik bağımlılıkları kontrol ediliyor arch.clone=AUR deposu kopyalanıyor {} arch.config.aur=AUR paketleri -arch.config.aur.tip=AUR paketlerinin yönetilmesine izin verir +arch.config.aur.tip=AUR paketlerinin yönetilmesine izin verir. git yüklenmeli. arch.config.automatch_providers=Auto-define dependency providers arch.config.automatch_providers.tip=It automatically chooses which provider will be used for a package dependency when both names are equal. arch.config.aur_build_dir=Build directory (AUR) @@ -106,7 +106,6 @@ arch.downgrade.reading_commits=Depo çalışmalarını oku arch.downgrade.repo_pkg.no_versions=Diskte eski sürüm bulunamadı arch.downgrade.searching_stored=Diskteki eski sürümlere bakılıyor arch.downgrade.version_found=Geçerli paket sürümü bulundu -arch.downloading.package=Paket indiriliyor arch.info.00_pkg_build=pkgbuild arch.info.01_id=kimlik arch.info.02_name=isim @@ -222,7 +221,6 @@ arch.task.mirrors=Yansılar yenileniyor arch.task.optimizing=Uygun hale getiriliyor {} arch.task.sync_databases.waiting=Waiting for {} arch.task.sync_sb.status={} güncelleniyor -arch.uncompressing.package=Paket arşivden çıkarılıyor arch.uninstall.clean_cached.error=Diskte bulunan eski {} sürümleri kaldırılamadı arch.uninstall.clean_cached.substatus=Eski sürümler diskten kaldırılıyor arch.uninstall.error.hard_dep_in_hold=It is not possible to uninstall {} because one of its dependencies is marked as "InHold" @@ -254,7 +252,7 @@ arch.upgrade.success={} paketi başarıyla yükseltildi arch.upgrade.upgrade_aur_pkgs=AUR paketleri yükseltiliyor arch.upgrade.upgrade_repo_pkgs=Resmi depo paketleri yükseltiliyor arch.warning.disabled={} kurulu değil gibi görünüyor. Arch / AUR paketlerini yönetmek mümkün olmayacaktır. -arch.warning.git={} kurulu değil gibi görünüyor. AUR paketlerini eski sürüme geçirmek mümkün olmayacaktır. +arch.warning.git={} seems not to be installed. It will not be possible to manage AUR packages. arch_repo.history.1_version=sürüm arch_repo.history.2_release=sürüm inşa arch_repo.history.3_date=tarih diff --git a/bauh/gems/arch/updates.py b/bauh/gems/arch/updates.py index fc4d32bb..65fa7964 100644 --- a/bauh/gems/arch/updates.py +++ b/bauh/gems/arch/updates.py @@ -8,7 +8,7 @@ from pkg_resources import parse_version from bauh.api.abstract.controller import UpgradeRequirements, UpgradeRequirement from bauh.api.abstract.handler import ProcessWatcher -from bauh.gems.arch import pacman, sorting +from bauh.gems.arch import pacman, sorting, aur from bauh.gems.arch.aur import AURClient from bauh.gems.arch.dependencies import DependenciesAnalyser from bauh.gems.arch.exceptions import PackageNotFoundException @@ -25,7 +25,7 @@ class UpdateRequirementsContext: 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]], aur_index: Set[str], arch_config: dict, remote_provided_map: Dict[str, Set[str]], remote_repo_map: Dict[str, str], - root_password: str): + root_password: str, aur_supported: bool): self.to_update = to_update self.repo_to_update = repo_to_update self.aur_to_update = aur_to_update @@ -42,16 +42,18 @@ class UpdateRequirementsContext: self.arch_config = arch_config self.remote_provided_map = remote_provided_map self.remote_repo_map = remote_repo_map + self.aur_supported = aur_supported class UpdatesSummarizer: - def __init__(self, aur_client: AURClient, i18n: I18n, logger: logging.Logger, deps_analyser: DependenciesAnalyser, watcher: ProcessWatcher): + def __init__(self, aur_client: AURClient, i18n: I18n, logger: logging.Logger, deps_analyser: DependenciesAnalyser, aur_supported: bool, watcher: ProcessWatcher): self.aur_client = aur_client self.i18n = i18n self.logger = logger self.watcher = watcher self.deps_analyser = deps_analyser + self.aur_supported = aur_supported def _fill_aur_pkg_update_data(self, pkg: ArchPackage, output: dict): output[pkg.name] = self.aur_client.map_update_data(pkg.get_base_name(), pkg.latest_version) @@ -313,7 +315,7 @@ class UpdatesSummarizer: self.logger.info("Filling provided names took {0:.2f} seconds".format(tf - ti)) def __fill_aur_index(self, context: UpdateRequirementsContext): - if context.arch_config['aur']: + if context.aur_supported: self.logger.info("Loading AUR index") names = self.aur_client.read_index() @@ -372,7 +374,8 @@ class UpdatesSummarizer: aur_to_install={}, to_install={}, pkgs_data={}, cannot_upgrade={}, to_remove={}, installed_names=set(), provided_map={}, aur_index=set(), 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) self.__fill_aur_index(context) aur_data = {} diff --git a/bauh/gems/arch/worker.py b/bauh/gems/arch/worker.py index 3add3e3f..6a97c1df 100644 --- a/bauh/gems/arch/worker.py +++ b/bauh/gems/arch/worker.py @@ -88,7 +88,8 @@ class AURIndexUpdater(Thread): class ArchDiskCacheUpdater(Thread): - def __init__(self, task_man: TaskManager, arch_config: dict, i18n: I18n, logger: logging.Logger, controller: "ArchManager", internet_available: bool, aur_indexer: Thread): + def __init__(self, task_man: TaskManager, arch_config: dict, i18n: I18n, logger: logging.Logger, controller: "ArchManager", internet_available: bool, + aur_supported: bool, aur_indexer: Thread): super(ArchDiskCacheUpdater, self).__init__(daemon=True) self.logger = logger self.task_man = task_man @@ -99,7 +100,7 @@ class ArchDiskCacheUpdater(Thread): self.to_index = 0 self.progress = 0 # progress is defined by the number of packages prepared and indexed self.repositories = arch_config['repositories'] - self.aur = bool(arch_config['aur']) + self.aur = aur_supported self.controller = controller self.internet_available = internet_available self.installed_hash_path = '{}/installed.sha1'.format(ARCH_CACHE_PATH)