diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index b4b9602b9..063927349 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -68,6 +68,7 @@ jobs: name: bundles-darwin path: | dist/*.tgz + dist/*.tar.zst dist/*.zip dist/*.dmg @@ -392,13 +393,13 @@ jobs: done - run: | for ARCHIVE in dist/${{ matrix.os }}-${{ matrix.arch }}/*.tar.in; do - tar c -C dist/${{ matrix.os }}-${{ matrix.arch }} -T $ARCHIVE --owner 0 --group 0 | pigz -9vc >$(basename ${ARCHIVE//.*/}.tgz); + tar c -C dist/${{ matrix.os }}-${{ matrix.arch }} -T $ARCHIVE --owner 0 --group 0 | zstd --ultra -22 -T0 >$(basename ${ARCHIVE//.*/}.tar.zst); done - uses: actions/upload-artifact@v4 with: name: bundles-${{ matrix.os }}-${{ matrix.arch }}-${{ matrix.target }} path: | - *.tgz + *.tar.zst # Build each Docker variant (OS, arch, and flavor) separately. Using QEMU is unreliable and slower. docker-build-push: @@ -531,7 +532,7 @@ jobs: - name: Upload release artifacts run: | pids=() - for payload in dist/*.txt dist/*.zip dist/*.tgz dist/*.exe dist/*.dmg ; do + for payload in dist/*.txt dist/*.zip dist/*.tgz dist/*.tar.zst dist/*.exe dist/*.dmg ; do echo "Uploading $payload" gh release upload ${GITHUB_REF_NAME} $payload --clobber & pids[$!]=$! diff --git a/docs/linux.mdx b/docs/linux.mdx index c40ab0545..49b58a45c 100644 --- a/docs/linux.mdx +++ b/docs/linux.mdx @@ -20,8 +20,8 @@ curl -fsSL https://ollama.com/install.sh | sh Download and extract the package: ```shell -curl -fsSL https://ollama.com/download/ollama-linux-amd64.tgz \ - | sudo tar zx -C /usr +curl -fsSL https://ollama.com/download/ollama-linux-amd64.tar.zst \ + | sudo tar x -C /usr ``` Start Ollama: @@ -41,8 +41,8 @@ ollama -v If you have an AMD GPU, also download and extract the additional ROCm package: ```shell -curl -fsSL https://ollama.com/download/ollama-linux-amd64-rocm.tgz \ - | sudo tar zx -C /usr +curl -fsSL https://ollama.com/download/ollama-linux-amd64-rocm.tar.zst \ + | sudo tar x -C /usr ``` ### ARM64 install @@ -50,8 +50,8 @@ curl -fsSL https://ollama.com/download/ollama-linux-amd64-rocm.tgz \ Download and extract the ARM64-specific package: ```shell -curl -fsSL https://ollama.com/download/ollama-linux-arm64.tgz \ - | sudo tar zx -C /usr +curl -fsSL https://ollama.com/download/ollama-linux-arm64.tar.zst \ + | sudo tar x -C /usr ``` ### Adding Ollama as a startup service (recommended) @@ -146,8 +146,8 @@ curl -fsSL https://ollama.com/install.sh | sh Or by re-downloading Ollama: ```shell -curl -fsSL https://ollama.com/download/ollama-linux-amd64.tgz \ - | sudo tar zx -C /usr +curl -fsSL https://ollama.com/download/ollama-linux-amd64.tar.zst \ + | sudo tar x -C /usr ``` ## Installing specific versions diff --git a/scripts/build_linux.sh b/scripts/build_linux.sh index 618722d11..7a5bfc9b8 100755 --- a/scripts/build_linux.sh +++ b/scripts/build_linux.sh @@ -12,6 +12,17 @@ set -eu . $(dirname $0)/env.sh +# Check for required tools +if ! command -v zstd >/dev/null 2>&1; then + echo "ERROR: zstd is required but not installed." >&2 + echo "Please install zstd:" >&2 + echo " - macOS: brew install zstd" >&2 + echo " - Debian/Ubuntu: sudo apt-get install zstd" >&2 + echo " - RHEL/CentOS/Fedora: sudo dnf install zstd" >&2 + echo " - Arch: sudo pacman -S zstd" >&2 + exit 1 +fi + mkdir -p dist docker buildx build \ @@ -40,16 +51,16 @@ fi # buildx behavior changes for single vs. multiplatform echo "Compressing linux tar bundles..." if echo $PLATFORM | grep "," > /dev/null ; then - tar c -C ./dist/linux_arm64 --exclude cuda_jetpack5 --exclude cuda_jetpack6 . | pigz -9vc >./dist/ollama-linux-arm64.tgz - tar c -C ./dist/linux_arm64 ./lib/ollama/cuda_jetpack5 | pigz -9vc >./dist/ollama-linux-arm64-jetpack5.tgz - tar c -C ./dist/linux_arm64 ./lib/ollama/cuda_jetpack6 | pigz -9vc >./dist/ollama-linux-arm64-jetpack6.tgz - tar c -C ./dist/linux_amd64 --exclude rocm . | pigz -9vc >./dist/ollama-linux-amd64.tgz - tar c -C ./dist/linux_amd64 ./lib/ollama/rocm | pigz -9vc >./dist/ollama-linux-amd64-rocm.tgz + tar c -C ./dist/linux_arm64 --exclude cuda_jetpack5 --exclude cuda_jetpack6 . | zstd --ultra -22 -T0 >./dist/ollama-linux-arm64.tar.zst + tar c -C ./dist/linux_arm64 ./lib/ollama/cuda_jetpack5 | zstd --ultra -22 -T0 >./dist/ollama-linux-arm64-jetpack5.tar.zst + tar c -C ./dist/linux_arm64 ./lib/ollama/cuda_jetpack6 | zstd --ultra -22 -T0 >./dist/ollama-linux-arm64-jetpack6.tar.zst + tar c -C ./dist/linux_amd64 --exclude rocm . | zstd --ultra -22 -T0 >./dist/ollama-linux-amd64.tar.zst + tar c -C ./dist/linux_amd64 ./lib/ollama/rocm | zstd --ultra -22 -T0 >./dist/ollama-linux-amd64-rocm.tar.zst elif echo $PLATFORM | grep "arm64" > /dev/null ; then - tar c -C ./dist/ --exclude cuda_jetpack5 --exclude cuda_jetpack6 bin lib | pigz -9vc >./dist/ollama-linux-arm64.tgz - tar c -C ./dist/ ./lib/ollama/cuda_jetpack5 | pigz -9vc >./dist/ollama-linux-arm64-jetpack5.tgz - tar c -C ./dist/ ./lib/ollama/cuda_jetpack6 | pigz -9vc >./dist/ollama-linux-arm64-jetpack6.tgz + tar c -C ./dist/ --exclude cuda_jetpack5 --exclude cuda_jetpack6 bin lib | zstd --ultra -22 -T0 >./dist/ollama-linux-arm64.tar.zst + tar c -C ./dist/ ./lib/ollama/cuda_jetpack5 | zstd --ultra -22 -T0 >./dist/ollama-linux-arm64-jetpack5.tar.zst + tar c -C ./dist/ ./lib/ollama/cuda_jetpack6 | zstd --ultra -22 -T0 >./dist/ollama-linux-arm64-jetpack6.tar.zst elif echo $PLATFORM | grep "amd64" > /dev/null ; then - tar c -C ./dist/ --exclude rocm bin lib | pigz -9vc >./dist/ollama-linux-amd64.tgz - tar c -C ./dist/ ./lib/ollama/rocm | pigz -9vc >./dist/ollama-linux-amd64-rocm.tgz + tar c -C ./dist/ --exclude rocm bin lib | zstd --ultra -22 -T0 >./dist/ollama-linux-amd64.tar.zst + tar c -C ./dist/ ./lib/ollama/rocm | zstd --ultra -22 -T0 >./dist/ollama-linux-amd64-rocm.tar.zst fi diff --git a/scripts/install.sh b/scripts/install.sh index 9c232400f..8e0b8ed8f 100644 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -66,6 +66,36 @@ if [ -n "$NEEDS" ]; then exit 1 fi +# Function to download and extract with fallback from zst to tgz +download_and_extract() { + local url_base="$1" + local dest_dir="$2" + local filename="$3" + + # Check if .tar.zst is available + if curl --fail --silent --head --location "${url_base}/${filename}.tar.zst${VER_PARAM}" >/dev/null 2>&1; then + # zst file exists - check if we have zstd tool + if ! available zstd; then + error "This version requires zstd for extraction. Please install zstd and try again: + - Debian/Ubuntu: sudo apt-get install zstd + - RHEL/CentOS/Fedora: sudo dnf install zstd + - Arch: sudo pacman -S zstd" + fi + + status "Downloading ${filename}.tar.zst" + curl --fail --show-error --location --progress-bar \ + "${url_base}/${filename}.tar.zst${VER_PARAM}" | \ + zstd -d | $SUDO tar -xf - -C "${dest_dir}" + return 0 + fi + + # Fall back to .tgz for older versions + status "Downloading ${filename}.tgz" + curl --fail --show-error --location --progress-bar \ + "${url_base}/${filename}.tgz${VER_PARAM}" | \ + $SUDO tar -xzf - -C "${dest_dir}" +} + for BINDIR in /usr/local/bin /usr/bin /bin; do echo $PATH | grep -q $BINDIR && break || continue done @@ -78,10 +108,7 @@ fi status "Installing ollama to $OLLAMA_INSTALL_DIR" $SUDO install -o0 -g0 -m755 -d $BINDIR $SUDO install -o0 -g0 -m755 -d "$OLLAMA_INSTALL_DIR/lib/ollama" -status "Downloading Linux ${ARCH} bundle" -curl --fail --show-error --location --progress-bar \ - "https://ollama.com/download/ollama-linux-${ARCH}.tgz${VER_PARAM}" | \ - $SUDO tar -xzf - -C "$OLLAMA_INSTALL_DIR" +download_and_extract "https://ollama.com/download" "$OLLAMA_INSTALL_DIR" "ollama-linux-${ARCH}" if [ "$OLLAMA_INSTALL_DIR/bin/ollama" != "$BINDIR/ollama" ] ; then status "Making ollama accessible in the PATH in $BINDIR" @@ -91,15 +118,9 @@ fi # Check for NVIDIA JetPack systems with additional downloads if [ -f /etc/nv_tegra_release ] ; then if grep R36 /etc/nv_tegra_release > /dev/null ; then - status "Downloading JetPack 6 components" - curl --fail --show-error --location --progress-bar \ - "https://ollama.com/download/ollama-linux-${ARCH}-jetpack6.tgz${VER_PARAM}" | \ - $SUDO tar -xzf - -C "$OLLAMA_INSTALL_DIR" + download_and_extract "https://ollama.com/download" "$OLLAMA_INSTALL_DIR" "ollama-linux-${ARCH}-jetpack6" elif grep R35 /etc/nv_tegra_release > /dev/null ; then - status "Downloading JetPack 5 components" - curl --fail --show-error --location --progress-bar \ - "https://ollama.com/download/ollama-linux-${ARCH}-jetpack5.tgz${VER_PARAM}" | \ - $SUDO tar -xzf - -C "$OLLAMA_INSTALL_DIR" + download_and_extract "https://ollama.com/download" "$OLLAMA_INSTALL_DIR" "ollama-linux-${ARCH}-jetpack5" else warning "Unsupported JetPack version detected. GPU may not be supported" fi @@ -222,10 +243,7 @@ if ! check_gpu lspci nvidia && ! check_gpu lshw nvidia && ! check_gpu lspci amdg fi if check_gpu lspci amdgpu || check_gpu lshw amdgpu; then - status "Downloading Linux ROCm ${ARCH} bundle" - curl --fail --show-error --location --progress-bar \ - "https://ollama.com/download/ollama-linux-${ARCH}-rocm.tgz${VER_PARAM}" | \ - $SUDO tar -xzf - -C "$OLLAMA_INSTALL_DIR" + download_and_extract "https://ollama.com/download" "$OLLAMA_INSTALL_DIR" "ollama-linux-${ARCH}-rocm" install_success status "AMD GPU ready."