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.

This commit is contained in:
David Cole 2009-01-21 13:39:22 -05:00
parent 88a499c54c
commit 36c228814b
4 changed files with 22 additions and 9 deletions

View File

@ -19,6 +19,8 @@
#include "cmCPackLog.h" #include "cmCPackLog.h"
#include "cmSystemTools.h" #include "cmSystemTools.h"
#include <cmsys/RegularExpression.hxx>
//---------------------------------------------------------------------- //----------------------------------------------------------------------
cmCPackBundleGenerator::cmCPackBundleGenerator() cmCPackBundleGenerator::cmCPackBundleGenerator()
{ {
@ -245,16 +247,14 @@ int cmCPackBundleGenerator::CompressFiles(const char* outFileName,
if(!cpack_package_icon.empty()) if(!cpack_package_icon.empty())
{ {
cmOStringStream temp_mount; cmOStringStream temp_mount;
temp_mount << this->GetOption("CPACK_TOPLEVEL_DIRECTORY") << "/mnt";
cmSystemTools::MakeDirectory(temp_mount.str().c_str());
cmOStringStream attach_command; cmOStringStream attach_command;
attach_command << this->GetOption("CPACK_COMMAND_HDIUTIL"); attach_command << this->GetOption("CPACK_COMMAND_HDIUTIL");
attach_command << " attach"; attach_command << " attach";
attach_command << " -mountpoint \"" << temp_mount.str() << "\"";
attach_command << " \"" << temp_image.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, cmCPackLogger(cmCPackLog::LOG_ERROR,
"Error attaching temporary disk image." "Error attaching temporary disk image."
@ -263,6 +263,10 @@ int cmCPackBundleGenerator::CompressFiles(const char* outFileName,
return 0; 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; cmOStringStream setfile_command;
setfile_command << this->GetOption("CPACK_COMMAND_SETFILE"); setfile_command << this->GetOption("CPACK_COMMAND_SETFILE");
setfile_command << " -a C"; 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; int exit_code = 1;
bool result = cmSystemTools::RunSingleCommand( bool result = cmSystemTools::RunSingleCommand(
command.str().c_str(), command.str().c_str(),
&output, output,
&exit_code, &exit_code,
0, 0,
this->GeneratorVerbose, this->GeneratorVerbose,

View File

@ -41,7 +41,7 @@ protected:
const std::vector<std::string>& files); const std::vector<std::string>& files);
bool CopyFile(cmOStringStream& source, cmOStringStream& target); bool CopyFile(cmOStringStream& source, cmOStringStream& target);
bool RunCommand(cmOStringStream& command); bool RunCommand(cmOStringStream& command, std::string* output = 0);
std::string InstallPrefix; std::string InstallPrefix;
}; };

View File

@ -18,7 +18,16 @@ SET(CPACK_BUNDLE_NAME "BundleGeneratorTest")
SET(CPACK_BUNDLE_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/Info.plist") SET(CPACK_BUNDLE_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/Info.plist")
SET(CPACK_BUNDLE_STARTUP_COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/StartupCommand") SET(CPACK_BUNDLE_STARTUP_COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/StartupCommand")
SET(CPACK_PACKAGE_DESCRIPTION "Project for testing OSX bundle generation") SET(CPACK_PACKAGE_DESCRIPTION "Project for testing OSX bundle generation")
# The custom volume icon is a copy of the normal Mac OSX volume icon, but
# on a white background. This is to differentiate it from the normal one
# so that you can verify that the custom icon is being used by doing a
# visual inspection of the mounted volume... This was added when fixing
# issue #7523...
#
SET(CPACK_PACKAGE_ICON "${CMAKE_CURRENT_SOURCE_DIR}/CustomVolumeIcon.icns")
SET(CPACK_PACKAGE_NAME "BundleGeneratorTest") SET(CPACK_PACKAGE_NAME "BundleGeneratorTest")
SET(CPACK_PACKAGE_VERSION "0.1") SET(CPACK_PACKAGE_VERSION "0.1")
INCLUDE(CPack)
INCLUDE(CPack)

Binary file not shown.