cmCPackPackageMakerGenerator.cxx 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578
  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, "Problem copying the resource files"
  227. << 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, "Problem running hdiutil command: "
  285. << dmgCmd.str() << std::endl
  286. << "Please check " << tmpFile << " for errors"
  287. << std::endl);
  288. return 0;
  289. }
  290. return 1;
  291. }
  292. int cmCPackPackageMakerGenerator::InitializeInternal()
  293. {
  294. this->SetOptionIfNotSet("CPACK_PACKAGING_INSTALL_PREFIX", "/usr");
  295. // Starting with Xcode 4.3, PackageMaker is a separate app, and you
  296. // can put it anywhere you want. So... use a variable for its location.
  297. // People who put it in unexpected places can use the variable to tell
  298. // us where it is.
  299. //
  300. // Use the following locations, in "most recent installation" order,
  301. // to search for the PackageMaker app. Assume people who copy it into
  302. // the new Xcode 4.3 app in "/Applications" will copy it into the nested
  303. // Applications folder inside the Xcode bundle itself. Or directly in
  304. // the "/Applications" directory.
  305. //
  306. // If found, save result in the CPACK_INSTALLER_PROGRAM variable.
  307. std::vector<std::string> paths;
  308. paths.push_back("/Applications/Xcode.app/Contents/Applications"
  309. "/PackageMaker.app/Contents/MacOS");
  310. paths.push_back("/Applications/Utilities"
  311. "/PackageMaker.app/Contents/MacOS");
  312. paths.push_back("/Applications"
  313. "/PackageMaker.app/Contents/MacOS");
  314. paths.push_back("/Developer/Applications/Utilities"
  315. "/PackageMaker.app/Contents/MacOS");
  316. paths.push_back("/Developer/Applications"
  317. "/PackageMaker.app/Contents/MacOS");
  318. std::string pkgPath;
  319. const char* inst_program = this->GetOption("CPACK_INSTALLER_PROGRAM");
  320. if (inst_program && *inst_program) {
  321. pkgPath = inst_program;
  322. } else {
  323. pkgPath = cmSystemTools::FindProgram("PackageMaker", paths, false);
  324. if (pkgPath.empty()) {
  325. cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find PackageMaker compiler"
  326. << std::endl);
  327. return 0;
  328. }
  329. this->SetOptionIfNotSet("CPACK_INSTALLER_PROGRAM", pkgPath.c_str());
  330. }
  331. // Get path to the real PackageMaker, not a symlink:
  332. pkgPath = cmSystemTools::GetRealPath(pkgPath);
  333. // Up from there to find the version.plist file in the "Contents" dir:
  334. std::string contents_dir;
  335. contents_dir = cmSystemTools::GetFilenamePath(pkgPath);
  336. contents_dir = cmSystemTools::GetFilenamePath(contents_dir);
  337. std::string versionFile = contents_dir + "/version.plist";
  338. if (!cmSystemTools::FileExists(versionFile.c_str())) {
  339. cmCPackLogger(cmCPackLog::LOG_ERROR,
  340. "Cannot find PackageMaker compiler version file: "
  341. << versionFile << std::endl);
  342. return 0;
  343. }
  344. cmsys::ifstream ifs(versionFile.c_str());
  345. if (!ifs) {
  346. cmCPackLogger(cmCPackLog::LOG_ERROR,
  347. "Cannot open PackageMaker compiler version file"
  348. << std::endl);
  349. return 0;
  350. }
  351. // Check the PackageMaker version
  352. cmsys::RegularExpression rexKey("<key>CFBundleShortVersionString</key>");
  353. cmsys::RegularExpression rexVersion("<string>([0-9]+.[0-9.]+)</string>");
  354. std::string line;
  355. bool foundKey = false;
  356. while (cmSystemTools::GetLineFromStream(ifs, line)) {
  357. if (rexKey.find(line)) {
  358. foundKey = true;
  359. break;
  360. }
  361. }
  362. if (!foundKey) {
  363. cmCPackLogger(
  364. cmCPackLog::LOG_ERROR,
  365. "Cannot find CFBundleShortVersionString in the PackageMaker compiler "
  366. "version file"
  367. << std::endl);
  368. return 0;
  369. }
  370. if (!cmSystemTools::GetLineFromStream(ifs, line) || !rexVersion.find(line)) {
  371. cmCPackLogger(cmCPackLog::LOG_ERROR,
  372. "Problem reading the PackageMaker compiler version file: "
  373. << versionFile << std::endl);
  374. return 0;
  375. }
  376. this->PackageMakerVersion = atof(rexVersion.match(1).c_str());
  377. if (this->PackageMakerVersion < 1.0) {
  378. cmCPackLogger(cmCPackLog::LOG_ERROR, "Require PackageMaker 1.0 or higher"
  379. << std::endl);
  380. return 0;
  381. }
  382. cmCPackLogger(cmCPackLog::LOG_DEBUG, "PackageMaker version is: "
  383. << this->PackageMakerVersion << std::endl);
  384. // Determine the package compatibility version. If it wasn't
  385. // specified by the user, we define it based on which features the
  386. // user requested.
  387. const char* packageCompat = this->GetOption("CPACK_OSX_PACKAGE_VERSION");
  388. if (packageCompat && *packageCompat) {
  389. unsigned int majorVersion = 10;
  390. unsigned int minorVersion = 5;
  391. int res = sscanf(packageCompat, "%u.%u", &majorVersion, &minorVersion);
  392. if (res == 2) {
  393. this->PackageCompatibilityVersion =
  394. getVersion(majorVersion, minorVersion);
  395. }
  396. } else if (this->GetOption("CPACK_DOWNLOAD_SITE")) {
  397. this->SetOption("CPACK_OSX_PACKAGE_VERSION", "10.5");
  398. this->PackageCompatibilityVersion = getVersion(10, 5);
  399. } else if (this->GetOption("CPACK_COMPONENTS_ALL")) {
  400. this->SetOption("CPACK_OSX_PACKAGE_VERSION", "10.4");
  401. this->PackageCompatibilityVersion = getVersion(10, 4);
  402. } else {
  403. this->SetOption("CPACK_OSX_PACKAGE_VERSION", "10.3");
  404. this->PackageCompatibilityVersion = getVersion(10, 3);
  405. }
  406. std::vector<std::string> no_paths;
  407. pkgPath = cmSystemTools::FindProgram("hdiutil", no_paths, false);
  408. if (pkgPath.empty()) {
  409. cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find hdiutil compiler"
  410. << std::endl);
  411. return 0;
  412. }
  413. this->SetOptionIfNotSet("CPACK_INSTALLER_PROGRAM_DISK_IMAGE",
  414. pkgPath.c_str());
  415. return this->Superclass::InitializeInternal();
  416. }
  417. bool cmCPackPackageMakerGenerator::RunPackageMaker(const char* command,
  418. const char* packageFile)
  419. {
  420. std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
  421. tmpFile += "/PackageMakerOutput.log";
  422. cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Execute: " << command << std::endl);
  423. std::string output;
  424. int retVal = 1;
  425. bool res = cmSystemTools::RunSingleCommand(
  426. command, &output, &output, &retVal, nullptr, this->GeneratorVerbose,
  427. cmDuration::zero());
  428. cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Done running package maker"
  429. << std::endl);
  430. if (!res || retVal) {
  431. cmGeneratedFileStream ofs(tmpFile.c_str());
  432. ofs << "# Run command: " << command << std::endl
  433. << "# Output:" << std::endl
  434. << output << std::endl;
  435. cmCPackLogger(
  436. cmCPackLog::LOG_ERROR, "Problem running PackageMaker command: "
  437. << command << std::endl
  438. << "Please check " << tmpFile << " for errors" << std::endl);
  439. return false;
  440. }
  441. // sometimes the command finishes but the directory is not yet
  442. // created, so try 10 times to see if it shows up
  443. int tries = 10;
  444. while (tries > 0 && !cmSystemTools::FileExists(packageFile)) {
  445. cmSystemTools::Delay(500);
  446. tries--;
  447. }
  448. if (!cmSystemTools::FileExists(packageFile)) {
  449. cmCPackLogger(cmCPackLog::LOG_ERROR,
  450. "Problem running PackageMaker command: "
  451. << command << std::endl
  452. << "Package not created: " << packageFile << std::endl);
  453. return false;
  454. }
  455. return true;
  456. }
  457. bool cmCPackPackageMakerGenerator::GenerateComponentPackage(
  458. const char* packageFile, const char* packageDir,
  459. const cmCPackComponent& component)
  460. {
  461. cmCPackLogger(cmCPackLog::LOG_OUTPUT, "- Building component package: "
  462. << packageFile << std::endl);
  463. // The command that will be used to run PackageMaker
  464. std::ostringstream pkgCmd;
  465. if (this->PackageCompatibilityVersion < getVersion(10, 5) ||
  466. this->PackageMakerVersion < 3.0) {
  467. // Create Description.plist and Info.plist files for normal Mac OS
  468. // X packages, which work on Mac OS X 10.3 and newer.
  469. std::string descriptionFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
  470. descriptionFile += '/' + component.Name + "-Description.plist";
  471. cmsys::ofstream out(descriptionFile.c_str());
  472. cmXMLWriter xout(out);
  473. xout.StartDocument();
  474. xout.Doctype("plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\""
  475. "\"http://www.apple.com/DTDs/PropertyList-1.0.dtd\"");
  476. xout.StartElement("plist");
  477. xout.Attribute("version", "1.4");
  478. xout.StartElement("dict");
  479. xout.Element("key", "IFPkgDescriptionTitle");
  480. xout.Element("string", component.DisplayName);
  481. xout.Element("key", "IFPkgDescriptionVersion");
  482. xout.Element("string", this->GetOption("CPACK_PACKAGE_VERSION"));
  483. xout.Element("key", "IFPkgDescriptionDescription");
  484. xout.Element("string", component.Description);
  485. xout.EndElement(); // dict
  486. xout.EndElement(); // plist
  487. xout.EndDocument();
  488. out.close();
  489. // Create the Info.plist file for this component
  490. std::string moduleVersionSuffix = ".";
  491. moduleVersionSuffix += component.Name;
  492. this->SetOption("CPACK_MODULE_VERSION_SUFFIX",
  493. moduleVersionSuffix.c_str());
  494. std::string infoFileName = component.Name;
  495. infoFileName += "-Info.plist";
  496. if (!this->CopyResourcePlistFile("Info.plist", infoFileName.c_str())) {
  497. return false;
  498. }
  499. pkgCmd << "\"" << this->GetOption("CPACK_INSTALLER_PROGRAM")
  500. << "\" -build -p \"" << packageFile << "\""
  501. << " -f \"" << packageDir << "\""
  502. << " -i \"" << this->GetOption("CPACK_TOPLEVEL_DIRECTORY") << "/"
  503. << infoFileName << "\""
  504. << " -d \"" << descriptionFile << "\"";
  505. } else {
  506. // Create a "flat" package on Mac OS X 10.5 and newer. Flat
  507. // packages are stored in a single file, rather than a directory
  508. // like normal packages, and can be downloaded by the installer
  509. // on-the-fly in Mac OS X 10.5 or newer. Thus, we need to create
  510. // flat packages when the packages will be downloaded on the fly.
  511. std::string pkgId = "com.";
  512. pkgId += this->GetOption("CPACK_PACKAGE_VENDOR");
  513. pkgId += '.';
  514. pkgId += this->GetOption("CPACK_PACKAGE_NAME");
  515. pkgId += '.';
  516. pkgId += component.Name;
  517. pkgCmd << "\"" << this->GetOption("CPACK_INSTALLER_PROGRAM")
  518. << "\" --root \"" << packageDir << "\""
  519. << " --id " << pkgId << " --target "
  520. << this->GetOption("CPACK_OSX_PACKAGE_VERSION") << " --out \""
  521. << packageFile << "\"";
  522. }
  523. // Run PackageMaker
  524. return RunPackageMaker(pkgCmd.str().c_str(), packageFile);
  525. }