aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-06-06 00:34:27 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-06-06 00:34:27 +0000
commit219cc6e7ad10343e1c0882896d3f82b2784f1e01 (patch)
tree0ce8e55185684e1ec499bf740e6d3ec629ad1d47
parentcb7bbe54e8dc5f1c6ea19f09d1ccc0f442cd7d5c (diff)
downloadpaludis-219cc6e7ad10343e1c0882896d3f82b2784f1e01.tar.gz
paludis-219cc6e7ad10343e1c0882896d3f82b2784f1e01.tar.xz
Switch to a new capabilities interface for repositories.
-rw-r--r--paludis/default_environment.cc30
-rw-r--r--paludis/dep_list.cc20
-rw-r--r--paludis/environment.cc63
-rw-r--r--paludis/fake_repository.cc47
-rw-r--r--paludis/fake_repository.hh34
-rw-r--r--paludis/match_package.cc4
-rw-r--r--paludis/package_database.cc56
-rw-r--r--paludis/package_database.hh10
-rw-r--r--paludis/portage_repository.cc25
-rw-r--r--paludis/portage_repository.hh25
-rw-r--r--paludis/portage_repository_TEST.cc12
-rw-r--r--paludis/repository.cc7
-rw-r--r--paludis/repository.hh412
-rw-r--r--paludis/vdb_repository.cc39
-rw-r--r--paludis/vdb_repository.hh19
-rw-r--r--src/contents.cc15
-rw-r--r--src/install.cc28
-rw-r--r--src/news.cc3
-rw-r--r--src/owner.cc5
-rw-r--r--src/query.cc8
-rw-r--r--src/sync.cc2
-rw-r--r--src/uninstall.cc8
22 files changed, 513 insertions, 359 deletions
diff --git a/paludis/default_environment.cc b/paludis/default_environment.cc
index ee1b328..6f14744 100644
--- a/paludis/default_environment.cc
+++ b/paludis/default_environment.cc
@@ -54,10 +54,14 @@ bool
DefaultEnvironment::query_use(const UseFlagName & f, const PackageDatabaseEntry * e) const
{
/* first check package database use masks... */
- if (e ? package_database()->fetch_repository(e->get<pde_repository>())->query_use_mask(f, e) :
- package_database()->fetch_repository(
- package_database()->favourite_repository())->query_use_mask(f, e))
- return false;
+ const Repository * const repo((e ?
+ package_database()->fetch_repository(e->get<pde_repository>()) :
+ package_database()->fetch_repository(package_database()->favourite_repository())
+ ).raw_pointer());
+
+ if (repo->get_interface<repo_use>())
+ if (repo->get_interface<repo_use>()->query_use_mask(f, e))
+ return false;
/* check use: per package user config */
if (e)
@@ -137,16 +141,16 @@ DefaultEnvironment::query_use(const UseFlagName & f, const PackageDatabaseEntry
} while (false);
/* check use: package database config */
- switch (e ? package_database()->fetch_repository(e->get<pde_repository>())->query_use(f, e) :
- package_database()->fetch_repository(package_database()->favourite_repository())->query_use(f, e))
- {
- case use_disabled:
- case use_unspecified:
- return false;
+ if (repo->get_interface<repo_use>())
+ switch (repo->get_interface<repo_use>()->query_use(f, e))
+ {
+ case use_disabled:
+ case use_unspecified:
+ return false;
- case use_enabled:
- return true;
- }
+ case use_enabled:
+ return true;
+ }
throw InternalError(PALUDIS_HERE, "bad state");
}
diff --git a/paludis/dep_list.cc b/paludis/dep_list.cc
index d39221f..88aff01 100644
--- a/paludis/dep_list.cc
+++ b/paludis/dep_list.cc
@@ -181,9 +181,9 @@ DepList::add(DepAtom::ConstPointer atom)
{
Save<const DepListEntry *> save_current_package(
&_imp->current_package, &*i);
- _add_in_role(_imp->environment->package_database()->fetch_metadata(
- PackageDatabaseEntry(i->get<dle_name>(), i->get<dle_version>(),
- i->get<dle_repository>()))->get<vm_deps>().run_depend(),
+ _add_in_role(_imp->environment->package_database()->fetch_repository(
+ i->get<dle_repository>())->version_metadata(
+ i->get<dle_name>(), i->get<dle_version>())->get<vm_deps>().run_depend(),
"runtime dependencies");
i->get<dle_flags>().set(dlef_has_trypredeps);
}
@@ -192,9 +192,9 @@ DepList::add(DepAtom::ConstPointer atom)
{
Save<const DepListEntry *> save_current_package(
&_imp->current_package, &*i);
- _add_in_role(_imp->environment->package_database()->fetch_metadata(
- PackageDatabaseEntry(i->get<dle_name>(), i->get<dle_version>(),
- i->get<dle_repository>()))->get<vm_deps>().post_depend(),
+ _add_in_role(_imp->environment->package_database()->fetch_repository(
+ i->get<dle_repository>())->version_metadata(
+ i->get<dle_name>(), i->get<dle_version>())->get<vm_deps>().post_depend(),
"post dependencies");
i->get<dle_flags>().set(dlef_has_postdeps);
}
@@ -392,7 +392,8 @@ DepList::visit(const PackageDepAtom * const p)
if (_imp->environment->mask_reasons(*e).any())
continue;
- metadata = _imp->environment->package_database()->fetch_metadata(*e);
+ metadata = _imp->environment->package_database()->fetch_repository(
+ e->get<pde_repository>())->version_metadata(e->get<pde_name>(), e->get<pde_version>());
match = &*e;
break;
}
@@ -407,8 +408,9 @@ DepList::visit(const PackageDepAtom * const p)
{
if (_imp->recursive_deps)
{
- metadata = _imp->environment->package_database()->fetch_metadata(
- *installed->last());
+ metadata = _imp->environment->package_database()->fetch_repository(
+ installed->last()->get<pde_repository>())->version_metadata(
+ installed->last()->get<pde_name>(), installed->last()->get<pde_version>());
DepListEntryFlags flags;
flags.set(dlef_has_predeps);
flags.set(dlef_skip);
diff --git a/paludis/environment.cc b/paludis/environment.cc
index 0fe8d6e..d024430 100644
--- a/paludis/environment.cc
+++ b/paludis/environment.cc
@@ -125,7 +125,8 @@ Environment::mask_reasons(const PackageDatabaseEntry & e) const
Context context("When checking mask reasons for '" + stringify(e) + "'");
MaskReasons result;
- VersionMetadata::ConstPointer metadata(package_database()->fetch_metadata(e));
+ VersionMetadata::ConstPointer metadata(package_database()->fetch_repository(
+ e.get<pde_repository>())->version_metadata(e.get<pde_name>(), e.get<pde_version>()));
if (metadata->get<vm_eapi>() != "0" && metadata->get<vm_eapi>() != ""
&& metadata->get<vm_eapi>() != "paludis-1")
@@ -178,27 +179,33 @@ Environment::mask_reasons(const PackageDatabaseEntry & e) const
if (query_user_masks(e))
result.set(mr_user_mask);
- if (package_database()->fetch_repository(e.get<pde_repository>())->query_profile_masks(e.get<pde_name>(),
- e.get<pde_version>()))
- result.set(mr_profile_mask);
+ const Repository * const repo(package_database()->fetch_repository(
+ e.get<pde_repository>()).raw_pointer());
- if (package_database()->fetch_repository(e.get<pde_repository>())->query_repository_masks(e.get<pde_name>(),
- e.get<pde_version>()))
- result.set(mr_repository_mask);
+ if (repo->get_interface<repo_mask>())
+ {
+ if (repo->get_interface<repo_mask>()->query_profile_masks(e.get<pde_name>(),
+ e.get<pde_version>()))
+ result.set(mr_profile_mask);
- if (metadata->get_ebuild_interface())
- if (! metadata->get_ebuild_interface()->get<evm_virtual>().empty())
- {
- QualifiedPackageName n(metadata->get_ebuild_interface()->get<evm_virtual>());
+ if (repo->get_interface<repo_mask>()->query_repository_masks(e.get<pde_name>(),
+ e.get<pde_version>()))
+ result.set(mr_repository_mask);
+
+ if (metadata->get_ebuild_interface())
+ if (! metadata->get_ebuild_interface()->get<evm_virtual>().empty())
+ {
+ QualifiedPackageName n(metadata->get_ebuild_interface()->get<evm_virtual>());
- if (package_database()->fetch_repository(e.get<pde_repository>())->query_profile_masks(n,
- e.get<pde_version>()))
- result.set(mr_profile_mask);
+ if (repo->get_interface<repo_mask>()->query_profile_masks(n,
+ e.get<pde_version>()))
+ result.set(mr_profile_mask);
- if (package_database()->fetch_repository(e.get<pde_repository>())->query_repository_masks(n,
- e.get<pde_version>()))
- result.set(mr_repository_mask);
- }
+ if (repo->get_interface<repo_mask>()->query_repository_masks(n,
+ e.get<pde_version>()))
+ result.set(mr_repository_mask);
+ }
+ }
}
}
@@ -215,7 +222,7 @@ Environment::begin_provide_map() const
for (PackageDatabase::RepositoryIterator r(package_database()->begin_repositories()),
r_end(package_database()->end_repositories()) ; r != r_end ; ++r)
{
- if (! (*r)->installed())
+ if (! (*r)->get_interface<repo_installed>())
continue;
std::copy((*r)->begin_provide_map(), (*r)->end_provide_map(),
@@ -245,13 +252,16 @@ Environment::package_set(const std::string & s) const
r_end(package_database()->end_repositories()) ;
r != r_end ; ++r)
{
- DepAtom::Pointer add((*r)->package_set(s));
+ if (! (*r)->get_interface<repo_sets>())
+ continue;
+
+ DepAtom::Pointer add((*r)->get_interface<repo_sets>()->package_set(s));
if (0 != add)
result->add_child(add);
if ("system" != s)
{
- add = (*r)->package_set("system");
+ add = (*r)->get_interface<repo_sets>()->package_set("system");
if (0 != add)
result->add_child(add);
}
@@ -269,7 +279,10 @@ Environment::package_set(const std::string & s) const
r_end(package_database()->end_repositories()) ;
r != r_end ; ++r)
{
- DepAtom::Pointer result((*r)->package_set(s));
+ if (! (*r)->get_interface<repo_sets>())
+ continue;
+
+ DepAtom::Pointer result((*r)->get_interface<repo_sets>()->package_set(s));
if (0 != result)
return result;
}
@@ -339,7 +352,8 @@ Environment::add_appropriate_to_world(DepAtom::ConstPointer a) const
for (PackageDatabase::RepositoryIterator r(package_database()->begin_repositories()),
r_end(package_database()->end_repositories()) ;
r != r_end ; ++r)
- (*r)->add_to_world((*i)->package());
+ if ((*r)->get_interface<repo_world>())
+ (*r)->get_interface<repo_world>()->add_to_world((*i)->package());
}
}
}
@@ -355,7 +369,8 @@ Environment::remove_appropriate_from_world(DepAtom::ConstPointer a) const
for (PackageDatabase::RepositoryIterator r(package_database()->begin_repositories()),
r_end(package_database()->end_repositories()) ;
r != r_end ; ++r)
- (*r)->remove_from_world((*i)->package());
+ if ((*r)->get_interface<repo_world>())
+ (*r)->get_interface<repo_world>()->remove_from_world((*i)->package());
}
}
diff --git a/paludis/fake_repository.cc b/paludis/fake_repository.cc
index 4b4e9a5..4c5268c 100644
--- a/paludis/fake_repository.cc
+++ b/paludis/fake_repository.cc
@@ -67,7 +67,19 @@ namespace paludis
}
FakeRepository::FakeRepository(const RepositoryName & name) :
- Repository(name),
+ Repository(name, RepositoryCapabilities::create((
+ param<repo_installable>(static_cast<InstallableInterface *>(0)),
+ param<repo_installed>(static_cast<InstalledInterface *>(0)),
+ param<repo_mask>(this),
+ param<repo_news>(static_cast<NewsInterface *>(0)),
+ param<repo_sets>(static_cast<SetsInterface *>(0)),
+ param<repo_syncable>(static_cast<SyncableInterface *>(0)),
+ param<repo_uninstallable>(static_cast<UninstallableInterface *>(0)),
+ param<repo_use>(this),
+ param<repo_world>(static_cast<WorldInterface *>(0))
+ ))),
+ Repository::MaskInterface(),
+ Repository::UseInterface(),
PrivateImplementationPattern<FakeRepository>(new Implementation<FakeRepository>)
{
_info.insert(std::make_pair(std::string("format"), std::string("fake")));
@@ -170,15 +182,6 @@ FakeRepository::do_version_metadata(
return _imp->metadata.find(stringify(q) + "-" + stringify(v))->second;
}
-Contents::ConstPointer
-FakeRepository::do_contents(
- const QualifiedPackageName & q, const VersionSpec & v) const
-{
- if (! has_version(q, v))
- throw InternalError(PALUDIS_HERE, "no version");
- return Contents::Pointer(new Contents);
-}
-
bool
FakeRepository::do_query_repository_masks(const QualifiedPackageName &,
const VersionSpec &) const
@@ -235,30 +238,6 @@ FakeRepository::do_is_mirror(const std::string &) const
}
void
-FakeRepository::do_install(const QualifiedPackageName &, const VersionSpec &, const InstallOptions &) const
-{
-}
-
-void
-FakeRepository::do_uninstall(const QualifiedPackageName &, const VersionSpec &, const InstallOptions &) const
-{
-}
-
-DepAtom::Pointer
-FakeRepository::do_package_set(const std::string &) const
-{
- AllDepAtom::Pointer result(0);
-
- return result;
-}
-
-bool
-FakeRepository::do_sync() const
-{
- return false;
-}
-
-void
FakeRepository::invalidate() const
{
}
diff --git a/paludis/fake_repository.hh b/paludis/fake_repository.hh
index c38d44c..b798fe8 100644
--- a/paludis/fake_repository.hh
+++ b/paludis/fake_repository.hh
@@ -37,8 +37,11 @@ namespace paludis
*
* \ingroup grpfakerepository
*/
- class FakeRepository : public Repository,
- private PrivateImplementationPattern<FakeRepository>
+ class FakeRepository :
+ public Repository,
+ public Repository::MaskInterface,
+ public Repository::UseInterface,
+ private PrivateImplementationPattern<FakeRepository>
{
protected:
virtual bool do_has_category_named(const CategoryNamePart &) const;
@@ -60,10 +63,6 @@ namespace paludis
const QualifiedPackageName &,
const VersionSpec &) const;
- virtual Contents::ConstPointer do_contents(
- const QualifiedPackageName &,
- const VersionSpec &) const;
-
virtual bool do_query_repository_masks(const QualifiedPackageName &,
const VersionSpec &) const;
@@ -84,16 +83,6 @@ namespace paludis
virtual bool do_is_mirror(const std::string &) const;
- virtual void do_install(const QualifiedPackageName &, const VersionSpec &,
- const InstallOptions &) const;
-
- virtual void do_uninstall(const QualifiedPackageName &, const VersionSpec &,
- const InstallOptions &) const;
-
- virtual DepAtom::Pointer do_package_set(const std::string & s) const;
-
- virtual bool do_sync() const;
-
public:
/**
* Constructor.
@@ -144,24 +133,11 @@ namespace paludis
*/
typedef CountedPtr<const FakeRepository, count_policy::InternalCountTag> ConstPointer;
- virtual bool installed() const
- {
- return false;
- }
-
virtual void invalidate() const;
virtual ProvideMapIterator begin_provide_map() const;
virtual ProvideMapIterator end_provide_map() const;
-
- virtual void remove_from_world(const QualifiedPackageName &) const
- {
- }
-
- virtual void add_to_world(const QualifiedPackageName &) const
- {
- }
};
}
diff --git a/paludis/match_package.cc b/paludis/match_package.cc
index 88bd08a..60e5280 100644
--- a/paludis/match_package.cc
+++ b/paludis/match_package.cc
@@ -47,7 +47,9 @@ match_package_internals::do_match(
if (atom->slot_ptr() || atom->use_requirements_ptr())
{
- VersionMetadata::ConstPointer metadata(env->package_database()->fetch_metadata(*entry));
+ VersionMetadata::ConstPointer metadata(env->package_database()->fetch_repository(
+ entry->get<pde_repository>())->version_metadata(
+ entry->get<pde_name>(), entry->get<pde_version>()));
if (atom->slot_ptr())
if (*atom->slot_ptr() != SlotName(metadata->get<vm_slot>()))
diff --git a/paludis/package_database.cc b/paludis/package_database.cc
index e2e5a9b..ff74a65 100644
--- a/paludis/package_database.cc
+++ b/paludis/package_database.cc
@@ -117,45 +117,6 @@ PackageDatabase::add_repository(const Repository::ConstPointer r)
_imp->repositories.push_back(r);
}
-VersionMetadata::ConstPointer
-PackageDatabase::fetch_metadata(const PackageDatabaseEntry & e) const
-{
- const Repository::ConstPointer rr(fetch_repository(e.get<pde_repository>()));
- if (! rr->has_category_named(e.get<pde_name>().get<qpn_category>()))
- throw NoSuchPackageError(stringify(e.get<pde_name>()));
- if (! rr->has_package_named(e.get<pde_name>()))
- throw NoSuchPackageError(stringify(e.get<pde_name>()));
- if (! rr->has_version(e.get<pde_name>(), e.get<pde_version>()))
- throw NoSuchVersionError(stringify(e.get<pde_name>()), e.get<pde_version>());
- return rr->version_metadata(e.get<pde_name>(), e.get<pde_version>());
-}
-
-Contents::ConstPointer
-PackageDatabase::fetch_contents(const PackageDatabaseEntry & e) const
-{
- const Repository::ConstPointer rr(fetch_repository(e.get<pde_repository>()));
- if (! rr->has_category_named(e.get<pde_name>().get<qpn_category>()))
- throw NoSuchPackageError(stringify(e.get<pde_name>()));
- if (! rr->has_package_named(e.get<pde_name>()))
- throw NoSuchPackageError(stringify(e.get<pde_name>()));
- if (! rr->has_version(e.get<pde_name>(), e.get<pde_version>()))
- throw NoSuchVersionError(stringify(e.get<pde_name>()), e.get<pde_version>());
- return rr->contents(e.get<pde_name>(), e.get<pde_version>());
-}
-
-Repository::ConstPointer
-PackageDatabase::fetch_repository(const RepositoryName & n) const
-{
- std::list<Repository::ConstPointer>::const_iterator
- r(_imp->repositories.begin()),
- r_end(_imp->repositories.end());
- for ( ; r != r_end ; ++r)
- if ((*r)->name() == n)
- return *r;
-
- throw NoSuchRepositoryError(stringify(n));
-}
-
QualifiedPackageName
PackageDatabase::fetch_unique_qualified_package_name(
const PackageNamePart & p) const
@@ -192,10 +153,10 @@ PackageDatabase::_do_query(const PackageDepAtom & a, const InstallState installe
r_end(_imp->repositories.end());
for ( ; r != r_end ; ++r)
{
- if ((installed_state == is_installed_only) && ! r->installed())
+ if ((installed_state == is_installed_only) && ! r->get_interface<repo_installed>())
continue;
- if ((installed_state == is_uninstalled_only) && r->installed())
+ if ((installed_state == is_uninstalled_only) && r->get_interface<repo_installed>())
continue;
if (! r->has_category_named(a.package().get<qpn_category>()))
@@ -225,6 +186,19 @@ PackageDatabase::query(const PackageDepAtom & a, const InstallState s) const
return _do_query(a, s);
}
+Repository::ConstPointer
+PackageDatabase::fetch_repository(const RepositoryName & n) const
+{
+ std::list<Repository::ConstPointer>::const_iterator
+ r(_imp->repositories.begin()),
+ r_end(_imp->repositories.end());
+ for ( ; r != r_end ; ++r)
+ if ((*r)->name() == n)
+ return *r;
+
+ throw NoSuchRepositoryError(stringify(n));
+}
+
const RepositoryName &
PackageDatabase::better_repository(const RepositoryName & r1,
const RepositoryName & r2) const
diff --git a/paludis/package_database.hh b/paludis/package_database.hh
index f737db6..00faf84 100644
--- a/paludis/package_database.hh
+++ b/paludis/package_database.hh
@@ -284,16 +284,6 @@ namespace paludis
void add_repository(Repository::ConstPointer);
/**
- * Fetch the version metadata for a particular item.
- */
- VersionMetadata::ConstPointer fetch_metadata(const PackageDatabaseEntry &) const;
-
- /**
- * Fetch the contents for a particular item.
- */
- Contents::ConstPointer fetch_contents(const PackageDatabaseEntry &) const;
-
- /**
* Fetch a named repository.
*/
Repository::ConstPointer fetch_repository(const RepositoryName &) const;
diff --git a/paludis/portage_repository.cc b/paludis/portage_repository.cc
index 243ff76..4426922 100644
--- a/paludis/portage_repository.cc
+++ b/paludis/portage_repository.cc
@@ -527,7 +527,18 @@ Implementation<PortageRepository>::invalidate() const
}
PortageRepository::PortageRepository(const PortageRepositoryParams & p) :
- Repository(PortageRepository::fetch_repo_name(stringify(p.get<prpk_location>()))),
+ Repository(PortageRepository::fetch_repo_name(stringify(p.get<prpk_location>())),
+ RepositoryCapabilities::create((
+ param<repo_mask>(this),
+ param<repo_installable>(this),
+ param<repo_installed>(static_cast<InstalledInterface *>(0)),
+ param<repo_news>(this),
+ param<repo_sets>(this),
+ param<repo_syncable>(this),
+ param<repo_uninstallable>(static_cast<UninstallableInterface *>(0)),
+ param<repo_use>(this),
+ param<repo_world>(static_cast<WorldInterface *>(0))
+ ))),
PrivateImplementationPattern<PortageRepository>(new Implementation<PortageRepository>(p))
{
_info.insert(std::make_pair(std::string("location"), stringify(_imp->location)));
@@ -1587,13 +1598,15 @@ PortageRepository::find_best(PackageDatabaseEntryCollection::Pointer & c, const
stringify(e.get<pde_version>()) + "':");
// Find an entry in c that matches e best. e is not in c.
QualifiedPackageName n(e.get<pde_name>());
- SlotName s(_imp->env->package_database()->fetch_metadata(e)->get<vm_slot>());
+ SlotName s(_imp->env->package_database()->fetch_repository(e.get<pde_repository>())->version_metadata(
+ e.get<pde_name>(), e.get<pde_version>())->get<vm_slot>());
PackageDatabaseEntryCollection::Iterator i(c->begin()), i_end(c->end()), i_best(c->end());
for ( ; i != i_end; ++i)
{
if (n != i->get<pde_name>())
continue;
- if (s != _imp->env->package_database()->fetch_metadata(*i)->get<vm_slot>())
+ if (s != _imp->env->package_database()->fetch_repository(i->get<pde_repository>())->version_metadata(
+ i->get<pde_name>(), i->get<pde_version>())->get<vm_slot>())
continue;
i_best = i;
@@ -1801,12 +1814,6 @@ PortageRepository::do_sync() const
}
void
-PortageRepository::do_uninstall(const QualifiedPackageName &, const VersionSpec &, const InstallOptions &) const
-{
- throw PackageUninstallActionError("PortageRepository doesn't support do_uninstall");
-}
-
-void
PortageRepository::invalidate() const
{
_imp->invalidate();
diff --git a/paludis/portage_repository.hh b/paludis/portage_repository.hh
index 9960c7c..8e1d41f 100644
--- a/paludis/portage_repository.hh
+++ b/paludis/portage_repository.hh
@@ -102,8 +102,15 @@ namespace paludis
*
* \ingroup grpportagerepository
*/
- class PortageRepository : public Repository,
- private PrivateImplementationPattern<PortageRepository>
+ class PortageRepository :
+ public Repository,
+ public Repository::MaskInterface,
+ public Repository::UseInterface,
+ public Repository::InstallableInterface,
+ public Repository::SyncableInterface,
+ public Repository::NewsInterface,
+ public Repository::SetsInterface,
+ private PrivateImplementationPattern<PortageRepository>
{
private:
void need_category_names() const;
@@ -164,9 +171,6 @@ namespace paludis
virtual void do_install(const QualifiedPackageName &, const VersionSpec &,
const InstallOptions &) const;
- virtual void do_uninstall(const QualifiedPackageName &,
- const VersionSpec &, const InstallOptions &) const PALUDIS_ATTRIBUTE((noreturn));
-
virtual DepAtom::Pointer do_package_set(const std::string & s) const;
virtual bool do_sync() const;
@@ -201,15 +205,10 @@ namespace paludis
virtual ProvideMapIterator end_provide_map() const;
- virtual void add_to_world(const QualifiedPackageName &) const
- {
- }
-
- virtual void remove_from_world(const QualifiedPackageName &) const
- {
- }
-
virtual void update_news() const;
+
+ typedef CountedPtr<PortageRepository, count_policy::InternalCountTag> Pointer;
+ typedef CountedPtr<const PortageRepository, count_policy::InternalCountTag> ConstPointer;
};
/**
diff --git a/paludis/portage_repository_TEST.cc b/paludis/portage_repository_TEST.cc
index 08eb993..66e7bed 100644
--- a/paludis/portage_repository_TEST.cc
+++ b/paludis/portage_repository_TEST.cc
@@ -588,10 +588,14 @@ namespace test_cases
{
TestMessageSuffix pass_suffix(stringify(pass), true);
- PackageDatabaseEntry p1(QualifiedPackageName("cat-one/pkg-one"), VersionSpec("1"), RepositoryName("test-repo-9"));
- PackageDatabaseEntry p2(QualifiedPackageName("cat-two/pkg-two"), VersionSpec("1"), RepositoryName("test-repo-9"));
- PackageDatabaseEntry p3(QualifiedPackageName("cat-one/pkg-none"), VersionSpec("1"), RepositoryName("test-repo-9"));
- PackageDatabaseEntry p4(QualifiedPackageName("cat-one/pkg-one"), VersionSpec("2"), RepositoryName("test-repo-9"));
+ PackageDatabaseEntry p1(QualifiedPackageName("cat-one/pkg-one"), VersionSpec("1"),
+ RepositoryName("test-repo-9"));
+ PackageDatabaseEntry p2(QualifiedPackageName("cat-two/pkg-two"), VersionSpec("1"),
+ RepositoryName("test-repo-9"));
+ PackageDatabaseEntry p3(QualifiedPackageName("cat-one/pkg-none"), VersionSpec("1"),
+ RepositoryName("test-repo-9"));
+ PackageDatabaseEntry p4(QualifiedPackageName("cat-one/pkg-one"), VersionSpec("2"),
+ RepositoryName("test-repo-9"));
TEST_CHECK(repo->query_use(UseFlagName("flag1"), &p1) == use_enabled);
TEST_CHECK(repo->query_use(UseFlagName("flag2"), &p1) == use_disabled);
diff --git a/paludis/repository.cc b/paludis/repository.cc
index 4f8c5af..ec9dc66 100644
--- a/paludis/repository.cc
+++ b/paludis/repository.cc
@@ -27,8 +27,11 @@
using namespace paludis;
-Repository::Repository(const RepositoryName & name) :
- _name(name)
+Repository::Repository(
+ const RepositoryName & name,
+ const RepositoryCapabilities & caps) :
+ _name(name),
+ _caps(caps)
{
}
diff --git a/paludis/repository.hh b/paludis/repository.hh
index dbf0b66..7adae2a 100644
--- a/paludis/repository.hh
+++ b/paludis/repository.hh
@@ -79,11 +79,30 @@ namespace paludis
typedef MakeSmartRecord<InstallOptionsTag>::Type InstallOptions;
/**
+ * Capability keys for a repository.
+ */
+ enum RepositoryCapabilitiesKeys
+ {
+ repo_installable,
+ repo_installed,
+ repo_mask,
+ repo_news,
+ repo_sets,
+ repo_syncable,
+ repo_uninstallable,
+ repo_use,
+ repo_world,
+ last_repo
+ };
+
+ /**
* A Repository provides a representation of a physical repository to a
* PackageDatabase.
*
* We make pretty heavy use of the non-virtual interface idiom here. See
- * \ref EffCpp items 35 and 37.
+ * \ref EffCpp items 35 and 37. There's a lot of optional functionality
+ * available. These are split off via get_interface() style functions,
+ * which return 0 if an interface is not available.
*
* \ingroup grprepository
*/
@@ -91,9 +110,53 @@ namespace paludis
private InstantiationPolicy<Repository, instantiation_method::NonCopyableTag>,
public InternalCounted<Repository>
{
+ public:
+ class InstallableInterface;
+ class InstalledInterface;
+ class MaskInterface;
+ class NewsInterface;
+ class SetsInterface;
+ class SyncableInterface;
+ class UninstallableInterface;
+ class UseInterface;
+ class WorldInterface;
+
+ protected:
+ /**
+ * Tag for RepositoryCapabilities.
+ *
+ * \see RepositoryCapabilities
+ * \ingroup grprepository
+ */
+ struct RepositoryCapabilitiesTag :
+ SmartRecordTag<comparison_mode::NoComparisonTag, void>,
+ SmartRecordKeys<RepositoryCapabilitiesKeys, last_repo>,
+ SmartRecordKey<repo_installable, InstallableInterface *>,
+ SmartRecordKey<repo_installed, InstalledInterface *>,
+ SmartRecordKey<repo_mask, MaskInterface *>,
+ SmartRecordKey<repo_news, NewsInterface *>,
+ SmartRecordKey<repo_sets, SetsInterface *>,
+ SmartRecordKey<repo_syncable, SyncableInterface *>,
+ SmartRecordKey<repo_uninstallable, UninstallableInterface *>,
+ SmartRecordKey<repo_use, UseInterface *>,
+ SmartRecordKey<repo_world, WorldInterface *>
+ {
+ };
+
+ /**
+ * Holds pointers to upcast ourself to different capability interfaces. Each entry
+ * is either a this pointer or a zero pointer.
+ *
+ * \see Repository
+ * \ingroup grprepository
+ */
+ typedef MakeSmartRecord<RepositoryCapabilitiesTag>::Type RepositoryCapabilities;
+
private:
const RepositoryName _name;
+ RepositoryCapabilities _caps;
+
protected:
/**
* Our repository information.
@@ -103,7 +166,10 @@ namespace paludis
/**
* Constructor.
*/
- Repository(const RepositoryName &);
+ Repository(const RepositoryName &, const RepositoryCapabilities &);
+
+ ///\name Implementations: naviagation functions
+ ///{
/**
* Override in descendents: fetch the metadata.
@@ -113,13 +179,6 @@ namespace paludis
const VersionSpec &) const = 0;
/**
- * Override in descendents: fetch the contents.
- */
- virtual Contents::ConstPointer do_contents(
- const QualifiedPackageName &,
- const VersionSpec &) const = 0;
-
- /**
* Override in descendents: check for a version.
*/
virtual bool do_has_version(const QualifiedPackageName &,
@@ -152,42 +211,10 @@ namespace paludis
*/
virtual bool do_has_category_named(const CategoryNamePart &) const = 0;
- /**
- * Override in descendents: check for a mask.
- */
- virtual bool do_query_repository_masks(const QualifiedPackageName &,
- const VersionSpec &) const = 0;
-
- /**
- * Override in descendents: check for a mask.
- */
- virtual bool do_query_profile_masks(const QualifiedPackageName &,
- const VersionSpec &) const = 0;
+ ///}
- /**
- * Override in descendents: get use.
- */
- virtual UseFlagState do_query_use(const UseFlagName &, const PackageDatabaseEntry *) const = 0;
-
- /**
- * Override in descendents: get use mask.
- */
- virtual bool do_query_use_mask(const UseFlagName &, const PackageDatabaseEntry *) const = 0;
-
- /**
- * Override in descendents: get use force.
- */
- virtual bool do_query_use_force(const UseFlagName &, const PackageDatabaseEntry *) const = 0;
-
- /**
- * Override in descendents: is this an arch flag?
- */
- virtual bool do_is_arch_flag(const UseFlagName &) const = 0;
-
- /**
- * Override in descendents: is this an expand flag?
- */
- virtual bool do_is_expand_flag(const UseFlagName &) const = 0;
+ ///\name Implementations: misc files
+ ///{
/**
* Override in descendents: is this a licence?
@@ -199,29 +226,34 @@ namespace paludis
*/
virtual bool do_is_mirror(const std::string &) const = 0;
- /**
- * Override in descendents: install.
- */
- virtual void do_install(const QualifiedPackageName &, const VersionSpec &,
- const InstallOptions &) const = 0;
+ ///}
- /**
- * Override in descendents: uninstall.
- */
- virtual void do_uninstall(const QualifiedPackageName &, const VersionSpec &,
- const InstallOptions &) const = 0;
+ public:
+ ///\name Interface queries
+ ///{
/**
- * Override in descendents: package list.
+ * Fetch an interface.
*/
- virtual DepAtom::Pointer do_package_set(const std::string & id) const = 0;
+ template <RepositoryCapabilitiesKeys k_>
+ typename RepositoryCapabilities::GetKeyType<k_>::Type
+ get_interface()
+ {
+ return _caps.get<k_>();
+ }
/**
- * Override in descendents: sync, if needed (true) or do nothing (false).
+ * Fetch an interface, const.
*/
- virtual bool do_sync() const = 0;
+ template <RepositoryCapabilitiesKeys k_>
+ const typename RepositoryCapabilities::GetKeyType<k_>::Type
+ get_interface() const
+ {
+ return _caps.get<k_>();
+ }
+
+ ///}
- public:
/**
* Destructor.
*/
@@ -293,16 +325,86 @@ namespace paludis
}
/**
- * Fetch contents.
+ * Iterator to information about our repository.
*/
- Contents::ConstPointer contents(
- const QualifiedPackageName & q,
- const VersionSpec & v) const
+ typedef std::map<std::string, std::string>::const_iterator InfoIterator;
+
+ /**
+ * Start of repository information.
+ */
+ InfoIterator begin_info() const
{
- return do_contents(q, v);
+ return _info.begin();
+ }
+
+ /**
+ * Past the end of repository information.
+ */
+ InfoIterator end_info() const
+ {
+ return _info.end();
+ }
+
+ /**
+ * Query whether the specified item is a licence.
+ */
+ bool is_license(const std::string & u) const
+ {
+ return do_is_licence(u);
+ }
+
+ /**
+ * Query whether the specified item is a mirror.
+ */
+ bool is_mirror(const std::string & u) const
+ {
+ return do_is_mirror(u);
}
/**
+ * Invalidate any cache.
+ */
+ virtual void invalidate() const = 0;
+
+ /**
+ * Our provide map iterator type.
+ */
+ typedef std::map<QualifiedPackageName, QualifiedPackageName>::const_iterator ProvideMapIterator;
+
+ /**
+ * Start of our provide map.
+ */
+ virtual ProvideMapIterator begin_provide_map() const = 0;
+
+ /**
+ * Past the end of our provide map.
+ */
+ virtual ProvideMapIterator end_provide_map() const = 0;
+ };
+
+ /**
+ * Interface for handling masks for the Repository class.
+ *
+ * \see Repository
+ * \ingroup grprepository
+ */
+ class Repository::MaskInterface
+ {
+ protected:
+ /**
+ * Override in descendents: check for a mask.
+ */
+ virtual bool do_query_repository_masks(const QualifiedPackageName &,
+ const VersionSpec &) const = 0;
+
+ /**
+ * Override in descendents: check for a mask.
+ */
+ virtual bool do_query_profile_masks(const QualifiedPackageName &,
+ const VersionSpec &) const = 0;
+
+ public:
+ /**
* Query repository masks.
*/
bool query_repository_masks(const QualifiedPackageName & q, const VersionSpec & v) const
@@ -317,29 +419,44 @@ namespace paludis
{
return do_query_profile_masks(q, v);
}
+ };
+ /**
+ * Interface for handling USE flags for the Repository class.
+ *
+ * \see Repository
+ * \ingroup grprepository
+ */
+ class Repository::UseInterface
+ {
+ protected:
/**
- * Iterator to information about our repository.
+ * Override in descendents: get use.
*/
- typedef std::map<std::string, std::string>::const_iterator InfoIterator;
+ virtual UseFlagState do_query_use(const UseFlagName &, const PackageDatabaseEntry *) const = 0;
/**
- * Start of repository information.
+ * Override in descendents: get use mask.
*/
- InfoIterator begin_info() const
- {
- return _info.begin();
- }
+ virtual bool do_query_use_mask(const UseFlagName &, const PackageDatabaseEntry *) const = 0;
/**
- * Past the end of repository information.
+ * Override in descendents: get use force.
*/
- InfoIterator end_info() const
- {
- return _info.end();
- }
+ virtual bool do_query_use_force(const UseFlagName &, const PackageDatabaseEntry *) const = 0;
/**
+ * Override in descendents: is this an arch flag?
+ */
+ virtual bool do_is_arch_flag(const UseFlagName &) const = 0;
+
+ /**
+ * Override in descendents: is this an expand flag?
+ */
+ virtual bool do_is_expand_flag(const UseFlagName &) const = 0;
+
+ public:
+ /**
* Query the state of the specified use flag.
*/
UseFlagState query_use(const UseFlagName & u, const PackageDatabaseEntry *pde) const
@@ -383,23 +500,52 @@ namespace paludis
{
return do_is_expand_flag(u);
}
+ };
+
+ /**
+ * Interface for handling actions for installed repositories.
+ *
+ * \see Repository
+ * \ingroup grprepository
+ */
+ class Repository::InstalledInterface
+ {
+ protected:
+ /**
+ * Override in descendents: fetch the contents.
+ */
+ virtual Contents::ConstPointer do_contents(
+ const QualifiedPackageName &,
+ const VersionSpec &) const = 0;
+ public:
/**
- * Query whether the specified item is a licence.
+ * Fetch contents.
*/
- bool is_license(const std::string & u) const
+ Contents::ConstPointer contents(
+ const QualifiedPackageName & q,
+ const VersionSpec & v) const
{
- return do_is_licence(u);
+ return do_contents(q, v);
}
+ };
+ /**
+ * Interface for handling installs for repositories.
+ *
+ * \see Repository
+ * \ingroup grprepository
+ */
+ class Repository::InstallableInterface
+ {
+ protected:
/**
- * Query whether the specified item is a mirror.
+ * Override in descendents: install.
*/
- bool is_mirror(const std::string & u) const
- {
- return do_is_mirror(u);
- }
+ virtual void do_install(const QualifiedPackageName &, const VersionSpec &,
+ const InstallOptions &) const = 0;
+ public:
/**
* Install a package.
*/
@@ -407,7 +553,24 @@ namespace paludis
{
do_install(q, v, i);
}
+ };
+
+ /**
+ * Interface for handling uninstalls for repositories.
+ *
+ * \see Repository
+ * \ingroup grprepository
+ */
+ class Repository::UninstallableInterface
+ {
+ protected:
+ /**
+ * Override in descendents: uninstall.
+ */
+ virtual void do_uninstall(const QualifiedPackageName &, const VersionSpec &,
+ const InstallOptions &) const = 0;
+ public:
/**
* Uninstall a package.
*/
@@ -415,24 +578,23 @@ namespace paludis
{
do_uninstall(q, v, i);
}
+ };
+ /**
+ * Interface for package sets for repositories.
+ *
+ * \see Repository
+ * \ingroup grprepository
+ */
+ class Repository::SetsInterface
+ {
+ protected:
/**
- * Return whether we are an 'installed' repo.
- *
- * No NVI indirection here, it's not worth it.
- */
- virtual bool installed() const = 0;
-
- /**
- * Sync, if necessary.
- *
- * \return True if we synced successfully, false if we skipped sync.
+ * Override in descendents: package list.
*/
- bool sync() const
- {
- return do_sync();
- }
+ virtual DepAtom::Pointer do_package_set(const std::string & id) const = 0;
+ public:
/**
* Fetch a package set.
*/
@@ -440,27 +602,43 @@ namespace paludis
{
return do_package_set(s);
}
+ };
+ /**
+ * Interface for syncing for repositories.
+ *
+ * \see Repository
+ * \ingroup grprepository
+ */
+ class Repository::SyncableInterface
+ {
+ protected:
/**
- * Invalidate any cache.
- */
- virtual void invalidate() const = 0;
-
- /**
- * Our provide map iterator type.
- */
- typedef std::map<QualifiedPackageName, QualifiedPackageName>::const_iterator ProvideMapIterator;
-
- /**
- * Start of our provide map.
+ * Override in descendents: sync, if needed (true) or do nothing (false).
*/
- virtual ProvideMapIterator begin_provide_map() const = 0;
+ virtual bool do_sync() const = 0;
+ public:
/**
- * Past the end of our provide map.
+ * Sync, if necessary.
+ *
+ * \return True if we synced successfully, false if we skipped sync.
*/
- virtual ProvideMapIterator end_provide_map() const = 0;
+ bool sync() const
+ {
+ return do_sync();
+ }
+ };
+ /**
+ * Interface for world handling for repositories.
+ *
+ * \see Repository
+ * \ingroup grprepository
+ */
+ class Repository::WorldInterface
+ {
+ public:
/**
* Add this package to world.
*/
@@ -470,7 +648,17 @@ namespace paludis
* Remove this package from world, if it is present.
*/
virtual void remove_from_world(const QualifiedPackageName &) const = 0;
+ };
+ /**
+ * Interface for news handling for repositories.
+ *
+ * \see Repository
+ * \ingroup grprepository
+ */
+ class Repository::NewsInterface
+ {
+ public:
/**
* Update our news.unread file.
*/
diff --git a/paludis/vdb_repository.cc b/paludis/vdb_repository.cc
index e3a441f..a56e8a6 100644
--- a/paludis/vdb_repository.cc
+++ b/paludis/vdb_repository.cc
@@ -358,7 +358,18 @@ Implementation<VDBRepository>::load_entry(std::vector<VDBEntry>::iterator p) con
}
VDBRepository::VDBRepository(const VDBRepositoryParams & p) :
- Repository(RepositoryName("installed")),
+ Repository(RepositoryName("installed"),
+ RepositoryCapabilities::create((
+ param<repo_installable>(static_cast<InstallableInterface *>(0)),
+ param<repo_installed>(this),
+ param<repo_mask>(static_cast<MaskInterface *>(0)),
+ param<repo_news>(static_cast<NewsInterface *>(0)),
+ param<repo_sets>(this),
+ param<repo_syncable>(static_cast<SyncableInterface *>(0)),
+ param<repo_uninstallable>(this),
+ param<repo_use>(this),
+ param<repo_world>(this)
+ ))),
PrivateImplementationPattern<VDBRepository>(new Implementation<VDBRepository>(p))
{
_info.insert(std::make_pair(std::string("location"), stringify(_imp->location)));
@@ -581,20 +592,6 @@ VDBRepository::do_contents(
return result;
}
-bool
-VDBRepository::do_query_repository_masks(const QualifiedPackageName &,
- const VersionSpec &) const
-{
- return false;
-}
-
-bool
-VDBRepository::do_query_profile_masks(const QualifiedPackageName &,
- const VersionSpec &) const
-{
- return false;
-}
-
UseFlagState
VDBRepository::do_query_use(const UseFlagName & f,
const PackageDatabaseEntry * const e) const
@@ -702,12 +699,6 @@ VDBRepository::do_is_mirror(const std::string &) const
}
void
-VDBRepository::do_install(const QualifiedPackageName &, const VersionSpec &, const InstallOptions &) const
-{
- throw PackageInstallActionError("VDBRepository doesn't support do_install");
-}
-
-void
VDBRepository::do_uninstall(const QualifiedPackageName & q, const VersionSpec & v, const InstallOptions & o) const
{
Context context("When uninstalling '" + stringify(q) + "-" + stringify(v) +
@@ -800,12 +791,6 @@ VDBRepository::do_package_set(const std::string & s) const
return DepAtom::Pointer(0);
}
-bool
-VDBRepository::do_sync() const
-{
- return false;
-}
-
void
VDBRepository::invalidate() const
{
diff --git a/paludis/vdb_repository.hh b/paludis/vdb_repository.hh
index 927a252..67692fc 100644
--- a/paludis/vdb_repository.hh
+++ b/paludis/vdb_repository.hh
@@ -85,6 +85,11 @@ namespace paludis
*/
class VDBRepository :
public Repository,
+ public Repository::InstalledInterface,
+ public Repository::UseInterface,
+ public Repository::UninstallableInterface,
+ public Repository::SetsInterface,
+ public Repository::WorldInterface,
public PrivateImplementationPattern<VDBRepository>
{
protected:
@@ -110,12 +115,6 @@ namespace paludis
const QualifiedPackageName &,
const VersionSpec &) const;
- virtual bool do_query_repository_masks(const QualifiedPackageName &,
- const VersionSpec &) const;
-
- virtual bool do_query_profile_masks(const QualifiedPackageName &,
- const VersionSpec &) const;
-
virtual UseFlagState do_query_use(const UseFlagName &, const PackageDatabaseEntry *) const;
virtual bool do_query_use_mask(const UseFlagName &, const PackageDatabaseEntry *) const;
@@ -130,16 +129,11 @@ namespace paludis
virtual bool do_is_mirror(const std::string &) const;
- virtual void do_install(const QualifiedPackageName &,
- const VersionSpec &, const InstallOptions &) const PALUDIS_ATTRIBUTE((noreturn));
-
virtual void do_uninstall(const QualifiedPackageName &, const VersionSpec &,
const InstallOptions &) const;
virtual DepAtom::Pointer do_package_set(const std::string &) const;
- virtual bool do_sync() const;
-
public:
/**
* Constructor.
@@ -173,6 +167,9 @@ namespace paludis
virtual void add_to_world(const QualifiedPackageName &) const;
virtual void remove_from_world(const QualifiedPackageName &) const;
+
+ typedef CountedPtr<VDBRepository, count_policy::InternalCountTag> Pointer;
+ typedef CountedPtr<const VDBRepository, count_policy::InternalCountTag> ConstPointer;
};
/**
diff --git a/src/contents.cc b/src/contents.cc
index ed95466..4138ece 100644
--- a/src/contents.cc
+++ b/src/contents.cc
@@ -62,9 +62,18 @@ do_one_contents_entry(
{
cout << "* " << colour(cl_package_name, e) << endl;
- p::Contents::ConstPointer contents(env->package_database()->fetch_contents(e));
- ContentsDisplayer d;
- std::for_each(contents->begin(), contents->end(), accept_visitor(&d));
+ const p::Repository::InstalledInterface * const installed_interface(
+ env->package_database()->fetch_repository(e.get<p::pde_repository>())->
+ get_interface<p::repo_installed>());
+ if (installed_interface)
+ {
+ p::Contents::ConstPointer contents(installed_interface->contents(
+ e.get<p::pde_name>(), e.get<p::pde_version>()));
+ ContentsDisplayer d;
+ std::for_each(contents->begin(), contents->end(), accept_visitor(&d));
+ }
+ else
+ cout << " " << colour(cl_red, "(unknown)") << endl;
cout << endl;
}
diff --git a/src/install.cc b/src/install.cc
index 9cacc58..cba7a7f 100644
--- a/src/install.cc
+++ b/src/install.cc
@@ -216,6 +216,9 @@ do_install()
/* display USE flags */
if (dep->get<p::dle_metadata>()->get_ebuild_interface())
{
+ const p::Repository::UseInterface * const use_interface(
+ env->package_database()->fetch_repository(dep->get<p::dle_repository>())->
+ get_interface<p::repo_use>());
std::set<p::UseFlagName> iuse;
p::WhitespaceTokeniser::get_instance()->tokenise(
dep->get<p::dle_metadata>()->get_ebuild_interface()->get<p::evm_iuse>(),
@@ -225,16 +228,14 @@ do_install()
{
if (env->query_use(*i, &p))
{
- if (env->package_database()->fetch_repository(
- dep->get<p::dle_repository>())->query_use_force(*i, &p))
+ if (use_interface && use_interface->query_use_force(*i, &p))
cout << " " << colour(cl_flag_on, "(" + p::stringify(*i) + ")");
else
cout << " " << colour(cl_flag_on, *i);
}
else
{
- if (env->package_database()->fetch_repository(
- dep->get<p::dle_repository>())->query_use_mask(*i, &p))
+ if (use_interface && use_interface->query_use_mask(*i, &p))
cout << " " << colour(cl_flag_off, "(-" + p::stringify(*i) + ")");
else
cout << " " << colour(cl_flag_off, "-" + p::stringify(*i));
@@ -352,8 +353,12 @@ do_install()
else
env->perform_hook(p::Hook("install_pre")("TARGET", cpvr));
- env->package_database()->fetch_repository(dep->get<p::dle_repository>())->
- install(dep->get<p::dle_name>(), dep->get<p::dle_version>(), opts);
+ const p::Repository::InstallableInterface * const installable_interface(
+ env->package_database()->fetch_repository(dep->get<p::dle_repository>())->
+ get_interface<p::repo_installable>());
+ if (! installable_interface)
+ throw p::InternalError(PALUDIS_HERE, "Trying to install from a non-installable repository");
+ installable_interface->install(dep->get<p::dle_name>(), dep->get<p::dle_version>(), opts);
if (opts.get<p::io_fetchonly>())
env->perform_hook(p::Hook("fetch_post")("TARGET", cpvr));
@@ -370,7 +375,7 @@ do_install()
// wrong now
for (p::PackageDatabase::RepositoryIterator r(env->package_database()->begin_repositories()),
r_end(env->package_database()->end_repositories()) ; r != r_end ; ++r)
- if ((*r)->installed())
+ if ((*r)->get_interface<p::repo_installed>())
(*r)->invalidate();
// look for packages with the same name in the same slot
@@ -410,8 +415,13 @@ do_install()
p::stringify(max_count) + ") Cleaning " + cpvr + ": " + stringify(*c));
env->perform_hook(p::Hook("uninstall_pre")("TARGET", stringify(*c)));
- env->package_database()->fetch_repository(c->get<p::pde_repository>())->
- uninstall(c->get<p::pde_name>(), c->get<p::pde_version>(), opts);
+
+ const p::Repository::UninstallableInterface * const uninstall_interface(
+ env->package_database()->fetch_repository(c->get<p::pde_repository>())->
+ get_interface<p::repo_uninstallable>());
+ if (! uninstall_interface)
+ throw p::InternalError(PALUDIS_HERE, "Trying to uninstall from a non-uninstallable repo");
+ uninstall_interface->uninstall(c->get<p::pde_name>(), c->get<p::pde_version>(), opts);
env->perform_hook(p::Hook("uninstall_post")("TARGET", stringify(*c)));
}
env->perform_hook(p::Hook("uninstall_all_pre")("TARGETS", p::join(c, c_end, " ")));
diff --git a/src/news.cc b/src/news.cc
index b3a90dd..68ce070 100644
--- a/src/news.cc
+++ b/src/news.cc
@@ -41,7 +41,8 @@ do_update_news()
for (p::PackageDatabase::RepositoryIterator r(env->package_database()->begin_repositories()),
r_end(env->package_database()->end_repositories()) ; r != r_end ; ++r)
- (*r)->update_news();
+ if ((*r)->get_interface<p::repo_news>())
+ (*r)->get_interface<p::repo_news>()->update_news();
return return_code;
}
diff --git a/src/owner.cc b/src/owner.cc
index d3f1deb..b83393b 100644
--- a/src/owner.cc
+++ b/src/owner.cc
@@ -83,7 +83,7 @@ do_one_owner(
for (p::PackageDatabase::RepositoryIterator r(env->package_database()->begin_repositories()),
r_end(env->package_database()->end_repositories()) ; r != r_end ; ++r)
{
- if (! (*r)->installed())
+ if (! (*r)->get_interface<p::repo_installed>())
continue;
p::CategoryNamePartCollection::ConstPointer cats((*r)->category_names());
@@ -99,7 +99,8 @@ do_one_owner(
v_end(vers->end()) ; v != v_end ; ++v)
{
p::PackageDatabaseEntry e(*p, *v, (*r)->name());
- p::Contents::ConstPointer contents(env->package_database()->fetch_contents(e));
+ p::Contents::ConstPointer contents((*r)->get_interface<p::repo_installed>()->
+ contents(*p, *v));
ContentsFinder d(query, CommandLine::get_instance()->a_full_match.specified());
std::for_each(contents->begin(), contents->end(), accept_visitor(&d));
if (d.found)
diff --git a/src/query.cc b/src/query.cc
index 131d938..2123d8b 100644
--- a/src/query.cc
+++ b/src/query.cc
@@ -106,7 +106,9 @@ void do_one_query(
for (e = entries->begin() ; e != e_end ; ++e)
if (e->get<p::pde_repository>() == *r)
{
- p::VersionMetadata::ConstPointer metadata(env->package_database()->fetch_metadata(*e));
+ p::VersionMetadata::ConstPointer metadata(env->package_database()->fetch_repository(
+ e->get<p::pde_repository>())->version_metadata(e->get<p::pde_name>(),
+ e->get<p::pde_version>()));
if (CommandLine::get_instance()->a_show_slot.specified())
{
/* show the slot, if we're about to move onto a new slot */
@@ -172,7 +174,9 @@ void do_one_query(
}
/* display metadata */
- p::VersionMetadata::ConstPointer metadata(env->package_database()->fetch_metadata(display_entry));
+ p::VersionMetadata::ConstPointer metadata(env->package_database()->fetch_repository(
+ display_entry.get<p::pde_repository>())->version_metadata(
+ display_entry.get<p::pde_name>(), display_entry.get<p::pde_version>()));
if (CommandLine::get_instance()->a_show_metadata.specified())
{
diff --git a/src/sync.cc b/src/sync.cc
index 2876f0a..4a7e6b9 100644
--- a/src/sync.cc
+++ b/src/sync.cc
@@ -40,7 +40,7 @@ namespace
std::cout << colour(cl_heading, "Sync " + p::stringify(r->name())) << std::endl;
try
{
- if (r->sync())
+ if (r->get_interface<p::repo_syncable>() && r->get_interface<p::repo_syncable>()->sync())
std::cout << "Sync " << r->name() << " completed" << std::endl;
else
std::cout << "Sync " << r->name() << " skipped" << std::endl;
diff --git a/src/uninstall.cc b/src/uninstall.cc
index 86816a9..df8202b 100644
--- a/src/uninstall.cc
+++ b/src/uninstall.cc
@@ -127,8 +127,12 @@ do_uninstall()
p::stringify(max_count) + ") Uninstalling " + cpvr);
env->perform_hook(p::Hook("uninstall_pre")("TARGET", cpvr));
- env->package_database()->fetch_repository(pkg->get<p::pde_repository>())->
- uninstall(pkg->get<p::pde_name>(), pkg->get<p::pde_version>(), opts);
+ const p::Repository::UninstallableInterface * const uninstall_interface(
+ env->package_database()->fetch_repository(pkg->get<p::pde_repository>())->
+ get_interface<p::repo_uninstallable>());
+ if (! uninstall_interface)
+ throw p::InternalError(PALUDIS_HERE, "Trying to uninstall from a non-uninstallable repo");
+ uninstall_interface->uninstall(pkg->get<p::pde_name>(), pkg->get<p::pde_version>(), opts);
env->perform_hook(p::Hook("uninstall_post")("TARGET", cpvr));
}
env->perform_hook(p::Hook("uninstall_all_post")("TARGETS", join(unmerge->begin(), unmerge->end(), " ")));