aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-04-02 17:55:13 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-04-02 17:55:13 +0000
commit872d0977cd9734c9637b9d7ea21433a714af7b7d (patch)
treedf6ef7268652b58675700140052201dbaec0322f
parent9aee67a0c625acdce2ac8483e77bc33f124a7f20 (diff)
downloadpaludis-872d0977cd9734c9637b9d7ea21433a714af7b7d.tar.gz
paludis-872d0977cd9734c9637b9d7ea21433a714af7b7d.tar.xz
Allow repositories to define hooks
-rw-r--r--paludis/hooker.cc20
-rw-r--r--paludis/repositories/cran/cran_installed_repository.cc3
-rw-r--r--paludis/repositories/cran/cran_repository.cc3
-rw-r--r--paludis/repositories/fake/fake_installed_repository.cc3
-rw-r--r--paludis/repositories/fake/fake_repository.cc3
-rw-r--r--paludis/repositories/gems/gems_repository.cc3
-rw-r--r--paludis/repositories/gentoo/portage_repository.cc12
-rw-r--r--paludis/repositories/gentoo/portage_repository.hh4
-rw-r--r--paludis/repositories/gentoo/vdb_repository.cc12
-rw-r--r--paludis/repositories/gentoo/vdb_repository.hh4
-rw-r--r--paludis/repositories/virtuals/installed_virtuals_repository.cc12
-rw-r--r--paludis/repositories/virtuals/installed_virtuals_repository.hh4
-rw-r--r--paludis/repositories/virtuals/virtuals_repository.cc3
-rw-r--r--paludis/repository.cc4
-rw-r--r--paludis/repository.hh21
-rw-r--r--paludis/repository.sr1
16 files changed, 98 insertions, 14 deletions
diff --git a/paludis/hooker.cc b/paludis/hooker.cc
index 9ad8b9d..df10811 100644
--- a/paludis/hooker.cc
+++ b/paludis/hooker.cc
@@ -68,17 +68,27 @@ Hooker::add_dir(const FSEntry & dir, const bool v)
int
Hooker::perform_hook(const Hook & hook) const
{
+ int max_exit_status(0);
+
+ Context context("When triggering hook '" + hook.name() + "'");
+ Log::get_instance()->message(ll_debug, lc_no_context, "Starting hook '" + hook.name() + "'");
+
+ /* repo hooks first */
+
+ for (PackageDatabase::RepositoryIterator r(_imp->env->package_database()->begin_repositories()),
+ r_end(_imp->env->package_database()->end_repositories()) ; r != r_end ; ++r)
+ if ((*r)->hook_interface)
+ max_exit_status = std::max(max_exit_status, ((*r)->hook_interface->perform_hook(hook)));
+
+ /* file hooks, but only if necessary */
+
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 0;
-
- Context context("When triggering hook '" + hook.name() + "'");
- Log::get_instance()->message(ll_debug, lc_no_context, "Starting hook '" + hook.name() + "'");
+ return max_exit_status;
bool had_hook(false);
- int max_exit_status(0);
for (std::list<std::pair<FSEntry, bool> >::const_iterator h(_imp->dirs.begin()), h_end(_imp->dirs.end()) ;
h != h_end ; ++h)
{
diff --git a/paludis/repositories/cran/cran_installed_repository.cc b/paludis/repositories/cran/cran_installed_repository.cc
index 68845cd..ec79333 100644
--- a/paludis/repositories/cran/cran_installed_repository.cc
+++ b/paludis/repositories/cran/cran_installed_repository.cc
@@ -187,7 +187,8 @@ CRANInstalledRepository::CRANInstalledRepository(const CRANInstalledRepositoryPa
.config_interface(0)
.destination_interface(this)
.licenses_interface(0)
- .portage_interface(0),
+ .portage_interface(0)
+ .hook_interface(0),
"cran_installed"),
PrivateImplementationPattern<CRANInstalledRepository>(new Implementation<CRANInstalledRepository>(p))
{
diff --git a/paludis/repositories/cran/cran_repository.cc b/paludis/repositories/cran/cran_repository.cc
index 79db20f..cda4c1e 100644
--- a/paludis/repositories/cran/cran_repository.cc
+++ b/paludis/repositories/cran/cran_repository.cc
@@ -181,7 +181,8 @@ CRANRepository::CRANRepository(const CRANRepositoryParams & p) :
.config_interface(0)
.contents_interface(0)
.licenses_interface(0)
- .portage_interface(0),
+ .portage_interface(0)
+ .hook_interface(0),
"cran"),
PrivateImplementationPattern<CRANRepository>(new Implementation<CRANRepository>(p))
{
diff --git a/paludis/repositories/fake/fake_installed_repository.cc b/paludis/repositories/fake/fake_installed_repository.cc
index 4716473..d7c85cb 100644
--- a/paludis/repositories/fake/fake_installed_repository.cc
+++ b/paludis/repositories/fake/fake_installed_repository.cc
@@ -44,7 +44,8 @@ FakeInstalledRepository::FakeInstalledRepository(const Environment * const e, co
.config_interface(0)
.destination_interface(this)
.licenses_interface(0)
- .portage_interface(0),
+ .portage_interface(0)
+ .hook_interface(0),
"fake_installed")
{
}
diff --git a/paludis/repositories/fake/fake_repository.cc b/paludis/repositories/fake/fake_repository.cc
index 3e338e4..0dc7c8c 100644
--- a/paludis/repositories/fake/fake_repository.cc
+++ b/paludis/repositories/fake/fake_repository.cc
@@ -42,7 +42,8 @@ FakeRepository::FakeRepository(const Environment * const e, const RepositoryName
.config_interface(0)
.destination_interface(0)
.licenses_interface(0)
- .portage_interface(0),
+ .portage_interface(0)
+ .hook_interface(0),
"fake"),
_virtual_packages(new VirtualsCollection::Concrete)
{
diff --git a/paludis/repositories/gems/gems_repository.cc b/paludis/repositories/gems/gems_repository.cc
index 1c56637..7aa912a 100644
--- a/paludis/repositories/gems/gems_repository.cc
+++ b/paludis/repositories/gems/gems_repository.cc
@@ -257,7 +257,8 @@ GemsRepository::GemsRepository(const GemsRepositoryParams & p) :
.config_interface(0)
.destination_interface(0)
.licenses_interface(0)
- .portage_interface(0),
+ .portage_interface(0)
+ .hook_interface(0),
"gems"),
PrivateImplementationPattern<GemsRepository>(new Implementation<GemsRepository>(p))
{
diff --git a/paludis/repositories/gentoo/portage_repository.cc b/paludis/repositories/gentoo/portage_repository.cc
index 01ba59b..12496ba 100644
--- a/paludis/repositories/gentoo/portage_repository.cc
+++ b/paludis/repositories/gentoo/portage_repository.cc
@@ -290,7 +290,8 @@ PortageRepository::PortageRepository(const PortageRepositoryParams & p) :
.config_interface(0)
.destination_interface(p.enable_destinations ? this : 0)
.licenses_interface(this)
- .portage_interface(this),
+ .portage_interface(this)
+ .hook_interface(this),
p.entry_format),
PrivateImplementationPattern<PortageRepository>(new Implementation<PortageRepository>(this, p))
{
@@ -1288,3 +1289,12 @@ PortageRepository::merge(const MergeOptions & o)
_imp->entries_ptr->merge(o);
}
+int
+PortageRepository::perform_hook(const Hook & hook) const
+{
+ Context context("When performing hook '" + stringify(hook.name()) + "' for repository '"
+ + stringify(name()) + "':");
+
+ return 0;
+}
+
diff --git a/paludis/repositories/gentoo/portage_repository.hh b/paludis/repositories/gentoo/portage_repository.hh
index 02e7c49..7c8ec64 100644
--- a/paludis/repositories/gentoo/portage_repository.hh
+++ b/paludis/repositories/gentoo/portage_repository.hh
@@ -60,6 +60,7 @@ namespace paludis
public RepositoryDestinationInterface,
public RepositoryLicensesInterface,
public RepositoryPortageInterface,
+ public RepositoryHookInterface,
private PrivateImplementationPattern<PortageRepository>
{
private:
@@ -189,6 +190,9 @@ namespace paludis
void set_profile_by_arch(const UseFlagName &);
///\}
+
+ int perform_hook(const Hook &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
};
}
diff --git a/paludis/repositories/gentoo/vdb_repository.cc b/paludis/repositories/gentoo/vdb_repository.cc
index d2aadf3..99dbd08 100644
--- a/paludis/repositories/gentoo/vdb_repository.cc
+++ b/paludis/repositories/gentoo/vdb_repository.cc
@@ -527,7 +527,8 @@ VDBRepository::VDBRepository(const VDBRepositoryParams & p) :
.config_interface(this)
.contents_interface(this)
.licenses_interface(0)
- .portage_interface(0),
+ .portage_interface(0)
+ .hook_interface(this),
"vdb"),
PrivateImplementationPattern<VDBRepository>(new Implementation<VDBRepository>(this, p))
{
@@ -1681,3 +1682,12 @@ VDBRepository::merge(const MergeOptions & m)
post_merge_command();
}
+int
+VDBRepository::perform_hook(const Hook & hook) const
+{
+ Context context("When performing hook '" + stringify(hook.name()) + "' for repository '"
+ + stringify(name()) + "':");
+
+ return 0;
+}
+
diff --git a/paludis/repositories/gentoo/vdb_repository.hh b/paludis/repositories/gentoo/vdb_repository.hh
index 9271f30..c0f186c 100644
--- a/paludis/repositories/gentoo/vdb_repository.hh
+++ b/paludis/repositories/gentoo/vdb_repository.hh
@@ -56,6 +56,7 @@ namespace paludis
public RepositoryDestinationInterface,
public RepositoryContentsInterface,
public RepositoryConfigInterface,
+ public RepositoryHookInterface,
public PrivateImplementationPattern<VDBRepository>
{
private:
@@ -175,6 +176,9 @@ namespace paludis
const PackageDatabaseEntry * const) const;
virtual FSEntry root() const;
+
+ int perform_hook(const Hook &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
};
/**
diff --git a/paludis/repositories/virtuals/installed_virtuals_repository.cc b/paludis/repositories/virtuals/installed_virtuals_repository.cc
index 337ee79..fa28eda 100644
--- a/paludis/repositories/virtuals/installed_virtuals_repository.cc
+++ b/paludis/repositories/virtuals/installed_virtuals_repository.cc
@@ -102,7 +102,8 @@ InstalledVirtualsRepository::InstalledVirtualsRepository(const Environment * con
.config_interface(0)
.destination_interface(0)
.licenses_interface(0)
- .portage_interface(0),
+ .portage_interface(0)
+ .hook_interface(this),
"installed_virtuals"),
PrivateImplementationPattern<InstalledVirtualsRepository>(
new Implementation<InstalledVirtualsRepository>(env, r))
@@ -335,3 +336,12 @@ InstalledVirtualsRepository::root() const
return _imp->root;
}
+int
+InstalledVirtualsRepository::perform_hook(const Hook & hook) const
+{
+ Context context("When performing hook '" + stringify(hook.name()) + "' for repository '"
+ + stringify(name()) + "':");
+
+ return 0;
+}
+
diff --git a/paludis/repositories/virtuals/installed_virtuals_repository.hh b/paludis/repositories/virtuals/installed_virtuals_repository.hh
index b901e1d..b21fdb7 100644
--- a/paludis/repositories/virtuals/installed_virtuals_repository.hh
+++ b/paludis/repositories/virtuals/installed_virtuals_repository.hh
@@ -33,6 +33,7 @@ namespace paludis
public Repository,
public RepositoryInstalledInterface,
public RepositoryMaskInterface,
+ public RepositoryHookInterface,
private PrivateImplementationPattern<InstalledVirtualsRepository>
{
private:
@@ -90,6 +91,9 @@ namespace paludis
}
virtual FSEntry root() const;
+
+ int perform_hook(const Hook &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
};
}
diff --git a/paludis/repositories/virtuals/virtuals_repository.cc b/paludis/repositories/virtuals/virtuals_repository.cc
index 7d2e810..21a5d09 100644
--- a/paludis/repositories/virtuals/virtuals_repository.cc
+++ b/paludis/repositories/virtuals/virtuals_repository.cc
@@ -93,7 +93,8 @@ VirtualsRepository::VirtualsRepository(const Environment * const env) :
.config_interface(0)
.contents_interface(0)
.licenses_interface(0)
- .portage_interface(0),
+ .portage_interface(0)
+ .hook_interface(0),
"virtuals"),
PrivateImplementationPattern<VirtualsRepository>(
new Implementation<VirtualsRepository>(env))
diff --git a/paludis/repository.cc b/paludis/repository.cc
index 61e2aac..299162b 100644
--- a/paludis/repository.cc
+++ b/paludis/repository.cc
@@ -330,3 +330,7 @@ RepositoryPortageInterface::~RepositoryPortageInterface()
{
}
+RepositoryHookInterface::~RepositoryHookInterface()
+{
+}
+
diff --git a/paludis/repository.hh b/paludis/repository.hh
index e5012dd..817cda8 100644
--- a/paludis/repository.hh
+++ b/paludis/repository.hh
@@ -48,6 +48,7 @@ namespace paludis
class Environment;
class RepositoryNameCache;
class PortageRepositoryProfile;
+ class Hook;
class Repository;
class RepositoryInstallableInterface;
@@ -68,6 +69,7 @@ namespace paludis
class RepositoryConfigInterface;
class RepositoryLicensesInterface;
class RepositoryPortageInterface;
+ class RepositoryHookInterface;
/**
* A set of destinations.
@@ -1235,6 +1237,25 @@ namespace paludis
};
/**
+ * Interface for handling hooks.
+ *
+ * \see Repository
+ * \ingroup grprepository
+ * \nosubgrouping
+ */
+ class RepositoryHookInterface
+ {
+ public:
+ /**
+ * Perform a hook, and return the highest exit status.
+ */
+ virtual int perform_hook(const Hook & hook) const
+ PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
+
+ virtual ~RepositoryHookInterface();
+ };
+
+ /**
* Parent class for install, uninstall errors.
*
* \ingroup grpexceptions
diff --git a/paludis/repository.sr b/paludis/repository.sr
index 8c53299..11e42a6 100644
--- a/paludis/repository.sr
+++ b/paludis/repository.sr
@@ -53,6 +53,7 @@ make_class_RepositoryCapabilities()
key config_interface "RepositoryConfigInterface *"
key licenses_interface "RepositoryLicensesInterface *"
key portage_interface "RepositoryPortageInterface *"
+ key hook_interface "RepositoryHookInterface *"
doxygen_comment << "END"
/**