From a1683b6a7d0a7835e01fec98a5ae75b3c5547186 Mon Sep 17 00:00:00 2001 From: Vinicius Moreira Date: Wed, 24 Nov 2021 11:56:20 -0300 Subject: [PATCH] [api] refactoring: configuration directory for the root user is now located at '/etc/bauh' --- CHANGELOG.md | 1 + README.md | 1 + bauh/api/paths.py | 2 +- bauh/gems/appimage/__init__.py | 4 ++-- bauh/gems/arch/__init__.py | 2 +- bauh/gems/flatpak/__init__.py | 6 +++--- bauh/gems/snap/__init__.py | 2 +- bauh/gems/web/__init__.py | 2 +- 8 files changed, 11 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index babd800e..30367e5c 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/). - General - directory paths changed for a root user using bauh: - caching: `/var/cache/bauh` + - configuration: `/etc/bauh` - temp dir: `/tmp/bauh@root` (`/tmp/bauh@$USER` for non root users) - UI diff --git a/README.md b/README.md index 4a034453..a12b7d9a 100644 --- a/README.md +++ b/README.md @@ -410,6 +410,7 @@ boot: ``` #### Directory structure, caching and logs +- `~/.config/bauh` (or `/etc/bauh` for **root**): stores configuration files - `~/.cache/bauh` (or `/var/cache/bauh` for **root**): stores data about your installed applications, databases, indexes, etc. Files are stored here to provide a faster initialization and data recovery. - `/tmp/bauh@$USER` (e.g: `/tmp/bauh@root`): stores logging and temporary files (e.g: build dependencies) diff --git a/bauh/api/paths.py b/bauh/api/paths.py index f494c436..2f918c0e 100644 --- a/bauh/api/paths.py +++ b/bauh/api/paths.py @@ -5,7 +5,7 @@ from bauh import __app_name__ from bauh.api import user CACHE_PATH = f'/var/cache/{__app_name__}' if user.is_root() else f'{Path.home()}/.cache/{__app_name__}' -CONFIG_PATH = '{}/.config/bauh'.format(str(Path.home())) +CONFIG_PATH = f'/etc/{__app_name__}' if user.is_root() else f'{Path.home()}/.config/{__app_name__}' USER_THEMES_PATH = '{}/.local/share/bauh/themes'.format(str(Path.home())) DESKTOP_ENTRIES_DIR = '{}/.local/share/applications'.format(str(Path.home())) TEMP_DIR = f'/tmp/{__app_name__}@{getuser()}' diff --git a/bauh/gems/appimage/__init__.py b/bauh/gems/appimage/__init__.py index 50e93377..9534da76 100644 --- a/bauh/gems/appimage/__init__.py +++ b/bauh/gems/appimage/__init__.py @@ -9,8 +9,8 @@ ROOT_DIR = os.path.dirname(os.path.abspath(__file__)) LOCAL_PATH = '{}/.local/share/bauh/appimage'.format(str(Path.home())) INSTALLATION_PATH = LOCAL_PATH + '/installed/' SUGGESTIONS_FILE = 'https://raw.githubusercontent.com/vinifmor/bauh-files/master/appimage/suggestions.txt' -CONFIG_FILE = '{}/appimage.yml'.format(CONFIG_PATH) -CONFIG_DIR = '{}/appimage'.format(CONFIG_PATH) +CONFIG_FILE = f'{CONFIG_PATH}/appimage.yml' +CONFIG_DIR = f'{CONFIG_PATH}/appimage' UPDATES_IGNORED_FILE = '{}/updates_ignored.txt'.format(CONFIG_DIR) SYMLINKS_DIR = '{}/.local/bin'.format(str(Path.home())) URL_COMPRESSED_DATABASES = 'https://raw.githubusercontent.com/vinifmor/bauh-files/master/appimage/dbs.tar.gz' diff --git a/bauh/gems/arch/__init__.py b/bauh/gems/arch/__init__.py index 6f83071a..33801aaf 100644 --- a/bauh/gems/arch/__init__.py +++ b/bauh/gems/arch/__init__.py @@ -14,7 +14,7 @@ CONFIG_DIR = '{}/.config/bauh/arch'.format(str(Path.home())) CUSTOM_MAKEPKG_FILE = '{}/makepkg.conf'.format(CONFIG_DIR) AUR_INDEX_FILE = f'{ARCH_CACHE_PATH}/aur/index.txt' AUR_INDEX_TS_FILE = f'{ARCH_CACHE_PATH}/aur/index.ts' -CONFIG_FILE = '{}/arch.yml'.format(CONFIG_PATH) +CONFIG_FILE = f'{CONFIG_PATH}/arch.yml' SUGGESTIONS_FILE = 'https://raw.githubusercontent.com/vinifmor/bauh-files/master/arch/aur_suggestions.txt' UPDATES_IGNORED_FILE = '{}/updates_ignored.txt'.format(CONFIG_DIR) EDITABLE_PKGBUILDS_FILE = '{}/aur/editable_pkgbuilds.txt'.format(CONFIG_DIR) diff --git a/bauh/gems/flatpak/__init__.py b/bauh/gems/flatpak/__init__.py index 3c3520ad..70096bb5 100644 --- a/bauh/gems/flatpak/__init__.py +++ b/bauh/gems/flatpak/__init__.py @@ -8,9 +8,9 @@ from bauh.commons import resource ROOT_DIR = os.path.dirname(os.path.abspath(__file__)) SUGGESTIONS_FILE = 'https://raw.githubusercontent.com/vinifmor/bauh-files/master/flatpak/suggestions.txt' -CONFIG_FILE = '{}/flatpak.yml'.format(CONFIG_PATH) -CONFIG_DIR = '{}/flatpak'.format(CONFIG_PATH) -UPDATES_IGNORED_FILE = '{}/updates_ignored.txt'.format(CONFIG_DIR) +CONFIG_FILE = f'{CONFIG_PATH}/flatpak.yml' +CONFIG_DIR = f'{CONFIG_PATH}/flatpak' +UPDATES_IGNORED_FILE = f'{CONFIG_DIR}/updates_ignored.txt' EXPORTS_PATH = '{}/.local/share/flatpak/exports/share'.format(str(Path.home())) VERSION_1_2 = parse_version('1.2') VERSION_1_3 = parse_version('1.3') diff --git a/bauh/gems/snap/__init__.py b/bauh/gems/snap/__init__.py index b3009571..d2356f43 100644 --- a/bauh/gems/snap/__init__.py +++ b/bauh/gems/snap/__init__.py @@ -5,7 +5,7 @@ from bauh.commons import resource ROOT_DIR = os.path.dirname(os.path.abspath(__file__)) SNAP_CACHE_PATH = f'{CACHE_PATH}/snap' -CONFIG_FILE = '{}/snap.yml'.format(CONFIG_PATH) +CONFIG_FILE = f'{CONFIG_PATH}/snap.yml' CATEGORIES_FILE_PATH = f'{SNAP_CACHE_PATH}/categories.txt' URL_CATEGORIES_FILE = 'https://raw.githubusercontent.com/vinifmor/bauh-files/master/snap/categories.txt' SUGGESTIONS_FILE = 'https://raw.githubusercontent.com/vinifmor/bauh-files/master/snap/suggestions.txt' diff --git a/bauh/gems/web/__init__.py b/bauh/gems/web/__init__.py index 8ec931c9..09458384 100644 --- a/bauh/gems/web/__init__.py +++ b/bauh/gems/web/__init__.py @@ -31,7 +31,7 @@ TEMP_PATH = f'{TEMP_DIR}/web' SEARCH_INDEX_FILE = f'{WEB_CACHE_PATH}/index.yml' SUGGESTIONS_CACHE_FILE = f'{WEB_CACHE_PATH}/suggestions.yml' SUGGESTIONS_CACHE_TS_FILE = map_timestamp_file(SUGGESTIONS_CACHE_FILE) -CONFIG_FILE = '{}/web.yml'.format(CONFIG_PATH) +CONFIG_FILE = f'{CONFIG_PATH}/web.yml' ENVIRONMENT_SETTINGS_CACHED_FILE = f'{WEB_CACHE_PATH}/environment.yml' ENVIRONMENT_SETTINGS_TS_FILE = f'{WEB_CACHE_PATH}/environment.ts' NATIVEFIER_BASE_URL = 'https://github.com/nativefier/nativefier/archive/v{version}.tar.gz'