container: finance: add dependency checks for modules

Since modules are included upon build type, if a build doesn't support
a feature then that feature's dependencies will not be available.

This commit will give notice of those missing dependencies.
This commit is contained in:
2024-09-16 21:51:59 -07:00
parent 6d0a38f6b5
commit 0b2c76a813
6 changed files with 19 additions and 5 deletions

View File

@@ -201,6 +201,7 @@ function lib_edit::__parse_args()
function lib_edit::__edit()
{
[ -z "$EDITOR" ] && lib_utils::die_fatal
lib_utils::deps_check "$(basename $EDITOR)"
for _type in "${global_arg_type[@]}"; do
case "$_type" in
@@ -247,6 +248,7 @@ function lib_edit::__edit()
[ ! -f "$_path" ] && touch "$_path"
if [[ "$_type" == "iadd" ]]; then
lib_utils::deps_check "hledger-iadd"
hledger-iadd -f "$_path" || lib_utils::die_fatal
fi
@@ -274,6 +276,8 @@ function lib_edit::__edit()
# original file's comments.
local -r _skip="$(grep -E "^//!" $_path | wc -l)"
local -r _args=("--quitguard" "--motd-url" "file:///dev/null" "--filetype" "csv" "--skip" "$_skip" "$_path")
lib_utils::deps_check "visidata"
visidata "${_args[@]}" || lib_utils::die_fatal
# TODO: HACK: visidata saves w/ DOS-style carriage...

View File

@@ -831,17 +831,22 @@ function lib_fetch::__fetch_exec()
#
local _exec=()
[[ "$global_arg_tor" =~ ^on$|^true$ ]] && _exec+=("proxychains") # Wrap with proxychains
if [[ "$global_arg_tor" =~ ^on$|^true$ ]]; then
lib_utils::deps_check "proxychains"
_exec+=("proxychains") # Wrap with proxychains
fi
# Test for Tor plugin
if [ ! -z "${_exec[*]}" ]; then
lib_utils::deps_check "curl"
if ! "${_exec[@]}" curl -s "https://check.torproject.org" &>/dev/null; then
lib_utils::die_fatal "Tor plugin not started (or needs restart)"
fi
fi
# TODO: remove no-limit after internal fetching writes per-paginated instead of per-fetch
_exec+=("/usr/bin/php" "-d" "memory_limit=\"-1\"" "-d" "include_path=\"/usr/local/lib:${_dir}\"")
lib_utils::deps_check "php"
_exec+=("php" "-d" "memory_limit=\"-1\"" "-d" "include_path=\"/usr/local/lib:${_dir}\"")
lib_utils::print_debug "${_exec[@]}"
#

View File

@@ -82,9 +82,8 @@ function lib_ledger::__ledger()
# hledger 1.34, linux-x86_64
# hledger 1.34.99-gcf0c7c2ef-20240702, linux-x86_64
#
# TODO: hope that container platforms will package 1.35 before 1.40 rolls out
#
# TODO: remove now that 1.40 is guaranteed minimum
# 1.34.99 and above
hledger --version \
| gawk '{ if ($2 !~ /^1.3(4.99|([5-9][\.[0-99]?))/) { exit 1 } }' FS=' '

View File

@@ -102,6 +102,8 @@ $(echo $global_meta_header | xsv headers -)
function lib_meta::__meta()
{
lib_utils::deps_check "visidata"
# TODO: can visidata regex multiple columns from the commandline?
local _tmp_dir
_tmp_dir="$(mktemp -d -p /tmp docker-finance_XXX)"

View File

@@ -95,6 +95,8 @@ function lib_times::__times()
local -r _timewdb="${_path}/timew"
local _command=("timew")
lib_utils::deps_check "${_command[*]}"
local -r _tag="${global_parent_profile}${global_arg_delim_1}${global_child_profile}"
case "$1" in

View File

@@ -74,7 +74,7 @@ function lib_finance::finance()
fi
declare -grx global_child_profile_journal="${global_child_profile_flow}/all-years.journal"
declare -grx global_hledger_cmd=("/usr/bin/hledger" "-f" "$global_child_profile_journal")
declare -grx global_hledger_cmd=("hledger" "-f" "$global_child_profile_journal")
# Globals (configuration)
declare -grx global_conf_fetch="${global_child_profile_flow}/docker-finance.d/fetch/fetch.yaml"
@@ -215,6 +215,8 @@ function lib_finance::reports()
function lib_finance::root()
{
# TODO: lib_root, add extendable arguments
lib_utils::deps_check "root"
# NOTE: will automatically load rootlogon.C
pushd "${DOCKER_FINANCE_CONTAINER_REPO}/src/root/macro" 1>/dev/null \
&& root -l