mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-08 23:24:15 +02:00
[aur] root check refactoring
This commit is contained in:
@@ -15,7 +15,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|||||||
- checking architecture dependencies (x86_64, i686)
|
- checking architecture dependencies (x86_64, i686)
|
||||||
- architecture dependencies are displayed on the info window as well
|
- architecture dependencies are displayed on the info window as well
|
||||||
- optimizations to speed up zst packages building
|
- optimizations to speed up zst packages building
|
||||||
- showing a warning messaging when trying to install / update a package with the root user
|
- showing a warning messaging when trying to install / update / downgrade a package with the root user
|
||||||
- UI:
|
- UI:
|
||||||
- **Settings** available as a tray action as well
|
- **Settings** available as a tray action as well
|
||||||
- minor improvements
|
- minor improvements
|
||||||
|
|||||||
@@ -192,6 +192,9 @@ class ArchManager(SoftwareManager):
|
|||||||
return SearchResult(apps, None, len(apps))
|
return SearchResult(apps, None, len(apps))
|
||||||
|
|
||||||
def downgrade(self, pkg: ArchPackage, root_password: str, watcher: ProcessWatcher) -> bool:
|
def downgrade(self, pkg: ArchPackage, root_password: str, watcher: ProcessWatcher) -> bool:
|
||||||
|
if not self._check_action_allowed(pkg, watcher):
|
||||||
|
return False
|
||||||
|
|
||||||
self.local_config = read_config()
|
self.local_config = read_config()
|
||||||
|
|
||||||
handler = ProcessHandler(watcher)
|
handler = ProcessHandler(watcher)
|
||||||
@@ -262,14 +265,20 @@ class ArchManager(SoftwareManager):
|
|||||||
if os.path.exists(pkg.get_disk_cache_path()):
|
if os.path.exists(pkg.get_disk_cache_path()):
|
||||||
shutil.rmtree(pkg.get_disk_cache_path())
|
shutil.rmtree(pkg.get_disk_cache_path())
|
||||||
|
|
||||||
def update(self, pkg: ArchPackage, root_password: str, watcher: ProcessWatcher) -> bool:
|
def _check_action_allowed(self, pkg: ArchPackage, watcher: ProcessWatcher) -> bool:
|
||||||
if user.is_root() and pkg.mirror == 'aur':
|
if user.is_root() and pkg.mirror == 'aur':
|
||||||
watcher.show_message(title=self.i18n['arch.install.aur.root_error.title'],
|
watcher.show_message(title=self.i18n['arch.install.aur.root_error.title'],
|
||||||
body=self.i18n['arch.install.aur.root_error.body'],
|
body=self.i18n['arch.install.aur.root_error.body'],
|
||||||
type_=MessageType.ERROR)
|
type_=MessageType.ERROR)
|
||||||
return False
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
|
def update(self, pkg: ArchPackage, root_password: str, watcher: ProcessWatcher) -> bool:
|
||||||
|
if not self._check_action_allowed(pkg, watcher):
|
||||||
|
return False
|
||||||
|
|
||||||
self.local_config = read_config()
|
self.local_config = read_config()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
return self.install(pkg=pkg, root_password=root_password, watcher=watcher, skip_optdeps=True)
|
return self.install(pkg=pkg, root_password=root_password, watcher=watcher, skip_optdeps=True)
|
||||||
finally:
|
finally:
|
||||||
@@ -900,10 +909,7 @@ class ArchManager(SoftwareManager):
|
|||||||
ArchCompilationOptimizer(self.context.logger).optimize()
|
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:
|
||||||
if user.is_root() and pkg.mirror == 'aur':
|
if not self._check_action_allowed(pkg, watcher):
|
||||||
watcher.show_message(title=self.i18n['arch.install.aur.root_error.title'],
|
|
||||||
body=self.i18n['arch.install.aur.root_error.body'],
|
|
||||||
type_=MessageType.ERROR)
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
clean_config = False
|
clean_config = False
|
||||||
|
|||||||
Reference in New Issue
Block a user