mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-09 23:34:17 +02:00
[arch] feature -> AUR: new custom action to quickly reinstall a package
This commit is contained in:
@@ -41,3 +41,7 @@ class DiskCacheLoaderFactory(ABC):
|
||||
:return:
|
||||
"""
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def new(self) -> DiskCacheLoader:
|
||||
pass
|
||||
|
||||
@@ -26,6 +26,7 @@ from bauh.api.abstract.view import MessageType, FormComponent, InputOption, Sing
|
||||
ViewComponent, PanelComponent, MultipleSelectComponent, TextInputComponent, TextInputType, \
|
||||
FileChooserComponent, TextComponent
|
||||
from bauh.api.constants import TEMP_DIR
|
||||
from bauh.api.exception import NoInternetException
|
||||
from bauh.commons import user, system
|
||||
from bauh.commons.boot import CreateConfigFile
|
||||
from bauh.commons.category import CategoriesDownloader
|
||||
@@ -3398,3 +3399,32 @@ class ArchManager(SoftwareManager):
|
||||
continue
|
||||
|
||||
return res
|
||||
|
||||
def reinstall(self, pkg: ArchPackage, root_password: str, watcher: ProcessWatcher) -> bool: # only available for AUR packages
|
||||
if not self.context.internet_checker.is_available():
|
||||
raise NoInternetException()
|
||||
|
||||
self.aur_client.clean_caches()
|
||||
|
||||
apidatas = self.aur_client.get_info({pkg.name})
|
||||
|
||||
if not apidatas:
|
||||
watcher.show_message(title=self.i18n['error'],
|
||||
body=self.i18n['arch.action.reinstall.error.no_apidata'],
|
||||
type_=MessageType.ERROR)
|
||||
return False
|
||||
|
||||
self.aur_mapper.fill_last_modified(pkg, apidatas[0])
|
||||
context = TransactionContext.gen_context_from(pkg=pkg,
|
||||
arch_config=self.configman.get_config(),
|
||||
root_password=root_password,
|
||||
handler=ProcessHandler(watcher),
|
||||
aur_supported=True)
|
||||
context.skip_opt_deps = False
|
||||
context.update_aur_index = True
|
||||
|
||||
return self.install(pkg=pkg,
|
||||
root_password=root_password,
|
||||
watcher=watcher,
|
||||
context=context,
|
||||
disk_loader=self.context.disk_loader_factory.new()).success
|
||||
|
||||
@@ -7,19 +7,26 @@ from bauh.view.util.translation import I18n
|
||||
|
||||
CACHED_ATTRS = {'command', 'icon_path', 'repository', 'maintainer', 'desktop_entry', 'categories', 'last_modified', 'commit'}
|
||||
|
||||
ACTIONS_AUR_ENABLE_PKGBUILD_EDITION = [CustomSoftwareAction(i18n_label_key='arch.action.enable_pkgbuild_edition',
|
||||
i18n_status_key='arch.action.enable_pkgbuild_edition.status',
|
||||
i18n_confirm_key='arch.action.enable_pkgbuild_edition.confirm',
|
||||
requires_root=False,
|
||||
manager_method='enable_pkgbuild_edition',
|
||||
icon_path=resource.get_path('img/mark_pkgbuild.svg', ROOT_DIR))]
|
||||
ACTION_AUR_ENABLE_PKGBUILD_EDITION = CustomSoftwareAction(i18n_label_key='arch.action.enable_pkgbuild_edition',
|
||||
i18n_status_key='arch.action.enable_pkgbuild_edition.status',
|
||||
i18n_confirm_key='arch.action.enable_pkgbuild_edition.confirm',
|
||||
requires_root=False,
|
||||
manager_method='enable_pkgbuild_edition',
|
||||
icon_path=resource.get_path('img/mark_pkgbuild.svg', ROOT_DIR))
|
||||
|
||||
ACTIONS_AUR_DISABLE_PKGBUILD_EDITION = [CustomSoftwareAction(i18n_label_key='arch.action.disable_pkgbuild_edition',
|
||||
i18n_status_key='arch.action.disable_pkgbuild_edition',
|
||||
i18n_confirm_key='arch.action.disable_pkgbuild_edition.confirm',
|
||||
requires_root=False,
|
||||
manager_method='disable_pkgbuild_edition',
|
||||
icon_path=resource.get_path('img/unmark_pkgbuild.svg', ROOT_DIR))]
|
||||
ACTION_AUR_DISABLE_PKGBUILD_EDITION = CustomSoftwareAction(i18n_label_key='arch.action.disable_pkgbuild_edition',
|
||||
i18n_status_key='arch.action.disable_pkgbuild_edition',
|
||||
i18n_confirm_key='arch.action.disable_pkgbuild_edition.confirm',
|
||||
requires_root=False,
|
||||
manager_method='disable_pkgbuild_edition',
|
||||
icon_path=resource.get_path('img/unmark_pkgbuild.svg', ROOT_DIR))
|
||||
|
||||
ACTION_AUR_REINSTALL = CustomSoftwareAction(i18n_label_key='arch.action.reinstall',
|
||||
i18n_status_key='arch.action.reinstall.status',
|
||||
i18n_confirm_key='arch.action.reinstall.confirm',
|
||||
requires_root=True,
|
||||
manager_method='reinstall',
|
||||
icon_path=resource.get_path('img/build.svg', ROOT_DIR))
|
||||
|
||||
|
||||
class ArchPackage(SoftwarePackage):
|
||||
@@ -174,11 +181,13 @@ class ArchPackage(SoftwarePackage):
|
||||
return '{}/PKGBUILD'.format(self.get_disk_cache_path())
|
||||
|
||||
def get_custom_supported_actions(self) -> List[CustomSoftwareAction]:
|
||||
if self.installed and self.pkgbuild_editable is not None and self.repository == 'aur':
|
||||
if self.pkgbuild_editable:
|
||||
return ACTIONS_AUR_DISABLE_PKGBUILD_EDITION
|
||||
else:
|
||||
return ACTIONS_AUR_ENABLE_PKGBUILD_EDITION
|
||||
if self.installed and self.repository == 'aur':
|
||||
actions = [ACTION_AUR_REINSTALL]
|
||||
|
||||
if self.pkgbuild_editable is not None:
|
||||
actions.append(ACTION_AUR_DISABLE_PKGBUILD_EDITION if self.pkgbuild_editable else ACTION_AUR_ENABLE_PKGBUILD_EDITION)
|
||||
|
||||
return actions
|
||||
|
||||
def __hash__(self):
|
||||
if self.view_name is not None:
|
||||
|
||||
119
bauh/gems/arch/resources/img/build.svg
Normal file
119
bauh/gems/arch/resources/img/build.svg
Normal file
@@ -0,0 +1,119 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
version="1.1"
|
||||
id="Capa_1"
|
||||
x="0px"
|
||||
y="0px"
|
||||
viewBox="0 0 512 512"
|
||||
xml:space="preserve"
|
||||
sodipodi:docname="build.svg"
|
||||
width="512"
|
||||
height="512"
|
||||
inkscape:version="1.0.1 (3bc2e813f5, 2020-09-07)"><metadata
|
||||
id="metadata947"><rdf:RDF><cc:Work
|
||||
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
|
||||
id="defs945">
|
||||
|
||||
|
||||
|
||||
</defs><sodipodi:namedview
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1"
|
||||
objecttolerance="10"
|
||||
gridtolerance="10"
|
||||
guidetolerance="10"
|
||||
inkscape:pageopacity="0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:window-width="1366"
|
||||
inkscape:window-height="739"
|
||||
id="namedview943"
|
||||
showgrid="false"
|
||||
inkscape:zoom="1.2142857"
|
||||
inkscape:cx="224"
|
||||
inkscape:cy="224"
|
||||
inkscape:window-x="0"
|
||||
inkscape:window-y="0"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:current-layer="Capa_1" />
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<g
|
||||
id="g1754"><g
|
||||
id="g904"
|
||||
transform="matrix(1.1254561,0,0,1.1254561,3.8978336,3.8978336)"
|
||||
style="fill:#59a869;fill-opacity:1">
|
||||
<g
|
||||
id="g902"
|
||||
style="fill:#59a869;fill-opacity:1"
|
||||
transform="matrix(1.4025677,0,0,1.4025677,-90.175165,11.541824)">
|
||||
<path
|
||||
d="m 256.272,0 h -64.784 c -4.48,0 -8.752,1.872 -11.712,5.216 C 173.92,11.808 165.472,16 156.032,16 146.592,16 138.128,11.808 132.288,5.216 129.312,1.872 125.04,0 120.56,0 H 72.272 c -4.416,0 -8,3.584 -8,8 v 64 c 0,4.416 3.584,8 8,8 h 48.288 c 4.48,0 8.752,-1.872 11.712,-5.216 C 138.128,68.192 146.576,64 156.032,64 c 32,0 36.256,37.744 36.256,48 l -0.272,64 h 64 v -64 c 0,-28.16 16.56,-48 48.256,-48 32,0 56.976,19.904 70.976,42.72 l 8.48,-4.4 c 0,-0.032 0,-0.032 0,-0.032 C 363.936,44.432 297.136,0 256.272,0 Z m -144,32 h -32 V 16 h 32 z"
|
||||
id="path900"
|
||||
style="fill:#59a869;fill-opacity:1" />
|
||||
</g>
|
||||
</g><g
|
||||
id="g1709"><g
|
||||
id="g1712"><path
|
||||
d="m 309.83377,357.64138 c 5.05762,-43.91375 1.06571,-60.90544 -18.08097,-97.49327 h -72.25159 c -19.14669,36.58783 -23.13859,53.57952 -18.06291,97.49327 9.12177,78.94169 -0.70444,82.78571 -0.90315,98.31499 -0.19869,15.5293 11.27126,27.0335 25.17969,27.0335 h 59.84239 c 13.90845,0 25.36031,-11.5042 25.17969,-27.0335 -0.19869,-15.52928 -10.02491,-19.3733 -0.90315,-98.31499 z"
|
||||
id="path906"
|
||||
style="fill:#59a869;fill-opacity:1;stroke-width:0.99132" /></g></g><g
|
||||
id="g912">
|
||||
</g><g
|
||||
id="g914">
|
||||
</g><g
|
||||
id="g916">
|
||||
</g><g
|
||||
id="g918">
|
||||
</g><g
|
||||
id="g920">
|
||||
</g><g
|
||||
id="g922">
|
||||
</g><g
|
||||
id="g924">
|
||||
</g><g
|
||||
id="g926">
|
||||
</g><g
|
||||
id="g928">
|
||||
</g><g
|
||||
id="g930">
|
||||
</g><g
|
||||
id="g932">
|
||||
</g><g
|
||||
id="g934">
|
||||
</g><g
|
||||
id="g936">
|
||||
</g><g
|
||||
id="g938">
|
||||
</g><g
|
||||
id="g940">
|
||||
</g><rect
|
||||
style="fill:#59a869;fill-opacity:1;stroke:none;stroke-width:284.117;stroke-miterlimit:4;stroke-dasharray:none"
|
||||
id="rect1724"
|
||||
width="90.90567"
|
||||
height="36.153423"
|
||||
x="20.398468"
|
||||
y="37.148106" /></g></svg>
|
||||
|
After Width: | Height: | Size: 3.4 KiB |
@@ -9,6 +9,10 @@ arch.action.disable_pkgbuild_edition.status=Unmarking PKGBUILD as editable
|
||||
arch.action.enable_pkgbuild_edition=Mark PKGBUILD as editable
|
||||
arch.action.enable_pkgbuild_edition.confirm=Mark PKGBUILD of {} as editable ?
|
||||
arch.action.enable_pkgbuild_edition.status=Marking PKGBUILD as editable
|
||||
arch.action.reinstall=Reinstall
|
||||
arch.action.reinstall.status=Reinstalling
|
||||
arch.action.reinstall.confirm=Do you want to reinstall {} ?
|
||||
arch.action.reinstall.error.no_apidata=It was not possible to retrieve information of {} from AUR
|
||||
arch.aur.action.edit_pkgbuild.body=Edit the PKGBUILD file of {} before continuing ?
|
||||
arch.aur.install.pgp.body=Per a instal·lar {} cal rebre les claus PGP següents
|
||||
arch.aur.install.pgp.receive_fail=Could not receive PGP key {}
|
||||
|
||||
@@ -9,6 +9,10 @@ arch.action.disable_pkgbuild_edition.status=Unmarking PKGBUILD as editable
|
||||
arch.action.enable_pkgbuild_edition=Mark PKGBUILD as editable
|
||||
arch.action.enable_pkgbuild_edition.confirm=Mark PKGBUILD of {} as editable ?
|
||||
arch.action.enable_pkgbuild_edition.status=Marking PKGBUILD as editable
|
||||
arch.action.reinstall=Reinstall
|
||||
arch.action.reinstall.status=Reinstalling
|
||||
arch.action.reinstall.confirm=Do you want to reinstall {} ?
|
||||
arch.action.reinstall.error.no_apidata=It was not possible to retrieve information of {} from AUR
|
||||
arch.aur.action.edit_pkgbuild.body=Edit the PKGBUILD file of {} before continuing ?
|
||||
arch.aur.install.pgp.body=Um {} zu installieren sind folgende PGP Schlüssel nötig
|
||||
arch.aur.install.pgp.receive_fail=PGP Schlüssel {} konnte nicht empfangen werden
|
||||
|
||||
@@ -9,6 +9,10 @@ arch.action.disable_pkgbuild_edition.status=Unmarking PKGBUILD as editable
|
||||
arch.action.enable_pkgbuild_edition=Mark PKGBUILD as editable
|
||||
arch.action.enable_pkgbuild_edition.confirm=Mark PKGBUILD of {} as editable ?
|
||||
arch.action.enable_pkgbuild_edition.status=Marking PKGBUILD as editable
|
||||
arch.action.reinstall=Reinstall
|
||||
arch.action.reinstall.status=Reinstalling
|
||||
arch.action.reinstall.confirm=Do you want to reinstall {} ?
|
||||
arch.action.reinstall.error.no_apidata=It was not possible to retrieve information of {} from AUR
|
||||
arch.aur.action.edit_pkgbuild.body=Edit the PKGBUILD file of {} before continuing ?
|
||||
arch.aur.install.pgp.body=To install {} is necessary to receive the following PGP keys
|
||||
arch.aur.install.pgp.receive_fail=Could not receive PGP key {}
|
||||
|
||||
@@ -9,6 +9,10 @@ arch.action.disable_pkgbuild_edition.status=Desmarcando PKGBUILD como editable
|
||||
arch.action.enable_pkgbuild_edition=Marcar PKGBUILD como editable
|
||||
arch.action.enable_pkgbuild_edition.confirm=Marcar PKGBUILD de {} como editable ?
|
||||
arch.action.enable_pkgbuild_edition.status=Marcando PKGBUILD como editable
|
||||
arch.action.reinstall=Reinstalar
|
||||
arch.action.reinstall.status=Reinstalando
|
||||
arch.action.reinstall.confirm=Desea reinstalar {} ?
|
||||
arch.action.reinstall.error.no_apidata=No fue posible recuperar información de {} del AUR
|
||||
arch.aur.action.edit_pkgbuild.body=Editar el archivo PKGBUILD de {} antes de continuar ?
|
||||
arch.aur.install.pgp.body=Para instalar {} es necesario recibir las siguientes claves PGP
|
||||
arch.aur.install.pgp.receive_fail=Could not receive PGP key {}
|
||||
|
||||
@@ -9,6 +9,10 @@ arch.action.disable_pkgbuild_edition.status=Décocher PKGBUILD comme éditable
|
||||
arch.action.enable_pkgbuild_edition=Cocher PKGBUILD comme éditable
|
||||
arch.action.enable_pkgbuild_edition.confirm=Cocher le PKGBUILD de {} comme éditable ?
|
||||
arch.action.enable_pkgbuild_edition.status=Le PKGBUILD devient éditable
|
||||
arch.action.reinstall=Reinstall
|
||||
arch.action.reinstall.status=Reinstalling
|
||||
arch.action.reinstall.confirm=Do you want to reinstall {} ?
|
||||
arch.action.reinstall.error.no_apidata=It was not possible to retrieve information of {} from AUR
|
||||
arch.aur.action.edit_pkgbuild.body=Editer le fichier PKGBUILD de {} avant de continuer ?
|
||||
arch.aur.install.pgp.body=Il faut installer {} pour recevoir les clés PGP suivantes
|
||||
arch.aur.install.pgp.receive_fail=Échec de la réception de la clé PGP {}
|
||||
|
||||
@@ -9,6 +9,10 @@ arch.action.disable_pkgbuild_edition.status=Unmarking PKGBUILD as editable
|
||||
arch.action.enable_pkgbuild_edition=Mark PKGBUILD as editable
|
||||
arch.action.enable_pkgbuild_edition.confirm=Mark PKGBUILD of {} as editable ?
|
||||
arch.action.enable_pkgbuild_edition.status=Marking PKGBUILD as editable
|
||||
arch.action.reinstall=Reinstall
|
||||
arch.action.reinstall.status=Reinstalling
|
||||
arch.action.reinstall.confirm=Do you want to reinstall {} ?
|
||||
arch.action.reinstall.error.no_apidata=It was not possible to retrieve information of {} from AUR
|
||||
arch.aur.action.edit_pkgbuild.body=Edit the PKGBUILD file of {} before continuing ?
|
||||
arch.aur.install.pgp.body=Per installare {} è necessario ricevere le seguenti chiavi PGP
|
||||
arch.aur.install.pgp.receive_fail=Impossibile ricevere la chiave PGP {}
|
||||
|
||||
@@ -9,6 +9,10 @@ arch.action.disable_pkgbuild_edition.status=Desmarcando PKGBUILD como editável
|
||||
arch.action.enable_pkgbuild_edition=Marcando PKGBUILD como editável
|
||||
arch.action.enable_pkgbuild_edition.confirm=Marcar o PKGBUILD de {} como editável ?
|
||||
arch.action.enable_pkgbuild_edition.status=Marcando PKGBUILD como editável
|
||||
arch.action.reinstall=Reinstalar
|
||||
arch.action.reinstall.status=Reinstalando
|
||||
arch.action.reinstall.confirm=Deseja reinstalar {} ?
|
||||
arch.action.reinstall.error.no_apidata=Não foi possível obter informações de {} do AUR
|
||||
arch.aur.action.edit_pkgbuild.body=Editar o arquivo PKGBUILD de {} antes de continuar ?
|
||||
arch.aur.install.pgp.body=Para instalar {} é necessário receber as seguintes chaves PGP
|
||||
arch.aur.install.pgp.receive_fail=Não foi possível receber a chave PGP {}
|
||||
|
||||
@@ -9,6 +9,10 @@ arch.action.disable_pkgbuild_edition.status=Unmarking PKGBUILD as editable
|
||||
arch.action.enable_pkgbuild_edition=Mark PKGBUILD as editable
|
||||
arch.action.enable_pkgbuild_edition.confirm=Mark PKGBUILD of {} as editable ?
|
||||
arch.action.enable_pkgbuild_edition.status=Marking PKGBUILD as editable
|
||||
arch.action.reinstall=Reinstall
|
||||
arch.action.reinstall.status=Reinstalling
|
||||
arch.action.reinstall.confirm=Do you want to reinstall {} ?
|
||||
arch.action.reinstall.error.no_apidata=It was not possible to retrieve information of {} from AUR
|
||||
arch.aur.action.edit_pkgbuild.body=Edit the PKGBUILD file of {} before continuing ?
|
||||
arch.aur.install.pgp.body=Для установки {} необходимо получить следующие PGP ключи
|
||||
arch.aur.install.pgp.receive_fail=Не удалось получить PGP-ключ {}
|
||||
|
||||
@@ -9,6 +9,10 @@ arch.action.disable_pkgbuild_edition.status=Unmarking PKGBUILD as editable
|
||||
arch.action.enable_pkgbuild_edition=Mark PKGBUILD as editable
|
||||
arch.action.enable_pkgbuild_edition.confirm=Mark PKGBUILD of {} as editable ?
|
||||
arch.action.enable_pkgbuild_edition.status=Marking PKGBUILD as editable
|
||||
arch.action.reinstall=Reinstall
|
||||
arch.action.reinstall.status=Reinstalling
|
||||
arch.action.reinstall.confirm=Do you want to reinstall {} ?
|
||||
arch.action.reinstall.error.no_apidata=It was not possible to retrieve information of {} from AUR
|
||||
arch.aur.action.edit_pkgbuild.body=Edit the PKGBUILD file of {} before continuing ?
|
||||
arch.aur.install.pgp.body={} kurmak için aşağıdaki PGP anahtarlarını almak gereklidir
|
||||
arch.aur.install.pgp.receive_fail=PGP anahtarı alınamadı {}
|
||||
|
||||
@@ -22,6 +22,7 @@ class AsyncDiskCacheLoader(Thread, DiskCacheLoader):
|
||||
self.cache_map = cache_map
|
||||
self.logger = logger
|
||||
self.processed = 0
|
||||
self._working = False
|
||||
|
||||
def fill(self, pkg: SoftwarePackage, sync: bool = False):
|
||||
"""
|
||||
@@ -31,7 +32,7 @@ class AsyncDiskCacheLoader(Thread, DiskCacheLoader):
|
||||
:return:
|
||||
"""
|
||||
if pkg and pkg.supports_disk_cache():
|
||||
if sync:
|
||||
if sync or not self._working:
|
||||
self._fill_cached_data(pkg)
|
||||
else:
|
||||
self.pkgs.append(pkg)
|
||||
@@ -40,6 +41,7 @@ class AsyncDiskCacheLoader(Thread, DiskCacheLoader):
|
||||
self._work = False
|
||||
|
||||
def run(self):
|
||||
self._working = True
|
||||
last = 0
|
||||
|
||||
while True:
|
||||
@@ -53,6 +55,8 @@ class AsyncDiskCacheLoader(Thread, DiskCacheLoader):
|
||||
elif not self._work:
|
||||
break
|
||||
|
||||
self._working = False
|
||||
|
||||
def _fill_cached_data(self, pkg: SoftwarePackage) -> bool:
|
||||
if os.path.exists(pkg.get_disk_data_path()):
|
||||
disk_path = pkg.get_disk_data_path()
|
||||
|
||||
Reference in New Issue
Block a user