98 lines
4.3 KiB
Bash
Executable File
98 lines
4.3 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
REPO_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
|
STAGING="${REPO_ROOT}/iso/config/includes.chroot_before_packages/live-artifacts"
|
|
|
|
mkdir -p "$STAGING"
|
|
|
|
echo "=== Building n-OS-tr components ==="
|
|
|
|
build_and_stage() {
|
|
local name="$1"
|
|
local src_dir="$2"
|
|
local stage_name="$3"
|
|
local build_cmd="$4"
|
|
shift 4
|
|
local candidates=("$@")
|
|
|
|
echo "--- Building: $name ---"
|
|
if [ ! -d "$src_dir" ]; then
|
|
echo " SKIP: $src_dir not found"
|
|
return 0
|
|
fi
|
|
|
|
(cd "$src_dir" && eval "$build_cmd")
|
|
|
|
local output=""
|
|
for candidate in "${candidates[@]}"; do
|
|
if [ -f "$src_dir/$candidate" ]; then
|
|
output="$src_dir/$candidate"
|
|
break
|
|
fi
|
|
done
|
|
|
|
if [ -n "$output" ]; then
|
|
cp "$output" "$STAGING/$stage_name"
|
|
echo " OK: staged $stage_name (from ${output#$src_dir/})"
|
|
else
|
|
echo " ERROR: no output found for $name"
|
|
echo " looked for: ${candidates[*]}"
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
# Tier 1: source-built components
|
|
build_and_stage "nostr_core_lib" "$REPO_ROOT/includes/nostr_core_lib" "libnostr_core.a" \
|
|
"bash ./build.sh x64" \
|
|
"libnostr_core_x64.a" "libnostr_core.a"
|
|
|
|
build_and_stage "n_signer" "$REPO_ROOT/includes/n_signer" "n_signer" \
|
|
"mkdir -p resources && ln -sfn ../../nostr_core_lib resources/nostr_core_lib && make dev" \
|
|
"build/nsigner" "build/n_signer" "n_signer"
|
|
|
|
build_and_stage "nostr-id-tui" "$REPO_ROOT/includes/nostr-id-tui" "nostr-id-tui" \
|
|
"./build_static.sh" \
|
|
"build/nostr-id-tui_static_x86_64" "build/nostr-id-tui" "nostr-id-tui"
|
|
|
|
build_and_stage "ginxsom" "$REPO_ROOT/includes/ginxsom" "ginxsom-fcgi" \
|
|
"REF=\$(git -C $REPO_ROOT/includes/nostr_core_lib rev-parse HEAD) && docker build --platform linux/amd64 --build-arg NOSTR_CORE_LIB_REF=\$REF -f Dockerfile.alpine-musl -t n-os-tr/ginxsom-musl-builder:latest . && CID=\$(docker create n-os-tr/ginxsom-musl-builder:latest /ginxsom-fcgi_static) && mkdir -p build && docker cp \${CID}:/ginxsom-fcgi_static build/ginxsom-fcgi_static_x86_64 && docker rm \$CID >/dev/null && chmod +x build/ginxsom-fcgi_static_x86_64" \
|
|
"build/ginxsom-fcgi_static_x86_64" "build/ginxsom-fcgi" "ginxsom-fcgi"
|
|
|
|
build_and_stage "nostr_terminal" "$REPO_ROOT/includes/nostr_terminal" "nt" \
|
|
"rm -rf resources/nostr_core_lib && mkdir -p resources && cp -a ../nostr_core_lib ./resources/nostr_core_lib && ./build.sh" \
|
|
"nt" "build/nt_static_x86_64" "build/nt"
|
|
|
|
build_and_stage "otp" "$REPO_ROOT/includes/otp" "otp" \
|
|
"[ -d miniz ] || git clone --depth 1 https://github.com/richgel999/miniz.git miniz; [ -f miniz/miniz_export.h ] || printf '%s\n' '#ifndef MINIZ_EXPORT_H' '#define MINIZ_EXPORT_H' '#define MINIZ_EXPORT' '#endif' > miniz/miniz_export.h; [ -d microtar/src ] || git clone --depth 1 https://github.com/rxi/microtar.git microtar; make static" \
|
|
"build/otp-x86_64" "build/otp-amd64" "build/otp"
|
|
|
|
build_and_stage "didactyl" "$REPO_ROOT/includes/didactyl" "didactyl" \
|
|
"rm -rf nostr_core_lib && cp -a ../nostr_core_lib ./nostr_core_lib && ./build_static.sh" \
|
|
"didactyl_static_x86_64" "build/didactyl_static_x86_64" "didactyl"
|
|
|
|
# Tier 2: fips (musl static binary for ISO)
|
|
build_and_stage "fips" "$REPO_ROOT/includes/fips" "fips" \
|
|
"(command -v rustup >/dev/null 2>&1 && rustup target add x86_64-unknown-linux-musl >/dev/null 2>&1 || true) && (cargo build --release --target x86_64-unknown-linux-musl --no-default-features --bin fips || cargo build --release --no-default-features --bin fips)" \
|
|
"target/x86_64-unknown-linux-musl/release/fips" "target/release/fips"
|
|
|
|
# Tier 3: nak (pre-built, just copy if present)
|
|
if [ -f "$REPO_ROOT/includes/third-party/nak/nak-v0.19.7-linux-amd64" ]; then
|
|
cp "$REPO_ROOT/includes/third-party/nak/nak-v0.19.7-linux-amd64" "$STAGING/nak"
|
|
chmod 755 "$STAGING/nak"
|
|
echo "--- Staged: nak (Tier 3, pre-built) ---"
|
|
else
|
|
echo "--- SKIP: nak binary not present in includes/third-party/nak/ ---"
|
|
fi
|
|
|
|
echo
|
|
echo "=== Staging complete. Contents of $STAGING: ==="
|
|
ls -la "$STAGING/" 2>/dev/null || echo "(empty)"
|
|
|
|
# Generate SHA256 manifest
|
|
if compgen -G "$STAGING/*" > /dev/null; then
|
|
rm -f "$STAGING/SHA256SUMS"
|
|
(cd "$STAGING" && find . -maxdepth 1 -type f ! -name 'SHA256SUMS' -printf '%f\n' | sort | xargs -r sha256sum > SHA256SUMS)
|
|
fi
|
|
echo "=== SHA256SUMS generated ==="
|