aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-09-17 20:50:07 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-09-17 20:50:07 +0100
commit56c39648f0389d0a11645ab9ff10e417e217457d (patch)
tree66a47cc2d929ae1c5ad77038e10b4b2586768c4a
parent1bc518fc1dcf013763de6cbf2cd243ca6eb057ce (diff)
downloadpaludis-56c39648f0389d0a11645ab9ff10e417e217457d.tar.gz
paludis-56c39648f0389d0a11645ab9ff10e417e217457d.tar.xz
more hooks
-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;