checked dependencies, made some optional, document optional dependencies

This commit is contained in:
fatalerrors
2026-06-02 17:49:16 +02:00
parent f0c62a5e7f
commit 462efef034
5 changed files with 78 additions and 13 deletions

View File

@@ -445,15 +445,49 @@ Verify support with:
printf '\e[38;2;38;139;210mTrue colour test\e[0m\n' printf '\e[38;2;38;139;210mTrue colour test\e[0m\n'
``` ```
## 5. Contact and more information ## 5. Optional dependencies
### 5.1. New users profile is designed so that every external dependency is optional: all features
degrade gracefully (an error message is shown and the specific function returns
early) when a binary is absent. The table below lists packages that are **not**
part of a standard minimal Linux installation (might differ from your actual
distribution, some are still extremely common). Nothing in this list is required
to load profile or use its core functions.
| Binary | Typical package name | Distr. | Function(s) | Behaviour when absent |
| --- | --- | --- | --- | --- |
| `figlet` | `figlet` | all | `showinfo` | ASCII banner skipped |
| `neofetch` | `neofetch` | all | `showinfo` | Falls back to `fastfetch`, then skipped |
| `fastfetch` | `fastfetch` | all | `showinfo` | Falls back if `neofetch` absent; then skipped |
| `jq` | `jq` | all | `myextip` | Raw JSON shown instead of formatted output |
| `hexdump` | `util-linux` / `bsdmainutils` | all | `busy` | Error message, function returns 1 |
| `numfmt` | `coreutils` ≥ 8.21 | all | `file_stats --min/--max` | Error message, function returns 1 |
| `envsubst` | `gettext` | all | config loading | `$VAR` references in `profile.conf` values left literal |
| `killall` | `psmisc` | all | `ku` | Falls back to `pkill` (procps); error if both absent |
| `pkill` / `pgrep` | `procps` / `procps-ng` | all | `ku`, `ppg`, `gpid` | `ku` falls back to `killall`; `ppg`/`gpid` fall back to `ps + awk` |
| `pigz` | `pigz` | all | `taz` (gzip) | Falls back to `gzip` (slower, single-thread) |
| `plzip` | `plzip` | all | `taz` (lzip) | Falls back to `lzip` |
| `lzip` / `plzip` | `lzip` | all | `taz`/`utaz` (.lz) | Error message if neither is available |
| `xz` | `xz-utils` / `xz` | all | `taz`/`utaz` (.xz) | Error message |
| `unrar` | `unrar` / `unrar-free` | all | `utaz` (.rar) | Error message |
| `unarj` | `arj` | all | `utaz` (.arj) | Error message |
| `lha` | `lhasa` | all | `utaz` (.lzh) | Error message |
| `unace` | `unace` | all | `utaz` (.ace) | Error message |
| `7z` | `p7zip-full` | all | `taz`/`utaz` (.7z) | Error message |
| `cabextract` | `cabextract` | all | `utaz` (.cab) | Error message |
| `rpm2cpio` | `rpm` | all | `utaz` (.rpm) | Error message |
| `nix-locate` | `nix-index` | NixOS | `pkgf` | Error: unsupported package manager |
| `qfile` | `gentoolkit` | Gentoo | `pkgf` | Error: unsupported package manager |
## 6. Contact and more information
### 6.1. New users
If you use (or plan to use) `profile`, I'll be happy if you simply mail me to If you use (or plan to use) `profile`, I'll be happy if you simply mail me to
let me know, especially if you don't plan to contribute. If you plan to let me know, especially if you don't plan to contribute. If you plan to
contribute, I'll be twice happier for sure! contribute, I'll be twice happier for sure!
### 5.2. Bugs ### 6.2. Bugs
**profile** bug tracker is hosted on its Gitea instance. Check the **profile** bug tracker is hosted on its Gitea instance. Check the
<https://git.geoffray-levasseur.org/fatalerrors/profile> page. If you find a bug, <https://git.geoffray-levasseur.org/fatalerrors/profile> page. If you find a bug,
@@ -468,7 +502,7 @@ have not tested the same code under a real Unix environment.
Check the [FAQ](./doc/FAQ.md) and the [to-do list](./doc/todo.md) before Check the [FAQ](./doc/FAQ.md) and the [to-do list](./doc/todo.md) before
sending any feature request or bug report, as it might already be documented. sending any feature request or bug report, as it might already be documented.
### 5.3. How to contribute? ### 6.3. How to contribute?
You are free to improve and contribute as you wish. If you have no idea what to You are free to improve and contribute as you wish. If you have no idea what to
do or want some direction, you can check the [to-do list](./doc/todo.md), do or want some direction, you can check the [to-do list](./doc/todo.md),

View File

@@ -471,6 +471,12 @@ file_stats()
fi fi
# Minimum/maximum size filters (evaluated in bytes) # Minimum/maximum size filters (evaluated in bytes)
if [[ -n "$min_size" || -n "$max_size" ]]; then
if ! command -v numfmt >/dev/null 2>&1; then
disp E "file_stats: --min/--max require 'numfmt' (GNU coreutils). Please install it."
return 1
fi
fi
if [[ -n "$min_size" ]]; then if [[ -n "$min_size" ]]; then
find_cmd+=(-size +"$(numfmt --from=iec "$min_size")"c) find_cmd+=(-size +"$(numfmt --from=iec "$min_size")"c)
fi fi

View File

@@ -94,6 +94,11 @@ busy()
delay_s=$(awk "BEGIN{ delay_s=$(awk "BEGIN{
printf \"%.3f\", $delay_ms / 1000 }") printf \"%.3f\", $delay_ms / 1000 }")
command -v hexdump >/dev/null 2>&1 || {
disp E "busy: 'hexdump' is required but not installed (util-linux or bsdmainutils)."
return 1
}
# Monitor /dev/urandom # Monitor /dev/urandom
( (
hexdump -C < /dev/urandom | grep -iF --line-buffered "$pattern" | \ hexdump -C < /dev/urandom | grep -iF --line-buffered "$pattern" | \

View File

@@ -199,7 +199,7 @@ export -f ppn
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Get PID list of the given process name # Get PID list of the given process name
# Usage: ppid <process_name [process_name2 ...]> # Usage: gpid <process_name [process_name2 ...]>
gpid() gpid()
{ {
local PARSED local PARSED
@@ -361,16 +361,33 @@ ku()
disp E "User '$u' does not exist." disp E "User '$u' does not exist."
return 1 return 1
else else
local cmd=(killall) local cmd
if [[ ${#signal_opt[@]} -gt 0 ]]; then # killall (psmisc) preferred; fall back to pkill (procps-ng).
cmd+=("${signal_opt[@]}") if command -v killall >/dev/null 2>&1; then
elif [[ -n "${KU_DEFAULT_SIGNAL:-}" ]]; then cmd=(killall)
cmd+=("-${KU_DEFAULT_SIGNAL}") if [[ ${#signal_opt[@]} -gt 0 ]]; then
cmd+=("${signal_opt[@]}")
elif [[ -n "${KU_DEFAULT_SIGNAL:-}" ]]; then
cmd+=("-${KU_DEFAULT_SIGNAL}")
fi
cmd+=(-u "$u")
elif command -v pkill >/dev/null 2>&1; then
cmd=(pkill)
# Translate killall's -s SIGNAME form to pkill's -SIGNAME form.
if [[ ${#signal_opt[@]} -eq 2 && "${signal_opt[0]}" == "-s" ]]; then
cmd+=("-${signal_opt[1]}")
elif [[ ${#signal_opt[@]} -gt 0 ]]; then
cmd+=("${signal_opt[@]}")
elif [[ -n "${KU_DEFAULT_SIGNAL:-}" ]]; then
cmd+=("-${KU_DEFAULT_SIGNAL}")
fi
cmd+=(-u "$u")
else
disp E "ku: neither 'killall' (psmisc) nor 'pkill' (procps) is available."
return 1
fi fi
cmd+=(-u "$u")
if (( dry_run )); then if (( dry_run )); then
printf "DRY-RUN: " printf "DRY-RUN: "
printf "%q " "${cmd[@]}" printf "%q " "${cmd[@]}"

View File

@@ -244,7 +244,10 @@ parse_conf()
# Correctly interpretet internal variables (e.g. $HOME) # Correctly interpretet internal variables (e.g. $HOME)
if [[ "$value" == *\$* ]]; then if [[ "$value" == *\$* ]]; then
value=$(envsubst <<< "$value") if command -v envsubst >/dev/null 2>&1; then
value=$(envsubst <<< "$value")
fi
# If envsubst is unavailable, $VAR references are left as-is.
fi fi
# Strip quotes (handling both " and ') # Strip quotes (handling both " and ')