Skip to content

Commit

Permalink
0.9.22
Browse files Browse the repository at this point in the history
  • Loading branch information
vinifmor authored Nov 30, 2021
2 parents a523cd9 + e96fa2d commit 68ae349
Show file tree
Hide file tree
Showing 85 changed files with 1,014 additions and 477 deletions.
54 changes: 54 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,60 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## [0.9.22] 2021-11-30
### Improvements
- 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)
- autostart: `/etc/xdg/autostart` (only used by the Web gem at the moment)
- desktop entries: `/usr/share/applications`
- custom themes: `/usr/share/bauh/themes`
- symlinks/binaries : `/usr/local/bin`
- shared files: `/usr/local/share/bauh`
- adding the `XDG_RUNTIME_DIR` environment variable if not available (following the pattern `/run/user/$UID`)
- refactorings related to String formatting
- refactorings related to shared information
- useless code removed

- UI
- settings panel:
- always displaying all supported packaging technologies
- displaying a tooltip with the missing dependencies for a supported packaging technology
<p align="center">
<img src="https://raw.githubusercontent.com/vinifmor/bauh-files/master/pictures/releases/0.9.22/missing_type_dep.png">
</p>

- AppImage
- faster reading of installed applications (subprocess call replaced by Python call)

- Flatpak
- settings: not displaying the installation target option when bauh is launched by the **root** user
- always considering **system** as the installation level for the **root** user

- Web
- the Electron builds cache directory has been moved to the environment directory `~/.local/share/bauh/web/env/electron`
- letting the Electron client to download the Electron build file instead of bauh (to avoid wrong caching paths)

### Fixes
- General
- single thread downloader (**wget**) does not create the directory where the file will be stored

- AppImage
- trying to download a file without a URL associated with [#210](https://github.com/vinifmor/bauh/issues/210)
- regressions:
- not able to import AppImage files (introduced in **0.9.21**)
- not able to upgrade imported AppImage files (introduced in **0.9.21**)

- Arch
- **wget** as a hard requirement for Arch package management

- UI
- settings panel:
- not re-enabling the action buttons when a validation error is displayed


## [0.9.21] 2021-11-20
### Fixes
- General
Expand Down
36 changes: 19 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Key features
- [Snap](#type_snap)
- [Native Web applications](#type_web)
7. [General settings](#settings)
8. [Cache and logs](#cache_logs)
8. [Directory structure, caching and logs](#dirs)
9. [Custom themes](#custom_themes)
10. [Tray icons](#tray_icons)
11. [CLI (Command Line Interface)](#cli)
Expand Down Expand Up @@ -154,7 +154,7 @@ rm -rf bauh_env` (just remove the directory)

To create a shortcut for bauh on your desktop menu:

- Copy the files from [bauh/desktop](https://raw.githubusercontent.com/vinifmor/bauh/master/bauh/desktop/bauh.desktop) to `~/.local/share/applications`
- Copy the files from [bauh/desktop](https://raw.githubusercontent.com/vinifmor/bauh/master/bauh/desktop/bauh.desktop) to `~/.local/share/applications` (or `/usr/share/applications` for **root**)
- Replace the `Exec` field on theses files by the bauh binary path. e.g: `Exec=/usr/bin/bauh` (or `bauh_env/bin/bauh`)
- Copy [logo.svg](https://raw.githubusercontent.com/vinifmor/bauh/master/bauh/view/resources/img/logo.svg) to `/usr/share/icons/hicolor/scalable/apps` as `bauh.svg`

Expand Down Expand Up @@ -191,13 +191,14 @@ bauh is officially distributed through [PyPi](https://pypi.org/project/bauh) and
- `Upgrade file`: allows to upgrade a manually installed AppImage file
- `Update database`: manually synchronize the AppImage database

- Installed applications are store at `~/.local/share/bauh/appimage/installed`
- Desktop entries (menu shortcuts) of the installed applications are stored at **~/.local/share/applications** (name pattern: `bauh_appimage_appname.desktop`)
- Symlinks are created at **~/.local/bin**. They have the same name of the application (if the name already exists, it will be created as 'app_name-appimage'. e.g: `rpcs3-appimage`)
- Downloaded database files are stored at **~/.cache/bauh/appimage** as **apps.db** and **releases.db**
- Installed applications are store at `~/.local/share/bauh/appimage/installed` (or `/usr/local/share/bauh/installed` for **root**)
- Desktop entries (menu shortcuts) of the installed applications are stored at `~/.local/share/applications` (or `/usr/share/applications` for **root**). Name pattern: `bauh_appimage_appname.desktop`
- Symlinks are created at `~/.local/bin` (or `/usr/local/bin` for **root**). They have the same name of the application (if the name already exists, it will be created as 'app_name-appimage'. e.g: `rpcs3-appimage`)
- Downloaded database files are stored at `~/.cache/bauh/appimage` (or `/var/cache/bauh/appimage` for **root**) as **apps.db** and **releases.db**
- Databases are updated during the initialization process if they are considered outdated
- 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` (or `/etc/bauh/appimage.yml` for **root**) and it allows the following customizations:
- Applications with ignored updates are defined at `~/.config/bauh/appimage/updates_ignored.txt` (or `/etc/bauh/appimage/updates_ignored.txt` for **root**)

```
database:
expiration: 60 # defines the period (in minutes) in which the database will be considered up to date during the initialization process. Use 0 if you always want to update it. Default: 60.
Expand Down Expand Up @@ -315,15 +316,15 @@ defined at [suggestions.yml](https://raw.githubusercontent.com/vinifmor/bauh-fil


- It relies on [NodeJS](https://nodejs.org/en/), [Electron](https://electronjs.org/) and [nativefier](https://github.com/jiahaog/nativefier) to do all the magic, but you do not need them installed on your system. An isolated installation environment
will be generated at **~/.local/share/bauh/web/env**.
will be generated at `~/.local/share/bauh/web/env` (or `/usr/local/share/bauh/web/env` for **root**).
- It supports DRM protected content through a custom Electron implementation provided by [castLabs](https://github.com/castlabs/electron-releases). nativefier handles the switch between the official Electron and the custom.
- The isolated environment is created based on the settings defined in [environment.yml](https://raw.githubusercontent.com/vinifmor/bauh-files/master/web/env/v1/environment.yml)
(downloaded during runtime).
- Some applications require Javascript fixes to properly work. If there is a known fix, bauh will download the file from [fix](https://github.com/vinifmor/bauh-files/tree/master/web/fix) and
attach it to the generated app.
- The installed applications are located at `~/.local/share/bauh/installed`.
- A desktop entry / menu shortcut will be generated for the installed applications at `~/.local/share/application`
- If the Tray Mode **Start Minimized** is defined during the installation setup, a desktop entry will be also generated at `~/.config/autostart`
- The installed applications are located at `~/.local/share/bauh/installed` (or `/usr/local/share/bauh/web/installed` for **root**).
- A desktop entry / menu shortcut will be generated for the installed applications at `~/.local/share/applications` (or `/usr/share/applications` for **root**)
- If the Tray Mode **Start Minimized** is defined during the installation setup, a desktop entry will be also generated at `~/.config/autostart` (or `/etc/xdg/autostart` for **root**)
allowing the application to launch automatically after the system's boot attached to the tray.

<p align="center">
Expand All @@ -334,7 +335,7 @@ allowing the application to launch automatically after the system's boot attache
- Extra actions
- `Clean installation environment`: removes all the installation environment folders (it does not remove installed apps)

- The configuration file is located at `~/.config/bauh/web.yml` and it allows the following customizations:
- The configuration file is located at `~/.config/bauh/web.yml` (or `/etc/bauh/web.yml` for **root**) and it allows the following customizations:

```
environment:
Expand Down Expand Up @@ -409,13 +410,14 @@ boot:
load_apps: true # if the installed applications or suggestions should be loaded on the management panel after the initialization process. Default: true.
```

#### <a name="cache_logs">Cache and Logs</a>
- Installation logs and temporary files are saved at `/tmp/bauh` (or `/tmp/bauh_root` if you launch it as root)
- Some data about your installed applications are stored in `~/.cache/bauh` to load them faster
#### <a name="dirs">Directory structure, caching and logs</a>
- `~/.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)


#### <a name="custom_themes">Custom themes</a>
- Custom themes can be provided by adding their files at `~/.local/share/bauh/themes` (sub-folders are allowed).
- Custom themes can be provided by adding their files at `~/.local/share/bauh/themes` (or `/usr/share/bauh/themes` for **root**). Sub-folders are allowed.
- Themes are composed by 2 required and 1 optional files sharing the same name:
- `my_theme.qss`: file with the qss rules. Full example: [light.qss](https://github.com/vinifmor/bauh/blob/master/bauh/view/resources/style/light/light.qss)
- `my_theme.meta`: file defining the theme's data. Full example: [light.meta](https://github.com/vinifmor/bauh/blob/master/bauh/view/resources/style/light/light.meta)
Expand Down
3 changes: 1 addition & 2 deletions bauh/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
__version__ = '0.9.21'
__version__ = '0.9.22'
__app_name__ = 'bauh'

import os
ROOT_DIR = os.path.dirname(os.path.abspath(__file__))
LOGS_PATH = '/tmp/{}/logs'.format(__app_name__)
3 changes: 2 additions & 1 deletion bauh/api/abstract/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class ApplicationContext:
def __init__(self, download_icons: bool, http_client: HttpClient, app_root_dir: str, i18n: I18n,
cache_factory: MemoryCacheFactory, disk_loader_factory: DiskCacheLoaderFactory,
logger: logging.Logger, file_downloader: FileDownloader, distro: str, app_name: str,
internet_checker: InternetChecker):
internet_checker: InternetChecker, root_user: bool):
"""
:param download_icons: if packages icons should be downloaded
:param http_client: a shared instance of http client
Expand All @@ -41,6 +41,7 @@ def __init__(self, download_icons: bool, http_client: HttpClient, app_root_dir:
self.default_categories = ('AudioVideo', 'Audio', 'Video', 'Development', 'Education', 'Game',
'Graphics', 'Network', 'Office', 'Science', 'Settings', 'System', 'Utility')
self.app_name = app_name
self.root_user = root_user
self.root_password = None
self.internet_checker = internet_checker

Expand Down
6 changes: 3 additions & 3 deletions bauh/api/abstract/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,9 @@ def set_enabled(self, enabled: bool):
pass

@abstractmethod
def can_work(self) -> bool:
def can_work(self) -> Tuple[bool, Optional[str]]:
"""
:return: if the instance can work based on what is installed in the user's machine.
:return: if the instance can work based on what is installed in the user's machine. If not, an optional string as a reason.
"""

def cache_to_disk(self, pkg: SoftwarePackage, icon_bytes: Optional[bytes], only_icon: bool):
Expand Down Expand Up @@ -368,7 +368,7 @@ def clear_data(self, logs: bool = True):
"""
pass

def get_settings(self, screen_width: int, screen_height: int) -> ViewComponent:
def get_settings(self, screen_width: int, screen_height: int) -> Optional[ViewComponent]:
"""
:param screen_width
:param screen_height
Expand Down
6 changes: 5 additions & 1 deletion bauh/api/abstract/download.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from abc import ABC, abstractmethod
from typing import Iterable, List, Optional
from typing import Iterable, List, Optional, Tuple

from bauh.api.abstract.handler import ProcessWatcher

Expand Down Expand Up @@ -41,3 +41,7 @@ def is_multithreaded_client_available(self, name: str) -> bool:
@abstractmethod
def list_available_multithreaded_clients(self) -> List[str]:
pass

@abstractmethod
def get_supported_clients(self) -> tuple:
pass
4 changes: 2 additions & 2 deletions bauh/api/abstract/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from enum import Enum
from typing import List, Optional

from bauh.api.constants import CACHE_PATH
from bauh.api.paths import CACHE_DIR


class CustomSoftwareAction:
Expand Down Expand Up @@ -146,7 +146,7 @@ def get_disk_cache_path(self):
"""
:return: base cache path for the specific app type
"""
return CACHE_PATH + '/' + self.get_type()
return f'{CACHE_DIR}/{self.get_type()}'

def can_be_updated(self) -> bool:
"""
Expand Down
6 changes: 4 additions & 2 deletions bauh/api/abstract/view.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from abc import ABC
from enum import Enum
from typing import List, Set, Optional
from typing import List, Set, Optional, Dict


class MessageType(Enum):
Expand Down Expand Up @@ -46,13 +46,14 @@ class InputOption:

def __init__(self, label: str, value: object, tooltip: Optional[str] = None,
icon_path: Optional[str] = None, read_only: bool = False, id_: Optional[str] = None,
invalid: bool = False):
invalid: bool = False, extra_properties: Optional[Dict[str, str]] = None):
"""
:param label: the string that will be shown to the user
:param value: the option value (not shown)
:param tooltip: an optional tooltip
:param icon_path: an optional icon path
:param invalid: if this option is considered invalid
:param extra_properties: extra properties
"""
if not label:
raise Exception("'label' must be a not blank string")
Expand All @@ -64,6 +65,7 @@ def __init__(self, label: str, value: object, tooltip: Optional[str] = None,
self.icon_path = icon_path
self.read_only = read_only
self.invalid = invalid
self.extra_properties = extra_properties

def __hash__(self):
return hash(self.label) + hash(self.value)
Expand Down
8 changes: 0 additions & 8 deletions bauh/api/constants.py

This file was deleted.

15 changes: 15 additions & 0 deletions bauh/api/paths.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from getpass import getuser
from pathlib import Path

from bauh import __app_name__
from bauh.api import user

CACHE_DIR = f'/var/cache/{__app_name__}' if user.is_root() else f'{Path.home()}/.cache/{__app_name__}'
CONFIG_DIR = f'/etc/{__app_name__}' if user.is_root() else f'{Path.home()}/.config/{__app_name__}'
USER_THEMES_DIR = f'/usr/share/{__app_name__}/themes' if user.is_root() else f'{Path.home()}/.local/share/{__app_name__}/themes'
DESKTOP_ENTRIES_DIR = '/usr/share/applications' if user.is_root() else f'{Path.home()}/.local/share/applications'
TEMP_DIR = f'/tmp/{__app_name__}@{getuser()}'
LOGS_DIR = f'{TEMP_DIR}/logs'
AUTOSTART_DIR = f'/etc/xdg/autostart' if user.is_root() else f'{Path.home()}/.config/autostart'
BINARIES_DIR = f'/usr/local/bin' if user.is_root() else f'{Path.home()}/.local/bin'
SHARED_FILES_DIR = f'/usr/local/share/{__app_name__}' if user.is_root() else f'{Path.home()}/.local/share/{__app_name__}'
6 changes: 6 additions & 0 deletions bauh/api/user.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import os
from typing import Optional


def is_root(user_id: Optional[int] = None):
return user_id == 0 if user_id is not None else os.getuid() == 0
3 changes: 3 additions & 0 deletions bauh/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ def main(tray: bool = False):
if not os.getenv('PYTHONUNBUFFERED'):
os.environ['PYTHONUNBUFFERED'] = '1'

if not os.getenv('XDG_RUNTIME_DIR'):
os.environ['XDG_RUNTIME_DIR'] = f'/run/user/{os.getuid()}'

faulthandler.enable()
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)

Expand Down
4 changes: 3 additions & 1 deletion bauh/cli/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import urllib3

from bauh import ROOT_DIR
from bauh.api import user
from bauh.api.abstract.context import ApplicationContext
from bauh.api.http import HttpClient
from bauh.cli import __app_name__, cli_args
Expand Down Expand Up @@ -45,7 +46,8 @@ def main():
file_downloader=AdaptableFileDownloader(logger, bool(app_config['download']['multithreaded']),
i18n, http_client, app_config['download']['multithreaded_client']),
app_name=__app_name__,
internet_checker=InternetChecker(offline=False))
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)

Expand Down
4 changes: 2 additions & 2 deletions bauh/commons/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@

import yaml

from bauh.api.constants import CONFIG_PATH
from bauh.api.paths import CONFIG_DIR
from bauh.commons import util


def read_config(file_path: str, template: dict, update_file: bool = False, update_async: bool = False) -> dict:
if not os.path.exists(file_path):
Path(CONFIG_PATH).mkdir(parents=True, exist_ok=True)
Path(CONFIG_DIR).mkdir(parents=True, exist_ok=True)
save_config(template, file_path)
else:
with open(file_path) as f:
Expand Down
16 changes: 12 additions & 4 deletions bauh/commons/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def __init__(self, cmd: List[str], cwd: str = '.', expected_code: int = 0,
global_interpreter: bool = USE_GLOBAL_INTERPRETER, lang: str = DEFAULT_LANG, root_password: str = None,
extra_paths: Set[str] = None, error_phrases: Set[str] = None, wrong_error_phrases: Set[str] = None,
shell: bool = False,
success_phrases: Set[str] = None):
success_phrases: Set[str] = None, extra_env: Optional[Dict[str, str]] = None):
pwdin, final_cmd = None, []

self.shell = shell
Expand All @@ -78,21 +78,29 @@ def __init__(self, cmd: List[str], cwd: str = '.', expected_code: int = 0,

final_cmd.extend(cmd)

self.instance = self._new(final_cmd, cwd, global_interpreter, lang, stdin=pwdin, extra_paths=extra_paths)
self.instance = self._new(final_cmd, cwd, global_interpreter, lang, stdin=pwdin, extra_paths=extra_paths, extra_env=extra_env)
self.expected_code = expected_code
self.error_phrases = error_phrases
self.wrong_error_phrases = wrong_error_phrases
self.success_phrases = success_phrases

def _new(self, cmd: List[str], cwd: str, global_interpreter: bool, lang: str, stdin = None, extra_paths: Set[str] = None) -> subprocess.Popen:
def _new(self, cmd: List[str], cwd: str, global_interpreter: bool, lang: str, stdin = None,
extra_paths: Set[str] = None, extra_env: Optional[Dict[str, str]] = None) -> subprocess.Popen:

env = gen_env(global_interpreter, lang, extra_paths=extra_paths)

if extra_env:
for var, val in extra_env.items():
if var not in env:
env[var] = val

args = {
"stdout": subprocess.PIPE,
"stderr": subprocess.STDOUT,
"stdin": stdin if stdin else subprocess.DEVNULL,
"bufsize": -1,
"cwd": cwd,
"env": gen_env(global_interpreter, lang, extra_paths=extra_paths),
"env": env,
"shell": self.shell
}

Expand Down
5 changes: 0 additions & 5 deletions bauh/commons/user.py

This file was deleted.

Loading

0 comments on commit 68ae349

Please sign in to comment.