aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornicole mazzuca <mazzucan@outlook.com>2020-08-25 15:08:25 -0700
committerGitHub <noreply@github.com>2020-08-25 15:08:25 -0700
commitdea7d758c6e721a53608f41245e4ecbd3db838f0 (patch)
treeebeea388710654759a10e315682ea143ac358481
parent582e30d142cbc7ebbb45a74e9c54cd069fabe097 (diff)
downloadvcpkg-dea7d758c6e721a53608f41245e4ecbd3db838f0.tar.gz
vcpkg-dea7d758c6e721a53608f41245e4ecbd3db838f0.zip
[vcpkg] Fix upgrade for port-version (#13069)
Co-authored-by: Billy Robert O'Neal <bion@microsoft.com>
-rw-r--r--toolsrc/src/vcpkg/commands.upgrade.cpp50
1 files changed, 28 insertions, 22 deletions
diff --git a/toolsrc/src/vcpkg/commands.upgrade.cpp b/toolsrc/src/vcpkg/commands.upgrade.cpp
index dd42d76c4..5e9ed7ce2 100644
--- a/toolsrc/src/vcpkg/commands.upgrade.cpp
+++ b/toolsrc/src/vcpkg/commands.upgrade.cpp
@@ -81,41 +81,46 @@ namespace vcpkg::Commands::Upgrade
else
{
std::vector<PackageSpec> not_installed;
- std::vector<PackageSpec> no_portfile;
+ std::vector<PackageSpec> no_control_file;
std::vector<PackageSpec> to_upgrade;
std::vector<PackageSpec> up_to_date;
for (auto&& spec : specs)
{
- auto it = status_db.find_installed(spec);
- if (it == status_db.end())
+ bool skip_version_check = false;
+ auto installed_status = status_db.find_installed(spec);
+ if (installed_status == status_db.end())
{
not_installed.push_back(spec);
+ skip_version_check = true;
}
- auto maybe_scfl = provider.get_control_file(spec.name());
- if (auto p_scfl = maybe_scfl.get())
+ auto maybe_control_file = provider.get_control_file(spec.name());
+ if (!maybe_control_file.has_value())
{
- if (it != status_db.end())
- {
- if (p_scfl->source_control_file->core_paragraph->version != (*it)->package.version)
- {
- to_upgrade.push_back(spec);
- }
- else
- {
- up_to_date.push_back(spec);
- }
- }
+ no_control_file.push_back(spec);
+ skip_version_check = true;
+ }
+
+ if (skip_version_check) continue;
+
+ const auto& control_file = maybe_control_file.value_or_exit(VCPKG_LINE_INFO);
+ const auto& control_paragraph = *control_file.source_control_file->core_paragraph;
+ auto control_version = VersionT(control_paragraph.version, control_paragraph.port_version);
+ const auto& installed_paragraph = (*installed_status)->package;
+ auto installed_version = VersionT(installed_paragraph.version, installed_paragraph.port_version);
+ if (control_version == installed_version)
+ {
+ up_to_date.push_back(spec);
}
else
{
- no_portfile.push_back(spec);
+ to_upgrade.push_back(spec);
}
}
Util::sort(not_installed);
- Util::sort(no_portfile);
+ Util::sort(no_control_file);
Util::sort(up_to_date);
Util::sort(to_upgrade);
@@ -137,16 +142,17 @@ namespace vcpkg::Commands::Upgrade
'\n');
}
- if (!no_portfile.empty())
+ if (!no_control_file.empty())
{
- System::print2(System::Color::error, "The following packages do not have a valid portfile:\n");
+ System::print2(System::Color::error,
+ "The following packages do not have a valid CONTROL or vcpkg.json:\n");
System::print2(Strings::join("",
- no_portfile,
+ no_control_file,
[](const PackageSpec& spec) { return " " + spec.to_string() + "\n"; }),
'\n');
}
- Checks::check_exit(VCPKG_LINE_INFO, not_installed.empty() && no_portfile.empty());
+ Checks::check_exit(VCPKG_LINE_INFO, not_installed.empty() && no_control_file.empty());
if (to_upgrade.empty()) Checks::exit_success(VCPKG_LINE_INFO);