aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-09-05 01:20:25 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-09-05 01:20:25 +0100
commit736ac3c1adfdbea0aa44d9bbfe15935b4105830e (patch)
tree9dd42f846301c36ff1c7caa1e052e932a6542d67
parent13fe1be9bb1abd6b9a77919172bd04fd9d2d2424 (diff)
downloadpaludis-736ac3c1adfdbea0aa44d9bbfe15935b4105830e.tar.gz
paludis-736ac3c1adfdbea0aa44d9bbfe15935b4105830e.tar.xz
very crude execution support
-rw-r--r--src/clients/cave/cmd_execute_resolution.cc135
-rw-r--r--src/clients/cave/cmd_resolve_cmdline.cc55
-rw-r--r--src/clients/cave/cmd_resolve_cmdline.hh20
3 files changed, 167 insertions, 43 deletions
diff --git a/src/clients/cave/cmd_execute_resolution.cc b/src/clients/cave/cmd_execute_resolution.cc
index 08e844b..2d13f39 100644
--- a/src/clients/cave/cmd_execute_resolution.cc
+++ b/src/clients/cave/cmd_execute_resolution.cc
@@ -94,12 +94,137 @@ namespace
}
};
- void execute_resolution(
+ int do_pretend(
const std::tr1::shared_ptr<Environment> &,
- const ResolutionLists &,
- const ExecuteResolutionCommandLine &)
+ const ExecuteResolutionCommandLine & cmdline,
+ const std::tr1::shared_ptr<const Decision> & c)
+ {
+ const std::tr1::shared_ptr<const PackageID> id(c->if_package_id());
+ Context context("When pretending for '" + stringify(*id) + "':");
+
+ std::string command(cmdline.program_options.a_perform_program.argument());
+ if (command.empty())
+ command = "$CAVE perform";
+
+ command.append(" pretend --hooks ");
+ command.append(stringify(id->uniquely_identifying_spec()));
+
+ paludis::Command cmd(command);
+ return run_command(cmd);
+ }
+
+ void starting_action(
+ const std::string & action,
+ const std::tr1::shared_ptr<const Decision> & c)
+ {
+ cout << endl;
+ cout << c::bold_blue() << "Starting " << action << " for "
+ << *c->if_package_id() << "..." << c::normal() << endl;
+ cout << endl;
+ }
+
+ void done_action(
+ const std::string & action,
+ const std::tr1::shared_ptr<const Decision> & c,
+ const bool success)
+ {
+ cout << endl;
+ if (success)
+ cout << c::bold_green() << "Done " << action << " for "
+ << *c->if_package_id() << c::normal() << endl;
+ else
+ cout << c::bold_red() << "Failed " << action << " for "
+ << *c->if_package_id() << c::normal() << endl;
+ cout << endl;
+ }
+
+ int do_fetch(
+ const std::tr1::shared_ptr<Environment> &,
+ const ExecuteResolutionCommandLine & cmdline,
+ const std::tr1::shared_ptr<const Decision> & c)
+ {
+ const std::tr1::shared_ptr<const PackageID> id(c->if_package_id());
+ Context context("When fetching for '" + stringify(*id) + "':");
+
+ starting_action("fetch", c);
+
+ std::string command(cmdline.program_options.a_perform_program.argument());
+ if (command.empty())
+ command = "$CAVE perform";
+
+ command.append(" fetch --hooks ");
+ command.append(stringify(id->uniquely_identifying_spec()));
+
+ paludis::Command cmd(command);
+ int retcode(run_command(cmd));
+
+ done_action("fetch", c, 0 == retcode);
+ return retcode;
+ }
+
+ int do_install_slash(
+ const std::tr1::shared_ptr<Environment> &,
+ const ExecuteResolutionCommandLine & cmdline,
+ const std::tr1::shared_ptr<const Resolution> & r)
+ {
+ const std::tr1::shared_ptr<const PackageID> id(r->decision()->if_package_id());
+ Context context("When installing to / for '" + stringify(*id) + "':");
+
+ starting_action("install to /", r->decision());
+
+ std::string command(cmdline.program_options.a_perform_program.argument());
+ if (command.empty())
+ command = "$CAVE perform";
+
+ command.append(" install --hooks ");
+ command.append(stringify(id->uniquely_identifying_spec()));
+ command.append(" --destination " + stringify(r->destinations()->slash()->repository()));
+ for (PackageIDSequence::ConstIterator i(r->destinations()->slash()->replacing()->begin()),
+ i_end(r->destinations()->slash()->replacing()->end()) ;
+ i != i_end ; ++i)
+ command.append(" --replacing " + stringify((*i)->uniquely_identifying_spec()));
+
+ paludis::Command cmd(command);
+ int retcode(run_command(cmd));
+
+ done_action("install to /", r->decision(), 0 == retcode);
+ return retcode;
+ }
+
+ int execute_resolution(
+ const std::tr1::shared_ptr<Environment> & env,
+ const ResolutionLists & lists,
+ const ExecuteResolutionCommandLine & cmdline)
{
Context context("When executing chosen resolution:");
+
+ int retcode(0);
+
+ for (Resolutions::ConstIterator c(lists.ordered()->begin()), c_end(lists.ordered()->end()) ;
+ c != c_end ; ++c)
+ retcode |= do_pretend(env, cmdline, (*c)->decision());
+
+ if (0 != retcode)
+ return retcode;
+
+ for (Resolutions::ConstIterator c(lists.ordered()->begin()), c_end(lists.ordered()->end()) ;
+ c != c_end ; ++c)
+ {
+ retcode = do_fetch(env, cmdline, (*c)->decision());
+ if (0 != retcode)
+ return retcode;
+
+ if ((*c)->destinations()->slash())
+ {
+ retcode = do_install_slash(env, cmdline, *c);
+ if (0 != retcode)
+ return retcode;
+ }
+ else
+ throw InternalError(PALUDIS_HERE, "destination != / not done yet");
+ }
+
+ return retcode;
}
}
@@ -134,9 +259,7 @@ ExecuteResolutionCommand::run(
Deserialisation deserialisation("ResolutionLists", deserialiser);
ResolutionLists lists(ResolutionLists::deserialise(deserialisation));
- execute_resolution(env, lists, cmdline);
-
- return 0;
+ return execute_resolution(env, lists, cmdline);
}
std::tr1::shared_ptr<args::ArgsHandler>
diff --git a/src/clients/cave/cmd_resolve_cmdline.cc b/src/clients/cave/cmd_resolve_cmdline.cc
index ce51f16..d35d446 100644
--- a/src/clients/cave/cmd_resolve_cmdline.cc
+++ b/src/clients/cave/cmd_resolve_cmdline.cc
@@ -47,17 +47,6 @@ ResolveCommandLineResolutionOptions::ResolveCommandLineResolutionOptions(args::A
// a_purge_unused_packages(&g_cleanup_options, "purge-unused-packages", '\0',
// "Purge packages that are no longer used after an uninstall or clean", true),
//
-// g_failure_options(this, "Failure Options", "Failure handling options."),
-// a_continue_on_failure(&g_failure_options, "continue-on-failure", '\0',
-// "Whether to continue after an error occurs",
-// args::EnumArg::EnumArgOptions
-// ("if-fetching", "Only if we are just fetching packages")
-// ("never", "Never")
-// ("if-satisfied", "If remaining packages' dependencies are satisfied")
-// ("if-independent", "If remaining packages do not depend upon any failing package")
-// ("always", "Always (dangerous)"),
-// "if-fetching"),
-//
// g_display_options(this, "Display Options", "Options relating to the resolution display."),
// a_show_option_descriptions(&g_display_options, "show-option-descriptions", '\0',
// "Whether to display descriptions for package options",
@@ -77,20 +66,6 @@ ResolveCommandLineResolutionOptions::ResolveCommandLineResolutionOptions(args::A
// "new"
// ),
-// g_phase_options(this, "Phase Options", "Options controlling which phases to execute. No sanity checking "
-// "is done, allowing you to shoot as many feet off as you desire. Phase names do not have the "
-// "src_, pkg_ or builtin_ prefix, so 'init', 'preinst', 'unpack', 'merge', 'strip' etc."),
-// a_skip_phase(&g_phase_options, "skip-phase", '\0', "Skip the named phases"),
-// a_abort_at_phase(&g_phase_options, "abort-at-phase", '\0', "Abort when a named phase is encounted"),
-// a_skip_until_phase(&g_phase_options, "skip-until-phase", '\0', "Skip every phase until a named phase is encounted"),
-// a_change_phases_for(&g_phase_options, "change-phases-for", '\0',
-// "Control to which package or packages these phase options apply",
-// args::EnumArg::EnumArgOptions
-// ("all", "All packages")
-// ("first", "Only the first package on the list")
-// ("last", "Only the last package on the list"),
-// "all"),
-//
g_keep_options(this, "Reinstall Options", "Control whether installed packages are kept."),
a_keep_targets(&g_keep_options, "keep-targets", 'K',
"Select whether to keep target packages",
@@ -231,7 +206,35 @@ ResolveCommandLineDisplayOptions::ResolveCommandLineDisplayOptions(args::ArgsHan
}
ResolveCommandLineExecutionOptions::ResolveCommandLineExecutionOptions(args::ArgsHandler * const h) :
- ArgsSection(h, "Execution Options")
+ ArgsSection(h, "Execution Options"),
+
+ g_world_options(this, "World Options", "Options controlling how the 'world' set is modified"),
+ a_preserve_world(&g_world_options, "preserve-world", '1', "Do not modify the 'world' set", true),
+
+ g_failure_options(this, "Failure Options", "Failure handling options."),
+ a_continue_on_failure(&g_failure_options, "continue-on-failure", '\0',
+ "Whether to continue after an error occurs",
+ args::EnumArg::EnumArgOptions
+ ("if-fetching", "Only if we are just fetching packages")
+ ("never", "Never")
+ ("if-satisfied", "If remaining packages' dependencies are satisfied")
+ ("if-independent", "If remaining packages do not depend upon any failing package")
+ ("always", "Always (dangerous)"),
+ "if-fetching"),
+
+ g_phase_options(this, "Phase Options", "Options controlling which phases to execute. No sanity checking "
+ "is done, allowing you to shoot as many feet off as you desire. Phase names do not have the "
+ "src_, pkg_ or builtin_ prefix, so 'init', 'preinst', 'unpack', 'merge', 'strip' etc."),
+ a_skip_phase(&g_phase_options, "skip-phase", '\0', "Skip the named phases"),
+ a_abort_at_phase(&g_phase_options, "abort-at-phase", '\0', "Abort when a named phase is encounted"),
+ a_skip_until_phase(&g_phase_options, "skip-until-phase", '\0', "Skip every phase until a named phase is encounted"),
+ a_change_phases_for(&g_phase_options, "change-phases-for", '\0',
+ "Control to which package or packages these phase options apply",
+ args::EnumArg::EnumArgOptions
+ ("all", "All packages")
+ ("first", "Only the first package on the list")
+ ("last", "Only the last package on the list"),
+ "all")
{
}
diff --git a/src/clients/cave/cmd_resolve_cmdline.hh b/src/clients/cave/cmd_resolve_cmdline.hh
index 70897cc..f1147ee 100644
--- a/src/clients/cave/cmd_resolve_cmdline.hh
+++ b/src/clients/cave/cmd_resolve_cmdline.hh
@@ -105,19 +105,17 @@ namespace paludis
{
ResolveCommandLineExecutionOptions(args::ArgsHandler * const);
- // args::ArgsGroup g_world_options;
- // args::SwitchArg a_preserve_world;
-
- // args::ArgsGroup g_failure_options;
- // args::EnumArg a_continue_on_failure;
-
- // args::ArgsGroup g_phase_options;
- // args::StringSetArg a_skip_phase;
- // args::StringSetArg a_abort_at_phase;
- // args::StringSetArg a_skip_until_phase;
- // args::EnumArg a_change_phases_for;
+ args::ArgsGroup g_world_options;
+ args::SwitchArg a_preserve_world;
+ args::ArgsGroup g_failure_options;
+ args::EnumArg a_continue_on_failure;
+ args::ArgsGroup g_phase_options;
+ args::StringSetArg a_skip_phase;
+ args::StringSetArg a_abort_at_phase;
+ args::StringSetArg a_skip_until_phase;
+ args::EnumArg a_change_phases_for;
};
struct ResolveCommandLineDisplayOptions :