aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-10-01 13:57:11 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-10-01 13:57:11 +0100
commitb855bceaa8a5a42bd38144974acce180cd72eb01 (patch)
tree591031a765d6613a4d78f7d953a73055475f750b
parent1bfe1ead773324524a9c2c037b81efbd9295a4fb (diff)
downloadpaludis-b855bceaa8a5a42bd38144974acce180cd72eb01.tar.gz
paludis-b855bceaa8a5a42bd38144974acce180cd72eb01.tar.xz
update world for cave resolve
-rw-r--r--src/clients/cave/cmd_execute_resolution.cc72
-rw-r--r--src/clients/cave/cmd_resolve.cc20
2 files changed, 87 insertions, 5 deletions
diff --git a/src/clients/cave/cmd_execute_resolution.cc b/src/clients/cave/cmd_execute_resolution.cc
index 3a9aafa..c395582 100644
--- a/src/clients/cave/cmd_execute_resolution.cc
+++ b/src/clients/cave/cmd_execute_resolution.cc
@@ -33,6 +33,7 @@
#include <paludis/util/iterator_funcs.hh>
#include <paludis/util/options.hh>
#include <paludis/util/simple_visitor_cast.hh>
+#include <paludis/util/make_named_values.hh>
#include <paludis/resolver/resolutions.hh>
#include <paludis/resolver/serialise.hh>
#include <paludis/resolver/reason.hh>
@@ -52,6 +53,7 @@
#include <paludis/hook.hh>
#include <paludis/environment.hh>
#include <paludis/action.hh>
+#include <paludis/package_dep_spec_properties.hh>
#include <set>
#include <iterator>
@@ -73,6 +75,7 @@ namespace
{
args::ArgsGroup g_general_options;
args::SwitchArg a_pretend;
+ args::SwitchArg a_set;
ResolveCommandLineExecutionOptions execution_options;
ResolveCommandLineProgramOptions program_options;
@@ -80,6 +83,7 @@ namespace
ExecuteResolutionCommandLine() :
g_general_options(main_options_section(), "General Options", "General options."),
a_pretend(&g_general_options, "pretend", '\0', "Only carry out the pretend action", false),
+ a_set(&g_general_options, "set", '\0', "Our target is a set rather than package specs", false),
execution_options(this),
program_options(this)
{
@@ -334,6 +338,74 @@ namespace
("TARGETS", join(cmdline.begin_parameters(), cmdline.end_parameters(), " "))
).max_exit_status())
throw ActionError("Aborted by hook");
+
+ if (! cmdline.execution_options.a_preserve_world.specified())
+ {
+ cout << endl << c::bold_green() << "Updating world" << c::normal() << endl << endl;
+
+ std::string command(cmdline.program_options.a_update_world_program.argument());
+ if (command.empty())
+ command = "$CAVE update-world";
+
+ bool any(false);
+ if (cmdline.a_set.specified())
+ {
+ command.append(" --set");
+ for (args::ArgsHandler::ParametersConstIterator a(cmdline.begin_parameters()),
+ a_end(cmdline.end_parameters()) ;
+ a != a_end ; ++a)
+ {
+ if (*a == "world" || *a == "system" || *a == "security"
+ || *a == "everything" || *a == "insecurity")
+ cout << "* Special set '" << *a << "' does not belong in world" << endl;
+ else
+ {
+ any = true;
+ cout << "* Adding '" << *a << "'" << endl;
+ command.append(" " + *a);
+ }
+ }
+ }
+ else
+ {
+ for (args::ArgsHandler::ParametersConstIterator a(cmdline.begin_parameters()),
+ a_end(cmdline.end_parameters()) ;
+ a != a_end ; ++a)
+ {
+ PackageDepSpec spec(parse_user_package_dep_spec(*a, env.get(), UserPackageDepSpecOptions()));
+ if (package_dep_spec_has_properties(spec, make_named_values<PackageDepSpecProperties>(
+ value_for<n::has_additional_requirements>(false),
+ value_for<n::has_category_name_part>(false),
+ value_for<n::has_from_repository>(false),
+ value_for<n::has_in_repository>(false),
+ value_for<n::has_installable_to_path>(false),
+ value_for<n::has_installable_to_repository>(false),
+ value_for<n::has_installed_at_path>(false),
+ value_for<n::has_package>(true),
+ value_for<n::has_package_name_part>(false),
+ value_for<n::has_slot_requirement>(false),
+ value_for<n::has_tag>(indeterminate),
+ value_for<n::has_version_requirements>(false)
+ )))
+ {
+ any = true;
+ cout << "* Adding '" << spec << "'" << endl;
+ command.append(" " + stringify(spec));
+ }
+ else
+ {
+ cout << "* Not adding '" << spec << "'" << endl;
+ }
+ }
+ }
+
+ if (any)
+ {
+ paludis::Command cmd(command);
+ if (0 != run_command(cmd))
+ throw ActionError("Updating world failed");
+ }
+ }
}
catch (...)
{
diff --git a/src/clients/cave/cmd_resolve.cc b/src/clients/cave/cmd_resolve.cc
index 5d397f4..4e09104 100644
--- a/src/clients/cave/cmd_resolve.cc
+++ b/src/clients/cave/cmd_resolve.cc
@@ -341,7 +341,8 @@ namespace
void add_resolver_targets(
const std::tr1::shared_ptr<Environment> & env,
const std::tr1::shared_ptr<Resolver> & resolver,
- const ResolveCommandLine & cmdline)
+ const ResolveCommandLine & cmdline,
+ bool & is_set)
{
Context context("When adding targets from commandline:");
@@ -371,6 +372,9 @@ namespace
seen_sets = true;
}
}
+
+ if (seen_sets)
+ is_set = true;
}
UseExisting use_existing_from_cmdline(const args::EnumArg & a, const bool is_set)
@@ -817,12 +821,14 @@ namespace
void perform_resolution(
const std::tr1::shared_ptr<Environment> &,
const ResolutionLists & resolution_lists,
- const ResolveCommandLine & cmdline) PALUDIS_ATTRIBUTE((noreturn));
+ const ResolveCommandLine & cmdline,
+ const bool is_set) PALUDIS_ATTRIBUTE((noreturn));
void perform_resolution(
const std::tr1::shared_ptr<Environment> &,
const ResolutionLists & resolution_lists,
- const ResolveCommandLine & cmdline)
+ const ResolveCommandLine & cmdline,
+ const bool is_set)
{
Context context("When performing chosen resolution:");
@@ -844,6 +850,9 @@ namespace
command = command + " " + (*o)->forwardable_string();
}
+ if (is_set)
+ command.append(" --set");
+
for (args::ArgsSection::GroupsConstIterator g(cmdline.program_options.begin()),
g_end(cmdline.program_options.end()) ;
g != g_end ; ++g)
@@ -1052,6 +1061,7 @@ ResolveCommand::run(
));
std::tr1::shared_ptr<Resolver> resolver(new Resolver(env.get(), resolver_functions));
+ bool is_set(false);
try
{
std::list<SuggestRestart> restarts;
@@ -1065,7 +1075,7 @@ ResolveCommand::run(
{
try
{
- add_resolver_targets(env, resolver, cmdline);
+ add_resolver_targets(env, resolver, cmdline, is_set);
resolver->resolve();
break;
}
@@ -1092,7 +1102,7 @@ ResolveCommand::run(
retcode |= 1;
if (0 == retcode)
- perform_resolution(env, *resolver->resolution_lists(), cmdline);
+ perform_resolution(env, *resolver->resolution_lists(), cmdline, is_set);
}
catch (...)
{