summaryrefslogtreecommitdiffstats
path: root/Source/cmcmd.cxx
diff options
context:
space:
mode:
authorNils Gladitz <nilsgladitz@gmail.com>2015-04-07 10:36:52 (GMT)
committerBrad King <brad.king@kitware.com>2015-04-10 12:32:31 (GMT)
commitd2cc580704fa4e608eae104ce5be211a229b2d64 (patch)
treefd9459775349e127095719de4252c790b781fd02 /Source/cmcmd.cxx
parent1264c5b2c485416128466510c42ab40a03eb0ca3 (diff)
downloadCMake-d2cc580704fa4e608eae104ce5be211a229b2d64.zip
CMake-d2cc580704fa4e608eae104ce5be211a229b2d64.tar.gz
CMake-d2cc580704fa4e608eae104ce5be211a229b2d64.tar.bz2
cmake: Teach "-E tar" command a "--format=" option
Allows specifying a libarchive defined archive format currently restricted to 7zip, gnutar, pax, paxr and zip. The default is "paxr" (pax restricted).
Diffstat (limited to 'Source/cmcmd.cxx')
-rw-r--r--Source/cmcmd.cxx33
1 files changed, 31 insertions, 2 deletions
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;