patch: hooks from zeta

This commit is contained in:
2026-08-17 19:23:32 -04:00
parent 159f7bfe83
commit 551ba34cab
6 changed files with 204 additions and 2 deletions
+41
View File
@@ -0,0 +1,41 @@
#!/bin/sh
# build.sh — example custom build script for zeta-makepkg.
#
# Invoked from the extracted source directory. The tool sets:
# $DESTDIR → staging tree root (e.g. /tmp/zeta-makepkg/hooks-demo-.../stage)
#
# This script installs a small command under usr/bin/ and a post-transaction
# hook under usr/share/zeta/hooks/. A hook is a pure-data Lua file:
#
# return {
# order = 50,
# trigger = { op = "install", type = "package", target = { "hooks-demo" } },
# action = { when = "post", exec = "true", description = "example hook" },
# }
#
# zeta-makepkg scans the stage for usr/share/zeta/hooks/*.hook, validates the
# format, and merges the paths into the generated `files` whitelist.
set -eu
echo "==> Building hooks-demo (custom)"
# Install a tiny command
mkdir -p "$DESTDIR/usr/bin"
cat > "$DESTDIR/usr/bin/hooks-demo" <<'EOF'
#!/bin/sh
echo "hooks-demo: post-transaction hooks are working"
EOF
chmod 755 "$DESTDIR/usr/bin/hooks-demo"
# Install a post-transaction hook (pure data, no side effects)
mkdir -p "$DESTDIR/usr/share/zeta/hooks"
cat > "$DESTDIR/usr/share/zeta/hooks/hooks-demo.hook" <<'EOF'
return {
order = 50,
trigger = { op = "install", type = "package", target = { "hooks-demo" } },
action = { when = "post", exec = "true", description = "example hook" },
}
EOF
echo "==> Install complete"
@@ -0,0 +1,26 @@
-- hooks-demo.recipe — demonstrates shipping a post-transaction hook.
--
-- The custom build script installs a small command and a hook file under
-- usr/share/zeta/hooks/. zeta-makepkg scans the stage for *.hook files,
-- validates each one (a hook is a pure-data Lua table carrying `trigger`
-- and `action`), and merges the found paths into the generated `files`
-- whitelist so the hook is committed alongside the declared files.
--
-- To try this:
-- 1. Unpack the source tarball: tar -xzf hooks-demo-1.0.tar.gz
-- 2. Run the script manually: cd hooks-demo-1.0 && DESTDIR=/tmp/stage sh build.sh
-- 3. Inspect the staged output: find /tmp/stage
-- 4. Build with makepkg: zeta-makepkg hooks-demo.recipe
return {
name = "hooks-demo",
version = "1.0",
summary = "Example package shipping a post-transaction hook",
url = "hooks-demo-1.0.tar.gz",
sha256 = nil,
deps = {},
build_system = "custom",
build_script = "build.sh",
files = { "usr/bin/hooks-demo", "usr/share/zeta/hooks/hooks-demo.hook" },
test = "test -x ${DESTDIR}/usr/bin/hooks-demo",
}