From: Nathan Moinvaziri Date: Sun, 2 May 2021 13:05:35 +0000 (-0700) Subject: Decompress gzip compressed archive to a separate file to prevent corruption issues... X-Git-Tag: 2.0.3~10 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=78f07cc2c4281276655956999cc6eee982f621e5;p=thirdparty%2Fzlib-ng.git Decompress gzip compressed archive to a separate file to prevent corruption issues on macOS. (#939) * Decompress gzip compressed archive to a separate file to prevent corruption issues on macOS. * Clean up fatal error messages in test-compress cmake script. --- diff --git a/cmake/test-compress.cmake b/cmake/test-compress.cmake index e5b1f3b47..4e9082114 100644 --- a/cmake/test-compress.cmake +++ b/cmake/test-compress.cmake @@ -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()