aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar David Leverton <levertond@googlemail.com> 2007-02-23 01:49:30 +0000
committerAvatar David Leverton <levertond@googlemail.com> 2007-02-23 01:49:30 +0000
commit902ab043b79baac156cf2f899d316ea4a5dfd89b (patch)
tree7af430edcdebb1eb9ae09d09a49289adea2fb37e
parent356e6d71e679a40a36e7501315cded23f0558af7 (diff)
downloadpaludis-902ab043b79baac156cf2f899d316ea4a5dfd89b.tar.gz
paludis-902ab043b79baac156cf2f899d316ea4a5dfd89b.tar.xz
Allow hooks to abort the operation by returning non-zero.
-rwxr-xr-xhooks/eselect_env_update.bash2
-rwxr-xr-xhooks/gnu_info_index.bash3
-rwxr-xr-xhooks/log.bash1
-rw-r--r--paludis/environment.cc3
-rw-r--r--paludis/environment.hh6
-rw-r--r--paludis/environment/default/default_environment.cc16
-rw-r--r--paludis/environment/default/default_environment.hh2
-rw-r--r--paludis/environment/test/test_environment.hh3
-rw-r--r--paludis/merger/merger.cc176
-rw-r--r--paludis/merger/unmerger.cc56
-rw-r--r--paludis/syncer.hh3
-rw-r--r--paludis/tasks/install_task.cc90
-rw-r--r--paludis/tasks/sync_task.cc36
-rw-r--r--paludis/tasks/uninstall_task.cc26
14 files changed, 245 insertions, 178 deletions
diff --git a/hooks/eselect_env_update.bash b/hooks/eselect_env_update.bash
index b37628a..544b505 100755
--- a/hooks/eselect_env_update.bash
+++ b/hooks/eselect_env_update.bash
@@ -26,7 +26,7 @@ fi
echo
einfo_unhooked "Regenerating environment..."
-eselect env update || exit 1
+eselect env update || ewarn "Regeneration failed"
einfo_unhooked "Done regenerating environment"
true
diff --git a/hooks/gnu_info_index.bash b/hooks/gnu_info_index.bash
index 0fdaab0..58e016c 100755
--- a/hooks/gnu_info_index.bash
+++ b/hooks/gnu_info_index.bash
@@ -80,9 +80,8 @@ touch "${vdb_loc}/.cache/info_time_cache"
if [[ ${bad_count} -gt 0 ]] ; then
ewarn "Processed $(( good_count + bad_count )) info files, with ${bad_count} errors"
- exit 1
else
einfo_unhooked "Processed ${good_count} info files"
- exit 0
fi
+exit 0
diff --git a/hooks/log.bash b/hooks/log.bash
index 43e042e..6580b52 100755
--- a/hooks/log.bash
+++ b/hooks/log.bash
@@ -101,3 +101,4 @@ X_OF_Y="${X_OF_Y+ (${X_OF_Y})}"
esac
) >> ${ROOT}/var/log/paludis.log
+true
diff --git a/paludis/environment.cc b/paludis/environment.cc
index efbac50..7f418ab 100644
--- a/paludis/environment.cc
+++ b/paludis/environment.cc
@@ -530,9 +530,10 @@ Environment::end_mirrors(const std::string &) const
return MirrorIterator(environment_mirrors.end());
}
-void
+int
Environment::perform_hook(const Hook &) const
{
+ return 0;
}
std::tr1::shared_ptr<const UseFlagNameCollection>
diff --git a/paludis/environment.hh b/paludis/environment.hh
index 0d1d237..2985ed4 100644
--- a/paludis/environment.hh
+++ b/paludis/environment.hh
@@ -351,11 +351,13 @@ namespace paludis
void remove_set_from_world(const SetName &, WorldCallbacks *) const;
/**
- * Perform a hook.
+ * Perform a hook. Returns the highest exit status of all
+ * hooks called (usually, only zero or non-zero is
+ * meaningful).
*
* Default behaviour: nothing happens.
*/
- virtual void perform_hook(const Hook & hook) const;
+ virtual int perform_hook(const Hook & hook) const PALUDIS_ATTRIBUTE((warn_unused_result));
/**
* Default root location.
diff --git a/paludis/environment/default/default_environment.cc b/paludis/environment/default/default_environment.cc
index 66275c9..5fbaf7a 100644
--- a/paludis/environment/default/default_environment.cc
+++ b/paludis/environment/default/default_environment.cc
@@ -555,10 +555,10 @@ namespace
{
}
- void operator() (const FSEntry & f) const;
+ int operator() (const FSEntry & f) const;
};
- void
+ int
Hooker::operator() (const FSEntry & f) const
{
Context context("When running hook script '" + stringify(f) +
@@ -584,16 +584,17 @@ namespace
else
Log::get_instance()->message(ll_warning, lc_no_context, "Hook '" + stringify(f)
+ "' returned failure '" + stringify(exit_status) + "'");
+ return exit_status;
}
}
-void
+int
DefaultEnvironment::perform_hook(const Hook & hook) const
{
HookPresentCache::iterator cache_entry(_imp->hook_cache.end());
if (_imp->hook_cache.end() != ((cache_entry = _imp->hook_cache.find(hook.name()))))
if (! cache_entry->second)
- return;
+ return 0;
Context context("When triggering hook '" + hook.name() + "'");
Log::get_instance()->message(ll_debug, lc_no_context, "Starting hook '" + hook.name() + "'");
@@ -601,6 +602,7 @@ DefaultEnvironment::perform_hook(const Hook & hook) const
const std::list<FSEntry> & hook_dirs_ref(get_hook_dirs());
bool had_hook(false);
+ int max_exit_status(0);
for (std::list<FSEntry>::const_iterator h(hook_dirs_ref.begin()),
h_end(hook_dirs_ref.end()) ; h != h_end ; ++h)
{
@@ -615,11 +617,15 @@ DefaultEnvironment::perform_hook(const Hook & hook) const
if (! hooks.empty())
had_hook = true;
- std::for_each(hooks.begin(), hooks.end(), Hooker(hook, paludis_command()));
+ for (std::list<FSEntry>::const_iterator hk(hooks.begin()),
+ hk_end(hooks.end()) ; hk != hk_end ; ++hk)
+ max_exit_status = std::max(max_exit_status, Hooker(hook, paludis_command())(*hk));
}
if (_imp->hook_cache.end() == cache_entry)
_imp->hook_cache.insert(std::make_pair(hook.name(), had_hook));
+
+ return max_exit_status;
}
std::string
diff --git a/paludis/environment/default/default_environment.hh b/paludis/environment/default/default_environment.hh
index 6e33911..fab2bee 100644
--- a/paludis/environment/default/default_environment.hh
+++ b/paludis/environment/default/default_environment.hh
@@ -79,7 +79,7 @@ namespace paludis
virtual std::tr1::shared_ptr<const UseFlagNameCollection> known_use_expand_names(const UseFlagName &,
const PackageDatabaseEntry *) const;
- virtual void perform_hook(const Hook & hook) const;
+ virtual int perform_hook(const Hook & hook) const PALUDIS_ATTRIBUTE((warn_unused_result));
virtual MirrorIterator begin_mirrors(const std::string & mirror) const;
diff --git a/paludis/environment/test/test_environment.hh b/paludis/environment/test/test_environment.hh
index 9fefdf9..560fd3c 100644
--- a/paludis/environment/test/test_environment.hh
+++ b/paludis/environment/test/test_environment.hh
@@ -72,8 +72,9 @@ namespace paludis
return "false";
}
- virtual void perform_hook(const Hook &) const
+ virtual int perform_hook(const Hook &) const PALUDIS_ATTRIBUTE((warn_unused_result))
{
+ return 0;
}
virtual MirrorIterator begin_mirrors(const std::string &) const;
diff --git a/paludis/merger/merger.cc b/paludis/merger/merger.cc
index f98f5b7..8fcc8f7 100644
--- a/paludis/merger/merger.cc
+++ b/paludis/merger/merger.cc
@@ -158,11 +158,12 @@ Merger::on_file(bool is_check, const FSEntry & src, const FSEntry & dst)
{
MergerEntryType m(entry_type(dst / src.basename()));
- if (is_check)
- _options.environment->perform_hook(extend_hook(
- Hook("merger_check_file_pre")
- ("INSTALL_SOURCE", stringify(src))
- ("INSTALL_DESTINATION", stringify(dst / src.basename()))));
+ if (is_check &&
+ 0 != _options.environment->perform_hook(extend_hook(
+ Hook("merger_check_file_pre")
+ ("INSTALL_SOURCE", stringify(src))
+ ("INSTALL_DESTINATION", stringify(dst / src.basename())))))
+ make_check_fail();
do
{
@@ -195,11 +196,12 @@ Merger::on_file(bool is_check, const FSEntry & src, const FSEntry & dst)
throw InternalError(PALUDIS_HERE, "Unexpected entry_type '" + stringify(m) + "'");
} while (false);
- if (is_check)
- _options.environment->perform_hook(extend_hook(
- Hook("merger_check_file_post")
- ("INSTALL_SOURCE", stringify(src))
- ("INSTALL_DESTINATION", stringify(dst / src.basename()))));
+ if (is_check &&
+ 0 != _options.environment->perform_hook(extend_hook(
+ Hook("merger_check_file_post")
+ ("INSTALL_SOURCE", stringify(src))
+ ("INSTALL_DESTINATION", stringify(dst / src.basename())))))
+ make_check_fail();
}
void
@@ -207,11 +209,12 @@ Merger::on_dir(bool is_check, const FSEntry & src, const FSEntry & dst)
{
MergerEntryType m(entry_type(dst / src.basename()));
- if (is_check)
- _options.environment->perform_hook(extend_hook(
- Hook("merger_check_dir_pre")
- ("INSTALL_SOURCE", stringify(src))
- ("INSTALL_DESTINATION", stringify(dst / src.basename()))));
+ if (is_check &&
+ 0 != _options.environment->perform_hook(extend_hook(
+ Hook("merger_check_dir_pre")
+ ("INSTALL_SOURCE", stringify(src))
+ ("INSTALL_DESTINATION", stringify(dst / src.basename())))))
+ make_check_fail();
do
{
@@ -245,11 +248,12 @@ Merger::on_dir(bool is_check, const FSEntry & src, const FSEntry & dst)
} while (false);
- if (is_check)
- _options.environment->perform_hook(extend_hook(
- Hook("merger_check_dir_post")
- ("INSTALL_SOURCE", stringify(src))
- ("INSTALL_DESTINATION", stringify(dst / src.basename()))));
+ if (is_check &&
+ 0 != _options.environment->perform_hook(extend_hook(
+ Hook("merger_check_dir_post")
+ ("INSTALL_SOURCE", stringify(src))
+ ("INSTALL_DESTINATION", stringify(dst / src.basename())))))
+ make_check_fail();
}
void
@@ -257,11 +261,12 @@ Merger::on_sym(bool is_check, const FSEntry & src, const FSEntry & dst)
{
MergerEntryType m(entry_type(dst / src.basename()));
- if (is_check)
- _options.environment->perform_hook(extend_hook(
- Hook("merger_check_sym_post")
- ("INSTALL_SOURCE", stringify(src))
- ("INSTALL_DESTINATION", stringify(dst / src.basename()))));
+ if (is_check &&
+ 0 != _options.environment->perform_hook(extend_hook(
+ Hook("merger_check_sym_post")
+ ("INSTALL_SOURCE", stringify(src))
+ ("INSTALL_DESTINATION", stringify(dst / src.basename())))))
+ make_check_fail();
do
{
@@ -294,11 +299,12 @@ Merger::on_sym(bool is_check, const FSEntry & src, const FSEntry & dst)
throw InternalError(PALUDIS_HERE, "Unexpected entry_type '" + stringify(m) + "'");
} while (false);
- if (is_check)
- _options.environment->perform_hook(extend_hook(
- Hook("merger_check_sym_post")
- ("INSTALL_SOURCE", stringify(src))
- ("INSTALL_DESTINATION", stringify(dst / src.basename()))));
+ if (is_check &&
+ 0 != _options.environment->perform_hook(extend_hook(
+ Hook("merger_check_sym_post")
+ ("INSTALL_SOURCE", stringify(src))
+ ("INSTALL_DESTINATION", stringify(dst / src.basename())))))
+ make_check_fail();
}
void
@@ -491,10 +497,11 @@ Merger::on_sym_over_misc(bool is_check, const FSEntry & src, const FSEntry & dst
void
Merger::install_file(const FSEntry & src, const FSEntry & dst_dir, const std::string & dst_name)
{
- _options.environment->perform_hook(extend_hook(
- Hook("merger_install_file_pre")
- ("INSTALL_SOURCE", stringify(src))
- ("INSTALL_DESTINATION", stringify(dst_dir / src.basename()))));
+ if (0 != _options.environment->perform_hook(extend_hook(
+ Hook("merger_install_file_pre")
+ ("INSTALL_SOURCE", stringify(src))
+ ("INSTALL_DESTINATION", stringify(dst_dir / src.basename())))))
+ throw MergerError("Merge of '" + stringify(src) + "' to '" + stringify(dst_dir) + "' aborted by hook");
FSCreateCon createcon(MatchPathCon::get_instance()->match(stringify(dst_dir/dst_name), src.permissions()));
FDHolder input_fd(::open(stringify(src).c_str(), O_RDONLY), false);
@@ -518,19 +525,21 @@ Merger::install_file(const FSEntry & src, const FSEntry & dst_dir, const std::st
while ((count = read(input_fd, buf, 4096)) > 0)
write(output_fd, buf, count);
- _options.environment->perform_hook(extend_hook(
- Hook("merger_install_file_post")
- ("INSTALL_SOURCE", stringify(src))
- ("INSTALL_DESTINATION", stringify(dst_dir / src.basename()))));
+ if (0 != _options.environment->perform_hook(extend_hook(
+ Hook("merger_install_file_post")
+ ("INSTALL_SOURCE", stringify(src))
+ ("INSTALL_DESTINATION", stringify(dst_dir / src.basename())))))
+ throw MergerError("Merge of '" + stringify(src) + "' to '" + stringify(dst_dir) + "' aborted by hook");
}
void
Merger::install_dir(const FSEntry & src, const FSEntry & dst_dir)
{
- _options.environment->perform_hook(extend_hook(
- Hook("merger_install_dir_pre")
- ("INSTALL_SOURCE", stringify(src))
- ("INSTALL_DESTINATION", stringify(dst_dir / src.basename()))));
+ if (0 != _options.environment->perform_hook(extend_hook(
+ Hook("merger_install_dir_pre")
+ ("INSTALL_SOURCE", stringify(src))
+ ("INSTALL_DESTINATION", stringify(dst_dir / src.basename())))))
+ throw MergerError("Merge of '" + stringify(src) + "' to '" + stringify(dst_dir) + "' aborted by hook");
mode_t mode(src.permissions());
FSEntry dst(dst_dir / src.basename());
@@ -540,36 +549,40 @@ Merger::install_dir(const FSEntry & src, const FSEntry & dst_dir)
/* pick up set*id bits */
dst.chmod(src.permissions());
- _options.environment->perform_hook(extend_hook(
- Hook("merger_install_dir_post")
- ("INSTALL_SOURCE", stringify(src))
- ("INSTALL_DESTINATION", stringify(dst_dir / src.basename()))));
+ if (0 != _options.environment->perform_hook(extend_hook(
+ Hook("merger_install_dir_post")
+ ("INSTALL_SOURCE", stringify(src))
+ ("INSTALL_DESTINATION", stringify(dst_dir / src.basename())))))
+ throw MergerError("Merge of '" + stringify(src) + "' to '" + stringify(dst_dir) + "' aborted by hook");
}
void
Merger::install_sym(const FSEntry & src, const FSEntry & dst_dir)
{
- _options.environment->perform_hook(extend_hook(
- Hook("merger_install_sym_pre")
- ("INSTALL_SOURCE", stringify(src))
- ("INSTALL_DESTINATION", stringify(dst_dir / src.basename()))));
+ if (0 != _options.environment->perform_hook(extend_hook(
+ Hook("merger_install_sym_pre")
+ ("INSTALL_SOURCE", stringify(src))
+ ("INSTALL_DESTINATION", stringify(dst_dir / src.basename())))))
+ throw MergerError("Merge of '" + stringify(src) + "' to '" + stringify(dst_dir) + "' aborted by hook");
FSCreateCon createcon(MatchPathCon::get_instance()->match(stringify(dst_dir / src.basename()), S_IFLNK));
if (0 != ::symlink(stringify(src.readlink()).c_str(), stringify(dst_dir / src.basename()).c_str()))
throw MergerError("Couldn't create symlink at '" + stringify(dst_dir / src.basename()) + "'");
- _options.environment->perform_hook(extend_hook(
- Hook("merger_install_sym_post")
- ("INSTALL_SOURCE", stringify(src))
- ("INSTALL_DESTINATION", stringify(dst_dir / src.basename()))));
+ if (0 != _options.environment->perform_hook(extend_hook(
+ Hook("merger_install_sym_post")
+ ("INSTALL_SOURCE", stringify(src))
+ ("INSTALL_DESTINATION", stringify(dst_dir / src.basename())))))
+ throw MergerError("Merge of '" + stringify(src) + "' to '" + stringify(dst_dir) + "' aborted by hook");
}
void
Merger::unlink_file(FSEntry d)
{
- _options.environment->perform_hook(extend_hook(
- Hook("merger_unlink_file_pre")
- ("UNLINK_TARGET", stringify(d))));
+ if (0 != _options.environment->perform_hook(extend_hook(
+ Hook("merger_unlink_file_pre")
+ ("UNLINK_TARGET", stringify(d)))))
+ throw MergerError("Unmerge of '" + stringify(d) + "' aborted by hook");
if (d.is_regular_file())
{
@@ -583,51 +596,58 @@ Merger::unlink_file(FSEntry d)
d.unlink();
- _options.environment->perform_hook(extend_hook(
- Hook("merger_unlink_file_post")
- ("UNLINK_TARGET", stringify(d))));
+ if (0 != _options.environment->perform_hook(extend_hook(
+ Hook("merger_unlink_file_post")
+ ("UNLINK_TARGET", stringify(d)))))
+ throw MergerError("Unmerge of '" + stringify(d) + "' aborted by hook");
}
void
Merger::unlink_sym(FSEntry d)
{
- _options.environment->perform_hook(extend_hook(
- Hook("merger_unlink_sym_pre")
- ("UNLINK_TARGET", stringify(d))));
+ if (0 != _options.environment->perform_hook(extend_hook(
+ Hook("merger_unlink_sym_pre")
+ ("UNLINK_TARGET", stringify(d)))))
+ throw MergerError("Unmerge of '" + stringify(d) + "' aborted by hook");
d.unlink();
- _options.environment->perform_hook(extend_hook(
- Hook("merger_unlink_sym_post")
- ("UNLINK_TARGET", stringify(d))));
+ if (0 != _options.environment->perform_hook(extend_hook(
+ Hook("merger_unlink_sym_post")
+ ("UNLINK_TARGET", stringify(d)))))
+ throw MergerError("Unmerge of '" + stringify(d) + "' aborted by hook");
}
void
Merger::unlink_dir(FSEntry d)
{
- _options.environment->perform_hook(extend_hook(
- Hook("merger_unlink_dir_pre")
- ("UNLINK_TARGET", stringify(d))));
+ if (0 != _options.environment->perform_hook(extend_hook(
+ Hook("merger_unlink_dir_pre")
+ ("UNLINK_TARGET", stringify(d)))))
+ throw MergerError("Unmerge of '" + stringify(d) + "' aborted by hook");
d.rmdir();
- _options.environment->perform_hook(extend_hook(
- Hook("merger_unlink_dir_post")
- ("UNLINK_TARGET", stringify(d))));
+ if (0 != _options.environment->perform_hook(extend_hook(
+ Hook("merger_unlink_dir_post")
+ ("UNLINK_TARGET", stringify(d)))))
+ throw MergerError("Unmerge of '" + stringify(d) + "' aborted by hook");
}
void
Merger::unlink_misc(FSEntry d)
{
- _options.environment->perform_hook(extend_hook(
- Hook("merger_unlink_misc_pre")
- ("UNLINK_TARGET", stringify(d))));
+ if (0 != _options.environment->perform_hook(extend_hook(
+ Hook("merger_unlink_misc_pre")
+ ("UNLINK_TARGET", stringify(d)))))
+ throw MergerError("Unmerge of '" + stringify(d) + "' aborted by hook");
d.unlink();
- _options.environment->perform_hook(extend_hook(
- Hook("merger_unlink_misc_post")
- ("UNLINK_TARGET", stringify(d))));
+ if (0 != _options.environment->perform_hook(extend_hook(
+ Hook("merger_unlink_misc_post")
+ ("UNLINK_TARGET", stringify(d)))))
+ throw MergerError("Unmerge of '" + stringify(d) + "' aborted by hook");
}
Hook
diff --git a/paludis/merger/unmerger.cc b/paludis/merger/unmerger.cc
index 37fc695..fac00b6 100644
--- a/paludis/merger/unmerger.cc
+++ b/paludis/merger/unmerger.cc
@@ -45,9 +45,10 @@ Unmerger::~Unmerger()
void
Unmerger::unlink_file(FSEntry d)
{
- _options.environment->perform_hook(extend_hook(
- Hook("unmerger_unlink_file_pre")
- ("UNLINK_TARGET", stringify(d))));
+ if (0 != _options.environment->perform_hook(extend_hook(
+ Hook("unmerger_unlink_file_pre")
+ ("UNLINK_TARGET", stringify(d)))))
+ throw UnmergerError("Unmerge of '" + stringify(d) + "' aborted by hook");
if (d.is_regular_file())
{
@@ -61,51 +62,58 @@ Unmerger::unlink_file(FSEntry d)
d.unlink();
- _options.environment->perform_hook(extend_hook(
- Hook("unmerger_unlink_file_post")
- ("UNLINK_TARGET", stringify(d))));
+ if (0 != _options.environment->perform_hook(extend_hook(
+ Hook("unmerger_unlink_file_post")
+ ("UNLINK_TARGET", stringify(d)))))
+ throw UnmergerError("Unmerge of '" + stringify(d) + "' aborted by hook");
}
void
Unmerger::unlink_sym(FSEntry d)
{
- _options.environment->perform_hook(extend_hook(
- Hook("unmerger_unlink_sym_pre")
- ("UNLINK_TARGET", stringify(d))));
+ if (0 != _options.environment->perform_hook(extend_hook(
+ Hook("unmerger_unlink_sym_pre")
+ ("UNLINK_TARGET", stringify(d)))))
+ throw UnmergerError("Unmerge of '" + stringify(d) + "' aborted by hook");
d.unlink();
- _options.environment->perform_hook(extend_hook(
- Hook("unmerger_unlink_sym_post")
- ("UNLINK_TARGET", stringify(d))));
+ if (0 != _options.environment->perform_hook(extend_hook(
+ Hook("unmerger_unlink_sym_post")
+ ("UNLINK_TARGET", stringify(d)))))
+ throw UnmergerError("Unmerge of '" + stringify(d) + "' aborted by hook");
}
void
Unmerger::unlink_dir(FSEntry d)
{
- _options.environment->perform_hook(extend_hook(
- Hook("unmerger_unlink_dir_pre")
- ("UNLINK_TARGET", stringify(d))));
+ if (0 != _options.environment->perform_hook(extend_hook(
+ Hook("unmerger_unlink_dir_pre")
+ ("UNLINK_TARGET", stringify(d)))))
+ throw UnmergerError("Unmerge of '" + stringify(d) + "' aborted by hook");
d.rmdir();
- _options.environment->perform_hook(extend_hook(
- Hook("unmerger_unlink_dir_post")
- ("UNLINK_TARGET", stringify(d))));
+ if (0 != _options.environment->perform_hook(extend_hook(
+ Hook("unmerger_unlink_dir_post")
+ ("UNLINK_TARGET", stringify(d)))))
+ throw UnmergerError("Unmerge of '" + stringify(d) + "' aborted by hook");
}
void
Unmerger::unlink_misc(FSEntry d)
{
- _options.environment->perform_hook(extend_hook(
- Hook("unmerger_unlink_misc_pre")
- ("UNLINK_TARGET", stringify(d))));
+ if (0 != _options.environment->perform_hook(extend_hook(
+ Hook("unmerger_unlink_misc_pre")
+ ("UNLINK_TARGET", stringify(d)))))
+ throw UnmergerError("Unmerge of '" + stringify(d) + "' aborted by hook");
d.unlink();
- _options.environment->perform_hook(extend_hook(
- Hook("unmerger_unlink_misc_post")
- ("UNLINK_TARGET", stringify(d))));
+ if (0 != _options.environment->perform_hook(extend_hook(
+ Hook("unmerger_unlink_misc_post")
+ ("UNLINK_TARGET", stringify(d)))))
+ throw UnmergerError("Unmerge of '" + stringify(d) + "' aborted by hook");
}
Hook
diff --git a/paludis/syncer.hh b/paludis/syncer.hh
index ae42521..7c4d748 100644
--- a/paludis/syncer.hh
+++ b/paludis/syncer.hh
@@ -107,13 +107,12 @@ namespace paludis
class SyncFailedError :
public PackageActionError
{
- protected:
+ public:
/**
* Constructor.
*/
SyncFailedError(const std::string & msg) throw ();
- public:
/**
* Constructor.
*/
diff --git a/paludis/tasks/install_task.cc b/paludis/tasks/install_task.cc
index 3d2fbbe..0bb65ce 100644
--- a/paludis/tasks/install_task.cc
+++ b/paludis/tasks/install_task.cc
@@ -186,9 +186,10 @@ InstallTask::execute()
on_build_deplist_post();
/* we're about to display our task list */
- if (_imp->pretend)
- _imp->env->perform_hook(Hook("install_pretend_pre")("TARGETS", join(_imp->raw_targets.begin(),
- _imp->raw_targets.end(), " ")));
+ if (_imp->pretend &&
+ 0 != _imp->env->perform_hook(Hook("install_pretend_pre")("TARGETS", join(_imp->raw_targets.begin(),
+ _imp->raw_targets.end(), " "))))
+ throw PackageInstallActionError("Pretend install aborted by hook");
on_display_merge_list_pre();
@@ -205,8 +206,9 @@ InstallTask::execute()
if (_imp->pretend)
{
- _imp->env->perform_hook(Hook("install_pretend_post")("TARGETS", join(
- _imp->raw_targets.begin(), _imp->raw_targets.end(), " ")));
+ if (0 != _imp->env->perform_hook(Hook("install_pretend_post")("TARGETS", join(
+ _imp->raw_targets.begin(), _imp->raw_targets.end(), " "))))
+ throw PackageInstallActionError("Pretend install aborted by hook");
return;
}
@@ -219,8 +221,9 @@ InstallTask::execute()
/* we're about to fetch / install the entire list */
if (_imp->install_options.fetch_only)
{
- _imp->env->perform_hook(Hook("fetch_all_pre")("TARGETS", join(
- _imp->raw_targets.begin(), _imp->raw_targets.end(), " ")));
+ if (0 != _imp->env->perform_hook(Hook("fetch_all_pre")("TARGETS", join(
+ _imp->raw_targets.begin(), _imp->raw_targets.end(), " "))))
+ throw PackageInstallActionError("Fetch aborted by hook");
on_fetch_all_pre();
}
else
@@ -235,9 +238,10 @@ InstallTask::execute()
d->destination->destination_interface->want_pre_post_phases())
any_live_destination = true;
- _imp->env->perform_hook(Hook("install_all_pre")
- ("TARGETS", join(_imp->raw_targets.begin(), _imp->raw_targets.end(), " "))
- ("PALUDIS_NO_LIVE_DESTINATION", any_live_destination ? "" : "yes"));
+ if (0 != _imp->env->perform_hook(Hook("install_all_pre")
+ ("TARGETS", join(_imp->raw_targets.begin(), _imp->raw_targets.end(), " "))
+ ("PALUDIS_NO_LIVE_DESTINATION", any_live_destination ? "" : "yes")))
+ throw PackageInstallActionError("Install aborted by hook");
on_install_all_pre();
}
@@ -271,17 +275,19 @@ InstallTask::execute()
/* we're about to fetch / install one item */
if (_imp->install_options.fetch_only)
{
- _imp->env->perform_hook(Hook("fetch_pre")
- ("TARGET", cpvr)
- ("X_OF_Y", stringify(x) + " of " + stringify(y)));
+ if (0 != _imp->env->perform_hook(Hook("fetch_pre")
+ ("TARGET", cpvr)
+ ("X_OF_Y", stringify(x) + " of " + stringify(y))))
+ throw PackageInstallActionError("Fetch of '" + cpvr + "' aborted by hook");
on_fetch_pre(*dep);
}
else
{
- _imp->env->perform_hook(Hook("install_pre")
- ("TARGET", cpvr)
- ("X_OF_Y", stringify(x) + " of " + stringify(y))
- ("PALUDIS_NO_LIVE_DESTINATION", live_destination ? "" : "yes"));
+ if (0 != _imp->env->perform_hook(Hook("install_pre")
+ ("TARGET", cpvr)
+ ("X_OF_Y", stringify(x) + " of " + stringify(y))
+ ("PALUDIS_NO_LIVE_DESTINATION", live_destination ? "" : "yes")))
+ throw PackageInstallActionError("Install of '" + cpvr + "' aborted by hook");
on_install_pre(*dep);
}
@@ -299,7 +305,7 @@ InstallTask::execute()
}
catch (const PackageInstallActionError & e)
{
- _imp->env->perform_hook(Hook("install_fail")("TARGET", cpvr)("MESSAGE", e.message()));
+ int PALUDIS_ATTRIBUTE((unused)) dummy(_imp->env->perform_hook(Hook("install_fail")("TARGET", cpvr)("MESSAGE", e.message())));
throw;
}
@@ -307,17 +313,19 @@ InstallTask::execute()
if (_imp->install_options.fetch_only)
{
on_fetch_post(*dep);
- _imp->env->perform_hook(Hook("fetch_post")
- ("TARGET", cpvr)
- ("X_OF_Y", stringify(x) + " of " + stringify(y)));
+ if (0 != _imp->env->perform_hook(Hook("fetch_post")
+ ("TARGET", cpvr)
+ ("X_OF_Y", stringify(x) + " of " + stringify(y))))
+ throw PackageInstallActionError("Fetch of '" + cpvr + "' aborted by hook");
}
else
{
on_install_post(*dep);
- _imp->env->perform_hook(Hook("install_post")
- ("TARGET", cpvr)
- ("X_OF_Y", stringify(x) + " of " + stringify(y))
- ("PALUDIS_NO_LIVE_DESTINATION", live_destination ? "" : "yes"));
+ if (0 != _imp->env->perform_hook(Hook("install_post")
+ ("TARGET", cpvr)
+ ("X_OF_Y", stringify(x) + " of " + stringify(y))
+ ("PALUDIS_NO_LIVE_DESTINATION", live_destination ? "" : "yes")))
+ throw PackageInstallActionError("Install of '" + cpvr + "' aborted by hook");
}
if (_imp->install_options.fetch_only || ! live_destination)
@@ -362,16 +370,18 @@ InstallTask::execute()
on_no_clean_needed(*dep);
else
{
- _imp->env->perform_hook(Hook("clean_all_pre")("TARGETS", join(
- clean_list.begin(), clean_list.end(), " ")));
+ if (0 != _imp->env->perform_hook(Hook("clean_all_pre")("TARGETS", join(
+ clean_list.begin(), clean_list.end(), " "))))
+ throw PackageInstallActionError("Clean aborted by hook");
on_clean_all_pre(*dep, clean_list);
for (PackageDatabaseEntryCollection::Iterator c(clean_list.begin()),
c_end(clean_list.end()) ; c != c_end ; ++c)
{
/* clean one item */
- _imp->env->perform_hook(Hook("clean_pre")("TARGET", stringify(*c))
- ("X_OF_Y", stringify(x) + " of " + stringify(y)));
+ if (0 != _imp->env->perform_hook(Hook("clean_pre")("TARGET", stringify(*c))
+ ("X_OF_Y", stringify(x) + " of " + stringify(y))))
+ throw PackageInstallActionError("Clean of '" + cpvr + "' aborted by hook");
on_clean_pre(*dep, *c);
const RepositoryUninstallableInterface * const uninstall_interface(
@@ -386,18 +396,20 @@ InstallTask::execute()
}
catch (const PackageUninstallActionError & e)
{
- _imp->env->perform_hook(Hook("clean_fail")("TARGET", stringify(*c))("MESSAGE", e.message()));
+ int PALUDIS_ATTRIBUTE((unused)) dummy(_imp->env->perform_hook(Hook("clean_fail")("TARGET", stringify(*c))("MESSAGE", e.message())));
throw;
}
on_clean_post(*dep, *c);
- _imp->env->perform_hook(Hook("clean_post")("TARGET", stringify(*c))
- ("X_OF_Y", stringify(x) + " of " + stringify(y)));
+ if (0 != _imp->env->perform_hook(Hook("clean_post")("TARGET", stringify(*c))
+ ("X_OF_Y", stringify(x) + " of " + stringify(y))))
+ throw PackageInstallActionError("Clean of '" + cpvr + "' aborted by hook");
}
/* we're done cleaning */
- _imp->env->perform_hook(Hook("clean_all_post")("TARGETS", join(
- clean_list.begin(), clean_list.end(), " ")));
+ if (0 != _imp->env->perform_hook(Hook("clean_all_post")("TARGETS", join(
+ clean_list.begin(), clean_list.end(), " "))))
+ throw PackageInstallActionError("Clean aborted by hook");
on_clean_all_post(*dep, clean_list);
}
@@ -452,14 +464,16 @@ InstallTask::execute()
if (_imp->install_options.fetch_only)
{
on_fetch_all_post();
- _imp->env->perform_hook(Hook("fetch_all_post")("TARGETS", join(
- _imp->raw_targets.begin(), _imp->raw_targets.end(), " ")));
+ if (0 != _imp->env->perform_hook(Hook("fetch_all_post")("TARGETS", join(
+ _imp->raw_targets.begin(), _imp->raw_targets.end(), " "))))
+ throw PackageInstallActionError("Fetch aborted by hook");
}
else
{
on_install_all_post();
- _imp->env->perform_hook(Hook("install_all_post")("TARGETS", join(
- _imp->raw_targets.begin(), _imp->raw_targets.end(), " ")));
+ if (0 != _imp->env->perform_hook(Hook("install_all_post")("TARGETS", join(
+ _imp->raw_targets.begin(), _imp->raw_targets.end(), " "))))
+ throw PackageInstallActionError("Install aborted by hook");
}
}
diff --git a/paludis/tasks/sync_task.cc b/paludis/tasks/sync_task.cc
index 632ebfb..ae97409 100644
--- a/paludis/tasks/sync_task.cc
+++ b/paludis/tasks/sync_task.cc
@@ -65,8 +65,10 @@ SyncTask::execute()
r_end(_imp->env->package_database()->end_repositories()) ; r != r_end ; ++r)
_imp->targets.push_back((*r)->name());
- _imp->env->perform_hook(Hook("sync_all_pre")("TARGETS", join(_imp->targets.begin(),
- _imp->targets.end(), " ")));
+ if (0 !=
+ _imp->env->perform_hook(Hook("sync_all_pre")("TARGETS", join(_imp->targets.begin(),
+ _imp->targets.end(), " "))))
+ throw SyncFailedError("Sync aborted by hook");
on_sync_all_pre();
int x(0), y(std::distance(_imp->targets.begin(), _imp->targets.end()));
@@ -76,33 +78,39 @@ SyncTask::execute()
Context context_local("When syncing repository '" + stringify(*r) + "':");
++x;
- _imp->env->perform_hook(Hook("sync_pre")("TARGET", stringify(*r))
- ("X_OF_Y", stringify(x) + " of " + stringify(y)));
- on_sync_pre(*r);
-
try
{
+ if (0 !=
+ _imp->env->perform_hook(Hook("sync_pre")("TARGET", stringify(*r))
+ ("X_OF_Y", stringify(x) + " of " + stringify(y))))
+ throw SyncFailedError("Sync of '" + stringify(*r) + "' aborted by hook");
+ on_sync_pre(*r);
+
std::tr1::shared_ptr<const Repository> rr(_imp->env->package_database()->fetch_repository(*r));
if (rr->syncable_interface && rr->syncable_interface->sync())
on_sync_succeed(*r);
else
on_sync_skip(*r);
+
+ on_sync_post(*r);
+ if (0 !=
+ _imp->env->perform_hook(Hook("sync_post")("TARGET", stringify(*r))
+ ("X_OF_Y", stringify(x) + " of " + stringify(y))))
+ throw SyncFailedError("Sync of '" + stringify(*r) + "' aborted by hook");
}
catch (const SyncFailedError & e)
{
- _imp->env->perform_hook(Hook("sync_fail")("TARGET", stringify(*r))
- ("X_OF_Y", stringify(x) + " of " + stringify(y)));
+ int PALUDIS_ATTRIBUTE((unused)) dummy(_imp->env->perform_hook(Hook("sync_fail")("TARGET", stringify(*r))
+ ("X_OF_Y", stringify(x) + " of " + stringify(y))));
on_sync_fail(*r, e);
}
-
- on_sync_post(*r);
- _imp->env->perform_hook(Hook("sync_post")("TARGET", stringify(*r))
- ("X_OF_Y", stringify(x) + " of " + stringify(y)));
}
on_sync_all_post();
- _imp->env->perform_hook(Hook("sync_all_post")("TARGETS", join(_imp->targets.begin(),
- _imp->targets.end(), " ")));
+ if (0 !=
+ _imp->env->perform_hook(Hook("sync_all_post")("TARGETS", join(_imp->targets.begin(),
+ _imp->targets.end(), " "))))
+ throw SyncFailedError("Sync aborted by hook");
}
diff --git a/paludis/tasks/uninstall_task.cc b/paludis/tasks/uninstall_task.cc
index e9e2e18..fc18249 100644
--- a/paludis/tasks/uninstall_task.cc
+++ b/paludis/tasks/uninstall_task.cc
@@ -286,8 +286,10 @@ UninstallTask::execute()
on_update_world_post();
}
- _imp->env->perform_hook(Hook("uninstall_all_pre")("TARGETS", join(_imp->raw_targets.begin(),
- _imp->raw_targets.end(), " ")));
+ if (0 !=
+ _imp->env->perform_hook(Hook("uninstall_all_pre")("TARGETS", join(_imp->raw_targets.begin(),
+ _imp->raw_targets.end(), " "))))
+ throw PackageUninstallActionError("Uninstall aborted by hook");
on_uninstall_all_pre();
int x(0), y(0);
@@ -303,8 +305,10 @@ UninstallTask::execute()
std::string cpvr(stringify(i->package));
- _imp->env->perform_hook(Hook("uninstall_pre")("TARGET", cpvr)
- ("X_OF_Y", stringify(x) + " of " + stringify(y)));
+ if (0 !=
+ _imp->env->perform_hook(Hook("uninstall_pre")("TARGET", cpvr)
+ ("X_OF_Y", stringify(x) + " of " + stringify(y))))
+ throw PackageUninstallActionError("Uninstall of '" + cpvr + "' aborted by hook");
on_uninstall_pre(*i);
const RepositoryUninstallableInterface * const uninstall_interface(
@@ -319,18 +323,22 @@ UninstallTask::execute()
}
catch (const PackageUninstallActionError & e)
{
- _imp->env->perform_hook(Hook("uninstall_fail")("TARGET", cpvr)("MESSAGE", e.message()));
+ int PALUDIS_ATTRIBUTE((unused)) dummy(_imp->env->perform_hook(Hook("uninstall_fail")("TARGET", cpvr)("MESSAGE", e.message())));
throw;
}
on_uninstall_post(*i);
- _imp->env->perform_hook(Hook("uninstall_post")("TARGET", cpvr)
- ("X_OF_Y", stringify(x) + " of " + stringify(y)));
+ if (0 !=
+ _imp->env->perform_hook(Hook("uninstall_post")("TARGET", cpvr)
+ ("X_OF_Y", stringify(x) + " of " + stringify(y))))
+ throw PackageUninstallActionError("Uninstall of '" + cpvr + "' aborted by hook");
}
on_uninstall_all_post();
- _imp->env->perform_hook(Hook("uninstall_all_post")("TARGETS", join(_imp->raw_targets.begin(),
- _imp->raw_targets.end(), " ")));
+ if (0 !=
+ _imp->env->perform_hook(Hook("uninstall_all_post")("TARGETS", join(_imp->raw_targets.begin(),
+ _imp->raw_targets.end(), " "))))
+ throw PackageUninstallActionError("Uninstall aborted by hook");
}
AmbiguousUnmergeTargetError::~AmbiguousUnmergeTargetError() throw ()