Ver Fonte

use `gzip` for runner embedding (#2067)

Jeffrey Morgan há 1 ano atrás
pai
commit
dc88cc3981

+ 1 - 1
llm/generate/gen_common.sh

@@ -84,7 +84,7 @@ compress_libs() {
     echo "Compressing payloads to reduce overall binary size..."
     pids=""
     for lib in ${BUILD_DIR}/lib/*.${LIB_EXT}* ; do
-        bzip2 -v9 ${lib} &
+        gzip --best ${lib} &
         pids+=" $!"
     done
     echo 

+ 4 - 4
llm/generate/gen_windows.ps1

@@ -23,7 +23,7 @@ function init_vars {
     } else {
         $script:CUDA_LIB_DIR=$env:CUDA_LIB_DIR
     }
-    $script:BZIP2=(get-command -ea 'silentlycontinue' bzip2).path
+    $script:GZIP=(get-command -ea 'silentlycontinue' gzip).path
     $script:DUMPBIN=(get-command -ea 'silentlycontinue' dumpbin).path
 }
 
@@ -69,14 +69,14 @@ function install {
 }
 
 function compress_libs {
-    if ($script:BZIP2 -eq $null) {
-        write-host "bzip2 not installed, not compressing files"
+    if ($script:GZIP -eq $null) {
+        write-host "gzip not installed, not compressing files"
         return
     }
     write-host "Compressing dlls..."
     $libs = dir "${script:buildDir}/lib/*.dll"
     foreach ($file in $libs) {
-        & "$script:BZIP2" -v9 $file
+        & "$script:GZIP" --best $file
     }
 }
 

+ 13 - 7
llm/payload_common.go

@@ -1,7 +1,7 @@
 package llm
 
 import (
-	"compress/bzip2"
+	"compress/gzip"
 	"errors"
 	"fmt"
 	"io"
@@ -182,9 +182,12 @@ func extractDynamicLibs(workDir, glob string) ([]string, error) {
 			}
 			src := io.Reader(srcFile)
 			filename := file
-			if strings.HasSuffix(file, ".bz2") {
-				src = bzip2.NewReader(src)
-				filename = strings.TrimSuffix(filename, ".bz2")
+			if strings.HasSuffix(file, ".gz") {
+				src, err = gzip.NewReader(src)
+				if err != nil {
+					return fmt.Errorf("decompress payload %s: %v", file, err)
+				}
+				filename = strings.TrimSuffix(filename, ".gz")
 			}
 
 			destFile := filepath.Join(targetDir, filepath.Base(filename))
@@ -229,9 +232,12 @@ func extractPayloadFiles(workDir, glob string) error {
 		}
 		src := io.Reader(srcFile)
 		filename := file
-		if strings.HasSuffix(file, ".bz2") {
-			src = bzip2.NewReader(src)
-			filename = strings.TrimSuffix(filename, ".bz2")
+		if strings.HasSuffix(file, ".gz") {
+			src, err = gzip.NewReader(src)
+			if err != nil {
+				return fmt.Errorf("decompress payload %s: %v", file, err)
+			}
+			filename = strings.TrimSuffix(filename, ".gz")
 		}
 
 		destFile := filepath.Join(workDir, filepath.Base(filename))

+ 0 - 1
scripts/rh_linux_deps.sh

@@ -28,7 +28,6 @@ fi
 
 if [ -n "${CMAKE_VERSION}" ]; then
     curl -s -L https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}-linux-$(uname -m).tar.gz | tar -zx -C /usr --strip-components 1
-    dnf install -y bzip2
 fi
 
 if [ -n "${GOLANG_VERSION}" ]; then