cmake -E tar: add support for .xz files with 'J'

This commit is contained in:
Ben Boeckel 2015-01-08 16:56:33 -05:00
parent b0a5d3932d
commit df16dcfb44
5 changed files with 19 additions and 6 deletions

View File

@ -0,0 +1,5 @@
add-xz-support
--------------
* The :manual:`cmake(1)` ``-E tar`` command now supports creating
``.xz``-compressed archives with the ``J`` flag.

View File

@ -1674,7 +1674,8 @@ std::string cmCTest::Base64GzipEncodeFile(std::string file)
std::vector<std::string> files;
files.push_back(file);
if(!cmSystemTools::CreateTar(tarFile.c_str(), files, true, false, false))
if(!cmSystemTools::CreateTar(tarFile.c_str(), files,
true, false, false, false))
{
cmCTestLog(this, ERROR_MESSAGE, "Error creating tar while "
"encoding file: " << file << std::endl);

View File

@ -1482,7 +1482,8 @@ bool cmSystemTools::IsPathToFramework(const char* path)
bool cmSystemTools::CreateTar(const char* outFileName,
const std::vector<std::string>& files,
bool gzip, bool bzip2, bool verbose)
bool gzip, bool bzip2, bool xz,
bool verbose)
{
#if defined(CMAKE_BUILD_WITH_CMAKE)
std::string cwd = cmSystemTools::GetCurrentWorkingDirectory();
@ -1498,7 +1499,8 @@ bool cmSystemTools::CreateTar(const char* outFileName,
}
cmArchiveWrite a(fout, (gzip? cmArchiveWrite::CompressGZip :
(bzip2? cmArchiveWrite::CompressBZip2 :
cmArchiveWrite::CompressNone)),
(xz? cmArchiveWrite::CompressXZ :
cmArchiveWrite::CompressNone))),
cmArchiveWrite::TypeTAR);
a.SetVerbose(verbose);
for(std::vector<std::string>::const_iterator i = files.begin();

View File

@ -387,7 +387,7 @@ public:
bool gzip, bool verbose);
static bool CreateTar(const char* outFileName,
const std::vector<std::string>& files, bool gzip,
bool bzip2, bool verbose);
bool bzip2, bool xz, bool verbose);
static bool ExtractTar(const char* inFileName, bool gzip,
bool verbose);
// This should be called first thing in main

View File

@ -71,7 +71,7 @@ void CMakeCommandUsage(const char* program)
<< " remove_directory dir - remove a directory and its contents\n"
<< " rename oldname newname - rename a file or directory "
"(on one volume)\n"
<< " tar [cxt][vf][zj] file.tar [file/dir1 file/dir2 ...]\n"
<< " tar [cxt][vf][zjJ] file.tar [file/dir1 file/dir2 ...]\n"
<< " - create or extract a tar or zip archive\n"
<< " sleep <number>... - sleep for given number of seconds\n"
<< " time command [args] ... - run command and return elapsed time\n"
@ -735,11 +735,16 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
}
bool gzip = false;
bool bzip2 = false;
bool xz = false;
bool verbose = false;
if ( flags.find_first_of('j') != flags.npos )
{
bzip2 = true;
}
if ( flags.find_first_of('J') != flags.npos )
{
xz = true;
}
if ( flags.find_first_of('z') != flags.npos )
{
gzip = true;
@ -760,7 +765,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, gzip, bzip2, verbose) )
outFile.c_str(), files, gzip, bzip2, xz, verbose) )
{
cmSystemTools::Error("Problem creating tar: ", outFile.c_str());
return 1;