aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-02-04 05:27:06 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-02-04 05:27:06 +0000
commit959b3533b6b24ceb6056d4de58b7c37a90deb4b0 (patch)
treeaf4484079bd9d91e7a30527927dc6aa9ea00daf4
parent52a0625233533cf0de1d284f17dc3f5fe5704401 (diff)
downloadpaludis-959b3533b6b24ceb6056d4de58b7c37a90deb4b0.tar.gz
paludis-959b3533b6b24ceb6056d4de58b7c37a90deb4b0.tar.xz
Allow sets to appear in world
-rw-r--r--paludis/environment.cc83
-rw-r--r--paludis/environment.hh51
-rw-r--r--paludis/repositories/cran/cran_installed_repository.cc57
-rw-r--r--paludis/repositories/cran/cran_installed_repository.hh7
-rw-r--r--paludis/repositories/vdb/vdb_repository.cc60
-rw-r--r--paludis/repositories/vdb/vdb_repository.hh8
-rw-r--r--paludis/repository.hh10
-rw-r--r--paludis/tasks/install_task.cc19
-rw-r--r--paludis/tasks/install_task.hh2
-rw-r--r--src/clients/gtkpaludis/install.cc10
-rw-r--r--src/clients/gtkpaludis/install.hh4
-rw-r--r--src/output/console_install_task.cc19
-rw-r--r--src/output/console_install_task.hh3
13 files changed, 290 insertions, 43 deletions
diff --git a/paludis/environment.cc b/paludis/environment.cc
index 84afadb..c11992b 100644
--- a/paludis/environment.cc
+++ b/paludis/environment.cc
@@ -301,28 +301,28 @@ namespace
if (inside_any)
{
if (w)
- w->skip_callback(a, "inside || ( ) block");
+ w->skip_callback(*a, "inside || ( ) block");
}
else if (inside_use)
{
if (w)
- w->skip_callback(a, "inside use? ( ) block");
+ w->skip_callback(*a, "inside use? ( ) block");
}
else if (a->slot_ptr())
{
if (w)
- w->skip_callback(a, ":slot restrictions");
+ w->skip_callback(*a, ":slot restrictions");
}
else if (a->version_requirements_ptr() && ! a->version_requirements_ptr()->empty())
{
if (w)
- w->skip_callback(a, "version restrictions");
+ w->skip_callback(*a, "version restrictions");
}
else
{
items.push_back(a);
if (w)
- w->add_callback(a);
+ w->add_callback(*a);
}
}
@@ -352,6 +352,25 @@ Environment::add_appropriate_to_world(std::tr1::shared_ptr<const DepAtom> a,
}
void
+Environment::add_set_to_world(const SetName & s, Environment::WorldCallbacks * ww) const
+{
+ if (s == SetName("world") || s == SetName("system") || s == SetName("security")
+ || s == SetName("everything") || s == SetName("insecurity"))
+ {
+ if (ww)
+ ww->skip_callback(s, "special sets cannot be added to world");
+ return;
+ }
+
+ for (PackageDatabase::RepositoryIterator r(package_database()->begin_repositories()),
+ r_end(package_database()->end_repositories()) ;
+ r != r_end ; ++r)
+ if ((*r)->world_interface && (*r)->sets_interface)
+ if ((*r)->sets_interface->package_set(s))
+ (*r)->world_interface->add_to_world(s);
+}
+
+void
Environment::remove_appropriate_from_world(std::tr1::shared_ptr<const DepAtom> a,
Environment::WorldCallbacks * const ww) const
{
@@ -366,10 +385,24 @@ Environment::remove_appropriate_from_world(std::tr1::shared_ptr<const DepAtom> a
if ((*r)->world_interface)
(*r)->world_interface->remove_from_world((*i)->package());
- ww->remove_callback(*i);
+ ww->remove_callback(**i);
}
}
+void
+Environment::remove_set_from_world(const SetName & s,
+ Environment::WorldCallbacks * const ww) const
+{
+ for (PackageDatabase::RepositoryIterator r(package_database()->begin_repositories()),
+ r_end(package_database()->end_repositories()) ;
+ r != r_end ; ++r)
+ if ((*r)->world_interface)
+ (*r)->world_interface->remove_from_world(s);
+
+ if (ww)
+ ww->remove_callback(s);
+}
+
Hook::Hook(const std::string & n) :
_name(n)
{
@@ -517,3 +550,41 @@ Environment::accept_eapi(const std::string & e) const
return e == "0" || e == "" || e == "paludis-1" || e == "CRAN-1";
}
+Environment::WorldCallbacks::WorldCallbacks()
+{
+}
+
+Environment::WorldCallbacks::~WorldCallbacks()
+{
+}
+
+void
+Environment::WorldCallbacks::add_callback(const PackageDepAtom &)
+{
+}
+
+void
+Environment::WorldCallbacks::skip_callback(const PackageDepAtom &, const std::string &)
+{
+}
+
+void
+Environment::WorldCallbacks::remove_callback(const PackageDepAtom &)
+{
+}
+
+void
+Environment::WorldCallbacks::add_callback(const SetName &)
+{
+}
+
+void
+Environment::WorldCallbacks::skip_callback(const SetName &, const std::string &)
+{
+}
+
+void
+Environment::WorldCallbacks::remove_callback(const SetName &)
+{
+}
+
diff --git a/paludis/environment.hh b/paludis/environment.hh
index 6366210..8a958e3 100644
--- a/paludis/environment.hh
+++ b/paludis/environment.hh
@@ -286,9 +286,7 @@ namespace paludis
///\name Basic operations
///\{
- WorldCallbacks()
- {
- }
+ WorldCallbacks();
///\}
@@ -296,46 +294,61 @@ namespace paludis
///\name Basic operations
///\{
- virtual ~WorldCallbacks()
- {
- }
+ virtual ~WorldCallbacks();
///\}
/**
* Called when adding an entry to world.
*/
- virtual void add_callback(const PackageDepAtom *)
- {
- }
+ virtual void add_callback(const PackageDepAtom &);
/**
* Called when skipping adding an entry to world.
*/
- virtual void skip_callback(const PackageDepAtom *,
- const std::string &)
- {
- }
+ virtual void skip_callback(const PackageDepAtom &, const std::string &);
/**
* Called when removing an entry to world.
*/
- virtual void remove_callback(const PackageDepAtom *)
- {
- }
+ virtual void remove_callback(const PackageDepAtom &);
+
+ /**
+ * Called when adding an entry to world.
+ */
+ virtual void add_callback(const SetName &);
+
+ /**
+ * Called when skipping adding an entry to world.
+ */
+ virtual void skip_callback(const SetName &, const std::string &);
+
+ /**
+ * Called when removing an entry from world.
+ */
+ virtual void remove_callback(const SetName &);
};
/**
* Add packages to world, if they are not there already, and if they are
* not a restricted atom.
*/
- void
- add_appropriate_to_world(std::tr1::shared_ptr<const DepAtom> a, WorldCallbacks * const) const;
+ void add_appropriate_to_world(std::tr1::shared_ptr<const DepAtom> a, WorldCallbacks *) const;
/**
* Remove packages from world, if they are there.
*/
- void remove_appropriate_from_world(std::tr1::shared_ptr<const DepAtom>, WorldCallbacks * const) const;
+ void remove_appropriate_from_world(std::tr1::shared_ptr<const DepAtom>, WorldCallbacks *) const;
+
+ /**
+ * Add a set to world, if it's not inappropriate.
+ */
+ void add_set_to_world(const SetName &, WorldCallbacks *) const;
+
+ /**
+ * Remove a set from world.
+ */
+ void remove_set_from_world(const SetName &, WorldCallbacks *) const;
/**
* Perform a hook.
diff --git a/paludis/repositories/cran/cran_installed_repository.cc b/paludis/repositories/cran/cran_installed_repository.cc
index e767d55..56485f8 100644
--- a/paludis/repositories/cran/cran_installed_repository.cc
+++ b/paludis/repositories/cran/cran_installed_repository.cc
@@ -570,8 +570,30 @@ CRANInstalledRepository::do_package_set(const SetName & s) const
for (LineConfigFile::Iterator line(world.begin()), line_end(world.end()) ;
line != line_end ; ++line)
{
- std::tr1::shared_ptr<PackageDepAtom> atom(new PackageDepAtom(QualifiedPackageName(*line)));
- result->add_child(atom);
+ try
+ {
+ if (std::string::npos == line->find('/'))
+ {
+ std::tr1::shared_ptr<DepAtom> atom(_imp->env->package_set(SetName(*line)));
+ if (atom)
+ result->add_child(atom);
+ else
+ Log::get_instance()->message(ll_warning, lc_no_context,
+ "Entry '" + stringify(*line) + "' in world file '" + stringify(_imp->world_file)
+ + "' is not a known set");
+ }
+ else
+ {
+ std::tr1::shared_ptr<PackageDepAtom> atom(new PackageDepAtom(QualifiedPackageName(*line)));
+ result->add_child(atom);
+ }
+ }
+ catch (const NameError & e)
+ {
+ Log::get_instance()->message(ll_warning, lc_no_context,
+ "Entry '" + stringify(*line) + "' in world file '" + stringify(_imp->world_file)
+ + "' gave error '" + e.message() + "' (" + e.what() + ")");
+ }
}
}
else
@@ -602,7 +624,7 @@ CRANInstalledRepository::invalidate()
}
void
-CRANInstalledRepository::add_to_world(const QualifiedPackageName & n) const
+CRANInstalledRepository::add_string_to_world(const std::string & n) const
{
bool found(false);
@@ -612,7 +634,7 @@ CRANInstalledRepository::add_to_world(const QualifiedPackageName & n) const
for (LineConfigFile::Iterator line(world.begin()), line_end(world.end()) ;
line != line_end ; ++line)
- if (QualifiedPackageName(*line) == n)
+ if (*line == n)
{
found = true;
break;
@@ -631,7 +653,7 @@ CRANInstalledRepository::add_to_world(const QualifiedPackageName & n) const
}
void
-CRANInstalledRepository::remove_from_world(const QualifiedPackageName & n) const
+CRANInstalledRepository::remove_string_from_world(const std::string & n) const
{
std::list<std::string> world_lines;
@@ -649,7 +671,7 @@ CRANInstalledRepository::remove_from_world(const QualifiedPackageName & n) const
std::string line;
while (std::getline(world_file, line))
{
- if (strip_leading(strip_trailing(line, " \t"), "\t") != stringify(n))
+ if (strip_leading(strip_trailing(line, " \t"), "\t") != n)
world_lines.push_back(line);
else
Log::get_instance()->message(ll_debug, lc_context, "Removing line '"
@@ -676,4 +698,27 @@ CRANInstalledRepository::is_suitable_destination_for(const PackageDatabaseEntry
return _imp->env->package_database()->fetch_repository(e.repository)->format() == "cran";
}
+void
+CRANInstalledRepository::add_to_world(const QualifiedPackageName & n) const
+{
+ add_string_to_world(stringify(n));
+}
+
+void
+CRANInstalledRepository::remove_from_world(const QualifiedPackageName & n) const
+{
+ remove_string_from_world(stringify(n));
+}
+
+void
+CRANInstalledRepository::add_to_world(const SetName & n) const
+{
+ add_string_to_world(stringify(n));
+}
+
+void
+CRANInstalledRepository::remove_from_world(const SetName & n) const
+{
+ remove_string_from_world(stringify(n));
+}
diff --git a/paludis/repositories/cran/cran_installed_repository.hh b/paludis/repositories/cran/cran_installed_repository.hh
index b0f7157..9c6f772 100644
--- a/paludis/repositories/cran/cran_installed_repository.hh
+++ b/paludis/repositories/cran/cran_installed_repository.hh
@@ -90,6 +90,9 @@ namespace paludis
virtual std::tr1::shared_ptr<const SetsCollection> sets_list() const;
+ virtual void add_string_to_world(const std::string &) const;
+ virtual void remove_string_from_world(const std::string &) const;
+
public:
/**
* Constructor.
@@ -114,6 +117,10 @@ namespace paludis
virtual void remove_from_world(const QualifiedPackageName &) const;
+ virtual void add_to_world(const SetName &) const;
+
+ virtual void remove_from_world(const SetName &) const;
+
virtual bool is_suitable_destination_for(const PackageDatabaseEntry &) const;
};
diff --git a/paludis/repositories/vdb/vdb_repository.cc b/paludis/repositories/vdb/vdb_repository.cc
index bc56970..32e5d5f 100644
--- a/paludis/repositories/vdb/vdb_repository.cc
+++ b/paludis/repositories/vdb/vdb_repository.cc
@@ -979,9 +979,31 @@ VDBRepository::do_package_set(const SetName & s) const
for (LineConfigFile::Iterator line(world.begin()), line_end(world.end()) ;
line != line_end ; ++line)
{
- std::tr1::shared_ptr<PackageDepAtom> atom(new PackageDepAtom(QualifiedPackageName(*line)));
- atom->set_tag(tag);
- result->add_child(atom);
+ try
+ {
+ if (std::string::npos == line->find('/'))
+ {
+ std::tr1::shared_ptr<DepAtom> atom(_imp->env->package_set(SetName(*line)));
+ if (atom)
+ result->add_child(atom);
+ else
+ Log::get_instance()->message(ll_warning, lc_no_context, "World file '"
+ + stringify(_imp->world_file) + "' entry '" + *line +
+ " is not a known package set");
+ }
+ else
+ {
+ std::tr1::shared_ptr<PackageDepAtom> atom(new PackageDepAtom(QualifiedPackageName(*line)));
+ atom->set_tag(tag);
+ result->add_child(atom);
+ }
+ }
+ catch (const NameError & n)
+ {
+ Log::get_instance()->message(ll_warning, lc_no_context, "World file '"
+ + stringify(_imp->world_file) + "' entry '" + *line + " is broken: '"
+ + n.message() + "' (" + n.what() + ")");
+ }
}
}
else
@@ -1013,9 +1035,9 @@ VDBRepository::invalidate()
}
void
-VDBRepository::add_to_world(const QualifiedPackageName & n) const
+VDBRepository::add_string_to_world(const std::string & n) const
{
- Context context("When adding '" + stringify(n) + "' to world file '" +
+ Context context("When adding '" + n + "' to world file '" +
stringify(_imp->world_file) + "':");
bool found(false);
@@ -1026,7 +1048,7 @@ VDBRepository::add_to_world(const QualifiedPackageName & n) const
for (LineConfigFile::Iterator line(world.begin()), line_end(world.end()) ;
line != line_end ; ++line)
- if (QualifiedPackageName(*line) == n)
+ if (*line == n)
{
found = true;
break;
@@ -1070,7 +1092,7 @@ VDBRepository::add_to_world(const QualifiedPackageName & n) const
}
void
-VDBRepository::remove_from_world(const QualifiedPackageName & n) const
+VDBRepository::remove_string_from_world(const std::string & n) const
{
std::list<std::string> world_lines;
@@ -1109,6 +1131,30 @@ VDBRepository::remove_from_world(const QualifiedPackageName & n) const
std::ostream_iterator<std::string>(world_file, "\n"));
}
+void
+VDBRepository::add_to_world(const QualifiedPackageName & n) const
+{
+ add_string_to_world(stringify(n));
+}
+
+void
+VDBRepository::add_to_world(const SetName & n) const
+{
+ add_string_to_world(stringify(n));
+}
+
+void
+VDBRepository::remove_from_world(const QualifiedPackageName & n) const
+{
+ remove_string_from_world(stringify(n));
+}
+
+void
+VDBRepository::remove_from_world(const SetName & n) const
+{
+ remove_string_from_world(stringify(n));
+}
+
std::string
VDBRepository::get_environment_variable(
const PackageDatabaseEntry & for_package,
diff --git a/paludis/repositories/vdb/vdb_repository.hh b/paludis/repositories/vdb/vdb_repository.hh
index df05438..780c7c3 100644
--- a/paludis/repositories/vdb/vdb_repository.hh
+++ b/paludis/repositories/vdb/vdb_repository.hh
@@ -114,6 +114,10 @@ namespace paludis
virtual std::tr1::shared_ptr<const CategoryNamePartCollection> do_category_names_containing_package(
const PackageNamePart &) const;
+ virtual void add_string_to_world(const std::string &) const;
+
+ virtual void remove_string_from_world(const std::string &) const;
+
public:
/**
* Constructor.
@@ -140,6 +144,10 @@ namespace paludis
virtual void remove_from_world(const QualifiedPackageName &) const;
+ virtual void add_to_world(const SetName &) const;
+
+ virtual void remove_from_world(const SetName &) const;
+
virtual std::string get_environment_variable(
const PackageDatabaseEntry & for_package,
const std::string & var) const;
diff --git a/paludis/repository.hh b/paludis/repository.hh
index 1f9dc46..71a7846 100644
--- a/paludis/repository.hh
+++ b/paludis/repository.hh
@@ -810,10 +810,20 @@ namespace paludis
virtual void add_to_world(const QualifiedPackageName &) const = 0;
/**
+ * Add this set to world.
+ */
+ virtual void add_to_world(const SetName &) const = 0;
+
+ /**
* Remove this package from world, if it is present.
*/
virtual void remove_from_world(const QualifiedPackageName &) const = 0;
+ /**
+ * Remove this set from world, if it is present.
+ */
+ virtual void remove_from_world(const SetName &) const = 0;
+
///\}
virtual ~RepositoryWorldInterface();
diff --git a/paludis/tasks/install_task.cc b/paludis/tasks/install_task.cc
index ffd9339..26c8ef5 100644
--- a/paludis/tasks/install_task.cc
+++ b/paludis/tasks/install_task.cc
@@ -152,15 +152,26 @@ namespace
{
}
- virtual void add_callback(const PackageDepAtom * a)
+ virtual void add_callback(const PackageDepAtom & a)
{
- t->on_update_world(*a);
+ t->on_update_world(a);
}
- virtual void skip_callback(const PackageDepAtom * a,
+ virtual void add_callback(const SetName & a)
+ {
+ t->on_update_world(a);
+ }
+
+ virtual void skip_callback(const PackageDepAtom & a,
+ const std::string & s)
+ {
+ t->on_update_world_skip(a, s);
+ }
+
+ virtual void skip_callback(const SetName & a,
const std::string & s)
{
- t->on_update_world_skip(*a, s);
+ t->on_update_world_skip(a, s);
}
};
}
diff --git a/paludis/tasks/install_task.hh b/paludis/tasks/install_task.hh
index ecceac1..766fded 100644
--- a/paludis/tasks/install_task.hh
+++ b/paludis/tasks/install_task.hh
@@ -143,7 +143,9 @@ namespace paludis
virtual void on_update_world_pre() = 0;
virtual void on_update_world(const PackageDepAtom &) = 0;
+ virtual void on_update_world(const SetName &) = 0;
virtual void on_update_world_skip(const PackageDepAtom &, const std::string &) = 0;
+ virtual void on_update_world_skip(const SetName &, const std::string &) = 0;
virtual void on_update_world_post() = 0;
virtual void on_preserve_world() = 0;
diff --git a/src/clients/gtkpaludis/install.cc b/src/clients/gtkpaludis/install.cc
index 751689e..cb5fabb 100644
--- a/src/clients/gtkpaludis/install.cc
+++ b/src/clients/gtkpaludis/install.cc
@@ -169,11 +169,21 @@ OurInstallTask::on_update_world(const PackageDepAtom &)
}
void
+OurInstallTask::on_update_world(const SetName &)
+{
+}
+
+void
OurInstallTask::on_update_world_skip(const PackageDepAtom &, const std::string &)
{
}
void
+OurInstallTask::on_update_world_skip(const SetName &, const std::string &)
+{
+}
+
+void
OurInstallTask::on_update_world_post()
{
}
diff --git a/src/clients/gtkpaludis/install.hh b/src/clients/gtkpaludis/install.hh
index 871192d..23e3b48 100644
--- a/src/clients/gtkpaludis/install.hh
+++ b/src/clients/gtkpaludis/install.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2006 Ciaran McCreesh <ciaranm@ciaranm.org>
+ * Copyright (c) 2006, 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -64,6 +64,8 @@ namespace gtkpaludis
virtual void on_update_world_pre();
virtual void on_update_world(const paludis::PackageDepAtom &);
virtual void on_update_world_skip(const paludis::PackageDepAtom &, const std::string &);
+ virtual void on_update_world(const paludis::SetName &);
+ virtual void on_update_world_skip(const paludis::SetName &, const std::string &);
virtual void on_update_world_post();
virtual void on_preserve_world();
diff --git a/src/output/console_install_task.cc b/src/output/console_install_task.cc
index cbd7f52..9d301e3 100644
--- a/src/output/console_install_task.cc
+++ b/src/output/console_install_task.cc
@@ -292,6 +292,12 @@ ConsoleInstallTask::on_update_world(const PackageDepAtom & a)
}
void
+ConsoleInstallTask::on_update_world(const SetName & a)
+{
+ output_starred_item("adding " + render_as_set_name(stringify(a)));
+}
+
+void
ConsoleInstallTask::on_update_world_skip(const PackageDepAtom & a, const std::string & s)
{
output_starred_item("skipping " + render_as_package_name(stringify(a)) + " ("
@@ -299,6 +305,13 @@ ConsoleInstallTask::on_update_world_skip(const PackageDepAtom & a, const std::st
}
void
+ConsoleInstallTask::on_update_world_skip(const SetName & a, const std::string & s)
+{
+ output_starred_item("skipping " + render_as_set_name(stringify(a)) + " ("
+ + s + ")");
+}
+
+void
ConsoleInstallTask::on_update_world_post()
{
}
@@ -1048,6 +1061,12 @@ ConsoleInstallTask::render_as_package_name(const std::string & s) const
}
std::string
+ConsoleInstallTask::render_as_set_name(const std::string & s) const
+{
+ return colour(cl_package_name, s);
+}
+
+std::string
ConsoleInstallTask::render_as_tag(const std::string & s) const
{
return colour(cl_tag, s);
diff --git a/src/output/console_install_task.hh b/src/output/console_install_task.hh
index cf9e7fb..7b7cd37 100644
--- a/src/output/console_install_task.hh
+++ b/src/output/console_install_task.hh
@@ -155,7 +155,9 @@ namespace paludis
virtual void on_update_world_pre();
virtual void on_update_world(const PackageDepAtom &);
+ virtual void on_update_world(const SetName &);
virtual void on_update_world_skip(const PackageDepAtom &, const std::string &);
+ virtual void on_update_world_skip(const SetName &, const std::string &);
virtual void on_update_world_post();
virtual void on_preserve_world();
@@ -181,6 +183,7 @@ namespace paludis
///\{
virtual std::string render_as_package_name(const std::string &) const;
+ virtual std::string render_as_set_name(const std::string &) const;
virtual std::string render_as_tag(const std::string &) const;
virtual std::string render_as_unimportant(const std::string &) const;
virtual std::string render_as_error(const std::string &) const;