diff --git a/README.md b/README.md index 817b18c..404ba6f 100644 --- a/README.md +++ b/README.md @@ -31,13 +31,13 @@ return { summary = "Short description", url = "https://.../src.tar.gz", deps = { "libfoo", "libbar>=2.0" }, - build_system = "autotools", -- autotools | cmake | meson | make | cargo | custom + build_system = "autotools", -- autotools | cmake | meson | make | cargo | zig | build.sh | custom configure_args = { "--enable-x" }, test = "${DESTDIR}/usr/bin/mypkg --version", } ``` -**Build systems**: `autotools`, `cmake`, `meson`, `make`, `cargo`, `custom` +**Build systems**: `autotools`, `cmake`, `meson`, `make`, `cargo`, `zig`, `build.sh`, `custom` ## Post-transaction hooks diff --git a/toolchain/cli/zeta-cli b/toolchain/cli/zeta-cli index 7a66045..1e89ad7 100755 --- a/toolchain/cli/zeta-cli +++ b/toolchain/cli/zeta-cli @@ -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") diff --git a/toolchain/examples/buildsh-demo/build.sh b/toolchain/examples/buildsh-demo/build.sh new file mode 100644 index 0000000..4bf5918 --- /dev/null +++ b/toolchain/examples/buildsh-demo/build.sh @@ -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" diff --git a/toolchain/examples/buildsh-demo/buildsh-demo.recipe b/toolchain/examples/buildsh-demo/buildsh-demo.recipe new file mode 100644 index 0000000..5edaaa5 --- /dev/null +++ b/toolchain/examples/buildsh-demo/buildsh-demo.recipe @@ -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", +} diff --git a/toolchain/examples/zig.recipe b/toolchain/examples/zig.recipe new file mode 100644 index 0000000..b843ea6 --- /dev/null +++ b/toolchain/examples/zig.recipe @@ -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" }, +} diff --git a/toolchain/lib/builder.lua b/toolchain/lib/builder.lua index 95019be..6617e8c 100644 --- a/toolchain/lib/builder.lua +++ b/toolchain/lib/builder.lua @@ -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)) diff --git a/toolchain/lib/recipe.lua b/toolchain/lib/recipe.lua index 137fcd6..11ab11c 100644 --- a/toolchain/lib/recipe.lua +++ b/toolchain/lib/recipe.lua @@ -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) .. "$"