diff options
author | Brad King <brad.king@kitware.com> | 2020-04-06 12:28:04 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2020-04-06 12:28:19 (GMT) |
commit | f0a27e44f32cbb40669dd4ec81d4029d69bc82a0 (patch) | |
tree | 466c3a98d2c818c586e81d7665b1a2da479e3e96 /Source/CPack | |
parent | 2b9e3abcb5f55fa74ff50979176545da6c56e368 (diff) | |
parent | b3bacf0152c15d46b5392c622b46dbfa2ad8c6c2 (diff) | |
download | CMake-f0a27e44f32cbb40669dd4ec81d4029d69bc82a0.zip CMake-f0a27e44f32cbb40669dd4ec81d4029d69bc82a0.tar.gz CMake-f0a27e44f32cbb40669dd4ec81d4029d69bc82a0.tar.bz2 |
Merge topic 'parallel-lzma-compression'
b3bacf0152 cmCPackArchiveGenerator: support multithreaded compression
b71d385ed4 cmCPackArchiveGenerator: support setting archive options
948aa8bd1c cmArchiveWrite: support setting archive filter options
b9c17de023 cmArchiveWrite: split out opening the file
Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Cristian Adam <cristian.adam@gmail.com>
Merge-request: !3195
Diffstat (limited to 'Source/CPack')
-rw-r--r-- | Source/CPack/cmCPackArchiveGenerator.cxx | 36 | ||||
-rw-r--r-- | Source/CPack/cmCPackArchiveGenerator.h | 2 | ||||
-rw-r--r-- | Source/CPack/cmCPackDebGenerator.cxx | 3 |
3 files changed, 41 insertions, 0 deletions
diff --git a/Source/CPack/cmCPackArchiveGenerator.cxx b/Source/CPack/cmCPackArchiveGenerator.cxx index 43f2946..aaa5318 100644 --- a/Source/CPack/cmCPackArchiveGenerator.cxx +++ b/Source/CPack/cmCPackArchiveGenerator.cxx @@ -8,6 +8,8 @@ #include <utility> #include <vector> +#include "cm_libarchive.h" + #include "cmCPackComponentGroup.h" #include "cmCPackGenerator.h" #include "cmCPackLog.h" @@ -154,6 +156,20 @@ int cmCPackArchiveGenerator::addOneComponentToArchive( } \ cmArchiveWrite archive(gf, this->Compress, this->ArchiveFormat); \ do { \ + if (!this->SetArchiveOptions(&archive)) { \ + cmCPackLogger(cmCPackLog::LOG_ERROR, \ + "Problem to set archive options <" \ + << (filename) << ">, ERROR = " << (archive).GetError() \ + << std::endl); \ + return 0; \ + } \ + if (!archive.Open()) { \ + cmCPackLogger(cmCPackLog::LOG_ERROR, \ + "Problem to open archive <" \ + << (filename) << ">, ERROR = " << (archive).GetError() \ + << std::endl); \ + return 0; \ + } \ if (!(archive)) { \ cmCPackLogger(cmCPackLog::LOG_ERROR, \ "Problem to create archive <" \ @@ -328,3 +344,23 @@ bool cmCPackArchiveGenerator::SupportsComponentInstallation() const // (for backward compatibility reason) return IsOn("CPACK_ARCHIVE_COMPONENT_INSTALL"); } + +bool cmCPackArchiveGenerator::SetArchiveOptions(cmArchiveWrite* archive) +{ +#if ARCHIVE_VERSION_NUMBER >= 3004000 + // Upstream fixed an issue with their integer parsing in 3.4.0 which would + // cause spurious errors to be raised from `strtoull`. + if (this->Compress == cmArchiveWrite::CompressXZ) { + const char* threads = "1"; + if (this->IsSet("CPACK_ARCHIVE_THREADS")) { + threads = this->GetOption("CPACK_ARCHIVE_THREADS"); + } + + if (!archive->SetFilterOption("xz", "threads", threads)) { + return false; + } + } +#endif + + return true; +} diff --git a/Source/CPack/cmCPackArchiveGenerator.h b/Source/CPack/cmCPackArchiveGenerator.h index 8d67720..7eb5665 100644 --- a/Source/CPack/cmCPackArchiveGenerator.h +++ b/Source/CPack/cmCPackArchiveGenerator.h @@ -86,6 +86,8 @@ private: return this->OutputExtension.c_str(); } + bool SetArchiveOptions(cmArchiveWrite* archive); + private: cmArchiveWrite::Compress Compress; std::string ArchiveFormat; diff --git a/Source/CPack/cmCPackDebGenerator.cxx b/Source/CPack/cmCPackDebGenerator.cxx index 5b7d8fb..c30a57a 100644 --- a/Source/CPack/cmCPackDebGenerator.cxx +++ b/Source/CPack/cmCPackDebGenerator.cxx @@ -173,6 +173,7 @@ bool DebGenerator::generateDataTar() const } cmArchiveWrite data_tar(fileStream_data_tar, TarCompressionType, DebianArchiveType); + data_tar.Open(); // uid/gid should be the one of the root user, and this root user has // always uid/gid equal to 0. @@ -291,6 +292,7 @@ bool DebGenerator::generateControlTar(std::string const& md5Filename) const } cmArchiveWrite control_tar(fileStream_control_tar, cmArchiveWrite::CompressGZip, DebianArchiveType); + control_tar.Open(); // sets permissions and uid/gid for the files control_tar.SetUIDAndGID(0u, 0u); @@ -410,6 +412,7 @@ bool DebGenerator::generateDeb() const cmGeneratedFileStream debStream; debStream.Open(outputPath, false, true); cmArchiveWrite deb(debStream, cmArchiveWrite::CompressNone, "arbsd"); + deb.Open(); // uid/gid should be the one of the root user, and this root user has // always uid/gid equal to 0. |