let a stack compute its settings without make

A stack can now ship <name>.env and <name>.sh next to its compose files. The
hook is sourced with the tag helpers available, which is what the computing
.mk files of the catalogue were using make for: 29 of its 44 .mk files only
exist to build variables like the fabio tags.

Converting stack/host/fabio.mk by hand gives byte-identical output for the
route tag, and drops a trailing comma the make version left in the listener
list.

Also: APP_HOST and APP_URI are computed (the tag helpers build on them),
--color controls the escape codes rather than always emitting them, and
make test-portability runs the CLI under busybox ash and dash.
This commit is contained in:
Yann Autissier
2026-09-03 20:22:52 +02:00
parent 234739e531
commit f541ca418b
13 changed files with 281 additions and 22 deletions
+28
View File
@@ -0,0 +1,28 @@
#shellcheck shell=sh
# hooks: the per-stack settings that used to live in a .mk file.
#
# A stack may ship, next to its compose files:
# <name>.env dotenv, for plain values
# <name>.env.<env> the same, for one environment
# <name>.sh shell, for values that have to be computed (fabio tags, JWTs)
# <name>.mk the legacy make snippet, still read for its groups
#
# A .sh hook runs with the myos helpers available (myos_tagprefix, myos_uri,
# myos_var) and sets variables directly. This is what lets a stack of the
# catalogue work on a machine that has no make.
# myos_stack_hooks DIR NAME load the hooks of one stack, most specific last
myos_stack_hooks() {
_hdir=$1; _hname=$2
for _h in "$_hdir/$_hname.env" "$_hdir/$_hname.env.$ENV"; do
[ -f "$_h" ] && myos_dotenv_load "$_h"
done
for _h in "$_hdir/$_hname.sh" "$_hdir/$_hname.$ENV.sh"; do
if [ -f "$_h" ]; then
myos_debug "hook $_h"
# shellcheck source=/dev/null
. "$_h"
fi
done
return 0
}