From 24d14e41bcda7eaeda4ca4bf179c910f108f7888 Mon Sep 17 00:00:00 2001 From: Vinicius Moreira Date: Mon, 30 Nov 2020 18:52:55 -0300 Subject: [PATCH] [appimage] fix: not able to launch AppImage files installed inside folders named with spaces --- CHANGELOG.md | 6 +++++- bauh/gems/appimage/controller.py | 6 +++--- bauh/gems/appimage/model.py | 9 ++++++++- bauh/gems/appimage/worker.py | 2 +- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d6ce53dc..0e52da78 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -50,10 +50,14 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - new parameter **--offline**: it assumes the internet connection is off. Useful if the connection is bad/unstable and you just want to check your installed packages. ### Fixes -- Arch: +- AppImage + - not able to launch AppImage files installed inside folders named with spaces (e.g: "/path/my folder/abc.appimage") + +- Arch - search: not able to find installed packages that were renamed on the repositories (e.g: xapps -> xapp) - not able to replace an installed package for a new one that replaces it during conflict resolutions (e.g: xapp replaces xapps) - AUR: not able to find some repository dependencies when their names are not an exact match (e.g: sc-controller [0.4.7-1] relies on "pylibacl". This dependency now is called "python-pylibacl") + - UI - history dialog: not able to maximize/minimize it on some systems - wrong tooltips diff --git a/bauh/gems/appimage/controller.py b/bauh/gems/appimage/controller.py index f05adf91..a433cb28 100644 --- a/bauh/gems/appimage/controller.py +++ b/bauh/gems/appimage/controller.py @@ -454,7 +454,7 @@ class AppImageManager(SoftwareManager): def install(self, pkg: AppImage, root_password: str, disk_loader: DiskCacheLoader, watcher: ProcessWatcher) -> TransactionResult: handler = ProcessHandler(watcher) - out_dir = INSTALLATION_PATH + pkg.name.lower() + out_dir = INSTALLATION_PATH + pkg.get_clean_name() counter = 0 while True: if os.path.exists(out_dir): @@ -530,7 +530,7 @@ class AppImageManager(SoftwareManager): with open('{}/{}'.format(extracted_folder, desktop_entry)) as f: de_content = f.read() - de_content = RE_DESKTOP_EXEC.sub('Exec={}\n'.format(file_path), de_content) + de_content = RE_DESKTOP_EXEC.sub('Exec="{}"\n'.format(file_path), de_content) extracted_icon = self._find_icon_file(extracted_folder) @@ -565,7 +565,7 @@ class AppImageManager(SoftwareManager): return TransactionResult.fail() def _gen_desktop_entry_path(self, app: AppImage) -> str: - return '{}/bauh_appimage_{}.desktop'.format(DESKTOP_ENTRIES_PATH, app.name.lower()) + return '{}/bauh_appimage_{}.desktop'.format(DESKTOP_ENTRIES_PATH, app.get_clean_name()) def is_enabled(self) -> bool: return self.enabled diff --git a/bauh/gems/appimage/model.py b/bauh/gems/appimage/model.py index ec9bc559..d5a65142 100644 --- a/bauh/gems/appimage/model.py +++ b/bauh/gems/appimage/model.py @@ -1,10 +1,13 @@ -from typing import List +import re +from typing import List, Optional from bauh.api.abstract.model import SoftwarePackage, CustomSoftwareAction from bauh.commons import resource from bauh.gems.appimage import ROOT_DIR, INSTALLATION_PATH from bauh.view.util.translation import I18n +RE_MANY_SPACES = re.compile(r'\s+') + CACHED_ATTRS = {'name', 'description', 'version', 'url_download', 'author', 'license', 'source', 'icon_path', 'github', 'categories', 'imported', 'install_dir', 'symlink'} @@ -120,3 +123,7 @@ class AppImage(SoftwarePackage): def __eq__(self, other): if isinstance(other, AppImage): return self.name == other.name and self.local_file_path == other.local_file_path + + def get_clean_name(self) -> Optional[str]: + if self.name: + return RE_MANY_SPACES.sub('-', self.name.lower().strip()) diff --git a/bauh/gems/appimage/worker.py b/bauh/gems/appimage/worker.py index 16e640b0..ab3673e2 100644 --- a/bauh/gems/appimage/worker.py +++ b/bauh/gems/appimage/worker.py @@ -121,7 +121,7 @@ class SymlinksVerifier(Thread): @staticmethod def create_symlink(app: AppImage, file_path: str, logger: logging.Logger, watcher: ProcessWatcher = None): logger.info("Creating a symlink for '{}'".format(app.name)) - possible_names = (app.name.lower(), '{}-appimage'.format(app.name.lower())) + possible_names = (app.get_clean_name(), '{}-appimage'.format(app.get_clean_name()), app.name.lower(), '{}-appimage'.format(app.name.lower())) if os.path.exists(SYMLINKS_DIR) and not os.path.isdir(SYMLINKS_DIR): logger.warning("'{}' is not a directory. It will not be possible to create a symlink for '{}'".format(SYMLINKS_DIR, app.name))