aboutsummaryrefslogtreecommitdiff
path: root/paludis/environments
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2008-03-09 14:07:05 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2008-03-09 14:07:05 +0000
commita297ce7c92fc48b2e5f7df4a2624c25ddab3b81d (patch)
treef3d4c5c11709d26bebdf0e7e424b569dcd992253 /paludis/environments
parent410f8b38e6bb0feb13e2d5e5c3ac34c4e87c0fee (diff)
downloadpaludis-a297ce7c92fc48b2e5f7df4a2624c25ddab3b81d.tar.gz
paludis-a297ce7c92fc48b2e5f7df4a2624c25ddab3b81d.tar.xz
world is now in env, not repos. Fixes: ticket:421
Diffstat (limited to 'paludis/environments')
-rw-r--r--paludis/environments/adapted/adapted_environment.cc26
-rw-r--r--paludis/environments/adapted/adapted_environment.hh10
-rw-r--r--paludis/environments/no_config/no_config_environment.cc26
-rw-r--r--paludis/environments/no_config/no_config_environment.hh14
-rw-r--r--paludis/environments/paludis/Makefile.am2
-rw-r--r--paludis/environments/paludis/paludis_config.cc19
-rw-r--r--paludis/environments/paludis/paludis_config.hh4
-rw-r--r--paludis/environments/paludis/paludis_environment.cc31
-rw-r--r--paludis/environments/paludis/paludis_environment.hh13
-rw-r--r--paludis/environments/paludis/world.cc180
-rw-r--r--paludis/environments/paludis/world.hh57
-rw-r--r--paludis/environments/portage/portage_environment.cc119
-rw-r--r--paludis/environments/portage/portage_environment.hh16
-rw-r--r--paludis/environments/test/test_environment.cc28
-rw-r--r--paludis/environments/test/test_environment.hh13
15 files changed, 545 insertions, 13 deletions
diff --git a/paludis/environments/adapted/adapted_environment.cc b/paludis/environments/adapted/adapted_environment.cc
index d4736ffb8..17e67cfa0 100644
--- a/paludis/environments/adapted/adapted_environment.cc
+++ b/paludis/environments/adapted/adapted_environment.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2007 Ciaran McCreesh
+ * Copyright (c) 2007, 2008 Ciaran McCreesh
*
* 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
@@ -238,3 +238,27 @@ AdaptedEnvironment::is_paludis_package(const QualifiedPackageName & q) const
return _imp->env->is_paludis_package(q);
}
+void
+AdaptedEnvironment::add_to_world(const QualifiedPackageName & q) const
+{
+ _imp->env->add_to_world(q);
+}
+
+void
+AdaptedEnvironment::add_to_world(const SetName & s) const
+{
+ _imp->env->add_to_world(s);
+}
+
+void
+AdaptedEnvironment::remove_from_world(const QualifiedPackageName & q) const
+{
+ _imp->env->remove_from_world(q);
+}
+
+void
+AdaptedEnvironment::remove_from_world(const SetName & s) const
+{
+ _imp->env->remove_from_world(s);
+}
+
diff --git a/paludis/environments/adapted/adapted_environment.hh b/paludis/environments/adapted/adapted_environment.hh
index 0683eb188..e64d0ff75 100644
--- a/paludis/environments/adapted/adapted_environment.hh
+++ b/paludis/environments/adapted/adapted_environment.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2007 Ciaran McCreesh
+ * Copyright (c) 2007, 2008 Ciaran McCreesh
*
* 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
@@ -127,6 +127,14 @@ namespace paludis
PALUDIS_ATTRIBUTE((warn_unused_result));
virtual bool is_paludis_package(const QualifiedPackageName &) const PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual void add_to_world(const QualifiedPackageName &) const;
+
+ virtual void add_to_world(const SetName &) const;
+
+ virtual void remove_from_world(const QualifiedPackageName &) const;
+
+ virtual void remove_from_world(const SetName &) const;
};
}
diff --git a/paludis/environments/no_config/no_config_environment.cc b/paludis/environments/no_config/no_config_environment.cc
index dd9657ff0..c75ecf3b5 100644
--- a/paludis/environments/no_config/no_config_environment.cc
+++ b/paludis/environments/no_config/no_config_environment.cc
@@ -364,6 +364,32 @@ NoConfigEnvironment::local_set(const SetName &) const
return tr1::shared_ptr<SetSpecTree::ConstItem>();
}
+tr1::shared_ptr<SetSpecTree::ConstItem>
+NoConfigEnvironment::world_set() const
+{
+ return tr1::shared_ptr<SetSpecTree::ConstItem>();
+}
+
+void
+NoConfigEnvironment::add_to_world(const QualifiedPackageName &) const
+{
+}
+
+void
+NoConfigEnvironment::remove_from_world(const QualifiedPackageName &) const
+{
+}
+
+void
+NoConfigEnvironment::add_to_world(const SetName &) const
+{
+}
+
+void
+NoConfigEnvironment::remove_from_world(const SetName &) const
+{
+}
+
bool
NoConfigEnvironment::unmasked_by_user(const PackageID &) const
{
diff --git a/paludis/environments/no_config/no_config_environment.hh b/paludis/environments/no_config/no_config_environment.hh
index 9c49b0641..1946be2f1 100644
--- a/paludis/environments/no_config/no_config_environment.hh
+++ b/paludis/environments/no_config/no_config_environment.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2006, 2007 Ciaran McCreesh
+ * Copyright (c) 2006, 2007, 2008 Ciaran McCreesh
*
* 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
@@ -58,10 +58,12 @@ namespace paludis
private InstantiationPolicy<NoConfigEnvironment, instantiation_method::NonCopyableTag>
{
protected:
-
virtual tr1::shared_ptr<SetSpecTree::ConstItem> local_set(const SetName &) const
PALUDIS_ATTRIBUTE((warn_unused_result));
+ virtual tr1::shared_ptr<SetSpecTree::ConstItem> world_set() const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
public:
///\name Basic operations
///\{
@@ -156,6 +158,14 @@ namespace paludis
virtual HookResult perform_hook(const Hook &) const
PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual void add_to_world(const QualifiedPackageName &) const;
+
+ virtual void add_to_world(const SetName &) const;
+
+ virtual void remove_from_world(const QualifiedPackageName &) const;
+
+ virtual void remove_from_world(const SetName &) const;
};
}
diff --git a/paludis/environments/paludis/Makefile.am b/paludis/environments/paludis/Makefile.am
index 1bbd956ec..3c059b487 100644
--- a/paludis/environments/paludis/Makefile.am
+++ b/paludis/environments/paludis/Makefile.am
@@ -18,6 +18,7 @@ libpaludispaludisenvironment_la_SOURCES = \
package_mask_conf.cc package_mask_conf.hh \
use_conf.cc use_conf.hh \
mirrors_conf.cc mirrors_conf.hh \
+ world.cc world.hh \
paludis_config.cc paludis_config.hh \
paludis_environment.cc paludis_environment.hh \
registration.cc
@@ -55,6 +56,7 @@ paludis_environment_paludis_include_HEADERS = \
licenses_conf.hh \
bashable_conf.hh \
package_mask_conf.hh \
+ world.hh \
mirrors_conf.hh
EXTRA_DIST = \
diff --git a/paludis/environments/paludis/paludis_config.cc b/paludis/environments/paludis/paludis_config.cc
index 603f44b04..f8969d6cb 100644
--- a/paludis/environments/paludis/paludis_config.cc
+++ b/paludis/environments/paludis/paludis_config.cc
@@ -24,6 +24,7 @@
#include <paludis/environments/paludis/mirrors_conf.hh>
#include <paludis/environments/paludis/licenses_conf.hh>
#include <paludis/environments/paludis/package_mask_conf.hh>
+#include <paludis/environments/paludis/world.hh>
#include <paludis/util/config_file.hh>
#include <paludis/distribution.hh>
@@ -100,6 +101,7 @@ namespace paludis
tr1::shared_ptr<PackageMaskConf> package_mask_conf;
tr1::shared_ptr<PackageMaskConf> package_unmask_conf;
tr1::shared_ptr<MirrorsConf> mirrors_conf;
+ mutable tr1::shared_ptr<World> world;
mutable Mutex reduced_mutex;
mutable tr1::shared_ptr<uid_t> reduced_uid;
@@ -143,6 +145,7 @@ namespace paludis
Context context("When loading environment.conf:");
tr1::shared_ptr<KeyValueConfigFile> kv;
+ tr1::shared_ptr<FSEntry> world_file;
if ((FSEntry(config_dir) / "environment.conf").exists())
kv.reset(new KeyValueConfigFile(FSEntry(config_dir) / "environment.conf", KeyValueConfigFileOptions()));
@@ -182,8 +185,17 @@ namespace paludis
accept_breaks_portage = kv->get("portage_compatible").empty();
distribution = kv->get("distribution");
+
+ if (! kv->get("world").empty())
+ world_file.reset(new FSEntry(kv->get("world")));
}
+ if (! world_file)
+ Log::get_instance()->message(ll_warning, lc_context) << "No world file specified. You should "
+ "specify 'world = /path/to/world/file' in " << (FSEntry(config_dir) / "environment.conf")
+ << ". Any attempted updates to world will not be saved.";
+ world.reset(new World(env, world_file));
+
has_environment_conf = true;
}
}
@@ -705,6 +717,13 @@ PaludisConfig::mirrors_conf() const
return _imp->mirrors_conf;
}
+tr1::shared_ptr<const World>
+PaludisConfig::world() const
+{
+ _imp->need_environment_conf();
+ return _imp->world;
+}
+
std::string
PaludisConfig::distribution() const
{
diff --git a/paludis/environments/paludis/paludis_config.hh b/paludis/environments/paludis/paludis_config.hh
index 853480551..93d901ff3 100644
--- a/paludis/environments/paludis/paludis_config.hh
+++ b/paludis/environments/paludis/paludis_config.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2006, 2007 Ciaran McCreesh
+ * Copyright (c) 2006, 2007, 2008 Ciaran McCreesh
*
* 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
@@ -49,6 +49,7 @@ namespace paludis
struct LicensesConf;
struct PackageMaskConf;
struct MirrorsConf;
+ struct World;
/**
* A PaludisConfigError is thrown if a configuration error is encountered
@@ -119,6 +120,7 @@ namespace paludis
tr1::shared_ptr<const PackageMaskConf> package_mask_conf() const;
tr1::shared_ptr<const PackageMaskConf> package_unmask_conf() const;
tr1::shared_ptr<const MirrorsConf> mirrors_conf() const;
+ tr1::shared_ptr<const World> world() const;
///\}
diff --git a/paludis/environments/paludis/paludis_environment.cc b/paludis/environments/paludis/paludis_environment.cc
index 892bf178a..555eb89e2 100644
--- a/paludis/environments/paludis/paludis_environment.cc
+++ b/paludis/environments/paludis/paludis_environment.cc
@@ -24,6 +24,7 @@
#include <paludis/environments/paludis/package_mask_conf.hh>
#include <paludis/environments/paludis/licenses_conf.hh>
#include <paludis/environments/paludis/mirrors_conf.hh>
+#include <paludis/environments/paludis/world.hh>
#include <paludis/repository_maker.hh>
@@ -386,6 +387,36 @@ PaludisEnvironment::local_set(const SetName & s) const
}
}
+tr1::shared_ptr<SetSpecTree::ConstItem>
+PaludisEnvironment::world_set() const
+{
+ return _imp->config->world()->world_set();
+}
+
+void
+PaludisEnvironment::add_to_world(const QualifiedPackageName & q) const
+{
+ _imp->config->world()->add_to_world(q);
+}
+
+void
+PaludisEnvironment::add_to_world(const SetName & s) const
+{
+ _imp->config->world()->add_to_world(s);
+}
+
+void
+PaludisEnvironment::remove_from_world(const QualifiedPackageName & q) const
+{
+ _imp->config->world()->remove_from_world(q);
+}
+
+void
+PaludisEnvironment::remove_from_world(const SetName & s) const
+{
+ _imp->config->world()->remove_from_world(s);
+}
+
tr1::shared_ptr<const SetNameSet>
PaludisEnvironment::set_names() const
{
diff --git a/paludis/environments/paludis/paludis_environment.hh b/paludis/environments/paludis/paludis_environment.hh
index 148ec4427..af767695f 100644
--- a/paludis/environments/paludis/paludis_environment.hh
+++ b/paludis/environments/paludis/paludis_environment.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2005, 2006, 2007 Ciaran McCreesh
+ * Copyright (c) 2005, 2006, 2007, 2008 Ciaran McCreesh
*
* 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
@@ -50,9 +50,10 @@ namespace paludis
private PrivateImplementationPattern<PaludisEnvironment>
{
protected:
-
virtual tr1::shared_ptr<SetSpecTree::ConstItem> local_set(const SetName & id) const;
+ virtual tr1::shared_ptr<SetSpecTree::ConstItem> world_set() const;
+
public:
///\name Basic operations
///\{
@@ -138,6 +139,14 @@ namespace paludis
virtual bool unmasked_by_user(const PackageID &) const
PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual void add_to_world(const QualifiedPackageName &) const;
+
+ virtual void add_to_world(const SetName &) const;
+
+ virtual void remove_from_world(const QualifiedPackageName &) const;
+
+ virtual void remove_from_world(const SetName &) const;
};
}
#endif
diff --git a/paludis/environments/paludis/world.cc b/paludis/environments/paludis/world.cc
new file mode 100644
index 000000000..8388168f6
--- /dev/null
+++ b/paludis/environments/paludis/world.cc
@@ -0,0 +1,180 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2008 Ciaran McCreesh
+ *
+ * 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
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <paludis/environments/paludis/world.hh>
+#include <paludis/util/private_implementation_pattern-impl.hh>
+#include <paludis/util/fs_entry.hh>
+#include <paludis/util/mutex.hh>
+#include <paludis/util/stringify.hh>
+#include <paludis/util/tr1_functional.hh>
+#include <paludis/util/log.hh>
+#include <paludis/set_file.hh>
+#include <paludis/user_dep_spec.hh>
+#include <paludis/dep_tag.hh>
+#include <fstream>
+
+using namespace paludis;
+using namespace paludis::paludis_environment;
+
+namespace paludis
+{
+ template <>
+ struct Implementation<World>
+ {
+ const Environment * const env;
+ const tr1::shared_ptr<const FSEntry> maybe_world_file;
+ mutable Mutex mutex;
+
+ Implementation(const Environment * const e, const tr1::shared_ptr<const FSEntry> & m) :
+ env(e),
+ maybe_world_file(m)
+ {
+ }
+ };
+}
+
+World::World(const Environment * const e, const tr1::shared_ptr<const FSEntry> & f) :
+ PrivateImplementationPattern<World>(new Implementation<World>(e, f))
+{
+}
+
+World::~World()
+{
+}
+
+void
+World::add_to_world(const SetName & s) const
+{
+ _add_string_to_world(stringify(s));
+}
+
+void
+World::add_to_world(const QualifiedPackageName & q) const
+{
+ _add_string_to_world(stringify(q));
+}
+
+void
+World::remove_from_world(const SetName & s) const
+{
+ _remove_string_from_world(stringify(s));
+}
+
+void
+World::remove_from_world(const QualifiedPackageName & q) const
+{
+ _remove_string_from_world(stringify(q));
+}
+
+void
+World::_add_string_to_world(const std::string & n) const
+{
+ using namespace tr1::placeholders;
+
+ if (! _imp->maybe_world_file)
+ {
+ Log::get_instance()->message(ll_warning, lc_context) << "Not adding '" << n << "' to world because "
+ "no world file has been configured. If you have recently upgraded from <paludis-0.26.0_alpha13, consult "
+ "the FAQ Upgrades section.";
+ return;
+ }
+
+ Lock l(_imp->mutex);
+
+ Context context("When adding '" + n + "' to world file '" + stringify(*_imp->maybe_world_file) + "':");
+
+ if (! _imp->maybe_world_file->exists())
+ {
+ std::ofstream f(stringify(*_imp->maybe_world_file).c_str());
+ if (! f)
+ {
+ Log::get_instance()->message(ll_warning, lc_no_context, "Cannot create world file '"
+ + stringify(*_imp->maybe_world_file) + "'");
+ return;
+ }
+ }
+
+ SetFile world(SetFileParams::create()
+ .file_name(*_imp->maybe_world_file)
+ .type(sft_simple)
+ .parser(tr1::bind(&parse_user_package_dep_spec, _1, UserPackageDepSpecOptions()))
+ .tag(tr1::shared_ptr<DepTag>())
+ .environment(_imp->env));
+ world.add(n);
+ world.rewrite();
+}
+
+void
+World::_remove_string_from_world(const std::string & n) const
+{
+ using namespace tr1::placeholders;
+
+ if (! _imp->maybe_world_file)
+ {
+ Log::get_instance()->message(ll_warning, lc_context) << "Not removing '" << n << "' from world because "
+ "no world file has been configured";
+ return;
+ }
+
+ Lock l(_imp->mutex);
+
+ Context context("When removing '" + n + "' from world file '" + stringify(*_imp->maybe_world_file) + "':");
+
+ if (_imp->maybe_world_file->exists())
+ {
+ SetFile world(SetFileParams::create()
+ .file_name(*_imp->maybe_world_file)
+ .type(sft_simple)
+ .parser(tr1::bind(&parse_user_package_dep_spec, _1, UserPackageDepSpecOptions()))
+ .tag(tr1::shared_ptr<DepTag>())
+ .environment(_imp->env));
+
+ world.remove(n);
+ world.rewrite();
+ }
+}
+
+tr1::shared_ptr<SetSpecTree::ConstItem>
+World::world_set() const
+{
+ using namespace tr1::placeholders;
+
+ tr1::shared_ptr<GeneralSetDepTag> tag(new GeneralSetDepTag(SetName("world"), "Environment"));
+
+ if (_imp->maybe_world_file)
+ {
+ if (_imp->maybe_world_file->exists())
+ {
+ SetFile world(SetFileParams::create()
+ .file_name(*_imp->maybe_world_file)
+ .type(sft_simple)
+ .parser(tr1::bind(&parse_user_package_dep_spec, _1, UserPackageDepSpecOptions()))
+ .tag(tag)
+ .environment(_imp->env));
+ return world.contents();
+ }
+ else
+ Log::get_instance()->message(ll_warning, lc_no_context) << "World file '" << *_imp->maybe_world_file
+ << "' doesn't exist";
+ }
+
+ return tr1::shared_ptr<SetSpecTree::ConstItem>(new ConstTreeSequence<SetSpecTree, AllDepSpec>(
+ tr1::shared_ptr<AllDepSpec>(new AllDepSpec)));
+}
+
diff --git a/paludis/environments/paludis/world.hh b/paludis/environments/paludis/world.hh
new file mode 100644
index 000000000..87b05a0b3
--- /dev/null
+++ b/paludis/environments/paludis/world.hh
@@ -0,0 +1,57 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2008 Ciaran McCreesh
+ *
+ * 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
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef PALUDIS_GUARD_PALUDIS_ENVIRONMENTS_PALUDIS_WORLD_HH
+#define PALUDIS_GUARD_PALUDIS_ENVIRONMENTS_PALUDIS_WORLD_HH 1
+
+#include <paludis/util/private_implementation_pattern.hh>
+#include <paludis/util/fs_entry-fwd.hh>
+#include <paludis/util/tr1_memory.hh>
+#include <paludis/name-fwd.hh>
+#include <paludis/dep_tree.hh>
+#include <paludis/environment-fwd.hh>
+#include <string>
+
+namespace paludis
+{
+ namespace paludis_environment
+ {
+ class World :
+ private PrivateImplementationPattern<World>
+ {
+ private:
+ void _add_string_to_world(const std::string &) const;
+ void _remove_string_from_world(const std::string &) const;
+
+ public:
+ World(const Environment * const, const tr1::shared_ptr<const FSEntry> &);
+ ~World();
+
+ tr1::shared_ptr<SetSpecTree::ConstItem> world_set() const PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ void add_to_world(const SetName &) const;
+ void add_to_world(const QualifiedPackageName &) const;
+
+ void remove_from_world(const SetName &) const;
+ void remove_from_world(const QualifiedPackageName &) const;
+ };
+ }
+}
+
+#endif
diff --git a/paludis/environments/portage/portage_environment.cc b/paludis/environments/portage/portage_environment.cc
index ccba73494..f66219c6d 100644
--- a/paludis/environments/portage/portage_environment.cc
+++ b/paludis/environments/portage/portage_environment.cc
@@ -44,14 +44,17 @@
#include <paludis/package_database.hh>
#include <paludis/package_id.hh>
#include <paludis/user_dep_spec.hh>
-#include <algorithm>
+#include <paludis/set_file.hh>
+#include <paludis/dep_tag.hh>
#include <paludis/util/tr1_functional.hh>
#include <paludis/util/mutex.hh>
#include <functional>
+#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <list>
+#include <fstream>
using namespace paludis;
using namespace paludis::portage_environment;
@@ -95,12 +98,16 @@ namespace paludis
tr1::shared_ptr<PackageDatabase> package_database;
+ const FSEntry world_file;
+ mutable Mutex world_mutex;
+
Implementation(Environment * const e, const std::string & s) :
conf_dir(FSEntry(s.empty() ? "/" : s) / SYSCONFDIR),
paludis_command("paludis"),
done_hooks(false),
overlay_importance(10),
- package_database(new PackageDatabase(e))
+ package_database(new PackageDatabase(e)),
+ world_file("/var/lib/portage/world")
{
}
@@ -420,7 +427,6 @@ PortageEnvironment::_add_vdb_repository()
keys->insert("format", "vdb");
keys->insert("names_cache", "/var/empty");
keys->insert("provides_cache", "/var/empty");
- keys->insert("world", "/var/lib/portage/world");
std::string builddir(_imp->vars->get("PORTAGE_TMPDIR"));
if (! builddir.empty())
builddir.append("/portage");
@@ -740,3 +746,110 @@ PortageEnvironment::reduced_uid() const
return getuid();
}
+void
+PortageEnvironment::add_to_world(const QualifiedPackageName & q) const
+{
+ _add_string_to_world(stringify(q));
+}
+
+void
+PortageEnvironment::add_to_world(const SetName & s) const
+{
+ _add_string_to_world(stringify(s));
+}
+
+void
+PortageEnvironment::remove_from_world(const QualifiedPackageName & q) const
+{
+ _remove_string_from_world(stringify(q));
+}
+
+void
+PortageEnvironment::remove_from_world(const SetName & s) const
+{
+ _remove_string_from_world(stringify(s));
+}
+
+void
+PortageEnvironment::_add_string_to_world(const std::string & s) const
+{
+ Lock l(_imp->world_mutex);
+
+ Context context("When adding '" + s + "' to world file '" + stringify(_imp->world_file) + "':");
+
+ using namespace tr1::placeholders;
+
+ if (! _imp->world_file.exists())
+ {
+ std::ofstream f(stringify(_imp->world_file).c_str());
+ if (! f)
+ {
+ Log::get_instance()->message(ll_warning, lc_no_context, "Cannot create world file '"
+ + stringify(_imp->world_file) + "'");
+ return;
+ }
+ }
+
+ SetFile world(SetFileParams::create()
+ .file_name(_imp->world_file)
+ .type(sft_simple)
+ .parser(tr1::bind(&parse_user_package_dep_spec, _1, UserPackageDepSpecOptions()))
+ .tag(tr1::shared_ptr<DepTag>())
+ .environment(this));
+ world.add(s);
+ world.rewrite();
+}
+
+void
+PortageEnvironment::_remove_string_from_world(const std::string & s) const
+{
+ Lock l(_imp->world_mutex);
+
+ Context context("When removing '" + s + "' from world file '" + stringify(_imp->world_file) + "':");
+
+ using namespace tr1::placeholders;
+
+ if (_imp->world_file.exists())
+ {
+ SetFile world(SetFileParams::create()
+ .file_name(_imp->world_file)
+ .type(sft_simple)
+ .parser(tr1::bind(&parse_user_package_dep_spec, _1, UserPackageDepSpecOptions()))
+ .tag(tr1::shared_ptr<DepTag>())
+ .environment(this));
+
+ world.remove(s);
+ world.rewrite();
+ }
+}
+
+tr1::shared_ptr<SetSpecTree::ConstItem>
+PortageEnvironment::world_set() const
+{
+ Context context("When fetching environment world set:");
+
+ tr1::shared_ptr<GeneralSetDepTag> tag(new GeneralSetDepTag(SetName("world"), stringify("Environment")));
+
+ using namespace tr1::placeholders;
+
+ Lock l(_imp->world_mutex);
+
+ if (_imp->world_file.exists())
+ {
+ SetFile world(SetFileParams::create()
+ .file_name(_imp->world_file)
+ .type(sft_simple)
+ .parser(tr1::bind(&parse_user_package_dep_spec, _1, UserPackageDepSpecOptions()))
+ .tag(tag)
+ .environment(this));
+ return world.contents();
+ }
+ else
+ Log::get_instance()->message(ll_warning, lc_no_context,
+ "World file '" + stringify(_imp->world_file) +
+ "' doesn't exist");
+
+ return tr1::shared_ptr<SetSpecTree::ConstItem>(new ConstTreeSequence<SetSpecTree, AllDepSpec>(
+ tr1::shared_ptr<AllDepSpec>(new AllDepSpec)));
+}
+
diff --git a/paludis/environments/portage/portage_environment.hh b/paludis/environments/portage/portage_environment.hh
index faeeb3100..03702201f 100644
--- a/paludis/environments/portage/portage_environment.hh
+++ b/paludis/environments/portage/portage_environment.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2007 Ciaran McCreesh
+ * Copyright (c) 2007, 2008 Ciaran McCreesh
*
* 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
@@ -74,10 +74,16 @@ namespace paludis
template<typename I_>
void _load_atom_file(const FSEntry &, I_, const std::string &);
+ void _add_string_to_world(const std::string &) const;
+ void _remove_string_from_world(const std::string &) const;
+
protected:
virtual tr1::shared_ptr<SetSpecTree::ConstItem> local_set(const SetName &) const
PALUDIS_ATTRIBUTE((warn_unused_result));
+ virtual tr1::shared_ptr<SetSpecTree::ConstItem> world_set() const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
public:
///\name Basic operations
///\{
@@ -138,6 +144,14 @@ namespace paludis
virtual uid_t reduced_uid() const;
virtual gid_t reduced_gid() const;
+
+ virtual void add_to_world(const QualifiedPackageName &) const;
+
+ virtual void add_to_world(const SetName &) const;
+
+ virtual void remove_from_world(const QualifiedPackageName &) const;
+
+ virtual void remove_from_world(const SetName &) const;
};
}
diff --git a/paludis/environments/test/test_environment.cc b/paludis/environments/test/test_environment.cc
index 18e4fabae..0243fbf1f 100644
--- a/paludis/environments/test/test_environment.cc
+++ b/paludis/environments/test/test_environment.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2005, 2006, 2007 Ciaran McCreesh
+ * Copyright (c) 2005, 2006, 2007, 2008 Ciaran McCreesh
*
* 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
@@ -189,3 +189,29 @@ TestEnvironment::known_use_expand_names(const UseFlagName &, const PackageID &)
return make_shared_ptr(new UseFlagNameSet);
}
+tr1::shared_ptr<SetSpecTree::ConstItem>
+TestEnvironment::world_set() const
+{
+ return tr1::shared_ptr<SetSpecTree::ConstItem>();
+}
+
+void
+TestEnvironment::add_to_world(const QualifiedPackageName &) const
+{
+}
+
+void
+TestEnvironment::remove_from_world(const QualifiedPackageName &) const
+{
+}
+
+void
+TestEnvironment::add_to_world(const SetName &) const
+{
+}
+
+void
+TestEnvironment::remove_from_world(const SetName &) const
+{
+}
+
diff --git a/paludis/environments/test/test_environment.hh b/paludis/environments/test/test_environment.hh
index a79121ecc..d4a9dcc99 100644
--- a/paludis/environments/test/test_environment.hh
+++ b/paludis/environments/test/test_environment.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2005, 2006, 2007 Ciaran McCreesh
+ * Copyright (c) 2005, 2006, 2007, 2008 Ciaran McCreesh
*
* 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
@@ -47,6 +47,9 @@ namespace paludis
virtual tr1::shared_ptr<SetSpecTree::ConstItem> local_set(const SetName &) const
PALUDIS_ATTRIBUTE((warn_unused_result));
+ virtual tr1::shared_ptr<SetSpecTree::ConstItem> world_set() const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
public:
///\name Basic operations
///\{
@@ -110,6 +113,14 @@ namespace paludis
virtual HookResult perform_hook(const Hook &) const
PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual void add_to_world(const QualifiedPackageName &) const;
+
+ virtual void add_to_world(const SetName &) const;
+
+ virtual void remove_from_world(const QualifiedPackageName &) const;
+
+ virtual void remove_from_world(const SetName &) const;
};
}