diff options
author | David Cole <david.cole@kitware.com> | 2009-01-21 13:39:22 -0500 |
---|---|---|
committer | David Cole <david.cole@kitware.com> | 2009-01-21 13:39:22 -0500 |
commit | 36c228814b18ef115a1a72cac4f103691f249569 (patch) | |
tree | 8bcec68f08b0480ce329df9e0e28bf51b81af6ff /Source/CPack | |
parent | 88a499c54c699c0893aee2736f22afbb457fbb41 (diff) | |
download | cmake-36c228814b18ef115a1a72cac4f103691f249569.tar.gz |
BUG: Fix issue #7523: Analyze output of 'hdiutil attach' to get the name of the volume that was mounted. Eliminates the need to use the -mountpoint arg of hdiutil which has a silly 90 character limit on the name of the mount point. Also add a custom volume icon to the BundleGeneratorTest to cover this code.
Diffstat (limited to 'Source/CPack')
-rw-r--r-- | Source/CPack/cmCPackBundleGenerator.cxx | 18 | ||||
-rw-r--r-- | Source/CPack/cmCPackBundleGenerator.h | 2 |
2 files changed, 12 insertions, 8 deletions
diff --git a/Source/CPack/cmCPackBundleGenerator.cxx b/Source/CPack/cmCPackBundleGenerator.cxx index d1ecdd81fd..b37c267814 100644 --- a/Source/CPack/cmCPackBundleGenerator.cxx +++ b/Source/CPack/cmCPackBundleGenerator.cxx @@ -19,6 +19,8 @@ #include "cmCPackLog.h" #include "cmSystemTools.h" +#include <cmsys/RegularExpression.hxx> + //---------------------------------------------------------------------- cmCPackBundleGenerator::cmCPackBundleGenerator() { @@ -245,16 +247,14 @@ int cmCPackBundleGenerator::CompressFiles(const char* outFileName, if(!cpack_package_icon.empty()) { cmOStringStream temp_mount; - temp_mount << this->GetOption("CPACK_TOPLEVEL_DIRECTORY") << "/mnt"; - cmSystemTools::MakeDirectory(temp_mount.str().c_str()); cmOStringStream attach_command; attach_command << this->GetOption("CPACK_COMMAND_HDIUTIL"); attach_command << " attach"; - attach_command << " -mountpoint \"" << temp_mount.str() << "\""; attach_command << " \"" << temp_image.str() << "\""; - if(!this->RunCommand(attach_command)) + std::string attach_output; + if(!this->RunCommand(attach_command, &attach_output)) { cmCPackLogger(cmCPackLog::LOG_ERROR, "Error attaching temporary disk image." @@ -263,6 +263,10 @@ int cmCPackBundleGenerator::CompressFiles(const char* outFileName, return 0; } + cmsys::RegularExpression mountpoint_regex(".*(/Volumes/[^\n]+)\n.*"); + mountpoint_regex.find(attach_output.c_str()); + temp_mount << mountpoint_regex.match(1); + cmOStringStream setfile_command; setfile_command << this->GetOption("CPACK_COMMAND_SETFILE"); setfile_command << " -a C"; @@ -335,14 +339,14 @@ bool cmCPackBundleGenerator::CopyFile(cmOStringStream& source, } //---------------------------------------------------------------------- -bool cmCPackBundleGenerator::RunCommand(cmOStringStream& command) +bool cmCPackBundleGenerator::RunCommand(cmOStringStream& command, + std::string* output) { - std::string output; int exit_code = 1; bool result = cmSystemTools::RunSingleCommand( command.str().c_str(), - &output, + output, &exit_code, 0, this->GeneratorVerbose, diff --git a/Source/CPack/cmCPackBundleGenerator.h b/Source/CPack/cmCPackBundleGenerator.h index 9335fdd47c..2a794f3bc3 100644 --- a/Source/CPack/cmCPackBundleGenerator.h +++ b/Source/CPack/cmCPackBundleGenerator.h @@ -41,7 +41,7 @@ protected: const std::vector<std::string>& files); bool CopyFile(cmOStringStream& source, cmOStringStream& target); - bool RunCommand(cmOStringStream& command); + bool RunCommand(cmOStringStream& command, std::string* output = 0); std::string InstallPrefix; }; |