This commit is contained in:
Vinícius Moreira
2022-02-11 16:02:36 -03:00
committed by GitHub
11 changed files with 248 additions and 143 deletions

7
.gitignore vendored
View File

@@ -8,3 +8,10 @@ dist
*.egg-info
build
*.db
linux_dist/appimage/AppDir
linux_dist/appimage/appimage-builder-cache
linux_dist/appimage/*.zsync
linux_dist/appimage/*.AppImage
linux_dist/appimage/*.gz
linux_dist/appimage/bauh-*

View File

@@ -4,6 +4,31 @@ 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.27] 2022-02-11
### Improvements
- Arch:
- preventing AUR's installed packages from not being mapped in cases the communication with the API fails
- code refactoring (String formatting method)
- Setup
- able to install bauh with python/pip without enforcing requirements through the environment variable `BAUH_SETUP_NO_REQS=1`
- Distribution
- AppImage: -~32% size reduction (141.93 MB -> 96.32 MB)
### Fixes
- Arch
- silent crash when handling and displaying transaction sub-status
- AUR: not detecting installed packages anymore due to recent AUR API changes
- installation fails when several dependent packages conflict with the installed ones
- removing a duplicate call to checking for AUR updates
- AppImage
- search: displaying duplicate installed apps for some cases
## [0.9.26] 2022-01-31
### Improvements

View File

@@ -17,7 +17,7 @@ Key features
## Index
1. [Installation](#installation)
- [AppImage](#inst_appimage)
- [Ubuntu-based distros (20.04)](#inst_ubuntu)
- [Ubuntu 20.04 based distros (Linux Mint, PopOS, ...)](#inst_ubuntu)
- [Arch-based distros](#inst_arch)
2. [Isolated installation](#inst_iso)
3. [Desktop entry / menu shortcut](#desk_entry)
@@ -56,7 +56,7 @@ Key features
- Run the following command through a terminal: `chmod a+x bauh-${version}-x86_64.AppImage` (replace `${version}` by the respective downloaded version)
- Launch it: `./bauh-${version}-x86_64.AppImage`
#### <a name="inst_ubuntu">Ubuntu-based distros (20.04)</a>
#### <a name="inst_ubuntu">Ubuntu 20.04 based distros (Linux Mint, PopOS, ...)</a>
##### Required dependencies
@@ -66,6 +66,7 @@ Key features
`sudo pip3 install bauh`
##### Optional dependencies (they should be installed with apt-get/apt)
- `timeshift`: system backup

View File

@@ -1,4 +1,4 @@
__version__ = '0.9.26'
__version__ = '0.9.27'
__app_name__ = 'bauh'
import os

View File

@@ -227,7 +227,7 @@ class AppImageManager(SoftwareManager):
installed_found.append(appim)
found = True
if not found and lower_words in appim.name.lower() or (appim.description and lower_words in appim.description.lower()):
if not found and (lower_words in appim.name.lower() or (appim.description and lower_words in appim.description.lower())):
installed_found.append(appim)
try:
apps_conn.close()

View File

@@ -112,12 +112,30 @@ class AURClient:
def search(self, words: str) -> dict:
return self.http_client.get_json(URL_SEARCH + words)
def get_info(self, names: Iterable[str]) -> List[dict]:
def get_info(self, names: Iterable[str]) -> Optional[List[dict]]:
if names:
try:
res = self.http_client.get_json(URL_INFO + self._map_names_as_queries(names))
return res['results'] if res and res.get('results') else []
except:
return []
except requests.exceptions.ConnectionError:
self.logger.warning('Could not retrieve installed AUR packages API data. It seems the internet connection is off.')
return
if res is None:
self.logger.warning("Call to AUR API's info endpoint has failed")
return
error = res.get('error')
if error:
self.logger.warning(f"AUR API's info endpoint returned an unexpected error: {error}")
return
results = res.get('results')
if results is not None:
return results
self.logger.warning(f"AUR API's info endpoint returned an unexpected response: {res}")
def map_provided(self, pkgname: str, pkgver: str, provided: Optional[Iterable[str]] = None, strip_epoch: bool = True) -> Set[str]:
all_provided = {pkgname, f"{pkgname}={pkgver.split('-')[0] if strip_epoch else pkgver}"}
@@ -130,7 +148,10 @@ class AURClient:
return all_provided
def gen_updates_data(self, names: Iterable[str]) -> Generator[Tuple[str, dict], None, None]:
for package in self.get_info(names):
pkgs_info = self.get_info(names)
if pkgs_info:
for package in pkgs_info:
pkgname, pkgver = package['Name'], package['Version'].split('-')[0]
deps = set()
@@ -175,7 +196,7 @@ class AURClient:
self.logger.warning('No .SRCINFO found for {}'.format(name))
self.logger.info('Checking if {} is based on another package'.format(name))
# if was not found, it may be based on another package.
infos = self.get_info({name})
infos = self.get_info((name,))
if infos:
info = infos[0]
@@ -214,8 +235,8 @@ class AURClient:
return self.extract_required_dependencies(info)
def _map_names_as_queries(self, names) -> str:
return '&'.join(['arg[{}]={}'.format(i, urllib.parse.quote(n)) for i, n in enumerate(names)])
def _map_names_as_queries(self, names: Iterable[str]) -> str:
return '&'.join((f'arg[]={urllib.parse.quote(n)}' for n in names))
def read_local_index(self) -> dict:
self.logger.info('Checking if the cached AUR index file exists')

View File

@@ -14,7 +14,6 @@ from pwd import getpwnam
from threading import Thread
from typing import List, Set, Type, Tuple, Dict, Iterable, Optional, Collection, Generator
import requests
from dateutil.parser import parse as parse_date
from bauh import __app_name__
@@ -412,18 +411,39 @@ class ArchManager(SoftwareManager):
res.update_total()
return res
def _fill_aur_pkgs(self, aur_pkgs: dict, output: List[ArchPackage], disk_loader: DiskCacheLoader, internet_available: bool,
def _fill_aur_pkgs_offline(self, aur_pkgs: dict, arch_config: dict, output: List[ArchPackage], disk_loader: Optional[DiskCacheLoader]):
self.logger.info("Reading cached data from installed AUR packages")
editable_pkgbuilds = self._read_editable_pkgbuilds() if arch_config['edit_aur_pkgbuild'] is not False else None
for name, data in aur_pkgs.items():
pkg = ArchPackage(name=name, version=data.get('version'),
latest_version=data.get('version'), description=data.get('description'),
installed=True, repository='aur', i18n=self.i18n)
pkg.categories = self.categories.get(pkg.name)
pkg.pkgbuild_editable = pkg.name in editable_pkgbuilds if editable_pkgbuilds is not None else None
if disk_loader:
disk_loader.fill(pkg)
pkg.status = PackageStatus.READY
output.append(pkg)
def _fill_aur_pkgs(self, aur_pkgs: dict, output: List[ArchPackage], disk_loader: Optional[DiskCacheLoader], internet_available: bool,
arch_config: dict, rebuild_check: Optional[Thread], rebuild_ignored: Optional[Thread], rebuild_output: Optional[Dict[str, Set[str]]]):
if internet_available:
try:
pkgsinfo = self.aur_client.get_info(aur_pkgs.keys())
except requests.exceptions.ConnectionError:
self.logger.warning('Could not retrieve installed AUR packages API data. It seems the internet connection is off.')
self.logger.info("Reading only local AUR packages data")
if not internet_available:
self._fill_aur_pkgs_offline(aur_pkgs=aur_pkgs, arch_config=arch_config,
output=output, disk_loader=disk_loader)
return
if pkgsinfo:
pkgsinfo = self.aur_client.get_info(aur_pkgs.keys())
if pkgsinfo is None:
self._fill_aur_pkgs_offline(aur_pkgs=aur_pkgs, arch_config=arch_config, output=output, disk_loader=disk_loader)
elif not pkgsinfo:
self.logger.warning("No data found for the supposed installed AUR packages returned from AUR API's info endpoint")
else:
editable_pkgbuilds = self._read_editable_pkgbuilds() if arch_config['edit_aur_pkgbuild'] is not False else None
ignore_rebuild_check = None
@@ -461,22 +481,6 @@ class ArchManager(SoftwareManager):
pkg.status = PackageStatus.READY
output.append(pkg)
else:
editable_pkgbuilds = self._read_editable_pkgbuilds() if arch_config['edit_aur_pkgbuild'] is not False else None
for name, data in aur_pkgs.items():
pkg = ArchPackage(name=name, version=data.get('version'),
latest_version=data.get('version'), description=data.get('description'),
installed=True, repository='aur', i18n=self.i18n)
pkg.categories = self.categories.get(pkg.name)
pkg.pkgbuild_editable = pkg.name in editable_pkgbuilds if editable_pkgbuilds is not None else None
if disk_loader:
disk_loader.fill(pkg)
pkg.status = PackageStatus.READY
output.append(pkg)
def _check_aur_package_update(self, pkg: ArchPackage, installed_data: dict, api_data: dict) -> bool:
if pkg.last_modified is None: # if last_modified is not available, then the install_date will be used instead
install_date = installed_data.get('install_date')
@@ -1322,9 +1326,13 @@ class ArchManager(SoftwareManager):
else:
instances = None
provided_by_uninstalled = pacman.map_provided(pkgs=to_uninstall)
uninstalled = self._uninstall_pkgs(to_uninstall, context.root_password, context.handler, ignore_dependencies=skip_requirements)
if uninstalled:
self._remove_uninstalled_from_context(provided_by_uninstalled, context)
if disk_loader: # loading package instances in case the uninstall succeeds
if instances:
for p in instances:
@@ -1395,6 +1403,22 @@ class ArchManager(SoftwareManager):
self._update_progress(context, 100)
return uninstalled
def _remove_uninstalled_from_context(self, provided_by_uninstalled: Dict[str, Set[str]], context: TransactionContext):
if context.provided_map and provided_by_uninstalled: # updating the current provided context
for name, provided in provided_by_uninstalled.items():
if name in context.provided_map:
del context.provided_map[name]
if provided:
for exp in provided:
exp_provided = context.provided_map.get(exp)
if exp_provided and name in exp_provided:
exp_provided.remove(name)
if not exp_provided:
del context.provided_map[exp]
def uninstall(self, pkg: ArchPackage, root_password: str, watcher: ProcessWatcher, disk_loader: DiskCacheLoader) -> TransactionResult:
self.aur_client.clean_caches()
@@ -1703,6 +1727,8 @@ class ArchManager(SoftwareManager):
res = self._uninstall(context=context, names={conflicting_pkg}, disk_loader=context.disk_loader,
remove_unneeded=False, skip_requirements=skip_requirements)
context.restabilish_progress()
return res
@@ -1789,7 +1815,11 @@ class ArchManager(SoftwareManager):
if len(pkgnames) != len(pkg_repos): # checking if any dep not found in the distro repos are from AUR
norepos = {p for p in pkgnames if p not in pkg_repos}
for pkginfo in self.aur_client.get_info(norepos):
aur_info = self.aur_client.get_info(norepos)
if aur_info:
for pkginfo in aur_info:
if pkginfo.get('Name') in norepos:
pkg_repos[pkginfo['Name']] = 'aur'
@@ -2384,7 +2414,7 @@ class ArchManager(SoftwareManager):
if context.pkg and context.pkg.maintainer:
pkg_maintainer = context.pkg.maintainer
elif context.repository == 'aur':
aur_infos = self.aur_client.get_info({context.name})
aur_infos = self.aur_client.get_info((context.name,))
pkg_maintainer = aur_infos[0].get('Maintainer') if aur_infos else None
else:
pkg_maintainer = context.repository
@@ -3482,7 +3512,7 @@ class ArchManager(SoftwareManager):
self.aur_client.clean_caches()
apidatas = self.aur_client.get_info({pkg.name})
apidatas = self.aur_client.get_info((pkg.name,))
if not apidatas:
watcher.show_message(title=self.i18n['error'],

View File

@@ -264,6 +264,9 @@ class DependenciesAnalyser:
aur_search = self.aur_client.search(dep_name)
if aur_search:
aur_results = aur_search.get('results')
if aur_results:
if dep_name == dep_exp:
version_required, exp_op = None, None
else:
@@ -271,8 +274,7 @@ class DependenciesAnalyser:
version_required = split_informed_dep[2]
exp_op = split_informed_dep[1] if split_informed_dep[1] != '=' else '=='
for pkgname, pkgdata in self.aur_client.gen_updates_data(
(aur_res['Name'] for aur_res in aur_search['results'])):
for pkgname, pkgdata in self.aur_client.gen_updates_data((aur_res['Name'] for aur_res in aur_results)):
if pkgname == dep_name or (dep_name in pkgdata['p']):
try:
if not version_required or match_required_version(pkgdata['v'], exp_op,
@@ -382,6 +384,7 @@ class DependenciesAnalyser:
raise PackageNotFoundException(dep_exp)
def _fill_aur_updates_data(self, pkgnames: Iterable[str], output_data: dict):
if pkgnames:
for pkgname, pkgdata in self.aur_client.gen_updates_data(pkgnames):
output_data[pkgname] = pkgdata
@@ -516,9 +519,6 @@ class DependenciesAnalyser:
if repo_providers_data:
deps_data.update(repo_providers_data)
for pkgname, pkgdata in self.aur_client.gen_updates_data(aur_providers_no_data):
deps_data[pkgname] = pkgdata
if aur_data_filler:
aur_data_filler.join()

View File

@@ -37,7 +37,7 @@ class TransactionStatusHandler(Thread):
def gen_percentage(self) -> str:
if self.percentage:
performed = self.downloading + self.upgrading + self.installing
return '({0:.2f}%) '.format((performed / (2 * self.pkgs_to_sync)) * 100)
return f'({(performed / (2 * self.pkgs_to_sync)) * 100:.2f}%) '
else:
return ''
@@ -52,18 +52,19 @@ class TransactionStatusHandler(Thread):
if self.pkgs_to_remove > 0:
self.removing += 1
self.watcher.change_substatus('[{}/{}] {} {}'.format(self.removing, self.pkgs_to_remove,
self.i18n['uninstalling'].capitalize(), output.split(' ')[1].strip()))
self.watcher.change_substatus(f"[{self.removing}/{self.pkgs_to_remove}] "
f"{self.i18n['uninstalling'].capitalize()} {output.split(' ')[1].strip()}")
else:
self.watcher.change_substatus('{} {}'.format(self.i18n['uninstalling'].capitalize(), output_split[1].strip()))
self.watcher.change_substatus(f"{self.i18n['uninstalling'].capitalize()} {output_split[1].strip()}")
elif output_split[1].lower().startswith('downloading') and (not self.names or (n for n in self.names if output_split[0].startswith(n))):
elif len(output_split) >= 2 and output_split[1].lower().startswith('downloading') and (not self.names or (n for n in self.names if output_split[0].startswith(n))):
if self.downloading < self.pkgs_to_sync:
perc = self.gen_percentage()
self.downloading += 1
self.watcher.change_substatus('{}[{}/{}] {} {} {}'.format(perc, self.downloading, self.pkgs_to_sync, bold('[pacman]'),
self.i18n['downloading'].capitalize(), output_split[0].strip()))
self.watcher.change_substatus(f"{perc}[{self.downloading}/{self.pkgs_to_sync}] {bold('[pacman]')} "
f"{self.i18n['downloading'].capitalize()} {output_split[0].strip()}")
elif output_split[0].lower() == 'upgrading' and (not self.names or output_split[1].split('.')[0] in self.names):
if self.get_performed() < self.pkgs_to_sync:
perc = self.gen_percentage()
@@ -72,8 +73,9 @@ class TransactionStatusHandler(Thread):
performed = self.upgrading + self.installing
if performed <= self.pkgs_to_sync:
self.watcher.change_substatus('{}[{}/{}] {} {}'.format(perc, performed, self.pkgs_to_sync,
self.i18n['manage_window.status.upgrading'].capitalize(), output_split[1].strip()))
self.watcher.change_substatus(f"{perc}[{performed}/{self.pkgs_to_sync}] "
f"{self.i18n['manage_window.status.upgrading'].capitalize()} {output_split[1].strip()}")
elif output_split[0].lower() == 'installing' and (not self.names or output_split[1].split('.')[0] in self.names):
if self.get_performed() < self.pkgs_to_sync:
perc = self.gen_percentage()
@@ -82,15 +84,14 @@ class TransactionStatusHandler(Thread):
performed = self.upgrading + self.installing
if performed <= self.pkgs_to_sync:
self.watcher.change_substatus('{}[{}/{}] {} {}'.format(perc, performed, self.pkgs_to_sync,
self.i18n['manage_window.status.installing'].capitalize(),
output_split[1].strip()))
self.watcher.change_substatus(f"{perc}[{performed}/{self.pkgs_to_sync}] "
f"{self.i18n['manage_window.status.installing'].capitalize()} {output_split[1].strip()}")
else:
substatus_found = False
lower_output = output.lower().strip()
for msg, key in self.accepted.items():
if lower_output.startswith(msg):
self.watcher.change_substatus(self.i18n['arch.substatus.{}'.format(key)].capitalize())
self.watcher.change_substatus(self.i18n[f'arch.substatus.{key}'].capitalize())
substatus_found = True
break

View File

@@ -2,6 +2,14 @@ version: 1
script:
- rm -rf AppDir appimage-builder-cache *.AppImage *.zsync |true
- mkdir -p AppDir/usr
- mkdir -p AppDir/usr/share/icons/hicolor/scalable/apps
- mkdir -p AppDir/usr/share/applications
- wget https://github.com/vinifmor/bauh/archive/${BAUH_VERSION}.tar.gz || exit 1
- BAUH_SETUP_NO_REQS=1 pip3 install ${BAUH_VERSION}.tar.gz --prefix=/usr --root=AppDir || exit 1
- tar -xf ${BAUH_VERSION}.tar.gz || exit 1
- cd bauh-${BAUH_VERSION} || exit 1
- cp bauh/view/resources/img/logo.svg ../AppDir/usr/share/icons/hicolor/scalable/apps/bauh.svg || exit 1
- cp bauh/desktop/bauh.desktop ../AppDir/usr/share/applications || exit 1
AppDir:
@@ -24,31 +32,40 @@ AppDir:
include:
- python3
- python3-pip
- python3-setuptools
- python3-wheel
- python3-requests
- python3-colorama
- python3-dateutil
- python3-yaml
- python3-packaging
- python3-pyqt5
- python3-lxml
- python3-bs4
- sqlite3
- axel
- aria2
- wget
- libfreetype6
- libfontconfig1
exclude: []
# - libfreetype6
# - libfontconfig1
exclude:
- dpkg
- apt
- aptitude
- python3-pip
- python3-setuptools
- python3-distutils
- libc-bin
- libc-dev-bin
- libc6
- libc6-dbg
- libc6-dev
after_bundle:
- pip3 install bauh==$BAUH_VERSION --prefix=/usr --root=AppDir
- mkdir -p AppDir/usr/share/icons/hicolor/scalable/apps
- cp AppDir/usr/lib/python3.8/site-packages/bauh/view/resources/img/logo.svg AppDir/usr/share/icons/hicolor/scalable/apps/bauh.svg
- mkdir -p AppDir/usr/share/applications
- cp AppDir/usr/lib/python3.8/site-packages/bauh/desktop/bauh.desktop AppDir/usr/share/applications
- pip3 install pyqt5 --prefix=/usr --root=AppDir || exit 1
- cd AppDir/usr/lib/python3.8/site-packages/PyQt5/Qt5/plugins || exit 1
- rm -rf audio gamepad gamepads geoservices printsupport sceneparsers sensorgestures sensors sqldrivers texttospeech webview || exit 1
- cd ../
- cd lib/ || exit 1
- rm libQt5Bluetooth.so.5 libQt5Designer.so.5 libQt5Multimedia.so.5 libQt5MultimediaGstTools.so.5 libQt5MultimediaWidgets.so.5 || exit 1
- rm libQt5Quick3D.so.5 libQt5Quick3DAssetImport.so.5 libQt5Quick3DRender.so.5 libQt5Quick3DRuntimeRender.so.5 libQt5QuickTest.so.5 || exit 1
- rm libQt5Quick3DUtils.so.5 libQt5PrintSupport.so.5 libQt5SerialPort.so.5 libQt5Sql.so.5 libQt5Sensors.so.5 libQt5Test.so.5 libQt5WebView.so.5 || exit 1
runtime:
version: "continuous"

View File

@@ -14,7 +14,10 @@ URL = "https://github.com/vinifmor/" + NAME
file_dir = os.path.dirname(os.path.abspath(__file__))
with open(file_dir + '/requirements.txt', 'r') as f:
if os.getenv('BAUH_SETUP_NO_REQS'):
requirements = []
else:
with open(f'{file_dir}/requirements.txt', 'r') as f:
requirements = [line.strip() for line in f.readlines() if line]