aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-10-19 10:18:28 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-10-19 10:18:28 +0000
commit5a75634a2260f3935b5d1e30f3217e3845f257ec (patch)
tree1fe551df8a80636438ee3d03002e518c29a2e8f1
parentbb0b6473479869291a60ca526b803ac93cb4a5b3 (diff)
downloadpaludis-5a75634a2260f3935b5d1e30f3217e3845f257ec.tar.gz
paludis-5a75634a2260f3935b5d1e30f3217e3845f257ec.tar.xz
Allow NoConfigEnvironment to work with VDB repositories. Be VDB friendly.
-rw-r--r--paludis/environment/no_config/Makefile.am3
-rw-r--r--paludis/environment/no_config/no_config_environment.cc188
-rw-r--r--paludis/environment/no_config/no_config_environment.hh13
-rw-r--r--paludis/environment/no_config/no_config_environment.sr1
-rw-r--r--ruby/environment.cc3
-rw-r--r--src/adjutrix/adjutrix.cc5
-rw-r--r--src/adjutrix/find_reverse_deps.cc12
7 files changed, 169 insertions, 56 deletions
diff --git a/paludis/environment/no_config/Makefile.am b/paludis/environment/no_config/Makefile.am
index 4c45031..ac081cc 100644
--- a/paludis/environment/no_config/Makefile.am
+++ b/paludis/environment/no_config/Makefile.am
@@ -15,7 +15,8 @@ libpaludisnoconfigenvironment_la_LDFLAGS = -version-info @VERSION_LIB_CURRENT@:@
libpaludisnoconfigenvironment_la_LIBADD = \
$(top_builddir)/paludis/util/libpaludisutil.la \
$(top_builddir)/paludis/libpaludis.la \
- $(top_builddir)/paludis/repositories/portage/libpaludisportagerepository.la
+ $(top_builddir)/paludis/repositories/portage/libpaludisportagerepository.la \
+ $(top_builddir)/paludis/repositories/vdb/libpaludisvdbrepository.la
lib_LTLIBRARIES = libpaludisnoconfigenvironment.la
paludis_environment_no_config_includedir = $(includedir)/paludis/environment/no_config
diff --git a/paludis/environment/no_config/no_config_environment.cc b/paludis/environment/no_config/no_config_environment.cc
index b9022fa..7dbc3ab 100644
--- a/paludis/environment/no_config/no_config_environment.cc
+++ b/paludis/environment/no_config/no_config_environment.cc
@@ -21,6 +21,7 @@
#include <paludis/util/collection_concrete.hh>
#include <paludis/util/tokeniser.hh>
#include <paludis/util/log.hh>
+#include <paludis/util/dir_iterator.hh>
#include <paludis/repositories/portage/portage_repository.hh>
#include <paludis/config_file.hh>
#include <set>
@@ -37,79 +38,162 @@ namespace paludis
{
const FSEntry top_level_dir;
bool accept_unstable;
+ bool is_vdb;
std::set<KeywordName> accepted_keywords;
std::list<NoConfigEnvironmentProfilesDescLine> profiles;
+ PackageDatabase::Pointer vdb_db;
- Implementation(Environment * const env, const NoConfigEnvironmentParams & params) :
- top_level_dir(params.repository_dir),
- accept_unstable(params.accept_unstable)
+ Implementation(Environment * const env, const NoConfigEnvironmentParams & params);
+ };
+
+ /* This goat is for Dave Wickham */
+}
+
+namespace
+{
+ bool is_vdb_repository(const FSEntry & location, NoConfigEnvironmentRepositoryType type)
+ {
+ switch (type)
{
- Context context("When initialising NoConfigEnvironment at '" + stringify(params.repository_dir) + "':");
+ case ncer_portage:
+ return false;
+ case ncer_vdb:
+ return true;
+ case ncer_auto:
+ ;
+ }
+
+ Context context("When determining repository type at '" + stringify(location) + "':");
- try
+ if (! location.is_directory())
+ throw ConfigurationError("Location is not a directory");
+
+ if ((location / "profiles").is_directory())
+ {
+ Log::get_instance()->message(ll_debug, lc_context, "Found profiles/, looks like Portage format");
+ return false;
+ }
+
+ int outer_count(0);
+ for (DirIterator d(location), d_end ; d != d_end ; ++d)
+ {
+ if (! d->is_directory())
+ continue;
+
+ int inner_count(0);
+ for (DirIterator e(*d), e_end ; e != e_end ; ++e)
{
- LineConfigFile profiles_desc(params.repository_dir / "profiles" / "profiles.desc");
- for (LineConfigFile::Iterator line(profiles_desc.begin()), line_end(profiles_desc.end()) ;
- line != line_end ; ++line)
+ if (! e->is_directory())
+ continue;
+
+ if ((*e / "CONTENTS").exists())
{
- std::vector<std::string> tokens;
- WhitespaceTokeniser::get_instance()->tokenise(*line, std::back_inserter(tokens));
-
- if (tokens.size() != 3)
- {
- Log::get_instance()->message(ll_warning, lc_context, "Skipping invalid line '"
- + *line + "'");
- continue;
- }
-
- profiles.push_back(NoConfigEnvironmentProfilesDescLine::create()
- .path(params.repository_dir / "profiles" / tokens.at(1))
- .status(tokens.at(2))
- .arch(tokens.at(0))
- .db(PackageDatabase::Pointer(new PackageDatabase(env))));
+ Log::get_instance()->message(ll_debug, lc_context, "Found '" + stringify(*e) +
+ "/CONTENTS', looks like VDB format");
+ return true;
}
+
+ if (inner_count++ >= 5)
+ break;
}
- catch (const ConfigFileError & e)
+
+ if (outer_count++ >= 5)
+ break;
+ }
+
+ throw ConfigurationError("Can't work out what kind of repository this is");
+ }
+}
+
+Implementation<NoConfigEnvironment>::Implementation(
+ Environment * const env, const NoConfigEnvironmentParams & params) :
+ top_level_dir(params.repository_dir),
+ accept_unstable(params.accept_unstable),
+ is_vdb(is_vdb_repository(params.repository_dir, params.repository_type)),
+ vdb_db(is_vdb ? new PackageDatabase(env) : 0)
+{
+ Context context("When initialising NoConfigEnvironment at '" + stringify(params.repository_dir) + "':");
+
+ if (! is_vdb)
+ {
+ Log::get_instance()->message(ll_debug, lc_context, "Not VDB, using profiles.desc");
+ try
+ {
+ LineConfigFile profiles_desc(params.repository_dir / "profiles" / "profiles.desc");
+ for (LineConfigFile::Iterator line(profiles_desc.begin()), line_end(profiles_desc.end()) ;
+ line != line_end ; ++line)
{
- Log::get_instance()->message(ll_warning, lc_context, "Could not load profiles.desc due to exception '"
- + e.message() + "' (" + e.what() + ")");
- }
+ std::vector<std::string> tokens;
+ WhitespaceTokeniser::get_instance()->tokenise(*line, std::back_inserter(tokens));
+
+ if (tokens.size() != 3)
+ {
+ Log::get_instance()->message(ll_warning, lc_context, "Skipping invalid line '"
+ + *line + "'");
+ continue;
+ }
- if (profiles.empty())
profiles.push_back(NoConfigEnvironmentProfilesDescLine::create()
- .path(params.repository_dir / "profiles" / "base")
- .status("default")
- .arch("default")
+ .path(params.repository_dir / "profiles" / tokens.at(1))
+ .status(tokens.at(2))
+ .arch(tokens.at(0))
.db(PackageDatabase::Pointer(new PackageDatabase(env))));
+ }
+ }
+ catch (const ConfigFileError & e)
+ {
+ Log::get_instance()->message(ll_warning, lc_context, "Could not load profiles.desc due to exception '"
+ + e.message() + "' (" + e.what() + ")");
+ }
- for (std::list<NoConfigEnvironmentProfilesDescLine>::iterator
- p(profiles.begin()), p_end(profiles.end()) ; p != p_end ; ++p)
- {
- AssociativeCollection<std::string, std::string>::Pointer keys(
- new AssociativeCollection<std::string, std::string>::Concrete);
+ if (profiles.empty())
+ profiles.push_back(NoConfigEnvironmentProfilesDescLine::create()
+ .path(params.repository_dir / "profiles" / "base")
+ .status("default")
+ .arch("default")
+ .db(PackageDatabase::Pointer(new PackageDatabase(env))));
- keys->insert("format", "portage");
- keys->insert("location", stringify(params.repository_dir));
- keys->insert("profiles", stringify(p->path));
+ for (std::list<NoConfigEnvironmentProfilesDescLine>::iterator
+ p(profiles.begin()), p_end(profiles.end()) ; p != p_end ; ++p)
+ {
+ AssociativeCollection<std::string, std::string>::Pointer keys(
+ new AssociativeCollection<std::string, std::string>::Concrete);
- p->db->add_repository(RepositoryMaker::get_instance()->find_maker("portage")(env,
- p->db.raw_pointer(), keys));
- p->db->add_repository(RepositoryMaker::get_instance()->find_maker("virtuals")(env,
- p->db.raw_pointer(), AssociativeCollection<std::string, std::string>::Pointer(0)));
- }
+ keys->insert("format", "portage");
+ keys->insert("location", stringify(params.repository_dir));
+ keys->insert("profiles", stringify(p->path));
+
+ p->db->add_repository(RepositoryMaker::get_instance()->find_maker("portage")(env,
+ p->db.raw_pointer(), keys));
+ p->db->add_repository(RepositoryMaker::get_instance()->find_maker("virtuals")(env,
+ p->db.raw_pointer(), AssociativeCollection<std::string, std::string>::Pointer(0)));
}
- };
+ }
+ else
+ {
+ Log::get_instance()->message(ll_debug, lc_context, "VDB, using vdb_db");
- /* This goat is for Dave Wickham */
+ AssociativeCollection<std::string, std::string>::Pointer keys(
+ new AssociativeCollection<std::string, std::string>::Concrete);
+
+ keys->insert("format", "vdb");
+ keys->insert("location", stringify(top_level_dir));
+
+ vdb_db->add_repository(RepositoryMaker::get_instance()->find_maker("vdb")(env,
+ vdb_db.raw_pointer(), keys));
+ vdb_db->add_repository(RepositoryMaker::get_instance()->find_maker("installed_virtuals")(env,
+ vdb_db.raw_pointer(), AssociativeCollection<std::string, std::string>::Pointer(0)));
+ }
}
NoConfigEnvironment::NoConfigEnvironment(const NoConfigEnvironmentParams & params) :
PrivateImplementationPattern<NoConfigEnvironment>(
new Implementation<NoConfigEnvironment>(this, params)),
- Environment(_imp->profiles.begin()->db)
+ Environment(_imp->is_vdb ? _imp->vdb_db : _imp->profiles.begin()->db)
{
/* do this to load accepted_keywords etc */
- set_profile(ProfilesIterator(_imp->profiles.begin()));
+ if (! _imp->is_vdb)
+ set_profile(ProfilesIterator(_imp->profiles.begin()));
}
NoConfigEnvironment::~NoConfigEnvironment()
@@ -131,6 +215,9 @@ NoConfigEnvironment::main_repository_dir() const
void
NoConfigEnvironment::set_profile(const NoConfigEnvironment::ProfilesIterator & i)
{
+ if (_imp->is_vdb)
+ throw ConfigurationError("Calling NoConfigEnvironment::set_profile but no Portage repository was defined");
+
change_package_database(i->db);
_imp->accepted_keywords.clear();
@@ -145,6 +232,9 @@ NoConfigEnvironment::set_profile(const FSEntry & location)
{
Context context("When setting NoConfigEnvironment profile to '" + stringify(location) + "':");
+ if (_imp->is_vdb)
+ throw ConfigurationError("Calling NoConfigEnvironment::set_profile but no Portage repository was defined");
+
for (ProfilesIterator i(begin_profiles()), i_end(end_profiles()) ; i != i_end ; ++i)
if (i->path == location)
{
@@ -180,7 +270,7 @@ NoConfigEnvironment::set_profile(const FSEntry & location)
bool
NoConfigEnvironment::accept_keyword(const KeywordName & k, const PackageDatabaseEntry * const) const
{
- return _imp->accepted_keywords.end() != _imp->accepted_keywords.find(k);
+ return _imp->is_vdb || (_imp->accepted_keywords.end() != _imp->accepted_keywords.find(k));
}
NoConfigEnvironment::ProfilesIterator
diff --git a/paludis/environment/no_config/no_config_environment.hh b/paludis/environment/no_config/no_config_environment.hh
index c4af3a8..8e8b114 100644
--- a/paludis/environment/no_config/no_config_environment.hh
+++ b/paludis/environment/no_config/no_config_environment.hh
@@ -27,6 +27,19 @@
namespace paludis
{
+ /**
+ * The type of repository to use for a NoConfigEnvironment.
+ *
+ * \see NoConfigEnvironment
+ * \ingroup grpnoconfigenvironment
+ */
+ enum NoConfigEnvironmentRepositoryType
+ {
+ ncer_portage,
+ ncer_vdb,
+ ncer_auto
+ };
+
#include <paludis/environment/no_config/no_config_environment-sr.hh>
/**
diff --git a/paludis/environment/no_config/no_config_environment.sr b/paludis/environment/no_config/no_config_environment.sr
index 0db14bb..4a2fb3c 100644
--- a/paludis/environment/no_config/no_config_environment.sr
+++ b/paludis/environment/no_config/no_config_environment.sr
@@ -5,6 +5,7 @@ make_class_NoConfigEnvironmentParams()
{
key repository_dir "FSEntry"
key accept_unstable bool
+ key repository_type NoConfigEnvironmentRepositoryType
allow_named_args
}
diff --git a/ruby/environment.cc b/ruby/environment.cc
index c54b93d..943158a 100644
--- a/ruby/environment.cc
+++ b/ruby/environment.cc
@@ -215,7 +215,8 @@ namespace
NoConfigEnvironment * e(new NoConfigEnvironment(NoConfigEnvironmentParams::create()
.repository_dir(FSEntry(path))
- .accept_unstable(false)));
+ .accept_unstable(false)
+ .repository_type(ncer_auto)));
EnvironmentData * ptr(new EnvironmentData(e, e));
VALUE tdata(Data_Wrap_Struct(self, 0, &Common<EnvironmentData>::free, ptr));
rb_obj_call_init(tdata, 1, &s);
diff --git a/src/adjutrix/adjutrix.cc b/src/adjutrix/adjutrix.cc
index 8737fbd..2892f6e 100644
--- a/src/adjutrix/adjutrix.cc
+++ b/src/adjutrix/adjutrix.cc
@@ -147,7 +147,10 @@ main(int argc, char *argv[])
NoConfigEnvironment env(NoConfigEnvironmentParams::create()
.repository_dir(get_location_and_add_filters())
- .accept_unstable(CommandLine::get_instance()->a_unstable.specified()));
+ .accept_unstable(CommandLine::get_instance()->a_unstable.specified())
+ .repository_type(
+ (CommandLine::get_instance()->a_reverse_deps.specified()) ? ncer_auto : ncer_portage
+ ));
if (CommandLine::get_instance()->a_find_stable_candidates.specified())
{
diff --git a/src/adjutrix/find_reverse_deps.cc b/src/adjutrix/find_reverse_deps.cc
index e61a096..e0b7285 100644
--- a/src/adjutrix/find_reverse_deps.cc
+++ b/src/adjutrix/find_reverse_deps.cc
@@ -24,6 +24,7 @@
#include <paludis/util/compare.hh>
#include <paludis/util/collection_concrete.hh>
#include <paludis/util/save.hh>
+#include <paludis/util/log.hh>
#include <set>
#include <map>
@@ -120,8 +121,7 @@ namespace
void
ReverseDepChecker::visit(const PackageDepAtom * const a)
{
- PackageDatabaseEntryCollection::ConstPointer dep_entries(
- _db->query(*a, is_uninstalled_only));
+ PackageDatabaseEntryCollection::ConstPointer dep_entries(_db->query(*a, is_either));
PackageDatabaseEntryCollection::Pointer matches(new PackageDatabaseEntryCollection::Concrete);
bool header_written = false;
@@ -181,7 +181,7 @@ namespace
Context context("When checking package '" + stringify(p) + "':");
PackageDatabaseEntryCollection::Pointer p_entries(env.package_database()->query(
- PackageDepAtom::Pointer(new PackageDepAtom(stringify(p))), is_uninstalled_only));
+ PackageDepAtom::Pointer(new PackageDepAtom(stringify(p))), is_either));
bool found_matches(false);
@@ -245,13 +245,17 @@ int do_find_reverse_deps(NoConfigEnvironment & env)
int ret(0);
if (entries->empty())
+ {
+ Log::get_instance()->message(ll_warning, lc_context, "No matches in package database for '"
+ + stringify(*atom) + "'");
return 1;
+ }
for (IndirectIterator<PackageDatabase::RepositoryIterator, const Repository>
r(env.package_database()->begin_repositories()),
r_end(env.package_database()->end_repositories()) ; r != r_end ; ++r)
{
- if (r->name() == RepositoryName("virtuals"))
+ if (r->name() == RepositoryName("virtuals") || r->name() == RepositoryName("installed_virtuals"))
continue;
write_repository_header(stringify(*atom), stringify(r->name()));