cmCPackPackageMakerGenerator.cxx 21 KB

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