diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d634131..0c9167d2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## [0.9.4] 2020 ### Features -- Ignore updates: now it is possible to ignore updates from software packages through their actions button (**+**). Supported types: Arch packages +- Ignore updates: now it is possible to ignore updates from software packages through their actions button (**+**). Supported types: Arch packages, Flatpaks and AppImages

diff --git a/README.md b/README.md index 174e0500..e825d213 100644 --- a/README.md +++ b/README.md @@ -101,7 +101,8 @@ Before uninstalling bauh via your package manager, consider executing `bauh --re ### Gems ( package technology support ) #### Flatpak ( flatpak ) -- Supported actions: search, install, uninstall, downgrade, launch, history +- Supported actions: search, install, uninstall, downgrade, launch, history and ignore updates +- Applications with ignored updates are defined at **~/.config/bauh/flatpak/updates_ignored.txt** - The configuration file is located at **~/.config/bauh/flatpak.yml** and it allows the following customizations: ``` installation_level: null # defines a default installation level: user or system. ( the popup will not be displayed if a value is defined ) @@ -119,7 +120,7 @@ installation_level: null # defines a default installation level: user or system. #### AppImage ( appimage ) -- Supported actions: search, install, uninstall, downgrade, launch, history +- Supported actions: search, install, uninstall, downgrade, launch, history and ignore updates - **Only x86_64 AppImage files are available through the search mechanism at the moment** - Custom actions - **Install AppImage file**: allows to install a external AppImage file @@ -147,8 +148,8 @@ db_updater: #### Arch ( Repositories / AUR ) - Only available for **Arch-based systems** -- Repository packages supported actions: search, install, uninstall, launch -- AUR packages supported actions: search, install, uninstall, downgrade, launch, history +- Repository packages supported actions: search, install, uninstall, launch and ignore updates +- AUR packages supported actions: search, install, uninstall, downgrade, launch, history and ignore updates - It handles conflicts, missing / optional packages installations, and several providers scenarios - Automatically makes simple package compilation improvements: diff --git a/bauh/gems/appimage/controller.py b/bauh/gems/appimage/controller.py index c257236f..eddece97 100644 --- a/bauh/gems/appimage/controller.py +++ b/bauh/gems/appimage/controller.py @@ -709,8 +709,6 @@ class AppImageManager(SoftwareManager): return ignored def ignore_update(self, pkg: AppImage): - Path(CONFIG_DIR).mkdir(parents=True, exist_ok=True) - current_ignored = self._read_ignored_updates() if pkg.name not in current_ignored: @@ -720,6 +718,7 @@ class AppImageManager(SoftwareManager): pkg.updates_ignored = True def _write_ignored_updates(self, names: Set[str]): + Path(CONFIG_DIR).mkdir(parents=True, exist_ok=True) ignored_list = [*names] ignored_list.sort() diff --git a/bauh/gems/flatpak/__init__.py b/bauh/gems/flatpak/__init__.py index 9d497cb2..cc5933d2 100644 --- a/bauh/gems/flatpak/__init__.py +++ b/bauh/gems/flatpak/__init__.py @@ -1,6 +1,9 @@ import os -from pathlib import Path + +from bauh.api.constants import CONFIG_PATH ROOT_DIR = os.path.dirname(os.path.abspath(__file__)) SUGGESTIONS_FILE = 'https://raw.githubusercontent.com/vinifmor/bauh-files/master/flatpak/suggestions.txt' -CONFIG_FILE = '{}/.config/bauh/flatpak.yml'.format(Path.home()) +CONFIG_FILE = '{}/flatpak.yml'.format(CONFIG_PATH) +CONFIG_DIR = '{}/flatpak'.format(CONFIG_PATH) +UPDATES_IGNORED_FILE = '{}/updates_ignored.txt'.format(CONFIG_DIR) diff --git a/bauh/gems/flatpak/controller.py b/bauh/gems/flatpak/controller.py index 1a3e73da..b397413d 100644 --- a/bauh/gems/flatpak/controller.py +++ b/bauh/gems/flatpak/controller.py @@ -1,6 +1,8 @@ +import os import traceback from datetime import datetime from math import floor +from pathlib import Path from threading import Thread from typing import List, Set, Type, Tuple @@ -16,7 +18,7 @@ from bauh.commons import user from bauh.commons.config import save_config from bauh.commons.html import strip_html, bold from bauh.commons.system import SystemProcess, ProcessHandler -from bauh.gems.flatpak import flatpak, SUGGESTIONS_FILE, CONFIG_FILE +from bauh.gems.flatpak import flatpak, SUGGESTIONS_FILE, CONFIG_FILE, UPDATES_IGNORED_FILE, CONFIG_DIR from bauh.gems.flatpak.config import read_config from bauh.gems.flatpak.constants import FLATHUB_API_URL from bauh.gems.flatpak.model import FlatpakApplication @@ -153,6 +155,14 @@ class FlatpakManager(SoftwareManager): else: model.update = '{}/{}'.format(app_json['installation'], app_json['ref']) in update_map['full'] + if models: + ignored = self._read_ignored_updates() + + if ignored: + for model in models: + if model.get_update_ignore_key() in ignored: + model.updates_ignored = True + return SearchResult(models, None, len(models)) def downgrade(self, pkg: FlatpakApplication, root_password: str, watcher: ProcessWatcher) -> bool: @@ -536,3 +546,50 @@ class FlatpakManager(SoftwareManager): return [*all_runtimes, *apps] else: return [*runtimes, *apps] + + def _read_ignored_updates(self) -> Set[str]: + ignored = set() + if os.path.exists(UPDATES_IGNORED_FILE): + with open(UPDATES_IGNORED_FILE) as f: + ignored_txt = f.read() + + for l in ignored_txt.split('\n'): + if l: + line_clean = l.strip() + + if line_clean: + ignored.add(line_clean) + + return ignored + + def _write_ignored_updates(self, keys: Set[str]): + Path(CONFIG_DIR).mkdir(parents=True, exist_ok=True) + ignored_list = [*keys] + ignored_list.sort() + + with open(UPDATES_IGNORED_FILE, 'w+') as f: + for ignored in ignored_list: + f.write('{}\n'.format(ignored)) + + def ignore_update(self, pkg: FlatpakApplication): + ignored_keys = self._read_ignored_updates() + + pkg_key = pkg.get_update_ignore_key() + + if pkg_key not in ignored_keys: + ignored_keys.add(pkg_key) + self._write_ignored_updates(ignored_keys) + + pkg.updates_ignored = True + + def revert_ignored_update(self, pkg: FlatpakApplication): + ignored_keys = self._read_ignored_updates() + + if ignored_keys: + pkg_key = pkg.get_update_ignore_key() + + if pkg_key in ignored_keys: + ignored_keys.remove(pkg_key) + self._write_ignored_updates(ignored_keys) + + pkg.updates_ignored = False diff --git a/bauh/gems/flatpak/model.py b/bauh/gems/flatpak/model.py index ca9129d9..182cb651 100644 --- a/bauh/gems/flatpak/model.py +++ b/bauh/gems/flatpak/model.py @@ -8,7 +8,7 @@ class FlatpakApplication(SoftwarePackage): def __init__(self, id: str = None, name: str = None, version: str = None, latest_version: str = None, description: str = None, branch: str = None, arch: str = None, origin: str = None, runtime: bool = False, ref: str = None, commit: str = None, - installation: str = None, i18n: I18n = None, partial: bool = False): + installation: str = None, i18n: I18n = None, partial: bool = False, updates_ignored: bool = False): super(FlatpakApplication, self).__init__(id=id, name=name, version=version, latest_version=latest_version, description=description) self.ref = ref @@ -22,6 +22,7 @@ class FlatpakApplication(SoftwarePackage): self.i18n = i18n self.base_id = None self.base_ref = None + self.updates_ignored = updates_ignored if runtime: self.categories = ['runtime'] @@ -106,3 +107,12 @@ class FlatpakApplication(SoftwarePackage): def supports_backup(self) -> bool: return True + + def supports_ignored_updates(self) -> bool: + return self.installed + + def is_update_ignored(self) -> bool: + return self.updates_ignored + + def get_update_ignore_key(self) -> str: + return '{}:{}:{}'.format(self.installation, self.id, self.branch) diff --git a/bauh/view/qt/commons.py b/bauh/view/qt/commons.py index 30aa9556..cdfa4708 100644 --- a/bauh/view/qt/commons.py +++ b/bauh/view/qt/commons.py @@ -48,7 +48,7 @@ def apply_filters(pkgv: PackageView, filters: dict, info: dict): hidden = not pkgv.model.categories or not [c for c in pkgv.model.categories if c.lower() == filters['category']] if not hidden and filters['updates']: - hidden = not pkgv.model.update + hidden = not pkgv.model.update or pkgv.model.is_update_ignored() if not hidden and filters['name']: hidden = filters['name'] not in pkgv.model.name.lower()