mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-07 01:14:15 +02:00
[improvement][aur] synchronizing the package databases once a day
This commit is contained in:
@@ -14,6 +14,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|||||||
- AUR:
|
- AUR:
|
||||||
- downgrading time reduced due to the fix described in ***Fixes***
|
- downgrading time reduced due to the fix described in ***Fixes***
|
||||||
- the custom **makepkg.conf** generated at **~/.config/bauh/arch** will enable **ccache** if available on the system
|
- the custom **makepkg.conf** generated at **~/.config/bauh/arch** will enable **ccache** if available on the system
|
||||||
|
- package databases synchronization once a day ( or every device reboot ) before the first package installation / upgrade / downgrade. This behavior can be disabled on **~/.config/arch.yml** / or the new settings panel:
|
||||||
|
```
|
||||||
|
sync_databases: true # enabled by default
|
||||||
|
```
|
||||||
- Configuration ( **~/.config/bauh/config.yml** )
|
- Configuration ( **~/.config/bauh/config.yml** )
|
||||||
- new property **hdpi** allowing to disable HDPI improvements
|
- new property **hdpi** allowing to disable HDPI improvements
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -163,6 +163,7 @@ db_updater:
|
|||||||
```
|
```
|
||||||
optimize: true # if 'false': disables the auto-compilation improvements
|
optimize: true # if 'false': disables the auto-compilation improvements
|
||||||
transitive_checking: true # if 'false': the dependency checking process will be faster, but the application will ask for a confirmation every time a not installed dependency is detected.
|
transitive_checking: true # if 'false': the dependency checking process will be faster, but the application will ask for a confirmation every time a not installed dependency is detected.
|
||||||
|
sync_databases: true # package databases synchronization once a day ( or every device reboot ) before the first package installation / upgrade / downgrade
|
||||||
```
|
```
|
||||||
- Required dependencies:
|
- Required dependencies:
|
||||||
- **pacman**
|
- **pacman**
|
||||||
@@ -242,7 +243,8 @@ ui:
|
|||||||
tray: # system tray settings
|
tray: # system tray settings
|
||||||
default_icon: null # defines a path to a custom icon
|
default_icon: null # defines a path to a custom icon
|
||||||
updates_icon: null # defines a path to a custom icon indicating updates
|
updates_icon: null # defines a path to a custom icon indicating updates
|
||||||
hdpi: true # enables HDPI rendering improvements. Use 'false' to disable them if you think the interface looks strange.
|
hdpi: true # enables HDPI rendering improvements. Use 'false' to disable them if you think the interface looks strange.
|
||||||
|
auto_scale: false # activates Qt auto screen scale factor (QT_AUTO_SCREEN_SCALE_FACTOR). It fixes scaling issues for some desktop environments ( like Gnome )
|
||||||
updates:
|
updates:
|
||||||
check_interval: 30 # the updates checking interval in SECONDS
|
check_interval: 30 # the updates checking interval in SECONDS
|
||||||
|
|
||||||
|
|||||||
@@ -3,5 +3,5 @@ from bauh.gems.arch import CONFIG_FILE
|
|||||||
|
|
||||||
|
|
||||||
def read_config(update_file: bool = False) -> dict:
|
def read_config(update_file: bool = False) -> dict:
|
||||||
template = {'optimize': True, 'transitive_checking': True}
|
template = {'optimize': True, 'transitive_checking': True, "sync_databases": True}
|
||||||
return read(CONFIG_FILE, template, update_file=update_file)
|
return read(CONFIG_FILE, template, update_file=update_file)
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import shutil
|
|||||||
import subprocess
|
import subprocess
|
||||||
import time
|
import time
|
||||||
import traceback
|
import traceback
|
||||||
|
from datetime import datetime
|
||||||
from math import floor
|
from math import floor
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
@@ -193,6 +194,9 @@ class ArchManager(SoftwareManager):
|
|||||||
|
|
||||||
handler = ProcessHandler(watcher)
|
handler = ProcessHandler(watcher)
|
||||||
app_build_dir = '{}/build_{}'.format(BUILD_DIR, int(time.time()))
|
app_build_dir = '{}/build_{}'.format(BUILD_DIR, int(time.time()))
|
||||||
|
|
||||||
|
self._sync_databases(root_password=root_password, handler=handler)
|
||||||
|
|
||||||
watcher.change_progress(5)
|
watcher.change_progress(5)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -769,6 +773,52 @@ class ArchManager(SoftwareManager):
|
|||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def _sync_databases(self, root_password: str, handler: ProcessHandler):
|
||||||
|
sync_path = '/tmp/bauh/arch/sync'
|
||||||
|
|
||||||
|
if self.local_config['sync_databases']:
|
||||||
|
if os.path.exists(sync_path):
|
||||||
|
with open(sync_path) as f:
|
||||||
|
sync_file = f.read()
|
||||||
|
|
||||||
|
try:
|
||||||
|
sync_time = datetime.fromtimestamp(int(sync_file))
|
||||||
|
now = datetime.now()
|
||||||
|
|
||||||
|
if (now - sync_time).days > 0:
|
||||||
|
self.logger.info("Package databases synchronization out of date")
|
||||||
|
else:
|
||||||
|
msg = "Package databases already synchronized"
|
||||||
|
self.logger.info(msg)
|
||||||
|
handler.watcher.print(msg)
|
||||||
|
return
|
||||||
|
except:
|
||||||
|
self.logger.warning("Could not convert the database synchronization time from '{}".format(sync_path))
|
||||||
|
traceback.print_exc()
|
||||||
|
|
||||||
|
handler.watcher.change_substatus(self.i18n['arch.sync_databases.substatus'])
|
||||||
|
synced, output = handler.handle_simple(pacman.sync_databases(root_password=root_password,
|
||||||
|
force=True))
|
||||||
|
if synced:
|
||||||
|
try:
|
||||||
|
Path('/tmp/bauh/arch').mkdir(parents=True, exist_ok=True)
|
||||||
|
with open('/tmp/bauh/arch/sync', 'w+') as f:
|
||||||
|
f.write(str(int(time.time())))
|
||||||
|
except:
|
||||||
|
traceback.print_exc()
|
||||||
|
else:
|
||||||
|
self.logger.warning("It was not possible to synchronized the package databases")
|
||||||
|
handler.watcher.change_substatus(self.i18n['arch.sync_databases.substatus.error'])
|
||||||
|
else:
|
||||||
|
msg = "Package databases synchronization disabled"
|
||||||
|
handler.watcher.print(msg)
|
||||||
|
self.logger.info(msg)
|
||||||
|
|
||||||
|
def _optimize_makepkg(self, watcher: ProcessWatcher):
|
||||||
|
if self.local_config['optimize'] and not os.path.exists(CUSTOM_MAKEPKG_FILE):
|
||||||
|
watcher.change_substatus(self.i18n['arch.makepkg.optimizing'])
|
||||||
|
ArchCompilationOptimizer(self.context.logger).optimize()
|
||||||
|
|
||||||
def install(self, pkg: ArchPackage, root_password: str, watcher: ProcessWatcher, skip_optdeps: bool = False) -> bool:
|
def install(self, pkg: ArchPackage, root_password: str, watcher: ProcessWatcher, skip_optdeps: bool = False) -> bool:
|
||||||
clean_config = False
|
clean_config = False
|
||||||
|
|
||||||
@@ -776,11 +826,12 @@ class ArchManager(SoftwareManager):
|
|||||||
self.local_config = read_config()
|
self.local_config = read_config()
|
||||||
clean_config = True
|
clean_config = True
|
||||||
|
|
||||||
if self.local_config['optimize'] and not os.path.exists(CUSTOM_MAKEPKG_FILE):
|
handler = ProcessHandler(watcher)
|
||||||
watcher.change_substatus(self.i18n['arch.makepkg.optimizing'])
|
|
||||||
ArchCompilationOptimizer(self.context.logger).optimize()
|
|
||||||
|
|
||||||
res = self._install_from_aur(pkg.name, pkg.package_base, pkg.maintainer, root_password, ProcessHandler(watcher), dependency=False, skip_optdeps=skip_optdeps)
|
self._sync_databases(root_password=root_password, handler=handler)
|
||||||
|
self._optimize_makepkg(watcher=watcher)
|
||||||
|
|
||||||
|
res = self._install_from_aur(pkg.name, pkg.package_base, pkg.maintainer, root_password, handler, dependency=False, skip_optdeps=skip_optdeps)
|
||||||
|
|
||||||
if res:
|
if res:
|
||||||
if os.path.exists(pkg.get_disk_data_path()):
|
if os.path.exists(pkg.get_disk_data_path()):
|
||||||
@@ -890,33 +941,40 @@ class ArchManager(SoftwareManager):
|
|||||||
def get_screenshots(self, pkg: SoftwarePackage) -> List[str]:
|
def get_screenshots(self, pkg: SoftwarePackage) -> List[str]:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def _gen_bool_selector(self, id_: str, label_key: str, tooltip_key: str, value: bool, max_width: int) -> SingleSelectComponent:
|
||||||
|
opts = [InputOption(label=self.i18n['yes'].capitalize(), value=True),
|
||||||
|
InputOption(label=self.i18n['no'].capitalize(), value=False)]
|
||||||
|
|
||||||
|
return SingleSelectComponent(label=self.i18n[label_key].capitalize(),
|
||||||
|
options=opts,
|
||||||
|
default_option=[o for o in opts if o.value == value][0],
|
||||||
|
max_per_line=len(opts),
|
||||||
|
type_=SelectViewType.RADIO,
|
||||||
|
tooltip=self.i18n[tooltip_key],
|
||||||
|
max_width=max_width,
|
||||||
|
id_=id_)
|
||||||
|
|
||||||
def get_settings(self, screen_width: int, screen_height: int) -> ViewComponent:
|
def get_settings(self, screen_width: int, screen_height: int) -> ViewComponent:
|
||||||
config = read_config()
|
config = read_config()
|
||||||
max_width = floor(screen_width * 0.15)
|
max_width = floor(screen_width * 0.15)
|
||||||
|
|
||||||
optz_opts = [InputOption(label=self.i18n['yes'].capitalize(), value=True),
|
|
||||||
InputOption(label=self.i18n['no'].capitalize(), value=False)]
|
|
||||||
|
|
||||||
trans_check_opts = [InputOption(label=self.i18n['yes'].capitalize(), value=True),
|
|
||||||
InputOption(label=self.i18n['no'].capitalize(), value=False)]
|
|
||||||
|
|
||||||
fields = [
|
fields = [
|
||||||
SingleSelectComponent(label=self.i18n['arch.config.optimize'].capitalize(),
|
self._gen_bool_selector(id_='opts',
|
||||||
options=optz_opts,
|
label_key='arch.config.optimize',
|
||||||
default_option=[o for o in optz_opts if o.value == config['optimize']][0],
|
tooltip_key='arch.config.optimize.tip',
|
||||||
max_per_line=len(optz_opts),
|
value=config['optimize'],
|
||||||
type_=SelectViewType.RADIO,
|
max_width=max_width),
|
||||||
tooltip=self.i18n['arch.config.optimize.tip'],
|
self._gen_bool_selector(id_='dep_check',
|
||||||
max_width=max_width,
|
label_key='arch.config.trans_dep_check',
|
||||||
id_='opts'),
|
tooltip_key='arch.config.trans_dep_check.tip',
|
||||||
SingleSelectComponent(label=self.i18n['arch.config.trans_dep_check'].capitalize(),
|
value=config['transitive_checking'],
|
||||||
options=trans_check_opts,
|
max_width=max_width),
|
||||||
default_option=[o for o in trans_check_opts if o.value == config['transitive_checking']][0],
|
self._gen_bool_selector(id_='sync_dbs',
|
||||||
max_per_line=len(trans_check_opts),
|
label_key='arch.config.sync_dbs',
|
||||||
type_=SelectViewType.RADIO,
|
tooltip_key='arch.config.sync_dbs.tip',
|
||||||
max_width=max_width,
|
value=config['sync_databases'],
|
||||||
tooltip=self.i18n['arch.config.trans_dep_check.tip'],
|
max_width=max_width)
|
||||||
id_='dep_check')]
|
]
|
||||||
|
|
||||||
return PanelComponent([FormComponent(fields, label=self.i18n['installation'].capitalize())])
|
return PanelComponent([FormComponent(fields, label=self.i18n['installation'].capitalize())])
|
||||||
|
|
||||||
@@ -926,6 +984,7 @@ class ArchManager(SoftwareManager):
|
|||||||
form_install = component.components[0]
|
form_install = component.components[0]
|
||||||
config['optimize'] = form_install.get_component('opts').get_selected()
|
config['optimize'] = form_install.get_component('opts').get_selected()
|
||||||
config['transitive_checking'] = form_install.get_component('dep_check').get_selected()
|
config['transitive_checking'] = form_install.get_component('dep_check').get_selected()
|
||||||
|
config['sync_databases'] = form_install.get_component('sync_dbs').get_selected()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
save_config(config, CONFIG_FILE)
|
save_config(config, CONFIG_FILE)
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import re
|
|||||||
from threading import Thread
|
from threading import Thread
|
||||||
from typing import List, Set, Tuple
|
from typing import List, Set, Tuple
|
||||||
|
|
||||||
from bauh.commons.system import run_cmd, new_subprocess, new_root_subprocess, SystemProcess
|
from bauh.commons.system import run_cmd, new_subprocess, new_root_subprocess, SystemProcess, SimpleProcess
|
||||||
from bauh.gems.arch.exceptions import PackageNotFoundException
|
from bauh.gems.arch.exceptions import PackageNotFoundException
|
||||||
|
|
||||||
RE_DEPS = re.compile(r'[\w\-_]+:[\s\w_\-\.]+\s+\[\w+\]')
|
RE_DEPS = re.compile(r'[\w\-_]+:[\s\w_\-\.]+\s+\[\w+\]')
|
||||||
@@ -354,3 +354,8 @@ def read_dependencies(name: str) -> Set[str]:
|
|||||||
depends_on.update([d for d in line.split(' ') if d and d.lower() != 'none'])
|
depends_on.update([d for d in line.split(' ') if d and d.lower() != 'none'])
|
||||||
|
|
||||||
return depends_on
|
return depends_on
|
||||||
|
|
||||||
|
|
||||||
|
def sync_databases(root_password: str, force: bool = False) -> SimpleProcess:
|
||||||
|
return SimpleProcess(cmd=['pacman', '-Sy{}'.format('y' if force else '')],
|
||||||
|
root_password=root_password)
|
||||||
|
|||||||
@@ -105,4 +105,8 @@ arch.makepkg.optimizing=Optimitzant la recopilació
|
|||||||
arch.config.optimize=optimize
|
arch.config.optimize=optimize
|
||||||
arch.config.trans_dep_check=check dependencies
|
arch.config.trans_dep_check=check dependencies
|
||||||
arch.config.optimize.tip=Optimized settings will be used in order to make the packages installation faster, otherwise the system settings will be used
|
arch.config.optimize.tip=Optimized settings will be used in order to make the packages installation faster, otherwise the system settings will be used
|
||||||
arch.config.trans_dep_check.tip=If all the package dependencies should be verified before the installation starts. Otherwise they will be discovered during the installation
|
arch.config.trans_dep_check.tip=If all the package dependencies should be verified before the installation starts. Otherwise they will be discovered during the installation
|
||||||
|
arch.sync_databases.substatus=Synchronizing package databases
|
||||||
|
arch.sync_databases.substatus.error=It was not possible to synchronize the package database
|
||||||
|
arch.config.sync_dbs=Synchronize packages databases
|
||||||
|
arch.config.sync_dbs.tip=Synchronizes the package databases once a day ( or after a device reboot ) before the first package installation, upgrade or downgrade. This option help to prevent errors during these operations.
|
||||||
@@ -105,4 +105,8 @@ arch.makepkg.optimizing=Optimiert die Zusammenstellung
|
|||||||
arch.config.optimize=optimize
|
arch.config.optimize=optimize
|
||||||
arch.config.trans_dep_check=check dependencies
|
arch.config.trans_dep_check=check dependencies
|
||||||
arch.config.optimize.tip=Optimized settings will be used in order to make the packages installation faster, otherwise the system settings will be used
|
arch.config.optimize.tip=Optimized settings will be used in order to make the packages installation faster, otherwise the system settings will be used
|
||||||
arch.config.trans_dep_check.tip=If all the package dependencies should be verified before the installation starts. Otherwise they will be discovered during the installation
|
arch.config.trans_dep_check.tip=If all the package dependencies should be verified before the installation starts. Otherwise they will be discovered during the installation
|
||||||
|
arch.sync_databases.substatus=Synchronizing package databases
|
||||||
|
arch.sync_databases.substatus.error=It was not possible to synchronize the package database
|
||||||
|
arch.config.sync_dbs=Synchronize packages databases
|
||||||
|
arch.config.sync_dbs.tip=Synchronizes the package databases once a day ( or after a device reboot ) before the first package installation, upgrade or downgrade. This option help to prevent errors during these operations.
|
||||||
@@ -105,4 +105,8 @@ arch.makepkg.optimizing=Optimizing the compilation
|
|||||||
arch.config.optimize=optimize
|
arch.config.optimize=optimize
|
||||||
arch.config.trans_dep_check=check dependencies
|
arch.config.trans_dep_check=check dependencies
|
||||||
arch.config.optimize.tip=Optimized settings will be used in order to make the packages installation faster, otherwise the system settings will be used
|
arch.config.optimize.tip=Optimized settings will be used in order to make the packages installation faster, otherwise the system settings will be used
|
||||||
arch.config.trans_dep_check.tip=If all the package dependencies should be verified before the installation starts. Otherwise they will be discovered during the installation
|
arch.config.trans_dep_check.tip=If all the package dependencies should be verified before the installation starts. Otherwise they will be discovered during the installation
|
||||||
|
arch.sync_databases.substatus=Synchronizing package databases
|
||||||
|
arch.sync_databases.substatus.error=It was not possible to synchronize the package database
|
||||||
|
arch.config.sync_dbs=Synchronize packages databases
|
||||||
|
arch.config.sync_dbs.tip=Synchronizes the package databases once a day ( or after a device reboot ) before the first package installation, upgrade or downgrade. This option help to prevent errors during these operations.
|
||||||
@@ -105,4 +105,8 @@ arch.makepkg.optimizing=Optimizando la compilación
|
|||||||
arch.config.optimize=optimizar
|
arch.config.optimize=optimizar
|
||||||
arch.config.trans_dep_check=verificar dependencias
|
arch.config.trans_dep_check=verificar dependencias
|
||||||
arch.config.optimize.tip=Se usará una configuración optimizada para acelerar la instalación de los paquetes, de lo contrario se usará la configuración del sistema
|
arch.config.optimize.tip=Se usará una configuración optimizada para acelerar la instalación de los paquetes, de lo contrario se usará la configuración del sistema
|
||||||
arch.config.trans_dep_check.tip=Si todas las dependencias del paquete deben ser verificadas antes de que comience la instalación. De lo contrario, se descubrirán durante la instalación.
|
arch.config.trans_dep_check.tip=Si todas las dependencias del paquete deben ser verificadas antes de que comience la instalación. De lo contrario, se descubrirán durante la instalación.
|
||||||
|
arch.sync_databases.substatus=Sincronizando bases de paquetes
|
||||||
|
arch.sync_databases.substatus.error=No fue posible sincronizar la base de paquetes
|
||||||
|
arch.config.sync_dbs=Sincronizar las bases de paquetes
|
||||||
|
arch.config.sync_dbs.tip=Sincroniza las bases de paquetes una vez al día ( o cada reinicialización del dispositivo ) antes de la primera instalación, actualización o reversión de un paquete. Esta opción ayuda a prevenir errores durante estas operaciones.
|
||||||
@@ -73,4 +73,8 @@ arch.makepkg.optimizing=Ottimizzando la compilazione
|
|||||||
arch.config.optimize=optimize
|
arch.config.optimize=optimize
|
||||||
arch.config.trans_dep_check=check dependencies
|
arch.config.trans_dep_check=check dependencies
|
||||||
arch.config.optimize.tip=Optimized settings will be used in order to make the packages installation faster, otherwise the system settings will be used
|
arch.config.optimize.tip=Optimized settings will be used in order to make the packages installation faster, otherwise the system settings will be used
|
||||||
arch.config.trans_dep_check.tip=If all the package dependencies should be verified before the installation starts. Otherwise they will be discovered during the installation
|
arch.config.trans_dep_check.tip=If all the package dependencies should be verified before the installation starts. Otherwise they will be discovered during the installation
|
||||||
|
arch.sync_databases.substatus=Synchronizing package databases
|
||||||
|
arch.sync_databases.substatus.error=It was not possible to synchronize the package database
|
||||||
|
arch.config.sync_dbs=Synchronize packages databases
|
||||||
|
arch.config.sync_dbs.tip=Synchronizes the package databases once a day ( or after a device reboot ) before the first package installation, upgrade or downgrade. This option help to prevent errors during these operations.
|
||||||
@@ -105,4 +105,8 @@ arch.makepkg.optimizing=Otimizando a compilação
|
|||||||
arch.config.optimize=otimizar
|
arch.config.optimize=otimizar
|
||||||
arch.config.trans_dep_check=verificar dependências
|
arch.config.trans_dep_check=verificar dependências
|
||||||
arch.config.optimize.tip=Utilizará configurações otimizadas para que a instalação de pacotes seja mais rápida, caso contrário utilizará a do sistema
|
arch.config.optimize.tip=Utilizará configurações otimizadas para que a instalação de pacotes seja mais rápida, caso contrário utilizará a do sistema
|
||||||
arch.config.trans_dep_check.tip=Se todas as dependências do pacote devem ser verificadas antes da instalação começar, caso contrário elas serão descobertas durante a instalação
|
arch.config.trans_dep_check.tip=Se todas as dependências do pacote devem ser verificadas antes da instalação começar, caso contrário elas serão descobertas durante a instalação
|
||||||
|
arch.sync_databases.substatus=Sincronizando bases de pacotes
|
||||||
|
arch.sync_databases.substatus.error=Não foi possível sincronizar as bases de pacotes
|
||||||
|
arch.config.sync_dbs=Sincronizar bases de pacotes
|
||||||
|
arch.config.sync_dbs.tip=Sincroniza as bases de pacotes uma vez ao dia ( ou a cada reinicialização do dispositivo ) antes da primeira instalação, atualização ou reversão de um pacote. Essa opção ajuda a evitar erros durante essa operações.
|
||||||
Reference in New Issue
Block a user