aboutsummaryrefslogtreecommitdiff
path: root/toolsrc/src/commands.upgrade.cpp
diff options
context:
space:
mode:
authorRobert Schumacher <roschuma@microsoft.com>2017-12-13 02:22:52 -0800
committerRobert Schumacher <roschuma@microsoft.com>2017-12-13 02:22:52 -0800
commit803347a0c545687f6e6b8b3594b52d11435491b3 (patch)
treeff348be8817468dbbe7f00ed07335b5e09652fea /toolsrc/src/commands.upgrade.cpp
parentbbb431c5a9f1548b6690067d05936053a86dc572 (diff)
downloadvcpkg-803347a0c545687f6e6b8b3594b52d11435491b3.tar.gz
vcpkg-803347a0c545687f6e6b8b3594b52d11435491b3.zip
[vcpkg-upgrade] Initial commit of upgrade command.
Diffstat (limited to 'toolsrc/src/commands.upgrade.cpp')
-rw-r--r--toolsrc/src/commands.upgrade.cpp79
1 files changed, 79 insertions, 0 deletions
diff --git a/toolsrc/src/commands.upgrade.cpp b/toolsrc/src/commands.upgrade.cpp
new file mode 100644
index 000000000..7a3210042
--- /dev/null
+++ b/toolsrc/src/commands.upgrade.cpp
@@ -0,0 +1,79 @@
+#include "pch.h"
+
+#include <vcpkg/commands.h>
+#include <vcpkg/dependencies.h>
+#include <vcpkg/help.h>
+#include <vcpkg/install.h>
+#include <vcpkg/statusparagraphs.h>
+#include <vcpkg/update.h>
+#include <vcpkg/vcpkglib.h>
+
+namespace vcpkg::Commands::Upgrade
+{
+ using Install::KeepGoing;
+ using Install::to_keep_going;
+
+ static const std::string OPTION_NO_DRY_RUN = "--no-dry-run";
+ static const std::string OPTION_KEEP_GOING = "--keep-going";
+
+ static const std::array<CommandSwitch, 2> INSTALL_SWITCHES = {{
+ {OPTION_NO_DRY_RUN, "Actually upgrade"},
+ {OPTION_KEEP_GOING, "Continue installing packages on failure"},
+ }};
+
+ const CommandStructure COMMAND_STRUCTURE = {
+ Help::create_example_string("upgrade --no-dry-run"),
+ 0,
+ 0,
+ {INSTALL_SWITCHES, {}},
+ nullptr,
+ };
+
+ 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);
+
+ auto outdated_packages = Update::find_outdated_packages(provider, status_db);
+ for (auto&& outdated_package : outdated_packages)
+ graph.upgrade(outdated_package.spec);
+
+ auto plan = graph.serialize();
+
+ if (plan.empty())
+ {
+ System::println("All packages are up-to-date.");
+ Checks::exit_success(VCPKG_LINE_INFO);
+ }
+
+ Dependencies::print_plan(plan, true);
+
+ if (!no_dry_run)
+ {
+ System::println(System::Color::warning,
+ "If you are sure you want to rebuild the above packages, run this command with the "
+ "--no-dry-run option.");
+ Checks::exit_fail(VCPKG_LINE_INFO);
+ }
+
+ const Install::InstallSummary summary = Install::perform(plan, keep_going, paths, status_db);
+
+ System::println("\nTotal elapsed time: %s\n", summary.total_elapsed_time);
+
+ if (keep_going == KeepGoing::YES)
+ {
+ summary.print();
+ }
+
+ Checks::exit_success(VCPKG_LINE_INFO);
+ }
+}