From 307b761df4197bf9cf1b69652808530e6219a868 Mon Sep 17 00:00:00 2001 From: Daniel Shaw Date: Tue, 25 Jul 2017 21:29:31 -0700 Subject: partial end to end feature packages hdf5 added vcpkg feature package support to other commands remove comments change qualifier bracket to parens added features to qualified dependencies --- toolsrc/src/commands_remove.cpp | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) (limited to 'toolsrc/src/commands_remove.cpp') diff --git a/toolsrc/src/commands_remove.cpp b/toolsrc/src/commands_remove.cpp index eabf2b9ae..e480f02dd 100644 --- a/toolsrc/src/commands_remove.cpp +++ b/toolsrc/src/commands_remove.cpp @@ -17,13 +17,19 @@ namespace vcpkg::Commands::Remove void remove_package(const VcpkgPaths& paths, const PackageSpec& spec, StatusParagraphs* status_db) { auto& fs = paths.get_filesystem(); - StatusParagraph& pkg = **status_db->find(spec.name(), spec.triplet()); + auto spghs = status_db->find_all(spec.name(), spec.triplet()); + auto core_pkg = **status_db->find(spec.name(), spec.triplet(), ""); - pkg.want = Want::PURGE; - pkg.state = InstallState::HALF_INSTALLED; - write_update(paths, pkg); + for (auto&& spgh : spghs) + { + StatusParagraph& pkg = **spgh; + if (pkg.state != InstallState::INSTALLED) continue; + pkg.want = Want::PURGE; + pkg.state = InstallState::HALF_INSTALLED; + write_update(paths, pkg); + } - auto maybe_lines = fs.read_lines(paths.listfile_path(pkg.package)); + auto maybe_lines = fs.read_lines(paths.listfile_path(core_pkg.package)); if (auto lines = maybe_lines.get()) { @@ -80,11 +86,16 @@ namespace vcpkg::Commands::Remove } } - fs.remove(paths.listfile_path(pkg.package)); + fs.remove(paths.listfile_path(core_pkg.package)); } - pkg.state = InstallState::NOT_INSTALLED; - write_update(paths, pkg); + for (auto&& spgh : spghs) + { + StatusParagraph& pkg = **spgh; + if (pkg.state != InstallState::HALF_INSTALLED) continue; + pkg.state = InstallState::NOT_INSTALLED; + write_update(paths, pkg); + } } static void print_plan(const std::map>& group_by_plan_type) -- cgit v1.2.3 From 3c34cca36adfce1d3388b30e643294be58b3ec8f Mon Sep 17 00:00:00 2001 From: Robert Schumacher Date: Wed, 23 Aug 2017 16:16:31 -0700 Subject: [vcpkg] Fix typo --- toolsrc/src/commands_remove.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'toolsrc/src/commands_remove.cpp') diff --git a/toolsrc/src/commands_remove.cpp b/toolsrc/src/commands_remove.cpp index e480f02dd..db5357514 100644 --- a/toolsrc/src/commands_remove.cpp +++ b/toolsrc/src/commands_remove.cpp @@ -151,7 +151,7 @@ namespace vcpkg::Commands::Remove if (specs.empty()) { - System::println(System::Color::success, "There are no oudated packages."); + System::println(System::Color::success, "There are no outdated packages."); Checks::exit_success(VCPKG_LINE_INFO); } } -- cgit v1.2.3 From 6684240090512f745bf7530b2fb4bcd31c3fb02e Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Mon, 28 Aug 2017 19:29:55 -0700 Subject: Use Strings::EMPTY --- toolsrc/src/commands_remove.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'toolsrc/src/commands_remove.cpp') diff --git a/toolsrc/src/commands_remove.cpp b/toolsrc/src/commands_remove.cpp index db5357514..cca541c85 100644 --- a/toolsrc/src/commands_remove.cpp +++ b/toolsrc/src/commands_remove.cpp @@ -18,7 +18,7 @@ namespace vcpkg::Commands::Remove { auto& fs = paths.get_filesystem(); auto spghs = status_db->find_all(spec.name(), spec.triplet()); - auto core_pkg = **status_db->find(spec.name(), spec.triplet(), ""); + auto core_pkg = **status_db->find(spec.name(), spec.triplet(), Strings::EMPTY); for (auto&& spgh : spghs) { -- cgit v1.2.3 From 81c9445376e677aa04d33b125917a61020cafda9 Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Thu, 31 Aug 2017 18:05:58 -0700 Subject: example -> EXAMPLE --- toolsrc/src/commands_remove.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'toolsrc/src/commands_remove.cpp') diff --git a/toolsrc/src/commands_remove.cpp b/toolsrc/src/commands_remove.cpp index cca541c85..2b5033166 100644 --- a/toolsrc/src/commands_remove.cpp +++ b/toolsrc/src/commands_remove.cpp @@ -136,7 +136,7 @@ namespace vcpkg::Commands::Remove static const std::string OPTION_RECURSE = "--recurse"; static const std::string OPTION_DRY_RUN = "--dry-run"; static const std::string OPTION_OUTDATED = "--outdated"; - static const std::string example = + static const std::string EXAMPLE = Commands::Help::create_example_string("remove zlib zlib:x64-windows curl boost"); const std::unordered_set options = args.check_and_get_optional_command_arguments( {OPTION_PURGE, OPTION_NO_PURGE, OPTION_RECURSE, OPTION_DRY_RUN, OPTION_OUTDATED}); @@ -145,7 +145,7 @@ namespace vcpkg::Commands::Remove std::vector specs; if (options.find(OPTION_OUTDATED) != options.cend()) { - args.check_exact_arg_count(0, example); + args.check_exact_arg_count(0, EXAMPLE); specs = Util::fmap(Update::find_outdated_packages(paths, status_db), [](auto&& outdated) { return outdated.spec; }); @@ -157,9 +157,9 @@ namespace vcpkg::Commands::Remove } else { - args.check_min_arg_count(1, example); + args.check_min_arg_count(1, EXAMPLE); specs = Util::fmap(args.command_arguments, [&](auto&& arg) { - return Input::check_and_get_package_spec(arg, default_triplet, example); + return Input::check_and_get_package_spec(arg, default_triplet, EXAMPLE); }); for (auto&& spec : specs) @@ -171,7 +171,7 @@ namespace vcpkg::Commands::Remove { // User specified --purge and --no-purge System::println(System::Color::error, "Error: cannot specify both --no-purge and --purge."); - System::print(example); + System::print(EXAMPLE); Checks::exit_fail(VCPKG_LINE_INFO); } const bool isRecursive = options.find(OPTION_RECURSE) != options.cend(); -- cgit v1.2.3 From 43dde3f4892be55558b012b845d864e7be95c7b9 Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Wed, 13 Sep 2017 16:10:25 -0700 Subject: Refactor package removal code to eliminate its duplication --- toolsrc/src/commands_remove.cpp | 63 +++++++++++++++++++++++------------------ 1 file changed, 36 insertions(+), 27 deletions(-) (limited to 'toolsrc/src/commands_remove.cpp') diff --git a/toolsrc/src/commands_remove.cpp b/toolsrc/src/commands_remove.cpp index 2b5033166..453e0ec96 100644 --- a/toolsrc/src/commands_remove.cpp +++ b/toolsrc/src/commands_remove.cpp @@ -129,6 +129,37 @@ namespace vcpkg::Commands::Remove } } + void perform_remove_plan_action(const VcpkgPaths& paths, + const RemovePlanAction& action, + const Purge purge, + StatusParagraphs& status_db) + { + const std::string display_name = action.spec.to_string(); + + switch (action.plan_type) + { + case RemovePlanType::NOT_INSTALLED: + System::println(System::Color::success, "Package %s is not installed", display_name); + break; + case RemovePlanType::REMOVE: + System::println("Removing package %s... ", display_name); + remove_package(paths, action.spec, &status_db); + System::println(System::Color::success, "Removing package %s... done", display_name); + break; + case RemovePlanType::UNKNOWN: + default: Checks::unreachable(VCPKG_LINE_INFO); + } + + if (purge == Purge::YES) + { + System::println("Purging package %s... ", display_name); + Files::Filesystem& fs = paths.get_filesystem(); + std::error_code ec; + fs.remove_all(paths.packages / action.spec.dir(), ec); + System::println(System::Color::success, "Purging package %s... done", display_name); + } + } + void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths, const Triplet& default_triplet) { static const std::string OPTION_PURGE = "--purge"; @@ -166,14 +197,15 @@ namespace vcpkg::Commands::Remove Input::check_triplet(spec.triplet(), paths); } - const bool alsoRemoveFolderFromPackages = options.find(OPTION_NO_PURGE) == options.end(); - if (options.find(OPTION_PURGE) != options.end() && !alsoRemoveFolderFromPackages) + const bool no_purge_was_passed = options.find(OPTION_NO_PURGE) != options.end(); + const bool purge_was_passed = options.find(OPTION_PURGE) != options.end(); + if (purge_was_passed && no_purge_was_passed) { - // User specified --purge and --no-purge System::println(System::Color::error, "Error: cannot specify both --no-purge and --purge."); System::print(EXAMPLE); Checks::exit_fail(VCPKG_LINE_INFO); } + const Purge purge = to_purge(purge_was_passed || !no_purge_was_passed); const bool isRecursive = options.find(OPTION_RECURSE) != options.cend(); const bool dryRun = options.find(OPTION_DRY_RUN) != options.cend(); @@ -209,30 +241,7 @@ namespace vcpkg::Commands::Remove for (const RemovePlanAction& action : remove_plan) { - const std::string display_name = action.spec.to_string(); - - switch (action.plan_type) - { - case RemovePlanType::NOT_INSTALLED: - System::println(System::Color::success, "Package %s is not installed", display_name); - break; - case RemovePlanType::REMOVE: - System::println("Removing package %s... ", display_name); - remove_package(paths, action.spec, &status_db); - System::println(System::Color::success, "Removing package %s... done", display_name); - break; - case RemovePlanType::UNKNOWN: - default: Checks::unreachable(VCPKG_LINE_INFO); - } - - if (alsoRemoveFolderFromPackages) - { - System::println("Purging package %s... ", display_name); - Files::Filesystem& fs = paths.get_filesystem(); - std::error_code ec; - fs.remove_all(paths.packages / action.spec.dir(), ec); - System::println(System::Color::success, "Purging package %s... done", display_name); - } + perform_remove_plan_action(paths, action, purge, status_db); } Checks::exit_success(VCPKG_LINE_INFO); -- cgit v1.2.3 From d080439ce408c4fd0312f0925f10543179e79b27 Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Wed, 13 Sep 2017 21:46:48 -0700 Subject: [commands_remove.cpp] Naming scheme and missing const --- toolsrc/src/commands_remove.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'toolsrc/src/commands_remove.cpp') diff --git a/toolsrc/src/commands_remove.cpp b/toolsrc/src/commands_remove.cpp index 453e0ec96..a9f1b2564 100644 --- a/toolsrc/src/commands_remove.cpp +++ b/toolsrc/src/commands_remove.cpp @@ -18,7 +18,7 @@ namespace vcpkg::Commands::Remove { auto& fs = paths.get_filesystem(); auto spghs = status_db->find_all(spec.name(), spec.triplet()); - auto core_pkg = **status_db->find(spec.name(), spec.triplet(), Strings::EMPTY); + const auto core_pkg = **status_db->find(spec.name(), spec.triplet(), Strings::EMPTY); for (auto&& spgh : spghs) { @@ -31,7 +31,7 @@ namespace vcpkg::Commands::Remove auto maybe_lines = fs.read_lines(paths.listfile_path(core_pkg.package)); - if (auto lines = maybe_lines.get()) + if (const auto lines = maybe_lines.get()) { std::vector dirs_touched; for (auto&& suffix : *lines) @@ -42,7 +42,7 @@ namespace vcpkg::Commands::Remove auto target = paths.installed / suffix; - auto status = fs.status(target, ec); + const auto status = fs.status(target, ec); if (ec) { System::println(System::Color::error, "failed: %s", ec.message()); @@ -72,7 +72,7 @@ namespace vcpkg::Commands::Remove } auto b = dirs_touched.rbegin(); - auto e = dirs_touched.rend(); + const auto e = dirs_touched.rend(); for (; b != e; ++b) { if (fs.is_empty(*b)) @@ -100,11 +100,11 @@ namespace vcpkg::Commands::Remove static void print_plan(const std::map>& group_by_plan_type) { - static constexpr std::array order = {RemovePlanType::NOT_INSTALLED, RemovePlanType::REMOVE}; + static constexpr std::array ORDER = {RemovePlanType::NOT_INSTALLED, RemovePlanType::REMOVE}; - for (const RemovePlanType plan_type : order) + for (const RemovePlanType plan_type : ORDER) { - auto it = group_by_plan_type.find(plan_type); + const auto it = group_by_plan_type.find(plan_type); if (it == group_by_plan_type.cend()) { continue; @@ -206,8 +206,8 @@ namespace vcpkg::Commands::Remove Checks::exit_fail(VCPKG_LINE_INFO); } const Purge purge = to_purge(purge_was_passed || !no_purge_was_passed); - const bool isRecursive = options.find(OPTION_RECURSE) != options.cend(); - const bool dryRun = options.find(OPTION_DRY_RUN) != options.cend(); + const bool is_recursive = options.find(OPTION_RECURSE) != options.cend(); + const bool dry_run = options.find(OPTION_DRY_RUN) != options.cend(); const std::vector remove_plan = Dependencies::create_remove_plan(specs, status_db); Checks::check_exit(VCPKG_LINE_INFO, !remove_plan.empty(), "Remove plan cannot be empty"); @@ -226,7 +226,7 @@ namespace vcpkg::Commands::Remove System::println(System::Color::warning, "Additional packages (*) need to be removed to complete this operation."); - if (!isRecursive) + if (!is_recursive) { System::println(System::Color::warning, "If you are sure you want to remove them, run the command with the --recurse option"); @@ -234,7 +234,7 @@ namespace vcpkg::Commands::Remove } } - if (dryRun) + if (dry_run) { Checks::exit_success(VCPKG_LINE_INFO); } -- cgit v1.2.3