mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-07 00:04:15 +02:00
[feature][appimage] able to ignore appimage updates
This commit is contained in:
@@ -132,6 +132,7 @@ installation_level: null # defines a default installation level: user or system.
|
|||||||
- Databases updater daemon running every 20 minutes ( it can be customized via the configuration file described below )
|
- Databases updater daemon running every 20 minutes ( it can be customized via the configuration file described below )
|
||||||
- Crashes may happen during an AppImage installation if **AppImageLauncher** is installed. It is advisable to uninstall it and reboot the system before trying to install an application.
|
- Crashes may happen during an AppImage installation if **AppImageLauncher** is installed. It is advisable to uninstall it and reboot the system before trying to install an application.
|
||||||
- All supported application names can be found at [apps.txt](https://github.com/vinifmor/bauh-files/blob/master/appimage/apps.txt)
|
- All supported application names can be found at [apps.txt](https://github.com/vinifmor/bauh-files/blob/master/appimage/apps.txt)
|
||||||
|
- Applications with ignored updates are defined at **~/.config/bauh/appimage/updates_ignored.txt**
|
||||||
- The configuration file is located at **~/.config/bauh/appimage.yml** and it allows the following customizations:
|
- The configuration file is located at **~/.config/bauh/appimage.yml** and it allows the following customizations:
|
||||||
```
|
```
|
||||||
db_updater:
|
db_updater:
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ LOCAL_PATH = '{}/.local/share/bauh/appimage'.format(str(Path.home()))
|
|||||||
INSTALLATION_PATH = LOCAL_PATH + '/installed/'
|
INSTALLATION_PATH = LOCAL_PATH + '/installed/'
|
||||||
SUGGESTIONS_FILE = 'https://raw.githubusercontent.com/vinifmor/bauh-files/master/appimage/suggestions.txt'
|
SUGGESTIONS_FILE = 'https://raw.githubusercontent.com/vinifmor/bauh-files/master/appimage/suggestions.txt'
|
||||||
CONFIG_FILE = '{}/appimage.yml'.format(CONFIG_PATH)
|
CONFIG_FILE = '{}/appimage.yml'.format(CONFIG_PATH)
|
||||||
|
CONFIG_DIR = '{}/appimage'.format(CONFIG_PATH)
|
||||||
|
UPDATES_IGNORED_FILE = '{}/updates_ignored.txt'.format(CONFIG_DIR)
|
||||||
|
|
||||||
|
|
||||||
def get_icon_path() -> str:
|
def get_icon_path() -> str:
|
||||||
|
|||||||
@@ -27,7 +27,8 @@ from bauh.commons import resource
|
|||||||
from bauh.commons.config import save_config
|
from bauh.commons.config import save_config
|
||||||
from bauh.commons.html import bold
|
from bauh.commons.html import bold
|
||||||
from bauh.commons.system import SystemProcess, new_subprocess, ProcessHandler, run_cmd, SimpleProcess
|
from bauh.commons.system import SystemProcess, new_subprocess, ProcessHandler, run_cmd, SimpleProcess
|
||||||
from bauh.gems.appimage import query, INSTALLATION_PATH, LOCAL_PATH, SUGGESTIONS_FILE, CONFIG_FILE, ROOT_DIR
|
from bauh.gems.appimage import query, INSTALLATION_PATH, LOCAL_PATH, SUGGESTIONS_FILE, CONFIG_FILE, ROOT_DIR, \
|
||||||
|
CONFIG_DIR, UPDATES_IGNORED_FILE
|
||||||
from bauh.gems.appimage.config import read_config
|
from bauh.gems.appimage.config import read_config
|
||||||
from bauh.gems.appimage.model import AppImage
|
from bauh.gems.appimage.model import AppImage
|
||||||
from bauh.gems.appimage.worker import DatabaseUpdater
|
from bauh.gems.appimage.worker import DatabaseUpdater
|
||||||
@@ -235,6 +236,13 @@ class AppImageManager(SoftwareManager):
|
|||||||
if not connection:
|
if not connection:
|
||||||
self._close_connection(DB_APPS_PATH, con)
|
self._close_connection(DB_APPS_PATH, con)
|
||||||
|
|
||||||
|
ignored_updates = self._read_ignored_updates()
|
||||||
|
|
||||||
|
if ignored_updates:
|
||||||
|
for app in res.installed:
|
||||||
|
if app.supports_ignored_updates() and app.name in ignored_updates:
|
||||||
|
app.updates_ignored = True
|
||||||
|
|
||||||
res.total = len(res.installed)
|
res.total = len(res.installed)
|
||||||
return res
|
return res
|
||||||
|
|
||||||
@@ -684,3 +692,47 @@ class AppImageManager(SoftwareManager):
|
|||||||
to_update.append(requirement)
|
to_update.append(requirement)
|
||||||
|
|
||||||
return UpgradeRequirements([], [], to_update, [])
|
return UpgradeRequirements([], [], to_update, [])
|
||||||
|
|
||||||
|
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 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:
|
||||||
|
current_ignored.add(pkg.name)
|
||||||
|
self._write_ignored_updates(current_ignored)
|
||||||
|
|
||||||
|
pkg.updates_ignored = True
|
||||||
|
|
||||||
|
def _write_ignored_updates(self, names: Set[str]):
|
||||||
|
ignored_list = [*names]
|
||||||
|
ignored_list.sort()
|
||||||
|
|
||||||
|
with open(UPDATES_IGNORED_FILE, 'w+') as f:
|
||||||
|
for ignored in ignored_list:
|
||||||
|
f.write('{}\n'.format(ignored))
|
||||||
|
|
||||||
|
def revert_ignored_update(self, pkg: AppImage):
|
||||||
|
current_ignored = self._read_ignored_updates()
|
||||||
|
|
||||||
|
if current_ignored and pkg.name in current_ignored:
|
||||||
|
current_ignored.remove(pkg.name)
|
||||||
|
|
||||||
|
self._write_ignored_updates(current_ignored)
|
||||||
|
|
||||||
|
pkg.updates_ignored = False
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ class AppImage(SoftwarePackage):
|
|||||||
url_download: str = None, url_icon: str = None, url_screenshot: str = None, license: str = None, author: str = None,
|
url_download: str = None, url_icon: str = None, url_screenshot: str = None, license: str = None, author: str = None,
|
||||||
categories=None, icon_path: str = None, installed: bool = False,
|
categories=None, icon_path: str = None, installed: bool = False,
|
||||||
url_download_latest_version: str = None, local_file_path: str = None, imported: bool = False,
|
url_download_latest_version: str = None, local_file_path: str = None, imported: bool = False,
|
||||||
i18n: I18n = None, install_dir: str = None, custom_actions: List[CustomSoftwareAction] = None, **kwargs):
|
i18n: I18n = None, install_dir: str = None, custom_actions: List[CustomSoftwareAction] = None, updates_ignored: bool = False, **kwargs):
|
||||||
super(AppImage, self).__init__(id=name, name=name, version=version, latest_version=version,
|
super(AppImage, self).__init__(id=name, name=name, version=version, latest_version=version,
|
||||||
icon_url=url_icon, license=license, description=description,
|
icon_url=url_icon, license=license, description=description,
|
||||||
installed=installed)
|
installed=installed)
|
||||||
@@ -32,6 +32,7 @@ class AppImage(SoftwarePackage):
|
|||||||
self.i18n = i18n
|
self.i18n = i18n
|
||||||
self.install_dir = install_dir
|
self.install_dir = install_dir
|
||||||
self.custom_actions = custom_actions
|
self.custom_actions = custom_actions
|
||||||
|
self.updates_ignored = updates_ignored
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "{} (name={}, github={})".format(self.__class__.__name__, self.name, self.github)
|
return "{} (name={}, github={})".format(self.__class__.__name__, self.name, self.github)
|
||||||
@@ -107,3 +108,9 @@ class AppImage(SoftwarePackage):
|
|||||||
|
|
||||||
def supports_backup(self) -> bool:
|
def supports_backup(self) -> bool:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def supports_ignored_updates(self) -> bool:
|
||||||
|
return self.installed and not self.imported
|
||||||
|
|
||||||
|
def is_update_ignored(self) -> bool:
|
||||||
|
return self.updates_ignored
|
||||||
|
|||||||
Reference in New Issue
Block a user