[gems.arch] enhancement: adding the AUR URL to the info dialog

This commit is contained in:
Vinicius Moreira
2023-11-25 08:26:49 -03:00
parent 4be25792fd
commit 54c2453597
11 changed files with 94 additions and 72 deletions

View File

@@ -6,6 +6,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
## NEXT
### Improvements
- Arch
- adding the AUR's URL on the package information dialog [#339](https://github.com/vinifmor/bauh/issues/339)
- General
- replaced the internet checking old host (`google.com`) by a more general one (`w3.org`) [#300](https://github.com/vinifmor/bauh/issues/300)
- parallelized installed packages reading

View File

@@ -11,7 +11,7 @@ from datetime import datetime
from pathlib import Path
from pwd import getpwnam
from threading import Thread
from typing import List, Set, Type, Tuple, Dict, Iterable, Optional, Collection, Generator
from typing import List, Set, Type, Tuple, Dict, Iterable, Optional, Collection, Generator, Any
from dateutil.parser import parse as parse_date
@@ -1551,84 +1551,95 @@ class ArchManager(SoftwareManager, SettingsController):
def get_managed_types(self) -> Set["type"]:
return {ArchPackage}
def _map_info_aur_installed(self, pkg: ArchPackage, pkgbuild_thread: Thread) -> Dict[str, Any]:
info = pacman.get_info_dict(pkg.name)
if info is not None:
self._parse_dates_string_from_info(pkg.name, info)
info['04_orphan'] = pkg.orphan
info['04_out_of_date'] = pkg.out_of_date
if pkg.commit:
info['commit'] = pkg.commit
if pkg.last_modified:
err_msg = f"Could not parse AUR package '{pkg.name}' 'last_modified' field ({pkg.last_modified})"
info['last_modified'] = self._parse_timestamp(ts=pkg.last_modified, error_msg=err_msg)
info['14_installed_files'] = pacman.list_installed_files(pkg.name)
pkgbuild_thread.join()
if pkg.pkgbuild:
info['13_pkg_build'] = pkg.pkgbuild
return info
def _map_info_aur_uninstalled(self, pkg: ArchPackage, pkgbuild_thread: Thread) -> Dict[str, Any]:
info = {
'01_id': pkg.id,
'02_name': pkg.name,
'03_description': pkg.description,
'03_version': pkg.version,
'04_orphan': pkg.orphan,
'04_out_of_date': pkg.out_of_date,
'04_popularity': pkg.popularity,
'05_votes': pkg.votes,
'06_package_base': pkg.package_base,
'07_maintainer': pkg.maintainer,
'10_url': pkg.url_download
}
if pkg.first_submitted:
info['08_first_submitted'] = self._parse_timestamp(ts=pkg.first_submitted,
error_msg="Could not parse AUR package '{}' 'first_submitted' field ({})".format(
pkg.name, pkg.first_submitted))
if pkg.last_modified:
info['09_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))
srcinfo = self.aur_client.get_src_info(pkg.name)
if srcinfo:
arch_str = 'x86_64' if self.context.is_system_x86_64() else 'i686'
for info_attr, src_attr in {'12_makedepends': 'makedepends',
'13_dependson': 'depends',
'14_optdepends': 'optdepends',
'checkdepends': '15_checkdepends'}.items():
if srcinfo.get(src_attr):
info[info_attr] = [*srcinfo[src_attr]]
arch_attr = f"{src_attr}_{arch_str}"
if srcinfo.get(arch_attr):
if not info.get(info_attr):
info[info_attr] = [*srcinfo[arch_attr]]
else:
info[info_attr].extend(srcinfo[arch_attr])
pkgbuild_thread.join()
if pkg.pkgbuild:
info['00_pkg_build'] = pkg.pkgbuild
else:
info['11_pkg_build_url'] = pkg.get_pkg_build_url()
return info
def _get_info_aur_pkg(self, pkg: ArchPackage) -> dict:
fill_pkgbuild = Thread(target=self.aur_mapper.fill_package_build, args=(pkg,), daemon=True)
fill_pkgbuild.start()
if pkg.installed:
info = pacman.get_info_dict(pkg.name)
if info is not None:
self._parse_dates_string_from_info(pkg.name, info)
info['04_orphan'] = pkg.orphan
info['04_out_of_date'] = pkg.out_of_date
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))
info['14_installed_files'] = pacman.list_installed_files(pkg.name)
fill_pkgbuild.join()
if pkg.pkgbuild:
info['13_pkg_build'] = pkg.pkgbuild
return info
info = self._map_info_aur_installed(pkg, fill_pkgbuild)
else:
info = {
'01_id': pkg.id,
'02_name': pkg.name,
'03_description': pkg.description,
'03_version': pkg.version,
'04_orphan': pkg.orphan,
'04_out_of_date': pkg.out_of_date,
'04_popularity': pkg.popularity,
'05_votes': pkg.votes,
'06_package_base': pkg.package_base,
'07_maintainer': pkg.maintainer,
'10_url': pkg.url_download
}
info = self._map_info_aur_uninstalled(pkg, fill_pkgbuild)
if pkg.first_submitted:
info['08_first_submitted'] = self._parse_timestamp(ts=pkg.first_submitted,
error_msg="Could not parse AUR package '{}' 'first_submitted' field ({})".format(pkg.name, pkg.first_submitted))
if pkg.last_modified:
info['09_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))
srcinfo = self.aur_client.get_src_info(pkg.name)
if srcinfo:
arch_str = 'x86_64' if self.context.is_system_x86_64() else 'i686'
for info_attr, src_attr in {'12_makedepends': 'makedepends',
'13_dependson': 'depends',
'14_optdepends': 'optdepends',
'checkdepends': '15_checkdepends'}.items():
if srcinfo.get(src_attr):
info[info_attr] = [*srcinfo[src_attr]]
arch_attr = '{}_{}'.format(src_attr, arch_str)
if srcinfo.get(arch_attr):
if not info.get(info_attr):
info[info_attr] = [*srcinfo[arch_attr]]
else:
info[info_attr].extend(srcinfo[arch_attr])
fill_pkgbuild.join()
if pkg.pkgbuild:
info['00_pkg_build'] = pkg.pkgbuild
else:
info['11_pkg_build_url'] = pkg.get_pkg_build_url()
return info
info["00_url"] = f"https://aur.archlinux.org/packages/{pkg.get_base_name()}"
return info
def _parse_dates_string_from_info(self, pkgname: str, info: dict):
for date_attr in ('install date', 'build date'):

View File

@@ -143,6 +143,7 @@ arch.downgrade.version_found=Sha trobat la versió actual del paquet
arch.aur.error.missing_root_dep={dep} is not installed and is required for installing {aur} packages as the {root} user
arch.aur.error.add_builder_user=It was not possible to create the user {user} for building {aur} packages
arch.info.00_pkg_build=PKGBUILD
arch.info.00_url=URL
arch.info.01_id=identificació
arch.info.02_name=nom
arch.info.03_description=descripció

View File

@@ -143,6 +143,7 @@ arch.downgrade.version_found=Aktuelle Paketversion gefunden
arch.aur.error.missing_root_dep={dep} ist nicht installiert und wird für die Installation von {aur} Paketen als {root} Benutzer benötigt
arch.aur.error.add_builder_user=Es war nicht möglich, den Benutzer {user} für die Erzeugung von {aur}-Paketen zu erstellen
arch.info.00_pkg_build=pkgbuild
arch.info.00_url=URL
arch.info.01_id=ID
arch.info.02_name=Name
arch.info.03_description=Beschreibung

View File

@@ -143,6 +143,7 @@ arch.downgrade.version_found=Current package version found
arch.aur.error.missing_root_dep={dep} is not installed and is required for installing {aur} packages as the {root} user
arch.aur.error.add_builder_user=It was not possible to create the user {user} for building {aur} packages
arch.info.00_pkg_build=pkgbuild
arch.info.00_url=URL
arch.info.01_id=id
arch.info.02_name=name
arch.info.03_description=description

View File

@@ -143,6 +143,7 @@ arch.downgrade.version_found=Version actual del paquete encontrada
arch.aur.error.missing_root_dep={dep} no está instalado y es necesario para la instalación de paquetes del {aur} como el usuario {root}
arch.aur.error.add_builder_user=No fue posible crear el usuario {user} para construir paquetes del {aur}
arch.info.00_pkg_build=pkgbuild
arch.info.00_url=URL
arch.info.01_id=id
arch.info.02_name=nombre
arch.info.03_description=descripción

View File

@@ -143,6 +143,7 @@ arch.downgrade.version_found=Version actuelle du paquet trouvée
arch.aur.error.missing_root_dep={dep} is not installed and is required for installing {aur} packages as the {root} user
arch.aur.error.add_builder_user=It was not possible to create the user {user} for building {aur} packages
arch.info.00_pkg_build=pkgbuild
arch.info.00_url=URL
arch.info.01_id=id
arch.info.02_name=nom
arch.info.03_description=description

View File

@@ -143,6 +143,7 @@ arch.downgrade.version_found=Trovata la versione del pacchetto corrente
arch.aur.error.missing_root_dep={dep} is not installed and is required for installing {aur} packages as the {root} user
arch.aur.error.add_builder_user=It was not possible to create the user {user} for building {aur} packages
arch.info.00_pkg_build=pkgbuild
arch.info.00_url=URL
arch.info.01_id=id
arch.info.02_name=nome
arch.info.03_description=descrizione

View File

@@ -142,6 +142,7 @@ arch.downgrade.version_found=Versão atual do pacote encontrada
arch.aur.error.missing_root_dep={dep} não está instalado e é necessário para a instalação de pacotes do {aur} como o usuário {root}
arch.aur.error.add_builder_user=Não foi possível criar o usuário {user} para a construção de pacotes do {aur}
arch.info.00_pkg_build=pkgbuild
arch.info.00_url=URL
arch.info.01_id=id
arch.info.02_name=nome
arch.info.03_description=descrição

View File

@@ -143,6 +143,7 @@ arch.downgrade.version_found=Найдена текущая версия паке
arch.aur.error.missing_root_dep={dep} не установлен и необходим для установки пакетов {aur} от имени пользователя {root}
arch.aur.error.add_builder_user=Не удалось создать пользователя {user} для сборки пакетов {aur}.
arch.info.00_pkg_build=PKGBUILD
arch.info.00_url=URL
arch.info.01_id=Идентификатор
arch.info.02_name=Имя
arch.info.03_description=Описание

View File

@@ -143,6 +143,7 @@ arch.downgrade.version_found=Geçerli paket sürümü bulundu
arch.aur.error.missing_root_dep={dep} is not installed and is required for installing {aur} packages as the {root} user
arch.aur.error.add_builder_user=It was not possible to create the user {user} for building {aur} packages
arch.info.00_pkg_build=pkgbuild
arch.info.00_url=URL
arch.info.01_id=kimlik
arch.info.02_name=isim
arch.info.03_description=açıklama