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:
@@ -147,7 +147,7 @@ ensure_vulkan_runtime() {
|
|||||||
|
|
||||||
install_from_archive_url() {
|
install_from_archive_url() {
|
||||||
local url="$1"
|
local url="$1"
|
||||||
local tmp
|
local tmp kind
|
||||||
tmp="$(mktemp -d)"
|
tmp="$(mktemp -d)"
|
||||||
(
|
(
|
||||||
cd "$tmp"
|
cd "$tmp"
|
||||||
@@ -158,20 +158,32 @@ install_from_archive_url() {
|
|||||||
else
|
else
|
||||||
log "WARN: LLAMACPP_SHA256 не задан — checksum skip"
|
log "WARN: LLAMACPP_SHA256 не задан — checksum skip"
|
||||||
fi
|
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
|
apt-get install -y -qq unzip >/dev/null 2>&1 || true
|
||||||
unzip -qo pkg.bin -d out
|
unzip -qo pkg.bin -d out
|
||||||
else
|
else
|
||||||
mkdir -p out
|
tar -xaf pkg.bin -C out 2>/dev/null \
|
||||||
tar -xaf pkg.bin -C out 2>/dev/null || tar -xzf pkg.bin -C out
|
|| tar -xzf pkg.bin -C out 2>/dev/null \
|
||||||
|
|| tar -xf pkg.bin -C out
|
||||||
fi
|
fi
|
||||||
|
;;
|
||||||
|
esac
|
||||||
local found
|
local found
|
||||||
found="$(find out -type f -name 'llama-server' | head -n1 || true)"
|
found="$(find out -type f -name 'llama-server' | head -n1 || true)"
|
||||||
if [[ -z "$found" ]]; then
|
if [[ -z "$found" ]]; then
|
||||||
found="$(find out -type f -name 'server' | head -n1 || true)"
|
found="$(find out -type f -name 'server' | head -n1 || true)"
|
||||||
fi
|
fi
|
||||||
if [[ -z "$found" ]]; then
|
if [[ -z "$found" ]]; then
|
||||||
log "в архиве нет llama-server"
|
log "в архиве нет llama-server (file says: ${kind:-unknown})"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
install -m 755 "$found" "$SERVER_BIN"
|
install -m 755 "$found" "$SERVER_BIN"
|
||||||
@@ -204,7 +216,9 @@ install_linux_release() {
|
|||||||
else
|
else
|
||||||
log "WARN: Linux prebuilt без GPU backend (CPU) — ${url##*/}"
|
log "WARN: Linux prebuilt без GPU backend (CPU) — ${url##*/}"
|
||||||
fi
|
fi
|
||||||
install_from_archive_url "$url"
|
if ! install_from_archive_url "$url"; then
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
echo "asset:${tag}" >"$STAMP"
|
echo "asset:${tag}" >"$STAMP"
|
||||||
chown "${SWARM_USER}:${SWARM_USER}" "$STAMP"
|
chown "${SWARM_USER}:${SWARM_USER}" "$STAMP"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user