summaryrefslogtreecommitdiffstats
path: root/Source/cmcmd.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2015-01-14 18:22:29 (GMT)
committerBrad King <brad.king@kitware.com>2015-01-19 19:16:19 (GMT)
commit3a60c899fce77f221cba670b62c90fe2d2daffed (patch)
tree7d7db3b6820f0766b5ecbdcb411b5d5b07ba6ed7 /Source/cmcmd.cxx
parent90f9c42732a18e53943c3aa27de76c2511c5a0c6 (diff)
downloadCMake-3a60c899fce77f221cba670b62c90fe2d2daffed.zip
CMake-3a60c899fce77f221cba670b62c90fe2d2daffed.tar.gz
CMake-3a60c899fce77f221cba670b62c90fe2d2daffed.tar.bz2
cmake: Teach "-E tar" command a "--mtime=" option
Add an option to set the mtime of entries in a tarball so that one can create a tarball with a consistent content hash (e.g. MD5) for a given set of files regardless of their current timestamps on disk. This will be useful for submission of tarballs to CDash, which tracks content hashes to avoid duplication. Inspired-by: Bill Hoffman <bill.hoffman@kitware.com>
Diffstat (limited to 'Source/cmcmd.cxx')
-rw-r--r--Source/cmcmd.cxx26
1 files changed, 24 insertions, 2 deletions
diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx
index ecf4650..7ca3eb3 100644
--- a/Source/cmcmd.cxx
+++ b/Source/cmcmd.cxx
@@ -729,9 +729,31 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
std::string flags = args[2];
std::string outFile = args[3];
std::vector<std::string> files;
+ std::string mtime;
+ bool doing_options = true;
for (std::string::size_type cc = 4; cc < args.size(); cc ++)
{
- files.push_back(args[cc]);
+ std::string const& arg = args[cc];
+ if (doing_options && cmHasLiteralPrefix(arg, "--"))
+ {
+ if (arg == "--")
+ {
+ doing_options = false;
+ }
+ else if (cmHasLiteralPrefix(arg, "--mtime="))
+ {
+ mtime = arg.substr(8);
+ }
+ else
+ {
+ cmSystemTools::Error("Unknown option to -E tar: ", arg.c_str());
+ return 1;
+ }
+ }
+ else
+ {
+ files.push_back(arg);
+ }
}
cmSystemTools::cmTarCompression compress =
cmSystemTools::TarCompressNone;
@@ -774,7 +796,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) )
+ outFile.c_str(), files, compress, verbose, mtime) )
{
cmSystemTools::Error("Problem creating tar: ", outFile.c_str());
return 1;