aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-07-06 19:50:31 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-07-06 19:50:31 +0000
commit760839d5647537922b620e82a852a018d7a6c7d5 (patch)
treeee7a37a60696358d36bb218f67314290fb810242
parentbe44842a4a76f7e96af07879b6b29be9b506dea5 (diff)
downloadpaludis-760839d5647537922b620e82a852a018d7a6c7d5.tar.gz
paludis-760839d5647537922b620e82a852a018d7a6c7d5.tar.xz
Packages are now added to world unless either a restriction (slot, version) or --preserve-world is specified
-rw-r--r--paludis/environment.cc80
-rw-r--r--paludis/environment.hh8
-rw-r--r--src/install.cc31
-rw-r--r--src/uninstall.cc13
4 files changed, 105 insertions, 27 deletions
diff --git a/paludis/environment.cc b/paludis/environment.cc
index 1def7aa..14f1f2d 100644
--- a/paludis/environment.cc
+++ b/paludis/environment.cc
@@ -303,6 +303,21 @@ namespace
/// Matches
std::list<const PackageDepAtom *> items;
+ void (* add_callback)(const PackageDepAtom *);
+ void (* skip_callback)(const PackageDepAtom *, const std::string & why);
+
+ bool inside_any;
+ bool inside_use;
+
+ WorldTargetFinder(void (* a)(const PackageDepAtom *),
+ void (* s)(const PackageDepAtom *, const std::string &)) :
+ add_callback(a),
+ skip_callback(s),
+ inside_any(false),
+ inside_use(false)
+ {
+ }
+
///\name Visit methods
///{
void visit(const AllDepAtom * a)
@@ -310,12 +325,16 @@ namespace
std::for_each(a->begin(), a->end(), accept_visitor(this));
}
- void visit(const AnyDepAtom *)
+ void visit(const AnyDepAtom * a)
{
+ Save<bool> save_inside_any(&inside_any, true);
+ std::for_each(a->begin(), a->end(), accept_visitor(this));
}
- void visit(const UseDepAtom *)
+ void visit(const UseDepAtom * a)
{
+ Save<bool> save_inside_use(&inside_use, true);
+ std::for_each(a->begin(), a->end(), accept_visitor(this));
}
void visit(const PlainTextDepAtom *)
@@ -324,8 +343,32 @@ namespace
void visit(const PackageDepAtom * a)
{
- if (! (a->slot_ptr() || a->version_spec_ptr()))
+ if (inside_any)
+ {
+ if (skip_callback)
+ (*skip_callback)(a, "inside || ( ) block");
+ }
+ else if (inside_use)
+ {
+ if (skip_callback)
+ (*skip_callback)(a, "inside use? ( ) block");
+ }
+ else if (a->slot_ptr())
+ {
+ if (skip_callback)
+ (*skip_callback)(a, ":slot restrictions");
+ }
+ else if (a->version_spec_ptr())
+ {
+ if (skip_callback)
+ (*skip_callback)(a, "version restrictions");
+ }
+ else
+ {
items.push_back(a);
+ if (add_callback)
+ (*add_callback)(a);
+ }
}
void visit(const BlockDepAtom *)
@@ -337,32 +380,28 @@ namespace
}
void
-Environment::add_appropriate_to_world(DepAtom::ConstPointer a) const
+Environment::add_appropriate_to_world(DepAtom::ConstPointer a,
+ void (* add_callback)(const PackageDepAtom *),
+ void (* skip_callback)(const PackageDepAtom *, const std::string & why)) const
{
- WorldTargetFinder w;
+ WorldTargetFinder w(add_callback, skip_callback);
a->accept(&w);
for (std::list<const PackageDepAtom *>::const_iterator i(w.items.begin()),
i_end(w.items.end()) ; i != i_end ; ++i)
{
- if (! package_database()->query(**i, is_installed_only)->empty())
- Log::get_instance()->message(ll_debug, lc_no_context,
- "Not adding '" + stringify(**i) +
- "' to world, because it is already installed");
- else
- {
- for (PackageDatabase::RepositoryIterator r(package_database()->begin_repositories()),
- r_end(package_database()->end_repositories()) ;
- r != r_end ; ++r)
- if ((*r)->get_interface<repo_world>())
- (*r)->get_interface<repo_world>()->add_to_world((*i)->package());
- }
+ for (PackageDatabase::RepositoryIterator r(package_database()->begin_repositories()),
+ r_end(package_database()->end_repositories()) ;
+ r != r_end ; ++r)
+ if ((*r)->get_interface<repo_world>())
+ (*r)->get_interface<repo_world>()->add_to_world((*i)->package());
}
}
void
-Environment::remove_appropriate_from_world(DepAtom::ConstPointer a) const
+Environment::remove_appropriate_from_world(DepAtom::ConstPointer a,
+ void (* remove_callback)(const PackageDepAtom *)) const
{
- WorldTargetFinder w;
+ WorldTargetFinder w(0, 0);
a->accept(&w);
for (std::list<const PackageDepAtom *>::const_iterator i(w.items.begin()),
i_end(w.items.end()) ; i != i_end ; ++i)
@@ -372,6 +411,9 @@ Environment::remove_appropriate_from_world(DepAtom::ConstPointer a) const
r != r_end ; ++r)
if ((*r)->get_interface<repo_world>())
(*r)->get_interface<repo_world>()->remove_from_world((*i)->package());
+
+ if (remove_callback)
+ (*remove_callback)(*i);
}
}
diff --git a/paludis/environment.hh b/paludis/environment.hh
index 189c09d..d613fc3 100644
--- a/paludis/environment.hh
+++ b/paludis/environment.hh
@@ -208,12 +208,16 @@ namespace paludis
* Add packages to world, if they are not there already, and if they are
* not a restricted atom.
*/
- void add_appropriate_to_world(DepAtom::ConstPointer) const;
+ void
+ add_appropriate_to_world(DepAtom::ConstPointer a,
+ void (* add_callback)(const PackageDepAtom *) = 0,
+ void (* skip_callback)(const PackageDepAtom *, const std::string &) = 0) const;
/**
* Remove packages from world, if they are there.
*/
- void remove_appropriate_from_world(DepAtom::ConstPointer) const;
+ void remove_appropriate_from_world(DepAtom::ConstPointer,
+ void (* remove_callback)(const PackageDepAtom *) = 0) const;
/**
* Perform a hook.
diff --git a/src/install.cc b/src/install.cc
index be369aa..5958625 100644
--- a/src/install.cc
+++ b/src/install.cc
@@ -59,6 +59,18 @@ namespace
cout << endl;
}
};
+
+ void
+ world_add_callback(const p::PackageDepAtom * const p)
+ {
+ cout << "* adding " << *p << endl;
+ }
+
+ void
+ world_skip_callback(const p::PackageDepAtom * const p, const std::string & why)
+ {
+ cout << "* skipping " << *p << " (" << why << ")" << endl;
+ }
}
int
@@ -96,12 +108,12 @@ do_install()
if (CommandLine::get_instance()->a_fetch.specified())
opts.set<p::io_fetchonly>(true);
+ bool had_set_targets(false), had_pkg_targets(false);
try
{
CommandLine::ParametersIterator q(CommandLine::get_instance()->begin_parameters()),
q_end(CommandLine::get_instance()->end_parameters());
- bool had_set_targets(false), had_pkg_targets(false);
for ( ; q != q_end ; ++q)
{
p::DepAtom::Pointer s(0);
@@ -134,10 +146,6 @@ do_install()
if (had_set_targets)
dep_list.set_reinstall(false);
- else if ((! CommandLine::get_instance()->a_pretend.specified()) &&
- (! opts.get<p::io_fetchonly>()))
- if (! CommandLine::get_instance()->a_preserve_world.specified())
- env->add_appropriate_to_world(targets);
}
catch (const p::AmbiguousPackageNameError & e)
{
@@ -496,6 +504,19 @@ do_install()
}
}
+ if ((! had_set_targets) &&
+ (! CommandLine::get_instance()->a_pretend.specified()) &&
+ (! opts.get<p::io_fetchonly>()))
+ {
+ cout << endl << colour(cl_heading, "Updating world file") << endl << endl;
+ if (! CommandLine::get_instance()->a_preserve_world.specified())
+ env->add_appropriate_to_world(targets, &world_add_callback,
+ &world_skip_callback);
+ else
+ cout << "* --preserve-world was specified, skipping world adds" << endl;
+ }
+
+
if (opts.get<p::io_fetchonly>())
env->perform_hook(p::Hook("fetch_all_post")("TARGETS", p::join(
CommandLine::get_instance()->begin_parameters(),
diff --git a/src/uninstall.cc b/src/uninstall.cc
index df8202b..dd5c30d 100644
--- a/src/uninstall.cc
+++ b/src/uninstall.cc
@@ -32,6 +32,14 @@ using std::cerr;
using std::cout;
using std::endl;
+namespace
+{
+ void world_remove_callback(const p::PackageDepAtom * const p)
+ {
+ cout << "* removing " << *p << endl;
+ }
+}
+
int
do_uninstall()
{
@@ -97,6 +105,7 @@ do_uninstall()
if (CommandLine::get_instance()->a_pretend.specified())
return return_code;
+ cout << endl << colour(cl_heading, "Updating world file") << endl << endl;
if (! CommandLine::get_instance()->a_preserve_world.specified())
{
p::AllDepAtom::Pointer all(new p::AllDepAtom);
@@ -104,8 +113,10 @@ do_uninstall()
t_end(targets.end()) ; t != t_end ; ++t)
all->add_child(*t);
- env->remove_appropriate_from_world(all);
+ env->remove_appropriate_from_world(all, &world_remove_callback);
}
+ else
+ cout << "* --preserve-world was specified, skipping world removes" << endl;
p::InstallOptions opts(false, false);
if (CommandLine::get_instance()->a_no_config_protection.specified())