mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-06 22:54:16 +02:00
[feature][flatpak] able to ignore flatpak updates
This commit is contained in:
@@ -6,7 +6,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|||||||
|
|
||||||
## [0.9.4] 2020
|
## [0.9.4] 2020
|
||||||
### Features
|
### 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
|
||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<img src="https://raw.githubusercontent.com/vinifmor/bauh/staging/pictures/releases/0.9.4/ignore_updates.png">
|
<img src="https://raw.githubusercontent.com/vinifmor/bauh/staging/pictures/releases/0.9.4/ignore_updates.png">
|
||||||
|
|||||||
@@ -101,7 +101,8 @@ Before uninstalling bauh via your package manager, consider executing `bauh --re
|
|||||||
### Gems ( package technology support )
|
### Gems ( package technology support )
|
||||||
#### Flatpak ( flatpak )
|
#### 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:
|
- 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 )
|
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 )
|
#### 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**
|
- **Only x86_64 AppImage files are available through the search mechanism at the moment**
|
||||||
- Custom actions
|
- Custom actions
|
||||||
- **Install AppImage file**: allows to install a external AppImage file
|
- **Install AppImage file**: allows to install a external AppImage file
|
||||||
@@ -147,8 +148,8 @@ db_updater:
|
|||||||
|
|
||||||
#### Arch ( Repositories / AUR )
|
#### Arch ( Repositories / AUR )
|
||||||
- Only available for **Arch-based systems**
|
- Only available for **Arch-based systems**
|
||||||
- Repository packages supported actions: search, install, uninstall, launch
|
- Repository packages supported actions: search, install, uninstall, launch and ignore updates
|
||||||
- AUR packages supported actions: search, install, uninstall, downgrade, launch, history
|
- AUR packages supported actions: search, install, uninstall, downgrade, launch, history and ignore updates
|
||||||
- It handles conflicts, missing / optional packages installations, and several providers scenarios
|
- It handles conflicts, missing / optional packages installations, and several providers scenarios
|
||||||
- Automatically makes simple package compilation improvements:
|
- Automatically makes simple package compilation improvements:
|
||||||
|
|
||||||
|
|||||||
@@ -709,8 +709,6 @@ class AppImageManager(SoftwareManager):
|
|||||||
return ignored
|
return ignored
|
||||||
|
|
||||||
def ignore_update(self, pkg: AppImage):
|
def ignore_update(self, pkg: AppImage):
|
||||||
Path(CONFIG_DIR).mkdir(parents=True, exist_ok=True)
|
|
||||||
|
|
||||||
current_ignored = self._read_ignored_updates()
|
current_ignored = self._read_ignored_updates()
|
||||||
|
|
||||||
if pkg.name not in current_ignored:
|
if pkg.name not in current_ignored:
|
||||||
@@ -720,6 +718,7 @@ class AppImageManager(SoftwareManager):
|
|||||||
pkg.updates_ignored = True
|
pkg.updates_ignored = True
|
||||||
|
|
||||||
def _write_ignored_updates(self, names: Set[str]):
|
def _write_ignored_updates(self, names: Set[str]):
|
||||||
|
Path(CONFIG_DIR).mkdir(parents=True, exist_ok=True)
|
||||||
ignored_list = [*names]
|
ignored_list = [*names]
|
||||||
ignored_list.sort()
|
ignored_list.sort()
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
import os
|
import os
|
||||||
from pathlib import Path
|
|
||||||
|
from bauh.api.constants import CONFIG_PATH
|
||||||
|
|
||||||
ROOT_DIR = os.path.dirname(os.path.abspath(__file__))
|
ROOT_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||||
SUGGESTIONS_FILE = 'https://raw.githubusercontent.com/vinifmor/bauh-files/master/flatpak/suggestions.txt'
|
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)
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
|
import os
|
||||||
import traceback
|
import traceback
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from math import floor
|
from math import floor
|
||||||
|
from pathlib import Path
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
from typing import List, Set, Type, Tuple
|
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.config import save_config
|
||||||
from bauh.commons.html import strip_html, bold
|
from bauh.commons.html import strip_html, bold
|
||||||
from bauh.commons.system import SystemProcess, ProcessHandler
|
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.config import read_config
|
||||||
from bauh.gems.flatpak.constants import FLATHUB_API_URL
|
from bauh.gems.flatpak.constants import FLATHUB_API_URL
|
||||||
from bauh.gems.flatpak.model import FlatpakApplication
|
from bauh.gems.flatpak.model import FlatpakApplication
|
||||||
@@ -153,6 +155,14 @@ class FlatpakManager(SoftwareManager):
|
|||||||
else:
|
else:
|
||||||
model.update = '{}/{}'.format(app_json['installation'], app_json['ref']) in update_map['full']
|
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))
|
return SearchResult(models, None, len(models))
|
||||||
|
|
||||||
def downgrade(self, pkg: FlatpakApplication, root_password: str, watcher: ProcessWatcher) -> bool:
|
def downgrade(self, pkg: FlatpakApplication, root_password: str, watcher: ProcessWatcher) -> bool:
|
||||||
@@ -536,3 +546,50 @@ class FlatpakManager(SoftwareManager):
|
|||||||
return [*all_runtimes, *apps]
|
return [*all_runtimes, *apps]
|
||||||
else:
|
else:
|
||||||
return [*runtimes, *apps]
|
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
|
||||||
|
|||||||
@@ -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,
|
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,
|
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,
|
super(FlatpakApplication, self).__init__(id=id, name=name, version=version,
|
||||||
latest_version=latest_version, description=description)
|
latest_version=latest_version, description=description)
|
||||||
self.ref = ref
|
self.ref = ref
|
||||||
@@ -22,6 +22,7 @@ class FlatpakApplication(SoftwarePackage):
|
|||||||
self.i18n = i18n
|
self.i18n = i18n
|
||||||
self.base_id = None
|
self.base_id = None
|
||||||
self.base_ref = None
|
self.base_ref = None
|
||||||
|
self.updates_ignored = updates_ignored
|
||||||
|
|
||||||
if runtime:
|
if runtime:
|
||||||
self.categories = ['runtime']
|
self.categories = ['runtime']
|
||||||
@@ -106,3 +107,12 @@ class FlatpakApplication(SoftwarePackage):
|
|||||||
|
|
||||||
def supports_backup(self) -> bool:
|
def supports_backup(self) -> bool:
|
||||||
return True
|
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)
|
||||||
|
|||||||
@@ -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']]
|
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']:
|
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']:
|
if not hidden and filters['name']:
|
||||||
hidden = filters['name'] not in pkgv.model.name.lower()
|
hidden = filters['name'] not in pkgv.model.name.lower()
|
||||||
|
|||||||
Reference in New Issue
Block a user