cmCPackPackageMakerGenerator.cxx 21 KB

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