aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/clients/cave/cmd_execute_resolution.cc87
1 files changed, 56 insertions, 31 deletions
diff --git a/src/clients/cave/cmd_execute_resolution.cc b/src/clients/cave/cmd_execute_resolution.cc
index 15b7fb1..38d4d6f 100644
--- a/src/clients/cave/cmd_execute_resolution.cc
+++ b/src/clients/cave/cmd_execute_resolution.cc
@@ -220,56 +220,81 @@ namespace
int retcode(0), x(0), y(std::distance(lists.ordered()->begin(), lists.ordered()->end()));
- if (0 != env->perform_hook(Hook("pretend_all_pre")
+ if (0 != env->perform_hook(Hook("install_task_execute_pre")
("TARGETS", join(cmdline.begin_parameters(), cmdline.end_parameters(), " "))
).max_exit_status())
throw ActionError("Aborted by hook");
- std::cout << "Executing pretend actions: " << std::flush;
-
- for (Resolutions::ConstIterator c(lists.ordered()->begin()), c_end(lists.ordered()->end()) ;
- c != c_end ; ++c)
- retcode |= do_pretend(env, cmdline, (*c)->decision(), ++x, y);
+ try
+ {
+ if (0 != env->perform_hook(Hook("pretend_all_pre")
+ ("TARGETS", join(cmdline.begin_parameters(), cmdline.end_parameters(), " "))
+ ).max_exit_status())
+ throw ActionError("Aborted by hook");
- std::cout << std::endl;
+ std::cout << "Executing pretend actions: " << std::flush;
- if (0 != env->perform_hook(Hook("pretend_all_post")
- ("TARGETS", join(cmdline.begin_parameters(), cmdline.end_parameters(), " "))
- ).max_exit_status())
- throw ActionError("Aborted by hook");
+ for (Resolutions::ConstIterator c(lists.ordered()->begin()), c_end(lists.ordered()->end()) ;
+ c != c_end ; ++c)
+ retcode |= do_pretend(env, cmdline, (*c)->decision(), ++x, y);
- if (0 != retcode || cmdline.a_pretend.specified())
- return retcode;
+ std::cout << std::endl;
- x = 0;
+ if (0 != env->perform_hook(Hook("pretend_all_post")
+ ("TARGETS", join(cmdline.begin_parameters(), cmdline.end_parameters(), " "))
+ ).max_exit_status())
+ throw ActionError("Aborted by hook");
- if (0 != env->perform_hook(Hook("install_all_pre")
- ("TARGETS", join(cmdline.begin_parameters(), cmdline.end_parameters(), " "))
- ).max_exit_status())
- throw ActionError("Aborted by hook");
+ if (0 != retcode || cmdline.a_pretend.specified())
+ return retcode;
- for (Resolutions::ConstIterator c(lists.ordered()->begin()), c_end(lists.ordered()->end()) ;
- c != c_end ; ++c)
- {
- ++x;
+ x = 0;
- retcode = do_fetch(env, cmdline, (*c)->decision(), x, y);
- if (0 != retcode)
- return retcode;
+ if (0 != env->perform_hook(Hook("install_all_pre")
+ ("TARGETS", join(cmdline.begin_parameters(), cmdline.end_parameters(), " "))
+ ).max_exit_status())
+ throw ActionError("Aborted by hook");
- if ((*c)->destinations()->slash())
+ for (Resolutions::ConstIterator c(lists.ordered()->begin()), c_end(lists.ordered()->end()) ;
+ c != c_end ; ++c)
{
- retcode = do_install_slash(env, cmdline, *c, x, y);
+ ++x;
+
+ retcode = do_fetch(env, cmdline, (*c)->decision(), x, y);
if (0 != retcode)
return retcode;
+
+ if ((*c)->destinations()->slash())
+ {
+ retcode = do_install_slash(env, cmdline, *c, x, y);
+ if (0 != retcode)
+ return retcode;
+ }
+ else
+ throw InternalError(PALUDIS_HERE, "destination != / not done yet");
}
- else
- throw InternalError(PALUDIS_HERE, "destination != / not done yet");
+
+ if (0 != env->perform_hook(Hook("install_all_post")
+ ("TARGETS", join(cmdline.begin_parameters(), cmdline.end_parameters(), " "))
+ ).max_exit_status())
+ throw ActionError("Aborted by hook");
+ }
+ catch (...)
+ {
+ if (0 != env->perform_hook(Hook("install_task_execute_post")
+ ("TARGETS", join(cmdline.begin_parameters(), cmdline.end_parameters(), " "))
+ ("PRETEND", stringify(cmdline.a_pretend.specified()))
+ ("SUCCESS", stringify(false))
+ ).max_exit_status())
+ throw ActionError("Aborted by hook");
+ throw;
}
- if (0 != env->perform_hook(Hook("install_all_post")
+ if (0 != env->perform_hook(Hook("install_task_execute_post")
("TARGETS", join(cmdline.begin_parameters(), cmdline.end_parameters(), " "))
- ).max_exit_status())
+ ("PRETEND", stringify(cmdline.a_pretend.specified()))
+ ("SUCCESS", stringify(true))
+ ).max_exit_status())
throw ActionError("Aborted by hook");
return retcode;