]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
Decompress gzip compressed archive to a separate file to prevent corruption issues...
authorNathan Moinvaziri <nathan@nathanm.com>
Sun, 2 May 2021 13:05:35 +0000 (06:05 -0700)
committerGitHub <noreply@github.com>
Sun, 2 May 2021 13:05:35 +0000 (15:05 +0200)
* Decompress gzip compressed archive to a separate file to prevent corruption issues on macOS.
* Clean up fatal error messages in test-compress cmake script.

cmake/test-compress.cmake

index e5b1f3b471fc9fd8d1326253eb4226896ce9a48b..4e90821147fba2654c4cdfcd229a647e9cbbe9b0 100644 (file)
@@ -65,10 +65,13 @@ get_filename_component(OUTPUT_DIR "${OUTPUT_BASE}" DIRECTORY)
 file(MAKE_DIRECTORY "${OUTPUT_DIR}")
 
 macro(cleanup)
-    # Cleanup temporary mingizip files
-    file(REMOVE ${OUTPUT_BASE}.gz ${OUTPUT_BASE}.out)
-    # Cleanup temporary gzip files
-    file(REMOVE ${OUTPUT_BASE}.gzip.gz ${OUTPUT_BASE}.gzip.out)
+    # Cleanup temporary files
+    file(REMOVE
+        ${OUTPUT_BASE}.gz
+        ${OUTPUT_BASE}.out
+        ${OUTPUT_BASE}.gzip
+        ${OUTPUT_BASE}.gzip.gz
+        ${OUTPUT_BASE}.gzip.out)
 endmacro()
 
 # Compress input file
@@ -180,34 +183,34 @@ if(GZIP_VERIFY AND NOT "${COMPRESS_ARGS}" MATCHES "-T")
             message(FATAL_ERROR "Gzip compress failed: ${CMD_RESULT}")
         endif()
 
-        if(NOT EXISTS ${OUTPUT_BASE}.gz)
+        if(NOT EXISTS ${OUTPUT_BASE}.gzip.gz)
             cleanup()
-            message(FATAL_ERROR "Cannot find minigzip decompress input: ${OUTPUT_BASE}.gzip.gz")
+            message(FATAL_ERROR "Cannot find decompress gzip input: ${OUTPUT_BASE}.gzip.gz")
         endif()
 
         # Check decompress target can handle gzip compressed output
         execute_process(COMMAND ${CMAKE_COMMAND}
             "-DCOMMAND=${DECOMPRESS_COMMAND}"
             -DINPUT=${OUTPUT_BASE}.gzip.gz
-            -DOUTPUT=${OUTPUT_BASE}.gzip.out
+            -DOUTPUT=${OUTPUT_BASE}.gzip
             "-DSUCCESS_EXIT=${SUCCESS_EXIT}"
             -P ${CMAKE_CURRENT_LIST_DIR}/run-and-redirect.cmake
             RESULT_VARIABLE CMD_RESULT)
 
         if(CMD_RESULT)
             cleanup()
-            message(FATAL_ERROR "Minigzip decompress gzip failed: ${CMD_RESULT}")
+            message(FATAL_ERROR "Decompress gzip failed: ${CMD_RESULT}")
         endif()
 
         if(COMPARE)
             # Compare original input file with gzip decompressed output
             execute_process(COMMAND ${CMAKE_COMMAND}
-                -E compare_files ${INPUT} ${OUTPUT_BASE}.gzip.out
+                -E compare_files ${INPUT} ${OUTPUT_BASE}.gzip
                 RESULT_VARIABLE CMD_RESULT)
 
             if(CMD_RESULT)
                 cleanup()
-                message(FATAL_ERROR "Compare minigzip decompress gzip failed: ${CMD_RESULT}")
+                message(FATAL_ERROR "Compare decompress gzip failed: ${CMD_RESULT}")
             endif()
         endif()
     endif()