[appimage] new config file

This commit is contained in:
Vinícius Moreira
2019-12-19 15:10:27 -03:00
parent 894e2d9988
commit 86bb1b55d6
5 changed files with 62 additions and 32 deletions

View File

@@ -14,9 +14,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
### Improvements
- AppImage:
- cleaning the downloaded database files when **--reset** is passed as parameter
- environment variables **BAUH_APPIMAGE_DB_UPDATER** and **BAUH_APPIMAGE_DB_UPDATER_TIME** dropped in favor of the new configuration file located at **~/.config/bauh/appimage.yml**
- AUR:
- The AUR indexer daemon is not running every 20 minutes anymore. It will only run during the boot, and will generate the optimized index
at **/tmp/bauh/arch/aur.txt**. This new behavior does not harm the current experience, and reduces memory usage. More information about this behavior in [README](https://github.com/vinifmor/bauh/blob/master/README.md).
- Environment variable **BAUH_ARCH_AUR_INDEX_UPDATER** dropped in favor of the behavior described above.
- Environment variables **BAUH_ARCH_OPTIMIZE** and **BAUH_ARCH_CHECK_SUBDEPS** dropped in favor of the new configuration file located at **~/.config/bauh/arch.yml**
- Minor memory improvements
### Fixes
- AUR:

View File

@@ -104,21 +104,28 @@ If bauh is not starting properly after changing its style, execute `bauh --reset
#### AppImage ( appimage )
- The user is able to search, install, uninstall, downgrade, launch and retrieve the applications history
- Supported sources: [AppImageHub](https://appimage.github.io) ( **applications with no releases published to GitHub are currently not available** )
- Faster downloads if **aria2c** is installed. Same behavior described in the **AUR support** section.
- Installed applications are store at **~/.local/share/bauh/appimage/installed**
- Desktop entries ( menu shortcuts ) of the installed applications are stored at **~/.local/share/applications**
- Downloaded database files are stored at **~/.local/share/bauh/appimage** as **apps.db** and **releases.db**
- Databases updater daemon running every 20 minutes ( the interval in SECONDS can be changed with the environment variable **BAUH_APPIMAGE_DB_UPDATER_TIME** ). It can be disabled via the environment variable **BAUH_APPIMAGE_DB_UPDATER=0**.
- Databases are always updated when bauh starts
- 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.
- All supported application names can be found at: https://github.com/vinifmor/bauh-files/blob/master/appimage/apps.txt
Obs: There are some crashes when **AppImageLauncher** is installed. It is advisable to uninstall it and reboot the system before trying to install an AppImage application.
- The configuration file is located at **~/.config/bauh/appimage.yml** and it allows the following customizations:
```
db_updater:
enabled: true # if 'false': disables the daemon database updater ( bauh will not be able to see if there are updates for your already installed AppImages )
interval: 1200 # the databases update interval in SECONDS ( 1200 == 20 minutes )
```
- Required dependencies
- Arch-based systems: **sqlite**, **wget** ( or **aria2** for faster multi-threaded downloads )
- Debian-based systems: **sqlite3**, **wget** ( or **aria2** for faster multi-threaded downloads )
- **aria2 will only be used if the multi-threaded download settings are enabled**
#### AUR ( arch )
- Only available for Arch-based systems
- The user is able to search, install, uninstall, downgrade, launch and retrieve the packages history
- The user is able to search, install, uninstall, downgrade, launch and retrieve packages history
- It handles conflicts, and missing / optional packages installations ( including from your distro mirrors )
- If [**aria2**](https://github.com/aria2/aria2) is installed on your system and multi-threaded downloads are enabled ( see **BAUH_DOWNLOAD_MULTITHREAD** ), the source packages
will be pre-downloaded faster ( it does **NOT** modify your **pacman** settings ).
- Automatically makes simple package compilation improvements:
a) if **MAKEFLAGS** is not set in **/etc/makepkg.conf**,
@@ -132,15 +139,15 @@ will be pre-downloaded faster ( it does **NOT** modify your **pacman** settings
- If some of your installed packages are not categorized, send an e-mail to **bauh4linux@gmail.com** informing their names and categories in the following format: ```name=category1[,category2,category3,...]```
- The configuration file is located at **~/.config/bauh/arch.yml** and it allows the following customizations:
```
optimize: true # if false: disables the auto-compilation improvements
transitive_checking: true # if false: the dependency checking process will be faster, but the application will ask for a confirmation every time a not installed dependency is detected.
optimize: true # if 'false': disables the auto-compilation improvements
transitive_checking: true # if 'false': the dependency checking process will be faster, but the application will ask for a confirmation every time a not installed dependency is detected.
```
- Required dependencies:
- **pacman**
- **wget**
- Optional dependencies:
- **git**: allows to retrieve packages release history and downgrading
- **aria2**: provides faster and multi-threaded downloads
- **aria2**: provides faster, multi-threaded downloads for required source files ( if the param )
#### Web Applications ( web )
- It allows the installation of native Web applications by typing an address / URL in the search bar.
@@ -165,8 +172,8 @@ environment:
system: false # set it to 'true' if you want to use the nativefier version globally installed on your system
```
- Required dependencies:
- Arch systems: **python-lxml**, **python-beautifulsoup4**
- Debian systems ( using pip ): **beautifulsoup4**, **lxml**
- Arch-based systems: **python-lxml**, **python-beautifulsoup4**
- Debian-based systems ( using pip ): **beautifulsoup4**, **lxml**
### General settings
You can change some application settings via environment variables or arguments (type ```bauh --help``` to get more information).

View File

@@ -0,0 +1,12 @@
from bauh.api.constants import CONFIG_PATH
from bauh.commons.config import read_config as read
def read_config(update_file: bool = False) -> dict:
default = {
'db_updater': {
'interval': 60 * 20,
'enabled': True
}
}
return read('{}/appimage.yml'.format(CONFIG_PATH), default, update_file=update_file)

View File

@@ -8,7 +8,7 @@ import subprocess
import traceback
from datetime import datetime
from pathlib import Path
from threading import Lock
from threading import Lock, Thread
from typing import Set, Type, List
from colorama import Fore
@@ -23,6 +23,7 @@ from bauh.api.constants import HOME_PATH
from bauh.commons.html import bold
from bauh.commons.system import SystemProcess, new_subprocess, ProcessHandler, run_cmd, SimpleProcess
from bauh.gems.appimage import query, INSTALLATION_PATH, suggestions, LOCAL_PATH
from bauh.gems.appimage.config import read_config
from bauh.gems.appimage.model import AppImage
from bauh.gems.appimage.worker import DatabaseUpdater
@@ -48,7 +49,6 @@ class AppImageManager(SoftwareManager):
self.logger = context.logger
self.file_downloader = context.file_downloader
self.db_locks = {DB_APPS_PATH: Lock(), DB_RELEASES_PATH: Lock()}
self.dbs_updater = DatabaseUpdater(http_client=context.http_client, logger=context.logger, db_locks=self.db_locks)
def _get_db_connection(self, db_path: str) -> sqlite3.Connection:
if os.path.exists(db_path):
@@ -387,8 +387,19 @@ class AppImageManager(SoftwareManager):
def requires_root(self, action: str, pkg: AppImage):
return False
def _start_updater(self):
local_config = read_config(update_file=True)
interval = local_config['db_updater']['interval'] or 20 * 60
updater = DatabaseUpdater(http_client=self.context.http_client, logger=self.context.logger,
db_locks=self.db_locks, interval=interval)
if local_config['db_updater']['enabled']:
updater.start()
else:
updater.download_databases() # only once
def prepare(self):
self.dbs_updater.start()
Thread(target=self._start_updater()).start()
def list_updates(self, internet_available: bool) -> List[PackageUpdate]:
res = self.read_installed(disk_loader=None, internet_available=internet_available)

View File

@@ -15,19 +15,24 @@ from bauh.gems.appimage import LOCAL_PATH
class DatabaseUpdater(Thread):
URL_DB = 'https://raw.githubusercontent.com/vinifmor/bauh-files/master/appimage/dbs.tar.gz'
COMPRESS_FILE_PATH = LOCAL_PATH + '/db.tar.gz'
def __init__(self, http_client: HttpClient, logger: logging.Logger, db_locks: dict):
def __init__(self, http_client: HttpClient, logger: logging.Logger, db_locks: dict, interval: int):
super(DatabaseUpdater, self).__init__(daemon=True)
self.http_client = http_client
self.logger = logger
self.enabled = bool(int(os.getenv('BAUH_APPIMAGE_DB_UPDATER', 1)))
self.db_locks = db_locks
self.sleep = int(os.getenv('BAUH_APPIMAGE_DB_UPDATER_TIME', 60 * 20))
self.sleep = interval
def download_databases(self):
try:
if not internet.is_available(self.http_client, self.logger):
return
except requests.exceptions.ConnectionError:
self.logger.warning('The internet connection seems to be off.')
return
def _download_databases(self):
self.logger.info('Retrieving AppImage databases')
res = self.http_client.get(self.URL_DB)
@@ -71,15 +76,7 @@ class DatabaseUpdater(Thread):
self.logger.warning('Could not download the database file {}'.format(self.URL_DB))
def run(self):
if self.enabled:
while True:
try:
if internet.is_available(self.http_client, self.logger):
self._download_databases()
except requests.exceptions.ConnectionError:
self.logger.warning('The internet connection seems to be off.')
self.logger.info('Sleeping')
time.sleep(self.sleep)
else:
self.logger.warning('AppImage database updater disabled')
while True:
self.download_databases()
self.logger.info('Sleeping')
time.sleep(self.sleep)