mirror of
https://github.com/hotwa/luci-app-openclaw.git
synced 2026-03-30 20:25:44 +00:00
Support relocatable custom install roots
This commit is contained in:
43
tests/test_node_packaging_contract.sh
Normal file
43
tests/test_node_packaging_contract.sh
Normal file
@@ -0,0 +1,43 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
SCRIPT_DIR=$(CDPATH= cd -- "$(dirname "$0")" && pwd)
|
||||
REPO_ROOT=$(CDPATH= cd -- "$SCRIPT_DIR/.." && pwd)
|
||||
|
||||
BUILD_SCRIPT="$REPO_ROOT/scripts/build-node-musl.sh"
|
||||
WORKFLOW="$REPO_ROOT/.github/workflows/build-node-musl.yml"
|
||||
MAKEFILE="$REPO_ROOT/Makefile"
|
||||
BUILD_IPK="$REPO_ROOT/scripts/build_ipk.sh"
|
||||
BUILD_RUN="$REPO_ROOT/scripts/build_run.sh"
|
||||
ENV_SCRIPT="$REPO_ROOT/root/usr/bin/openclaw-env"
|
||||
|
||||
fail() {
|
||||
echo "FAIL: $1" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
grep -Fq 'patchelf --set-interpreter "/lib/ld-musl-aarch64.so.1"' "$BUILD_SCRIPT" || fail "build script should use system musl loader"
|
||||
grep -Fq '$ORIGIN/../lib' "$BUILD_SCRIPT" || fail "build script should use relative rpath"
|
||||
if grep -Fq 'patchelf --set-interpreter "${INSTALL_PREFIX}/lib/ld-musl-aarch64.so.1"' "$BUILD_SCRIPT"; then
|
||||
fail "build script should not hardcode interpreter to install prefix"
|
||||
fi
|
||||
|
||||
grep -Fq 'verify_prefix /opt/openclaw/node' "$WORKFLOW" || fail "workflow should verify default install path"
|
||||
grep -Fq 'verify_prefix /tmp/custom-openclaw-root/openclaw/node' "$WORKFLOW" || fail "workflow should verify custom install path"
|
||||
|
||||
grep -Fq 'oc_node_version_ge "$installed_ver" "$node_ver"' "$ENV_SCRIPT" || fail "installer should enforce minimum node version after extraction"
|
||||
if grep -Fq 'mirror_list="$mirror_list ${NODE_SELF_HOST}/${v1_tarball}"' "$ENV_SCRIPT"; then
|
||||
fail "installer should not auto-fallback from V2 to V1 tarball"
|
||||
fi
|
||||
|
||||
grep -Fq 'openclaw-paths.sh' "$MAKEFILE" || fail "package makefile should install path helper"
|
||||
grep -Fq 'openclaw-node.sh' "$MAKEFILE" || fail "package makefile should install node helper"
|
||||
grep -Fq 'openclaw/paths.lua' "$MAKEFILE" || fail "package makefile should install Lua path helper"
|
||||
grep -Fq 'openclaw-paths.sh' "$BUILD_IPK" || fail "ipk builder should package path helper"
|
||||
grep -Fq 'openclaw-node.sh' "$BUILD_IPK" || fail "ipk builder should package node helper"
|
||||
grep -Fq 'openclaw/paths.lua' "$BUILD_IPK" || fail "ipk builder should package Lua path helper"
|
||||
grep -Fq 'openclaw-paths.sh' "$BUILD_RUN" || fail "run builder should package path helper"
|
||||
grep -Fq 'openclaw-node.sh' "$BUILD_RUN" || fail "run builder should package node helper"
|
||||
grep -Fq 'openclaw/paths.lua' "$BUILD_RUN" || fail "run builder should package Lua path helper"
|
||||
|
||||
echo "ok"
|
||||
54
tests/test_openclaw_node.sh
Normal file
54
tests/test_openclaw_node.sh
Normal file
@@ -0,0 +1,54 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
SCRIPT_DIR=$(CDPATH= cd -- "$(dirname "$0")" && pwd)
|
||||
REPO_ROOT=$(CDPATH= cd -- "$SCRIPT_DIR/.." && pwd)
|
||||
|
||||
. "$REPO_ROOT/root/usr/libexec/openclaw-node.sh"
|
||||
|
||||
fail() {
|
||||
echo "FAIL: $1" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
normalized=$(oc_normalize_node_version "v22.16.1") || fail "normalize valid version"
|
||||
[ "$normalized" = "22.16.1" ] || fail "normalized version value"
|
||||
|
||||
if oc_normalize_node_version "broken-version" >/dev/null 2>&1; then
|
||||
fail "invalid version should not normalize"
|
||||
fi
|
||||
|
||||
oc_node_version_ge "22.16.0" "22.16.0" || fail "exact version should satisfy requirement"
|
||||
oc_node_version_ge "22.16.1" "22.16.0" || fail "newer patch should satisfy requirement"
|
||||
oc_node_version_ge "23.0.0" "22.16.0" || fail "newer major should satisfy requirement"
|
||||
if oc_node_version_ge "22.15.1" "22.16.0"; then
|
||||
fail "older minor version should not satisfy requirement"
|
||||
fi
|
||||
|
||||
tmpdir=$(mktemp -d)
|
||||
trap 'rm -rf "$tmpdir"' EXIT INT TERM
|
||||
|
||||
cat > "$tmpdir/node-ok" <<'EOF'
|
||||
#!/bin/sh
|
||||
if [ "${1:-}" = "--version" ]; then
|
||||
echo "v22.16.2"
|
||||
exit 0
|
||||
fi
|
||||
exit 1
|
||||
EOF
|
||||
chmod +x "$tmpdir/node-ok"
|
||||
|
||||
cat > "$tmpdir/node-bad" <<'EOF'
|
||||
#!/bin/sh
|
||||
exit 127
|
||||
EOF
|
||||
chmod +x "$tmpdir/node-bad"
|
||||
|
||||
read_ver=$(oc_read_node_version "$tmpdir/node-ok") || fail "read runnable node version"
|
||||
[ "$read_ver" = "22.16.2" ] || fail "read version value"
|
||||
|
||||
if oc_read_node_version "$tmpdir/node-bad" >/dev/null 2>&1; then
|
||||
fail "broken node binary should not be accepted"
|
||||
fi
|
||||
|
||||
echo "ok"
|
||||
Reference in New Issue
Block a user