diff options
| author | Konstantin Podsvirov <konstantin@podsvirov.pro> | 2017-09-27 02:57:51 +0300 |
|---|---|---|
| committer | Konstantin Podsvirov <konstantin@podsvirov.pro> | 2017-09-28 00:21:26 +0300 |
| commit | c6149fae2f9f33d9ed363650aee6aea642574b0a (patch) | |
| tree | dd89cad4395719d9ff8690fc2c9239e9e52a325c | |
| parent | 68b9c2d8b9119acb48643447a7561a5c2b733d25 (diff) | |
| download | vcpkg-c6149fae2f9f33d9ed363650aee6aea642574b0a.tar.gz vcpkg-c6149fae2f9f33d9ed363650aee6aea642574b0a.zip | |
[vcpkg-export-ifw] Usage QtIFW tools
Download and use tools to make repository and installer
| -rw-r--r-- | scripts/fetchDependency.ps1 | 11 | ||||
| -rw-r--r-- | toolsrc/include/VcpkgPaths.h | 6 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg_Commands_Export_IFW.h | 2 | ||||
| -rw-r--r-- | toolsrc/src/VcpkgPaths.cpp | 40 | ||||
| -rw-r--r-- | toolsrc/src/commands_export.cpp | 19 | ||||
| -rw-r--r-- | toolsrc/src/commands_export_ifw.cpp | 145 |
6 files changed, 193 insertions, 30 deletions
diff --git a/scripts/fetchDependency.ps1 b/scripts/fetchDependency.ps1 index 2a23002a4..25447c19b 100644 --- a/scripts/fetchDependency.ps1 +++ b/scripts/fetchDependency.ps1 @@ -137,6 +137,17 @@ function SelectProgram([Parameter(Mandatory=$true)][string]$Dependency) $extractionType = $ExtractionType_ZIP $extractionFolder = "$downloadsDir\MinGit-2.14.1-32-bit" } + elseif($Dependency -eq "installerbase") + { + $requiredVersion = "3.1.81" + $downloadVersion = "3.1.81" + $url = "https://github.com/podsvirov/installer-framework/releases/download/cr203958-9/QtInstallerFramework-win-x86.zip" + $downloadPath = "$downloadsDir\QtInstallerFramework-win-x86.zip" + $expectedDownloadedFileHash = "f2ce23cf5cf9fc7ce409bdca49328e09a070c0026d3c8a04e4dfde7b05b83fe8" + $executableFromDownload = "$downloadsDir\QtInstallerFramework-win-x86\bin\installerbase.exe" + $extractionType = $ExtractionType_ZIP + $extractionFolder = $downloadsDir + } else { throw "Unknown program requested" diff --git a/toolsrc/include/VcpkgPaths.h b/toolsrc/include/VcpkgPaths.h index d55c95fe1..e7893ba15 100644 --- a/toolsrc/include/VcpkgPaths.h +++ b/toolsrc/include/VcpkgPaths.h @@ -57,6 +57,9 @@ namespace vcpkg const fs::path& get_cmake_exe() const; const fs::path& get_git_exe() const; const fs::path& get_nuget_exe() const; + const fs::path& get_ifw_installerbase_exe() const; + const fs::path& get_ifw_binarycreator_exe() const; + const fs::path& get_ifw_repogen_exe() const; /// <summary>Retrieve a toolset matching a VS version</summary> /// <remarks> @@ -70,6 +73,9 @@ namespace vcpkg Lazy<fs::path> cmake_exe; Lazy<fs::path> git_exe; Lazy<fs::path> nuget_exe; + Lazy<fs::path> ifw_installerbase_exe; + Lazy<fs::path> ifw_binarycreator_exe; + Lazy<fs::path> ifw_repogen_exe; Lazy<std::vector<Toolset>> toolsets; }; } diff --git a/toolsrc/include/vcpkg_Commands_Export_IFW.h b/toolsrc/include/vcpkg_Commands_Export_IFW.h index 881bbaf63..c066ca021 100644 --- a/toolsrc/include/vcpkg_Commands_Export_IFW.h +++ b/toolsrc/include/vcpkg_Commands_Export_IFW.h @@ -9,7 +9,9 @@ namespace vcpkg::Commands::Export::IFW { Optional<std::string> maybe_repository_url; Optional<std::string> maybe_packages_dir_path; + Optional<std::string> maybe_repository_dir_path; Optional<std::string> maybe_config_file_path; + Optional<std::string> maybe_installer_file_path; }; void do_export(const std::vector<Dependencies::ExportPlanAction> &export_plan, const std::string &export_id, const Options &ifw_options, const VcpkgPaths& paths); diff --git a/toolsrc/src/VcpkgPaths.cpp b/toolsrc/src/VcpkgPaths.cpp index 02e238b3f..89435cd38 100644 --- a/toolsrc/src/VcpkgPaths.cpp +++ b/toolsrc/src/VcpkgPaths.cpp @@ -164,6 +164,31 @@ namespace vcpkg return fetch_dependency(scripts_folder, L"git", downloaded_copy, EXPECTED_VERSION); } + static fs::path get_ifw_installerbase_path(const fs::path& downloads_folder, const fs::path& scripts_folder) + { + static constexpr std::array<int, 3> EXPECTED_VERSION = { 3, 1, 81 }; + static const std::wstring VERSION_CHECK_ARGUMENTS = L"--framework-version"; + + const fs::path downloaded_copy = downloads_folder / "QtInstallerFramework-win-x86" / "bin" / "installerbase.exe"; + + std::vector<fs::path> candidate_paths; + candidate_paths.push_back(downloaded_copy); + // TODO: Uncomment later + //const std::vector<fs::path> from_path = Files::find_from_PATH(L"installerbase"); + //candidate_paths.insert(candidate_paths.end(), from_path.cbegin(), from_path.cend()); + //candidate_paths.push_back(fs::path(System::get_environment_variable(L"HOMEDRIVE").value_or("C:")) / "Qt" / "Tools" / "QtInstallerFramework" / "3.1" / "bin" / "installerbase.exe"); + //candidate_paths.push_back(fs::path(System::get_environment_variable(L"HOMEDRIVE").value_or("C:")) / "Qt" / "QtIFW-3.1.0" / "bin" / "installerbase.exe"); + + const Optional<fs::path> path = + find_if_has_equal_or_greater_version(candidate_paths, VERSION_CHECK_ARGUMENTS, EXPECTED_VERSION); + if (const auto p = path.get()) + { + return *p; + } + + return fetch_dependency(scripts_folder, L"installerbase", downloaded_copy, EXPECTED_VERSION); + } + Expected<VcpkgPaths> VcpkgPaths::create(const fs::path& vcpkg_root_dir) { std::error_code ec; @@ -247,6 +272,21 @@ namespace vcpkg return this->nuget_exe.get_lazy([this]() { return get_nuget_path(this->downloads, this->scripts); }); } + const fs::path& VcpkgPaths::get_ifw_installerbase_exe() const + { + return this->ifw_installerbase_exe.get_lazy([this]() { return get_ifw_installerbase_path(this->downloads, this->scripts); }); + } + + const fs::path& VcpkgPaths::get_ifw_binarycreator_exe() const + { + return this->ifw_binarycreator_exe.get_lazy([this]() { return get_ifw_installerbase_exe().parent_path() / "binarycreator.exe"; }); + } + + const fs::path& VcpkgPaths::get_ifw_repogen_exe() const + { + return this->ifw_repogen_exe.get_lazy([this]() { return get_ifw_installerbase_exe().parent_path() / "repogen.exe"; }); + } + static std::vector<std::string> get_vs2017_installation_instances(const VcpkgPaths& paths) { const fs::path script = paths.scripts / "findVisualStudioInstallationInstances.ps1"; diff --git a/toolsrc/src/commands_export.cpp b/toolsrc/src/commands_export.cpp index 6632dfe67..3662a46d8 100644 --- a/toolsrc/src/commands_export.cpp +++ b/toolsrc/src/commands_export.cpp @@ -249,7 +249,9 @@ namespace vcpkg::Commands::Export static const std::string OPTION_NUGET_VERSION = "--nuget-version"; static const std::string OPTION_IFW_REPOSITORY_URL = "--ifw-repository-url"; static const std::string OPTION_IFW_PACKAGES_DIR_PATH = "--ifw-packages-directory-path"; + static const std::string OPTION_IFW_REPOSITORY_DIR_PATH = "--ifw-repository-directory-path"; static const std::string OPTION_IFW_CONFIG_FILE_PATH = "--ifw-configuration-file-path"; + static const std::string OPTION_IFW_INSTALLER_FILE_PATH = "--ifw-installer-file-path"; // input sanitization static const std::string EXAMPLE = @@ -276,7 +278,9 @@ namespace vcpkg::Commands::Export OPTION_NUGET_VERSION, OPTION_IFW_REPOSITORY_URL, OPTION_IFW_PACKAGES_DIR_PATH, - OPTION_IFW_CONFIG_FILE_PATH + OPTION_IFW_REPOSITORY_DIR_PATH, + OPTION_IFW_CONFIG_FILE_PATH, + OPTION_IFW_INSTALLER_FILE_PATH }); const bool dry_run = options.switches.find(OPTION_DRY_RUN) != options.switches.cend(); const bool raw = options.switches.find(OPTION_RAW) != options.switches.cend(); @@ -310,10 +314,18 @@ namespace vcpkg::Commands::Export Checks::check_exit( VCPKG_LINE_INFO, !ifw_options.maybe_packages_dir_path || ifw, "--ifw-packages-directory-path is only valid with --ifw"); + ifw_options.maybe_repository_dir_path = maybe_lookup(options.settings, OPTION_IFW_REPOSITORY_DIR_PATH); + Checks::check_exit( + VCPKG_LINE_INFO, !ifw_options.maybe_repository_dir_path || ifw, "--ifw-repository-directory-path is only valid with --ifw"); + ifw_options.maybe_config_file_path = maybe_lookup(options.settings, OPTION_IFW_CONFIG_FILE_PATH); Checks::check_exit( VCPKG_LINE_INFO, !ifw_options.maybe_config_file_path || ifw, "--ifw-configuration-file-path is only valid with --ifw"); + ifw_options.maybe_installer_file_path = maybe_lookup(options.settings, OPTION_IFW_INSTALLER_FILE_PATH); + Checks::check_exit( + VCPKG_LINE_INFO, !ifw_options.maybe_installer_file_path || ifw, "--ifw-installer-file-path is only valid with --ifw"); + // create the plan const StatusParagraphs status_db = database_load_check(paths); std::vector<ExportPlanAction> export_plan = Dependencies::create_export_plan(paths, specs, status_db); @@ -464,10 +476,7 @@ With a project open, go to Tools->NuGet Package Manager->Package Manager Console { IFW::do_export(export_plan, export_id, ifw_options, paths); - // TODO: Download corrected QtIFW tools and automate installer creation - System::println("Use corrected QtIFW tools (for more info see: https://codereview.qt-project.org/#/c/203958) to create installer..."); - - print_next_step_info("[...]"); + print_next_step_info("@RootDir@/src/vcpkg"); } Checks::exit_success(VCPKG_LINE_INFO); diff --git a/toolsrc/src/commands_export_ifw.cpp b/toolsrc/src/commands_export_ifw.cpp index e2499b75d..d1428f5d1 100644 --- a/toolsrc/src/commands_export_ifw.cpp +++ b/toolsrc/src/commands_export_ifw.cpp @@ -26,7 +26,35 @@ namespace vcpkg::Commands::Export::IFW return date_time_as_string; } - fs::path export_real_package(const fs::path& raw_exported_dir_path, + fs::path get_packages_dir_path(const std::string &export_id, const Options &ifw_options, const VcpkgPaths& paths) + { + return ifw_options.maybe_packages_dir_path.has_value() ? + fs::path(ifw_options.maybe_packages_dir_path.value_or_exit(VCPKG_LINE_INFO)) + : paths.root / (export_id + "-ifw-packages"); + } + + fs::path get_repository_dir_path(const std::string &export_id, const Options &ifw_options, const VcpkgPaths& paths) + { + return ifw_options.maybe_packages_dir_path.has_value() ? + fs::path(ifw_options.maybe_repository_dir_path.value_or_exit(VCPKG_LINE_INFO)) + : paths.root / (export_id + "-ifw-repository"); + } + + fs::path get_config_file_path(const std::string &export_id, const Options &ifw_options, const VcpkgPaths& paths) + { + return ifw_options.maybe_config_file_path.has_value() ? + fs::path(ifw_options.maybe_config_file_path.value_or_exit(VCPKG_LINE_INFO)) + : paths.root / (export_id + "-ifw-configuration.xml"); + } + + fs::path get_installer_file_path(const std::string &export_id, const Options &ifw_options, const VcpkgPaths& paths) + { + return ifw_options.maybe_config_file_path.has_value() ? + fs::path(ifw_options.maybe_installer_file_path.value_or_exit(VCPKG_LINE_INFO)) + : paths.root / (export_id + "-ifw-installer.exe"); + } + + fs::path export_real_package(const fs::path& ifw_packages_dir_path, const ExportPlanAction& action, Files::Filesystem& fs) { @@ -37,7 +65,7 @@ namespace vcpkg::Commands::Export::IFW // Prepare meta dir const fs::path package_xml_file_path = - raw_exported_dir_path / + ifw_packages_dir_path / Strings::format("packages.%s.%s", action.spec.name(), action.spec.triplet().canonical_name()) / "meta" / "package.xml"; const fs::path package_xml_dir_path = package_xml_file_path.parent_path(); @@ -47,6 +75,11 @@ namespace vcpkg::Commands::Export::IFW "Could not create directory for package file %s", package_xml_file_path.generic_string()); + auto deps = Strings::join( + ",", binary_paragraph.depends, [](const std::string& dep) { return "packages." + dep + ":"; }); + + if (!deps.empty()) deps = "\n <Dependencies>" + deps + "</Dependencies>"; + fs.write_contents(package_xml_file_path, Strings::format( R"###(<?xml version="1.0"?> @@ -54,7 +87,7 @@ R"###(<?xml version="1.0"?> <DisplayName>%s</DisplayName> <Version>%s</Version> <ReleaseDate>%s</ReleaseDate> - <AutoDependOn>packages.%s:,triplets.%s:</AutoDependOn> + <AutoDependOn>packages.%s:,triplets.%s:</AutoDependOn>%s <Virtual>true</Virtual> </Package> )###", @@ -62,10 +95,11 @@ R"###(<?xml version="1.0"?> binary_paragraph.version, create_release_date(), action.spec.name(), - action.spec.triplet().canonical_name())); + action.spec.triplet().canonical_name(), + deps)); // Return dir path for export package data - return raw_exported_dir_path / + return ifw_packages_dir_path / Strings::format("packages.%s.%s", action.spec.name(), action.spec.triplet().canonical_name()) / "data" / "installed"; } @@ -110,11 +144,6 @@ R"###(<?xml version="1.0"?> "Could not create directory for package file %s", package_xml_file_path.generic_string()); - auto deps = Strings::join( - ",", binary_paragraph.depends, [](const std::string& dep) { return "packages." + dep + ":"; }); - - if (!deps.empty()) deps = "\n <Dependencies>" + deps + "</Dependencies>"; - fs.write_contents(package_xml_file_path, Strings::format( R"###(<?xml version="1.0"?> @@ -122,14 +151,13 @@ R"###(<?xml version="1.0"?> <DisplayName>%s</DisplayName> <Description>%s</Description> <Version>%s</Version> - <ReleaseDate>%s</ReleaseDate>%s + <ReleaseDate>%s</ReleaseDate> </Package> )###", action.spec.name(), binary_paragraph.description, binary_paragraph.version, - create_release_date(), - deps)); + create_release_date())); } } @@ -210,9 +238,7 @@ R"###(<?xml version="1.0"?> std::error_code ec; Files::Filesystem& fs = paths.get_filesystem(); - const fs::path config_xml_file_path = ifw_options.maybe_config_file_path.has_value() ? - fs::path(ifw_options.maybe_config_file_path.value_or_exit(VCPKG_LINE_INFO)) - : paths.root / (export_id + "-ifw-configuration") / "config.xml"; + const fs::path config_xml_file_path = get_config_file_path(export_id, ifw_options, paths); fs::path config_xml_dir_path = config_xml_file_path.parent_path(); fs.create_directories(config_xml_dir_path, ec); @@ -243,21 +269,76 @@ R"###(<?xml version="1.0"?> </Installer> )###", formatted_repo_url)); + } + + void do_repository(const std::string &export_id, const Options &ifw_options, const VcpkgPaths& paths) + { + const fs::path& repogen_exe = paths.get_ifw_repogen_exe(); + const fs::path packages_dir = get_packages_dir_path(export_id, ifw_options, paths); + const fs::path repository_dir = get_repository_dir_path(export_id, ifw_options, paths); + + System::println("Generating repository %s...", repository_dir.generic_string()); - System::println("Created ifw configuration file: %s", config_xml_file_path.generic_string()); + const std::wstring cmd_line = + Strings::wformat(LR"("%s" --packages "%s" "%s" > nul)", + repogen_exe.native(), + packages_dir.native(), + repository_dir.native()); + + const int exit_code = System::cmd_execute_clean(cmd_line); + Checks::check_exit(VCPKG_LINE_INFO, exit_code == 0, "Error: IFW repository generating failed"); + + System::println(System::Color::success, "Generating repository %s... done.", repository_dir.generic_string()); + } + + void do_installer(const std::string &export_id, const Options &ifw_options, const VcpkgPaths& paths) + { + const fs::path& binarycreator_exe = paths.get_ifw_binarycreator_exe(); + const fs::path config_file = get_config_file_path(export_id, ifw_options, paths); + const fs::path packages_dir = get_packages_dir_path(export_id, ifw_options, paths); + const fs::path repository_dir = get_repository_dir_path(export_id, ifw_options, paths); + const fs::path installer_file = get_installer_file_path(export_id, ifw_options, paths); + + System::println("Generating installer %s...", installer_file.generic_string()); + + std::wstring cmd_line; + + std::string ifw_repo_url = ifw_options.maybe_repository_url.value_or(""); + if (!ifw_repo_url.empty()) + { + cmd_line = + Strings::wformat(LR"("%s" --online-only --config "%s" --repository "%s" "%s" > nul)", + binarycreator_exe.native(), + config_file.native(), + repository_dir.native(), + installer_file.native()); + } + else + { + cmd_line = + Strings::wformat(LR"("%s" --config "%s" --packages "%s" "%s" > nul)", + binarycreator_exe.native(), + config_file.native(), + packages_dir.native(), + installer_file.native()); + } + + const int exit_code = System::cmd_execute_clean(cmd_line); + Checks::check_exit(VCPKG_LINE_INFO, exit_code == 0, "Error: IFW installer generating failed"); + + System::println(System::Color::success, "Generating installer %s... done.", installer_file.generic_string()); } void do_export(const std::vector<ExportPlanAction> &export_plan, const std::string &export_id, const Options &ifw_options, const VcpkgPaths& paths) { - System::println("Creating ifw packages... "); + const fs::path ifw_packages_dir_path = get_packages_dir_path(export_id, ifw_options, paths); + const fs::path config_file = get_config_file_path(export_id, ifw_options, paths); + + System::println("Exporting packages %s... ", ifw_packages_dir_path.generic_string()); std::error_code ec; Files::Filesystem& fs = paths.get_filesystem(); - const fs::path ifw_packages_dir_path = ifw_options.maybe_packages_dir_path.has_value() ? - fs::path(ifw_options.maybe_packages_dir_path.value_or_exit(VCPKG_LINE_INFO)) - : paths.root / (export_id + "-ifw-packages"); - fs.remove_all(ifw_packages_dir_path, ec); Checks::check_exit(VCPKG_LINE_INFO, !ec, @@ -299,9 +380,13 @@ R"###(<?xml version="1.0"?> (binary_paragraph.fullstem() + ".list")); Install::install_files_and_write_listfile(paths.get_filesystem(), paths.package_dir(action.spec), dirs); - System::println(System::Color::success, "Exporting package %s... done", display_name); + System::println("Exporting package %s... done", display_name); } + System::println("Exporting packages %s... done", ifw_packages_dir_path.generic_string()); + + System::println("Generating configuration %s...", config_file.generic_string()); + // Unique packages export_unique_packages(ifw_packages_dir_path, unique_packages, fs); @@ -313,9 +398,19 @@ R"###(<?xml version="1.0"?> // Integration export_integration(ifw_packages_dir_path, fs); - System::println("Created ifw packages directory: %s", ifw_packages_dir_path.generic_string()); - // Configuration export_config(export_id, ifw_options, paths); + + System::println("Generating configuration %s... done.", config_file.generic_string()); + + // Do repository (optional) + std::string ifw_repo_url = ifw_options.maybe_repository_url.value_or(""); + if (!ifw_repo_url.empty()) + { + do_repository(export_id, ifw_options, paths); + } + + // Do installer + do_installer(export_id, ifw_options, paths); } } |
