diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0b7f5c37..b336967a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,6 +6,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
## [0.9.23]
### Features
+- General
+ - new configuration file `/etc/bauh/gems.forbidden` can be used by system administrators/distribution package managers to disable the management of supported packaging formats globally (more on that [here](https://github.com/vinifmor/bauh#forbidden_gems))
+
- Arch
- allowing AUR packages to be installed when bauh is launched by the root user [#196](https://github.com/vinifmor/bauh/issues/196)
- it creates a non-root user called **bauh-aur** for building the packages (`useradd` and `runuser` commands must be installed)
diff --git a/README.md b/README.md
index 987ea0d3..4eeb4b29 100644
--- a/README.md
+++ b/README.md
@@ -15,22 +15,23 @@ Key features
## Index
-1. [Installation](#installation)
+1. [Installation](#installation)
- [Ubuntu-based distros (20.04)](#inst_ubuntu)
- [Arch-based distros](#inst_arch)
-2. [Isolated installation](#inst_iso)
-3. [Desktop entry / menu shortcut](#desk_entry)
-4. [Autostart: tray mode](#autostart)
-5. [Distribution](#dist)
-6. [Supported types](#types)
+2. [Isolated installation](#inst_iso)
+3. [Desktop entry / menu shortcut](#desk_entry)
+4. [Autostart: tray mode](#autostart)
+5. [Distribution](#dist)
+6. [Supported types](#types)
- [AppImage](#type_appimage)
- [Arch packages/AUR](#type_arch)
- [Flatpak](#type_flatpak)
- [Snap](#type_snap)
- [Native Web applications](#type_web)
-7. [General settings](#settings)
-8. [Directory structure, caching and logs](#dirs)
-9. [Custom themes](#custom_themes)
+7. [General settings](#settings)
+ - [Forbidden packaging formats](#forbidden_gems)
+8. [Directory structure, caching and logs](#dirs)
+9. [Custom themes](#custom_themes)
10. [Tray icons](#tray_icons)
11. [CLI (Command Line Interface)](#cli)
12. [Improving performance](#performance)
@@ -413,6 +414,16 @@ boot:
load_apps: true # if the installed applications or suggestions should be loaded on the management panel after the initialization process. Default: true.
```
+##### Forbidden packaging formats
+- System administrators and package managers of Linux distributions can disable the usage/management of supported packaging formats
+by adding their ids to the file `/etc/bauh/gems.forbidden`. This will prevent their management code to be loaded.
+- Example (one id per line):
+```
+arch
+appimage
+# flatpak # 'sharps' can be used to ignore a given line (comment)
+```
+
#### 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.
diff --git a/bauh/cli/app.py b/bauh/cli/app.py
index d5ffd7fd..468da1c3 100644
--- a/bauh/cli/app.py
+++ b/bauh/cli/app.py
@@ -49,7 +49,8 @@ def main():
internet_checker=InternetChecker(offline=False),
root_user=user.is_root())
- managers = gems.load_managers(context=context, locale=i18n.current_key, config=app_config, default_locale=DEFAULT_I18N_KEY)
+ managers = gems.load_managers(context=context, locale=i18n.current_key, config=app_config,
+ default_locale=DEFAULT_I18N_KEY, logger=logger)
cli = CLIManager(GenericSoftwareManager(managers, context=context, config=app_config))
diff --git a/bauh/manage.py b/bauh/manage.py
index 14458a17..2a4ea28b 100644
--- a/bauh/manage.py
+++ b/bauh/manage.py
@@ -45,7 +45,8 @@ def new_manage_panel(app_args: Namespace, app_config: dict, logger: logging.Logg
internet_checker=InternetChecker(offline=app_args.offline),
root_user=user.is_root())
- managers = gems.load_managers(context=context, locale=i18n.current_key, config=app_config, default_locale=DEFAULT_I18N_KEY)
+ managers = gems.load_managers(context=context, locale=i18n.current_key, config=app_config,
+ default_locale=DEFAULT_I18N_KEY, logger=logger)
if app_args.reset:
util.clean_app_files(managers)
diff --git a/bauh/view/core/gems.py b/bauh/view/core/gems.py
index 70014c1c..334f8592 100644
--- a/bauh/view/core/gems.py
+++ b/bauh/view/core/gems.py
@@ -1,12 +1,15 @@
import inspect
import os
import pkgutil
-from typing import List
+from logging import Logger
+from typing import List, Generator
-from bauh import ROOT_DIR
+from bauh import __app_name__, ROOT_DIR
from bauh.api.abstract.controller import SoftwareManager, ApplicationContext
from bauh.view.util import translation
+FORBIDDEN_GEMS_FILE = f'/etc/{__app_name__}/gems.forbidden'
+
def find_manager(member):
if not isinstance(member, str):
@@ -19,11 +22,33 @@ def find_manager(member):
return manager_found
-def load_managers(locale: str, context: ApplicationContext, config: dict, default_locale: str) -> List[SoftwareManager]:
+def read_forbidden_gems() -> Generator[str, None, None]:
+ try:
+ with open(FORBIDDEN_GEMS_FILE) as f:
+ forbidden_lines = f.readlines()
+
+ for line in forbidden_lines:
+ clean_line = line.strip()
+
+ if clean_line and not clean_line.startswith('#'):
+ yield clean_line
+
+ except FileNotFoundError:
+ pass
+
+
+def load_managers(locale: str, context: ApplicationContext, config: dict, default_locale: str, logger: Logger) -> List[SoftwareManager]:
managers = []
+ forbidden_gems = {gem for gem in read_forbidden_gems()}
+
for f in os.scandir(f'{ROOT_DIR}/gems'):
if f.is_dir() and f.name != '__pycache__':
+
+ if f.name in forbidden_gems:
+ logger.warning(f"gem '{f.name}' could not be loaded because it was marked as forbidden in '{FORBIDDEN_GEMS_FILE}'")
+ continue
+
loader = pkgutil.find_loader(f'bauh.gems.{f.name}.controller')
if loader: