aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar David Leverton <levertond@googlemail.com> 2007-02-23 02:26:23 +0000
committerAvatar David Leverton <levertond@googlemail.com> 2007-02-23 02:26:23 +0000
commitfac0a89664ffa7fbd592393c7a07acf58c16381b (patch)
tree47a69ed4fa7e379d6c1836c9a724bd0917117ebd
parent902ab043b79baac156cf2f899d316ea4a5dfd89b (diff)
downloadpaludis-fac0a89664ffa7fbd592393c7a07acf58c16381b.tar.gz
paludis-fac0a89664ffa7fbd592393c7a07acf58c16381b.tar.xz
Add {merger_check,merger_install,unmerger_unlink}_{pre,post} hooks.
-rw-r--r--hooks/Makefile.am.m46
-rw-r--r--paludis/merger/merger.cc25
-rw-r--r--paludis/repositories/gentoo/vdb_unmerger.cc11
3 files changed, 42 insertions, 0 deletions
diff --git a/hooks/Makefile.am.m4 b/hooks/Makefile.am.m4
index f34b95c..306618f 100644
--- a/hooks/Makefile.am.m4
+++ b/hooks/Makefile.am.m4
@@ -139,18 +139,24 @@ userhook(`merger_unlink_sym_pre')
userhook(`merger_unlink_sym_post')
userhook(`merger_unlink_misc_pre')
userhook(`merger_unlink_misc_post')
+userhook(`merger_install_pre')
+userhook(`merger_install_post')
userhook(`merger_install_file_pre')
userhook(`merger_install_file_post')
userhook(`merger_install_sym_pre')
userhook(`merger_install_sym_post')
userhook(`merger_install_dir_pre')
userhook(`merger_install_dir_post')
+userhook(`merger_check_pre')
+userhook(`merger_check_post')
userhook(`merger_check_file_pre')
userhook(`merger_check_file_post')
userhook(`merger_check_sym_pre')
userhook(`merger_check_sym_post')
userhook(`merger_check_dir_pre')
userhook(`merger_check_dir_post')
+userhook(`unmerger_unlink_pre')
+userhook(`unmerger_unlink_post')
userhook(`unmerger_unlink_file_pre')
userhook(`unmerger_unlink_file_post')
userhook(`unmerger_unlink_dir_pre')
diff --git a/paludis/merger/merger.cc b/paludis/merger/merger.cc
index 8fcc8f7..79b451e 100644
--- a/paludis/merger/merger.cc
+++ b/paludis/merger/merger.cc
@@ -54,7 +54,20 @@ Merger::check()
Context context("When checking merge from '" + stringify(_options.image) + "' to '"
+ stringify(_options.root) + "':");
+ if (0 != _options.environment->perform_hook(extend_hook(
+ Hook("merger_check_pre")
+ ("INSTALL_SOURCE", stringify(_options.image))
+ ("INSTALL_DESTINATION", stringify(_options.root)))))
+ make_check_fail();
+
do_dir_recursive(true, _options.image, _options.root);
+
+ if (0 != _options.environment->perform_hook(extend_hook(
+ Hook("merger_check_post")
+ ("INSTALL_SOURCE", stringify(_options.image))
+ ("INSTALL_DESTINATION", stringify(_options.root)))))
+ make_check_fail();
+
return _result;
}
@@ -85,7 +98,19 @@ Merger::merge()
}
} old_umask(::umask(0000));
+ if (0 != _options.environment->perform_hook(extend_hook(
+ Hook("merger_install_pre")
+ ("INSTALL_SOURCE", stringify(_options.image))
+ ("INSTALL_DESTINATION", stringify(_options.root)))))
+ throw MergerError("Merge of '" + stringify(_options.image) + "' to '" + stringify(_options.root) + "' aborted by hook");
+
do_dir_recursive(false, _options.image, _options.root);
+
+ if (0 != _options.environment->perform_hook(extend_hook(
+ Hook("merger_install_post")
+ ("INSTALL_SOURCE", stringify(_options.image))
+ ("INSTALL_DESTINATION", stringify(_options.root)))))
+ throw MergerError("Merge of '" + stringify(_options.image) + "' to '" + stringify(_options.root) + "' aborted by hook");
}
MergerEntryType
diff --git a/paludis/repositories/gentoo/vdb_unmerger.cc b/paludis/repositories/gentoo/vdb_unmerger.cc
index 7179b90..ac8904e 100644
--- a/paludis/repositories/gentoo/vdb_unmerger.cc
+++ b/paludis/repositories/gentoo/vdb_unmerger.cc
@@ -21,6 +21,7 @@
using namespace paludis;
+#include <paludis/environment.hh>
#include <paludis/repositories/gentoo/vdb_unmerger-sr.cc>
#include <paludis/util/tokeniser.hh>
#include <paludis/util/log.hh>
@@ -79,8 +80,18 @@ VDBUnmerger::unmerge()
while (std::getline(c, line))
lines.push_back(line);
+ if (0 != _imp->options.environment->perform_hook(extend_hook(
+ Hook("unmerger_unlink_pre")
+ ("UNLINK_TARGET", stringify(_imp->options.root)))))
+ throw UnmergerError("Unmerge of '" + stringify(_imp->options.root) + "' aborted by hook");
+
unmerge_non_directories(lines.begin(), lines.end());
unmerge_directories(lines.rbegin(), lines.rend());
+
+ if (0 != _imp->options.environment->perform_hook(extend_hook(
+ Hook("unmerger_unlink_post")
+ ("UNLINK_TARGET", stringify(_imp->options.root)))))
+ throw UnmergerError("Unmerge of '" + stringify(_imp->options.root) + "' aborted by hook");
}
bool