Refactor installation script for improved archive handling and error logging

- Introduced a new variable to determine the type of archive being processed, enhancing the logic for handling different file types.
- Updated the installation process to ensure proper extraction of both zip and tar files, improving compatibility with various archive formats.
- Enhanced logging to provide clearer feedback on the type of archive being processed, aiding in troubleshooting.
- Added error handling to ensure the installation process returns a failure status if the archive does not contain the expected binaries.
This commit is contained in:
Leonid Pershin
2026-08-21 08:22:17 +03:00
parent 91d2ce0fab
commit 5081a6bc1e
+20 -6
View File
@@ -147,7 +147,7 @@ ensure_vulkan_runtime() {
install_from_archive_url() {
local url="$1"
local tmp
local tmp kind
tmp="$(mktemp -d)"
(
cd "$tmp"
@@ -158,20 +158,32 @@ install_from_archive_url() {
else
log "WARN: LLAMACPP_SHA256 не задан — checksum skip"
fi
if file pkg.bin | grep -qi zip; then
mkdir -p out
# Do NOT grep -i zip — that matches "gzip" and breaks .tar.gz.
kind="$(file -b pkg.bin 2>/dev/null || true)"
case "$url" in
*.zip)
apt-get install -y -qq unzip >/dev/null 2>&1 || true
unzip -qo pkg.bin -d out
;;
*)
if [[ "$kind" == Zip\ archive* ]] || [[ "$kind" == *"Zip archive"* ]]; then
apt-get install -y -qq unzip >/dev/null 2>&1 || true
unzip -qo pkg.bin -d out
else
mkdir -p out
tar -xaf pkg.bin -C out 2>/dev/null || tar -xzf pkg.bin -C out
tar -xaf pkg.bin -C out 2>/dev/null \
|| tar -xzf pkg.bin -C out 2>/dev/null \
|| tar -xf pkg.bin -C out
fi
;;
esac
local found
found="$(find out -type f -name 'llama-server' | head -n1 || true)"
if [[ -z "$found" ]]; then
found="$(find out -type f -name 'server' | head -n1 || true)"
fi
if [[ -z "$found" ]]; then
log "в архиве нет llama-server"
log "в архиве нет llama-server (file says: ${kind:-unknown})"
exit 1
fi
install -m 755 "$found" "$SERVER_BIN"
@@ -204,7 +216,9 @@ install_linux_release() {
else
log "WARN: Linux prebuilt без GPU backend (CPU) — ${url##*/}"
fi
install_from_archive_url "$url"
if ! install_from_archive_url "$url"; then
return 1
fi
echo "asset:${tag}" >"$STAMP"
chown "${SWARM_USER}:${SWARM_USER}" "$STAMP"
}