mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-07 00:04:15 +02:00
[arch] fixes -> not displaying installed AUR packages when AUR support is disabled | downloading AUR index during the initialization process when AUR support is disabled
This commit is contained in:
@@ -13,6 +13,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|||||||
- crashing when information of a given package is not available
|
- crashing when information of a given package is not available
|
||||||
- displaying "provided" repository packages on the search results (e.g: **nvidia** would appear as a package)
|
- displaying "provided" repository packages on the search results (e.g: **nvidia** would appear as a package)
|
||||||
- calling pacman to read installed packages when "Repositories" and "AUR" properties are set to "false" (it would not display the packages, but the call was unnecessary being done)
|
- calling pacman to read installed packages when "Repositories" and "AUR" properties are set to "false" (it would not display the packages, but the call was unnecessary being done)
|
||||||
|
- not displaying installed AUR packages when AUR support is disabled
|
||||||
|
- downloading AUR index during the initialization process when AUR support is disabled
|
||||||
- UI
|
- UI
|
||||||
- displaying a popup when information of a given package is not available
|
- displaying a popup when information of a given package is not available
|
||||||
|
|
||||||
|
|||||||
@@ -33,18 +33,6 @@ class SpacerComponent(ViewComponent):
|
|||||||
super(SpacerComponent, self).__init__(id_=None)
|
super(SpacerComponent, self).__init__(id_=None)
|
||||||
|
|
||||||
|
|
||||||
class PanelComponent(ViewComponent):
|
|
||||||
|
|
||||||
def __init__(self, components: List[ViewComponent], id_: str = None):
|
|
||||||
super(PanelComponent, self).__init__(id_=id_)
|
|
||||||
self.components = components
|
|
||||||
self.component_map = {c.id: c for c in components if c.id is not None} if components else None
|
|
||||||
|
|
||||||
def get_component(self, id_: str) -> ViewComponent:
|
|
||||||
if self.component_map:
|
|
||||||
return self.component_map.get(id_)
|
|
||||||
|
|
||||||
|
|
||||||
class InputViewComponent(ViewComponent):
|
class InputViewComponent(ViewComponent):
|
||||||
"""
|
"""
|
||||||
Represents an component which needs a user interaction to provide its value
|
Represents an component which needs a user interaction to provide its value
|
||||||
@@ -96,6 +84,7 @@ class SingleSelectComponent(InputViewComponent):
|
|||||||
self.label = label
|
self.label = label
|
||||||
self.options = options
|
self.options = options
|
||||||
self.value = default_option
|
self.value = default_option
|
||||||
|
self.init_value = default_option
|
||||||
self.max_per_line = max_per_line
|
self.max_per_line = max_per_line
|
||||||
self.tooltip = tooltip
|
self.tooltip = tooltip
|
||||||
self.max_width = max_width
|
self.max_width = max_width
|
||||||
@@ -105,6 +94,9 @@ class SingleSelectComponent(InputViewComponent):
|
|||||||
if self.value:
|
if self.value:
|
||||||
return self.value.value
|
return self.value.value
|
||||||
|
|
||||||
|
def changed(self) -> bool:
|
||||||
|
return self.init_value != self.value
|
||||||
|
|
||||||
|
|
||||||
class MultipleSelectComponent(InputViewComponent):
|
class MultipleSelectComponent(InputViewComponent):
|
||||||
|
|
||||||
@@ -214,10 +206,18 @@ class FormComponent(ViewComponent):
|
|||||||
self.components = components
|
self.components = components
|
||||||
self.component_map = {c.id: c for c in components if c.id} if components else None
|
self.component_map = {c.id: c for c in components if c.id} if components else None
|
||||||
|
|
||||||
def get_component(self, id_: str) -> ViewComponent:
|
def get_component(self, id_: str) -> Optional[ViewComponent]:
|
||||||
if self.component_map:
|
if self.component_map:
|
||||||
return self.component_map.get(id_)
|
return self.component_map.get(id_)
|
||||||
|
|
||||||
|
def get_single_select_component(self, id_: str) -> Optional[SingleSelectComponent]:
|
||||||
|
comp = self.get_component(id_)
|
||||||
|
|
||||||
|
if comp:
|
||||||
|
if not isinstance(comp, SingleSelectComponent):
|
||||||
|
raise Exception("'{}' is not a {}".format(id_, SingleSelectComponent.__class__.__name__))
|
||||||
|
return comp
|
||||||
|
|
||||||
|
|
||||||
class FileChooserComponent(ViewComponent):
|
class FileChooserComponent(ViewComponent):
|
||||||
|
|
||||||
@@ -281,3 +281,23 @@ class RangeInputComponent(InputViewComponent):
|
|||||||
self.step = step_value
|
self.step = step_value
|
||||||
self.value = value
|
self.value = value
|
||||||
self.max_width = max_width
|
self.max_width = max_width
|
||||||
|
|
||||||
|
|
||||||
|
class PanelComponent(ViewComponent):
|
||||||
|
|
||||||
|
def __init__(self, components: List[ViewComponent], id_: str = None):
|
||||||
|
super(PanelComponent, self).__init__(id_=id_)
|
||||||
|
self.components = components
|
||||||
|
self.component_map = {c.id: c for c in components if c.id is not None} if components else None
|
||||||
|
|
||||||
|
def get_component(self, id_: str) -> Optional[ViewComponent]:
|
||||||
|
if self.component_map:
|
||||||
|
return self.component_map.get(id_)
|
||||||
|
|
||||||
|
def get_form_component(self, id_: str) -> Optional[FormComponent]:
|
||||||
|
comp = self.get_component(id_)
|
||||||
|
|
||||||
|
if comp:
|
||||||
|
if not isinstance(comp, FormComponent):
|
||||||
|
raise Exception("'{}' is not a {}".format(id_, FormComponent.__class__.__name__))
|
||||||
|
return comp
|
||||||
|
|||||||
@@ -515,11 +515,8 @@ class ArchManager(SoftwareManager):
|
|||||||
thread_updates.start()
|
thread_updates.start()
|
||||||
|
|
||||||
repo_map = pacman.map_repositories(repo_pkgs)
|
repo_map = pacman.map_repositories(repo_pkgs)
|
||||||
if len(repo_map) != len(repo_pkgs):
|
|
||||||
self.logger.warning("Not mapped all signed packages repositories. Mapped: {}. Total: {}".format(len(repo_map), len(repo_pkgs)))
|
|
||||||
|
|
||||||
thread_updates.join()
|
thread_updates.join()
|
||||||
|
|
||||||
self.logger.info("Repository updates found" if updates else "No repository updates found")
|
self.logger.info("Repository updates found" if updates else "No repository updates found")
|
||||||
|
|
||||||
for name, data in repo_pkgs.items():
|
for name, data in repo_pkgs.items():
|
||||||
@@ -545,6 +542,9 @@ class ArchManager(SoftwareManager):
|
|||||||
if disk_loader:
|
if disk_loader:
|
||||||
disk_loader.fill(pkg, sync=True)
|
disk_loader.fill(pkg, sync=True)
|
||||||
|
|
||||||
|
if not aur_supported and pkg.repository == 'aur':
|
||||||
|
pkg.repository = None # if AUR support is disabled, the repository should be reported as "unknown"
|
||||||
|
|
||||||
if aur_supported or pkg.repository != 'aur': # this case happens when a package was removed from AUR
|
if aur_supported or pkg.repository != 'aur': # this case happens when a package was removed from AUR
|
||||||
pkgs.append(pkg)
|
pkgs.append(pkg)
|
||||||
|
|
||||||
@@ -567,24 +567,27 @@ class ArchManager(SoftwareManager):
|
|||||||
|
|
||||||
aur_pkgs, repo_pkgs = None, None
|
aur_pkgs, repo_pkgs = None, None
|
||||||
|
|
||||||
if repos_supported and installed['signed']:
|
if repos_supported:
|
||||||
repo_pkgs = installed['signed']
|
repo_pkgs = installed['signed']
|
||||||
|
|
||||||
if installed['not_signed']:
|
if installed['not_signed']:
|
||||||
if self.index_aur:
|
if aur_supported:
|
||||||
self.index_aur.join()
|
if self.index_aur:
|
||||||
|
self.index_aur.join()
|
||||||
|
|
||||||
aur_index = self.aur_client.read_index()
|
aur_index = self.aur_client.read_index()
|
||||||
|
|
||||||
for pkg in {*installed['not_signed']}:
|
for pkg in {*installed['not_signed']}:
|
||||||
if pkg not in aur_index:
|
if pkg not in aur_index:
|
||||||
if repo_pkgs is not None:
|
if repos_supported:
|
||||||
repo_pkgs[pkg] = installed['not_signed'][pkg]
|
repo_pkgs[pkg] = installed['not_signed'][pkg]
|
||||||
|
|
||||||
if aur_supported and installed['not_signed']:
|
if aur_supported and installed['not_signed']:
|
||||||
del installed['not_signed'][pkg]
|
del installed['not_signed'][pkg]
|
||||||
|
|
||||||
aur_pkgs = installed['not_signed'] if aur_supported else None
|
aur_pkgs = installed['not_signed']
|
||||||
|
elif repos_supported:
|
||||||
|
repo_pkgs.update(installed['not_signed'])
|
||||||
|
|
||||||
pkgs = []
|
pkgs = []
|
||||||
if repo_pkgs or aur_pkgs:
|
if repo_pkgs or aur_pkgs:
|
||||||
@@ -2896,35 +2899,41 @@ class ArchManager(SoftwareManager):
|
|||||||
value=arch_config['categories_exp'] if isinstance(arch_config['categories_exp'], int) else ''),
|
value=arch_config['categories_exp'] if isinstance(arch_config['categories_exp'], int) else ''),
|
||||||
]
|
]
|
||||||
|
|
||||||
return PanelComponent([FormComponent(fields, spaces=False)])
|
return PanelComponent([FormComponent(fields, spaces=False, id_='root')])
|
||||||
|
|
||||||
def save_settings(self, component: PanelComponent) -> Tuple[bool, Optional[List[str]]]:
|
def save_settings(self, component: PanelComponent) -> Tuple[bool, Optional[List[str]]]:
|
||||||
arch_config = self.configman.get_config()
|
arch_config = self.configman.get_config()
|
||||||
|
|
||||||
panel = component.components[0]
|
form = component.get_form_component('root')
|
||||||
arch_config['repositories'] = panel.get_component('repos').get_selected()
|
arch_config['repositories'] = form.get_single_select_component('repos').get_selected()
|
||||||
arch_config['aur'] = panel.get_component('aur').get_selected()
|
arch_config['optimize'] = form.get_single_select_component('opts').get_selected()
|
||||||
arch_config['optimize'] = panel.get_component('opts').get_selected()
|
arch_config['sync_databases'] = form.get_single_select_component('sync_dbs').get_selected()
|
||||||
arch_config['sync_databases'] = panel.get_component('sync_dbs').get_selected()
|
arch_config['sync_databases_startup'] = form.get_single_select_component('sync_dbs_start').get_selected()
|
||||||
arch_config['sync_databases_startup'] = panel.get_component('sync_dbs_start').get_selected()
|
arch_config['clean_cached'] = form.get_single_select_component('clean_cached').get_selected()
|
||||||
arch_config['clean_cached'] = panel.get_component('clean_cached').get_selected()
|
arch_config['refresh_mirrors_startup'] = form.get_single_select_component('ref_mirs').get_selected()
|
||||||
arch_config['refresh_mirrors_startup'] = panel.get_component('ref_mirs').get_selected()
|
arch_config['mirrors_sort_limit'] = form.get_component('mirrors_sort_limit').get_int_value()
|
||||||
arch_config['mirrors_sort_limit'] = panel.get_component('mirrors_sort_limit').get_int_value()
|
arch_config['repositories_mthread_download'] = form.get_component('mthread_download').get_selected()
|
||||||
arch_config['repositories_mthread_download'] = panel.get_component('mthread_download').get_selected()
|
arch_config['automatch_providers'] = form.get_single_select_component('autoprovs').get_selected()
|
||||||
arch_config['automatch_providers'] = panel.get_component('autoprovs').get_selected()
|
arch_config['edit_aur_pkgbuild'] = form.get_single_select_component('edit_aur_pkgbuild').get_selected()
|
||||||
arch_config['edit_aur_pkgbuild'] = panel.get_component('edit_aur_pkgbuild').get_selected()
|
arch_config['aur_remove_build_dir'] = form.get_single_select_component('aur_remove_build_dir').get_selected()
|
||||||
arch_config['aur_remove_build_dir'] = panel.get_component('aur_remove_build_dir').get_selected()
|
arch_config['aur_build_dir'] = form.get_component('aur_build_dir').file_path
|
||||||
arch_config['aur_build_dir'] = panel.get_component('aur_build_dir').file_path
|
arch_config['aur_build_only_chosen'] = form.get_single_select_component('aur_build_only_chosen').get_selected()
|
||||||
arch_config['aur_build_only_chosen'] = panel.get_component('aur_build_only_chosen').get_selected()
|
arch_config['aur_idx_exp'] = form.get_component('aur_idx_exp').get_int_value()
|
||||||
arch_config['aur_idx_exp'] = panel.get_component('aur_idx_exp').get_int_value()
|
arch_config['check_dependency_breakage'] = form.get_single_select_component('check_dependency_breakage').get_selected()
|
||||||
arch_config['check_dependency_breakage'] = panel.get_component('check_dependency_breakage').get_selected()
|
arch_config['suggest_optdep_uninstall'] = form.get_single_select_component('suggest_optdep_uninstall').get_selected()
|
||||||
arch_config['suggest_optdep_uninstall'] = panel.get_component('suggest_optdep_uninstall').get_selected()
|
arch_config['suggest_unneeded_uninstall'] = form.get_single_select_component('suggest_unneeded_uninstall').get_selected()
|
||||||
arch_config['suggest_unneeded_uninstall'] = panel.get_component('suggest_unneeded_uninstall').get_selected()
|
arch_config['categories_exp'] = form.get_component('arch_cats_exp').get_int_value()
|
||||||
arch_config['categories_exp'] = panel.get_component('arch_cats_exp').get_int_value()
|
|
||||||
|
|
||||||
if not arch_config['aur_build_dir']:
|
if not arch_config['aur_build_dir']:
|
||||||
arch_config['aur_build_dir'] = None
|
arch_config['aur_build_dir'] = None
|
||||||
|
|
||||||
|
aur_enabled_select = form.get_single_select_component('aur')
|
||||||
|
arch_config['aur'] = aur_enabled_select.get_selected()
|
||||||
|
|
||||||
|
if aur_enabled_select.changed() and arch_config['aur']:
|
||||||
|
self.index_aur = AURIndexUpdater(context=self.context, taskman=TaskManager(), arch_config=arch_config)
|
||||||
|
self.index_aur.start()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.configman.save_config(arch_config)
|
self.configman.save_config(arch_config)
|
||||||
return True, None
|
return True, None
|
||||||
|
|||||||
@@ -44,6 +44,9 @@ class AURIndexUpdater(Thread):
|
|||||||
self.taskman.register_task(self.task_id, self.i18n['arch.task.aur.index.status'], get_icon_path())
|
self.taskman.register_task(self.task_id, self.i18n['arch.task.aur.index.status'], get_icon_path())
|
||||||
|
|
||||||
def should_update(self) -> bool:
|
def should_update(self) -> bool:
|
||||||
|
if not aur.is_supported(self.config):
|
||||||
|
return False
|
||||||
|
|
||||||
try:
|
try:
|
||||||
exp_hours = int(self.config['aur_idx_exp'])
|
exp_hours = int(self.config['aur_idx_exp'])
|
||||||
except:
|
except:
|
||||||
@@ -134,7 +137,7 @@ class AURIndexUpdater(Thread):
|
|||||||
|
|
||||||
tf = time.time()
|
tf = time.time()
|
||||||
self.taskman.finish_task(self.task_id)
|
self.taskman.finish_task(self.task_id)
|
||||||
self.logger.info("Finished. Took {0:.2f} seconds".format(tf - ti))
|
self.logger.info("Finished. Took {0:.5f} seconds".format(tf - ti))
|
||||||
|
|
||||||
|
|
||||||
class ArchDiskCacheUpdater(Thread):
|
class ArchDiskCacheUpdater(Thread):
|
||||||
|
|||||||
Reference in New Issue
Block a user