summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorAndy Cedilnik <andy.cedilnik@kitware.com>2006-03-03 20:04:28 (GMT)
committerAndy Cedilnik <andy.cedilnik@kitware.com>2006-03-03 20:04:28 (GMT)
commitce51e361fe4d53ba775636849880350898467002 (patch)
tree144837354eff8963478fb25ab1c00a15369c4ab4 /Source
parent49c0a4b52af4ca2cd7361f253bd387d812b43aa3 (diff)
downloadCMake-ce51e361fe4d53ba775636849880350898467002.zip
CMake-ce51e361fe4d53ba775636849880350898467002.tar.gz
CMake-ce51e361fe4d53ba775636849880350898467002.tar.bz2
ENH: Check package maker version
Diffstat (limited to 'Source')
-rw-r--r--Source/CPack/cmCPackPackageMakerGenerator.cxx53
-rw-r--r--Source/CPack/cmCPackPackageMakerGenerator.h2
2 files changed, 53 insertions, 2 deletions
diff --git a/Source/CPack/cmCPackPackageMakerGenerator.cxx b/Source/CPack/cmCPackPackageMakerGenerator.cxx
index 9a5ea2b..8b1e59b 100644
--- a/Source/CPack/cmCPackPackageMakerGenerator.cxx
+++ b/Source/CPack/cmCPackPackageMakerGenerator.cxx
@@ -30,6 +30,7 @@
//----------------------------------------------------------------------
cmCPackPackageMakerGenerator::cmCPackPackageMakerGenerator()
{
+ this->PackageMakerVersion = 0;
}
//----------------------------------------------------------------------
@@ -77,7 +78,11 @@ int cmCPackPackageMakerGenerator::CompressFiles(const char* outFileName, const c
<< "\" -build -p \"" << packageDirFileName << "\" -f \"" << this->GetOption("CPACK_TEMPORARY_DIRECTORY")
<< "\" -r \"" << this->GetOption("CPACK_TOPLEVEL_DIRECTORY") << "/Resources\" -i \""
<< this->GetOption("CPACK_TOPLEVEL_DIRECTORY") << "/Info.plist\" -d \""
- << this->GetOption("CPACK_TOPLEVEL_DIRECTORY") << "/Description.plist\" -v";
+ << this->GetOption("CPACK_TOPLEVEL_DIRECTORY") << "/Description.plist\"";
+ if ( this->PackageMakerVersion > 2.0 )
+ {
+ pkgCmd << " -v";
+ }
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Execute: " << pkgCmd.str().c_str() << std::endl);
std::string output;
int retVal = 1;
@@ -122,7 +127,51 @@ int cmCPackPackageMakerGenerator::Initialize(const char* name, cmMakefile* mf)
int res = this->Superclass::Initialize(name, mf);
cmCPackLogger(cmCPackLog::LOG_DEBUG, "cmCPackPackageMakerGenerator::Initialize()" << std::endl);
std::vector<std::string> path;
- std::string pkgPath = "/Developer/Applications/Utilities/PackageMaker.app/Contents/MacOS";
+ std::string pkgPath = "/Developer/Applications/Utilities/PackageMaker.app/Contents";
+ std::string versionFile = pkgPath + "/version.plist";
+ pkgPath += "/MacOS";
+ if ( !cmSystemTools::FileExists(versionFile.c_str()) )
+ {
+ cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find PackageMaker compiler version file: " << versionFile.c_str() << std::endl);
+ return 0;
+ }
+ std::ifstream ifs(versionFile.c_str());
+ if ( !ifs )
+ {
+ cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot open PackageMaker compiler version file" << std::endl);
+ return 0;
+ }
+ // Check the PackageMaker version
+ cmsys::RegularExpression rexKey("<key>CFBundleShortVersionString</key>");
+ cmsys::RegularExpression rexVersion("<string>([0-9]+.[0-9]+)</string>");
+ std::string line;
+ bool foundKey = false;
+ while ( cmSystemTools::GetLineFromStream(ifs, line) )
+ {
+ if ( rexKey.find(line) )
+ {
+ foundKey = true;
+ break;
+ }
+ }
+ if ( !foundKey )
+ {
+ cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find CFBundleShortVersionString in the PackageMaker compiler version file" << std::endl);
+ return 0;
+ }
+ if ( !cmSystemTools::GetLineFromStream(ifs, line) || !rexVersion.find(line) )
+ {
+ cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem reading the PackageMaker compiler version file" << std::endl);
+ return 0;
+ }
+ this->PackageMakerVersion = atof(rexVersion.match(1).c_str());
+ if ( this->PackageMakerVersion < 1 )
+ {
+ cmCPackLogger(cmCPackLog::LOG_ERROR, "Require PackageMaker 1.0 or higher" << std::endl);
+ return 0;
+ }
+ cmCPackLogger(cmCPackLog::LOG_DEBUG, "PackageMaker version is: " << this->PackageMakerVersion << std::endl);
+
path.push_back(pkgPath);
pkgPath = cmSystemTools::FindProgram("PackageMaker", path, false);
if ( pkgPath.empty() )
diff --git a/Source/CPack/cmCPackPackageMakerGenerator.h b/Source/CPack/cmCPackPackageMakerGenerator.h
index e56201f..d44b5af 100644
--- a/Source/CPack/cmCPackPackageMakerGenerator.h
+++ b/Source/CPack/cmCPackPackageMakerGenerator.h
@@ -51,6 +51,8 @@ protected:
bool CopyCreateResourceFile(const char* name);
bool CopyResourcePlistFile(const char* name);
+
+ float PackageMakerVersion;
};
#endif