aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Schumacher <roschuma@microsoft.com>2017-12-13 04:47:59 -0800
committerRobert Schumacher <roschuma@microsoft.com>2017-12-13 04:47:59 -0800
commite6b16165e7d69feab3f4841ab702e6072199b9d4 (patch)
treecfa4aa8b77b7010f19afef5c7d41a81733fb4af3
parent621d9afe7b8225ce3607b599413dd60cc93c94e9 (diff)
downloadvcpkg-e6b16165e7d69feab3f4841ab702e6072199b9d4.tar.gz
vcpkg-e6b16165e7d69feab3f4841ab702e6072199b9d4.zip
Revert "[vcpkg-upgrade] Accept list of packages to specifically upgrade."
This reverts commit d88563cd095b9aaad81d57f1c0a254d7e17cf859.
-rw-r--r--toolsrc/include/vcpkg/packagespec.h7
-rw-r--r--toolsrc/src/commands.upgrade.cpp108
-rw-r--r--toolsrc/src/vcpkg/base/checks.cpp9
3 files changed, 16 insertions, 108 deletions
diff --git a/toolsrc/include/vcpkg/packagespec.h b/toolsrc/include/vcpkg/packagespec.h
index f1119e2f3..071487e1a 100644
--- a/toolsrc/include/vcpkg/packagespec.h
+++ b/toolsrc/include/vcpkg/packagespec.h
@@ -34,13 +34,6 @@ namespace vcpkg
std::string to_string() const;
- bool operator<(const PackageSpec& other) const
- {
- if (name() < other.name()) return true;
- if (name() > other.name()) return false;
- return triplet() < other.triplet();
- }
-
private:
std::string m_name;
Triplet m_triplet;
diff --git a/toolsrc/src/commands.upgrade.cpp b/toolsrc/src/commands.upgrade.cpp
index 2ce04faa9..7a3210042 100644
--- a/toolsrc/src/commands.upgrade.cpp
+++ b/toolsrc/src/commands.upgrade.cpp
@@ -1,10 +1,8 @@
#include "pch.h"
-#include <vcpkg/base/util.h>
#include <vcpkg/commands.h>
#include <vcpkg/dependencies.h>
#include <vcpkg/help.h>
-#include <vcpkg/input.h>
#include <vcpkg/install.h>
#include <vcpkg/statusparagraphs.h>
#include <vcpkg/update.h>
@@ -26,121 +24,37 @@ namespace vcpkg::Commands::Upgrade
const CommandStructure COMMAND_STRUCTURE = {
Help::create_example_string("upgrade --no-dry-run"),
0,
- SIZE_MAX,
+ 0,
{INSTALL_SWITCHES, {}},
nullptr,
};
- void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths, const Triplet& default_triplet)
+ void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths, const Triplet&)
{
+ // input sanitization
const ParsedArguments options = args.parse_arguments(COMMAND_STRUCTURE);
const bool no_dry_run = Util::Sets::contains(options.switches, OPTION_NO_DRY_RUN);
const KeepGoing keep_going = to_keep_going(Util::Sets::contains(options.switches, OPTION_KEEP_GOING));
+ // create the plan
StatusParagraphs status_db = database_load_check(paths);
Dependencies::PathsPortFileProvider provider(paths);
Dependencies::PackageGraph graph(provider, status_db);
- // input sanitization
- const std::vector<PackageSpec> specs = Util::fmap(args.command_arguments, [&](auto&& arg) {
- return Input::check_and_get_package_spec(arg, default_triplet, COMMAND_STRUCTURE.example_text);
- });
+ auto outdated_packages = Update::find_outdated_packages(provider, status_db);
+ for (auto&& outdated_package : outdated_packages)
+ graph.upgrade(outdated_package.spec);
- for (auto&& spec : specs)
- {
- Input::check_triplet(spec.triplet(), paths);
- }
-
- if (specs.empty())
- {
- // If no packages specified, upgrade all outdated packages.
- auto outdated_packages = Update::find_outdated_packages(provider, status_db);
-
- if (outdated_packages.empty())
- {
- System::println("All installed packages are up-to-date with the local portfiles.");
- Checks::exit_success(VCPKG_LINE_INFO);
- }
+ auto plan = graph.serialize();
- for (auto&& outdated_package : outdated_packages)
- graph.upgrade(outdated_package.spec);
- }
- else
+ if (plan.empty())
{
- std::vector<PackageSpec> not_installed;
- std::vector<PackageSpec> no_portfile;
- 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())
- {
- not_installed.push_back(spec);
- }
-
- auto maybe_scf = provider.get_control_file(spec.name());
- if (auto p_scf = maybe_scf.get())
- {
- if (it != status_db.end())
- {
- if (p_scf->core_paragraph->version != (*it)->package.version)
- {
- to_upgrade.push_back(spec);
- }
- else
- {
- up_to_date.push_back(spec);
- }
- }
- }
- else
- {
- no_portfile.push_back(spec);
- }
- }
-
- Util::sort(not_installed);
- Util::sort(no_portfile);
- Util::sort(up_to_date);
- Util::sort(to_upgrade);
-
- if (!up_to_date.empty())
- {
- System::println(System::Color::success, "The following packages are up-to-date:");
- System::println(Strings::join(
- "", up_to_date, [](const PackageSpec& spec) { return " " + spec.to_string() + "\n"; }));
- }
-
- if (!not_installed.empty())
- {
- System::println(System::Color::error, "The following packages are not installed:");
- System::println(Strings::join(
- "", not_installed, [](const PackageSpec& spec) { return " " + spec.to_string() + "\n"; }));
- }
-
- if (!no_portfile.empty())
- {
- System::println(System::Color::error, "The following packages do not have a valid portfile:");
- System::println(Strings::join(
- "", no_portfile, [](const PackageSpec& spec) { return " " + spec.to_string() + "\n"; }));
- }
-
- Checks::check_exit(VCPKG_LINE_INFO, not_installed.empty() && no_portfile.empty());
-
- if (to_upgrade.empty()) Checks::exit_success(VCPKG_LINE_INFO);
-
- for (auto&& spec : to_upgrade)
- graph.upgrade(spec);
+ System::println("All packages are up-to-date.");
+ Checks::exit_success(VCPKG_LINE_INFO);
}
- auto plan = graph.serialize();
-
- Checks::check_exit(VCPKG_LINE_INFO, !plan.empty());
-
Dependencies::print_plan(plan, true);
if (!no_dry_run)
diff --git a/toolsrc/src/vcpkg/base/checks.cpp b/toolsrc/src/vcpkg/base/checks.cpp
index 23f2cc630..ed28d6e2b 100644
--- a/toolsrc/src/vcpkg/base/checks.cpp
+++ b/toolsrc/src/vcpkg/base/checks.cpp
@@ -49,7 +49,8 @@ namespace vcpkg::Checks
#else
void register_console_ctrl_handler() {}
#endif
- void unreachable(const LineInfo& line_info)
+
+ [[noreturn]] void unreachable(const LineInfo& line_info)
{
System::println(System::Color::error, "Error: Unreachable code was reached");
System::println(System::Color::error, line_info.to_string()); // Always print line_info here
@@ -60,13 +61,13 @@ namespace vcpkg::Checks
#endif
}
- void exit_with_code(const LineInfo& line_info, const int exit_code)
+ [[noreturn]] void exit_with_code(const LineInfo& line_info, const int exit_code)
{
Debug::println(System::Color::error, line_info.to_string());
cleanup_and_exit(exit_code);
}
- void exit_with_message(const LineInfo& line_info, const CStringView error_message)
+ [[noreturn]] void exit_with_message(const LineInfo& line_info, const CStringView error_message)
{
System::println(System::Color::error, error_message);
exit_fail(line_info);
@@ -76,7 +77,7 @@ namespace vcpkg::Checks
{
if (!expression)
{
- exit_fail(line_info);
+ exit_with_message(line_info, "");
}
}