mirror of
https://github.com/mudler/LocalAI.git
synced 2026-07-04 13:27:04 -04:00
golang-darwin.sh's packaging check derived the launch binary by grepping every $CURDIR/... reference in run.sh and taking the last one. Backends that pick a runtime CPU variant assign it via unquoted `LIBRARY=$CURDIR/libgo<x>-avx512.so` lines, so the heuristic returned `libgo<x>-avx512.so` — a variant Darwin never builds (arm64 builds only fallback) — and the check then failed with "package/libgo<x>-avx512.so not found ... refusing to package (#10267)", breaking the darwin builds for whisper, sam3-cpp, vibevoice-cpp and friends. Scan only the `exec` line(s) (the actual launch contract) and tolerate a quoted `exec "$CURDIR"/<binary>`. parakeet-cpp's parakeet-cpp-grpc and the quoted-only backends (sherpa/piper/opus) resolve correctly; no Linux change. Assisted-by: Claude:claude-opus-4-8 Signed-off-by: Ettore Di Giacinto <mudler@localai.io> Co-authored-by: Ettore Di Giacinto <mudler@localai.io>
58 lines
2.5 KiB
Bash
58 lines
2.5 KiB
Bash
#!/bin/bash -eux
|
|
|
|
export BUILD_TYPE="${BUILD_TYPE:-metal}"
|
|
|
|
mkdir -p backend-images
|
|
make -C backend/go/${BACKEND} build
|
|
|
|
BACKEND_DIR="backend/go/${BACKEND}"
|
|
|
|
# Never package a stray CMake build tree (e.g. build-libgo*-*.so/, a directory
|
|
# left behind by a partial native build) into the backend image.
|
|
rm -rf "${BACKEND_DIR}"/build-*
|
|
|
|
# Fail loudly if the build did not produce the backend binary, instead of
|
|
# silently packaging the source/build tree as a "backend" that can never start
|
|
# (issue #10267: the darwin vibevoice-cpp image shipped sources, no binary).
|
|
# run.sh's final `exec $CURDIR/<binary>` is the contract for what gets launched;
|
|
# the binary is not always named after the backend (e.g. parakeet-cpp launches
|
|
# parakeet-cpp-grpc), so derive it from run.sh and fall back to ${BACKEND}.
|
|
#
|
|
# Only scan the `exec` line(s): many run.sh select a runtime CPU variant via
|
|
# unquoted `LIBRARY=$CURDIR/libgo<x>-avx512.so` lines, and a whole-file grep
|
|
# would pick the last of those (avx512, which Darwin never builds) instead of
|
|
# the binary — failing the check below for whisper/sam3-cpp/vibevoice-cpp/...
|
|
# Also tolerate the exec being quoted (`exec "$CURDIR"/<binary>`).
|
|
RUN_BINARY=""
|
|
if [ -f "${BACKEND_DIR}/run.sh" ]; then
|
|
RUN_BINARY=$(grep -E '^[[:space:]]*exec[[:space:]]' "${BACKEND_DIR}/run.sh" | grep -oE '"?\$CURDIR"?/[A-Za-z0-9._-]+' | grep -v 'ld\.so' | tail -1 | sed -E 's|"?\$CURDIR"?/||')
|
|
fi
|
|
RUN_BINARY="${RUN_BINARY:-${BACKEND}}"
|
|
|
|
# Ship the self-contained package/ dir (run.sh + binary + lib/), matching the
|
|
# Linux Dockerfile.golang (`COPY .../package/. ./`). Packaging the whole backend
|
|
# dir instead left the runtime libraries under package/lib while run.sh looks in
|
|
# $CURDIR/lib, so backends such as sherpa-onnx could not dlopen their libs at
|
|
# runtime (they started fine only when run from inside package/). Backends that
|
|
# don't assemble a package/ fall back to the backend dir.
|
|
OCI_ROOT="${BACKEND_DIR}"
|
|
if [ -d "${BACKEND_DIR}/package" ]; then
|
|
OCI_ROOT="${BACKEND_DIR}/package"
|
|
fi
|
|
|
|
if [ ! -x "${OCI_ROOT}/${RUN_BINARY}" ]; then
|
|
echo "ERROR: ${OCI_ROOT}/${RUN_BINARY} not found after build; refusing to package a broken backend image (see issue #10267)." >&2
|
|
exit 1
|
|
fi
|
|
|
|
PLATFORMARCH="${PLATFORMARCH:-darwin/arm64}"
|
|
IMAGE_NAME="${IMAGE_NAME:-localai/${BACKEND}-darwin}"
|
|
|
|
./local-ai util create-oci-image \
|
|
"${OCI_ROOT}/." \
|
|
--output ./backend-images/${BACKEND}.tar \
|
|
--image-name $IMAGE_NAME \
|
|
--platform $PLATFORMARCH
|
|
|
|
make -C backend/go/${BACKEND} clean
|