From 7f7102f90c0c061926702237a5b385450c02f7c5 Mon Sep 17 00:00:00 2001 From: lethosor Date: Sat, 15 Oct 2016 12:07:50 -0400 Subject: [PATCH] Distribute a gunzip.pl script gunzip isn't reliably available on Windows, but IO::Uncompress::Gunzip should be. Suggested by Quietust. --- CMake/DownloadFile.cmake | 4 +++- depends/gunzip.pl | 21 +++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100755 depends/gunzip.pl diff --git a/CMake/DownloadFile.cmake b/CMake/DownloadFile.cmake index 1a8a40562..8f9938f90 100644 --- a/CMake/DownloadFile.cmake +++ b/CMake/DownloadFile.cmake @@ -31,7 +31,9 @@ function(download_file_unzip URL ZIP_TYPE ZIP_DEST ZIP_MD5 UNZIP_DEST UNZIP_MD5) if(EXISTS "${ZIP_DEST}") message("* Decompressing ${FILENAME}") if("${ZIP_TYPE}" STREQUAL "gz") - execute_process(COMMAND gunzip --force "${ZIP_DEST}") + execute_process(COMMAND + "${PERL_EXECUTABLE}" "${CMAKE_SOURCE_DIR}/depends/gunzip.pl" + "${ZIP_DEST}" --force) else() message(SEND_ERROR "Unknown ZIP_TYPE: ${ZIP_TYPE}") endif() diff --git a/depends/gunzip.pl b/depends/gunzip.pl new file mode 100755 index 000000000..4a21daafd --- /dev/null +++ b/depends/gunzip.pl @@ -0,0 +1,21 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +use IO::Uncompress::Gunzip qw(gunzip $GunzipError); + +my %args = map { $_ => 1 } @ARGV; + +my $in_file = $ARGV[0] or die "no input file"; +# remove extension +(my $out_file = $in_file) =~ s{\.[^.]+$}{}; + +if (! -f $in_file) { + die "input file does not exist: \"$in_file\"\n"; +} +if (-f $out_file and !exists($args{'--force'})) { + die "output file exists, not overwriting: \"$out_file\""; +} + +gunzip $in_file => $out_file or die "gunzip failed: $GunzipError\n";