From 9885aa151b9a404958f9f8e67e85e8fb7f68859a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20Moreira?= Date: Thu, 30 Jan 2020 16:05:57 -0300 Subject: [PATCH] [fix][flatpak] not able to update partials for Flatpak < 1.5 --- bauh/gems/flatpak/controller.py | 12 +++++++++++- bauh/gems/flatpak/flatpak.py | 12 ++++++++++-- bauh/gems/flatpak/model.py | 2 ++ 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/bauh/gems/flatpak/controller.py b/bauh/gems/flatpak/controller.py index 0c27bfb9..c1fee9dc 100644 --- a/bauh/gems/flatpak/controller.py +++ b/bauh/gems/flatpak/controller.py @@ -185,7 +185,17 @@ class FlatpakManager(SoftwareManager): self.api_cache.delete(pkg.id) def update(self, pkg: FlatpakApplication, root_password: str, watcher: ProcessWatcher) -> bool: - return ProcessHandler(watcher).handle(SystemProcess(subproc=flatpak.update(pkg.ref, pkg.installation))) + related, deps = False, False + ref = pkg.ref + + if pkg.partial and flatpak.get_version() < '1.5': + related, deps = True, True + ref = pkg.base_ref + + return ProcessHandler(watcher).handle(SystemProcess(subproc=flatpak.update(app_ref=ref, + installation=pkg.installation, + related=related, + deps=deps))) def uninstall(self, pkg: FlatpakApplication, root_password: str, watcher: ProcessWatcher) -> bool: uninstalled = ProcessHandler(watcher).handle(SystemProcess(subproc=flatpak.uninstall(pkg.ref, pkg.installation))) diff --git a/bauh/gems/flatpak/flatpak.py b/bauh/gems/flatpak/flatpak.py index d9645d2d..c9401f7a 100755 --- a/bauh/gems/flatpak/flatpak.py +++ b/bauh/gems/flatpak/flatpak.py @@ -149,13 +149,21 @@ def list_installed(version: str) -> List[dict]: return apps -def update(app_ref: str, installation: str): +def update(app_ref: str, installation: str, related: bool = False, deps: bool = False): """ Updates the app reference :param app_ref: :return: """ - return new_subprocess(['flatpak', 'update', '--no-related', '--no-deps', '-y', app_ref, '--{}'.format(installation)]) + cmd = ['flatpak', 'update', '-y', app_ref, '--{}'.format(installation)] + + if not related: + cmd.append('--no-related') + + if not deps: + cmd.append('--no-deps') + + return new_subprocess(cmd) def uninstall(app_ref: str, installation: str): diff --git a/bauh/gems/flatpak/model.py b/bauh/gems/flatpak/model.py index 8ae20ec1..ae70d4ec 100644 --- a/bauh/gems/flatpak/model.py +++ b/bauh/gems/flatpak/model.py @@ -23,6 +23,7 @@ class FlatpakApplication(SoftwarePackage): self.installation = installation if installation else 'system' self.i18n = i18n self.base_id = None + self.base_ref = None if runtime: self.categories = ['runtime'] @@ -81,6 +82,7 @@ class FlatpakApplication(SoftwarePackage): partial.base_id = self.id if self.ref: + partial.base_ref = self.ref partial.ref = '/'.join((partial_id, *self.ref.split('/')[1:])) partial.partial = True