aboutsummaryrefslogtreecommitdiff
path: root/paludis/repositories/accounts
diff options
context:
space:
mode:
Diffstat (limited to 'paludis/repositories/accounts')
-rw-r--r--paludis/repositories/accounts/accounts_id.cc27
-rw-r--r--paludis/repositories/accounts/accounts_id.hh4
-rw-r--r--paludis/repositories/accounts/accounts_repository.cc29
-rw-r--r--paludis/repositories/accounts/accounts_repository_store.cc46
-rw-r--r--paludis/repositories/accounts/accounts_repository_store.hh14
-rw-r--r--paludis/repositories/accounts/installed_accounts_id.cc22
-rw-r--r--paludis/repositories/accounts/installed_accounts_id.hh4
7 files changed, 76 insertions, 70 deletions
diff --git a/paludis/repositories/accounts/accounts_id.cc b/paludis/repositories/accounts/accounts_id.cc
index 64aa7eebd..8995fac0a 100644
--- a/paludis/repositories/accounts/accounts_id.cc
+++ b/paludis/repositories/accounts/accounts_id.cc
@@ -36,7 +36,9 @@
#include <paludis/name.hh>
#include <paludis/version_spec.hh>
#include <paludis/literal_metadata_key.hh>
+#include <paludis/environment.hh>
#include <paludis/repository.hh>
+#include <paludis/package_database.hh>
#include <paludis/action.hh>
#include <paludis/user_dep_spec.hh>
#include <algorithm>
@@ -71,7 +73,7 @@ namespace paludis
const QualifiedPackageName name;
const VersionSpec version;
- const std::shared_ptr<const Repository> repository;
+ const RepositoryName repository_name;
const std::shared_ptr<const LiteralMetadataValueKey<FSPath> > fs_location_key;
const std::shared_ptr<const MetadataCollectionKey<Set<std::string> > > from_repositories_key;
@@ -97,13 +99,13 @@ namespace paludis
mutable std::shared_ptr<const LiteralMetadataValueKey<std::string> > preferred_gid_key;
Imp(const Environment * const e,
- const QualifiedPackageName & q, const std::shared_ptr<const Repository> & r,
+ const QualifiedPackageName & q, const RepositoryName & r,
const std::shared_ptr<const MetadataCollectionKey<Set<std::string> > > & f,
const FSPath & l, const bool u, const bool m) :
env(e),
name(q),
version("0", { }),
- repository(r),
+ repository_name(r),
fs_location_key(std::make_shared<LiteralMetadataValueKey<FSPath>>("location", "Location", mkt_internal, l)),
from_repositories_key(f),
behaviours_key(AccountsIDBehaviours::get_instance()->behaviours_key),
@@ -117,7 +119,7 @@ namespace paludis
}
AccountsID::AccountsID(const Environment * const e,
- const QualifiedPackageName & q, const std::shared_ptr<const Repository> & r,
+ const QualifiedPackageName & q, const RepositoryName & r,
const std::shared_ptr<const MetadataCollectionKey<Set<std::string> > > & f, const FSPath & l,
const bool u, const bool m) :
Pimp<AccountsID>(e, q, r, f, l, u, m),
@@ -270,10 +272,10 @@ AccountsID::version() const
return _imp->version;
}
-const std::shared_ptr<const Repository>
-AccountsID::repository() const
+const RepositoryName
+AccountsID::repository_name() const
{
- return _imp->repository;
+ return _imp->repository_name;
}
const std::string
@@ -282,16 +284,16 @@ AccountsID::canonical_form(const PackageIDCanonicalForm f) const
switch (f)
{
case idcf_full:
- return stringify(name()) + "-" + stringify(version()) + "::" + stringify(repository()->name());
+ return stringify(name()) + "-" + stringify(version()) + "::" + stringify(repository_name());
case idcf_no_version:
- return stringify(name()) + "::" + stringify(repository()->name());
+ return stringify(name()) + "::" + stringify(repository_name());
case idcf_version:
return stringify(version());
case idcf_no_name:
- return stringify(version()) + "::" + stringify(repository()->name());
+ return stringify(version()) + "::" + stringify(repository_name());
case last_idcf:
break;
@@ -303,7 +305,7 @@ AccountsID::canonical_form(const PackageIDCanonicalForm f) const
PackageDepSpec
AccountsID::uniquely_identifying_spec() const
{
- return parse_user_package_dep_spec(stringify(name()) + "::" + stringify(repository()->name()),
+ return parse_user_package_dep_spec(stringify(name()) + "::" + stringify(repository_name()),
_imp->env, { });
}
@@ -538,7 +540,8 @@ AccountsID::perform_action(Action & action) const
i != i_end ; ++i)
{
Context local_context("When cleaning '" + stringify(**i) + "':");
- if ((*i)->repository()->format_key() && (*i)->repository()->format_key()->value() == "installed-accounts"
+ auto repo(_imp->env->package_database()->fetch_repository((*i)->repository_name()));
+ if (repo->format_key() && repo->format_key()->value() == "installed-accounts"
&& (*i)->name() == name())
continue;
else
diff --git a/paludis/repositories/accounts/accounts_id.hh b/paludis/repositories/accounts/accounts_id.hh
index 6285e42e8..88b90b211 100644
--- a/paludis/repositories/accounts/accounts_id.hh
+++ b/paludis/repositories/accounts/accounts_id.hh
@@ -47,7 +47,7 @@ namespace paludis
public:
AccountsID(const Environment * const,
- const QualifiedPackageName &, const std::shared_ptr<const Repository> &,
+ const QualifiedPackageName &, const RepositoryName &,
const std::shared_ptr<const MetadataCollectionKey<Set<std::string> > > &,
const FSPath &, const bool is_user, const bool masked);
~AccountsID();
@@ -56,7 +56,7 @@ namespace paludis
virtual const QualifiedPackageName name() const;
virtual const VersionSpec version() const;
- virtual const std::shared_ptr<const Repository> repository() const;
+ virtual const RepositoryName repository_name() const;
virtual PackageDepSpec uniquely_identifying_spec() const;
///\name Specific metadata keys
diff --git a/paludis/repositories/accounts/accounts_repository.cc b/paludis/repositories/accounts/accounts_repository.cc
index 18d87d62c..02af0953f 100644
--- a/paludis/repositories/accounts/accounts_repository.cc
+++ b/paludis/repositories/accounts/accounts_repository.cc
@@ -40,6 +40,7 @@
#include <paludis/filtered_generator.hh>
#include <paludis/hook.hh>
#include <paludis/common_sets.hh>
+#include <paludis/package_database.hh>
using namespace paludis;
using namespace paludis::accounts_repository;
@@ -57,15 +58,15 @@ namespace
}
std::shared_ptr<AccountsRepositoryStore>
- make_store(const AccountsRepository * const repo, const AccountsRepositoryParams & p)
+ make_store(const RepositoryName & repository_name, const AccountsRepositoryParams & p)
{
- return std::make_shared<AccountsRepositoryStore>(p.environment(), repo, false);
+ return std::make_shared<AccountsRepositoryStore>(p.environment(), repository_name, false);
}
std::shared_ptr<AccountsRepositoryStore>
- make_installed_store(const AccountsRepository * const repo, const InstalledAccountsRepositoryParams & p)
+ make_installed_store(const RepositoryName & repository_name, const InstalledAccountsRepositoryParams & p)
{
- return std::make_shared<AccountsRepositoryStore>(p.environment(), repo, true);
+ return std::make_shared<AccountsRepositoryStore>(p.environment(), repository_name, true);
}
}
@@ -84,29 +85,29 @@ namespace paludis
const ActiveObjectPtr<DeferredConstructionPtr<std::shared_ptr<AccountsRepositoryStore> > > store;
- Imp(AccountsRepository * const repo, const AccountsRepositoryParams & p) :
+ Imp(const RepositoryName & repository_name, const AccountsRepositoryParams & p) :
params_if_not_installed(std::make_shared<AccountsRepositoryParams>(p)),
format_key(std::make_shared<LiteralMetadataValueKey<std::string> >("format", "format", mkt_significant, "accounts")),
store(DeferredConstructionPtr<std::shared_ptr<AccountsRepositoryStore> > (
- std::bind(&make_store, repo, std::cref(*params_if_not_installed))))
+ std::bind(&make_store, repository_name, std::cref(*params_if_not_installed))))
{
}
- Imp(AccountsRepository * const repo, const InstalledAccountsRepositoryParams & p) :
+ Imp(const RepositoryName & repository_name, const InstalledAccountsRepositoryParams & p) :
params_if_installed(std::make_shared<InstalledAccountsRepositoryParams>(p)),
handler_if_installed(make_handler(p.handler())),
format_key(std::make_shared<LiteralMetadataValueKey<std::string> >("format", "format", mkt_significant, "installed-accounts")),
handler_key(std::make_shared<LiteralMetadataValueKey<std::string> >("handler", "handler", mkt_normal, p.handler())),
installed_root_key(std::make_shared<LiteralMetadataValueKey<FSPath>>("root", "root", mkt_normal, p.root())),
store(DeferredConstructionPtr<std::shared_ptr<AccountsRepositoryStore> > (
- std::bind(&make_installed_store, repo, std::cref(*params_if_installed))))
+ std::bind(&make_installed_store, repository_name, std::cref(*params_if_installed))))
{
}
};
}
AccountsRepository::AccountsRepository(const AccountsRepositoryParams & p) :
- Pimp<AccountsRepository>(this, p),
+ Pimp<AccountsRepository>(p.name(), p),
Repository(
p.environment(),
p.name(),
@@ -124,7 +125,7 @@ AccountsRepository::AccountsRepository(const AccountsRepositoryParams & p) :
}
AccountsRepository::AccountsRepository(const InstalledAccountsRepositoryParams & p) :
- Pimp<AccountsRepository>(this, p),
+ Pimp<AccountsRepository>(p.name(), p),
Repository(
p.environment(),
p.name(),
@@ -275,9 +276,9 @@ void
AccountsRepository::invalidate()
{
if (_imp->params_if_not_installed)
- _imp.reset(new Imp<AccountsRepository>(this, *_imp->params_if_not_installed));
+ _imp.reset(new Imp<AccountsRepository>(name(), *_imp->params_if_not_installed));
else
- _imp.reset(new Imp<AccountsRepository>(this, *_imp->params_if_installed));
+ _imp.reset(new Imp<AccountsRepository>(name(), *_imp->params_if_installed));
_add_metadata_keys();
}
@@ -403,7 +404,9 @@ AccountsRepository::some_ids_might_not_be_masked() const
bool
AccountsRepository::is_suitable_destination_for(const std::shared_ptr<const PackageID> & id) const
{
- std::string f(id->repository()->format_key() ? id->repository()->format_key()->value() : "");
+ auto env(_imp->params_if_installed ? _imp->params_if_installed->environment() : _imp->params_if_not_installed->environment());
+ auto repo(env->package_database()->fetch_repository(id->repository_name()));
+ std::string f(repo->format_key() ? repo->format_key()->value() : "");
return _imp->handler_if_installed && f == "accounts";
}
diff --git a/paludis/repositories/accounts/accounts_repository_store.cc b/paludis/repositories/accounts/accounts_repository_store.cc
index 02208f094..279c72bb2 100644
--- a/paludis/repositories/accounts/accounts_repository_store.cc
+++ b/paludis/repositories/accounts/accounts_repository_store.cc
@@ -64,16 +64,16 @@ namespace paludis
struct Imp<AccountsRepositoryStore>
{
const Environment * const env;
- const AccountsRepository * const repo;
+ const RepositoryName repository_name;
const bool installed;
std::shared_ptr<CategoryNamePartSet> categories;
mutable PackageNames package_names;
mutable IDs ids;
- Imp(const Environment * const e, const AccountsRepository * const r, const bool i) :
+ Imp(const Environment * const e, const RepositoryName & r, const bool i) :
env(e),
- repo(r),
+ repository_name(r),
installed(i),
categories(std::make_shared<CategoryNamePartSet>())
{
@@ -85,11 +85,11 @@ namespace paludis
AccountsRepositoryStore::AccountsRepositoryStore(
const Environment * const env,
- const AccountsRepository * const repo,
+ const RepositoryName & r,
const bool installed) :
- Pimp<AccountsRepositoryStore>(env, repo, installed)
+ Pimp<AccountsRepositoryStore>(env, r, installed)
{
- _load(repo->shared_from_this());
+ _load(r);
}
AccountsRepositoryStore::~AccountsRepositoryStore()
@@ -97,7 +97,7 @@ AccountsRepositoryStore::~AccountsRepositoryStore()
}
void
-AccountsRepositoryStore::_load(const std::shared_ptr<const Repository> & repo)
+AccountsRepositoryStore::_load(const RepositoryName & repository_name)
{
Context context("When loading data for AccountsRepository:");
@@ -134,13 +134,13 @@ AccountsRepositoryStore::_load(const std::shared_ptr<const Repository> & repo)
std::shared_ptr<Set<std::string> > r_set(std::make_shared<Set<std::string>>());
r_set->insert(stringify((*r)->name()));
std::shared_ptr<LiteralMetadataStringSetKey> r_key(std::make_shared<LiteralMetadataStringSetKey>("defined_by", "Defined by repository", mkt_internal, r_set));
- _load_one(repo, r_key, dir);
+ _load_one(repository_name, r_key, dir);
}
}
void
AccountsRepositoryStore::_load_one(
- const std::shared_ptr<const Repository> & repo,
+ const RepositoryName & repository_name,
const std::shared_ptr<const MetadataCollectionKey<Set<std::string> > > & from_repo,
const FSPath & dir)
{
@@ -148,29 +148,29 @@ AccountsRepositoryStore::_load_one(
FSPath users_dir(dir / "users");
if (users_dir.stat().is_directory_or_symlink_to_directory())
- _load_one_users(repo, from_repo, users_dir);
+ _load_one_users(repository_name, from_repo, users_dir);
else
Log::get_instance()->message("accounts.no_users", ll_debug, lc_context) <<
- "Repository " << repo->name() << " has accounts_repository_data_location " << dir << ", but no users subdirectory";
+ "Repository " << repository_name << " has accounts_repository_data_location " << dir << ", but no users subdirectory";
FSPath groups_dir(dir / "groups");
if (groups_dir.stat().is_directory_or_symlink_to_directory())
- _load_one_groups(repo, from_repo, groups_dir);
+ _load_one_groups(repository_name, from_repo, groups_dir);
else
Log::get_instance()->message("accounts.no_groups", ll_debug, lc_context) <<
- "Repository " << repo->name() << " has accounts_repository_data_location " << dir << ", but no groups subdirectory";
+ "Repository " << repository_name << " has accounts_repository_data_location " << dir << ", but no groups subdirectory";
}
void
AccountsRepositoryStore::_load_one_users(
- const std::shared_ptr<const Repository> & repo,
+ const RepositoryName & repository_name,
const std::shared_ptr<const MetadataCollectionKey<Set<std::string> > > & from_repo,
const FSPath & dir)
{
for (FSIterator d(dir, { fsio_inode_sort }), d_end ; d != d_end ; ++d)
if (is_file_with_extension(*d, ".conf", { }))
- _load_one_user(repo, from_repo, *d);
+ _load_one_user(repository_name, from_repo, *d);
else
Log::get_instance()->message("accounts.unknown_file", ll_debug, lc_context) <<
"Don't know what to do with '" << *d << "'";
@@ -178,7 +178,7 @@ AccountsRepositoryStore::_load_one_users(
void
AccountsRepositoryStore::_load_one_user(
- const std::shared_ptr<const Repository> & repo,
+ const RepositoryName & repository_name,
const std::shared_ptr<const MetadataCollectionKey<Set<std::string> > > & from_repo,
const FSPath & filename)
{
@@ -213,20 +213,20 @@ AccountsRepositoryStore::_load_one_user(
q->second = std::make_shared<PackageIDSequence>();
if (_imp->installed)
- q->second->push_back(std::make_shared<InstalledAccountsID>(_imp->env, qpn, repo, true));
+ q->second->push_back(std::make_shared<InstalledAccountsID>(_imp->env, qpn, repository_name, true));
else
- q->second->push_back(std::make_shared<AccountsID>(_imp->env, qpn, repo, from_repo, filename, true, masked));
+ q->second->push_back(std::make_shared<AccountsID>(_imp->env, qpn, repository_name, from_repo, filename, true, masked));
}
void
AccountsRepositoryStore::_load_one_groups(
- const std::shared_ptr<const Repository> & repo,
+ const RepositoryName & repository_name,
const std::shared_ptr<const MetadataCollectionKey<Set<std::string> > > & from_repo,
const FSPath & dir)
{
for (FSIterator d(dir, { fsio_inode_sort }), d_end ; d != d_end ; ++d)
if (is_file_with_extension(*d, ".conf", { }))
- _load_one_group(repo, from_repo, *d);
+ _load_one_group(repository_name, from_repo, *d);
else
Log::get_instance()->message("accounts.unknown_file", ll_debug, lc_context) <<
"Don't know what to do with '" << *d << "'";
@@ -234,7 +234,7 @@ AccountsRepositoryStore::_load_one_groups(
void
AccountsRepositoryStore::_load_one_group(
- const std::shared_ptr<const Repository> & repo,
+ const RepositoryName & repository_name,
const std::shared_ptr<const MetadataCollectionKey<Set<std::string> > > & from_repo,
const FSPath & filename)
{
@@ -269,9 +269,9 @@ AccountsRepositoryStore::_load_one_group(
q->second = std::make_shared<PackageIDSequence>();
if (_imp->installed)
- q->second->push_back(std::make_shared<InstalledAccountsID>(_imp->env, qpn, repo, false));
+ q->second->push_back(std::make_shared<InstalledAccountsID>(_imp->env, qpn, repository_name, false));
else
- q->second->push_back(std::make_shared<AccountsID>(_imp->env, qpn, repo, from_repo, filename, false, masked));
+ q->second->push_back(std::make_shared<AccountsID>(_imp->env, qpn, repository_name, from_repo, filename, false, masked));
}
bool
diff --git a/paludis/repositories/accounts/accounts_repository_store.hh b/paludis/repositories/accounts/accounts_repository_store.hh
index c27ab12fa..271cf3c8a 100644
--- a/paludis/repositories/accounts/accounts_repository_store.hh
+++ b/paludis/repositories/accounts/accounts_repository_store.hh
@@ -39,37 +39,37 @@ namespace paludis
private Pimp<AccountsRepositoryStore>
{
private:
- void _load(const std::shared_ptr<const Repository> & repo);
+ void _load(const RepositoryName &);
void _load_one(
- const std::shared_ptr<const Repository> & repo,
+ const RepositoryName &,
const std::shared_ptr<const MetadataCollectionKey<Set<std::string> > > & from_repo,
const FSPath & dir);
void _load_one_users(
- const std::shared_ptr<const Repository> & repo,
+ const RepositoryName &,
const std::shared_ptr<const MetadataCollectionKey<Set<std::string> > > & from_repo,
const FSPath & dir);
void _load_one_user(
- const std::shared_ptr<const Repository> & repo,
+ const RepositoryName &,
const std::shared_ptr<const MetadataCollectionKey<Set<std::string> > > & from_repo,
const FSPath & file);
void _load_one_groups(
- const std::shared_ptr<const Repository> & repo,
+ const RepositoryName &,
const std::shared_ptr<const MetadataCollectionKey<Set<std::string> > > & from_repo,
const FSPath & dir);
void _load_one_group(
- const std::shared_ptr<const Repository> & repo,
+ const RepositoryName &,
const std::shared_ptr<const MetadataCollectionKey<Set<std::string> > > & from_repo,
const FSPath & file);
public:
AccountsRepositoryStore(
const Environment * const,
- const AccountsRepository * const,
+ const RepositoryName &,
const bool installed);
~AccountsRepositoryStore();
diff --git a/paludis/repositories/accounts/installed_accounts_id.cc b/paludis/repositories/accounts/installed_accounts_id.cc
index f84bdfd45..295e2bf1b 100644
--- a/paludis/repositories/accounts/installed_accounts_id.cc
+++ b/paludis/repositories/accounts/installed_accounts_id.cc
@@ -74,7 +74,7 @@ namespace paludis
const QualifiedPackageName name;
const VersionSpec version;
- const std::shared_ptr<const Repository> repository;
+ const RepositoryName repository_name;
const std::shared_ptr<const LiteralMetadataStringSetKey> behaviours_key;
mutable Mutex mutex;
@@ -83,12 +83,12 @@ namespace paludis
const bool is_user;
Imp(const Environment * const e,
- const QualifiedPackageName & q, const std::shared_ptr<const Repository> & r,
+ const QualifiedPackageName & q, const RepositoryName & r,
const bool u) :
env(e),
name(q),
version("0", { }),
- repository(r),
+ repository_name(r),
behaviours_key(InstalledAccountsIDBehaviours::get_instance()->behaviours_key),
is_user(u)
{
@@ -97,7 +97,7 @@ namespace paludis
}
InstalledAccountsID::InstalledAccountsID(const Environment * const e,
- const QualifiedPackageName & q, const std::shared_ptr<const Repository> & r, const bool u) :
+ const QualifiedPackageName & q, const RepositoryName & r, const bool u) :
Pimp<InstalledAccountsID>(e, q, r, u),
_imp(Pimp<InstalledAccountsID>::_imp)
{
@@ -191,10 +191,10 @@ InstalledAccountsID::version() const
return _imp->version;
}
-const std::shared_ptr<const Repository>
-InstalledAccountsID::repository() const
+const RepositoryName
+InstalledAccountsID::repository_name() const
{
- return _imp->repository;
+ return _imp->repository_name;
}
const std::string
@@ -203,16 +203,16 @@ InstalledAccountsID::canonical_form(const PackageIDCanonicalForm f) const
switch (f)
{
case idcf_full:
- return stringify(name()) + "-" + stringify(version()) + "::" + stringify(repository()->name());
+ return stringify(name()) + "-" + stringify(version()) + "::" + stringify(repository_name());
case idcf_no_version:
- return stringify(name()) + "::" + stringify(repository()->name());
+ return stringify(name()) + "::" + stringify(repository_name());
case idcf_version:
return stringify(version());
case idcf_no_name:
- return stringify(version()) + "::" + stringify(repository()->name());
+ return stringify(version()) + "::" + stringify(repository_name());
case last_idcf:
break;
@@ -224,7 +224,7 @@ InstalledAccountsID::canonical_form(const PackageIDCanonicalForm f) const
PackageDepSpec
InstalledAccountsID::uniquely_identifying_spec() const
{
- return parse_user_package_dep_spec(stringify(name()) + "::" + stringify(repository()->name()), _imp->env, { });
+ return parse_user_package_dep_spec(stringify(name()) + "::" + stringify(repository_name()), _imp->env, { });
}
const std::shared_ptr<const MetadataValueKey<std::shared_ptr<const PackageID> > >
diff --git a/paludis/repositories/accounts/installed_accounts_id.hh b/paludis/repositories/accounts/installed_accounts_id.hh
index 2e7d9de7a..6d09a2edb 100644
--- a/paludis/repositories/accounts/installed_accounts_id.hh
+++ b/paludis/repositories/accounts/installed_accounts_id.hh
@@ -46,7 +46,7 @@ namespace paludis
public:
InstalledAccountsID(const Environment * const,
- const QualifiedPackageName &, const std::shared_ptr<const Repository> &,
+ const QualifiedPackageName &, const RepositoryName &,
const bool is_user);
~InstalledAccountsID();
@@ -54,7 +54,7 @@ namespace paludis
virtual const QualifiedPackageName name() const;
virtual const VersionSpec version() const;
- virtual const std::shared_ptr<const Repository> repository() const;
+ virtual const RepositoryName repository_name() const;
virtual PackageDepSpec uniquely_identifying_spec() const;
///\name Specific metadata keys