mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-07 07:04:16 +02:00
[arch] improvement -> AUR: new settings property 'aur_build_dir'
This commit is contained in:
@@ -156,7 +156,8 @@ class TextInputType(Enum):
|
||||
class TextInputComponent(ViewComponent):
|
||||
|
||||
def __init__(self, label: str, value: str = '', placeholder: str = None, tooltip: str = None, read_only: bool =False,
|
||||
id_: str = None, only_int: bool = False, max_width: int = -1, type_: TextInputType = TextInputType.SINGLE_LINE):
|
||||
id_: str = None, only_int: bool = False, max_width: int = -1, type_: TextInputType = TextInputType.SINGLE_LINE,
|
||||
capitalize_label: bool = True):
|
||||
super(TextInputComponent, self).__init__(id_=id_)
|
||||
self.label = label
|
||||
self.value = value
|
||||
@@ -166,6 +167,7 @@ class TextInputComponent(ViewComponent):
|
||||
self.only_int = only_int
|
||||
self.max_width = max_width
|
||||
self.type = type_
|
||||
self.capitalize_label = capitalize_label
|
||||
|
||||
def get_value(self) -> str:
|
||||
if self.value is not None:
|
||||
@@ -189,6 +191,12 @@ class TextInputComponent(ViewComponent):
|
||||
if val:
|
||||
return int(self.value)
|
||||
|
||||
def get_label(self) -> str:
|
||||
if not self.label:
|
||||
return ''
|
||||
else:
|
||||
return self.label.capitalize() if self.capitalize_label else self.label
|
||||
|
||||
|
||||
class FormComponent(ViewComponent):
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@ from bauh.commons import resource
|
||||
|
||||
ROOT_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
BUILD_DIR = '{}/arch'.format(TEMP_DIR)
|
||||
PACKAGE_CACHE_DIR = '{}/pkg_cache'.format(BUILD_DIR)
|
||||
ARCH_CACHE_PATH = CACHE_PATH + '/arch'
|
||||
CATEGORIES_FILE_PATH = ARCH_CACHE_PATH + '/categories.txt'
|
||||
URL_CATEGORIES_FILE = 'https://raw.githubusercontent.com/vinifmor/bauh-files/master/arch/categories.txt'
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
from pathlib import Path
|
||||
|
||||
from bauh.commons.config import read_config as read
|
||||
from bauh.gems.arch import CONFIG_FILE
|
||||
from bauh.gems.arch import CONFIG_FILE, BUILD_DIR
|
||||
|
||||
|
||||
def read_config(update_file: bool = False) -> dict:
|
||||
@@ -13,5 +15,16 @@ def read_config(update_file: bool = False) -> dict:
|
||||
'mirrors_sort_limit': 5,
|
||||
'repositories_mthread_download': False,
|
||||
'automatch_providers': True,
|
||||
'edit_aur_pkgbuild': False}
|
||||
'edit_aur_pkgbuild': False,
|
||||
'aur_build_dir': None}
|
||||
return read(CONFIG_FILE, template, update_file=update_file)
|
||||
|
||||
|
||||
def get_build_dir(arch_config: dict) -> str:
|
||||
build_dir = arch_config.get('aur_build_dir')
|
||||
|
||||
if not build_dir:
|
||||
build_dir = BUILD_DIR
|
||||
|
||||
Path(build_dir).mkdir(parents=True, exist_ok=True)
|
||||
return build_dir
|
||||
|
||||
@@ -30,12 +30,12 @@ from bauh.commons.config import save_config
|
||||
from bauh.commons.html import bold
|
||||
from bauh.commons.system import SystemProcess, ProcessHandler, new_subprocess, run_cmd, SimpleProcess
|
||||
from bauh.commons.view_utils import new_select
|
||||
from bauh.gems.arch import BUILD_DIR, aur, pacman, makepkg, message, confirmation, disk, git, \
|
||||
from bauh.gems.arch import aur, pacman, makepkg, message, confirmation, disk, git, \
|
||||
gpg, URL_CATEGORIES_FILE, CATEGORIES_FILE_PATH, CUSTOM_MAKEPKG_FILE, SUGGESTIONS_FILE, \
|
||||
CONFIG_FILE, get_icon_path, database, mirrors, sorting, cpu_manager, ARCH_CACHE_PATH, UPDATES_IGNORED_FILE, \
|
||||
CONFIG_DIR, EDITABLE_PKGBUILDS_FILE, URL_GPG_SERVERS
|
||||
CONFIG_DIR, EDITABLE_PKGBUILDS_FILE, URL_GPG_SERVERS, BUILD_DIR
|
||||
from bauh.gems.arch.aur import AURClient
|
||||
from bauh.gems.arch.config import read_config
|
||||
from bauh.gems.arch.config import read_config, get_build_dir
|
||||
from bauh.gems.arch.dependencies import DependenciesAnalyser
|
||||
from bauh.gems.arch.download import MultithreadedDownloadService, ArchDownloadException
|
||||
from bauh.gems.arch.exceptions import PackageNotFoundException
|
||||
@@ -571,7 +571,7 @@ class ArchManager(SoftwareManager):
|
||||
return SearchResult(pkgs, None, len(pkgs))
|
||||
|
||||
def _downgrade_aur_pkg(self, context: TransactionContext):
|
||||
context.build_dir = '{}/build_{}'.format(BUILD_DIR, int(time.time()))
|
||||
context.build_dir = '{}/build_{}'.format(get_build_dir(context.config), int(time.time()))
|
||||
|
||||
try:
|
||||
if not os.path.exists(context.build_dir):
|
||||
@@ -1318,7 +1318,8 @@ class ArchManager(SoftwareManager):
|
||||
return self._get_info_repo_pkg(pkg)
|
||||
|
||||
def _get_history_aur_pkg(self, pkg: ArchPackage) -> PackageHistory:
|
||||
temp_dir = '{}/build_{}'.format(BUILD_DIR, int(time.time()))
|
||||
arch_config = read_config()
|
||||
temp_dir = '{}/build_{}'.format(get_build_dir(arch_config), int(time.time()))
|
||||
|
||||
try:
|
||||
Path(temp_dir).mkdir(parents=True)
|
||||
@@ -1814,7 +1815,7 @@ class ArchManager(SoftwareManager):
|
||||
return True
|
||||
|
||||
def _install_optdeps(self, context: TransactionContext) -> bool:
|
||||
odeps = pacman.map_optional_deps({context.name}, remote=False, not_installed=True)[context.name]
|
||||
odeps = pacman.map_optional_deps({context.name}, remote=False, not_installed=True).get(context.name)
|
||||
|
||||
if not odeps:
|
||||
return True
|
||||
@@ -2107,7 +2108,7 @@ class ArchManager(SoftwareManager):
|
||||
def _install_from_aur(self, context: TransactionContext) -> bool:
|
||||
self._optimize_makepkg(context.config, context.watcher)
|
||||
|
||||
context.build_dir = '{}/build_{}'.format(BUILD_DIR, int(time.time()))
|
||||
context.build_dir = '{}/build_{}'.format(get_build_dir(context.config), int(time.time()))
|
||||
|
||||
try:
|
||||
if not os.path.exists(context.build_dir):
|
||||
@@ -2484,7 +2485,14 @@ class ArchManager(SoftwareManager):
|
||||
value=local_config['edit_aur_pkgbuild'],
|
||||
max_width=max_width,
|
||||
type_=SelectViewType.RADIO,
|
||||
capitalize_label=False)
|
||||
capitalize_label=False),
|
||||
TextInputComponent(id_='aur_build_dir',
|
||||
label=self.i18n['arch.config.aur_build_dir'],
|
||||
tooltip=self.i18n['arch.config.aur_build_dir.tip'].format(BUILD_DIR),
|
||||
only_int=False,
|
||||
max_width=max_width,
|
||||
value=local_config.get('aur_build_dir', ''),
|
||||
capitalize_label=False)
|
||||
|
||||
]
|
||||
|
||||
@@ -2505,6 +2513,10 @@ class ArchManager(SoftwareManager):
|
||||
config['repositories_mthread_download'] = form_install.get_component('mthread_download').get_selected()
|
||||
config['automatch_providers'] = form_install.get_component('autoprovs').get_selected()
|
||||
config['edit_aur_pkgbuild'] = form_install.get_component('edit_aur_pkgbuild').get_selected()
|
||||
config['aur_build_dir'] = form_install.get_component('aur_build_dir').get_value().strip()
|
||||
|
||||
if not config['aur_build_dir']:
|
||||
config['aur_build_dir'] = None
|
||||
|
||||
try:
|
||||
save_config(config, CONFIG_FILE)
|
||||
|
||||
@@ -754,9 +754,8 @@ def remove_several(pkgnames: Iterable[str], root_password: str, skip_checks: boo
|
||||
|
||||
def map_optional_deps(names: Iterable[str], remote: bool, not_installed: bool = False) -> Dict[str, Dict[str, str]]:
|
||||
output = run_cmd('pacman -{}i {}'.format('S' if remote else 'Q', ' '.join(names)))
|
||||
|
||||
res = {}
|
||||
if output:
|
||||
res = {}
|
||||
latest_name, deps = None, None
|
||||
|
||||
for l in output.split('\n'):
|
||||
@@ -801,7 +800,7 @@ def map_optional_deps(names: Iterable[str], remote: bool, not_installed: bool =
|
||||
sev_deps = {dep.strip(): '' for dep in l.split(' ') if dep and (not not_installed or '[installed]' not in dep)}
|
||||
deps.update(sev_deps)
|
||||
|
||||
return res
|
||||
return res
|
||||
|
||||
|
||||
def map_all_deps(names: Iterable[str], only_installed: bool = False) -> Dict[str, Set[str]]:
|
||||
|
||||
@@ -30,6 +30,8 @@ arch.config.aur=AUR packages
|
||||
arch.config.aur.tip=It allows to manage AUR packages
|
||||
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)
|
||||
arch.config.aur_build_dir.tip=It define a custom directory where the AUR packages will be built. Default: {}.
|
||||
arch.config.clean_cache=Elimina les versions antigues
|
||||
arch.config.clean_cache.tip=Si cal eliminar les versions antigues d'un paquet emmagatzemat al disc durant la desinstal·lació
|
||||
arch.config.edit_aur_pkgbuild=Edit PKGBUILD (AUR)
|
||||
|
||||
@@ -30,6 +30,8 @@ arch.config.aur=AUR packages
|
||||
arch.config.aur.tip=It allows to manage AUR packages
|
||||
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)
|
||||
arch.config.aur_build_dir.tip=It define a custom directory where the AUR packages will be built. Default: {}.
|
||||
arch.config.clean_cache=Remove old versions
|
||||
arch.config.clean_cache.tip=Whether old versions of a package stored on disk should be removed during uninstall
|
||||
arch.config.edit_aur_pkgbuild=Edit PKGBUILD (AUR)
|
||||
|
||||
@@ -31,6 +31,8 @@ arch.config.aur=AUR packages
|
||||
arch.config.aur.tip=It allows to manage AUR packages
|
||||
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)
|
||||
arch.config.aur_build_dir.tip=It define a custom directory where the AUR packages will be built. Default: {}.
|
||||
arch.config.clean_cache=Remove old versions
|
||||
arch.config.clean_cache.tip=Whether old versions of a package stored on disk should be removed during uninstall
|
||||
arch.config.edit_aur_pkgbuild=Edit PKGBUILD (AUR)
|
||||
|
||||
@@ -30,6 +30,8 @@ arch.config.aur=Paquetes de AUR
|
||||
arch.config.aur.tip=Permite gestionar paquetes del AUR
|
||||
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)
|
||||
arch.config.aur_build_dir.tip=Define un directorio personalizado donde se construirán los paquetes AUR. Defecto: {}.
|
||||
arch.config.clean_cache=Eliminar versiones antiguas
|
||||
arch.config.clean_cache.tip=Si las versiones antiguas de un paquete almacenado en el disco deben ser eliminadas durante la desinstalación
|
||||
arch.config.edit_aur_pkgbuild=Editar PKGBUILD (AUR)
|
||||
|
||||
@@ -30,6 +30,8 @@ arch.config.aur=AUR packages
|
||||
arch.config.aur.tip=It allows to manage AUR packages
|
||||
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)
|
||||
arch.config.aur_build_dir.tip=It define a custom directory where the AUR packages will be built. Default: {}.
|
||||
arch.config.clean_cache=Rimuovi le vecchie versioni
|
||||
arch.config.clean_cache.tip=Se le vecchie versioni di un pacchetto memorizzate sul disco devono essere rimosse durante la disinstallazione
|
||||
arch.config.edit_aur_pkgbuild=Edit PKGBUILD (AUR)
|
||||
|
||||
@@ -31,6 +31,8 @@ arch.config.aur=Pacotes do AUR
|
||||
arch.config.aur.tip=Permite gerenciar pacotes dos AUR
|
||||
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)
|
||||
arch.config.aur_build_dir.tip=Define um diretório personalizado onde pacotes do AUR serão construídos. Padrão: {}.
|
||||
arch.config.clean_cache=Remover versões antigas
|
||||
arch.config.clean_cache.tip=Se versões antigas de um pacote armazenadas em disco devem ser removidas durante a desinstalação
|
||||
arch.config.edit_aur_pkgbuild=Editar PKGBUILD (AUR)
|
||||
|
||||
@@ -30,6 +30,8 @@ arch.config.aur=пакеты AUR
|
||||
arch.config.aur.tip=Это позволяет управлять пакетами AUR
|
||||
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)
|
||||
arch.config.aur_build_dir.tip=It define a custom directory where the AUR packages will be built. Default: {}.
|
||||
arch.config.clean_cache=Remove old versions
|
||||
arch.config.clean_cache.tip=Whether old versions of a package stored on disk should be removed during uninstall
|
||||
arch.config.edit_aur_pkgbuild=Edit PKGBUILD (AUR)
|
||||
|
||||
@@ -30,6 +30,8 @@ arch.config.aur=AUR paketleri
|
||||
arch.config.aur.tip=AUR paketlerinin yönetilmesine izin verir
|
||||
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)
|
||||
arch.config.aur_build_dir.tip=It define a custom directory where the AUR packages will be built. Default: {}.
|
||||
arch.config.clean_cache=Önbelleği temizle
|
||||
arch.config.clean_cache.tip=Disk üzerinde kurulu bir paketin eski sürümlerinin kaldırma sırasında kaldırılıp kaldırılmayacağı
|
||||
arch.config.edit_aur_pkgbuild=Edit PKGBUILD (AUR)
|
||||
|
||||
@@ -13,8 +13,8 @@ from bauh.api.abstract.context import ApplicationContext
|
||||
from bauh.api.abstract.handler import TaskManager
|
||||
from bauh.commons.html import bold
|
||||
from bauh.commons.system import run_cmd, new_root_subprocess, ProcessHandler
|
||||
from bauh.gems.arch import pacman, disk, CUSTOM_MAKEPKG_FILE, CONFIG_DIR, BUILD_DIR, \
|
||||
AUR_INDEX_FILE, get_icon_path, database, mirrors, ARCH_CACHE_PATH
|
||||
from bauh.gems.arch import pacman, disk, CUSTOM_MAKEPKG_FILE, CONFIG_DIR, AUR_INDEX_FILE, get_icon_path, database, \
|
||||
mirrors, ARCH_CACHE_PATH, BUILD_DIR
|
||||
from bauh.gems.arch.aur import URL_INDEX
|
||||
from bauh.view.util.translation import I18n
|
||||
|
||||
|
||||
@@ -461,7 +461,8 @@ class TextInputQt(QGroupBox):
|
||||
self.model = model
|
||||
self.setLayout(QGridLayout())
|
||||
self.setStyleSheet('QGridLayout {margin-left: 0} QLabel { font-weight: bold}')
|
||||
self.layout().addWidget(QLabel(model.label.capitalize() + ' :' if model.label else ''), 0, 0)
|
||||
|
||||
self.layout().addWidget(QLabel(model.get_label()), 0, 0)
|
||||
|
||||
if self.model.max_width > 0:
|
||||
self.setMaximumWidth(self.model.max_width)
|
||||
@@ -825,7 +826,7 @@ class FormQt(QGroupBox):
|
||||
label.layout().addWidget(label_component)
|
||||
|
||||
if label:
|
||||
label_component.setText(c.label.capitalize())
|
||||
label_component.setText(c.get_label())
|
||||
|
||||
if c.tooltip:
|
||||
label.layout().addWidget(self.gen_tip_icon(c.tooltip))
|
||||
|
||||
Reference in New Issue
Block a user