diff --git a/azure-pipelines/end-to-end-tests-dir/bundles.ps1 b/azure-pipelines/end-to-end-tests-dir/bundles.ps1 index 71c0cf31c7..13ee72d4e7 100644 --- a/azure-pipelines/end-to-end-tests-dir/bundles.ps1 +++ b/azure-pipelines/end-to-end-tests-dir/bundles.ps1 @@ -150,7 +150,7 @@ foreach ($k in $b.keys) { Run-Vcpkg install vcpkg-hello-world-1 --dry-run @commonArgs ` --x-buildtrees-root=$buildtreesRoot ` - --x-builtin-ports-root=$deploy/ports ` + --x-builtin-ports-root=$deployment/ports ` --x-install-root=$installRoot ` --x-packages-root=$packagesRoot Throw-IfNotFailed @@ -164,7 +164,7 @@ $CurrentTest = "Testing bundle.usegitregistry" Run-Vcpkg install --dry-run @commonArgs ` --x-manifest-root=$manifestdir ` --x-buildtrees-root=$buildtreesRoot ` - --x-builtin-ports-root=$deploy/ports ` + --x-builtin-ports-root=$deployment/ports ` --x-install-root=$installRoot ` --x-packages-root=$packagesRoot Throw-IfNotFailed @@ -184,7 +184,7 @@ New-Item -ItemType Directory -Force $manifestdir2 | Out-Null Run-Vcpkg install @commonArgs ` --x-manifest-root=$manifestdir2 ` --x-buildtrees-root=$buildtreesRoot ` - --x-builtin-ports-root=$deploy/ports ` + --x-builtin-ports-root=$deployment/ports ` --x-install-root=$installRoot ` --x-packages-root=$packagesRoot Throw-IfFailed @@ -192,7 +192,7 @@ Throw-IfFailed Run-Vcpkg search vcpkg-hello-world-1 @commonArgs ` --x-manifest-root=$manifestdir2 ` --x-buildtrees-root=$buildtreesRoot ` - --x-builtin-ports-root=$deploy/ports ` + --x-builtin-ports-root=$deployment/ports ` --x-install-root=$installRoot ` --x-packages-root=$packagesRoot Throw-IfFailed diff --git a/azure-pipelines/end-to-end-tests-dir/upgrade.ps1 b/azure-pipelines/end-to-end-tests-dir/upgrade.ps1 new file mode 100644 index 0000000000..dacd0be1d3 --- /dev/null +++ b/azure-pipelines/end-to-end-tests-dir/upgrade.ps1 @@ -0,0 +1,48 @@ +. "$PSScriptRoot/../end-to-end-tests-prelude.ps1" + +git clone $VcpkgRoot "$TestingRoot/temp-repo" --local +try +{ + $env:VCPKG_ROOT = "$TestingRoot/temp-repo" + git -C "$TestingRoot/temp-repo" switch -d e1934f4a2a0c58bb75099d89ed980832379907fa # vcpkg-cmake @ 2022-12-22 + $output = Run-VcpkgAndCaptureOutput install vcpkg-cmake + Throw-IfFailed + if (-Not ($output -match 'vcpkg-cmake:[^ ]+ -> 2022-12-22')) + { + throw 'Unexpected vcpkg-cmake install' + } + + git -C "$TestingRoot/temp-repo" switch -d f6a5d4e8eb7476b8d7fc12a56dff300c1c986131 # vcpkg-cmake @ 2023-05-04 + $output = Run-VcpkgAndCaptureOutput upgrade + Throw-IfNotFailed + if (-Not ($output -match 'If you are sure you want to rebuild the above packages, run this command with the --no-dry-run option.')) + { + throw "Upgrade didn't handle dry-run correctly" + } + + if (-Not ($output -match '\* vcpkg-cmake:[^ ]+ -> 2023-05-04')) + { + throw "Upgrade didn't choose expected version" + } + + $output = Run-VcpkgAndCaptureOutput upgrade --no-dry-run + Throw-IfFailed + if (-Not ($output -match '\* vcpkg-cmake:[^ ]+ -> 2023-05-04')) + { + throw "Upgrade didn't choose expected version" + } + + if (-Not ($output -match 'vcpkg-cmake:[^:]+: REMOVED:')) + { + throw "Upgrade didn't remove" + } + + if (-Not ($output -match 'vcpkg-cmake:[^:]+: SUCCEEDED:')) + { + throw "Upgrade didn't install" + } +} +finally +{ + $env:VCPKG_ROOT = $VcpkgRoot +} diff --git a/include/vcpkg/dependencies.h b/include/vcpkg/dependencies.h index a273e9dc9f..7682a42de1 100644 --- a/include/vcpkg/dependencies.h +++ b/include/vcpkg/dependencies.h @@ -66,6 +66,7 @@ namespace vcpkg InstallPlanAction(const PackageSpec& spec, const SourceControlFileAndLocation& scfl, + const Path& packages_dir, const RequestType& request_type, Triplet host_triplet, std::map>&& dependencies, diff --git a/src/vcpkg-test/binarycaching.cpp b/src/vcpkg-test/binarycaching.cpp index b74d930c5b..db6483dee6 100644 --- a/src/vcpkg-test/binarycaching.cpp +++ b/src/vcpkg-test/binarycaching.cpp @@ -223,6 +223,7 @@ Build-Depends: bzip InstallPlanAction ipa(PackageSpec{"zlib2", Test::X64_WINDOWS}, scfl, + "test_packages_root", RequestType::USER_REQUESTED, Test::ARM_UWP, {{"a", {}}, {"b", {}}}, @@ -347,6 +348,7 @@ Version: 1.5 std::vector install_plan; install_plan.emplace_back(PackageSpec{"someheadpackage", Test::X64_WINDOWS}, scfl, + "test_packages_root", RequestType::USER_REQUESTED, Test::ARM_UWP, std::map>{}, @@ -422,6 +424,7 @@ Description: a spiffy compression library wrapper SourceControlFileAndLocation scfl{std::move(*maybe_scf.get()), Path()}; plan.install_actions.emplace_back(PackageSpec("zlib", Test::X64_ANDROID), scfl, + "test_packages_root", RequestType::USER_REQUESTED, Test::ARM64_WINDOWS, std::map>{}, @@ -448,6 +451,7 @@ Description: a spiffy compression library wrapper SourceControlFileAndLocation scfl2{std::move(*maybe_scf2.get()), Path()}; plan.install_actions.emplace_back(PackageSpec("zlib2", Test::X64_ANDROID), scfl2, + "test_packages_root", RequestType::USER_REQUESTED, Test::ARM64_WINDOWS, std::map>{}, diff --git a/src/vcpkg-test/dependencies.cpp b/src/vcpkg-test/dependencies.cpp index 6945a4020e..93aa2d63a6 100644 --- a/src/vcpkg-test/dependencies.cpp +++ b/src/vcpkg-test/dependencies.cpp @@ -2278,11 +2278,16 @@ TEST_CASE ("formatting plan 1", "[dependencies]") const RemovePlanAction remove_b({"b", Test::X64_OSX}, RequestType::USER_REQUESTED); const RemovePlanAction remove_a({"a", Test::X64_OSX}, RequestType::USER_REQUESTED); const RemovePlanAction remove_c({"c", Test::X64_OSX}, RequestType::AUTO_SELECTED); - InstallPlanAction install_a({"a", Test::X64_OSX}, scfl_a, RequestType::AUTO_SELECTED, Test::X64_ANDROID, {}, {}); + + const Path pr = "packages_root"; + InstallPlanAction install_a( + {"a", Test::X64_OSX}, scfl_a, pr, RequestType::AUTO_SELECTED, Test::X64_ANDROID, {}, {}); InstallPlanAction install_b( - {"b", Test::X64_OSX}, scfl_b, RequestType::AUTO_SELECTED, Test::X64_ANDROID, {{"1", {}}}, {}); - InstallPlanAction install_c({"c", Test::X64_OSX}, scfl_c, RequestType::USER_REQUESTED, Test::X64_ANDROID, {}, {}); - InstallPlanAction install_f({"f", Test::X64_OSX}, scfl_f, RequestType::USER_REQUESTED, Test::X64_ANDROID, {}, {}); + {"b", Test::X64_OSX}, scfl_b, pr, RequestType::AUTO_SELECTED, Test::X64_ANDROID, {{"1", {}}}, {}); + InstallPlanAction install_c( + {"c", Test::X64_OSX}, scfl_c, pr, RequestType::USER_REQUESTED, Test::X64_ANDROID, {}, {}); + InstallPlanAction install_f( + {"f", Test::X64_OSX}, scfl_f, pr, RequestType::USER_REQUESTED, Test::X64_ANDROID, {}, {}); install_f.plan_type = InstallPlanType::EXCLUDED; InstallPlanAction already_installed_d( @@ -2374,7 +2379,7 @@ TEST_CASE ("dependency graph API snapshot") MockVersionedPortfileProvider vp; auto& scfl_a = vp.emplace("a", {"1", 0}); InstallPlanAction install_a( - {"a", Test::X64_WINDOWS}, scfl_a, RequestType::AUTO_SELECTED, Test::X64_ANDROID, {}, {}); + {"a", Test::X64_WINDOWS}, scfl_a, "packages_root", RequestType::AUTO_SELECTED, Test::X64_ANDROID, {}, {}); ActionPlan plan; plan.install_actions.push_back(std::move(install_a)); diff --git a/src/vcpkg-test/spdx.cpp b/src/vcpkg-test/spdx.cpp index c23a466c4c..6f790f8453 100644 --- a/src/vcpkg-test/spdx.cpp +++ b/src/vcpkg-test/spdx.cpp @@ -21,7 +21,7 @@ TEST_CASE ("spdx maximum serialization", "[spdx]") cpgh.raw_version = "1.0"; cpgh.version_scheme = VersionScheme::Relaxed; - InstallPlanAction ipa(spec, scfl, RequestType::USER_REQUESTED, Test::X86_WINDOWS, {}, {}); + InstallPlanAction ipa(spec, scfl, "test_packages_root", RequestType::USER_REQUESTED, Test::X86_WINDOWS, {}, {}); auto& abi = *(ipa.abi_info = AbiInfo{}).get(); abi.package_abi = "ABIHASH"; @@ -175,7 +175,7 @@ TEST_CASE ("spdx minimum serialization", "[spdx]") cpgh.raw_version = "1.0"; cpgh.version_scheme = VersionScheme::String; - InstallPlanAction ipa(spec, scfl, RequestType::USER_REQUESTED, Test::X86_WINDOWS, {}, {}); + InstallPlanAction ipa(spec, scfl, "test_packages_root", RequestType::USER_REQUESTED, Test::X86_WINDOWS, {}, {}); auto& abi = *(ipa.abi_info = AbiInfo{}).get(); abi.package_abi = "deadbeef"; @@ -303,7 +303,7 @@ TEST_CASE ("spdx concat resources", "[spdx]") cpgh.raw_version = "1.0"; cpgh.version_scheme = VersionScheme::String; - InstallPlanAction ipa(spec, scfl, RequestType::USER_REQUESTED, Test::X86_WINDOWS, {}, {}); + InstallPlanAction ipa(spec, scfl, "test_packages_root", RequestType::USER_REQUESTED, Test::X86_WINDOWS, {}, {}); auto& abi = *(ipa.abi_info = AbiInfo{}).get(); abi.package_abi = "deadbeef"; diff --git a/src/vcpkg/dependencies.cpp b/src/vcpkg/dependencies.cpp index 45ce1cdf31..e759bb5390 100644 --- a/src/vcpkg/dependencies.cpp +++ b/src/vcpkg/dependencies.cpp @@ -292,7 +292,8 @@ namespace vcpkg PackageGraph(const PortFileProvider& provider, const CMakeVars::CMakeVarProvider& var_provider, const StatusParagraphs& status_db, - Triplet host_triplet); + Triplet host_triplet, + const Path& packages_dir); ~PackageGraph() = default; void install(Span specs, UnsupportedPortAction unsupported_port_action); @@ -306,6 +307,7 @@ namespace vcpkg const CMakeVars::CMakeVarProvider& m_var_provider; std::unique_ptr m_graph; + Path m_packages_dir; std::map m_unsupported_features; }; @@ -457,6 +459,7 @@ namespace vcpkg InstallPlanAction::InstallPlanAction(const PackageSpec& spec, const SourceControlFileAndLocation& scfl, + const Path& packages_dir, const RequestType& request_type, Triplet host_triplet, std::map>&& dependencies, @@ -469,6 +472,7 @@ namespace vcpkg , feature_dependencies(std::move(dependencies)) , build_failure_messages(std::move(build_failure_messages)) , host_triplet(host_triplet) + , package_dir(packages_dir / spec.dir()) { } @@ -707,7 +711,7 @@ namespace vcpkg const StatusParagraphs& status_db, const CreateInstallPlanOptions& options) { - PackageGraph pgraph(port_provider, var_provider, status_db, options.host_triplet); + PackageGraph pgraph(port_provider, var_provider, status_db, options.host_triplet, options.packages_dir); std::vector feature_specs; for (const FullPackageSpec& spec : specs) @@ -719,17 +723,7 @@ namespace vcpkg pgraph.install(feature_specs, options.unsupported_port_action); - auto res = pgraph.serialize(options.randomizer); - - for (auto&& action : res.install_actions) - { - if (action.source_control_file_and_location.has_value()) - { - action.package_dir.emplace(options.packages_dir / action.spec.dir()); - } - } - - return res; + return pgraph.serialize(options.randomizer); } void PackageGraph::mark_for_reinstall(const PackageSpec& first_remove_spec, @@ -927,7 +921,7 @@ namespace vcpkg const StatusParagraphs& status_db, const CreateInstallPlanOptions& options) { - PackageGraph pgraph(port_provider, var_provider, status_db, options.host_triplet); + PackageGraph pgraph(port_provider, var_provider, status_db, options.host_triplet, options.packages_dir); pgraph.upgrade(specs, options.unsupported_port_action); @@ -1044,21 +1038,33 @@ namespace vcpkg fspecs.insert(fspec); continue; } + auto&& dep_clust = m_graph->get(fspec.spec()); const auto& default_features = [&] { if (dep_clust.m_install_info.has_value()) + { return dep_clust.get_scfl_or_exit() .source_control_file->core_paragraph->default_features; - if (auto p = dep_clust.m_installed.get()) return p->ipv.core->package.default_features; + } + + if (auto p = dep_clust.m_installed.get()) + { + return p->ipv.core->package.default_features; + } + Checks::unreachable(VCPKG_LINE_INFO); }(); + for (auto&& default_feature : default_features) + { fspecs.emplace(fspec.spec(), default_feature); + } } computed_edges[kv.first].assign(fspecs.begin(), fspecs.end()); } plan.install_actions.emplace_back(p_cluster->m_spec, p_cluster->get_scfl_or_exit(), + m_packages_dir, p_cluster->request_type, m_graph->m_host_triplet, std::move(computed_edges), @@ -1113,8 +1119,11 @@ namespace vcpkg PackageGraph::PackageGraph(const PortFileProvider& port_provider, const CMakeVars::CMakeVarProvider& var_provider, const StatusParagraphs& status_db, - Triplet host_triplet) - : m_var_provider(var_provider), m_graph(create_feature_install_graph(port_provider, status_db, host_triplet)) + Triplet host_triplet, + const Path& packages_dir) + : m_var_provider(var_provider) + , m_graph(create_feature_install_graph(port_provider, status_db, host_triplet)) + , m_packages_dir(packages_dir) { } @@ -1272,12 +1281,14 @@ namespace vcpkg const IBaselineProvider& base_provider, const IOverlayProvider& oprovider, const CMakeVars::CMakeVarProvider& var_provider, - Triplet host_triplet) + Triplet host_triplet, + const Path& packages_dir) : m_ver_provider(ver_provider) , m_base_provider(base_provider) , m_o_provider(oprovider) , m_var_provider(var_provider) , m_host_triplet(host_triplet) + , m_packages_dir(packages_dir) { } @@ -1294,6 +1305,7 @@ namespace vcpkg const IOverlayProvider& m_o_provider; const CMakeVars::CMakeVarProvider& m_var_provider; const Triplet m_host_triplet; + const Path m_packages_dir; struct DepSpec { @@ -1784,6 +1796,7 @@ namespace vcpkg : RequestType::AUTO_SELECTED; InstallPlanAction ipa(dep.spec, *node.second.scfl, + m_packages_dir, request, m_host_triplet, compute_feature_dependencies(node, deps), @@ -1901,24 +1914,14 @@ namespace vcpkg const PackageSpec& toplevel, const CreateInstallPlanOptions& options) { - VersionedPackageGraph vpg(provider, bprovider, oprovider, var_provider, options.host_triplet); + VersionedPackageGraph vpg( + provider, bprovider, oprovider, var_provider, options.host_triplet, options.packages_dir); for (auto&& o : overrides) { vpg.add_override(o.name, {o.version, o.port_version}); } vpg.solve_with_roots(deps, toplevel); - auto ret = vpg.finalize_extract_plan(toplevel, options.unsupported_port_action); - if (auto plan = ret.get()) - { - for (auto&& action : plan->install_actions) - { - if (action.source_control_file_and_location.has_value()) - { - action.package_dir.emplace(options.packages_dir / action.spec.dir()); - } - } - } - return ret; + return vpg.finalize_extract_plan(toplevel, options.unsupported_port_action); } } diff --git a/src/vcpkg/postbuildlint.cpp b/src/vcpkg/postbuildlint.cpp index 8c7c3d4924..57e2251bbb 100644 --- a/src/vcpkg/postbuildlint.cpp +++ b/src/vcpkg/postbuildlint.cpp @@ -353,11 +353,11 @@ namespace vcpkg static LintStatus check_for_copyright_file(const ReadOnlyFilesystem& fs, const PackageSpec& spec, + const Path& package_dir, const VcpkgPaths& paths, MessageSink& msg_sink) { - const auto packages_dir = paths.package_dir(spec); - const auto copyright_file = packages_dir / "share" / spec.name() / "copyright"; + const auto copyright_file = package_dir / "share" / spec.name() / "copyright"; switch (fs.status(copyright_file, IgnoreErrors{})) { @@ -1364,7 +1364,7 @@ namespace vcpkg error_count += check_folder_debug_lib_cmake(fs, package_dir, spec, msg_sink); error_count += check_for_dlls_in_lib_dir(fs, package_dir, msg_sink); error_count += check_for_dlls_in_lib_dir(fs, package_dir / "debug", msg_sink); - error_count += check_for_copyright_file(fs, spec, paths, msg_sink); + error_count += check_for_copyright_file(fs, spec, package_dir, paths, msg_sink); error_count += check_for_exes(fs, package_dir, msg_sink); error_count += check_for_exes(fs, package_dir / "debug", msg_sink); error_count += check_for_usage_forgot_install(fs, port_dir, package_dir, spec, msg_sink);