cmCPackIFWGenerator.cxx 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654
  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 "cmCPackIFWGenerator.h"
  4. #include <sstream>
  5. #include <utility>
  6. #include "cmCPackComponentGroup.h"
  7. #include "cmCPackGenerator.h"
  8. #include "cmCPackIFWCommon.h"
  9. #include "cmCPackIFWInstaller.h"
  10. #include "cmCPackIFWPackage.h"
  11. #include "cmCPackIFWRepository.h"
  12. #include "cmCPackLog.h" // IWYU pragma: keep
  13. #include "cmDuration.h"
  14. #include "cmGeneratedFileStream.h"
  15. #include "cmStringAlgorithms.h"
  16. #include "cmSystemTools.h"
  17. #include "cmValue.h"
  18. cmCPackIFWGenerator::cmCPackIFWGenerator()
  19. {
  20. this->Generator = this;
  21. }
  22. cmCPackIFWGenerator::~cmCPackIFWGenerator() = default;
  23. int cmCPackIFWGenerator::PackageFiles()
  24. {
  25. cmCPackIFWLogger(OUTPUT, "- Configuration" << std::endl);
  26. // Installer configuragion
  27. this->Installer.GenerateInstallerFile();
  28. // Packages configuration
  29. this->Installer.GeneratePackageFiles();
  30. std::string ifwTLD = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
  31. std::string ifwTmpFile = cmStrCat(ifwTLD, "/IFWOutput.log");
  32. // Create repositories
  33. if (!this->RunRepogen(ifwTmpFile)) {
  34. return 0;
  35. }
  36. // Create installer
  37. if (!this->RunBinaryCreator(ifwTmpFile)) {
  38. return 0;
  39. }
  40. return 1;
  41. }
  42. std::vector<std::string> cmCPackIFWGenerator::BuildRepogenCommand()
  43. {
  44. std::vector<std::string> ifwCmd;
  45. std::string ifwArg;
  46. ifwCmd.emplace_back(this->RepoGen);
  47. if (this->IsVersionLess("2.0.0")) {
  48. ifwCmd.emplace_back("-c");
  49. ifwCmd.emplace_back(this->toplevel + "/config/config.xml");
  50. }
  51. ifwCmd.emplace_back("-p");
  52. ifwCmd.emplace_back(this->toplevel + "/packages");
  53. if (!this->PkgsDirsVector.empty()) {
  54. for (std::string const& it : this->PkgsDirsVector) {
  55. ifwCmd.emplace_back("-p");
  56. ifwCmd.emplace_back(it);
  57. }
  58. }
  59. if (!this->RepoDirsVector.empty()) {
  60. if (!this->IsVersionLess("3.1")) {
  61. for (std::string const& rd : this->RepoDirsVector) {
  62. ifwCmd.emplace_back("--repository");
  63. ifwCmd.emplace_back(rd);
  64. }
  65. } else {
  66. cmCPackIFWLogger(WARNING,
  67. "The \"CPACK_IFW_REPOSITORIES_DIRECTORIES\" "
  68. << "variable is set, but content will be skipped, "
  69. << "because this feature available only since "
  70. << "QtIFW 3.1. Please update your QtIFW instance."
  71. << std::endl);
  72. }
  73. }
  74. if (!this->OnlineOnly && !this->DownloadedPackages.empty()) {
  75. ifwCmd.emplace_back("-i");
  76. auto it = this->DownloadedPackages.begin();
  77. ifwArg = (*it)->Name;
  78. ++it;
  79. while (it != this->DownloadedPackages.end()) {
  80. ifwArg += "," + (*it)->Name;
  81. ++it;
  82. }
  83. ifwCmd.emplace_back(ifwArg);
  84. }
  85. ifwCmd.emplace_back(this->toplevel + "/repository");
  86. return ifwCmd;
  87. }
  88. int cmCPackIFWGenerator::RunRepogen(const std::string& ifwTmpFile)
  89. {
  90. if (this->Installer.RemoteRepositories.empty()) {
  91. return 1;
  92. }
  93. std::vector<std::string> ifwCmd = this->BuildRepogenCommand();
  94. cmCPackIFWLogger(VERBOSE,
  95. "Execute: " << cmSystemTools::PrintSingleCommand(ifwCmd)
  96. << std::endl);
  97. std::string output;
  98. int retVal = 1;
  99. cmCPackIFWLogger(OUTPUT, "- Generate repository" << std::endl);
  100. bool res = cmSystemTools::RunSingleCommand(ifwCmd, &output, &output, &retVal,
  101. nullptr, this->GeneratorVerbose,
  102. cmDuration::zero());
  103. if (!res || retVal) {
  104. cmGeneratedFileStream ofs(ifwTmpFile);
  105. ofs << "# Run command: " << cmSystemTools::PrintSingleCommand(ifwCmd)
  106. << std::endl
  107. << "# Output:" << std::endl
  108. << output << std::endl;
  109. cmCPackIFWLogger(
  110. ERROR,
  111. "Problem running IFW command: "
  112. << cmSystemTools::PrintSingleCommand(ifwCmd) << std::endl
  113. << "Please check \"" << ifwTmpFile << "\" for errors" << std::endl);
  114. return 0;
  115. }
  116. if (!this->Repository.RepositoryUpdate.empty() &&
  117. !this->Repository.PatchUpdatesXml()) {
  118. cmCPackIFWLogger(WARNING,
  119. "Problem patch IFW \"Updates\" "
  120. << "file: \"" << this->toplevel
  121. << "/repository/Updates.xml\"" << std::endl);
  122. }
  123. cmCPackIFWLogger(OUTPUT,
  124. "- repository: \"" << this->toplevel
  125. << "/repository\" generated"
  126. << std::endl);
  127. return 1;
  128. }
  129. std::vector<std::string> cmCPackIFWGenerator::BuildBinaryCreatorCommmand()
  130. {
  131. std::vector<std::string> ifwCmd;
  132. std::string ifwArg;
  133. ifwCmd.emplace_back(this->BinCreator);
  134. ifwCmd.emplace_back("-c");
  135. ifwCmd.emplace_back(this->toplevel + "/config/config.xml");
  136. if (!this->Installer.Resources.empty()) {
  137. ifwCmd.emplace_back("-r");
  138. auto it = this->Installer.Resources.begin();
  139. std::string path = this->toplevel + "/resources/";
  140. ifwArg = path + *it;
  141. ++it;
  142. while (it != this->Installer.Resources.end()) {
  143. ifwArg += "," + path + *it;
  144. ++it;
  145. }
  146. ifwCmd.emplace_back(ifwArg);
  147. }
  148. ifwCmd.emplace_back("-p");
  149. ifwCmd.emplace_back(this->toplevel + "/packages");
  150. if (!this->PkgsDirsVector.empty()) {
  151. for (std::string const& it : this->PkgsDirsVector) {
  152. ifwCmd.emplace_back("-p");
  153. ifwCmd.emplace_back(it);
  154. }
  155. }
  156. if (!this->RepoDirsVector.empty()) {
  157. if (!this->IsVersionLess("3.1")) {
  158. for (std::string const& rd : this->RepoDirsVector) {
  159. ifwCmd.emplace_back("--repository");
  160. ifwCmd.emplace_back(rd);
  161. }
  162. } else {
  163. cmCPackIFWLogger(WARNING,
  164. "The \"CPACK_IFW_REPOSITORIES_DIRECTORIES\" "
  165. << "variable is set, but content will be skipped, "
  166. << "because this feature available only since "
  167. << "QtIFW 3.1. Please update your QtIFW instance."
  168. << std::endl);
  169. }
  170. }
  171. if (this->OnlineOnly) {
  172. ifwCmd.emplace_back("--online-only");
  173. } else if (!this->DownloadedPackages.empty() &&
  174. !this->Installer.RemoteRepositories.empty()) {
  175. ifwCmd.emplace_back("-e");
  176. auto it = this->DownloadedPackages.begin();
  177. ifwArg = (*it)->Name;
  178. ++it;
  179. while (it != this->DownloadedPackages.end()) {
  180. ifwArg += "," + (*it)->Name;
  181. ++it;
  182. }
  183. ifwCmd.emplace_back(ifwArg);
  184. } else if (!this->DependentPackages.empty()) {
  185. ifwCmd.emplace_back("-i");
  186. ifwArg.clear();
  187. // Binary
  188. auto bit = this->BinaryPackages.begin();
  189. while (bit != this->BinaryPackages.end()) {
  190. ifwArg += (*bit)->Name + ",";
  191. ++bit;
  192. }
  193. // Depend
  194. auto it = this->DependentPackages.begin();
  195. ifwArg += it->second.Name;
  196. ++it;
  197. while (it != this->DependentPackages.end()) {
  198. ifwArg += "," + it->second.Name;
  199. ++it;
  200. }
  201. ifwCmd.emplace_back(ifwArg);
  202. }
  203. // TODO: set correct name for multipackages
  204. if (!this->packageFileNames.empty()) {
  205. ifwCmd.emplace_back(this->packageFileNames[0]);
  206. } else {
  207. ifwCmd.emplace_back("installer" + this->OutputExtension);
  208. }
  209. return ifwCmd;
  210. }
  211. int cmCPackIFWGenerator::RunBinaryCreator(const std::string& ifwTmpFile)
  212. {
  213. std::vector<std::string> ifwCmd = this->BuildBinaryCreatorCommmand();
  214. cmCPackIFWLogger(VERBOSE,
  215. "Execute: " << cmSystemTools::PrintSingleCommand(ifwCmd)
  216. << std::endl);
  217. std::string output;
  218. int retVal = 1;
  219. cmCPackIFWLogger(OUTPUT, "- Generate package" << std::endl);
  220. bool res = cmSystemTools::RunSingleCommand(ifwCmd, &output, &output, &retVal,
  221. nullptr, this->GeneratorVerbose,
  222. cmDuration::zero());
  223. if (!res || retVal) {
  224. cmGeneratedFileStream ofs(ifwTmpFile);
  225. ofs << "# Run command: " << cmSystemTools::PrintSingleCommand(ifwCmd)
  226. << std::endl
  227. << "# Output:" << std::endl
  228. << output << std::endl;
  229. cmCPackIFWLogger(
  230. ERROR,
  231. "Problem running IFW command: "
  232. << cmSystemTools::PrintSingleCommand(ifwCmd) << std::endl
  233. << "Please check \"" << ifwTmpFile << "\" for errors" << std::endl);
  234. return 0;
  235. }
  236. return 1;
  237. }
  238. const char* cmCPackIFWGenerator::GetPackagingInstallPrefix()
  239. {
  240. const char* defPrefix = this->cmCPackGenerator::GetPackagingInstallPrefix();
  241. std::string tmpPref = defPrefix ? defPrefix : "";
  242. if (this->Components.empty()) {
  243. tmpPref += "packages/" + this->GetRootPackageName() + "/data";
  244. }
  245. this->SetOption("CPACK_IFW_PACKAGING_INSTALL_PREFIX", tmpPref);
  246. return this->GetOption("CPACK_IFW_PACKAGING_INSTALL_PREFIX")->c_str();
  247. }
  248. const char* cmCPackIFWGenerator::GetOutputExtension()
  249. {
  250. return this->OutputExtension.c_str();
  251. }
  252. int cmCPackIFWGenerator::InitializeInternal()
  253. {
  254. // Search Qt Installer Framework tools
  255. const std::string BinCreatorOpt = "CPACK_IFW_BINARYCREATOR_EXECUTABLE";
  256. const std::string RepoGenOpt = "CPACK_IFW_REPOGEN_EXECUTABLE";
  257. const std::string FrameworkVersionOpt = "CPACK_IFW_FRAMEWORK_VERSION";
  258. if (!this->IsSet(BinCreatorOpt) || !this->IsSet(RepoGenOpt) ||
  259. !this->IsSet(FrameworkVersionOpt)) {
  260. this->ReadListFile("CPackIFW.cmake");
  261. }
  262. // Look 'binarycreator' executable (needs)
  263. cmValue BinCreatorStr = this->GetOption(BinCreatorOpt);
  264. if (!BinCreatorStr || cmIsNOTFOUND(BinCreatorStr)) {
  265. this->BinCreator.clear();
  266. } else {
  267. this->BinCreator = *BinCreatorStr;
  268. }
  269. if (this->BinCreator.empty()) {
  270. cmCPackIFWLogger(ERROR,
  271. "Cannot find QtIFW compiler \"binarycreator\": "
  272. "likely it is not installed, or not in your PATH"
  273. << std::endl);
  274. return 0;
  275. }
  276. // Look 'repogen' executable (optional)
  277. cmValue repoGen = this->GetOption(RepoGenOpt);
  278. if (!repoGen || cmIsNOTFOUND(repoGen)) {
  279. this->RepoGen.clear();
  280. } else {
  281. this->RepoGen = *repoGen;
  282. }
  283. // Framework version
  284. if (cmValue frameworkVersion = this->GetOption(FrameworkVersionOpt)) {
  285. this->FrameworkVersion = *frameworkVersion;
  286. } else {
  287. this->FrameworkVersion = "1.9.9";
  288. }
  289. // Variables that Change Behavior
  290. // Resolve duplicate names
  291. this->ResolveDuplicateNames =
  292. this->IsOn("CPACK_IFW_RESOLVE_DUPLICATE_NAMES");
  293. // Additional packages dirs
  294. this->PkgsDirsVector.clear();
  295. if (cmValue dirs = this->GetOption("CPACK_IFW_PACKAGES_DIRECTORIES")) {
  296. cmExpandList(dirs, this->PkgsDirsVector);
  297. }
  298. // Additional repositories dirs
  299. this->RepoDirsVector.clear();
  300. if (cmValue dirs = this->GetOption("CPACK_IFW_REPOSITORIES_DIRECTORIES")) {
  301. cmExpandList(dirs, this->RepoDirsVector);
  302. }
  303. // Installer
  304. this->Installer.Generator = this;
  305. this->Installer.ConfigureFromOptions();
  306. // Repository
  307. this->Repository.Generator = this;
  308. this->Repository.Name = "Unspecified";
  309. if (cmValue site = this->GetOption("CPACK_DOWNLOAD_SITE")) {
  310. this->Repository.Url = *site;
  311. this->Installer.RemoteRepositories.push_back(&this->Repository);
  312. }
  313. // Repositories
  314. if (cmValue RepoAllStr = this->GetOption("CPACK_IFW_REPOSITORIES_ALL")) {
  315. std::vector<std::string> RepoAllVector = cmExpandedList(RepoAllStr);
  316. for (std::string const& r : RepoAllVector) {
  317. this->GetRepository(r);
  318. }
  319. }
  320. if (cmValue ifwDownloadAll = this->GetOption("CPACK_IFW_DOWNLOAD_ALL")) {
  321. this->OnlineOnly = cmIsOn(ifwDownloadAll);
  322. } else if (cmValue cpackDownloadAll =
  323. this->GetOption("CPACK_DOWNLOAD_ALL")) {
  324. this->OnlineOnly = cmIsOn(cpackDownloadAll);
  325. } else {
  326. this->OnlineOnly = false;
  327. }
  328. if (!this->Installer.RemoteRepositories.empty() && this->RepoGen.empty()) {
  329. cmCPackIFWLogger(ERROR,
  330. "Cannot find QtIFW repository generator \"repogen\": "
  331. "likely it is not installed, or not in your PATH"
  332. << std::endl);
  333. return 0;
  334. }
  335. // Executable suffix
  336. std::string exeSuffix(this->GetOption("CMAKE_EXECUTABLE_SUFFIX"));
  337. std::string sysName(this->GetOption("CMAKE_SYSTEM_NAME"));
  338. if (sysName == "Linux") {
  339. this->ExecutableSuffix = ".run";
  340. } else if (sysName == "Windows") {
  341. this->ExecutableSuffix = ".exe";
  342. } else if (sysName == "Darwin") {
  343. this->ExecutableSuffix = ".app";
  344. } else {
  345. this->ExecutableSuffix = exeSuffix;
  346. }
  347. // Output extension
  348. if (cmValue optOutExt =
  349. this->GetOption("CPACK_IFW_PACKAGE_FILE_EXTENSION")) {
  350. this->OutputExtension = *optOutExt;
  351. } else if (sysName == "Darwin") {
  352. this->OutputExtension = ".dmg";
  353. } else {
  354. this->OutputExtension = this->ExecutableSuffix;
  355. }
  356. if (this->OutputExtension.empty()) {
  357. this->OutputExtension = this->cmCPackGenerator::GetOutputExtension();
  358. }
  359. return this->Superclass::InitializeInternal();
  360. }
  361. std::string cmCPackIFWGenerator::GetComponentInstallDirNameSuffix(
  362. const std::string& componentName)
  363. {
  364. const std::string prefix = "packages/";
  365. const std::string suffix = "/data";
  366. if (this->componentPackageMethod == this->ONE_PACKAGE) {
  367. return std::string(prefix + this->GetRootPackageName() + suffix);
  368. }
  369. return prefix +
  370. this->GetComponentPackageName(&this->Components[componentName]) + suffix;
  371. }
  372. cmCPackComponent* cmCPackIFWGenerator::GetComponent(
  373. const std::string& projectName, const std::string& componentName)
  374. {
  375. auto cit = this->Components.find(componentName);
  376. if (cit != this->Components.end()) {
  377. return &(cit->second);
  378. }
  379. cmCPackComponent* component =
  380. this->cmCPackGenerator::GetComponent(projectName, componentName);
  381. if (!component) {
  382. return component;
  383. }
  384. std::string name = this->GetComponentPackageName(component);
  385. auto pit = this->Packages.find(name);
  386. if (pit != this->Packages.end()) {
  387. return component;
  388. }
  389. cmCPackIFWPackage* package = &this->Packages[name];
  390. package->Name = name;
  391. package->Generator = this;
  392. if (package->ConfigureFromComponent(component)) {
  393. package->Installer = &this->Installer;
  394. this->Installer.Packages.insert(
  395. std::pair<std::string, cmCPackIFWPackage*>(name, package));
  396. this->ComponentPackages.insert(
  397. std::pair<cmCPackComponent*, cmCPackIFWPackage*>(component, package));
  398. if (component->IsDownloaded) {
  399. this->DownloadedPackages.insert(package);
  400. } else {
  401. this->BinaryPackages.insert(package);
  402. }
  403. } else {
  404. this->Packages.erase(name);
  405. cmCPackIFWLogger(ERROR,
  406. "Cannot configure package \""
  407. << name << "\" for component \"" << component->Name
  408. << "\"" << std::endl);
  409. }
  410. return component;
  411. }
  412. cmCPackComponentGroup* cmCPackIFWGenerator::GetComponentGroup(
  413. const std::string& projectName, const std::string& groupName)
  414. {
  415. cmCPackComponentGroup* group =
  416. this->cmCPackGenerator::GetComponentGroup(projectName, groupName);
  417. if (!group) {
  418. return group;
  419. }
  420. std::string name = this->GetGroupPackageName(group);
  421. auto pit = this->Packages.find(name);
  422. if (pit != this->Packages.end()) {
  423. return group;
  424. }
  425. cmCPackIFWPackage* package = &this->Packages[name];
  426. package->Name = name;
  427. package->Generator = this;
  428. if (package->ConfigureFromGroup(group)) {
  429. package->Installer = &this->Installer;
  430. this->Installer.Packages.insert(
  431. std::pair<std::string, cmCPackIFWPackage*>(name, package));
  432. this->GroupPackages.insert(
  433. std::pair<cmCPackComponentGroup*, cmCPackIFWPackage*>(group, package));
  434. this->BinaryPackages.insert(package);
  435. } else {
  436. this->Packages.erase(name);
  437. cmCPackIFWLogger(ERROR,
  438. "Cannot configure package \""
  439. << name << "\" for component group \"" << group->Name
  440. << "\"" << std::endl);
  441. }
  442. return group;
  443. }
  444. enum cmCPackGenerator::CPackSetDestdirSupport
  445. cmCPackIFWGenerator::SupportsSetDestdir() const
  446. {
  447. return cmCPackGenerator::SETDESTDIR_SHOULD_NOT_BE_USED;
  448. }
  449. bool cmCPackIFWGenerator::SupportsAbsoluteDestination() const
  450. {
  451. return false;
  452. }
  453. bool cmCPackIFWGenerator::SupportsComponentInstallation() const
  454. {
  455. return true;
  456. }
  457. bool cmCPackIFWGenerator::IsOnePackage() const
  458. {
  459. return this->componentPackageMethod == cmCPackGenerator::ONE_PACKAGE;
  460. }
  461. std::string cmCPackIFWGenerator::GetRootPackageName()
  462. {
  463. // Default value
  464. std::string name = "root";
  465. if (cmValue optIFW_PACKAGE_GROUP =
  466. this->GetOption("CPACK_IFW_PACKAGE_GROUP")) {
  467. // Configure from root group
  468. cmCPackIFWPackage package;
  469. package.Generator = this;
  470. package.ConfigureFromGroup(optIFW_PACKAGE_GROUP);
  471. name = package.Name;
  472. } else if (cmValue optIFW_PACKAGE_NAME =
  473. this->GetOption("CPACK_IFW_PACKAGE_NAME")) {
  474. // Configure from root package name
  475. name = *optIFW_PACKAGE_NAME;
  476. } else if (cmValue optPACKAGE_NAME = this->GetOption("CPACK_PACKAGE_NAME")) {
  477. // Configure from package name
  478. name = *optPACKAGE_NAME;
  479. }
  480. return name;
  481. }
  482. std::string cmCPackIFWGenerator::GetGroupPackageName(
  483. cmCPackComponentGroup* group) const
  484. {
  485. std::string name;
  486. if (!group) {
  487. return name;
  488. }
  489. if (cmCPackIFWPackage* package = this->GetGroupPackage(group)) {
  490. return package->Name;
  491. }
  492. cmValue option =
  493. this->GetOption("CPACK_IFW_COMPONENT_GROUP_" +
  494. cmsys::SystemTools::UpperCase(group->Name) + "_NAME");
  495. name = option ? *option : group->Name;
  496. if (group->ParentGroup) {
  497. cmCPackIFWPackage* package = this->GetGroupPackage(group->ParentGroup);
  498. bool dot = !this->ResolveDuplicateNames;
  499. if (dot && !cmHasPrefix(name, package->Name)) {
  500. name = package->Name + "." + name;
  501. }
  502. }
  503. return name;
  504. }
  505. std::string cmCPackIFWGenerator::GetComponentPackageName(
  506. cmCPackComponent* component) const
  507. {
  508. std::string name;
  509. if (!component) {
  510. return name;
  511. }
  512. if (cmCPackIFWPackage* package = this->GetComponentPackage(component)) {
  513. return package->Name;
  514. }
  515. std::string prefix = "CPACK_IFW_COMPONENT_" +
  516. cmsys::SystemTools::UpperCase(component->Name) + "_";
  517. cmValue option = this->GetOption(prefix + "NAME");
  518. name = option ? *option : component->Name;
  519. if (component->Group) {
  520. cmCPackIFWPackage* package = this->GetGroupPackage(component->Group);
  521. if ((this->componentPackageMethod ==
  522. cmCPackGenerator::ONE_PACKAGE_PER_GROUP) ||
  523. this->IsOn(prefix + "COMMON")) {
  524. return package->Name;
  525. }
  526. bool dot = !this->ResolveDuplicateNames;
  527. if (dot && !cmHasPrefix(name, package->Name)) {
  528. name = package->Name + "." + name;
  529. }
  530. }
  531. return name;
  532. }
  533. cmCPackIFWPackage* cmCPackIFWGenerator::GetGroupPackage(
  534. cmCPackComponentGroup* group) const
  535. {
  536. auto pit = this->GroupPackages.find(group);
  537. return pit != this->GroupPackages.end() ? pit->second : nullptr;
  538. }
  539. cmCPackIFWPackage* cmCPackIFWGenerator::GetComponentPackage(
  540. cmCPackComponent* component) const
  541. {
  542. auto pit = this->ComponentPackages.find(component);
  543. return pit != this->ComponentPackages.end() ? pit->second : nullptr;
  544. }
  545. cmCPackIFWRepository* cmCPackIFWGenerator::GetRepository(
  546. const std::string& repositoryName)
  547. {
  548. auto rit = this->Repositories.find(repositoryName);
  549. if (rit != this->Repositories.end()) {
  550. return &(rit->second);
  551. }
  552. cmCPackIFWRepository* repository = &this->Repositories[repositoryName];
  553. repository->Name = repositoryName;
  554. repository->Generator = this;
  555. if (repository->ConfigureFromOptions()) {
  556. if (repository->Update == cmCPackIFWRepository::None) {
  557. this->Installer.RemoteRepositories.push_back(repository);
  558. } else {
  559. this->Repository.RepositoryUpdate.push_back(repository);
  560. }
  561. } else {
  562. this->Repositories.erase(repositoryName);
  563. repository = nullptr;
  564. cmCPackIFWLogger(WARNING,
  565. "Invalid repository \""
  566. << repositoryName << "\""
  567. << " configuration. Repository will be skipped."
  568. << std::endl);
  569. }
  570. return repository;
  571. }