add: zig and build.sh

build systems
This commit is contained in:
2026-08-23 16:48:51 -04:00
parent 4c701854f9
commit 0b3ebd0f7a
7 changed files with 84 additions and 6 deletions
+3 -1
View File
@@ -227,6 +227,8 @@ local function wizard()
"meson (meson setup build && ninja && ninja install)",
"make (make && make install)",
"cargo (cargo build --release)",
"zig (zig build && zig build install --prefix /usr)",
"build.sh (sh build.sh with DESTDIR staging)",
"custom (run build_script)",
})
@@ -235,7 +237,7 @@ local function wizard()
-- 8. Configure args (skip for cargo)
rcp.configure_args = {}
if rcp.build_system ~= "cargo" then
if rcp.build_system ~= "cargo" and rcp.build_system ~= "build.sh" then
io.write("Configure args" .. dim(" [comma-separated, e.g. --enable-feature, --without-x]") .. ": ")
io.flush()
local args_line = io.read("*l")
+26
View File
@@ -0,0 +1,26 @@
#!/bin/sh
# build.sh — example build.sh-style build script for zeta-makepkg.
#
# Invoked from the extracted source directory. The tool sets:
# $DESTDIR → staging tree root (e.g. /tmp/zeta-makepkg/buildsh-tool-.../stage)
#
# This script must compile/assemble the software and install every output
# file under $DESTDIR with standard FHS paths (usr/bin/, usr/lib/, etc.).
#
# For a real project you would replace the example below with the project's
# own build.sh — e.g. one that runs configure && make && make install with
# DESTDIR set, or any autotools-like shell build sequence.
set -eu
echo "==> Building buildsh-tool (build.sh)"
# Example: install a shell script into the staging tree
mkdir -p "$DESTDIR/usr/bin"
cat > "$DESTDIR/usr/bin/buildsh-tool" <<'EOF'
#!/bin/sh
echo "buildsh-tool 1.0"
EOF
chmod 755 "$DESTDIR/usr/bin/buildsh-tool"
echo "==> Install complete"
@@ -0,0 +1,23 @@
-- buildsh-demo.recipe — demonstrates build_system = "build.sh".
--
-- The build.sh build system runs the source tree's build.sh script from the
-- extracted source directory. The script receives $DESTDIR pointing at the
-- staging tree where installed files must be placed, exactly like the
-- 'custom' build system — but the script name is fixed to build.sh.
--
-- To try this:
-- 1. Unpack the source tarball: tar -xzf buildsh-tool-1.0.tar.gz
-- 2. Run the script manually: cd buildsh-tool-1.0 && DESTDIR=/tmp/stage sh build.sh
-- 3. Inspect the staged output: find /tmp/stage
-- 4. Build with makepkg: zeta-makepkg buildsh-demo.recipe
return {
name = "buildsh-tool",
version = "1.0",
summary = "Example build.sh-style package (shell-installed binary)",
url = "buildsh-tool-1.0.tar.gz",
sha256 = nil,
deps = {},
build_system = "build.sh",
test = "test -x ${DESTDIR}/usr/bin/buildsh-tool",
}
+16
View File
@@ -0,0 +1,16 @@
-- zig.recipe — zig build system example.
--
-- Demonstrates: zig, configure_args (-D flags), source sha256.
return {
name = "my-zig-app",
version = "1.0.0",
summary = "An example application built with Zig",
url = "https://example.com/my-zig-app-1.0.0.tar.gz",
sha256 = nil,
deps = {},
build_system = "zig",
configure_args = { "-Doptimize=ReleaseFast" },
test = "test -x ${DESTDIR}/usr/bin/my-zig-app",
files = { "usr/bin/my-zig-app" },
}
+11 -1
View File
@@ -3,7 +3,7 @@
-- Handles the full build pipeline for a recipe:
-- 1. fetch_source — download to cache (or detect git)
-- 2. extract_source — unpack tarball or clone git repo
-- 3. run_build — dispatch autotools/cmake/meson/make/cargo/custom
-- 3. run_build — dispatch autotools/cmake/meson/make/cargo/zig/build.sh/custom
-- 4. run_test — execute post-build verification command
--
-- All subprocesses run in a minimal environment. Build tools (meson, cmake,
@@ -298,6 +298,16 @@ function builder.run_build(recipe, source_dir, stage_dir, opts)
end
run("install -D " .. path.quote(target) .. " " .. path.quote(path.join(bin_dir, path.basename(target))))
elseif bs == "zig" then
run("zig build -Doptimize=ReleaseSafe" .. args_str)
run("zig build install --prefix /usr -Ddestdir=" .. path.quote(stage_dir))
elseif bs == "build.sh" then
if not path.exists(path.join(source_dir, "build.sh")) then
error(("no build.sh script found in %s (build_system is 'build.sh')"):format(source_dir), 0)
end
run("DESTDIR=" .. path.quote(stage_dir) .. " sh build.sh")
elseif bs == "custom" then
local script = recipe.build_script
run("DESTDIR=" .. path.quote(stage_dir) .. " sh " .. path.quote(script))
+3 -2
View File
@@ -11,7 +11,7 @@
-- url = "https://.../mypkg-1.2.3.tar.gz",
-- sha256 = nil, -- optional source checksum
-- deps = { "libfoo" },
-- build_system = "meson", -- autotools | cmake | meson | make | cargo | custom
-- build_system = "meson", -- autotools | cmake | meson | make | cargo | zig | build.sh | custom
-- configure_args = { ... }, -- optional extra args
-- build_script = "build.sh", -- required for custom
-- test = "test -f ${DESTDIR}/usr/bin/mypkg",
@@ -31,7 +31,8 @@ local KNOWN_KEYS = {
local BUILD_SYSTEMS = {
autotools = true, cmake = true, meson = true,
make = true, cargo = true, custom = true,
make = true, cargo = true, zig = true,
["build.sh"] = true, custom = true,
}
local HEX64 = "^" .. string.rep("%x", 64) .. "$"