cmCPackIFWGenerator.cxx 19 KB

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