aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Kim Højgaard-Hansen <kimrhh@exherbo.org> 2010-01-10 23:27:09 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-01-12 16:06:05 +0000
commit6b69bf18f2c0ffe88cdfaf8de0ad5db7735d8e52 (patch)
tree9395124e3b92f2ad4d60566361674e8a7b99b810
parentc1a3eba3407529b26f0a1a81c5f6e0170430b158 (diff)
downloadpaludis-6b69bf18f2c0ffe88cdfaf8de0ad5db7735d8e52.tar.gz
paludis-6b69bf18f2c0ffe88cdfaf8de0ad5db7735d8e52.tar.xz
also run install_task_execute_post hook upon failure
-rw-r--r--src/clients/cave/cmd_execute_resolution.cc177
1 files changed, 94 insertions, 83 deletions
diff --git a/src/clients/cave/cmd_execute_resolution.cc b/src/clients/cave/cmd_execute_resolution.cc
index bfa9bf0..e25c3f6 100644
--- a/src/clients/cave/cmd_execute_resolution.cc
+++ b/src/clients/cave/cmd_execute_resolution.cc
@@ -518,112 +518,123 @@ namespace
}
};
- int execute_resolution(
+ int execute_resolution_main(
const std::tr1::shared_ptr<Environment> & env,
const ResolverLists & lists,
const ExecuteResolutionCommandLine & cmdline)
{
- Context context("When executing chosen resolution:");
-
int retcode(0);
- if (0 != env->perform_hook(Hook("install_task_execute_pre")
- ("TARGETS", join(cmdline.begin_parameters(), cmdline.end_parameters(), " "))
- ).max_exit_status())
- throw ActionAbortedError("Aborted by hook");
+ JobCounts counts;
+ CompletedOutputManagers completed_output_managers;
- try
- {
- JobCounts counts;
- CompletedOutputManagers completed_output_managers;
-
- for (JobIDSequence::ConstIterator c(lists.ordered_job_ids()->begin()),
- c_end(lists.ordered_job_ids()->end()) ;
- c != c_end ; ++c)
- lists.jobs()->fetch(*c)->accept(counts);
-
- PerformJobs perform_jobs(env, cmdline, counts, completed_output_managers);
- for (JobIDSequence::ConstIterator c(lists.ordered_job_ids()->begin()),
- c_end(lists.ordered_job_ids()->end()) ;
- c != c_end ; ++c)
- if (! lists.jobs()->fetch(*c)->accept_returning<bool>(perform_jobs))
- break;
+ for (JobIDSequence::ConstIterator c(lists.ordered_job_ids()->begin()),
+ c_end(lists.ordered_job_ids()->end()) ;
+ c != c_end ; ++c)
+ lists.jobs()->fetch(*c)->accept(counts);
+
+ PerformJobs perform_jobs(env, cmdline, counts, completed_output_managers);
+ for (JobIDSequence::ConstIterator c(lists.ordered_job_ids()->begin()),
+ c_end(lists.ordered_job_ids()->end()) ;
+ c != c_end ; ++c)
+ if (! lists.jobs()->fetch(*c)->accept_returning<bool>(perform_jobs))
+ break;
- completed_output_managers.clear();
+ completed_output_managers.clear();
- retcode |= perform_jobs.retcode;
- if ((0 != retcode) || (cmdline.a_pretend.specified()))
- return retcode;
+ retcode |= perform_jobs.retcode;
+ if ((0 != retcode) || (cmdline.a_pretend.specified()))
+ return retcode;
- if (! cmdline.execution_options.a_preserve_world.specified())
- {
- cout << endl << c::bold_green() << "Updating world" << c::normal() << endl << endl;
+ 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";
+ 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())
+ 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)
{
- 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"
+ || *a == "installed-packages" || *a == "installed-slots")
+ cout << "* Special set '" << *a << "' does not belong in world" << endl;
+ else
{
- if (*a == "world" || *a == "system" || *a == "security"
- || *a == "everything" || *a == "insecurity"
- || *a == "installed-packages" || *a == "installed-slots")
- cout << "* Special set '" << *a << "' does not belong in world" << endl;
- else
- {
- any = true;
- cout << "* Adding '" << *a << "'" << endl;
- command.append(" " + *a);
- }
+ any = true;
+ cout << "* Adding '" << *a << "'" << endl;
+ command.append(" " + *a);
}
}
- else
+ }
+ else
+ {
+ for (args::ArgsHandler::ParametersConstIterator a(cmdline.begin_parameters()),
+ a_end(cmdline.end_parameters()) ;
+ a != a_end ; ++a)
{
- 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
{
- 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;
- }
+ cout << "* Not adding '" << spec << "'" << endl;
}
}
+ }
- if (any)
- {
- paludis::Command cmd(command);
- if (0 != run_command(cmd))
- throw ActionAbortedError("Updating world failed");
- }
+ if (any)
+ {
+ paludis::Command cmd(command);
+ if (0 != run_command(cmd))
+ throw ActionAbortedError("Updating world failed");
}
}
+ return retcode;
+ }
+
+ int execute_resolution(
+ const std::tr1::shared_ptr<Environment> & env,
+ const ResolverLists & lists,
+ const ExecuteResolutionCommandLine & cmdline)
+ {
+ Context context("When executing chosen resolution:");
+
+ int retcode(0);
+
+ if (0 != env->perform_hook(Hook("install_task_execute_pre")
+ ("TARGETS", join(cmdline.begin_parameters(), cmdline.end_parameters(), " "))
+ ).max_exit_status())
+ throw ActionAbortedError("Aborted by hook");
+
+ try
+ {
+ retcode = execute_resolution_main(env, lists, cmdline);
+ }
catch (...)
{
if (0 != env->perform_hook(Hook("install_task_execute_post")