diff --git a/CHANGELOG.md b/CHANGELOG.md index 92e904b1..f53be63d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Flatpak: - allow the user to choose the installation level: **user** or **system** - able to deal with user and system applications / runtimes + - able to handle partial updates for Flatpak >= 1.5 - new configuration file located at **~/.config/bauh/flatpak.yml** ( it allows to define a default installation level ) ### Improvements diff --git a/bauh/gems/flatpak/controller.py b/bauh/gems/flatpak/controller.py index c5f3c0a9..49f16942 100644 --- a/bauh/gems/flatpak/controller.py +++ b/bauh/gems/flatpak/controller.py @@ -127,7 +127,7 @@ class FlatpakManager(SoftwareManager): partial_model.update = True models.append(partial_model) else: - model.update = app_json['ref'] in updates[0] if updates else None + model.update = '{}/{}'.format(app_json['installation'], app_json['ref']) in update_map['full'] return SearchResult(models, None, len(models)) @@ -176,6 +176,9 @@ class FlatpakManager(SoftwareManager): app_info['type'] = 'runtime' if app.runtime else 'app' app_info['description'] = strip_html(app.description) if app.description else '' + if app.installation: + app_info['installation'] = app.installation + if app_info.get('installed'): app_info['installed'] = app_info['installed'].replace('?', ' ') diff --git a/bauh/gems/flatpak/flatpak.py b/bauh/gems/flatpak/flatpak.py index 6097a266..359fbb1d 100755 --- a/bauh/gems/flatpak/flatpak.py +++ b/bauh/gems/flatpak/flatpak.py @@ -180,16 +180,22 @@ def list_updates_as_str(version: str) -> Dict[str, set]: def read_updates(version: str, installation: str) -> Dict[str, set]: + res = {'partial': set(), 'full': set()} if version < '1.2': - # TODO - return run_cmd('{} update --no-related --{}'.format(BASE_CMD, installation), ignore_return_code=True) + try: + output = run_cmd('{} update --no-related --no-deps --{}'.format(BASE_CMD, installation), ignore_return_code=True) + + if 'Updating in {}'.format(installation) in output: + for line in output.split('Updating in {}:\n'.format(installation))[1].split('\n'): + if not line.startswith('Is this ok'): + res['full'].add('{}/{}'.format(installation, line.split('\t')[0].strip())) + except: + traceback.print_exc() else: updates = new_subprocess([BASE_CMD, 'update', '--{}'.format(installation)]).stdout reg = r'[0-9]+\.\s+.+' if version >= '1.5.0' else r'[0-9]+\.\s+(\w+|\.)+\s+\w+\s+(\w|\.)+' - res = {'partial': set(), 'full': set()} - try: for o in new_subprocess(['grep', '-E', reg, '-o', '--color=never'], stdin=updates).stdout: if o: @@ -207,7 +213,7 @@ def read_updates(version: str, installation: str) -> Dict[str, set]: except: traceback.print_exc() - return res + return res def downgrade(app_ref: str, commit: str, installation: str, root_password: str) -> subprocess.Popen: