1
0

cmCPackPackageMakerGenerator.cxx 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582
  1. /*============================================================================
  2. CMake - Cross Platform Makefile Generator
  3. Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
  4. Distributed under the OSI-approved BSD License (the "License");
  5. see accompanying file Copyright.txt for details.
  6. This software is distributed WITHOUT ANY WARRANTY; without even the
  7. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  8. See the License for more information.
  9. ============================================================================*/
  10. #include "cmCPackPackageMakerGenerator.h"
  11. #include "cmCPackComponentGroup.h"
  12. #include "cmCPackLog.h"
  13. #include "cmGeneratedFileStream.h"
  14. #include "cmGlobalGenerator.h"
  15. #include "cmMakefile.h"
  16. #include "cmSystemTools.h"
  17. #include "cmake.h"
  18. #include <cmsys/FStream.hxx>
  19. #include <cmsys/Glob.hxx>
  20. #include <cmsys/SystemTools.hxx>
  21. #include <assert.h>
  22. static inline unsigned int getVersion(unsigned int major, unsigned int minor)
  23. {
  24. assert(major < 256 && minor < 256);
  25. return ((major & 0xFF) << 16 | minor);
  26. }
  27. cmCPackPackageMakerGenerator::cmCPackPackageMakerGenerator()
  28. {
  29. this->PackageMakerVersion = 0.0;
  30. this->PackageCompatibilityVersion = getVersion(10, 4);
  31. }
  32. cmCPackPackageMakerGenerator::~cmCPackPackageMakerGenerator()
  33. {
  34. }
  35. bool cmCPackPackageMakerGenerator::SupportsComponentInstallation() const
  36. {
  37. return this->PackageCompatibilityVersion >= getVersion(10, 4);
  38. }
  39. int cmCPackPackageMakerGenerator::PackageFiles()
  40. {
  41. // TODO: Use toplevel
  42. // It is used! Is this an obsolete comment?
  43. std::string resDir; // Where this package's resources will go.
  44. std::string packageDirFileName =
  45. this->GetOption("CPACK_TEMPORARY_DIRECTORY");
  46. if (this->Components.empty()) {
  47. packageDirFileName += ".pkg";
  48. resDir = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
  49. resDir += "/Resources";
  50. } else {
  51. packageDirFileName += ".mpkg";
  52. if (!cmsys::SystemTools::MakeDirectory(packageDirFileName.c_str())) {
  53. cmCPackLogger(cmCPackLog::LOG_ERROR,
  54. "unable to create package directory " << packageDirFileName
  55. << std::endl);
  56. return 0;
  57. }
  58. resDir = packageDirFileName;
  59. resDir += "/Contents";
  60. if (!cmsys::SystemTools::MakeDirectory(resDir.c_str())) {
  61. cmCPackLogger(cmCPackLog::LOG_ERROR,
  62. "unable to create package subdirectory " << resDir
  63. << std::endl);
  64. return 0;
  65. }
  66. resDir += "/Resources";
  67. if (!cmsys::SystemTools::MakeDirectory(resDir.c_str())) {
  68. cmCPackLogger(cmCPackLog::LOG_ERROR,
  69. "unable to create package subdirectory " << resDir
  70. << std::endl);
  71. return 0;
  72. }
  73. resDir += "/en.lproj";
  74. }
  75. const char* preflight = this->GetOption("CPACK_PREFLIGHT_SCRIPT");
  76. const char* postflight = this->GetOption("CPACK_POSTFLIGHT_SCRIPT");
  77. const char* postupgrade = this->GetOption("CPACK_POSTUPGRADE_SCRIPT");
  78. if (this->Components.empty()) {
  79. // Create directory structure
  80. std::string preflightDirName = resDir + "/PreFlight";
  81. std::string postflightDirName = resDir + "/PostFlight";
  82. // if preflight or postflight scripts not there create directories
  83. // of the same name, I think this makes it work
  84. if (!preflight) {
  85. if (!cmsys::SystemTools::MakeDirectory(preflightDirName.c_str())) {
  86. cmCPackLogger(cmCPackLog::LOG_ERROR,
  87. "Problem creating installer directory: "
  88. << preflightDirName.c_str() << std::endl);
  89. return 0;
  90. }
  91. }
  92. if (!postflight) {
  93. if (!cmsys::SystemTools::MakeDirectory(postflightDirName.c_str())) {
  94. cmCPackLogger(cmCPackLog::LOG_ERROR,
  95. "Problem creating installer directory: "
  96. << postflightDirName.c_str() << std::endl);
  97. return 0;
  98. }
  99. }
  100. // if preflight, postflight, or postupgrade are set
  101. // then copy them into the resource directory and make
  102. // them executable
  103. if (preflight) {
  104. this->CopyInstallScript(resDir.c_str(), preflight, "preflight");
  105. }
  106. if (postflight) {
  107. this->CopyInstallScript(resDir.c_str(), postflight, "postflight");
  108. }
  109. if (postupgrade) {
  110. this->CopyInstallScript(resDir.c_str(), postupgrade, "postupgrade");
  111. }
  112. } else if (postflight) {
  113. // create a postflight component to house the script
  114. this->PostFlightComponent.Name = "PostFlight";
  115. this->PostFlightComponent.DisplayName = "PostFlight";
  116. this->PostFlightComponent.Description = "PostFlight";
  117. this->PostFlightComponent.IsHidden = true;
  118. // empty directory for pkg contents
  119. std::string packageDir = toplevel + "/" + PostFlightComponent.Name;
  120. if (!cmsys::SystemTools::MakeDirectory(packageDir.c_str())) {
  121. cmCPackLogger(cmCPackLog::LOG_ERROR,
  122. "Problem creating component packages directory: "
  123. << packageDir.c_str() << std::endl);
  124. return 0;
  125. }
  126. // create package
  127. std::string packageFileDir = packageDirFileName + "/Contents/Packages/";
  128. if (!cmsys::SystemTools::MakeDirectory(packageFileDir.c_str())) {
  129. cmCPackLogger(
  130. cmCPackLog::LOG_ERROR,
  131. "Problem creating component PostFlight Packages directory: "
  132. << packageFileDir.c_str() << std::endl);
  133. return 0;
  134. }
  135. std::string packageFile =
  136. packageFileDir + this->GetPackageName(PostFlightComponent);
  137. if (!this->GenerateComponentPackage(
  138. packageFile.c_str(), packageDir.c_str(), PostFlightComponent)) {
  139. return 0;
  140. }
  141. // copy postflight script into resource directory of .pkg
  142. std::string resourceDir = packageFile + "/Contents/Resources";
  143. this->CopyInstallScript(resourceDir.c_str(), postflight, "postflight");
  144. }
  145. if (!this->Components.empty()) {
  146. // Create the directory where component packages will be built.
  147. std::string basePackageDir = packageDirFileName;
  148. basePackageDir += "/Contents/Packages";
  149. if (!cmsys::SystemTools::MakeDirectory(basePackageDir.c_str())) {
  150. cmCPackLogger(cmCPackLog::LOG_ERROR,
  151. "Problem creating component packages directory: "
  152. << basePackageDir.c_str() << std::endl);
  153. return 0;
  154. }
  155. // Create the directory where downloaded component packages will
  156. // be placed.
  157. const char* userUploadDirectory =
  158. this->GetOption("CPACK_UPLOAD_DIRECTORY");
  159. std::string uploadDirectory;
  160. if (userUploadDirectory && *userUploadDirectory) {
  161. uploadDirectory = userUploadDirectory;
  162. } else {
  163. uploadDirectory = this->GetOption("CPACK_PACKAGE_DIRECTORY");
  164. uploadDirectory += "/CPackUploads";
  165. }
  166. // Create packages for each component
  167. bool warnedAboutDownloadCompatibility = false;
  168. std::map<std::string, cmCPackComponent>::iterator compIt;
  169. for (compIt = this->Components.begin(); compIt != this->Components.end();
  170. ++compIt) {
  171. std::string packageFile;
  172. if (compIt->second.IsDownloaded) {
  173. if (this->PackageCompatibilityVersion >= getVersion(10, 5) &&
  174. this->PackageMakerVersion >= 3.0) {
  175. // Build this package within the upload directory.
  176. packageFile = uploadDirectory;
  177. if (!cmSystemTools::FileExists(uploadDirectory.c_str())) {
  178. if (!cmSystemTools::MakeDirectory(uploadDirectory.c_str())) {
  179. cmCPackLogger(cmCPackLog::LOG_ERROR,
  180. "Unable to create package upload directory "
  181. << uploadDirectory << std::endl);
  182. return 0;
  183. }
  184. }
  185. } else if (!warnedAboutDownloadCompatibility) {
  186. if (this->PackageCompatibilityVersion < getVersion(10, 5)) {
  187. cmCPackLogger(
  188. cmCPackLog::LOG_WARNING,
  189. "CPack warning: please set CPACK_OSX_PACKAGE_VERSION to 10.5 "
  190. "or greater enable downloaded packages. CPack will build a "
  191. "non-downloaded package."
  192. << std::endl);
  193. }
  194. if (this->PackageMakerVersion < 3) {
  195. cmCPackLogger(cmCPackLog::LOG_WARNING,
  196. "CPack warning: unable to build downloaded "
  197. "packages with PackageMaker versions prior "
  198. "to 3.0. CPack will build a non-downloaded package."
  199. << std::endl);
  200. }
  201. warnedAboutDownloadCompatibility = true;
  202. }
  203. }
  204. if (packageFile.empty()) {
  205. // Build this package within the overall distribution
  206. // metapackage.
  207. packageFile = basePackageDir;
  208. // We're not downloading this component, even if the user
  209. // requested it.
  210. compIt->second.IsDownloaded = false;
  211. }
  212. packageFile += '/';
  213. packageFile += GetPackageName(compIt->second);
  214. std::string packageDir = toplevel;
  215. packageDir += '/';
  216. packageDir += compIt->first;
  217. if (!this->GenerateComponentPackage(
  218. packageFile.c_str(), packageDir.c_str(), compIt->second)) {
  219. return 0;
  220. }
  221. }
  222. }
  223. this->SetOption("CPACK_MODULE_VERSION_SUFFIX", "");
  224. // Copy or create all of the resource files we need.
  225. if (!this->CopyCreateResourceFile("License", resDir.c_str()) ||
  226. !this->CopyCreateResourceFile("ReadMe", resDir.c_str()) ||
  227. !this->CopyCreateResourceFile("Welcome", resDir.c_str()) ||
  228. !this->CopyResourcePlistFile("Info.plist") ||
  229. !this->CopyResourcePlistFile("Description.plist")) {
  230. cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem copying the resource files"
  231. << std::endl);
  232. return 0;
  233. }
  234. if (this->Components.empty()) {
  235. // Use PackageMaker to build the package.
  236. std::ostringstream pkgCmd;
  237. pkgCmd << "\"" << this->GetOption("CPACK_INSTALLER_PROGRAM")
  238. << "\" -build -p \"" << packageDirFileName << "\"";
  239. if (this->Components.empty()) {
  240. pkgCmd << " -f \"" << this->GetOption("CPACK_TEMPORARY_DIRECTORY");
  241. } else {
  242. pkgCmd << " -mi \"" << this->GetOption("CPACK_TEMPORARY_DIRECTORY")
  243. << "/packages/";
  244. }
  245. pkgCmd << "\" -r \"" << this->GetOption("CPACK_TOPLEVEL_DIRECTORY")
  246. << "/Resources\" -i \""
  247. << this->GetOption("CPACK_TOPLEVEL_DIRECTORY")
  248. << "/Info.plist\" -d \""
  249. << this->GetOption("CPACK_TOPLEVEL_DIRECTORY")
  250. << "/Description.plist\"";
  251. if (this->PackageMakerVersion > 2.0) {
  252. pkgCmd << " -v";
  253. }
  254. if (!RunPackageMaker(pkgCmd.str().c_str(), packageDirFileName.c_str()))
  255. return 0;
  256. } else {
  257. // We have built the package in place. Generate the
  258. // distribution.dist file to describe it for the installer.
  259. WriteDistributionFile(packageDirFileName.c_str());
  260. }
  261. std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
  262. tmpFile += "/hdiutilOutput.log";
  263. std::ostringstream dmgCmd;
  264. dmgCmd << "\"" << this->GetOption("CPACK_INSTALLER_PROGRAM_DISK_IMAGE")
  265. << "\" create -ov -format UDZO -srcfolder \"" << packageDirFileName
  266. << "\" \"" << packageFileNames[0] << "\"";
  267. std::string output;
  268. int retVal = 1;
  269. int numTries = 10;
  270. bool res = false;
  271. while (numTries > 0) {
  272. res =
  273. cmSystemTools::RunSingleCommand(dmgCmd.str().c_str(), &output, &output,
  274. &retVal, 0, this->GeneratorVerbose, 0);
  275. if (res && !retVal) {
  276. numTries = -1;
  277. break;
  278. }
  279. cmSystemTools::Delay(500);
  280. numTries--;
  281. }
  282. if (!res || retVal) {
  283. cmGeneratedFileStream ofs(tmpFile.c_str());
  284. ofs << "# Run command: " << dmgCmd.str().c_str() << std::endl
  285. << "# Output:" << std::endl
  286. << output.c_str() << std::endl;
  287. cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem running hdiutil command: "
  288. << dmgCmd.str().c_str() << std::endl
  289. << "Please check " << tmpFile.c_str() << " for errors"
  290. << std::endl);
  291. return 0;
  292. }
  293. return 1;
  294. }
  295. int cmCPackPackageMakerGenerator::InitializeInternal()
  296. {
  297. this->SetOptionIfNotSet("CPACK_PACKAGING_INSTALL_PREFIX", "/usr");
  298. // Starting with Xcode 4.3, PackageMaker is a separate app, and you
  299. // can put it anywhere you want. So... use a variable for its location.
  300. // People who put it in unexpected places can use the variable to tell
  301. // us where it is.
  302. //
  303. // Use the following locations, in "most recent installation" order,
  304. // to search for the PackageMaker app. Assume people who copy it into
  305. // the new Xcode 4.3 app in "/Applications" will copy it into the nested
  306. // Applications folder inside the Xcode bundle itself. Or directly in
  307. // the "/Applications" directory.
  308. //
  309. // If found, save result in the CPACK_INSTALLER_PROGRAM variable.
  310. std::vector<std::string> paths;
  311. paths.push_back("/Applications/Xcode.app/Contents/Applications"
  312. "/PackageMaker.app/Contents/MacOS");
  313. paths.push_back("/Applications/Utilities"
  314. "/PackageMaker.app/Contents/MacOS");
  315. paths.push_back("/Applications"
  316. "/PackageMaker.app/Contents/MacOS");
  317. paths.push_back("/Developer/Applications/Utilities"
  318. "/PackageMaker.app/Contents/MacOS");
  319. paths.push_back("/Developer/Applications"
  320. "/PackageMaker.app/Contents/MacOS");
  321. std::string pkgPath;
  322. const char* inst_program = this->GetOption("CPACK_INSTALLER_PROGRAM");
  323. if (inst_program && *inst_program) {
  324. pkgPath = inst_program;
  325. } else {
  326. pkgPath = cmSystemTools::FindProgram("PackageMaker", paths, false);
  327. if (pkgPath.empty()) {
  328. cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find PackageMaker compiler"
  329. << std::endl);
  330. return 0;
  331. }
  332. this->SetOptionIfNotSet("CPACK_INSTALLER_PROGRAM", pkgPath.c_str());
  333. }
  334. // Get path to the real PackageMaker, not a symlink:
  335. pkgPath = cmSystemTools::GetRealPath(pkgPath.c_str());
  336. // Up from there to find the version.plist file in the "Contents" dir:
  337. std::string contents_dir;
  338. contents_dir = cmSystemTools::GetFilenamePath(pkgPath);
  339. contents_dir = cmSystemTools::GetFilenamePath(contents_dir);
  340. std::string versionFile = contents_dir + "/version.plist";
  341. if (!cmSystemTools::FileExists(versionFile.c_str())) {
  342. cmCPackLogger(cmCPackLog::LOG_ERROR,
  343. "Cannot find PackageMaker compiler version file: "
  344. << versionFile.c_str() << std::endl);
  345. return 0;
  346. }
  347. cmsys::ifstream ifs(versionFile.c_str());
  348. if (!ifs) {
  349. cmCPackLogger(cmCPackLog::LOG_ERROR,
  350. "Cannot open PackageMaker compiler version file"
  351. << std::endl);
  352. return 0;
  353. }
  354. // Check the PackageMaker version
  355. cmsys::RegularExpression rexKey("<key>CFBundleShortVersionString</key>");
  356. cmsys::RegularExpression rexVersion("<string>([0-9]+.[0-9.]+)</string>");
  357. std::string line;
  358. bool foundKey = false;
  359. while (cmSystemTools::GetLineFromStream(ifs, line)) {
  360. if (rexKey.find(line)) {
  361. foundKey = true;
  362. break;
  363. }
  364. }
  365. if (!foundKey) {
  366. cmCPackLogger(
  367. cmCPackLog::LOG_ERROR,
  368. "Cannot find CFBundleShortVersionString in the PackageMaker compiler "
  369. "version file"
  370. << std::endl);
  371. return 0;
  372. }
  373. if (!cmSystemTools::GetLineFromStream(ifs, line) || !rexVersion.find(line)) {
  374. cmCPackLogger(cmCPackLog::LOG_ERROR,
  375. "Problem reading the PackageMaker compiler version file: "
  376. << versionFile.c_str() << std::endl);
  377. return 0;
  378. }
  379. this->PackageMakerVersion = atof(rexVersion.match(1).c_str());
  380. if (this->PackageMakerVersion < 1.0) {
  381. cmCPackLogger(cmCPackLog::LOG_ERROR, "Require PackageMaker 1.0 or higher"
  382. << std::endl);
  383. return 0;
  384. }
  385. cmCPackLogger(cmCPackLog::LOG_DEBUG, "PackageMaker version is: "
  386. << this->PackageMakerVersion << std::endl);
  387. // Determine the package compatibility version. If it wasn't
  388. // specified by the user, we define it based on which features the
  389. // user requested.
  390. const char* packageCompat = this->GetOption("CPACK_OSX_PACKAGE_VERSION");
  391. if (packageCompat && *packageCompat) {
  392. unsigned int majorVersion = 10;
  393. unsigned int minorVersion = 5;
  394. int res = sscanf(packageCompat, "%u.%u", &majorVersion, &minorVersion);
  395. if (res == 2) {
  396. this->PackageCompatibilityVersion =
  397. getVersion(majorVersion, minorVersion);
  398. }
  399. } else if (this->GetOption("CPACK_DOWNLOAD_SITE")) {
  400. this->SetOption("CPACK_OSX_PACKAGE_VERSION", "10.5");
  401. this->PackageCompatibilityVersion = getVersion(10, 5);
  402. } else if (this->GetOption("CPACK_COMPONENTS_ALL")) {
  403. this->SetOption("CPACK_OSX_PACKAGE_VERSION", "10.4");
  404. this->PackageCompatibilityVersion = getVersion(10, 4);
  405. } else {
  406. this->SetOption("CPACK_OSX_PACKAGE_VERSION", "10.3");
  407. this->PackageCompatibilityVersion = getVersion(10, 3);
  408. }
  409. std::vector<std::string> no_paths;
  410. pkgPath = cmSystemTools::FindProgram("hdiutil", no_paths, false);
  411. if (pkgPath.empty()) {
  412. cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find hdiutil compiler"
  413. << std::endl);
  414. return 0;
  415. }
  416. this->SetOptionIfNotSet("CPACK_INSTALLER_PROGRAM_DISK_IMAGE",
  417. pkgPath.c_str());
  418. return this->Superclass::InitializeInternal();
  419. }
  420. bool cmCPackPackageMakerGenerator::RunPackageMaker(const char* command,
  421. const char* packageFile)
  422. {
  423. std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
  424. tmpFile += "/PackageMakerOutput.log";
  425. cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Execute: " << command << std::endl);
  426. std::string output;
  427. int retVal = 1;
  428. bool res = cmSystemTools::RunSingleCommand(
  429. command, &output, &output, &retVal, 0, this->GeneratorVerbose, 0);
  430. cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Done running package maker"
  431. << std::endl);
  432. if (!res || retVal) {
  433. cmGeneratedFileStream ofs(tmpFile.c_str());
  434. ofs << "# Run command: " << command << std::endl
  435. << "# Output:" << std::endl
  436. << output.c_str() << std::endl;
  437. cmCPackLogger(
  438. cmCPackLog::LOG_ERROR, "Problem running PackageMaker command: "
  439. << command << std::endl
  440. << "Please check " << tmpFile.c_str() << " for errors" << std::endl);
  441. return false;
  442. }
  443. // sometimes the command finishes but the directory is not yet
  444. // created, so try 10 times to see if it shows up
  445. int tries = 10;
  446. while (tries > 0 && !cmSystemTools::FileExists(packageFile)) {
  447. cmSystemTools::Delay(500);
  448. tries--;
  449. }
  450. if (!cmSystemTools::FileExists(packageFile)) {
  451. cmCPackLogger(cmCPackLog::LOG_ERROR,
  452. "Problem running PackageMaker command: "
  453. << command << std::endl
  454. << "Package not created: " << packageFile << std::endl);
  455. return false;
  456. }
  457. return true;
  458. }
  459. bool cmCPackPackageMakerGenerator::GenerateComponentPackage(
  460. const char* packageFile, const char* packageDir,
  461. const cmCPackComponent& component)
  462. {
  463. cmCPackLogger(cmCPackLog::LOG_OUTPUT, "- Building component package: "
  464. << packageFile << std::endl);
  465. // The command that will be used to run PackageMaker
  466. std::ostringstream pkgCmd;
  467. if (this->PackageCompatibilityVersion < getVersion(10, 5) ||
  468. this->PackageMakerVersion < 3.0) {
  469. // Create Description.plist and Info.plist files for normal Mac OS
  470. // X packages, which work on Mac OS X 10.3 and newer.
  471. std::string descriptionFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
  472. descriptionFile += '/' + component.Name + "-Description.plist";
  473. cmsys::ofstream out(descriptionFile.c_str());
  474. out << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << std::endl
  475. << "<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\""
  476. << "\"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">" << std::endl
  477. << "<plist version=\"1.4\">" << std::endl
  478. << "<dict>" << std::endl
  479. << " <key>IFPkgDescriptionTitle</key>" << std::endl
  480. << " <string>" << component.DisplayName << "</string>" << std::endl
  481. << " <key>IFPkgDescriptionVersion</key>" << std::endl
  482. << " <string>" << this->GetOption("CPACK_PACKAGE_VERSION")
  483. << "</string>" << std::endl
  484. << " <key>IFPkgDescriptionDescription</key>" << std::endl
  485. << " <string>" + this->EscapeForXML(component.Description)
  486. << "</string>" << std::endl
  487. << "</dict>" << std::endl
  488. << "</plist>" << std::endl;
  489. out.close();
  490. // Create the Info.plist file for this component
  491. std::string moduleVersionSuffix = ".";
  492. moduleVersionSuffix += component.Name;
  493. this->SetOption("CPACK_MODULE_VERSION_SUFFIX",
  494. moduleVersionSuffix.c_str());
  495. std::string infoFileName = component.Name;
  496. infoFileName += "-Info.plist";
  497. if (!this->CopyResourcePlistFile("Info.plist", infoFileName.c_str())) {
  498. return false;
  499. }
  500. pkgCmd << "\"" << this->GetOption("CPACK_INSTALLER_PROGRAM")
  501. << "\" -build -p \"" << packageFile << "\""
  502. << " -f \"" << packageDir << "\""
  503. << " -i \"" << this->GetOption("CPACK_TOPLEVEL_DIRECTORY") << "/"
  504. << infoFileName << "\""
  505. << " -d \"" << descriptionFile << "\"";
  506. } else {
  507. // Create a "flat" package on Mac OS X 10.5 and newer. Flat
  508. // packages are stored in a single file, rather than a directory
  509. // like normal packages, and can be downloaded by the installer
  510. // on-the-fly in Mac OS X 10.5 or newer. Thus, we need to create
  511. // flat packages when the packages will be downloaded on the fly.
  512. std::string pkgId = "com.";
  513. pkgId += this->GetOption("CPACK_PACKAGE_VENDOR");
  514. pkgId += '.';
  515. pkgId += this->GetOption("CPACK_PACKAGE_NAME");
  516. pkgId += '.';
  517. pkgId += component.Name;
  518. pkgCmd << "\"" << this->GetOption("CPACK_INSTALLER_PROGRAM")
  519. << "\" --root \"" << packageDir << "\""
  520. << " --id " << pkgId << " --target "
  521. << this->GetOption("CPACK_OSX_PACKAGE_VERSION") << " --out \""
  522. << packageFile << "\"";
  523. }
  524. // Run PackageMaker
  525. return RunPackageMaker(pkgCmd.str().c_str(), packageFile);
  526. }