diff options
57 files changed, 276 insertions, 143 deletions
diff --git a/Help/manual/cmake.1.rst b/Help/manual/cmake.1.rst index da41bbb..b2f7e9d 100644 --- a/Help/manual/cmake.1.rst +++ b/Help/manual/cmake.1.rst @@ -215,6 +215,10 @@ Available commands are: names start in ``-``. ``--mtime=<date>`` Specify modification time recorded in tarball entries. + ``--format=<format>`` + Specify the format of the archive to be created. + Supported formats are: ``7zip``, ``gnutar``, ``pax``, + ``paxr`` (restricted pax, default), and ``zip``. ``time <command> [<args>...]`` Run command and return elapsed time. diff --git a/Help/release/dev/tar-write-format.rst b/Help/release/dev/tar-write-format.rst new file mode 100644 index 0000000..004df21 --- /dev/null +++ b/Help/release/dev/tar-write-format.rst @@ -0,0 +1,6 @@ +tar-write-format +---------------- + +* The :manual:`cmake(1)` ``-E tar`` command learned a new + ``--format<format>`` option to specify the archive format to + be written. diff --git a/Modules/CTestCoverageCollectGCOV.cmake b/Modules/CTestCoverageCollectGCOV.cmake index 8659a69..6c74cf3 100644 --- a/Modules/CTestCoverageCollectGCOV.cmake +++ b/Modules/CTestCoverageCollectGCOV.cmake @@ -198,6 +198,7 @@ ${label_files} execute_process(COMMAND ${CMAKE_COMMAND} -E tar ${tar_opts} ${GCOV_TARBALL} "--mtime=1970-01-01 0:0:0 UTC" + "--format=gnutar" --files-from=${coverage_dir}/coverage_file_list.txt WORKING_DIRECTORY ${binary_dir}) endfunction() diff --git a/Source/CPack/cmCPack7zGenerator.cxx b/Source/CPack/cmCPack7zGenerator.cxx index ce31ad4..2809e56 100644 --- a/Source/CPack/cmCPack7zGenerator.cxx +++ b/Source/CPack/cmCPack7zGenerator.cxx @@ -15,7 +15,7 @@ //---------------------------------------------------------------------- cmCPack7zGenerator::cmCPack7zGenerator() :cmCPackArchiveGenerator(cmArchiveWrite::CompressNone, - cmArchiveWrite::Type7Zip) + "7zip") { } diff --git a/Source/CPack/cmCPackArchiveGenerator.cxx b/Source/CPack/cmCPackArchiveGenerator.cxx index 05b5cd9..58bd947 100644 --- a/Source/CPack/cmCPackArchiveGenerator.cxx +++ b/Source/CPack/cmCPackArchiveGenerator.cxx @@ -27,10 +27,10 @@ //---------------------------------------------------------------------- cmCPackArchiveGenerator::cmCPackArchiveGenerator(cmArchiveWrite::Compress t, - cmArchiveWrite::Type at) + std::string const& format) { this->Compress = t; - this->Archive = at; + this->ArchiveFormat = format; } //---------------------------------------------------------------------- @@ -108,7 +108,7 @@ if (!GenerateHeader(&gf)) \ << ">." << std::endl); \ return 0; \ } \ -cmArchiveWrite archive(gf,this->Compress, this->Archive); \ +cmArchiveWrite archive(gf,this->Compress, this->ArchiveFormat); \ if (!archive) \ { \ cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem to create archive < " \ diff --git a/Source/CPack/cmCPackArchiveGenerator.h b/Source/CPack/cmCPackArchiveGenerator.h index 6411b1e..16e7632 100644 --- a/Source/CPack/cmCPackArchiveGenerator.h +++ b/Source/CPack/cmCPackArchiveGenerator.h @@ -31,7 +31,7 @@ public: /** * Construct generator */ - cmCPackArchiveGenerator(cmArchiveWrite::Compress, cmArchiveWrite::Type); + cmCPackArchiveGenerator(cmArchiveWrite::Compress, std::string const& format); virtual ~cmCPackArchiveGenerator(); // Used to add a header to the archive virtual int GenerateHeader(std::ostream* os); @@ -68,7 +68,7 @@ protected: int PackageComponentsAllInOne(); virtual const char* GetOutputExtension() = 0; cmArchiveWrite::Compress Compress; - cmArchiveWrite::Type Archive; + std::string ArchiveFormat; }; #endif diff --git a/Source/CPack/cmCPackTGZGenerator.cxx b/Source/CPack/cmCPackTGZGenerator.cxx index 509c7f8..3fa2b64 100644 --- a/Source/CPack/cmCPackTGZGenerator.cxx +++ b/Source/CPack/cmCPackTGZGenerator.cxx @@ -15,7 +15,7 @@ //---------------------------------------------------------------------- cmCPackTGZGenerator::cmCPackTGZGenerator() :cmCPackArchiveGenerator(cmArchiveWrite::CompressGZip, - cmArchiveWrite::TypeTAR) + "paxr") { } diff --git a/Source/CPack/cmCPackTXZGenerator.cxx b/Source/CPack/cmCPackTXZGenerator.cxx index ecfc177..6d4ede1 100644 --- a/Source/CPack/cmCPackTXZGenerator.cxx +++ b/Source/CPack/cmCPackTXZGenerator.cxx @@ -15,7 +15,7 @@ //---------------------------------------------------------------------- cmCPackTXZGenerator::cmCPackTXZGenerator() :cmCPackArchiveGenerator(cmArchiveWrite::CompressXZ, - cmArchiveWrite::TypeTAR) + "paxr") { } diff --git a/Source/CPack/cmCPackTarBZip2Generator.cxx b/Source/CPack/cmCPackTarBZip2Generator.cxx index ae73c37..9ff588b 100644 --- a/Source/CPack/cmCPackTarBZip2Generator.cxx +++ b/Source/CPack/cmCPackTarBZip2Generator.cxx @@ -14,7 +14,7 @@ //---------------------------------------------------------------------- cmCPackTarBZip2Generator::cmCPackTarBZip2Generator() :cmCPackArchiveGenerator(cmArchiveWrite::CompressBZip2, - cmArchiveWrite::TypeTAR) + "paxr") { } diff --git a/Source/CPack/cmCPackTarCompressGenerator.cxx b/Source/CPack/cmCPackTarCompressGenerator.cxx index df29408..1c8311b 100644 --- a/Source/CPack/cmCPackTarCompressGenerator.cxx +++ b/Source/CPack/cmCPackTarCompressGenerator.cxx @@ -15,7 +15,7 @@ //---------------------------------------------------------------------- cmCPackTarCompressGenerator::cmCPackTarCompressGenerator() :cmCPackArchiveGenerator(cmArchiveWrite::CompressCompress, - cmArchiveWrite::TypeTAR) + "paxr") { } diff --git a/Source/CPack/cmCPackZIPGenerator.cxx b/Source/CPack/cmCPackZIPGenerator.cxx index e6e4e77..7ef7729 100644 --- a/Source/CPack/cmCPackZIPGenerator.cxx +++ b/Source/CPack/cmCPackZIPGenerator.cxx @@ -15,7 +15,7 @@ //---------------------------------------------------------------------- cmCPackZIPGenerator::cmCPackZIPGenerator() :cmCPackArchiveGenerator(cmArchiveWrite::CompressNone, - cmArchiveWrite::TypeZIP) + "zip") { } diff --git a/Source/cmArchiveWrite.cxx b/Source/cmArchiveWrite.cxx index cf2fe82..72818f5 100644 --- a/Source/cmArchiveWrite.cxx +++ b/Source/cmArchiveWrite.cxx @@ -79,11 +79,12 @@ struct cmArchiveWrite::Callback }; //---------------------------------------------------------------------------- -cmArchiveWrite::cmArchiveWrite(std::ostream& os, Compress c, Type t): - Stream(os), - Archive(archive_write_new()), - Disk(archive_read_disk_new()), - Verbose(false) +cmArchiveWrite::cmArchiveWrite( + std::ostream& os, Compress c, std::string const& format): + Stream(os), + Archive(archive_write_new()), + Disk(archive_read_disk_new()), + Verbose(false) { switch (c) { @@ -141,35 +142,16 @@ cmArchiveWrite::cmArchiveWrite(std::ostream& os, Compress c, Type t): { this->Error = "archive_read_disk_set_standard_lookup: "; this->Error += cm_archive_error_string(this->Archive); - return;; + return; } #endif - switch (t) + + if(archive_write_set_format_by_name(this->Archive, format.c_str()) + != ARCHIVE_OK) { - case TypeZIP: - if(archive_write_set_format_zip(this->Archive) != ARCHIVE_OK) - { - this->Error = "archive_write_set_format_zip: "; - this->Error += cm_archive_error_string(this->Archive); - return; - } - break; - case TypeTAR: - if(archive_write_set_format_pax_restricted(this->Archive) != ARCHIVE_OK) - { - this->Error = "archive_write_set_format_pax_restricted: "; - this->Error += cm_archive_error_string(this->Archive); - return; - } - break; - case Type7Zip: - if(archive_write_set_format_7zip(this->Archive) != ARCHIVE_OK) - { - this->Error = "archive_write_set_format_7zip: "; - this->Error += cm_archive_error_string(this->Archive); - return; - } - break; + this->Error = "archive_write_set_format_by_name: "; + this->Error += cm_archive_error_string(this->Archive); + return; } // do not pad the last block!! diff --git a/Source/cmArchiveWrite.h b/Source/cmArchiveWrite.h index 17357b4..794cb28 100644 --- a/Source/cmArchiveWrite.h +++ b/Source/cmArchiveWrite.h @@ -38,16 +38,10 @@ public: CompressXZ }; - /** Archive Type */ - enum Type - { - TypeTAR, - TypeZIP, - Type7Zip - }; - /** Construct with output stream to which to write archive. */ - cmArchiveWrite(std::ostream& os, Compress c = CompressNone, Type = TypeTAR); + cmArchiveWrite(std::ostream& os, Compress c = CompressNone, + std::string const& format = "paxr"); + ~cmArchiveWrite(); /** diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 5264123..95d05a6 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -1475,7 +1475,8 @@ bool cmSystemTools::IsPathToFramework(const char* path) bool cmSystemTools::CreateTar(const char* outFileName, const std::vector<std::string>& files, cmTarCompression compressType, - bool verbose, std::string const& mtime) + bool verbose, std::string const& mtime, + std::string const& format) { #if defined(CMAKE_BUILD_WITH_CMAKE) std::string cwd = cmSystemTools::GetCurrentWorkingDirectory(); @@ -1505,8 +1506,10 @@ bool cmSystemTools::CreateTar(const char* outFileName, compress = cmArchiveWrite::CompressNone; break; } + cmArchiveWrite a(fout, compress, - cmArchiveWrite::TypeTAR); + format.empty() ? "paxr" : format); + a.SetMTime(mtime); a.SetVerbose(verbose); for(std::vector<std::string>::const_iterator i = files.begin(); diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h index c59ae96..433ef46 100644 --- a/Source/cmSystemTools.h +++ b/Source/cmSystemTools.h @@ -395,7 +395,8 @@ public: static bool CreateTar(const char* outFileName, const std::vector<std::string>& files, cmTarCompression compressType, bool verbose, - std::string const& mtime = std::string()); + std::string const& mtime = std::string(), + std::string const& format = std::string()); static bool ExtractTar(const char* inFileName, bool verbose); // This should be called first thing in main // it will keep child processes from inheriting the diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx index 9f2ea46..2ef04ef 100644 --- a/Source/cmcmd.cxx +++ b/Source/cmcmd.cxx @@ -703,10 +703,20 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) // Tar files else if (args[1] == "tar" && args.size() > 3) { + const char* knownFormats[] = + { + "7zip", + "gnutar", + "pax", + "paxr", + "zip" + }; + std::string flags = args[2]; std::string outFile = args[3]; std::vector<std::string> files; std::string mtime; + std::string format; bool doing_options = true; for (std::string::size_type cc = 4; cc < args.size(); cc ++) { @@ -729,6 +739,19 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) return 1; } } + else if (cmHasLiteralPrefix(arg, "--format=")) + { + format = arg.substr(9); + bool isKnown = std::find(cmArrayBegin(knownFormats), + cmArrayEnd(knownFormats), format) != cmArrayEnd(knownFormats); + + if(!isKnown) + { + cmSystemTools::Error("Unknown -E tar --format= argument: ", + format.c_str()); + return 1; + } + } else { cmSystemTools::Error("Unknown option to -E tar: ", arg.c_str()); @@ -759,7 +782,13 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) compress = cmSystemTools::TarCompressGZip; ++nCompress; } - if ( nCompress > 1 ) + if ( (format == "7zip" || format == "zip") && nCompress > 0 ) + { + cmSystemTools::Error("Can not use compression flags with format: ", + format.c_str()); + return 1; + } + else if ( nCompress > 1 ) { cmSystemTools::Error("Can only compress a tar file one way; " "at most one flag of z, j, or J may be used"); @@ -781,7 +810,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) else if ( flags.find_first_of('c') != flags.npos ) { if ( !cmSystemTools::CreateTar( - outFile.c_str(), files, compress, verbose, mtime) ) + outFile.c_str(), files, compress, verbose, mtime, format) ) { cmSystemTools::Error("Problem creating tar: ", outFile.c_str()); return 1; diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index f80191b..aa6a993 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -218,7 +218,6 @@ if(BUILD_TESTING) ADD_TEST_MACRO(FindModulesExecuteAll FindModulesExecuteAll) ADD_TEST_MACRO(StringFileTest StringFileTest) ADD_TEST_MACRO(TryCompile TryCompile) - ADD_TEST_MACRO(TarTest TarTest) ADD_TEST_MACRO(SystemInformation SystemInformation) ADD_TEST_MACRO(MathTest MathTest) ADD_TEST_MACRO(CompileFeatures CompileFeatures) diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 3709913..d7ac81d 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -200,6 +200,7 @@ add_RunCMake_test(target_link_libraries) add_RunCMake_test(target_compile_features) add_RunCMake_test(CheckModules) add_RunCMake_test(CommandLine) +add_RunCMake_test(CommandLineTar) add_RunCMake_test(install) add_RunCMake_test(CPackInstallProperties) diff --git a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake index e8b4584..f879ee6 100644 --- a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake +++ b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake @@ -1,16 +1,5 @@ include(RunCMake) -run_cmake_command(E_tar-bad-opt1 ${CMAKE_COMMAND} -E tar cvf bad.tar --bad) -run_cmake_command(E_tar-bad-mtime1 ${CMAKE_COMMAND} -E tar cvf bad.tar --mtime=bad .) -run_cmake_command(E_tar-bad-from1 ${CMAKE_COMMAND} -E tar cvf bad.tar --files-from=bad) -run_cmake_command(E_tar-bad-from2 ${CMAKE_COMMAND} -E tar cvf bad.tar --files-from=.) -run_cmake_command(E_tar-bad-from3 ${CMAKE_COMMAND} -E tar cvf bad.tar --files-from=${CMAKE_CURRENT_LIST_DIR}/E_tar-bad-from3.txt) -run_cmake_command(E_tar-bad-from4 ${CMAKE_COMMAND} -E tar cvf bad.tar --files-from=${CMAKE_CURRENT_LIST_DIR}/E_tar-bad-from4.txt) -run_cmake_command(E_tar-bad-from5 ${CMAKE_COMMAND} -E tar cvf bad.tar --files-from=${CMAKE_CURRENT_LIST_DIR}/E_tar-bad-from5.txt) -run_cmake_command(E_tar-end-opt1 ${CMAKE_COMMAND} -E tar cvf bad.tar -- --bad) -run_cmake_command(E_tar-end-opt2 ${CMAKE_COMMAND} -E tar cvf bad.tar --) -run_cmake_command(E_tar-mtime ${CMAKE_COMMAND} -E tar cvf bad.tar "--mtime=1970-01-01 00:00:00 UTC") - run_cmake_command(build-no-cache ${CMAKE_COMMAND} --build ${RunCMake_SOURCE_DIR}) run_cmake_command(build-no-generator diff --git a/Tests/RunCMake/CommandLine/E_tar-end-opt1-result.txt b/Tests/RunCMake/CommandLineTar/7zip-gz-result.txt index d00491f..d00491f 100644 --- a/Tests/RunCMake/CommandLine/E_tar-end-opt1-result.txt +++ b/Tests/RunCMake/CommandLineTar/7zip-gz-result.txt diff --git a/Tests/RunCMake/CommandLineTar/7zip-gz-stderr.txt b/Tests/RunCMake/CommandLineTar/7zip-gz-stderr.txt new file mode 100644 index 0000000..2fad326 --- /dev/null +++ b/Tests/RunCMake/CommandLineTar/7zip-gz-stderr.txt @@ -0,0 +1 @@ +CMake Error: Can not use compression flags with format: 7zip diff --git a/Tests/RunCMake/CommandLineTar/7zip.cmake b/Tests/RunCMake/CommandLineTar/7zip.cmake new file mode 100644 index 0000000..4bc6548 --- /dev/null +++ b/Tests/RunCMake/CommandLineTar/7zip.cmake @@ -0,0 +1,10 @@ +set(OUTPUT_NAME "test.7z") + +set(COMPRESSION_FLAGS cvf) +set(COMPRESSION_OPTIONS --format=7zip) + +set(DECOMPRESSION_FLAGS xvf) + +include(${CMAKE_CURRENT_LIST_DIR}/roundtrip.cmake) + +check_magic("377abcaf271c" LIMIT 6 HEX) diff --git a/Tests/RunCMake/CommandLineTar/CMakeLists.txt b/Tests/RunCMake/CommandLineTar/CMakeLists.txt new file mode 100644 index 0000000..2897109 --- /dev/null +++ b/Tests/RunCMake/CommandLineTar/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.0) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/CommandLineTar/RunCMakeTest.cmake b/Tests/RunCMake/CommandLineTar/RunCMakeTest.cmake new file mode 100644 index 0000000..12635db --- /dev/null +++ b/Tests/RunCMake/CommandLineTar/RunCMakeTest.cmake @@ -0,0 +1,28 @@ +include(RunCMake) + +function(external_command_test NAME) + run_cmake_command(${NAME} ${CMAKE_COMMAND} -E ${ARGN}) +endfunction() + +external_command_test(bad-opt1 tar cvf bad.tar --bad) +external_command_test(bad-mtime1 tar cvf bad.tar --mtime=bad .) +external_command_test(bad-from1 tar cvf bad.tar --files-from=bad) +external_command_test(bad-from2 tar cvf bad.tar --files-from=.) +external_command_test(bad-from3 tar cvf bad.tar --files-from=${CMAKE_CURRENT_LIST_DIR}/bad-from3.txt) +external_command_test(bad-from4 tar cvf bad.tar --files-from=${CMAKE_CURRENT_LIST_DIR}/bad-from4.txt) +external_command_test(bad-from5 tar cvf bad.tar --files-from=${CMAKE_CURRENT_LIST_DIR}/bad-from5.txt) +external_command_test(end-opt1 tar cvf bad.tar -- --bad) +external_command_test(end-opt2 tar cvf bad.tar --) +external_command_test(mtime tar cvf bad.tar "--mtime=1970-01-01 00:00:00 UTC") +external_command_test(bad-format tar cvf bad.tar "--format=bad-format") +external_command_test(zip-bz2 tar cvjf bad.tar "--format=zip") +external_command_test(7zip-gz tar cvzf bad.tar "--format=7zip") + +run_cmake(7zip) +run_cmake(gnutar) +run_cmake(gnutar-gz) +run_cmake(pax) +run_cmake(pax-xz) +run_cmake(paxr) +run_cmake(paxr-bz2) +run_cmake(zip) diff --git a/Tests/RunCMake/CommandLine/E_tar-bad-opt1-result.txt b/Tests/RunCMake/CommandLineTar/bad-format-result.txt index d00491f..d00491f 100644 --- a/Tests/RunCMake/CommandLine/E_tar-bad-opt1-result.txt +++ b/Tests/RunCMake/CommandLineTar/bad-format-result.txt diff --git a/Tests/RunCMake/CommandLineTar/bad-format-stderr.txt b/Tests/RunCMake/CommandLineTar/bad-format-stderr.txt new file mode 100644 index 0000000..fe9e2dc --- /dev/null +++ b/Tests/RunCMake/CommandLineTar/bad-format-stderr.txt @@ -0,0 +1 @@ +CMake Error: Unknown -E tar --format= argument: bad-format diff --git a/Tests/RunCMake/CommandLine/E_tar-bad-mtime1-result.txt b/Tests/RunCMake/CommandLineTar/bad-from1-result.txt index d00491f..d00491f 100644 --- a/Tests/RunCMake/CommandLine/E_tar-bad-mtime1-result.txt +++ b/Tests/RunCMake/CommandLineTar/bad-from1-result.txt diff --git a/Tests/RunCMake/CommandLine/E_tar-bad-from1-stderr.txt b/Tests/RunCMake/CommandLineTar/bad-from1-stderr.txt index d67431d..d67431d 100644 --- a/Tests/RunCMake/CommandLine/E_tar-bad-from1-stderr.txt +++ b/Tests/RunCMake/CommandLineTar/bad-from1-stderr.txt diff --git a/Tests/RunCMake/CommandLine/E_tar-bad-from5-result.txt b/Tests/RunCMake/CommandLineTar/bad-from2-result.txt index d00491f..d00491f 100644 --- a/Tests/RunCMake/CommandLine/E_tar-bad-from5-result.txt +++ b/Tests/RunCMake/CommandLineTar/bad-from2-result.txt diff --git a/Tests/RunCMake/CommandLine/E_tar-bad-from2-stderr.txt b/Tests/RunCMake/CommandLineTar/bad-from2-stderr.txt index d1d278c..d1d278c 100644 --- a/Tests/RunCMake/CommandLine/E_tar-bad-from2-stderr.txt +++ b/Tests/RunCMake/CommandLineTar/bad-from2-stderr.txt diff --git a/Tests/RunCMake/CommandLine/E_tar-bad-from4-result.txt b/Tests/RunCMake/CommandLineTar/bad-from3-result.txt index d00491f..d00491f 100644 --- a/Tests/RunCMake/CommandLine/E_tar-bad-from4-result.txt +++ b/Tests/RunCMake/CommandLineTar/bad-from3-result.txt diff --git a/Tests/RunCMake/CommandLine/E_tar-bad-from3-stderr.txt b/Tests/RunCMake/CommandLineTar/bad-from3-stderr.txt index 147bd80..da32ad9 100644 --- a/Tests/RunCMake/CommandLine/E_tar-bad-from3-stderr.txt +++ b/Tests/RunCMake/CommandLineTar/bad-from3-stderr.txt @@ -1,2 +1,2 @@ -^CMake Error: -E tar --files-from='.*/Tests/RunCMake/CommandLine/E_tar-bad-from3.txt' file invalid line: +^CMake Error: -E tar --files-from='.*/Tests/RunCMake/CommandLineTar/bad-from3.txt' file invalid line: -add-file=option-typo$ diff --git a/Tests/RunCMake/CommandLine/E_tar-bad-from3.txt b/Tests/RunCMake/CommandLineTar/bad-from3.txt index 5bad1c3..5bad1c3 100644 --- a/Tests/RunCMake/CommandLine/E_tar-bad-from3.txt +++ b/Tests/RunCMake/CommandLineTar/bad-from3.txt diff --git a/Tests/RunCMake/CommandLine/E_tar-bad-from3-result.txt b/Tests/RunCMake/CommandLineTar/bad-from4-result.txt index d00491f..d00491f 100644 --- a/Tests/RunCMake/CommandLine/E_tar-bad-from3-result.txt +++ b/Tests/RunCMake/CommandLineTar/bad-from4-result.txt diff --git a/Tests/RunCMake/CommandLine/E_tar-bad-from5-stderr.txt b/Tests/RunCMake/CommandLineTar/bad-from4-stderr.txt index 1417d4d..1417d4d 100644 --- a/Tests/RunCMake/CommandLine/E_tar-bad-from5-stderr.txt +++ b/Tests/RunCMake/CommandLineTar/bad-from4-stderr.txt diff --git a/Tests/RunCMake/CommandLine/E_tar-bad-from4.txt b/Tests/RunCMake/CommandLineTar/bad-from4.txt index 4b97f79..4b97f79 100644 --- a/Tests/RunCMake/CommandLine/E_tar-bad-from4.txt +++ b/Tests/RunCMake/CommandLineTar/bad-from4.txt diff --git a/Tests/RunCMake/CommandLine/E_tar-bad-from2-result.txt b/Tests/RunCMake/CommandLineTar/bad-from5-result.txt index d00491f..d00491f 100644 --- a/Tests/RunCMake/CommandLine/E_tar-bad-from2-result.txt +++ b/Tests/RunCMake/CommandLineTar/bad-from5-result.txt diff --git a/Tests/RunCMake/CommandLine/E_tar-bad-from4-stderr.txt b/Tests/RunCMake/CommandLineTar/bad-from5-stderr.txt index 1417d4d..1417d4d 100644 --- a/Tests/RunCMake/CommandLine/E_tar-bad-from4-stderr.txt +++ b/Tests/RunCMake/CommandLineTar/bad-from5-stderr.txt diff --git a/Tests/RunCMake/CommandLine/E_tar-bad-from5.txt b/Tests/RunCMake/CommandLineTar/bad-from5.txt index 9ea755b..9ea755b 100644 --- a/Tests/RunCMake/CommandLine/E_tar-bad-from5.txt +++ b/Tests/RunCMake/CommandLineTar/bad-from5.txt diff --git a/Tests/RunCMake/CommandLine/E_tar-bad-from1-result.txt b/Tests/RunCMake/CommandLineTar/bad-mtime1-result.txt index d00491f..d00491f 100644 --- a/Tests/RunCMake/CommandLine/E_tar-bad-from1-result.txt +++ b/Tests/RunCMake/CommandLineTar/bad-mtime1-result.txt diff --git a/Tests/RunCMake/CommandLine/E_tar-bad-mtime1-stderr.txt b/Tests/RunCMake/CommandLineTar/bad-mtime1-stderr.txt index ca925f1..ca925f1 100644 --- a/Tests/RunCMake/CommandLine/E_tar-bad-mtime1-stderr.txt +++ b/Tests/RunCMake/CommandLineTar/bad-mtime1-stderr.txt diff --git a/Tests/RunCMake/CommandLineTar/bad-opt1-result.txt b/Tests/RunCMake/CommandLineTar/bad-opt1-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CommandLineTar/bad-opt1-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/E_tar-bad-opt1-stderr.txt b/Tests/RunCMake/CommandLineTar/bad-opt1-stderr.txt index 35133c8..35133c8 100644 --- a/Tests/RunCMake/CommandLine/E_tar-bad-opt1-stderr.txt +++ b/Tests/RunCMake/CommandLineTar/bad-opt1-stderr.txt diff --git a/Tests/RunCMake/CommandLineTar/end-opt1-result.txt b/Tests/RunCMake/CommandLineTar/end-opt1-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CommandLineTar/end-opt1-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/E_tar-end-opt1-stderr.txt b/Tests/RunCMake/CommandLineTar/end-opt1-stderr.txt index 1fddf6d..1fddf6d 100644 --- a/Tests/RunCMake/CommandLine/E_tar-end-opt1-stderr.txt +++ b/Tests/RunCMake/CommandLineTar/end-opt1-stderr.txt diff --git a/Tests/RunCMake/CommandLineTar/gnutar-gz.cmake b/Tests/RunCMake/CommandLineTar/gnutar-gz.cmake new file mode 100644 index 0000000..5f2674a --- /dev/null +++ b/Tests/RunCMake/CommandLineTar/gnutar-gz.cmake @@ -0,0 +1,10 @@ +set(OUTPUT_NAME "test.tar.gz") + +set(COMPRESSION_FLAGS cvzf) +set(COMPRESSION_OPTIONS --format=gnutar) + +set(DECOMPRESSION_FLAGS xvzf) + +include(${CMAKE_CURRENT_LIST_DIR}/roundtrip.cmake) + +check_magic("1f8b" LIMIT 2 HEX) diff --git a/Tests/RunCMake/CommandLineTar/gnutar.cmake b/Tests/RunCMake/CommandLineTar/gnutar.cmake new file mode 100644 index 0000000..aaca596 --- /dev/null +++ b/Tests/RunCMake/CommandLineTar/gnutar.cmake @@ -0,0 +1,10 @@ +set(OUTPUT_NAME "test.tar") + +set(COMPRESSION_FLAGS cvf) +set(COMPRESSION_OPTIONS --format=gnutar) + +set(DECOMPRESSION_FLAGS xvf) + +include(${CMAKE_CURRENT_LIST_DIR}/roundtrip.cmake) + +check_magic("7573746172202000" OFFSET 257 LIMIT 8 HEX) diff --git a/Tests/RunCMake/CommandLineTar/pax-xz.cmake b/Tests/RunCMake/CommandLineTar/pax-xz.cmake new file mode 100644 index 0000000..baf63d5 --- /dev/null +++ b/Tests/RunCMake/CommandLineTar/pax-xz.cmake @@ -0,0 +1,10 @@ +set(OUTPUT_NAME "test.tar.xz") + +set(COMPRESSION_FLAGS cvJf) +set(COMPRESSION_OPTIONS --format=pax) + +set(DECOMPRESSION_FLAGS xvJf) + +include(${CMAKE_CURRENT_LIST_DIR}/roundtrip.cmake) + +check_magic("fd377a585a00" LIMIT 6 HEX) diff --git a/Tests/RunCMake/CommandLineTar/pax.cmake b/Tests/RunCMake/CommandLineTar/pax.cmake new file mode 100644 index 0000000..60ed238 --- /dev/null +++ b/Tests/RunCMake/CommandLineTar/pax.cmake @@ -0,0 +1,10 @@ +set(OUTPUT_NAME "test.tar") + +set(COMPRESSION_FLAGS cvf) +set(COMPRESSION_OPTIONS --format=pax) + +set(DECOMPRESSION_FLAGS xvf) + +include(${CMAKE_CURRENT_LIST_DIR}/roundtrip.cmake) + +check_magic("7573746172003030" OFFSET 257 LIMIT 8 HEX) diff --git a/Tests/RunCMake/CommandLineTar/paxr-bz2.cmake b/Tests/RunCMake/CommandLineTar/paxr-bz2.cmake new file mode 100644 index 0000000..881a0af --- /dev/null +++ b/Tests/RunCMake/CommandLineTar/paxr-bz2.cmake @@ -0,0 +1,10 @@ +set(OUTPUT_NAME "test.tar.bz2") + +set(COMPRESSION_FLAGS cvjf) +set(COMPRESSION_OPTIONS --format=paxr) + +set(DECOMPRESSION_FLAGS xvjf) + +include(${CMAKE_CURRENT_LIST_DIR}/roundtrip.cmake) + +check_magic("425a68" LIMIT 3 HEX) diff --git a/Tests/RunCMake/CommandLineTar/paxr.cmake b/Tests/RunCMake/CommandLineTar/paxr.cmake new file mode 100644 index 0000000..968a103 --- /dev/null +++ b/Tests/RunCMake/CommandLineTar/paxr.cmake @@ -0,0 +1,10 @@ +set(OUTPUT_NAME "test.tar") + +set(COMPRESSION_FLAGS cvf) +set(COMPRESSION_OPTIONS --format=paxr) + +set(DECOMPRESSION_FLAGS xvf) + +include(${CMAKE_CURRENT_LIST_DIR}/roundtrip.cmake) + +check_magic("7573746172003030" OFFSET 257 LIMIT 8 HEX) diff --git a/Tests/RunCMake/CommandLineTar/roundtrip.cmake b/Tests/RunCMake/CommandLineTar/roundtrip.cmake new file mode 100644 index 0000000..dc1c885 --- /dev/null +++ b/Tests/RunCMake/CommandLineTar/roundtrip.cmake @@ -0,0 +1,81 @@ +foreach(parameter OUTPUT_NAME COMPRESSION_FLAGS DECOMPRESSION_FLAGS) + if(NOT DEFINED ${parameter}) + message(FATAL_ERROR "missing required parameter ${parameter}") + endif() +endforeach() + +function(run_tar WORKING_DIRECTORY) + execute_process(COMMAND ${CMAKE_COMMAND} -E tar ${ARGN} + WORKING_DIRECTORY ${WORKING_DIRECTORY} + RESULT_VARIABLE result + ) + + if(NOT result STREQUAL "0") + message(FATAL_ERROR "tar failed with arguments [${ARGN}] result [${result}]") + endif() +endfunction() + +set(COMPRESS_DIR compress_dir) +set(FULL_COMPRESS_DIR ${CMAKE_CURRENT_BINARY_DIR}/${COMPRESS_DIR}) + +set(DECOMPRESS_DIR decompress_dir) +set(FULL_DECOMPRESS_DIR ${CMAKE_CURRENT_BINARY_DIR}/${DECOMPRESS_DIR}) + +set(FULL_OUTPUT_NAME ${CMAKE_CURRENT_BINARY_DIR}/${OUTPUT_NAME}) + +set(CHECK_FILES + "f1.txt" + "d1/f1.txt" + "d 2/f1.txt" + "d + 3/f1.txt" + "d_4/f1.txt" + "d-4/f1.txt" + "My Special Directory/f1.txt" +) + +foreach(file ${CHECK_FILES}) + configure_file(${CMAKE_CURRENT_LIST_FILE} ${FULL_COMPRESS_DIR}/${file} COPYONLY) +endforeach() + +if(UNIX) + execute_process(COMMAND ln -sf f1.txt ${FULL_COMPRESS_DIR}/d1/f2.txt) + list(APPEND CHECK_FILES "d1/f2.txt") +endif() + +file(REMOVE ${FULL_OUTPUT_NAME}) +file(REMOVE_RECURSE ${FULL_DECOMPRESS_DIR}) +file(MAKE_DIRECTORY ${FULL_DECOMPRESS_DIR}) + +run_tar(${CMAKE_CURRENT_BINARY_DIR} ${COMPRESSION_FLAGS} ${FULL_OUTPUT_NAME} ${COMPRESSION_OPTIONS} ${COMPRESS_DIR}) +run_tar(${FULL_DECOMPRESS_DIR} ${DECOMPRESSION_FLAGS} ${FULL_OUTPUT_NAME} ${DECOMPRESSION_OPTIONS}) + +foreach(file ${CHECK_FILES}) + set(input ${FULL_COMPRESS_DIR}/${file}) + set(output ${FULL_DECOMPRESS_DIR}/${COMPRESS_DIR}/${file}) + + if(NOT EXISTS ${input}) + message(SEND_ERROR "Cannot find input file ${output}") + endif() + + if(NOT EXISTS ${output}) + message(SEND_ERROR "Cannot find output file ${output}") + endif() + + file(MD5 ${input} input_md5) + file(MD5 ${output} output_md5) + + if(NOT input_md5 STREQUAL output_md5) + message(SEND_ERROR "Files \"${input}\" and \"${output}\" are different") + endif() +endforeach() + +function(check_magic EXPECTED) + file(READ ${FULL_OUTPUT_NAME} ACTUAL + ${ARGN} + ) + + if(NOT ACTUAL STREQUAL EXPECTED) + message(FATAL_ERROR + "Actual [${ACTUAL}] does not match expected [${EXPECTED}]") + endif() +endfunction() diff --git a/Tests/RunCMake/CommandLineTar/zip-bz2-result.txt b/Tests/RunCMake/CommandLineTar/zip-bz2-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CommandLineTar/zip-bz2-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLineTar/zip-bz2-stderr.txt b/Tests/RunCMake/CommandLineTar/zip-bz2-stderr.txt new file mode 100644 index 0000000..1134b4f --- /dev/null +++ b/Tests/RunCMake/CommandLineTar/zip-bz2-stderr.txt @@ -0,0 +1 @@ +CMake Error: Can not use compression flags with format: zip diff --git a/Tests/RunCMake/CommandLineTar/zip.cmake b/Tests/RunCMake/CommandLineTar/zip.cmake new file mode 100644 index 0000000..08e2fdb --- /dev/null +++ b/Tests/RunCMake/CommandLineTar/zip.cmake @@ -0,0 +1,10 @@ +set(OUTPUT_NAME "test.zip") + +set(COMPRESSION_FLAGS cvf) +set(COMPRESSION_OPTIONS --format=zip) + +set(DECOMPRESSION_FLAGS xvf) + +include(${CMAKE_CURRENT_LIST_DIR}/roundtrip.cmake) + +check_magic("504b0304" LIMIT 4 HEX) diff --git a/Tests/TarTest/CMakeLists.txt b/Tests/TarTest/CMakeLists.txt deleted file mode 100644 index bcc340b..0000000 --- a/Tests/TarTest/CMakeLists.txt +++ /dev/null @@ -1,69 +0,0 @@ -cmake_minimum_required (VERSION 2.6) -project(TarTest) - -# this is macro that we will be running -macro(EXEC_TAR_COMMAND DIR ARGS) - exec_program("${CMAKE_COMMAND}" "${DIR}" ARGS "-E tar ${ARGS}" RETURN_VALUE RET) - if(${RET}) - message(FATAL_ERROR "CMake tar command failed with arguments \"${ARGS}\"") - endif() -endmacro() - -# Create a directory structure -set(CHECK_FILES) -macro(COPY F1 F2) - configure_file("${CMAKE_CURRENT_SOURCE_DIR}/${F1}" "${CMAKE_CURRENT_BINARY_DIR}/tar_dir/${F2}" COPYONLY) - set(CHECK_FILES ${CHECK_FILES} "${F2}") -endmacro() -COPY("CMakeLists.txt" "f1.txt") -COPY("CMakeLists.txt" "d1/f1.txt") -COPY("CMakeLists.txt" "d 2/f1.txt") -COPY("CMakeLists.txt" "d + 3/f1.txt") -COPY("CMakeLists.txt" "d_4/f1.txt") -COPY("CMakeLists.txt" "d-4/f1.txt") -COPY("CMakeLists.txt" "My Special Directory/f1.txt") - -if(UNIX) - exec_program("ln" ARGS "-sf f1.txt \"${CMAKE_CURRENT_BINARY_DIR}/tar_dir/d1/f2.txt\"") - set(CHECK_FILES ${CHECK_FILES} "d1/f2.txt") -endif() - -# cleanup first in case there are files left from previous runs -# if the umask is odd on the machine it might create files that -# are not automatically over written. These tests are run -# each time the configure step is run. -file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/test_tar.tar") -file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/test_tgz.tgz") -file(REMOVE_RECURSE "${CMAKE_CURRENT_BINARY_DIR}/test_output_tar") -file(REMOVE_RECURSE "${CMAKE_CURRENT_BINARY_DIR}/test_output_tgz") - -make_directory("${CMAKE_CURRENT_BINARY_DIR}/test_output_tar") -make_directory("${CMAKE_CURRENT_BINARY_DIR}/test_output_tgz") - - -# Run tests -EXEC_TAR_COMMAND("${CMAKE_CURRENT_BINARY_DIR}" "cvf \"${CMAKE_CURRENT_BINARY_DIR}/test_tar.tar\" tar_dir") -EXEC_TAR_COMMAND("${CMAKE_CURRENT_BINARY_DIR}" "cvfz \"${CMAKE_CURRENT_BINARY_DIR}/test_tgz.tgz\" tar_dir") - -EXEC_TAR_COMMAND("${CMAKE_CURRENT_BINARY_DIR}/test_output_tar" "xvf \"${CMAKE_CURRENT_BINARY_DIR}/test_tar.tar\"") -EXEC_TAR_COMMAND("${CMAKE_CURRENT_BINARY_DIR}/test_output_tgz" "xvfz \"${CMAKE_CURRENT_BINARY_DIR}/test_tgz.tgz\"") - -macro(CHECK_DIR_STRUCTURE DIR) - foreach(file ${CHECK_FILES}) - set(sfile "${DIR}/${file}") - set(rfile "${CMAKE_CURRENT_BINARY_DIR}/tar_dir/${file}") - if(NOT EXISTS "${sfile}") - message(SEND_ERROR "Cannot find file ${sfile}") - else() - exec_program("${CMAKE_COMMAND}" ARGS "-E compare_files \"${sfile}\" \"${rfile}\"" RETURN_VALUE ret) - if(${ret}) - message(SEND_ERROR "Files \"${sfile}\" \"${rfile}\" are different") - endif() - endif() - endforeach() -endmacro() - -CHECK_DIR_STRUCTURE("${CMAKE_CURRENT_BINARY_DIR}/test_output_tar/tar_dir") - -add_executable(TarTest TestTarExec.cxx) - diff --git a/Tests/TarTest/TestTarExec.cxx b/Tests/TarTest/TestTarExec.cxx deleted file mode 100644 index 86f2cd1..0000000 --- a/Tests/TarTest/TestTarExec.cxx +++ /dev/null @@ -1,5 +0,0 @@ -int main() -{ - return 0; -} - |