diff options
author | Konstantin Podsvirov <konstantin@podsvirov.pro> | 2014-10-05 08:52:57 (GMT) |
---|---|---|
committer | Konstantin Podsvirov <konstantin@podsvirov.pro> | 2014-10-05 08:52:57 (GMT) |
commit | ed9684a22cf4babeaa1f9083f4061d789e513ba9 (patch) | |
tree | b9ee70182d4f8639770898479579373a65ca36d5 /Source/CPack/IFW | |
parent | f9f748745c6f4ef5b2dbf6d0732bc67a23d1cc63 (diff) | |
download | CMake-ed9684a22cf4babeaa1f9083f4061d789e513ba9.zip CMake-ed9684a22cf4babeaa1f9083f4061d789e513ba9.tar.gz CMake-ed9684a22cf4babeaa1f9083f4061d789e513ba9.tar.bz2 |
CPackIFW: Added support for multiple repositories
Now user can add IFW specific repo with cpack_ifw_add_repository macro
Diffstat (limited to 'Source/CPack/IFW')
-rw-r--r-- | Source/CPack/IFW/cmCPackIFWGenerator.cxx | 30 | ||||
-rw-r--r-- | Source/CPack/IFW/cmCPackIFWGenerator.h | 2 | ||||
-rw-r--r-- | Source/CPack/IFW/cmCPackIFWInstaller.cxx | 124 | ||||
-rw-r--r-- | Source/CPack/IFW/cmCPackIFWInstaller.h | 11 |
4 files changed, 142 insertions, 25 deletions
diff --git a/Source/CPack/IFW/cmCPackIFWGenerator.cxx b/Source/CPack/IFW/cmCPackIFWGenerator.cxx index dabb3b3..7f06e2d 100644 --- a/Source/CPack/IFW/cmCPackIFWGenerator.cxx +++ b/Source/CPack/IFW/cmCPackIFWGenerator.cxx @@ -56,7 +56,7 @@ int cmCPackIFWGenerator::PackageFiles() ifwTmpFile += "/IFWOutput.log"; // Run repogen - if (!DownloadSite.empty()) + if (!Installer.Repositories.empty()) { std::string ifwCmd = RepoGen; ifwCmd += " -c " + this->toplevel + "/config/config.xml"; @@ -128,7 +128,7 @@ int cmCPackIFWGenerator::PackageFiles() { ifwCmd += " --online-only"; } - else if (!DownloadedPackages.empty() && !DownloadSite.empty()) + else if (!DownloadedPackages.empty() && !Installer.Repositories.empty()) { ifwCmd += " -e "; std::set<cmCPackIFWPackage*>::iterator it @@ -278,16 +278,26 @@ int cmCPackIFWGenerator::InitializeInternal() PkgsDirsVector); } - // Remote repository + // Installer + Installer.Generator = this; + Installer.ConfigureFromOptions(); - if (const char *site = this->GetOption("CPACK_DOWNLOAD_SITE")) + if (const char* ifwDownloadAll = + this->GetOption("CPACK_IFW_DOWNLOAD_ALL")) { - DownloadSite = site; + OnlineOnly = cmSystemTools::IsOn(ifwDownloadAll); + } + else if (const char* cpackDownloadAll = + this->GetOption("CPACK_DOWNLOAD_ALL")) + { + OnlineOnly = cmSystemTools::IsOn(cpackDownloadAll); + } + else + { + OnlineOnly = false; } - OnlineOnly = this->IsOn("CPACK_DOWNLOAD_ALL") ? true : false; - - if (!DownloadSite.empty() && RepoGen.empty()) { + if (!Installer.Repositories.empty() && RepoGen.empty()) { cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find QtIFW repository generator \"repogen\": " "likely it is not installed, or not in your PATH" @@ -295,10 +305,6 @@ int cmCPackIFWGenerator::InitializeInternal() return 0; } - // Installer - Installer.Generator = this; - Installer.ConfigureFromOptions(); - return this->Superclass::InitializeInternal(); } diff --git a/Source/CPack/IFW/cmCPackIFWGenerator.h b/Source/CPack/IFW/cmCPackIFWGenerator.h index 7211e04..1d4d67b 100644 --- a/Source/CPack/IFW/cmCPackIFWGenerator.h +++ b/Source/CPack/IFW/cmCPackIFWGenerator.h @@ -127,8 +127,6 @@ private: std::string RepoGen; std::string BinCreator; - std::string DownloadSite; - bool OnlineOnly; bool ResolveDuplicateNames; std::vector<std::string> PkgsDirsVector; diff --git a/Source/CPack/IFW/cmCPackIFWInstaller.cxx b/Source/CPack/IFW/cmCPackIFWInstaller.cxx index fcb07e6..0644ecb 100644 --- a/Source/CPack/IFW/cmCPackIFWInstaller.cxx +++ b/Source/CPack/IFW/cmCPackIFWInstaller.cxx @@ -45,6 +45,12 @@ const char *cmCPackIFWInstaller::GetOption(const std::string &op) const } //---------------------------------------------------------------------------- +bool cmCPackIFWInstaller::IsOn(const std::string &op) const +{ + return Generator ? Generator->IsOn(op) : false; +} + +//---------------------------------------------------------------------------- void cmCPackIFWInstaller::ConfigureFromOptions() { // Name; @@ -167,6 +173,78 @@ void cmCPackIFWInstaller::ConfigureFromOptions() { AdminTargetDir = option; } + + // Repositories + Repositories.clear(); + RepositoryStruct Repo; + if (const char *site = this->GetOption("CPACK_DOWNLOAD_SITE")) + { + Repo.Url = site; + Repositories.push_back(Repo); + } + if(const char *RepoAllStr = this->GetOption("CPACK_IFW_REPOSITORIES_ALL")) + { + std::vector<std::string> RepoAllVector; + cmSystemTools::ExpandListArgument(RepoAllStr, + RepoAllVector); + for(std::vector<std::string>::iterator + rit = RepoAllVector.begin(); rit != RepoAllVector.end(); ++rit) + { + std::string prefix = "CPACK_IFW_REPOSITORY_" + + cmsys::SystemTools::UpperCase(*rit) + + "_"; + // Url + if (const char* url = GetOption(prefix + "URL")) + { + Repo.Url = url; + } + else + { + Repo.Url = ""; + } + // Enabled + if (IsOn(prefix + "DISABLED")) + { + Repo.Enabled = "0"; + } + else + { + Repo.Enabled = ""; + } + // Username + if (const char* username = GetOption(prefix + "USERNAME")) + { + Repo.Username = username; + } + else + { + Repo.Username = ""; + } + // Password + if (const char* password = GetOption(prefix + "PASSWORD")) + { + Repo.Password = password; + } + else + { + Repo.Password = ""; + } + // DisplayName + if (const char* displayName = GetOption(prefix + "DISPLAY_NAME")) + { + Repo.DisplayName = displayName; + } + else + { + Repo.DisplayName = ""; + } + + if(!Repo.Url.empty()) + { + Repositories.push_back(Repo); + } + } + } } //---------------------------------------------------------------------------- @@ -246,19 +324,43 @@ void cmCPackIFWInstaller::GenerateInstallerFile() << "</AdminTargetDir>" << std::endl; } - // Site - if (!Generator->DownloadSite.empty()) + // Remote repositories + if (!Repositories.empty()) { xout << " <RemoteRepositories>" << std::endl; - xout << " <Repository>" << std::endl; - xout << " <Url>" << Generator->DownloadSite - << "</Url>" << std::endl; - // These properties can not be set from "cpack_configure_downloads" - // <Enabled>1</Enabled> - // <Username>user</Username> - // <Password>password</Password> - // <DisplayName>Example repository</DisplayName> - xout << " </Repository>" << std::endl; + for(std::vector<RepositoryStruct>::iterator + rit = Repositories.begin(); rit != Repositories.end(); ++rit) + { + xout << " <Repository>" << std::endl; + // Url + xout << " <Url>" << rit->Url + << "</Url>" << std::endl; + // Enabled + if(!rit->Enabled.empty()) + { + xout << " <Enabled>" << rit->Enabled + << "</Enabled>" << std::endl; + } + // Username + if(!rit->Username.empty()) + { + xout << " <Username>" << rit->Username + << "</Username>" << std::endl; + } + // Password + if(!rit->Password.empty()) + { + xout << " <Password>" << rit->Password + << "</Password>" << std::endl; + } + // DisplayName + if(!rit->DisplayName.empty()) + { + xout << " <DisplayName>" << rit->DisplayName + << "</DisplayName>" << std::endl; + } + xout << " </Repository>" << std::endl; + } xout << " </RemoteRepositories>" << std::endl; } diff --git a/Source/CPack/IFW/cmCPackIFWInstaller.h b/Source/CPack/IFW/cmCPackIFWInstaller.h index 1630a94..5824d33 100644 --- a/Source/CPack/IFW/cmCPackIFWInstaller.h +++ b/Source/CPack/IFW/cmCPackIFWInstaller.h @@ -27,6 +27,15 @@ public: // Types typedef std::map<std::string, cmCPackIFWPackage*> PackagesMap; + struct RepositoryStruct + { + std::string Url; + std::string Enabled; + std::string Username; + std::string Password; + std::string DisplayName; + }; + public: // Constructor /** @@ -69,6 +78,7 @@ public: // Configuration public: // Internal implementation const char* GetOption(const std::string& op) const; + bool IsOn(const std::string& op) const; void ConfigureFromOptions(); @@ -78,6 +88,7 @@ public: // Internal implementation cmCPackIFWGenerator* Generator; PackagesMap Packages; + std::vector<RepositoryStruct> Repositories; std::string Directory; }; |