aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-04-27 11:48:30 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-04-27 11:48:30 +0000
commit10992400975d6f6177e29fc85c1a884be5faa13c (patch)
tree531e066fabd319abb653049a7c5bf579c182c69c
parente4d1470f1af5ade81679e728ff19de03b18901bd (diff)
downloadpaludis-10992400975d6f6177e29fc85c1a884be5faa13c.tar.gz
paludis-10992400975d6f6177e29fc85c1a884be5faa13c.tar.xz
Environment implementation / interface split. Use of '*' in Paludis keywords.conf, use.conf, licenses.conf is now deprecated in favour of '*/*'
-rw-r--r--configure.ac10
-rw-r--r--paludis/Makefile.am.m42
-rw-r--r--paludis/dep_list/dep_list.cc19
-rw-r--r--paludis/dep_list/dep_list.hh1
-rw-r--r--paludis/dep_list/uninstall_list.cc8
-rw-r--r--paludis/dep_list/uninstall_list_TEST.cc1
-rw-r--r--paludis/dep_spec_flattener.cc2
-rw-r--r--paludis/environment.cc667
-rw-r--r--paludis/environment.hh428
-rw-r--r--paludis/environment.se21
-rw-r--r--paludis/environment_implementation.cc408
-rw-r--r--paludis/environment_implementation.hh162
-rw-r--r--paludis/environment_implementation_TEST.cc132
-rw-r--r--paludis/environments/adapted/Makefile.am59
-rw-r--r--paludis/environments/adapted/adapted_environment.cc209
-rw-r--r--paludis/environments/adapted/adapted_environment.hh108
-rw-r--r--paludis/environments/adapted/adapted_environment_TEST.cc40
-rw-r--r--paludis/environments/adapted/registration.cc32
-rw-r--r--paludis/environments/no_config/Makefile.am28
-rw-r--r--paludis/environments/no_config/no_config_environment.cc141
-rw-r--r--paludis/environments/no_config/no_config_environment.hh33
-rw-r--r--paludis/environments/no_config/no_config_environment_TEST.cc46
-rwxr-xr-xpaludis/environments/no_config/no_config_environment_TEST_cleanup.sh9
-rwxr-xr-xpaludis/environments/no_config/no_config_environment_TEST_setup.sh25
-rw-r--r--paludis/environments/paludis/Makefile.am14
-rw-r--r--paludis/environments/paludis/bashable_conf.cc57
-rw-r--r--paludis/environments/paludis/bashable_conf.hh33
-rw-r--r--paludis/environments/paludis/keywords_conf.cc224
-rw-r--r--paludis/environments/paludis/keywords_conf.hh47
-rw-r--r--paludis/environments/paludis/licenses_conf.cc219
-rw-r--r--paludis/environments/paludis/licenses_conf.hh47
-rw-r--r--paludis/environments/paludis/mirrors_conf.cc93
-rw-r--r--paludis/environments/paludis/mirrors_conf.hh49
-rw-r--r--paludis/environments/paludis/package_mask_conf.cc84
-rw-r--r--paludis/environments/paludis/package_mask_conf.hh48
-rw-r--r--paludis/environments/paludis/paludis_config.cc906
-rw-r--r--paludis/environments/paludis/paludis_config.hh137
-rw-r--r--paludis/environments/paludis/paludis_environment.cc556
-rw-r--r--paludis/environments/paludis/paludis_environment.hh95
-rw-r--r--paludis/environments/paludis/paludis_environment_TEST.cc75
-rwxr-xr-xpaludis/environments/paludis/paludis_environment_TEST_setup.sh30
-rw-r--r--paludis/environments/paludis/use_conf.cc357
-rw-r--r--paludis/environments/paludis/use_conf.hh52
-rw-r--r--paludis/environments/portage/portage_environment.cc164
-rw-r--r--paludis/environments/portage/portage_environment.hh54
-rw-r--r--paludis/environments/portage/portage_environment_TEST.cc77
-rw-r--r--paludis/environments/test/test_environment.cc74
-rw-r--r--paludis/environments/test/test_environment.hh65
-rw-r--r--paludis/files.m46
-rw-r--r--paludis/hook.cc80
-rw-r--r--paludis/hook.hh75
-rw-r--r--paludis/hooker.cc2
-rw-r--r--paludis/hooker_TEST.cc1
-rw-r--r--paludis/match_package.cc14
-rw-r--r--paludis/match_package.hh7
-rw-r--r--paludis/merger/merger.cc1
-rw-r--r--paludis/merger/unmerger.cc1
-rw-r--r--paludis/name.hh14
-rw-r--r--paludis/qa/deps_visible_check.cc50
-rw-r--r--paludis/qa/keywords_check.cc2
-rw-r--r--paludis/repositories/cran/cran_description.cc2
-rw-r--r--paludis/repositories/cran/cran_installed_repository.cc14
-rw-r--r--paludis/repositories/cran/cran_installed_repository.hh2
-rw-r--r--paludis/repositories/cran/cran_repository.cc12
-rw-r--r--paludis/repositories/cran/cran_repository.hh2
-rw-r--r--paludis/repositories/fake/fake_repository_base.cc6
-rw-r--r--paludis/repositories/fake/fake_repository_base.hh2
-rw-r--r--paludis/repositories/gems/gems_repository.cc17
-rw-r--r--paludis/repositories/gems/gems_repository.hh2
-rw-r--r--paludis/repositories/gentoo/ebin.cc13
-rw-r--r--paludis/repositories/gentoo/ebin_entries.cc31
-rw-r--r--paludis/repositories/gentoo/ebuild.cc28
-rw-r--r--paludis/repositories/gentoo/ebuild_entries.cc34
-rw-r--r--paludis/repositories/gentoo/ebuild_flat_metadata_cache.cc4
-rw-r--r--paludis/repositories/gentoo/glsa.cc4
-rw-r--r--paludis/repositories/gentoo/portage_repository.cc3
-rw-r--r--paludis/repositories/gentoo/portage_repository.hh2
-rw-r--r--paludis/repositories/gentoo/portage_repository_profile.cc3
-rw-r--r--paludis/repositories/gentoo/portage_repository_sets.cc4
-rw-r--r--paludis/repositories/gentoo/portage_repository_sets.hh2
-rw-r--r--paludis/repositories/gentoo/vdb_merger.cc8
-rw-r--r--paludis/repositories/gentoo/vdb_repository.cc17
-rw-r--r--paludis/repositories/gentoo/vdb_repository.hh2
-rw-r--r--paludis/repositories/gentoo/vdb_unmerger.cc7
-rw-r--r--paludis/repositories/virtuals/installed_virtuals_repository.cc15
-rw-r--r--paludis/repositories/virtuals/virtuals_repository.cc8
-rw-r--r--paludis/repository-fwd.hh73
-rw-r--r--paludis/repository.hh53
-rw-r--r--paludis/repository_name_cache_TEST.cc1
-rw-r--r--paludis/set_file.cc3
-rw-r--r--paludis/syncer.cc23
-rw-r--r--paludis/tasks/find_unused_packages_task.cc9
-rw-r--r--paludis/tasks/install_task.cc146
-rw-r--r--paludis/tasks/install_task.hh9
-rw-r--r--paludis/tasks/report_task.cc1
-rw-r--r--paludis/tasks/sync_task.cc2
-rw-r--r--paludis/tasks/uninstall_task.cc30
-rw-r--r--paludis/util/Makefile.am.m42
-rw-r--r--paludis/util/collection-fwd.hh37
-rw-r--r--paludis/util/collection.hh3
-rw-r--r--paludis/util/files.m42
-rw-r--r--paludis/util/iterator.hh15
-rw-r--r--paludis/version_metadata.cc24
-rw-r--r--paludis/version_metadata.sr18
-rwxr-xr-xruby/dep_list_TEST_setup.sh6
-rw-r--r--ruby/environment.cc131
-rw-r--r--ruby/environment_TEST.rb165
-rwxr-xr-xruby/environment_TEST_setup.sh6
-rwxr-xr-xruby/package_database_TEST_setup.sh6
-rwxr-xr-xruby/paludis_ruby_TEST_setup.sh6
-rwxr-xr-xruby/repository_TEST_setup.sh6
-rw-r--r--ruby/version_metadata.cc10
-rw-r--r--ruby/version_metadata_TEST.rb2
-rw-r--r--src/clients/adjutrix/Makefile.am1
-rw-r--r--src/clients/adjutrix/display_default_system_resolution.cc2
-rw-r--r--src/clients/adjutrix/display_profiles_use.cc5
-rw-r--r--src/clients/adjutrix/downgrade_check.cc1
-rw-r--r--src/clients/adjutrix/find_dropped_keywords.cc15
-rw-r--r--src/clients/adjutrix/find_insecure_packages.cc2
-rw-r--r--src/clients/adjutrix/find_reverse_deps.cc2
-rw-r--r--src/clients/adjutrix/find_stable_candidates.cc12
-rw-r--r--src/clients/adjutrix/keywords_graph.cc12
-rw-r--r--src/clients/adjutrix/what_needs_keywording.cc12
-rw-r--r--src/clients/contrarius/Makefile.am1
-rw-r--r--src/clients/contrarius/contrarius.cc4
-rw-r--r--src/clients/contrarius/install.cc13
-rw-r--r--src/clients/contrarius/stage.cc48
-rw-r--r--src/clients/contrarius/stage.hh18
-rw-r--r--src/clients/contrarius/stage_builder.cc1
-rw-r--r--src/clients/inquisitio/description_extractor.cc1
-rw-r--r--src/clients/inquisitio/do_search.cc2
-rw-r--r--src/clients/paludis/Makefile.am1
-rw-r--r--src/clients/paludis/applets.cc11
-rw-r--r--src/clients/paludis/install.cc13
-rwxr-xr-xsrc/clients/paludis/install_TEST3
-rwxr-xr-xsrc/clients/paludis/install_TEST_setup.sh13
-rw-r--r--src/clients/paludis/list.cc20
-rw-r--r--src/clients/paludis/query.cc2
-rw-r--r--src/clients/paludis/uninstall.cc1
-rwxr-xr-xsrc/clients/paludis/upgrade_TEST_setup.sh6
-rw-r--r--src/output/console_install_task.cc9
-rw-r--r--src/output/console_query_task.cc4
-rw-r--r--src/output/licence.cc3
-rw-r--r--src/output/licence.hh4
-rw-r--r--src/output/use_flag_pretty_printer.cc9
-rwxr-xr-xtest/run_test.sh10
-rw-r--r--tr1/tr1_functional.hh3
147 files changed, 4210 insertions, 3488 deletions
diff --git a/configure.ac b/configure.ac
index d95a2cc..9e65241 100644
--- a/configure.ac
+++ b/configure.ac
@@ -750,17 +750,18 @@ fi
dnl }}}
dnl {{{ environments
-ALL_ENVIRONMENTS="no_config paludis portage test"
-DEFAULT_ENVIRONMENTS="no_config paludis test"
+ALL_ENVIRONMENTS="adapted no_config paludis portage test"
+DEFAULT_ENVIRONMENTS="adapted no_config paludis test"
AC_MSG_CHECKING([which environments to build...])
AC_ARG_WITH([environments],
[ --with-environments=foo,bar,...
Build the specified environments:
- default Equivalent to no_config,paludis.test
+ default Equivalent to adapted,no_config,paludis.test
+ adapted An environment adapter, for contrarius etc
no_config Configurationless environment, for adjutrix etc
paludis Standard Paludis environments
- portage Portage configuration (UNUSABLE)
+ portage Portage configuration (experimental)
test For test cases],
[environments="`echo $with_environments | tr ',' ' '`"],
[environments="$DEFAULT_ENVIRONMENTS"])
@@ -921,6 +922,7 @@ AC_OUTPUT(
paludis/dep_list/Makefile
paludis/digests/Makefile
paludis/environments/Makefile
+ paludis/environments/adapted/Makefile
paludis/environments/paludis/Makefile
paludis/environments/portage/Makefile
paludis/environments/no_config/Makefile
diff --git a/paludis/Makefile.am.m4 b/paludis/Makefile.am.m4
index 64b5843..67e9867 100644
--- a/paludis/Makefile.am.m4
+++ b/paludis/Makefile.am.m4
@@ -29,6 +29,7 @@ $1_TEST_CXXFLAGS = -I$(top_srcdir)
')dnl
define(`addtestscript', `define(`testscriptlist', testscriptlist `$1_TEST_setup.sh $1_TEST_cleanup.sh')')dnl
define(`addhh', `define(`filelist', filelist `$1.hh')define(`headerlist', headerlist `$1.hh')')dnl
+define(`addfwd', `define(`filelist', filelist `$1-fwd.hh')define(`headerlist', headerlist `$1-fwd.hh')')dnl
define(`addhhx', `define(`filelist', filelist `$1.hh')')dnl
define(`addcc', `define(`filelist', filelist `$1.cc')')dnl
define(`addimpl', `define(`filelist', filelist `$1-impl.hh')')dnl
@@ -54,6 +55,7 @@ $1-se.cc : $1.se $(top_srcdir)/misc/make_se.bash
')dnl
define(`addthis', `dnl
ifelse(`$2', `hh', `addhh(`$1')', `')dnl
+ifelse(`$2', `fwd', `addfwd(`$1')', `')dnl
ifelse(`$2', `hhx', `addhhx(`$1')', `')dnl
ifelse(`$2', `cc', `addcc(`$1')', `')dnl
ifelse(`$2', `sr', `addsr(`$1')', `')dnl
diff --git a/paludis/dep_list/dep_list.cc b/paludis/dep_list/dep_list.cc
index fddb2d0..06b88b9 100644
--- a/paludis/dep_list/dep_list.cc
+++ b/paludis/dep_list/dep_list.cc
@@ -288,7 +288,7 @@ namespace
{
const UseDepSpec * const u(spec->as_use_dep_spec());
if (0 != u)
- return env->query_use(u->flag(), pde) ^ u->inverse();
+ return (pde ? env->query_use(u->flag(), *pde) : false) ^ u->inverse();
else
return true;
}
@@ -412,7 +412,7 @@ DepList::QueryVisitor::visit(const UseDepSpec * const a)
{
/* for use? ( ) dep specs, return true if we're not enabled, so that
* weird || ( ) cases work. */
- if (d->_imp->env->query_use(a->flag(), d->_imp->current_pde()) ^ a->inverse())
+ if ((d->_imp->current_pde() ? d->_imp->env->query_use(a->flag(), *d->_imp->current_pde()) : false) ^ a->inverse())
{
result = true;
for (CompositeDepSpec::Iterator c(a->begin()), c_end(a->end()) ; c != c_end ; ++c)
@@ -604,13 +604,16 @@ DepList::AddVisitor::visit(const PackageDepSpec * const a)
mask_mask += mr_license;
mask_mask += mr_by_association;
- bool override_tilde_keywords(masks_to_override[dl_override_tilde_keywords]);
- bool override_unkeyworded(masks_to_override[dl_override_unkeyworded]);
+ MaskReasonsOptions override_options;
+ if (masks_to_override[dl_override_tilde_keywords])
+ override_options += mro_override_tilde_keywords;
+ if (masks_to_override[dl_override_unkeyworded])
+ override_options += mro_override_unkeyworded;
for (PackageDatabaseEntryCollection::ReverseIterator p(installable_candidates->rbegin()),
p_end(installable_candidates->rend()) ; p != p_end ; ++p)
{
- if (! (d->_imp->env->mask_reasons(*p, override_tilde_keywords, override_unkeyworded).subtract(mask_mask).any()))
+ if (! (d->_imp->env->mask_reasons(*p, override_options).subtract(mask_mask).any()))
{
d->add_error_package(*p, dlk_masked);
best_visible_candidate = &*p;
@@ -792,7 +795,7 @@ DepList::AddVisitor::visit(const UseDepSpec * const a)
{
if (d->_imp->opts->use == dl_use_deps_standard)
{
- if (d->_imp->env->query_use(a->flag(), d->_imp->current_pde()) ^ a->inverse())
+ if ((d->_imp->current_pde() ? d->_imp->env->query_use(a->flag(), *d->_imp->current_pde()) : false) ^ a->inverse())
std::for_each(a->begin(), a->end(), accept_visitor(this));
}
else
@@ -1085,7 +1088,7 @@ DepList::ShowSuggestVisitor::visit(const PlainTextDepSpec * const)
void
DepList::ShowSuggestVisitor::visit(const UseDepSpec * const a)
{
- if (d->_imp->env->query_use(a->flag(), d->_imp->current_pde()) ^ a->inverse())
+ if ((d->_imp->current_pde() ? d->_imp->env->query_use(a->flag(), *d->_imp->current_pde()) : false) ^ a->inverse())
std::for_each(a->begin(), a->end(), accept_visitor(this));
}
@@ -1615,7 +1618,7 @@ DepList::prefer_installed_over_uninstalled(const PackageDatabaseEntry & installe
for (std::set<std::string>::const_iterator f(use_common.begin()), f_end(use_common.end()) ;
f != f_end ; ++f)
- if (_imp->env->query_use(UseFlagName(*f), &installed) != _imp->env->query_use(UseFlagName(*f), &uninstalled))
+ if (_imp->env->query_use(UseFlagName(*f), installed) != _imp->env->query_use(UseFlagName(*f), uninstalled))
return false;
}
diff --git a/paludis/dep_list/dep_list.hh b/paludis/dep_list/dep_list.hh
index b76c220..cf45b68 100644
--- a/paludis/dep_list/dep_list.hh
+++ b/paludis/dep_list/dep_list.hh
@@ -36,6 +36,7 @@
namespace paludis
{
+ class VersionMetadata;
#include <paludis/dep_list/dep_list-sr.hh>
diff --git a/paludis/dep_list/uninstall_list.cc b/paludis/dep_list/uninstall_list.cc
index 53e48db..040352d 100644
--- a/paludis/dep_list/uninstall_list.cc
+++ b/paludis/dep_list/uninstall_list.cc
@@ -28,6 +28,8 @@ using namespace paludis;
#include <paludis/util/log.hh>
#include <paludis/hashed_containers.hh>
#include <paludis/match_package.hh>
+#include <paludis/version_metadata.hh>
+#include <paludis/package_database.hh>
#include <list>
#include <algorithm>
@@ -263,7 +265,7 @@ namespace
void visit(const UseDepSpec * const u)
{
- if (env->query_use(UseFlagName(u->flag()), &pkg) ^ u->inverse())
+ if (env->query_use(UseFlagName(u->flag()), pkg) ^ u->inverse())
std::for_each(u->begin(), u->end(), accept_visitor(this));
}
@@ -361,7 +363,7 @@ UninstallList::add_unused_dependencies()
ArbitrarilyOrderedPackageDatabaseEntryCollectionComparator());
/* if any of them aren't already on the list, and aren't in world, add them and recurse */
- std::tr1::shared_ptr<DepSpec> world(_imp->env->package_set(SetName("world")));
+ std::tr1::shared_ptr<DepSpec> world(_imp->env->set(SetName("world")));
for (PackageDatabaseEntryCollection::Iterator i(unused_dependencies->begin()),
i_end(unused_dependencies->end()) ; i != i_end ; ++i)
{
@@ -428,7 +430,7 @@ UninstallList::collect_world() const
new ArbitrarilyOrderedPackageDatabaseEntryCollection::Concrete);
std::tr1::shared_ptr<const ArbitrarilyOrderedPackageDatabaseEntryCollection> everything(collect_all_installed());
- std::tr1::shared_ptr<DepSpec> world(_imp->env->package_set(SetName("world")));
+ std::tr1::shared_ptr<DepSpec> world(_imp->env->set(SetName("world")));
for (PackageDatabaseEntryCollection::Iterator i(everything->begin()),
i_end(everything->end()) ; i != i_end ; ++i)
if (match_package_in_heirarchy(*_imp->env, *world, *i))
diff --git a/paludis/dep_list/uninstall_list_TEST.cc b/paludis/dep_list/uninstall_list_TEST.cc
index 4c82551..a6aef2b 100644
--- a/paludis/dep_list/uninstall_list_TEST.cc
+++ b/paludis/dep_list/uninstall_list_TEST.cc
@@ -24,6 +24,7 @@
#include <paludis/environments/test/test_environment.hh>
#include <paludis/portage_dep_parser.hh>
#include <paludis/util/collection_concrete.hh>
+#include <paludis/package_database.hh>
#include <test/test_framework.hh>
#include <test/test_runner.hh>
#include <string>
diff --git a/paludis/dep_spec_flattener.cc b/paludis/dep_spec_flattener.cc
index b6e9ce8..39d4020 100644
--- a/paludis/dep_spec_flattener.cc
+++ b/paludis/dep_spec_flattener.cc
@@ -105,7 +105,7 @@ void DepSpecFlattener::visit(const AnyDepSpec *)
void DepSpecFlattener::visit(const UseDepSpec * u)
{
- if (_imp->env->query_use(u->flag(), _imp->pkg) ^ u->inverse())
+ if (_imp->env->query_use(u->flag(), *_imp->pkg) ^ u->inverse())
std::for_each(u->begin(), u->end(), accept_visitor(
static_cast<DepSpecVisitorTypes::ConstVisitor *>(this)));
}
diff --git a/paludis/environment.cc b/paludis/environment.cc
index 2f1a583..cddd3ac 100644
--- a/paludis/environment.cc
+++ b/paludis/environment.cc
@@ -17,678 +17,13 @@
* Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <paludis/package_database.hh>
-#include <paludis/dep_spec.hh>
#include <paludis/environment.hh>
-#include <paludis/util/log.hh>
-#include <paludis/util/save.hh>
-#include <paludis/util/tokeniser.hh>
-#include <paludis/util/collection_concrete.hh>
-#include <paludis/util/fs_entry.hh>
-
-#include <set>
-#include <list>
-
-/** \file
- * Implementation of Environment.
- *
- * \ingroup grpenvironment
- */
using namespace paludis;
-Environment::Environment(std::tr1::shared_ptr<PackageDatabase> d) :
- _package_database(d)
-{
-}
+#include <paludis/environment-se.cc>
Environment::~Environment()
{
}
-namespace
-{
- /**
- * Check whether licences for a package are accepted.
- */
- struct LicenceChecker :
- DepSpecVisitorTypes::ConstVisitor,
- DepSpecVisitorTypes::ConstVisitor::VisitChildren<LicenceChecker, AllDepSpec>
- {
- using DepSpecVisitorTypes::ConstVisitor::VisitChildren<LicenceChecker, AllDepSpec>::visit;
-
- /// Are all necessary licences ok?
- bool ok;
-
- /// Our environment.
- const Environment * const env;
-
- /// Our package database.
- const PackageDatabaseEntry * const db_entry;
-
- /// Constructor
- LicenceChecker(const Environment * const e, const PackageDatabaseEntry * const d) :
- ok(true),
- env(e),
- db_entry(d)
- {
- }
-
- ///\name Visit methods
- ///{
-
- void visit(const AnyDepSpec * spec)
- {
- bool local_ok(false);
-
- if (spec->begin() == spec->end())
- local_ok = true;
- else
- {
- for (CompositeDepSpec::Iterator i(spec->begin()), i_end(spec->end()) ;
- i != i_end ; ++i)
- {
- Save<bool> save_ok(&ok, true);
- (*i)->accept(this);
- local_ok |= ok;
- }
- }
-
- ok &= local_ok;
- }
-
- void visit(const UseDepSpec * spec)
- {
- if (env->query_use(spec->flag(), db_entry))
- std::for_each(spec->begin(), spec->end(), accept_visitor(this));
- }
-
- void visit(const PlainTextDepSpec * spec)
- {
- if (! env->accept_license(spec->text(), db_entry))
- ok = false;
- }
-
- void visit(const PackageDepSpec *) PALUDIS_ATTRIBUTE((noreturn))
- {
- throw InternalError(PALUDIS_HERE, "Encountered PackageDepSpec in licence?");
- }
-
- void visit(const BlockDepSpec *) PALUDIS_ATTRIBUTE((noreturn))
- {
- throw InternalError(PALUDIS_HERE, "Encountered BlockDepSpec in licence?");
- }
- ///}
- };
-}
-
-MaskReasons
-Environment::mask_reasons(const PackageDatabaseEntry & e, const bool override_tilde_keywords,
- const bool override_unkeyworded) const
-{
- Context context("When checking mask reasons for '" + stringify(e) + "'");
-
- MaskReasons result;
- std::tr1::shared_ptr<const VersionMetadata> metadata(package_database()->fetch_repository(
- e.repository)->version_metadata(e.name, e.version));
-
- if (! accept_eapi(metadata->eapi))
- result += mr_eapi;
- else
- {
- if (breaks_portage(e, *metadata) && ! accept_breaks_portage())
- result += mr_breaks_portage;
-
- if (metadata->interactive && ! accept_interactive())
- result += mr_interactive;
-
- if (metadata->virtual_interface)
- {
- result |= mask_reasons(metadata->virtual_interface->virtual_for);
- if (result.any())
- result += mr_by_association;
- }
-
- if (metadata->ebuild_interface)
- {
- std::set<KeywordName> keywords;
- WhitespaceTokeniser::get_instance()->tokenise(
- metadata->ebuild_interface->keywords,
- create_inserter<KeywordName>(std::inserter(keywords, keywords.end())));
- if (keywords.empty())
- keywords.insert(KeywordName("empty"));
-
- result += mr_keyword;
- for (std::set<KeywordName>::const_iterator i(keywords.begin()),
- i_end(keywords.end()) ; i != i_end ; ++i)
- if (accept_keyword(*i, &e, override_tilde_keywords))
- {
- result -= mr_keyword;
- break;
- }
-
- if (override_unkeyworded && result[mr_keyword])
- {
- result -= mr_keyword;
- for (std::set<KeywordName>::const_iterator i(keywords.begin()),
- i_end(keywords.end()) ; i != i_end ; ++i)
- if ("-*" == stringify(*i))
- result += mr_keyword;
- else if ('-' == stringify(*i).at(0))
- if (accept_keyword(KeywordName(stringify(*i).substr(1)), &e, override_tilde_keywords))
- {
- result += mr_keyword;
- break;
- }
- }
- }
-
- if (metadata->license_interface)
- {
- LicenceChecker lc(this, &e);
- metadata->license_interface->license()->accept(&lc);
- if (! lc.ok)
- result += mr_license;
- }
-
- if (! query_user_unmasks(e))
- {
- if (query_user_masks(e))
- result += mr_user_mask;
-
- const Repository * const repo(package_database()->fetch_repository(e.repository).get());
-
- if (repo->mask_interface)
- {
- if (repo->mask_interface->query_profile_masks(e.name,
- e.version))
- result += mr_profile_mask;
-
- if (repo->mask_interface->query_repository_masks(e.name,
- e.version))
- result += mr_repository_mask;
- }
- }
- }
-
- return result;
-}
-
-std::tr1::shared_ptr<DepSpec>
-Environment::package_set(const SetName & s) const
-{
- /* favour local sets first */
- std::tr1::shared_ptr<CompositeDepSpec> result(local_package_set(s));
- if (0 != result)
- return result;
-
- /* these sets always exist, even if empty */
- if (s.data() == "everything" || s.data() == "system" || s.data() == "world" || s.data() == "security")
- result.reset(new AllDepSpec);
-
- for (PackageDatabase::RepositoryIterator r(package_database()->begin_repositories()),
- r_end(package_database()->end_repositories()) ;
- r != r_end ; ++r)
- {
- if (! (*r)->sets_interface)
- continue;
-
- std::tr1::shared_ptr<DepSpec> add((*r)->sets_interface->package_set(s));
- if (0 != add)
- {
- if (! result)
- result.reset(new AllDepSpec);
- result->add_child(add);
- }
-
- if ("everything" == s.data() || "world" == s.data())
- {
- add = (*r)->sets_interface->package_set(SetName("system"));
- if (0 != add)
- result->add_child(add);
- }
- }
-
- return result;
-}
-
-namespace
-{
- /**
- * Find package targets that are appropriate for adding to or removing
- * from the world file.
- */
- struct WorldTargetFinder :
- DepSpecVisitorTypes::ConstVisitor,
- DepSpecVisitorTypes::ConstVisitor::VisitChildren<WorldTargetFinder, AllDepSpec>
- {
- using DepSpecVisitorTypes::ConstVisitor::VisitChildren<WorldTargetFinder, AllDepSpec>::visit;
-
- /// Matches
- std::list<const PackageDepSpec *> items;
-
- /// Callback object pointer, may be 0.
- Environment::WorldCallbacks * const w;
-
- /// Are we inside a || ( ) group?
- bool inside_any;
-
- /// Are we inside a use? ( ) group?
- bool inside_use;
-
- /// Constructor.
- WorldTargetFinder(Environment::WorldCallbacks * const ww) :
- w(ww),
- inside_any(false),
- inside_use(false)
- {
- }
-
- ///\name Visit methods
- ///{
- void visit(const AnyDepSpec * a)
- {
- Save<bool> save_inside_any(&inside_any, true);
- std::for_each(a->begin(), a->end(), accept_visitor(this));
- }
-
- void visit(const UseDepSpec * a)
- {
- Save<bool> save_inside_use(&inside_use, true);
- std::for_each(a->begin(), a->end(), accept_visitor(this));
- }
-
- void visit(const PlainTextDepSpec *)
- {
- }
-
- void visit(const PackageDepSpec * a)
- {
- if (inside_any)
- {
- if (w)
- w->skip_callback(*a, "inside || ( ) block");
- }
- else if (inside_use)
- {
- if (w)
- w->skip_callback(*a, "inside use? ( ) block");
- }
- else if (a->slot_ptr())
- {
- if (w)
- 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");
- }
- else
- {
- items.push_back(a);
- if (w)
- w->add_callback(*a);
- }
- }
-
- void visit(const BlockDepSpec *)
- {
- }
- ///}
-
- };
-}
-
-void
-Environment::add_appropriate_to_world(std::tr1::shared_ptr<const DepSpec> a,
- Environment::WorldCallbacks * const ww) const
-{
- WorldTargetFinder w(ww);
- a->accept(&w);
- for (std::list<const PackageDepSpec *>::const_iterator i(w.items.begin()),
- i_end(w.items.end()) ; i != i_end ; ++i)
- {
- for (PackageDatabase::RepositoryIterator r(package_database()->begin_repositories()),
- r_end(package_database()->end_repositories()) ;
- r != r_end ; ++r)
- if ((*r)->world_interface && (*i)->package_ptr())
- (*r)->world_interface->add_to_world(*(*i)->package_ptr());
- }
-}
-
-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)->world_interface->add_to_world(s);
-
- if (ww)
- ww->add_callback(s);
-}
-
-void
-Environment::remove_appropriate_from_world(std::tr1::shared_ptr<const DepSpec> a,
- Environment::WorldCallbacks * const ww) const
-{
- WorldTargetFinder w(ww);
- a->accept(&w);
- for (std::list<const PackageDepSpec *>::const_iterator i(w.items.begin()),
- i_end(w.items.end()) ; i != i_end ; ++i)
- {
- for (PackageDatabase::RepositoryIterator r(package_database()->begin_repositories()),
- r_end(package_database()->end_repositories()) ;
- r != r_end ; ++r)
- if ((*r)->world_interface && (*i)->package_ptr())
- (*r)->world_interface->remove_from_world(*(*i)->package_ptr());
-
- 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);
-}
-
-namespace paludis
-{
- template<>
- struct Implementation<Hook>
- {
- std::string name;
- std::map<std::string, std::string> extra_env;
-
- Implementation(const std::string & n, const std::map<std::string, std::string> & e) :
- name(n),
- extra_env(e)
- {
- }
- };
-}
-
-Hook::Hook(const std::string & n) :
- PrivateImplementationPattern<Hook>(new Implementation<Hook>(n, std::map<std::string, std::string>()))
-{
-}
-
-Hook::Hook(const Hook & h) :
- PrivateImplementationPattern<Hook>(new Implementation<Hook>(h._imp->name, h._imp->extra_env))
-{
-}
-
-Hook::~Hook()
-{
-}
-
-Hook
-Hook::operator() (const std::string & k, const std::string & v) const
-{
- Hook result(*this);
- result._imp->extra_env.insert(std::make_pair(k, v));
- return result;
-}
-
-Hook::Iterator
-Hook::begin() const
-{
- return Iterator(_imp->extra_env.begin());
-}
-
-Hook::Iterator
-Hook::end() const
-{
- return Iterator(_imp->extra_env.end());
-}
-
-std::string
-Hook::name() const
-{
- return _imp->name;
-}
-
-bool
-Environment::query_use(const UseFlagName & f, const PackageDatabaseEntry * e) const
-{
- /* first check package database use masks... */
- const Repository * const repo((e ? package_database()->fetch_repository(e->repository).get() : 0));
-
- if (repo && repo->use_interface)
- {
- if (repo->use_interface->query_use_mask(f, e))
- return false;
- if (repo->use_interface->query_use_force(f, e))
- return true;
- }
-
- /* check use: package database config */
- if (repo && repo->use_interface)
- {
- switch (repo->use_interface->query_use(f, e))
- {
- case use_disabled:
- case use_unspecified:
- return false;
-
- case use_enabled:
- return true;
- }
-
- throw InternalError(PALUDIS_HERE, "bad state");
- }
- else
- {
- return false;
- }
-}
-
-bool
-Environment::accept_keyword(const KeywordName & keyword, const PackageDatabaseEntry * const,
- const bool) const
-{
- if (keyword == KeywordName("*"))
- return true;
-
- return false;
-}
-
-bool
-Environment::accept_license(const std::string &, const PackageDatabaseEntry * const) const
-{
- return true;
-}
-
-bool
-Environment::query_user_masks(const PackageDatabaseEntry &) const
-{
- return false;
-}
-
-bool
-Environment::query_user_unmasks(const PackageDatabaseEntry &) const
-{
- return false;
-}
-
-std::string
-Environment::bashrc_files() const
-{
- return "";
-}
-
-
-std::string
-Environment::hook_dirs() const
-{
- return "";
-}
-
-std::string
-Environment::fetchers_dirs() const
-{
- return
- DATADIR "/paludis/fetchers" " "
- LIBEXECDIR "/paludis/fetchers" " "
- ;
-}
-
-std::string
-Environment::syncers_dirs() const
-{
- return
- DATADIR "/paludis/syncers" " "
- LIBEXECDIR "/paludis/syncers" " "
- ;
-}
-
-namespace
-{
- static const std::multimap<std::string, std::string> environment_mirrors;
-}
-
-Environment::MirrorIterator
-Environment::begin_mirrors(const std::string &) const
-{
- return MirrorIterator(environment_mirrors.begin());
-}
-
-Environment::MirrorIterator
-Environment::end_mirrors(const std::string &) const
-{
- return MirrorIterator(environment_mirrors.end());
-}
-
-int
-Environment::perform_hook(const Hook &) const
-{
- return 0;
-}
-
-std::tr1::shared_ptr<const UseFlagNameCollection>
-Environment::known_use_expand_names(const UseFlagName &, const PackageDatabaseEntry *) const
-{
- return std::tr1::shared_ptr<const UseFlagNameCollection>(new UseFlagNameCollection::Concrete);
-}
-
-std::tr1::shared_ptr<const SetsCollection>
-Environment::sets_list() const
-{
- return std::tr1::shared_ptr<const SetsCollection>(new SetsCollection::Concrete);
-}
-
-bool
-Environment::accept_eapi(const std::string & e) const
-{
- return e == "0" || e == "" || e == "paludis-1" || e == "CRAN-1";
-}
-
-FSEntry
-Environment::root() const
-{
- return FSEntry("/");
-}
-
-std::tr1::shared_ptr<const DestinationsCollection>
-Environment::default_destinations() const
-{
- std::tr1::shared_ptr<DestinationsCollection> result(new DestinationsCollection::Concrete);
-
- for (PackageDatabase::RepositoryIterator r(package_database()->begin_repositories()),
- r_end(package_database()->end_repositories()) ;
- r != r_end ; ++r)
- if ((*r)->destination_interface)
- if ((*r)->destination_interface->is_default_destination())
- result->insert(*r);
-
- return result;
-}
-
-uid_t
-Environment::reduced_uid() const
-{
- return getuid();
-}
-
-gid_t
-Environment::reduced_gid() const
-{
- return getgid();
-}
-
-bool
-Environment::breaks_portage(const PackageDatabaseEntry & e, const VersionMetadata & m) const
-{
- return (e.version.has_try_part() || e.version.has_scm_part()
- || std::string::npos != m.eapi.find("paludis"));
-}
-
-Environment::WorldCallbacks::WorldCallbacks()
-{
-}
-
-Environment::WorldCallbacks::~WorldCallbacks()
-{
-}
-
-void
-Environment::WorldCallbacks::add_callback(const PackageDepSpec &)
-{
-}
-
-void
-Environment::WorldCallbacks::skip_callback(const PackageDepSpec &, const std::string &)
-{
-}
-
-void
-Environment::WorldCallbacks::remove_callback(const PackageDepSpec &)
-{
-}
-
-void
-Environment::WorldCallbacks::add_callback(const SetName &)
-{
-}
-
-void
-Environment::WorldCallbacks::skip_callback(const SetName &, const std::string &)
-{
-}
-
-void
-Environment::WorldCallbacks::remove_callback(const SetName &)
-{
-}
-
-bool
-Environment::accept_interactive() const
-{
- return false;
-}
-
-bool
-Environment::accept_breaks_portage() const
-{
- return true;
-}
-
diff --git a/paludis/environment.hh b/paludis/environment.hh
index 764ff49..2dca949 100644
--- a/paludis/environment.hh
+++ b/paludis/environment.hh
@@ -20,10 +20,13 @@
#ifndef PALUDIS_GUARD_PALUDIS_ENVIRONMENT_HH
#define PALUDIS_GUARD_PALUDIS_ENVIRONMENT_HH 1
+#include <paludis/util/instantiation_policy.hh>
+#include <paludis/util/options.hh>
+#include <paludis/util/collection.hh>
+#include <paludis/util/fs_entry.hh>
#include <paludis/mask_reasons.hh>
#include <paludis/name.hh>
-#include <paludis/package_database.hh>
-#include <paludis/util/instantiation_policy.hh>
+#include <paludis/repository-fwd.hh>
/** \file
* Declarations for the Environment class.
@@ -33,59 +36,29 @@
namespace paludis
{
- struct EnvironmentMirrorIteratorTag;
+ class Hook;
+ class PackageDatabase;
+ class PackageDatabaseEntry;
+ class DepSpec;
+
+#include <paludis/environment-se.hh>
/**
- * Iterate over environment mirrors.
+ * Options for Environment::mask_reasons().
*
* \see Environment
+ * \see MaskReasonsOption
* \ingroup grpenvironment
*/
- typedef libwrapiter::ForwardIterator<EnvironmentMirrorIteratorTag,
- const std::pair<const std::string, std::string> > EnvironmentMirrorIterator;
+ typedef Options<MaskReasonsOption> MaskReasonsOptions;
/**
- * Represents the data for an Environment hook call.
+ * A collection of mirror prefixes.
*
+ * \see Environment
* \ingroup grpenvironment
- * \nosubgrouping
*/
- class Hook :
- private PrivateImplementationPattern<Hook>
- {
- public:
- ///\name Basic operations
- ///\{
-
- Hook(const std::string & name);
-
- Hook(const Hook &);
-
- ~Hook();
-
- ///\}
-
- /// Add data to the hook.
- Hook operator() (const std::string & key, const std::string & value) const
- PALUDIS_ATTRIBUTE((warn_unused_result));
-
- ///\name Iterate over environment data
- ///\{
-
- typedef libwrapiter::ForwardIterator<Hook, const std::pair<const std::string, std::string> > Iterator;
-
- Iterator begin() const
- PALUDIS_ATTRIBUTE((warn_unused_result));
-
- Iterator end() const
- PALUDIS_ATTRIBUTE((warn_unused_result));
-
- ///\}
-
- /// Our name.
- std::string name() const
- PALUDIS_ATTRIBUTE((warn_unused_result));
- };
+ typedef SequentialCollection<std::string> MirrorsCollection;
/**
* Represents a working environment, which contains an available packages
@@ -95,364 +68,201 @@ namespace paludis
* Contains a PackageDatabase, which in turn contains a number of Repository
* instances.
*
- * EnvironmentMaker is often used to create the appropriate Environment
- * subclass for an application.
+ * Environment itself is purely an interface class. Actual Environment
+ * implementations descend from EnvironmentImplementation, which provides
+ * much of the common implementation details. EnvironmentMaker is often
+ * used to create the appropriate Environment subclass for an application.
*
* \ingroup grpenvironment
* \see PackageDatabase
- * \see Repository
* \see EnvironmentMaker
+ * \see EnvironmentImplementation
* \nosubgrouping
*/
class Environment :
private InstantiationPolicy<Environment, instantiation_method::NonCopyableTag>
{
- private:
- std::tr1::shared_ptr<PackageDatabase> _package_database;
+ public:
+ ///\name Basic operations
+ ///\{
- protected:
- /**
- * Constructor.
- */
- Environment(std::tr1::shared_ptr<PackageDatabase>);
+ virtual ~Environment() = 0;
- /**
- * Local package set, or zero.
- */
- virtual std::tr1::shared_ptr<CompositeDepSpec> local_package_set(const SetName &) const
- {
- return std::tr1::shared_ptr<AllDepSpec>();
- }
+ ///\}
- /**
- * Change our package database.
- */
- void change_package_database(std::tr1::shared_ptr<PackageDatabase> _p)
- {
- _package_database = _p;
- }
+ ///\name Use-related queries
+ ///\{
- public:
/**
- * Does the user want the specified USE flag set for a
- * particular package?
- *
- * Default behaviour: all USE flags turned off, unless overridden by
- * the repository for the pde.
+ * Is a particular use flag enabled for a particular package?
*/
- virtual bool query_use(const UseFlagName &, const PackageDatabaseEntry *) const
- PALUDIS_ATTRIBUTE((warn_unused_result));
+ virtual bool query_use(const UseFlagName &, const PackageDatabaseEntry &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
/**
- * Force a use flag.
+ * Return a collection of known use flag names for a particular package that start
+ * with a particular use expand prefix.
+ *
+ * It is up to subclasses to decide whether to return all known use flags with
+ * the specified prefix or merely all enabled use flags. It is not safe to assume
+ * that all flags in the returned value will be enabled for the specified package.
*/
- virtual void force_use(std::tr1::shared_ptr<const PackageDepSpec>, const UseFlagName &,
- const UseFlagState) = 0;
+ virtual std::tr1::shared_ptr<const UseFlagNameCollection> known_use_expand_names(
+ const UseFlagName &, const PackageDatabaseEntry &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
- /**
- * Clear forced use flags.
- */
- virtual void clear_forced_use() = 0;
+ ///\}
- /**
- * Fetch any known use expand names (including prefix) that start with a
- * given prefix.
- *
- * Default behaviour: no names known.
- */
- virtual std::tr1::shared_ptr<const UseFlagNameCollection> known_use_expand_names(const UseFlagName &,
- const PackageDatabaseEntry *) const
- PALUDIS_ATTRIBUTE((warn_unused_result));
+ ///\name Mask-related queries
+ ///\{
/**
- * Is the specified KEYWORD accepted?
+ * Return the reasons for a package being masked.
*
- * Default behaviour: only "*" accepted.
+ * \see paludis::query::NotMasked
*/
- virtual bool accept_keyword(const KeywordName &, const PackageDatabaseEntry * const,
- const bool override_tilde_keywords = false) const
- PALUDIS_ATTRIBUTE((warn_unused_result));
+ virtual MaskReasons mask_reasons(const PackageDatabaseEntry &,
+ const MaskReasonsOptions & = MaskReasonsOptions()) const
+ PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
/**
- * Is the specified EAPI accepted?
+ * Do we accept a particular license for a particular package?
*
- * Default behaviour: known EAPIs accepted.
+ * Default behaviour: true.
*/
- virtual bool accept_eapi(const std::string &) const
- PALUDIS_ATTRIBUTE((warn_unused_result));
+ virtual bool accept_license(const std::string &, const PackageDatabaseEntry &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
/**
- * Is the specified LICENSE accepted?
+ * Do we accept any of the specified keywords for a particular package?
*
- * Default behaviour: yes.
- */
- virtual bool accept_license(const std::string &, const PackageDatabaseEntry * const) const
- PALUDIS_ATTRIBUTE((warn_unused_result));
-
- /**
- * Accept packages that break Portage?
+ * If the collection includes "*", should return true.
*
- * Default behaviour: yes.
+ * Default behaviour: true if the collection includes "*".
*/
- virtual bool accept_breaks_portage() const;
+ virtual bool accept_keywords(std::tr1::shared_ptr<const KeywordNameCollection>, const PackageDatabaseEntry &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
- /**
- * Accept interactive packages?
- *
- * Default behaviour: no.
- */
- virtual bool accept_interactive() const;
+ ///\}
- /**
- * Fetch the masks for a particular package.
- */
- MaskReasons mask_reasons(const PackageDatabaseEntry &,
- const bool override_tilde_keywords = false,
- const bool override_unkeyworded = false) const
- PALUDIS_ATTRIBUTE((warn_unused_result));
+ ///\name Database-related functions
+ ///\{
- /**
- * Are there any user masks on a package?
- *
- * Default behaviour: no.
- */
- virtual bool query_user_masks(const PackageDatabaseEntry &) const
- PALUDIS_ATTRIBUTE((warn_unused_result));
+ virtual std::tr1::shared_ptr<PackageDatabase> package_database()
+ PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
- /**
- * Are there any user unmasks on a package?
- *
- * Default behaviour: no.
- */
- virtual bool query_user_unmasks(const PackageDatabaseEntry &) const
- PALUDIS_ATTRIBUTE((warn_unused_result));
+ virtual std::tr1::shared_ptr<const PackageDatabase> package_database() const
+ PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
- /**
- * Fetch our package database.
- */
- std::tr1::shared_ptr<const PackageDatabase> package_database() const
- {
- return _package_database;
- }
+ ///\}
- /**
- * Fetch our package database.
- */
- std::tr1::shared_ptr<PackageDatabase> package_database()
- {
- return _package_database;
- }
+ ///\name System information
+ ///\{
/**
- * Our bashrc files.
- *
- * Default behaviour: none.
+ * Return a collection of bashrc files to be used by the various components
+ * that are implemented in bash.
*/
- virtual std::string bashrc_files() const
- PALUDIS_ATTRIBUTE((warn_unused_result));
+ virtual std::tr1::shared_ptr<const FSEntryCollection> bashrc_files() const
+ PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
/**
- * Our hook directories.
- *
- * Default behaviour: none.
+ * Return directories to search for syncer scripts.
*/
- virtual std::string hook_dirs() const
- PALUDIS_ATTRIBUTE((warn_unused_result));
+ virtual std::tr1::shared_ptr<const FSEntryCollection> syncers_dirs() const
+ PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
/**
- * Our fetchers directories.
- *
- * Default behaviour: user then paludis fetcher dirs.
+ * Return directories to search for fetcher scripts.
*/
- virtual std::string fetchers_dirs() const
- PALUDIS_ATTRIBUTE((warn_unused_result));
+ virtual std::tr1::shared_ptr<const FSEntryCollection> fetchers_dirs() const
+ PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
/**
- * Our syncers directories.
- *
- * Default behaviour: user then paludis syncer dirs.
+ * Return directories to search for hooks.
*/
- virtual std::string syncers_dirs() const
- PALUDIS_ATTRIBUTE((warn_unused_result));
+ virtual std::tr1::shared_ptr<const FSEntryCollection> hook_dirs() const
+ PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
/**
- * How to run paludis.
+ * Return the command used to launch paludis (the client).
*/
virtual std::string paludis_command() const
PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
/**
- * Change how to run paludis.
+ * Change the command used to launch paludis (the client).
*/
virtual void set_paludis_command(const std::string &) = 0;
/**
- * Destructor.
- */
- virtual ~Environment();
-
- /**
- * Iterator over named mirror entries.
- */
- typedef EnvironmentMirrorIterator MirrorIterator;
-
- /**
- * Iterator to the start of our mirrors.
- *
- * Default behaviour: no mirrors. If specialising, also do
- * Environment::end_mirrors.
+ * Our root location for installs.
*/
- virtual MirrorIterator begin_mirrors(const std::string & mirror) const
- PALUDIS_ATTRIBUTE((warn_unused_result));
+ virtual const FSEntry root() const = 0;
/**
- * Iterator to past the end of our mirrors.
- *
- * Default behaviour: no mirrors. If specialising, also do
- * Environment::begin_mirrors.
+ * User id to use when reduced privs are permissible.
*/
- virtual MirrorIterator end_mirrors(const std::string & mirror) const
- PALUDIS_ATTRIBUTE((warn_unused_result));
+ virtual uid_t reduced_uid() const = 0;
/**
- * Fetch a named package set.
+ * Group id to use when reduced privs are permissible.
*/
- std::tr1::shared_ptr<DepSpec> package_set(const SetName &) const
- PALUDIS_ATTRIBUTE((warn_unused_result));
-
- /**
- * Fetch all named sets. Does not include sets from repositories.
- *
- * Default behaviour: no sets.
- */
- virtual std::tr1::shared_ptr<const SetsCollection> sets_list() const
- PALUDIS_ATTRIBUTE((warn_unused_result));
-
- /**
- * Subclass for callbacks used by add_appropriate_to_world and
- * remove_appropriate_from_world.
- *
- * \ingroup grpenvironment
- * \nosubgrouping
- */
- class WorldCallbacks
- {
- protected:
- ///\name Basic operations
- ///\{
-
- WorldCallbacks();
-
- ///\}
-
- public:
- ///\name Basic operations
- ///\{
-
- virtual ~WorldCallbacks();
-
- ///\}
+ virtual gid_t reduced_gid() const = 0;
- /**
- * Called when adding an entry to world.
- */
- virtual void add_callback(const PackageDepSpec &);
-
- /**
- * Called when skipping adding an entry to world.
- */
- virtual void skip_callback(const PackageDepSpec &, const std::string &);
-
- /**
- * Called when removing an entry to world.
- */
- virtual void remove_callback(const PackageDepSpec &);
-
- /**
- * 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 &);
- };
+ ///\name Mirror information
+ ///\{
/**
- * Add packages to world, if they are not there already, and if they are
- * not a restricted spec.
+ * Return the mirror URI prefixes for a named mirror.
*/
- void add_appropriate_to_world(std::tr1::shared_ptr<const DepSpec> a, WorldCallbacks *) const;
+ virtual std::tr1::shared_ptr<const MirrorsCollection> mirrors(const std::string &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
- /**
- * Remove packages from world, if they are there.
- */
- void remove_appropriate_from_world(std::tr1::shared_ptr<const DepSpec>, WorldCallbacks *) const;
+ ///\}
- /**
- * Add a set to world, if it's not inappropriate.
- */
- void add_set_to_world(const SetName &, WorldCallbacks *) const;
+ ///\name Package sets
+ ///\{
/**
- * Remove a set from world.
+ * Return all known named sets.
*/
- void remove_set_from_world(const SetName &, WorldCallbacks *) const;
+ virtual std::tr1::shared_ptr<const SetNameCollection> set_names() const
+ PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
/**
- * Perform a hook. Returns the highest exit status of all
- * hooks called (usually, only zero or non-zero is
- * meaningful).
+ * Return a named set.
*
- * Default behaviour: nothing happens.
+ * If the named set is not known, returns a zero pointer.
*/
- virtual int perform_hook(const Hook & hook) const PALUDIS_ATTRIBUTE((warn_unused_result));
+ virtual std::tr1::shared_ptr<DepSpec> set(const SetName &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
- /**
- * Default root location.
- *
- * Default: /.
- */
- virtual FSEntry root() const
- PALUDIS_ATTRIBUTE((warn_unused_result));
+ ///\}
+
+ ///\name Destination information
+ ///\{
/**
- * Default destinations.
- *
- * Default: all repositories that provide RepositoryDestinationInterface and mark themselves
- * as a default destination.
+ * Default destination candidates for installing packages.
*/
virtual std::tr1::shared_ptr<const DestinationsCollection> default_destinations() const
- PALUDIS_ATTRIBUTE((warn_unused_result));
+ PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
- /**
- * uid to use for operations that don't reqiure root privs.
- *
- * Should return the current uid unless we are root. Default: always return
- * the current uid.
- */
- virtual uid_t reduced_uid() const
- PALUDIS_ATTRIBUTE((warn_unused_result));
+ ///\}
- /**
- * gid to use for operations that don't reqiure root privs.
- *
- * Should return the current gid unless we are root. Default: always return
- * the current gid.
- */
- virtual gid_t reduced_gid() const
- PALUDIS_ATTRIBUTE((warn_unused_result));
+ ///\name Hook methods
+ ///\{
/**
- * Test whether a particular package will break Portage.
+ * Perform a hook, return the highest exit status.
*/
- bool breaks_portage(const PackageDatabaseEntry &, const VersionMetadata &) const;
+ virtual int perform_hook(const Hook &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
+
+ ///\}
};
}
diff --git a/paludis/environment.se b/paludis/environment.se
new file mode 100644
index 0000000..e4bf5c6
--- /dev/null
+++ b/paludis/environment.se
@@ -0,0 +1,21 @@
+#!/bin/bash
+# vim: set sw=4 sts=4 et ft=sh :
+
+make_enum_MaskReasonsOption()
+{
+ prefix mro
+
+ key mro_override_unkeyworded "Ignore keyword masks for unkeyworded packages"
+ key mro_override_tilde_keywords "Pretend packages with keyword ~foo also have keyword foo"
+
+ doxygen_comment << "END"
+ /**
+ * Options for Environment::mask_reasons().
+ *
+ * \see MaskReasonsOptions
+ * \see Environment
+ * \ingroup grpenvironment
+ */
+END
+}
+
diff --git a/paludis/environment_implementation.cc b/paludis/environment_implementation.cc
new file mode 100644
index 0000000..141864e
--- /dev/null
+++ b/paludis/environment_implementation.cc
@@ -0,0 +1,408 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2005, 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
+ * 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 "environment_implementation.hh"
+#include <paludis/package_database_entry.hh>
+#include <paludis/version_metadata.hh>
+#include <paludis/package_database.hh>
+#include <paludis/util/collection_concrete.hh>
+
+using namespace paludis;
+
+namespace
+{
+ struct LicenceChecker :
+ DepSpecVisitorTypes::ConstVisitor,
+ DepSpecVisitorTypes::ConstVisitor::VisitChildren<LicenceChecker, AllDepSpec>
+ {
+ using DepSpecVisitorTypes::ConstVisitor::VisitChildren<LicenceChecker, AllDepSpec>::visit;
+
+ bool ok;
+ const EnvironmentImplementation * const env;
+ bool (EnvironmentImplementation::* const func) (const std::string &, const PackageDatabaseEntry &) const;
+ const PackageDatabaseEntry * const db_entry;
+
+ LicenceChecker(const EnvironmentImplementation * const e,
+ bool (EnvironmentImplementation::* const f) (const std::string &, const PackageDatabaseEntry &) const,
+ const PackageDatabaseEntry * const d) :
+ ok(true),
+ env(e),
+ func(f),
+ db_entry(d)
+ {
+ }
+
+ void visit(const AnyDepSpec * spec)
+ {
+ bool local_ok(false);
+
+ if (spec->begin() == spec->end())
+ local_ok = true;
+ else
+ {
+ for (CompositeDepSpec::Iterator i(spec->begin()), i_end(spec->end()) ;
+ i != i_end ; ++i)
+ {
+ Save<bool> save_ok(&ok, true);
+ (*i)->accept(this);
+ local_ok |= ok;
+ }
+ }
+
+ ok &= local_ok;
+ }
+
+ void visit(const UseDepSpec * spec)
+ {
+ if (env->query_use(spec->flag(), *db_entry))
+ std::for_each(spec->begin(), spec->end(), accept_visitor(this));
+ }
+
+ void visit(const PlainTextDepSpec * spec)
+ {
+ if (! (env->*func)(spec->text(), *db_entry))
+ ok = false;
+ }
+
+ void visit(const PackageDepSpec *) PALUDIS_ATTRIBUTE((noreturn))
+ {
+ throw InternalError(PALUDIS_HERE, "Encountered PackageDepSpec in licence?");
+ }
+
+ void visit(const BlockDepSpec *) PALUDIS_ATTRIBUTE((noreturn))
+ {
+ throw InternalError(PALUDIS_HERE, "Encountered BlockDepSpec in licence?");
+ }
+ };
+}
+bool
+EnvironmentImplementation::accept_eapi(const std::string & e, const PackageDatabaseEntry &) const
+{
+ return e == "0" || e == "" || e == "paludis-1" || e == "CRAN-1";
+}
+
+bool
+EnvironmentImplementation::accept_keywords(std::tr1::shared_ptr<const KeywordNameCollection> k,
+ const PackageDatabaseEntry &) const
+{
+ return k->end() != k->find(KeywordName("*"));
+}
+
+bool
+EnvironmentImplementation::accept_license(const std::string &, const PackageDatabaseEntry &) const
+{
+ return true;
+}
+
+bool
+EnvironmentImplementation::accept_breaks_portage(const PackageDatabaseEntry &) const
+{
+ return true;
+}
+
+bool
+EnvironmentImplementation::accept_interactive(const PackageDatabaseEntry &) const
+{
+ return false;
+}
+
+bool
+EnvironmentImplementation::masked_by_user(const PackageDatabaseEntry &) const
+{
+ return false;
+}
+
+bool
+EnvironmentImplementation::unmasked_by_user(const PackageDatabaseEntry &) const
+{
+ return false;
+}
+
+bool
+EnvironmentImplementation::breaks_portage(const PackageDatabaseEntry & e, const VersionMetadata & m) const
+{
+ return (e.version.has_try_part() || e.version.has_scm_part()
+ || std::string::npos != m.eapi.find("paludis"));
+}
+
+EnvironmentImplementation::~EnvironmentImplementation()
+{
+}
+
+
+std::tr1::shared_ptr<const UseFlagNameCollection>
+EnvironmentImplementation::known_use_expand_names(const UseFlagName &, const PackageDatabaseEntry &) const
+{
+ static std::tr1::shared_ptr<const UseFlagNameCollection> result(new UseFlagNameCollection::Concrete);
+ return result;
+}
+
+std::tr1::shared_ptr<const FSEntryCollection>
+EnvironmentImplementation::bashrc_files() const
+{
+ static std::tr1::shared_ptr<const FSEntryCollection> result(new FSEntryCollection::Concrete);
+ return result;
+}
+
+std::tr1::shared_ptr<const FSEntryCollection>
+EnvironmentImplementation::syncers_dirs() const
+{
+ std::tr1::shared_ptr<FSEntryCollection> result(new FSEntryCollection::Concrete);
+ result->push_back(FSEntry(DATADIR "/paludis/syncers"));
+ result->push_back(FSEntry(LIBEXECDIR "/paludis/syncers"));
+ return result;
+}
+
+std::tr1::shared_ptr<const FSEntryCollection>
+EnvironmentImplementation::fetchers_dirs() const
+{
+ std::tr1::shared_ptr<FSEntryCollection> result(new FSEntryCollection::Concrete);
+ result->push_back(FSEntry(DATADIR "/paludis/fetchers"));
+ result->push_back(FSEntry(LIBEXECDIR "/paludis/fetchers"));
+ return result;
+}
+
+std::tr1::shared_ptr<const FSEntryCollection>
+EnvironmentImplementation::hook_dirs() const
+{
+ static std::tr1::shared_ptr<const FSEntryCollection> result(new FSEntryCollection::Concrete);
+ return result;
+}
+
+const FSEntry
+EnvironmentImplementation::root() const
+{
+ return FSEntry("/");
+}
+
+uid_t
+EnvironmentImplementation::reduced_uid() const
+{
+ return getuid();
+}
+
+gid_t
+EnvironmentImplementation::reduced_gid() const
+{
+ return getgid();
+}
+
+std::tr1::shared_ptr<const MirrorsCollection>
+EnvironmentImplementation::mirrors(const std::string &) const
+{
+ static std::tr1::shared_ptr<const MirrorsCollection> result(new MirrorsCollection::Concrete);
+ return result;
+}
+
+std::tr1::shared_ptr<const SetNameCollection>
+EnvironmentImplementation::set_names() const
+{
+ static std::tr1::shared_ptr<const SetNameCollection> result(new SetNameCollection::Concrete);
+ return result;
+}
+
+int
+EnvironmentImplementation::perform_hook(const Hook &) const
+{
+ return 0;
+}
+
+std::tr1::shared_ptr<const DestinationsCollection>
+EnvironmentImplementation::default_destinations() const
+{
+ std::tr1::shared_ptr<DestinationsCollection> result(new DestinationsCollection::Concrete);
+
+ for (PackageDatabase::RepositoryIterator r(package_database()->begin_repositories()),
+ r_end(package_database()->end_repositories()) ;
+ r != r_end ; ++r)
+ if ((*r)->destination_interface)
+ if ((*r)->destination_interface->is_default_destination())
+ result->insert(*r);
+
+ return result;
+}
+
+MaskReasons
+EnvironmentImplementation::mask_reasons(const PackageDatabaseEntry & e, const MaskReasonsOptions & options) const
+{
+ Context context("When checking for mask reasons for '" + stringify(e) + "':");
+
+ MaskReasons result;
+ std::tr1::shared_ptr<const VersionMetadata> metadata(package_database()->fetch_repository(
+ e.repository)->version_metadata(e.name, e.version));
+
+ if (! accept_eapi(metadata->eapi, e))
+ {
+ result += mr_eapi;
+ return result;
+ }
+
+ if (breaks_portage(e, *metadata) && ! accept_breaks_portage(e))
+ result += mr_breaks_portage;
+
+ if (metadata->interactive && ! accept_interactive(e))
+ result += mr_interactive;
+
+ if (metadata->virtual_interface)
+ {
+ result |= mask_reasons(metadata->virtual_interface->virtual_for);
+ if (result.any())
+ result += mr_by_association;
+ }
+
+ if (metadata->ebuild_interface)
+ {
+ std::tr1::shared_ptr<const KeywordNameCollection> keywords(metadata->ebuild_interface->keywords());
+ if (! accept_keywords(keywords, e))
+ {
+ do
+ {
+ if (options[mro_override_unkeyworded])
+ {
+ std::tr1::shared_ptr<KeywordNameCollection> minus_keywords(new KeywordNameCollection::Concrete);
+ for (KeywordNameCollection::Iterator k(keywords->begin()), k_end(keywords->end()) ;
+ k != k_end ; ++k)
+ if ('-' == stringify(*k).at(0))
+ minus_keywords->insert(KeywordName(stringify(*k).substr(1)));
+
+ if (! accept_keywords(minus_keywords, e))
+ continue;
+ }
+
+ if (options[mro_override_tilde_keywords])
+ {
+ std::tr1::shared_ptr<KeywordNameCollection> detildeified_keywords(new KeywordNameCollection::Concrete);
+ for (KeywordNameCollection::Iterator k(keywords->begin()), k_end(keywords->end()) ;
+ k != k_end ; ++k)
+ {
+ detildeified_keywords->insert(*k);
+ if ('~' == stringify(*k).at(0))
+ detildeified_keywords->insert(KeywordName(stringify(*k).substr(1)));
+ }
+
+ if (accept_keywords(detildeified_keywords, e))
+ continue;
+ }
+
+ result += mr_keyword;
+ } while (false);
+ }
+ }
+
+ if (metadata->license_interface)
+ {
+ LicenceChecker lc(this, &EnvironmentImplementation::accept_license, &e);
+ metadata->license_interface->license()->accept(&lc);
+ if (! lc.ok)
+ result += mr_license;
+ }
+
+ if (! unmasked_by_user(e))
+ {
+ if (masked_by_user(e))
+ result += mr_user_mask;
+
+ std::tr1::shared_ptr<const Repository> repo(package_database()->fetch_repository(e.repository));
+ if (repo->mask_interface)
+ {
+ if (repo->mask_interface->query_profile_masks(e.name, e.version))
+ result += mr_profile_mask;
+
+ if (repo->mask_interface->query_repository_masks(e.name, e.version))
+ result += mr_repository_mask;
+ }
+ }
+
+ return result;
+}
+
+std::tr1::shared_ptr<DepSpec>
+EnvironmentImplementation::set(const SetName & s) const
+{
+ std::tr1::shared_ptr<CompositeDepSpec> result(local_set(s));
+ if (result)
+ return result;
+
+ /* these sets always exist, even if empty */
+ if (s.data() == "everything" || s.data() == "system" || s.data() == "world" || s.data() == "security")
+ result.reset(new AllDepSpec);
+
+ for (PackageDatabase::RepositoryIterator r(package_database()->begin_repositories()),
+ r_end(package_database()->end_repositories()) ;
+ r != r_end ; ++r)
+ {
+ if (! (*r)->sets_interface)
+ continue;
+
+ std::tr1::shared_ptr<DepSpec> add((*r)->sets_interface->package_set(s));
+ if (0 != add)
+ {
+ if (! result)
+ result.reset(new AllDepSpec);
+ result->add_child(add);
+ }
+
+ if ("everything" == s.data() || "world" == s.data())
+ {
+ add = (*r)->sets_interface->package_set(SetName("system"));
+ if (0 != add)
+ result->add_child(add);
+ }
+ }
+
+ return result;
+}
+
+bool
+EnvironmentImplementation::query_use(const UseFlagName & f, const PackageDatabaseEntry & e) const
+{
+ std::tr1::shared_ptr<const Repository> repo(package_database()->fetch_repository(e.repository));
+
+ if (repo && repo->use_interface)
+ {
+ if (repo->use_interface->query_use_mask(f, &e))
+ return false;
+ if (repo->use_interface->query_use_force(f, &e))
+ return true;
+ }
+
+ if (repo && repo->use_interface)
+ {
+ switch (repo->use_interface->query_use(f, &e))
+ {
+ case use_disabled:
+ case use_unspecified:
+ return false;
+
+ case use_enabled:
+ return true;
+ }
+
+ throw InternalError(PALUDIS_HERE, "bad state");
+ }
+ else
+ return false;
+}
+
+std::tr1::shared_ptr<CompositeDepSpec>
+EnvironmentImplementation::local_set(const SetName &) const
+{
+ return std::tr1::shared_ptr<CompositeDepSpec>();
+}
+
diff --git a/paludis/environment_implementation.hh b/paludis/environment_implementation.hh
new file mode 100644
index 0000000..111f2dd
--- /dev/null
+++ b/paludis/environment_implementation.hh
@@ -0,0 +1,162 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2005, 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
+ * 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_ENVIRONMENT_IMPLEMENTATION_HH
+#define PALUDIS_GUARD_PALUDIS_ENVIRONMENT_IMPLEMENTATION_HH 1
+
+#include <paludis/environment.hh>
+
+namespace paludis
+{
+ class VersionMetadata;
+ class CompositeDepSpec;
+
+ /**
+ * Simplifies implementing the Environment interface.
+ *
+ * \ingroup grpenvironment
+ * \see Environment
+ */
+ class EnvironmentImplementation :
+ public Environment
+ {
+ protected:
+ ///\name Mask reasons
+
+ /**
+ * Do we accept a particular EAPI for a particular package?
+ *
+ * Default behaviour: recognised EAPIs accepted.
+ */
+ virtual bool accept_eapi(const std::string &, const PackageDatabaseEntry &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ /**
+ * Accept packages with versions, EAPIs etc that will break Portage?
+ *
+ * Default behaviour: true.
+ */
+ virtual bool accept_breaks_portage(const PackageDatabaseEntry &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ /**
+ * Accept interactive packages?
+ *
+ * Default behaviour: true.
+ */
+ virtual bool accept_interactive(const PackageDatabaseEntry &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ /**
+ * Is a package masked by user settings?
+ *
+ * Default behaviour: false.
+ */
+ virtual bool masked_by_user(const PackageDatabaseEntry &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ /**
+ * Is a package unmasked by user settings?
+ *
+ * Default behaviour: false.
+ */
+ virtual bool unmasked_by_user(const PackageDatabaseEntry &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ /**
+ * Does a package break Portage?
+ */
+ virtual bool breaks_portage(const PackageDatabaseEntry &, const VersionMetadata &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ ///\}
+
+ ///\name Package sets
+ ///\{
+
+ /**
+ * Return the environment-specific named set, or a zero pointer if no such set is available.
+ */
+ virtual std::tr1::shared_ptr<CompositeDepSpec> local_set(const SetName &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ public:
+ ///\name Basic operations
+ ///\{
+
+ virtual ~EnvironmentImplementation() = 0;
+
+ ///\}
+
+ virtual bool query_use(const UseFlagName &, const PackageDatabaseEntry &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual std::tr1::shared_ptr<const UseFlagNameCollection> known_use_expand_names(
+ const UseFlagName &, const PackageDatabaseEntry &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual MaskReasons mask_reasons(const PackageDatabaseEntry &,
+ const MaskReasonsOptions & = MaskReasonsOptions()) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual bool accept_license(const std::string &, const PackageDatabaseEntry &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual bool accept_keywords(std::tr1::shared_ptr<const KeywordNameCollection>, const PackageDatabaseEntry &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual std::tr1::shared_ptr<const FSEntryCollection> bashrc_files() const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual std::tr1::shared_ptr<const FSEntryCollection> syncers_dirs() const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual std::tr1::shared_ptr<const FSEntryCollection> fetchers_dirs() const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual std::tr1::shared_ptr<const FSEntryCollection> hook_dirs() const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual const FSEntry root() const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual uid_t reduced_uid() const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual gid_t reduced_gid() const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual std::tr1::shared_ptr<const MirrorsCollection> mirrors(const std::string &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual std::tr1::shared_ptr<const SetNameCollection> set_names() const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual std::tr1::shared_ptr<DepSpec> set(const SetName &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual std::tr1::shared_ptr<const DestinationsCollection> default_destinations() const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual int perform_hook(const Hook &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+ };
+}
+
+#endif
diff --git a/paludis/environment_implementation_TEST.cc b/paludis/environment_implementation_TEST.cc
new file mode 100644
index 0000000..23ce2d6
--- /dev/null
+++ b/paludis/environment_implementation_TEST.cc
@@ -0,0 +1,132 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 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
+ * 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/environment_implementation.hh>
+#include <paludis/package_database.hh>
+#include <paludis/repositories/fake/fake_repository.hh>
+#include <test/test_framework.hh>
+#include <test/test_runner.hh>
+
+using namespace paludis;
+using namespace test;
+
+namespace
+{
+ class EITestEnvironment :
+ public EnvironmentImplementation
+ {
+ private:
+ std::tr1::shared_ptr<PackageDatabase> _package_database;
+
+ public:
+ EITestEnvironment() :
+ _package_database(new PackageDatabase(this))
+ {
+ std::tr1::shared_ptr<FakeRepository> repo(new FakeRepository(this, RepositoryName("repo")));
+ _package_database->add_repository(1, std::tr1::shared_ptr<Repository>(repo));
+
+ repo->add_version("foo", "one", "0")->ebuild_interface->keywords_string = "test foo";
+ repo->add_version("foo", "two", "0")->ebuild_interface->keywords_string = "~test foo";
+ repo->add_version("foo", "three", "0")->ebuild_interface->keywords_string = "-test foo";
+ repo->add_version("foo", "four", "0")->ebuild_interface->keywords_string = "-* foo";
+ }
+
+ ~EITestEnvironment()
+ {
+ }
+
+ std::tr1::shared_ptr<PackageDatabase> package_database()
+ {
+ return _package_database;
+ }
+
+ std::tr1::shared_ptr<const PackageDatabase> package_database() const
+ {
+ return _package_database;
+ }
+
+ std::string paludis_command() const
+ {
+ return "";
+ }
+
+ void set_paludis_command(const std::string &)
+ {
+ }
+
+ bool accept_keywords(std::tr1::shared_ptr<const KeywordNameCollection> k, const PackageDatabaseEntry &) const
+ {
+ return k->end() != k->find(KeywordName("test")) || k->end() != k->find(KeywordName("*"));
+ }
+ };
+}
+
+namespace test_cases
+{
+ struct MaskReasonsTest : TestCase
+ {
+ MaskReasonsTest() : TestCase("mask reasons") { }
+
+ void run()
+ {
+ EITestEnvironment env;
+
+ MaskReasons m1(env.mask_reasons(PackageDatabaseEntry(
+ QualifiedPackageName("foo/one"), VersionSpec("0"), RepositoryName("repo"))));
+ TEST_CHECK(! m1[mr_keyword]);
+
+ MaskReasons m2(env.mask_reasons(PackageDatabaseEntry(
+ QualifiedPackageName("foo/two"), VersionSpec("0"), RepositoryName("repo"))));
+ TEST_CHECK(m2[mr_keyword]);
+ m2 = env.mask_reasons(PackageDatabaseEntry(
+ QualifiedPackageName("foo/two"), VersionSpec("0"), RepositoryName("repo")),
+ MaskReasonsOptions() + mro_override_tilde_keywords);
+ TEST_CHECK(! m2[mr_keyword]);
+ m2 = env.mask_reasons(PackageDatabaseEntry(
+ QualifiedPackageName("foo/two"), VersionSpec("0"), RepositoryName("repo")),
+ MaskReasonsOptions() + mro_override_unkeyworded);
+ TEST_CHECK(! m2[mr_keyword]);
+
+ MaskReasons m3(env.mask_reasons(PackageDatabaseEntry(
+ QualifiedPackageName("foo/three"), VersionSpec("0"), RepositoryName("repo"))));
+ TEST_CHECK(m3[mr_keyword]);
+ m3 = env.mask_reasons(PackageDatabaseEntry(
+ QualifiedPackageName("foo/three"), VersionSpec("0"), RepositoryName("repo")),
+ MaskReasonsOptions() + mro_override_tilde_keywords);
+ TEST_CHECK(m3[mr_keyword]);
+ m3 = env.mask_reasons(PackageDatabaseEntry(
+ QualifiedPackageName("foo/three"), VersionSpec("0"), RepositoryName("repo")),
+ MaskReasonsOptions() + mro_override_unkeyworded);
+ TEST_CHECK(m3[mr_keyword]);
+
+ MaskReasons m4(env.mask_reasons(PackageDatabaseEntry(
+ QualifiedPackageName("foo/four"), VersionSpec("0"), RepositoryName("repo"))));
+ TEST_CHECK(m4[mr_keyword]);
+ m4 = env.mask_reasons(PackageDatabaseEntry(
+ QualifiedPackageName("foo/four"), VersionSpec("0"), RepositoryName("repo")),
+ MaskReasonsOptions() + mro_override_tilde_keywords);
+ TEST_CHECK(m4[mr_keyword]);
+ m4 = env.mask_reasons(PackageDatabaseEntry(
+ QualifiedPackageName("foo/four"), VersionSpec("0"), RepositoryName("repo")),
+ MaskReasonsOptions() + mro_override_unkeyworded);
+ TEST_CHECK(m4[mr_keyword]);
+ }
+ } test_mask_reasons;
+}
+
diff --git a/paludis/environments/adapted/Makefile.am b/paludis/environments/adapted/Makefile.am
new file mode 100644
index 0000000..38fabe2
--- /dev/null
+++ b/paludis/environments/adapted/Makefile.am
@@ -0,0 +1,59 @@
+CLEANFILES = *~ gmon.out *.gcov *.gcno *.gcda ihateautomake.cc ihateautomake.o
+DISTCLEANFILES =
+MAINTAINERCLEANFILES = Makefile.in
+AM_CXXFLAGS = -I$(top_srcdir) @PALUDIS_CXXFLAGS@ @PALUDIS_CXXFLAGS_VISIBILITY@
+DEFS= \
+ -DSYSCONFDIR=\"$(sysconfdir)\" \
+ -DLIBEXECDIR=\"$(libexecdir)\" \
+ -DDATADIR=\"$(datadir)\" \
+ -DLIBDIR=\"$(libdir)\"
+
+libpaludisadaptedenvironment_la_SOURCES = \
+ adapted_environment.cc adapted_environment.hh \
+ registration.cc
+
+libpaludisadaptedenvironment_la_LDFLAGS = -version-info @VERSION_LIB_CURRENT@:@VERSION_LIB_REVISION@:0
+
+libpaludisadaptedenvironment_la_LIBADD = \
+ $(top_builddir)/paludis/repositories/libpaludisrepositories.la \
+ $(top_builddir)/paludis/util/libpaludisutil.la \
+ $(top_builddir)/paludis/libpaludis.la
+
+lib_LTLIBRARIES = libpaludisadaptedenvironment.la
+
+paludis_environment_adapted_includedir = $(includedir)/paludis/environments/adapted
+paludis_environment_adapted_include_HEADERS = \
+ adapted_environment.hh
+
+EXTRA_DIST = \
+ adapted_environment_TEST.cc
+
+TESTS = adapted_environment_TEST
+
+TESTS_ENVIRONMENT = env \
+ PALUDIS_EBUILD_DIR="$(top_srcdir)/ebuild/" \
+ PALUDIS_SKIP_CONFIG="yes" \
+ PALUDIS_REPOSITORY_SO_DIR="$(top_builddir)/paludis/repositories" \
+ TEST_SCRIPT_DIR="$(srcdir)/" \
+ bash $(top_srcdir)/test/run_test.sh
+
+check_PROGRAMS = $(TESTS)
+check_SCRIPTS =
+
+adapted_environment_TEST_SOURCES = adapted_environment_TEST.cc
+
+adapted_environment_TEST_LDADD = \
+ libpaludisadaptedenvironment.la \
+ $(top_builddir)/paludis/environments/test/libpaludistestenvironment.la \
+ $(top_builddir)/paludis/util/test_extras.o \
+ $(top_builddir)/test/libtest.a \
+ $(top_builddir)/paludis/libpaludis.la \
+ $(top_builddir)/paludis/util/libpaludisutil.la \
+ $(DYNAMIC_LD_LIBS)
+
+BUILT_SOURCES =
+
+built-sources : $(BUILT_SOURCES)
+ for s in $(SUBDIRS) ; do $(MAKE) -C $$s built-sources || exit 1 ; done
+
+
diff --git a/paludis/environments/adapted/adapted_environment.cc b/paludis/environments/adapted/adapted_environment.cc
new file mode 100644
index 0000000..afb9183
--- /dev/null
+++ b/paludis/environments/adapted/adapted_environment.cc
@@ -0,0 +1,209 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 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
+ * 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 "adapted_environment.hh"
+#include <paludis/hashed_containers.hh>
+#include <paludis/dep_spec.hh>
+#include <paludis/match_package.hh>
+
+using namespace paludis;
+
+typedef MakeHashedMultiMap<UseFlagName, std::pair<std::tr1::shared_ptr<const PackageDepSpec>, UseFlagState> >::Type Use;
+
+namespace paludis
+{
+ template<>
+ struct Implementation<AdaptedEnvironment>
+ {
+ std::tr1::shared_ptr<Environment> env;
+ Use use;
+
+ Implementation(std::tr1::shared_ptr<Environment> e) :
+ env(e)
+ {
+ }
+ };
+}
+
+AdaptedEnvironment::AdaptedEnvironment(std::tr1::shared_ptr<Environment> e) :
+ PrivateImplementationPattern<AdaptedEnvironment>(new Implementation<AdaptedEnvironment>(e))
+{
+}
+
+AdaptedEnvironment::~AdaptedEnvironment()
+{
+}
+
+void
+AdaptedEnvironment::adapt_use(std::tr1::shared_ptr<const PackageDepSpec> p,
+ const UseFlagName & u, const UseFlagState s)
+{
+ _imp->use.insert(std::make_pair(u, std::make_pair(p, s)));
+}
+
+void
+AdaptedEnvironment::clear_adaptions()
+{
+ _imp.reset(new Implementation<AdaptedEnvironment>(_imp->env));
+}
+
+std::tr1::shared_ptr<PackageDatabase>
+AdaptedEnvironment::package_database()
+{
+ return _imp->env->package_database();
+}
+
+std::tr1::shared_ptr<const PackageDatabase>
+AdaptedEnvironment::package_database() const
+{
+ return _imp->env->package_database();
+}
+
+bool
+AdaptedEnvironment::query_use(const UseFlagName & u, const PackageDatabaseEntry & e) const
+{
+ UseFlagState result(use_unspecified);
+ for (std::pair<Use::const_iterator, Use::const_iterator> p(_imp->use.equal_range(u)) ;
+ p.first != p.second ; ++p.first)
+ if (match_package(*this, *p.first->second.first, e))
+ result = p.first->second.second;
+
+ switch (result)
+ {
+ case use_enabled:
+ return true;
+
+ case use_disabled:
+ return false;
+
+ case use_unspecified:
+ return _imp->env->query_use(u, e);
+ }
+
+ throw InternalError(PALUDIS_HERE, "Bad state");
+}
+
+std::tr1::shared_ptr<const UseFlagNameCollection>
+AdaptedEnvironment::known_use_expand_names(const UseFlagName & u, const PackageDatabaseEntry & e) const
+{
+ return _imp->env->known_use_expand_names(u, e);
+}
+
+MaskReasons
+AdaptedEnvironment::mask_reasons(const PackageDatabaseEntry & e, const MaskReasonsOptions & r) const
+{
+ return _imp->env->mask_reasons(e, r);
+}
+
+bool
+AdaptedEnvironment::accept_license(const std::string & l, const PackageDatabaseEntry & e) const
+{
+ return _imp->env->accept_license(l, e);
+}
+
+bool
+AdaptedEnvironment::accept_keywords(std::tr1::shared_ptr<const KeywordNameCollection> k, const PackageDatabaseEntry & e) const
+{
+ return _imp->env->accept_keywords(k, e);
+}
+
+std::tr1::shared_ptr<const FSEntryCollection>
+AdaptedEnvironment::bashrc_files() const
+{
+ return _imp->env->bashrc_files();
+}
+
+std::tr1::shared_ptr<const FSEntryCollection>
+AdaptedEnvironment::syncers_dirs() const
+{
+ return _imp->env->syncers_dirs();
+}
+
+std::tr1::shared_ptr<const FSEntryCollection>
+AdaptedEnvironment::fetchers_dirs() const
+{
+ return _imp->env->fetchers_dirs();
+}
+
+std::tr1::shared_ptr<const FSEntryCollection>
+AdaptedEnvironment::hook_dirs() const
+{
+ return _imp->env->hook_dirs();
+}
+
+std::string
+AdaptedEnvironment::paludis_command() const
+{
+ return _imp->env->paludis_command();
+}
+
+void
+AdaptedEnvironment::set_paludis_command(const std::string & s)
+{
+ _imp->env->set_paludis_command(s);
+}
+
+const FSEntry
+AdaptedEnvironment::root() const
+{
+ return _imp->env->root();
+}
+
+uid_t
+AdaptedEnvironment::reduced_uid() const
+{
+ return _imp->env->reduced_uid();
+}
+
+gid_t
+AdaptedEnvironment::reduced_gid() const
+{
+ return _imp->env->reduced_gid();
+}
+
+std::tr1::shared_ptr<const MirrorsCollection>
+AdaptedEnvironment::mirrors(const std::string & m) const
+{
+ return _imp->env->mirrors(m);
+}
+
+std::tr1::shared_ptr<const SetNameCollection>
+AdaptedEnvironment::set_names() const
+{
+ return _imp->env->set_names();
+}
+
+std::tr1::shared_ptr<DepSpec>
+AdaptedEnvironment::set(const SetName & s) const
+{
+ return _imp->env->set(s);
+}
+
+std::tr1::shared_ptr<const DestinationsCollection>
+AdaptedEnvironment::default_destinations() const
+{
+ return _imp->env->default_destinations();
+}
+
+int
+AdaptedEnvironment::perform_hook(const Hook & h) const
+{
+ return _imp->env->perform_hook(h);
+}
+
diff --git a/paludis/environments/adapted/adapted_environment.hh b/paludis/environments/adapted/adapted_environment.hh
new file mode 100644
index 0000000..2ac0760
--- /dev/null
+++ b/paludis/environments/adapted/adapted_environment.hh
@@ -0,0 +1,108 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 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
+ * 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_ADAPTED_ADAPTED_ENVIRONMENT_HH
+#define PALUDIS_GUARD_PALUDIS_ENVIRONMENTS_ADAPTED_ADAPTED_ENVIRONMENT_HH 1
+
+#include <paludis/environment.hh>
+
+namespace paludis
+{
+ class PackageDepSpec;
+
+ class AdaptedEnvironment :
+ public Environment,
+ private PrivateImplementationPattern<AdaptedEnvironment>
+ {
+ public:
+ AdaptedEnvironment(std::tr1::shared_ptr<Environment>);
+ ~AdaptedEnvironment();
+
+ ///\name Adapting methods
+ ///\{
+
+ void adapt_use(std::tr1::shared_ptr<const PackageDepSpec>, const UseFlagName &, const UseFlagState);
+ void clear_adaptions();
+
+ ///\}
+
+ virtual bool query_use(const UseFlagName &, const PackageDatabaseEntry &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual std::tr1::shared_ptr<const UseFlagNameCollection> known_use_expand_names(
+ const UseFlagName &, const PackageDatabaseEntry &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual MaskReasons mask_reasons(const PackageDatabaseEntry &,
+ const MaskReasonsOptions & = MaskReasonsOptions()) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual bool accept_license(const std::string &, const PackageDatabaseEntry &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual bool accept_keywords(std::tr1::shared_ptr<const KeywordNameCollection>, const PackageDatabaseEntry &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual std::tr1::shared_ptr<PackageDatabase> package_database()
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual std::tr1::shared_ptr<const PackageDatabase> package_database() const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual std::tr1::shared_ptr<const FSEntryCollection> bashrc_files() const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual std::tr1::shared_ptr<const FSEntryCollection> syncers_dirs() const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual std::tr1::shared_ptr<const FSEntryCollection> fetchers_dirs() const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual std::tr1::shared_ptr<const FSEntryCollection> hook_dirs() const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual std::string paludis_command() const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual void set_paludis_command(const std::string &);
+
+ virtual const FSEntry root() const;
+
+ virtual uid_t reduced_uid() const;
+
+ virtual gid_t reduced_gid() const;
+
+ virtual std::tr1::shared_ptr<const MirrorsCollection> mirrors(const std::string &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual std::tr1::shared_ptr<const SetNameCollection> set_names() const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual std::tr1::shared_ptr<DepSpec> set(const SetName &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual std::tr1::shared_ptr<const DestinationsCollection> default_destinations() const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual int perform_hook(const Hook &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+ };
+}
+
+#endif
diff --git a/paludis/environments/adapted/adapted_environment_TEST.cc b/paludis/environments/adapted/adapted_environment_TEST.cc
new file mode 100644
index 0000000..e83e43c
--- /dev/null
+++ b/paludis/environments/adapted/adapted_environment_TEST.cc
@@ -0,0 +1,40 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 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
+ * 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 "adapted_environment.hh"
+#include <paludis/environments/test/test_environment.hh>
+#include <test/test_framework.hh>
+#include <test/test_runner.hh>
+
+using namespace paludis;
+using namespace test;
+
+namespace test_cases
+{
+ struct AdaptedEnvironmentTest : TestCase
+ {
+ AdaptedEnvironmentTest() : TestCase("adapted environment") { }
+
+ void run()
+ {
+ AdaptedEnvironment e(std::tr1::shared_ptr<TestEnvironment>(new TestEnvironment));
+ }
+ } test_adapted_environment;
+}
+
diff --git a/paludis/environments/adapted/registration.cc b/paludis/environments/adapted/registration.cc
new file mode 100644
index 0000000..18d5e2d
--- /dev/null
+++ b/paludis/environments/adapted/registration.cc
@@ -0,0 +1,32 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 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
+ * 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/environment_maker.hh>
+
+using namespace paludis;
+
+extern "C"
+{
+ void register_environments(EnvironmentMaker * maker);
+}
+
+void register_environments(EnvironmentMaker *)
+{
+}
+
diff --git a/paludis/environments/no_config/Makefile.am b/paludis/environments/no_config/Makefile.am
index 4a5211d..cb852c8 100644
--- a/paludis/environments/no_config/Makefile.am
+++ b/paludis/environments/no_config/Makefile.am
@@ -41,7 +41,33 @@ paludis_environment_no_config_include_HEADERS = \
EXTRA_DIST = \
no_config_environment-sr.hh \
no_config_environment-sr.cc \
- no_config_environment.sr
+ no_config_environment.sr \
+ no_config_environment_TEST.cc \
+ no_config_environment_TEST_setup.sh \
+ no_config_environment_TEST_cleanup.sh
+
+TESTS = no_config_environment_TEST
+
+TESTS_ENVIRONMENT = env \
+ PALUDIS_EBUILD_DIR="$(top_srcdir)/ebuild/" \
+ PALUDIS_SKIP_CONFIG="yes" \
+ PALUDIS_REPOSITORY_SO_DIR="$(top_builddir)/paludis/repositories" \
+ TEST_SCRIPT_DIR="$(srcdir)/" \
+ bash $(top_srcdir)/test/run_test.sh
+
+check_PROGRAMS = $(TESTS)
+check_SCRIPTS = no_config_environment_TEST_setup.sh no_config_environment_TEST_cleanup.sh
+
+no_config_environment_TEST_SOURCES = no_config_environment_TEST.cc
+
+no_config_environment_TEST_LDADD = \
+ libpaludisnoconfigenvironment.la \
+ $(top_builddir)/paludis/util/test_extras.o \
+ $(top_builddir)/test/libtest.a \
+ $(top_builddir)/paludis/repositories/libpaludisrepositories.la \
+ $(top_builddir)/paludis/libpaludis.la \
+ $(top_builddir)/paludis/util/libpaludisutil.la \
+ $(DYNAMIC_LD_LIBS)
BUILT_SOURCES = \
no_config_environment-sr.hh \
diff --git a/paludis/environments/no_config/no_config_environment.cc b/paludis/environments/no_config/no_config_environment.cc
index f53e905..131cd98 100644
--- a/paludis/environments/no_config/no_config_environment.cc
+++ b/paludis/environments/no_config/no_config_environment.cc
@@ -24,6 +24,7 @@
#include <paludis/util/dir_iterator.hh>
#include <paludis/repositories/repository_maker.hh>
#include <paludis/config_file.hh>
+#include <paludis/package_database.hh>
#include <set>
using namespace paludis;
@@ -35,6 +36,8 @@ namespace paludis
template<>
struct Implementation<NoConfigEnvironment>
{
+ const NoConfigEnvironmentParams params;
+
const FSEntry top_level_dir;
const FSEntry write_cache;
bool accept_unstable;
@@ -45,7 +48,10 @@ namespace paludis
std::string paludis_command;
- Implementation(Environment * const env, const NoConfigEnvironmentParams & params);
+ std::tr1::shared_ptr<PackageDatabase> package_database;
+
+ Implementation(NoConfigEnvironment * const env, const NoConfigEnvironmentParams & params);
+ void initialise(NoConfigEnvironment * const env);
};
/* This goat is for Dave Wickham */
@@ -108,12 +114,19 @@ namespace
}
Implementation<NoConfigEnvironment>::Implementation(
- Environment * const env, const NoConfigEnvironmentParams & params) :
- top_level_dir(params.repository_dir),
- write_cache(params.write_cache),
- accept_unstable(params.accept_unstable),
- is_vdb(is_vdb_repository(params.repository_dir, params.repository_type)),
- paludis_command("false")
+ NoConfigEnvironment * const env, const NoConfigEnvironmentParams & p) :
+ params(p),
+ top_level_dir(p.repository_dir),
+ write_cache(p.write_cache),
+ accept_unstable(p.accept_unstable),
+ is_vdb(is_vdb_repository(p.repository_dir, p.repository_type)),
+ paludis_command("false"),
+ package_database(new PackageDatabase(env))
+{
+}
+
+void
+Implementation<NoConfigEnvironment>::initialise(NoConfigEnvironment * const env)
{
Context context("When initialising NoConfigEnvironment at '" + stringify(params.repository_dir) + "':");
@@ -130,7 +143,7 @@ Implementation<NoConfigEnvironment>::Implementation(
keys->insert("write_cache", stringify(params.write_cache));
keys->insert("names_cache", "/var/empty");
- env->package_database()->add_repository(1, ((master_repo =
+ package_database->add_repository(1, ((master_repo =
RepositoryMaker::get_instance()->find_maker("ebuild")(env, keys))));
}
@@ -145,9 +158,9 @@ Implementation<NoConfigEnvironment>::Implementation(
if (FSEntry("/var/empty") != params.master_repository_dir)
keys->insert("master_repository", stringify(master_repo->name()));
- env->package_database()->add_repository(2, ((main_repo =
+ package_database->add_repository(2, ((main_repo =
RepositoryMaker::get_instance()->find_maker("ebuild")(env, keys))));
- env->package_database()->add_repository(-2, RepositoryMaker::get_instance()->find_maker("virtuals")(env,
+ package_database->add_repository(-2, RepositoryMaker::get_instance()->find_maker("virtuals")(env,
std::tr1::shared_ptr<AssociativeCollection<std::string, std::string> >()));
}
else
@@ -162,21 +175,22 @@ Implementation<NoConfigEnvironment>::Implementation(
keys->insert("provides_cache", "/var/empty");
keys->insert("location", stringify(top_level_dir));
- env->package_database()->add_repository(1, RepositoryMaker::get_instance()->find_maker("vdb")(env, keys));
+ package_database->add_repository(1, RepositoryMaker::get_instance()->find_maker("vdb")(env, keys));
std::tr1::shared_ptr<AssociativeCollection<std::string, std::string> > iv_keys(
new AssociativeCollection<std::string, std::string>::Concrete);
iv_keys->insert("root", "/");
- env->package_database()->add_repository(-2, RepositoryMaker::get_instance()->find_maker("installed_virtuals")(env,
+ package_database->add_repository(-2, RepositoryMaker::get_instance()->find_maker("installed_virtuals")(env,
iv_keys));
}
}
NoConfigEnvironment::NoConfigEnvironment(const NoConfigEnvironmentParams & params) :
- Environment(std::tr1::shared_ptr<PackageDatabase>(new PackageDatabase(this))),
PrivateImplementationPattern<NoConfigEnvironment>(
new Implementation<NoConfigEnvironment>(this, params))
{
+ _imp->initialise(this);
+
if (_imp->main_repo)
if (_imp->main_repo->portage_interface->end_profiles() != _imp->main_repo->portage_interface->begin_profiles())
_imp->main_repo->portage_interface->set_profile(_imp->main_repo->portage_interface->begin_profiles());
@@ -192,61 +206,12 @@ NoConfigEnvironment::~NoConfigEnvironment()
{
}
-std::string
-NoConfigEnvironment::paludis_command() const
-{
- return _imp->paludis_command;
-}
-
-void
-NoConfigEnvironment::set_paludis_command(const std::string & s)
-{
- _imp->paludis_command = s;
-}
-
FSEntry
NoConfigEnvironment::main_repository_dir() const
{
return _imp->top_level_dir;
}
-bool
-NoConfigEnvironment::accept_keyword(const KeywordName & k, const PackageDatabaseEntry * const,
- const bool override_tilde_keywords) const
-{
- if (_imp->is_vdb)
- return true;
-
- std::string accept_keywords(_imp->main_repo->portage_interface->profile_variable("ACCEPT_KEYWORDS"));
- if (accept_keywords.empty())
- {
- std::string arch(_imp->main_repo->portage_interface->profile_variable("ARCH"));
- if (stringify(k) == arch)
- return true;
-
- if ((_imp->accept_unstable || override_tilde_keywords) && ("~" + stringify(k) == arch))
- return true;
- }
- else
- {
- std::list<KeywordName> accepted;
- WhitespaceTokeniser::get_instance()->tokenise(accept_keywords,
- create_inserter<KeywordName>(std::back_inserter(accepted)));
-
- if (accepted.end() != std::find(accepted.begin(), accepted.end(), k))
- return true;
-
- if ((_imp->accept_unstable || override_tilde_keywords) && '~' == stringify(k).at(0))
- {
- if (accepted.end() != std::find(accepted.begin(), accepted.end(),
- KeywordName(stringify(k).substr(1))))
- return true;
- }
- }
-
- return false;
-}
-
void
NoConfigEnvironment::set_accept_unstable(const bool value)
{
@@ -277,15 +242,57 @@ NoConfigEnvironment::master_repository() const
return _imp->master_repo;
}
-void
-NoConfigEnvironment::force_use(std::tr1::shared_ptr<const PackageDepSpec>,
- const UseFlagName &, const UseFlagState)
+std::tr1::shared_ptr<PackageDatabase>
+NoConfigEnvironment::package_database()
+{
+ return _imp->package_database;
+}
+
+std::tr1::shared_ptr<const PackageDatabase>
+NoConfigEnvironment::package_database() const
{
- throw InternalError(PALUDIS_HERE, "force_use not currently available for NoConfigEnvironment");
+ return _imp->package_database;
+}
+
+std::string
+NoConfigEnvironment::paludis_command() const
+{
+ return _imp->paludis_command;
}
void
-NoConfigEnvironment::clear_forced_use()
+NoConfigEnvironment::set_paludis_command(const std::string & s)
{
+ _imp->paludis_command = s;
+}
+
+bool
+NoConfigEnvironment::accept_keywords(std::tr1::shared_ptr<const KeywordNameCollection> keywords,
+ const PackageDatabaseEntry &) const
+{
+ if (_imp->is_vdb)
+ return true;
+
+ std::string ak(_imp->main_repo->portage_interface->profile_variable("ACCEPT_KEYWORDS"));
+
+ if (ak.empty())
+ {
+ std::string arch(_imp->main_repo->portage_interface->profile_variable("ARCH"));
+ if (keywords->end() != keywords->find(KeywordName(arch)))
+ return true;
+ }
+ else
+ {
+ std::list<KeywordName> accepted;
+ WhitespaceTokeniser::get_instance()->tokenise(ak,
+ create_inserter<KeywordName>(std::back_inserter(accepted)));
+
+ for (KeywordNameCollection::Iterator k(keywords->begin()), k_end(keywords->end()) ;
+ k != k_end ; ++k)
+ if (accepted.end() != std::find(accepted.begin(), accepted.end(), *k))
+ return true;
+ }
+
+ return false;
}
diff --git a/paludis/environments/no_config/no_config_environment.hh b/paludis/environments/no_config/no_config_environment.hh
index b342149..3366bae 100644
--- a/paludis/environments/no_config/no_config_environment.hh
+++ b/paludis/environments/no_config/no_config_environment.hh
@@ -20,7 +20,7 @@
#ifndef PALUDIS_GUARD_PALUDIS_ENVIRONMENT_NO_CONFIG_NO_CONFIG_ENVIRONMENT_HH
#define PALUDIS_GUARD_PALUDIS_ENVIRONMENT_NO_CONFIG_NO_CONFIG_ENVIRONMENT_HH 1
-#include <paludis/environment.hh>
+#include <paludis/environment_implementation.hh>
#include <paludis/util/fs_entry.hh>
#include <paludis/util/private_implementation_pattern.hh>
#include <libwrapiter/libwrapiter_forward_iterator.hh>
@@ -49,10 +49,14 @@ namespace paludis
* \nosubgrouping
*/
class PALUDIS_VISIBLE NoConfigEnvironment :
- public Environment,
+ public EnvironmentImplementation,
private PrivateImplementationPattern<NoConfigEnvironment>,
private InstantiationPolicy<NoConfigEnvironment, instantiation_method::NonCopyableTag>
{
+ protected:
+ virtual bool accept_keywords(std::tr1::shared_ptr<const KeywordNameCollection>, const PackageDatabaseEntry &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
public:
///\name Basic operations
///\{
@@ -63,21 +67,24 @@ namespace paludis
///\}
- virtual std::string paludis_command() const;
- virtual void set_paludis_command(const std::string &);
+ ///\name NoConfigEnvironment-specific configuration options
+ ///\{
/**
* What is our top level directory for our main repository?
*/
FSEntry main_repository_dir() const;
- virtual bool accept_keyword(const KeywordName &, const PackageDatabaseEntry * const, const bool) const;
-
/**
* Should we accept unstable keywords?
*/
void set_accept_unstable(const bool value);
+ ///\}
+
+ ///\name NoConfigEnvironment-specific repository information
+ ///\{
+
/**
* Fetch our 'main' repository.
*/
@@ -98,10 +105,18 @@ namespace paludis
*/
std::tr1::shared_ptr<const Repository> master_repository() const;
- virtual void force_use(std::tr1::shared_ptr<const PackageDepSpec>, const UseFlagName &,
- const UseFlagState) PALUDIS_ATTRIBUTE((noreturn));
+ ///\}
+
+ virtual std::tr1::shared_ptr<PackageDatabase> package_database()
+ PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual void clear_forced_use();
+ virtual std::tr1::shared_ptr<const PackageDatabase> package_database() const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual std::string paludis_command() const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual void set_paludis_command(const std::string &);
};
}
diff --git a/paludis/environments/no_config/no_config_environment_TEST.cc b/paludis/environments/no_config/no_config_environment_TEST.cc
new file mode 100644
index 0000000..29cbc9c
--- /dev/null
+++ b/paludis/environments/no_config/no_config_environment_TEST.cc
@@ -0,0 +1,46 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * 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
+ * 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 "no_config_environment.hh"
+#include <test/test_runner.hh>
+#include <test/test_framework.hh>
+
+using namespace test;
+using namespace paludis;
+
+namespace test_cases
+{
+ struct NoConfigEnvironmentTest : TestCase
+ {
+ NoConfigEnvironmentTest() : TestCase("no config environment") { }
+
+ void run()
+ {
+ NoConfigEnvironment e(NoConfigEnvironmentParams::create()
+ .repository_dir(FSEntry("no_config_environment_TEST_dir/repo"))
+ .write_cache(FSEntry("/var/empty"))
+ .accept_unstable(false)
+ .repository_type(ncer_auto)
+ .master_repository_dir(FSEntry("/var/empty")));
+
+ TEST_CHECK(e.package_database());
+ }
+ } test_no_config_environment;
+}
+
diff --git a/paludis/environments/no_config/no_config_environment_TEST_cleanup.sh b/paludis/environments/no_config/no_config_environment_TEST_cleanup.sh
new file mode 100755
index 0000000..43e621d
--- /dev/null
+++ b/paludis/environments/no_config/no_config_environment_TEST_cleanup.sh
@@ -0,0 +1,9 @@
+#!/bin/bash
+# vim: set ft=sh sw=4 sts=4 et :
+
+if [ -d no_config_environment_TEST_dir ] ; then
+ rm -fr no_config_environment_TEST_dir
+else
+ true
+fi
+
diff --git a/paludis/environments/no_config/no_config_environment_TEST_setup.sh b/paludis/environments/no_config/no_config_environment_TEST_setup.sh
new file mode 100755
index 0000000..7fcf32a
--- /dev/null
+++ b/paludis/environments/no_config/no_config_environment_TEST_setup.sh
@@ -0,0 +1,25 @@
+#!/bin/bash
+# vim: set ft=sh sw=4 sts=4 et :
+
+mkdir no_config_environment_TEST_dir || exit 2
+cd no_config_environment_TEST_dir || exit 3
+
+mkdir -p repo/{profiles/profile,cat-one/pkg-one}
+cat <<END > repo/profiles/repo_name
+foo
+END
+cat <<END > repo/profiles/categories
+cat-one
+END
+cat <<END > repo/profiles/profiles.desc
+foo profile stable
+END
+cat <<END > repo/profiles/profile/make.defaults
+ARCH="foo"
+USE="moo"
+USE_EXPAND="EXP MORE_EXP THIRD_EXP"
+EXP="one"
+MORE_EXP="one"
+THIRD_EXP="one"
+END
+
diff --git a/paludis/environments/paludis/Makefile.am b/paludis/environments/paludis/Makefile.am
index edcc3f3..97bcce6 100644
--- a/paludis/environments/paludis/Makefile.am
+++ b/paludis/environments/paludis/Makefile.am
@@ -12,6 +12,12 @@ DEFS= \
-DLIBDIR=\"$(libdir)\"
libpaludispaludisenvironment_la_SOURCES = \
+ bashable_conf.cc bashable_conf.hh \
+ keywords_conf.cc keywords_conf.hh \
+ licenses_conf.cc licenses_conf.hh \
+ package_mask_conf.cc package_mask_conf.hh \
+ use_conf.cc use_conf.hh \
+ mirrors_conf.cc mirrors_conf.hh \
paludis_config.cc paludis_config.hh \
paludis_environment.cc paludis_environment.hh \
registration.cc
@@ -45,7 +51,13 @@ paludis_environment_paludis_include_HEADERS = \
paludis_config.hh \
paludis_environment.hh \
use_config_entry-sr.hh \
- repository_config_entry-sr.hh
+ repository_config_entry-sr.hh \
+ use_conf.hh \
+ keywords_conf.hh \
+ licenses_conf.hh \
+ bashable_conf.hh \
+ package_mask_conf.hh \
+ mirrors_conf.hh
EXTRA_DIST = \
paludis_environment_TEST_setup.sh \
diff --git a/paludis/environments/paludis/bashable_conf.cc b/paludis/environments/paludis/bashable_conf.cc
new file mode 100644
index 0000000..89c6143
--- /dev/null
+++ b/paludis/environments/paludis/bashable_conf.cc
@@ -0,0 +1,57 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 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
+ * 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 "bashable_conf.hh"
+#include <paludis/config_file.hh>
+#include <paludis/util/fs_entry.hh>
+#include <paludis/util/pstream.hh>
+#include <paludis/util/is_file_with_extension.hh>
+#include <paludis/util/log.hh>
+
+using namespace paludis;
+
+std::tr1::shared_ptr<LineConfigFile>
+paludis::make_bashable_conf(const FSEntry & f)
+{
+ Context context("When making a config file out of '" + stringify(f) + "':");
+
+ std::tr1::shared_ptr<LineConfigFile> result;
+
+ if (is_file_with_extension(f, ".bash", IsFileWithOptions()))
+ {
+ Command cmd(Command("bash '" + stringify(f) + "'")
+ .with_setenv("PALUDIS_LOG_LEVEL", stringify(Log::get_instance()->log_level()))
+ .with_setenv("PALUDIS_EBUILD_DIR", getenv_with_default("PALUDIS_EBUILD_DIR", LIBEXECDIR "/paludis"))
+ .with_stderr_prefix(f.basename() + "> "));
+ PStream s(cmd);
+ result.reset(new LineConfigFile(s, LineConfigFileOptions()));
+
+ if (s.exit_status() != 0)
+ {
+ Log::get_instance()->message(ll_warning, lc_context, "Script '" + stringify(f)
+ + "' returned non-zero exit status '" + stringify(s.exit_status()) + "'");
+ result.reset();
+ }
+ }
+ else
+ result.reset(new LineConfigFile(f, LineConfigFileOptions()));
+
+ return result;
+}
+
diff --git a/paludis/environments/paludis/bashable_conf.hh b/paludis/environments/paludis/bashable_conf.hh
new file mode 100644
index 0000000..f17730c
--- /dev/null
+++ b/paludis/environments/paludis/bashable_conf.hh
@@ -0,0 +1,33 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 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
+ * 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_BASHABLE_CONF_HH
+#define PALUDIS_GUARD_PALUDIS_ENVIRONMENTS_PALUDIS_BASHABLE_CONF_HH 1
+
+#include <tr1/memory>
+
+namespace paludis
+{
+ class LineConfigFile;
+ class FSEntry;
+
+ std::tr1::shared_ptr<LineConfigFile> make_bashable_conf(const FSEntry &);
+}
+
+#endif
diff --git a/paludis/environments/paludis/keywords_conf.cc b/paludis/environments/paludis/keywords_conf.cc
new file mode 100644
index 0000000..87850a3
--- /dev/null
+++ b/paludis/environments/paludis/keywords_conf.cc
@@ -0,0 +1,224 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 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
+ * 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 "keywords_conf.hh"
+#include <paludis/environment.hh>
+#include <paludis/package_database_entry.hh>
+#include <paludis/hashed_containers.hh>
+#include <paludis/name.hh>
+#include <paludis/dep_spec.hh>
+#include <paludis/match_package.hh>
+#include <paludis/environments/paludis/paludis_environment.hh>
+#include <paludis/environments/paludis/bashable_conf.hh>
+#include <paludis/util/log.hh>
+#include <paludis/util/tokeniser.hh>
+#include <list>
+#include <vector>
+#include <map>
+
+using namespace paludis;
+
+typedef std::list<KeywordName> KeywordsList;
+typedef std::map<std::tr1::shared_ptr<const PackageDepSpec>, KeywordsList> PDSToKeywordsList;
+typedef std::pair<std::tr1::shared_ptr<const DepSpec>, KeywordsList> SetNameEntry;
+
+typedef MakeHashedMap<QualifiedPackageName, PDSToKeywordsList>::Type SpecificMap;
+typedef PDSToKeywordsList UnspecificMap;
+typedef MakeHashedMap<SetName, SetNameEntry>::Type NamedSetMap;
+
+namespace paludis
+{
+ template<>
+ struct Implementation<KeywordsConf>
+ {
+ const PaludisEnvironment * const env;
+
+ SpecificMap qualified;
+ UnspecificMap unqualified;
+ mutable NamedSetMap set;
+
+ Implementation(const PaludisEnvironment * const e) :
+ env(e)
+ {
+ }
+ };
+}
+
+KeywordsConf::KeywordsConf(const PaludisEnvironment * const e) :
+ PrivateImplementationPattern<KeywordsConf>(new Implementation<KeywordsConf>(e))
+{
+}
+
+KeywordsConf::~KeywordsConf()
+{
+}
+
+void
+KeywordsConf::add(const FSEntry & filename)
+{
+ Context context("When adding source '" + stringify(filename) + "' as a keywords file:");
+
+ std::tr1::shared_ptr<LineConfigFile> f(make_bashable_conf(filename));
+ if (! f)
+ return;
+
+ for (LineConfigFile::Iterator line(f->begin()), line_end(f->end()) ;
+ line != line_end ; ++line)
+ {
+ std::vector<std::string> tokens;
+ WhitespaceTokeniser::get_instance()->tokenise(*line, std::back_inserter(tokens));
+
+ if (tokens.size() < 2)
+ continue;
+
+ if ("*" == tokens.at(0))
+ {
+ Log::get_instance()->message(ll_warning, lc_context) << "Use of token '*' is deprecated, use '*/*' instead";
+ tokens.at(0) = "*/*";
+ }
+
+ if (std::string::npos == tokens.at(0).find("/"))
+ {
+ NamedSetMap::iterator i(_imp->set.insert(std::make_pair(SetName(tokens.at(0)), std::make_pair(
+ std::tr1::shared_ptr<DepSpec>(), KeywordsList()))).first);
+
+ for (std::vector<std::string>::const_iterator t(next(tokens.begin())), t_end(tokens.end()) ;
+ t != t_end ; ++t)
+ i->second.second.push_back(KeywordName(*t));
+ }
+ else
+ {
+ std::tr1::shared_ptr<PackageDepSpec> d(new PackageDepSpec(tokens.at(0), pds_pm_unspecific));
+ if (d->package_ptr())
+ {
+ KeywordsList & k(_imp->qualified[*d->package_ptr()][d]);
+ for (std::vector<std::string>::const_iterator t(next(tokens.begin())), t_end(tokens.end()) ;
+ t != t_end ; ++t)
+ k.push_back(KeywordName(*t));
+ }
+ else
+ {
+ KeywordsList & k(_imp->unqualified[d]);
+ for (std::vector<std::string>::const_iterator t(next(tokens.begin())), t_end(tokens.end()) ;
+ t != t_end ; ++t)
+ k.push_back(KeywordName(*t));
+ }
+ }
+ }
+}
+
+bool
+KeywordsConf::query(std::tr1::shared_ptr<const KeywordNameCollection> k, const PackageDatabaseEntry & e) const
+{
+ static const KeywordName star_keyword("*");
+ static const KeywordName minus_star_keyword("*");
+
+ if (k->end() != k->find(star_keyword))
+ return true;
+
+ /* highest priority: specific */
+ bool break_when_done(false);
+ {
+ SpecificMap::const_iterator i(_imp->qualified.find(e.name));
+ if (i != _imp->qualified.end())
+ {
+ for (PDSToKeywordsList::const_iterator j(i->second.begin()), j_end(i->second.end()) ;
+ j != j_end ; ++j)
+ {
+ if (! match_package(*_imp->env, *j->first, e))
+ continue;
+
+ for (KeywordsList::const_iterator l(j->second.begin()), l_end(j->second.end()) ;
+ l != l_end ; ++l)
+ {
+ if (k->end() != k->find(*l))
+ return true;
+
+ if (*l == star_keyword)
+ return true;
+
+ if (*l == minus_star_keyword)
+ break_when_done = true;
+ }
+ }
+ }
+ }
+
+ if (break_when_done)
+ return false;
+
+ /* next: named sets */
+ {
+ for (NamedSetMap::iterator i(_imp->set.begin()), i_end(_imp->set.end()) ;
+ i != i_end ; ++i)
+ {
+ if (! i->second.first)
+ {
+ i->second.first = _imp->env->set(i->first);
+ if (! i->second.first)
+ {
+ Log::get_instance()->message(ll_warning, lc_no_context) << "Set name '"
+ << i->first << "' does not exist";
+ i->second.first.reset(new AllDepSpec);
+ }
+ }
+
+ if (! match_package_in_heirarchy(*_imp->env, *i->second.first, e))
+ continue;
+
+ for (KeywordsList::const_iterator l(i->second.second.begin()), l_end(i->second.second.end()) ;
+ l != l_end ; ++l)
+ {
+ if (k->end() != k->find(*l))
+ return true;
+
+ if (*l == star_keyword)
+ return true;
+
+ if (*l == minus_star_keyword)
+ break_when_done = true;
+ }
+ }
+ }
+
+
+ if (break_when_done)
+ return false;
+
+ /* last: unspecific */
+ for (PDSToKeywordsList::const_iterator j(_imp->unqualified.begin()), j_end(_imp->unqualified.end()) ;
+ j != j_end ; ++j)
+ {
+ if (! match_package(*_imp->env, *j->first, e))
+ continue;
+
+ for (KeywordsList::const_iterator l(j->second.begin()), l_end(j->second.end()) ;
+ l != l_end ; ++l)
+ {
+ if (k->end() != k->find(*l))
+ return true;
+
+ if (*l == star_keyword)
+ return true;
+ }
+ }
+
+ return false;
+}
+
diff --git a/paludis/environments/paludis/keywords_conf.hh b/paludis/environments/paludis/keywords_conf.hh
new file mode 100644
index 0000000..0274e78
--- /dev/null
+++ b/paludis/environments/paludis/keywords_conf.hh
@@ -0,0 +1,47 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 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
+ * 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_KEYWORDS_CONF_HH
+#define PALUDIS_GUARD_PALUDIS_ENVIRONMENTS_PALUDIS_KEYWORDS_CONF_HH 1
+
+#include <paludis/util/private_implementation_pattern.hh>
+#include <paludis/util/instantiation_policy.hh>
+#include <paludis/config_file.hh>
+#include <paludis/name.hh>
+
+namespace paludis
+{
+ class PaludisEnvironment;
+ class PackageDatabaseEntry;
+
+ class KeywordsConf :
+ private PrivateImplementationPattern<KeywordsConf>,
+ private InstantiationPolicy<KeywordsConf, instantiation_method::NonCopyableTag>
+ {
+ public:
+ KeywordsConf(const PaludisEnvironment * const);
+ ~KeywordsConf();
+
+ void add(const FSEntry &);
+
+ bool query(std::tr1::shared_ptr<const KeywordNameCollection>, const PackageDatabaseEntry &) const;
+ };
+}
+
+#endif
diff --git a/paludis/environments/paludis/licenses_conf.cc b/paludis/environments/paludis/licenses_conf.cc
new file mode 100644
index 0000000..c8761f8
--- /dev/null
+++ b/paludis/environments/paludis/licenses_conf.cc
@@ -0,0 +1,219 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 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
+ * 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 "licenses_conf.hh"
+#include <paludis/environment.hh>
+#include <paludis/package_database_entry.hh>
+#include <paludis/hashed_containers.hh>
+#include <paludis/name.hh>
+#include <paludis/dep_spec.hh>
+#include <paludis/match_package.hh>
+#include <paludis/environments/paludis/paludis_environment.hh>
+#include <paludis/environments/paludis/bashable_conf.hh>
+#include <paludis/util/log.hh>
+#include <paludis/util/tokeniser.hh>
+#include <list>
+#include <vector>
+#include <map>
+
+using namespace paludis;
+
+typedef std::list<std::string> LicensesList;
+typedef std::map<std::tr1::shared_ptr<const PackageDepSpec>, LicensesList> PDSToLicensesList;
+typedef std::pair<std::tr1::shared_ptr<const DepSpec>, LicensesList> SetNameEntry;
+
+typedef MakeHashedMap<QualifiedPackageName, PDSToLicensesList>::Type SpecificMap;
+typedef PDSToLicensesList UnspecificMap;
+typedef MakeHashedMap<SetName, SetNameEntry>::Type NamedSetMap;
+
+namespace paludis
+{
+ template<>
+ struct Implementation<LicensesConf>
+ {
+ const PaludisEnvironment * const env;
+
+ SpecificMap qualified;
+ UnspecificMap unqualified;
+ mutable NamedSetMap set;
+
+ Implementation(const PaludisEnvironment * const e) :
+ env(e)
+ {
+ }
+ };
+}
+
+LicensesConf::LicensesConf(const PaludisEnvironment * const e) :
+ PrivateImplementationPattern<LicensesConf>(new Implementation<LicensesConf>(e))
+{
+}
+
+LicensesConf::~LicensesConf()
+{
+}
+
+void
+LicensesConf::add(const FSEntry & filename)
+{
+ Context context("When adding source '" + stringify(filename) + "' as a licenses file:");
+
+ std::tr1::shared_ptr<LineConfigFile> f(make_bashable_conf(filename));
+ if (! f)
+ return;
+
+ for (LineConfigFile::Iterator line(f->begin()), line_end(f->end()) ;
+ line != line_end ; ++line)
+ {
+ std::vector<std::string> tokens;
+ WhitespaceTokeniser::get_instance()->tokenise(*line, std::back_inserter(tokens));
+
+ if (tokens.size() < 2)
+ continue;
+
+ if ("*" == tokens.at(0))
+ {
+ Log::get_instance()->message(ll_warning, lc_context) << "Use of token '*' is deprecated, use '*/*' instead";
+ tokens.at(0) = "*/*";
+ }
+
+ if (std::string::npos == tokens.at(0).find("/"))
+ {
+ NamedSetMap::iterator i(_imp->set.insert(std::make_pair(SetName(tokens.at(0)), std::make_pair(
+ std::tr1::shared_ptr<DepSpec>(), LicensesList()))).first);
+
+ for (std::vector<std::string>::const_iterator t(next(tokens.begin())), t_end(tokens.end()) ;
+ t != t_end ; ++t)
+ i->second.second.push_back(*t);
+ }
+ else
+ {
+ std::tr1::shared_ptr<PackageDepSpec> d(new PackageDepSpec(tokens.at(0), pds_pm_unspecific));
+ if (d->package_ptr())
+ {
+ LicensesList & k(_imp->qualified[*d->package_ptr()][d]);
+ for (std::vector<std::string>::const_iterator t(next(tokens.begin())), t_end(tokens.end()) ;
+ t != t_end ; ++t)
+ k.push_back(*t);
+ }
+ else
+ {
+ LicensesList & k(_imp->unqualified[d]);
+ for (std::vector<std::string>::const_iterator t(next(tokens.begin())), t_end(tokens.end()) ;
+ t != t_end ; ++t)
+ k.push_back(*t);
+ }
+ }
+ }
+}
+
+bool
+LicensesConf::query(const std::string & t, const PackageDatabaseEntry & e) const
+{
+ /* highest priority: specific */
+ bool break_when_done(false);
+ {
+ SpecificMap::const_iterator i(_imp->qualified.find(e.name));
+ if (i != _imp->qualified.end())
+ {
+ for (PDSToLicensesList::const_iterator j(i->second.begin()), j_end(i->second.end()) ;
+ j != j_end ; ++j)
+ {
+ if (! match_package(*_imp->env, *j->first, e))
+ continue;
+
+ for (LicensesList::const_iterator l(j->second.begin()), l_end(j->second.end()) ;
+ l != l_end ; ++l)
+ {
+ if (*l == t)
+ return true;
+
+ if (*l == "*")
+ return true;
+
+ if (*l == "-*")
+ break_when_done = true;
+ }
+ }
+ }
+ }
+
+ if (break_when_done)
+ return false;
+
+ /* next: named sets */
+ {
+ for (NamedSetMap::iterator i(_imp->set.begin()), i_end(_imp->set.end()) ;
+ i != i_end ; ++i)
+ {
+ if (! i->second.first)
+ {
+ i->second.first = _imp->env->set(i->first);
+ if (! i->second.first)
+ {
+ Log::get_instance()->message(ll_warning, lc_no_context) << "Set name '"
+ << i->first << "' does not exist";
+ i->second.first.reset(new AllDepSpec);
+ }
+ }
+
+ if (! match_package_in_heirarchy(*_imp->env, *i->second.first, e))
+ continue;
+
+ for (LicensesList::const_iterator l(i->second.second.begin()), l_end(i->second.second.end()) ;
+ l != l_end ; ++l)
+ {
+ if (*l == t)
+ return true;
+
+ if (*l == "*")
+ return true;
+
+ if (*l == "-*")
+ break_when_done = true;
+ }
+ }
+ }
+
+
+ if (break_when_done)
+ return false;
+
+ /* last: unspecific */
+ for (PDSToLicensesList::const_iterator j(_imp->unqualified.begin()), j_end(_imp->unqualified.end()) ;
+ j != j_end ; ++j)
+ {
+ if (! match_package(*_imp->env, *j->first, e))
+ continue;
+
+ for (LicensesList::const_iterator l(j->second.begin()), l_end(j->second.end()) ;
+ l != l_end ; ++l)
+ {
+ if (*l == t)
+ return true;
+
+ if (*l == "*")
+ return true;
+ }
+ }
+
+ return false;
+}
+
+
diff --git a/paludis/environments/paludis/licenses_conf.hh b/paludis/environments/paludis/licenses_conf.hh
new file mode 100644
index 0000000..dc6ab24
--- /dev/null
+++ b/paludis/environments/paludis/licenses_conf.hh
@@ -0,0 +1,47 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 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
+ * 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_PALUDIS_ENVIRONMENTS_PALUDIS_LICENSES_CONF_HH
+#define PALUDIS_GUARD_PALUDIS_PALUDIS_ENVIRONMENTS_PALUDIS_LICENSES_CONF_HH 1
+
+#include <paludis/util/private_implementation_pattern.hh>
+#include <paludis/util/instantiation_policy.hh>
+#include <paludis/config_file.hh>
+#include <paludis/name.hh>
+
+namespace paludis
+{
+ class PaludisEnvironment;
+ class PackageDatabaseEntry;
+
+ class LicensesConf :
+ private PrivateImplementationPattern<LicensesConf>,
+ private InstantiationPolicy<LicensesConf, instantiation_method::NonCopyableTag>
+ {
+ public:
+ LicensesConf(const PaludisEnvironment * const);
+ ~LicensesConf();
+
+ void add(const FSEntry &);
+
+ bool query(const std::string &, const PackageDatabaseEntry &) const;
+ };
+}
+
+#endif
diff --git a/paludis/environments/paludis/mirrors_conf.cc b/paludis/environments/paludis/mirrors_conf.cc
new file mode 100644
index 0000000..2b9eca4
--- /dev/null
+++ b/paludis/environments/paludis/mirrors_conf.cc
@@ -0,0 +1,93 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 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
+ * 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 "mirrors_conf.hh"
+#include <paludis/environment.hh>
+#include <paludis/package_database_entry.hh>
+#include <paludis/hashed_containers.hh>
+#include <paludis/name.hh>
+#include <paludis/environments/paludis/paludis_environment.hh>
+#include <paludis/environments/paludis/bashable_conf.hh>
+#include <paludis/util/log.hh>
+#include <paludis/util/tokeniser.hh>
+#include <paludis/util/collection_concrete.hh>
+#include <vector>
+
+using namespace paludis;
+
+typedef MakeHashedMultiMap<std::string, std::string>::Type Mirrors;
+
+namespace paludis
+{
+ template<>
+ struct Implementation<MirrorsConf>
+ {
+ const PaludisEnvironment * const env;
+ Mirrors mirrors;
+
+ Implementation(const PaludisEnvironment * const e) :
+ env(e)
+ {
+ }
+ };
+}
+
+MirrorsConf::MirrorsConf(const PaludisEnvironment * const e) :
+ PrivateImplementationPattern<MirrorsConf>(new Implementation<MirrorsConf>(e))
+{
+}
+
+MirrorsConf::~MirrorsConf()
+{
+}
+
+void
+MirrorsConf::add(const FSEntry & filename)
+{
+ Context context("When adding source '" + stringify(filename) + "' as a mirrors file:");
+
+ std::tr1::shared_ptr<LineConfigFile> f(make_bashable_conf(filename));
+ if (! f)
+ return;
+
+ for (LineConfigFile::Iterator line(f->begin()), line_end(f->end()) ;
+ line != line_end ; ++line)
+ {
+ std::vector<std::string> tokens;
+ WhitespaceTokeniser::get_instance()->tokenise(*line, std::back_inserter(tokens));
+
+ if (tokens.size() < 2)
+ continue;
+
+ for (std::vector<std::string>::const_iterator t(next(tokens.begin())), t_end(tokens.end()) ;
+ t != t_end ; ++t)
+ _imp->mirrors.insert(std::make_pair(tokens.at(0), *t));
+ }
+}
+
+std::tr1::shared_ptr<const MirrorsCollection>
+MirrorsConf::query(const std::string & m) const
+{
+ std::tr1::shared_ptr<MirrorsCollection> result(new MirrorsCollection::Concrete);
+ std::pair<Mirrors::const_iterator, Mirrors::const_iterator> p(_imp->mirrors.equal_range(m));
+ std::copy(p.first, p.second, transform_inserter(result->inserter(), SelectSecond<std::string, std::string>()));
+ return result;
+}
+
+
diff --git a/paludis/environments/paludis/mirrors_conf.hh b/paludis/environments/paludis/mirrors_conf.hh
new file mode 100644
index 0000000..0d9dcb7
--- /dev/null
+++ b/paludis/environments/paludis/mirrors_conf.hh
@@ -0,0 +1,49 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 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
+ * 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_MIRRORS_CONF_HH
+#define PALUDIS_GUARD_PALUDIS_ENVIRONMENTS_PALUDIS_MIRRORS_CONF_HH 1
+
+#include <paludis/util/private_implementation_pattern.hh>
+#include <paludis/util/instantiation_policy.hh>
+#include <paludis/config_file.hh>
+#include <paludis/environment.hh>
+#include <paludis/name.hh>
+
+namespace paludis
+{
+ class PaludisEnvironment;
+ class PackageDatabaseEntry;
+
+ class MirrorsConf :
+ private PrivateImplementationPattern<MirrorsConf>,
+ private InstantiationPolicy<MirrorsConf, instantiation_method::NonCopyableTag>
+ {
+ public:
+ MirrorsConf(const PaludisEnvironment * const);
+ ~MirrorsConf();
+
+ void add(const FSEntry &);
+
+ std::tr1::shared_ptr<const MirrorsCollection> query(const std::string &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+ };
+}
+
+#endif
diff --git a/paludis/environments/paludis/package_mask_conf.cc b/paludis/environments/paludis/package_mask_conf.cc
new file mode 100644
index 0000000..6216b8f
--- /dev/null
+++ b/paludis/environments/paludis/package_mask_conf.cc
@@ -0,0 +1,84 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 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
+ * 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 "package_mask_conf.hh"
+#include <paludis/environment.hh>
+#include <paludis/package_database_entry.hh>
+#include <paludis/hashed_containers.hh>
+#include <paludis/name.hh>
+#include <paludis/dep_spec.hh>
+#include <paludis/match_package.hh>
+#include <paludis/environments/paludis/paludis_environment.hh>
+#include <paludis/environments/paludis/bashable_conf.hh>
+#include <paludis/util/log.hh>
+#include <paludis/util/tokeniser.hh>
+#include <list>
+#include <algorithm>
+#include <tr1/functional>
+
+using namespace paludis;
+
+namespace paludis
+{
+ template<>
+ struct Implementation<PackageMaskConf>
+ {
+ const PaludisEnvironment * const env;
+ std::list<std::tr1::shared_ptr<const PackageDepSpec> > masks;
+
+ Implementation(const PaludisEnvironment * const e) :
+ env(e)
+ {
+ }
+ };
+}
+
+PackageMaskConf::PackageMaskConf(const PaludisEnvironment * const e) :
+ PrivateImplementationPattern<PackageMaskConf>(new Implementation<PackageMaskConf>(e))
+{
+}
+
+PackageMaskConf::~PackageMaskConf()
+{
+}
+
+void
+PackageMaskConf::add(const FSEntry & filename)
+{
+ Context context("When adding source '" + stringify(filename) + "' as a package mask or unmask file:");
+
+ std::tr1::shared_ptr<LineConfigFile> f(make_bashable_conf(filename));
+ if (! f)
+ return;
+
+ for (LineConfigFile::Iterator line(f->begin()), line_end(f->end()) ;
+ line != line_end ; ++line)
+ _imp->masks.push_back(std::tr1::shared_ptr<PackageDepSpec>(new PackageDepSpec(*line, pds_pm_unspecific)));
+}
+
+bool
+PackageMaskConf::query(const PackageDatabaseEntry & e) const
+{
+ using namespace std::tr1::placeholders;
+ return indirect_iterator(_imp->masks.end()) != std::find_if(
+ indirect_iterator(_imp->masks.begin()),
+ indirect_iterator(_imp->masks.end()),
+ std::tr1::bind(&match_package, std::tr1::ref(*_imp->env), _1, e));
+}
+
diff --git a/paludis/environments/paludis/package_mask_conf.hh b/paludis/environments/paludis/package_mask_conf.hh
new file mode 100644
index 0000000..926a1e6
--- /dev/null
+++ b/paludis/environments/paludis/package_mask_conf.hh
@@ -0,0 +1,48 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 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
+ * 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_PACKAGE_MASK_CONF_HH
+#define PALUDIS_GUARD_PALUDIS_ENVIRONMENTS_PALUDIS_PACKAGE_MASK_CONF_HH 1
+
+#include <paludis/util/private_implementation_pattern.hh>
+#include <paludis/util/instantiation_policy.hh>
+#include <paludis/config_file.hh>
+#include <paludis/name.hh>
+
+namespace paludis
+{
+ class PaludisEnvironment;
+ class PackageDatabaseEntry;
+
+ class PackageMaskConf :
+ private PrivateImplementationPattern<PackageMaskConf>,
+ private InstantiationPolicy<PackageMaskConf, instantiation_method::NonCopyableTag>
+ {
+ public:
+ PackageMaskConf(const PaludisEnvironment * const);
+ ~PackageMaskConf();
+
+ void add(const FSEntry &);
+
+ bool query(const PackageDatabaseEntry &) const;
+ };
+}
+
+#endif
+
diff --git a/paludis/environments/paludis/paludis_config.cc b/paludis/environments/paludis/paludis_config.cc
index 5405d10..c2d5291 100644
--- a/paludis/environments/paludis/paludis_config.cc
+++ b/paludis/environments/paludis/paludis_config.cc
@@ -19,6 +19,12 @@
#include <paludis/environments/paludis/paludis_config.hh>
#include <paludis/environments/paludis/paludis_environment.hh>
+#include <paludis/environments/paludis/keywords_conf.hh>
+#include <paludis/environments/paludis/use_conf.hh>
+#include <paludis/environments/paludis/mirrors_conf.hh>
+#include <paludis/environments/paludis/licenses_conf.hh>
+#include <paludis/environments/paludis/package_mask_conf.hh>
+
#include <paludis/config_file.hh>
#include <paludis/util/collection_concrete.hh>
#include <paludis/util/compare.hh>
@@ -72,57 +78,16 @@ namespace paludis
std::string paludis_command;
std::string root;
std::string config_dir;
- std::string bashrc_files;
-
- mutable bool sets_expanded;
+ std::tr1::shared_ptr<FSEntryCollection> bashrc_files;
std::list<RepositoryConfigEntry> repos;
- std::map<QualifiedPackageName, std::vector<
- std::pair<std::tr1::shared_ptr<const PackageDepSpec>, KeywordName> > > keywords;
-
- const std::vector<std::pair<std::tr1::shared_ptr<const PackageDepSpec>, KeywordName> > empty_keywords;
-
- std::vector<KeywordName> default_keywords;
-
- mutable std::vector<SetKeywordConfigEntry> set_keywords;
-
- std::map<QualifiedPackageName, std::vector<
- std::pair<std::tr1::shared_ptr<const PackageDepSpec>, std::string> > > licenses;
-
- const std::vector<std::pair<std::tr1::shared_ptr<const PackageDepSpec>, std::string> > empty_licenses;
-
- std::vector<std::string> default_licenses;
-
- mutable std::vector<SetLicenseConfigEntry> set_licenses;
-
- std::map<QualifiedPackageName, std::vector<std::tr1::shared_ptr<const PackageDepSpec> > > user_masks;
-
- std::map<QualifiedPackageName, std::vector<std::tr1::shared_ptr<const PackageDepSpec> > > user_unmasks;
-
- std::vector<std::tr1::shared_ptr<const PackageDepSpec> > empty_masks;
-
- mutable std::vector<SetMaskConfigEntry> set_masks;
- mutable std::vector<SetMaskConfigEntry> set_unmasks;
-
- std::map<QualifiedPackageName, std::vector<UseConfigEntry> > use;
-
- mutable std::vector<SetUseConfigEntry> set_use;
-
- mutable std::vector<SetUseConfigMinusStarEntry> set_use_prefixes_that_have_minus_star;
-
- std::vector<std::pair<std::tr1::shared_ptr<const PackageDepSpec>, std::string> > empty_use_prefixes;
-
- std::map<QualifiedPackageName, std::vector<std::pair<std::tr1::shared_ptr<const PackageDepSpec>, std::string> > >
- use_prefixes_that_have_minus_star;
-
- std::vector<UseConfigEntry> empty_use;
-
- std::vector<std::pair<UseFlagName, UseFlagState> > default_use;
-
- std::vector<std::string> default_use_prefixes_that_have_minus_star;
-
- std::multimap<std::string, std::string> mirrors;
+ std::tr1::shared_ptr<KeywordsConf> keywords_conf;
+ std::tr1::shared_ptr<UseConf> use_conf;
+ std::tr1::shared_ptr<LicensesConf> licenses_conf;
+ std::tr1::shared_ptr<PackageMaskConf> package_mask_conf;
+ std::tr1::shared_ptr<PackageMaskConf> package_unmask_conf;
+ std::tr1::shared_ptr<MirrorsConf> mirrors_conf;
mutable std::tr1::shared_ptr<uid_t> reduced_uid;
mutable std::tr1::shared_ptr<gid_t> reduced_gid;
@@ -133,7 +98,6 @@ namespace paludis
Implementation(PaludisEnvironment * const);
- void need_sets_expanded() const;
void need_environment_conf() const;
};
@@ -141,7 +105,13 @@ namespace paludis
env(e),
paludis_command("paludis"),
config_dir("(unset)"),
- sets_expanded(false),
+ bashrc_files(new FSEntryCollection::Concrete),
+ keywords_conf(new KeywordsConf(e)),
+ use_conf(new UseConf(e)),
+ licenses_conf(new LicensesConf(e)),
+ package_mask_conf(new PackageMaskConf(e)),
+ package_unmask_conf(new PackageMaskConf(e)),
+ mirrors_conf(new MirrorsConf(e)),
has_environment_conf(false),
accept_breaks_portage(true),
reduced_username(getenv_with_default("PALUDIS_REDUCED_USERNAME", "paludisbuild"))
@@ -197,113 +167,6 @@ namespace paludis
has_environment_conf = true;
}
-
- void
- Implementation<PaludisConfig>::need_sets_expanded() const
- {
- if (sets_expanded)
- return;
-
- {
- Context context("When expanding set names from use.conf:");
-
- for (std::vector<SetUseConfigEntry>::iterator s(set_use.begin()), s_end(set_use.end()) ;
- s != s_end ; ++s)
- if (! s->dep_spec)
- {
- s->dep_spec = env->package_set(*s->set_name);
- if (! s->dep_spec)
- {
- Log::get_instance()->message(ll_warning, lc_context, "Set '" +
- stringify(*s->set_name) + "' doesn't exist");
- s->dep_spec.reset(new AllDepSpec);
- }
- }
-
- for (std::vector<SetUseConfigMinusStarEntry>::iterator s(set_use_prefixes_that_have_minus_star.begin()),
- s_end(set_use_prefixes_that_have_minus_star.end()) ; s != s_end ; ++s)
- if (! s->dep_spec)
- {
- s->dep_spec = env->package_set(*s->set_name);
- if (! s->dep_spec)
- {
- Log::get_instance()->message(ll_warning, lc_context, "Set '" +
- stringify(*s->set_name) + "' doesn't exist");
- s->dep_spec.reset(new AllDepSpec);
- }
- }
- }
-
- {
- Context context("When expanding set names from keywords.conf:");
-
- for (std::vector<SetKeywordConfigEntry>::iterator s(set_keywords.begin()), s_end(set_keywords.end()) ;
- s != s_end ; ++s)
- if (! s->dep_spec)
- {
- s->dep_spec = env->package_set(*s->set_name);
- if (! s->dep_spec)
- {
- Log::get_instance()->message(ll_warning, lc_context, "Set '" +
- stringify(*s->set_name) + "' doesn't exist");
- s->dep_spec.reset(new AllDepSpec);
- }
- }
- }
-
- {
- Context context("When expanding set names from licenses.conf:");
-
- for (std::vector<SetLicenseConfigEntry>::iterator s(set_licenses.begin()), s_end(set_licenses.end()) ;
- s != s_end ; ++s)
- if (! s->dep_spec)
- {
- s->dep_spec = env->package_set(*s->set_name);
- if (! s->dep_spec)
- {
- Log::get_instance()->message(ll_warning, lc_context, "Set '" +
- stringify(*s->set_name) + "' doesn't exist");
- s->dep_spec.reset(new AllDepSpec);
- }
- }
- }
-
- {
- Context context("When expanding set names from package_unmask.conf:");
-
- for (std::vector<SetMaskConfigEntry>::iterator s(set_unmasks.begin()), s_end(set_unmasks.end()) ;
- s != s_end ; ++s)
- if (! s->dep_spec)
- {
- s->dep_spec = env->package_set(*s->set_name);
- if (! s->dep_spec)
- {
- Log::get_instance()->message(ll_warning, lc_context, "Set '" +
- stringify(*s->set_name) + "' doesn't exist");
- s->dep_spec.reset(new AllDepSpec);
- }
- }
- }
-
- {
- Context context("When expanding set names from package_mask.conf:");
-
- for (std::vector<SetMaskConfigEntry>::iterator s(set_masks.begin()), s_end(set_masks.end()) ;
- s != s_end ; ++s)
- if (! s->dep_spec)
- {
- s->dep_spec = env->package_set(*s->set_name);
- if (! s->dep_spec)
- {
- Log::get_instance()->message(ll_warning, lc_context, "Set '" +
- stringify(*s->set_name) + "' doesn't exist");
- s->dep_spec.reset(new AllDepSpec);
- }
- }
- }
-
- sets_expanded = true;
- }
}
PaludisConfigError::PaludisConfigError(const std::string & msg) throw () :
@@ -525,66 +388,33 @@ PaludisConfig::PaludisConfig(PaludisEnvironment * const e, const std::string & s
if (! file->is_regular_file())
continue;
- std::tr1::shared_ptr<LineConfigFile> f;
- if (is_file_with_extension(*file, ".bash", IsFileWithOptions()))
- {
- Command cmd(Command("bash '" + stringify(*file) + "'")
- .with_setenv("PALUDIS_LOG_LEVEL", stringify(Log::get_instance()->log_level()))
- .with_setenv("PALUDIS_EBUILD_DIR", getenv_with_default("PALUDIS_EBUILD_DIR", LIBEXECDIR "/paludis"))
- .with_stderr_prefix(file->basename() + "> "));
- PStream s(cmd);
- f.reset(new LineConfigFile(s, LineConfigFileOptions()));
+ _imp->keywords_conf->add(*file);
+ }
+ }
- if (s.exit_status() != 0)
- {
- Log::get_instance()->message(ll_warning, lc_context, "Script '" + stringify(*file)
- + "' returned non-zero exit status '" + stringify(s.exit_status()) + "'");
- f.reset();
- }
- }
- else
- f.reset(new LineConfigFile(*file, LineConfigFileOptions()));
+ /* use */
+ {
+ std::list<FSEntry> files;
+ files.push_back(local_config_dir / "use.conf");
+ files.push_back(local_config_dir / "use.bash");
+ if ((local_config_dir / "use.conf.d").exists())
+ {
+ std::copy(DirIterator(local_config_dir / "use.conf.d"), DirIterator(),
+ filter_inserter(std::back_inserter(files), std::tr1::bind(&is_file_with_extension, _1, ".conf", IsFileWithOptions())));
+ std::copy(DirIterator(local_config_dir / "use.conf.d"), DirIterator(),
+ filter_inserter(std::back_inserter(files), std::tr1::bind(&is_file_with_extension, _1, ".bash", IsFileWithOptions())));
+ }
+
+ for (std::list<FSEntry>::const_iterator file(files.begin()), file_end(files.end()) ;
+ file != file_end ; ++file)
+ {
+ Context local_context("When reading use file '" + stringify(*file) + "':");
- if (! f)
+ if (! file->is_regular_file())
continue;
- for (LineConfigFile::Iterator line(f->begin()), line_end(f->end()) ;
- line != line_end ; ++line)
- {
- std::vector<std::string> tokens;
- WhitespaceTokeniser::get_instance()->tokenise(*line, std::back_inserter(tokens));
- if (tokens.empty())
- continue;
- if ("*" == tokens.at(0))
- std::copy(next(tokens.begin()), tokens.end(),
- create_inserter<KeywordName>(std::back_inserter(_imp->default_keywords)));
- else if (std::string::npos == tokens.at(0).find('/'))
- {
- for (std::vector<std::string>::const_iterator t(next(tokens.begin())), t_end(tokens.end()) ;
- t != t_end ; ++t)
- _imp->set_keywords.push_back(SetKeywordConfigEntry(
- std::tr1::shared_ptr<SetName>(new SetName(tokens.at(0))),
- std::tr1::shared_ptr<DepSpec>(), KeywordName(*t)));
- }
- else
- {
- std::tr1::shared_ptr<const PackageDepSpec> a(new PackageDepSpec(tokens.at(0), pds_pm_unspecific));
- for (std::vector<std::string>::const_iterator t(next(tokens.begin())), t_end(tokens.end()) ;
- t != t_end ; ++t)
- {
- if (a->package_ptr())
- _imp->keywords[*a->package_ptr()].push_back(std::make_pair(a, *t));
- else
- _imp->set_keywords.push_back(SetKeywordConfigEntry(
- std::tr1::shared_ptr<const SetName>(), a, KeywordName(*t)));
- }
- }
- }
+ _imp->use_conf->add(*file);
}
-
- if (_imp->default_keywords.empty())
- throw PaludisConfigError("No default keywords specified (a keywords.conf file should "
- "contain an entry in the form '* keyword')");
}
/* licenses */
@@ -608,64 +438,8 @@ PaludisConfig::PaludisConfig(PaludisEnvironment * const e, const std::string & s
if (! file->is_regular_file())
continue;
- std::tr1::shared_ptr<LineConfigFile> f;
- if (is_file_with_extension(*file, ".bash", IsFileWithOptions()))
- {
- Command cmd(Command("bash '" + stringify(*file) + "'")
- .with_setenv("PALUDIS_LOG_LEVEL", stringify(Log::get_instance()->log_level()))
- .with_setenv("PALUDIS_EBUILD_DIR", getenv_with_default("PALUDIS_EBUILD_DIR", LIBEXECDIR "/paludis"))
- .with_stderr_prefix(file->basename() + "> "));
- PStream s(cmd);
- f.reset(new LineConfigFile(s, LineConfigFileOptions()));
-
- if (s.exit_status() != 0)
- {
- Log::get_instance()->message(ll_warning, lc_context, "Script '" + stringify(*file)
- + "' returned non-zero exit status '" + stringify(s.exit_status()) + "'");
- f.reset();
- }
- }
- else
- f.reset(new LineConfigFile(*file, LineConfigFileOptions()));
-
- if (! f)
- continue;
-
- for (LineConfigFile::Iterator line(f->begin()), line_end(f->end()) ;
- line != line_end ; ++line)
- {
- std::vector<std::string> tokens;
- WhitespaceTokeniser::get_instance()->tokenise(*line, std::back_inserter(tokens));
- if (tokens.empty())
- continue;
- if ("*" == tokens.at(0))
- std::copy(next(tokens.begin()), tokens.end(), std::back_inserter(_imp->default_licenses));
- else if (std::string::npos == tokens.at(0).find('/'))
- {
- for (std::vector<std::string>::const_iterator t(next(tokens.begin())), t_end(tokens.end()) ;
- t != t_end ; ++t)
- _imp->set_licenses.push_back(SetLicenseConfigEntry(
- std::tr1::shared_ptr<SetName>(new SetName(tokens.at(0))),
- std::tr1::shared_ptr<DepSpec>(), *t));
- }
- else
- {
- std::tr1::shared_ptr<const PackageDepSpec> a(new PackageDepSpec(tokens.at(0), pds_pm_unspecific));
- for (std::vector<std::string>::const_iterator t(next(tokens.begin())), t_end(tokens.end()) ;
- t != t_end ; ++t)
- if (a->package_ptr())
- _imp->licenses[*a->package_ptr()].push_back(std::make_pair(a, *t));
- else
- _imp->set_licenses.push_back(SetLicenseConfigEntry(
- std::tr1::shared_ptr<SetName>(), a, *t));
- }
- }
+ _imp->licenses_conf->add(*file);
}
-
- if (_imp->default_licenses.empty())
- throw PaludisConfigError("No default licenses specified (a licenses.conf file should "
- "contain an entry in the form '* license license', or '* *' if you don't want any "
- "license filtering)");
}
/* user mask */
@@ -689,50 +463,7 @@ PaludisConfig::PaludisConfig(PaludisEnvironment * const e, const std::string & s
if (! file->is_regular_file())
continue;
- std::tr1::shared_ptr<LineConfigFile> f;
-
- if (is_file_with_extension(*file, ".bash", IsFileWithOptions()))
- {
- Command cmd(Command("bash '" + stringify(*file) + "'")
- .with_setenv("PALUDIS_LOG_LEVEL", stringify(Log::get_instance()->log_level()))
- .with_setenv("PALUDIS_EBUILD_DIR", getenv_with_default("PALUDIS_EBUILD_DIR", LIBEXECDIR "/paludis"))
- .with_stderr_prefix(file->basename() + "> "));
- PStream s(cmd);
- f.reset(new LineConfigFile(s, LineConfigFileOptions()));
-
- if (s.exit_status() != 0)
- {
- Log::get_instance()->message(ll_warning, lc_context, "Script '" + stringify(*file)
- + "' returned non-zero exit status '" + stringify(s.exit_status()) + "'");
- f.reset();
- }
- }
- else
- f.reset(new LineConfigFile(*file, LineConfigFileOptions()));
-
- if (! f)
- continue;
-
- for (LineConfigFile::Iterator line(f->begin()), line_end(f->end()) ;
- line != line_end ; ++line)
- {
- if (line->empty())
- continue;
-
- if (std::string::npos == line->find('/'))
- _imp->set_masks.push_back(SetMaskConfigEntry(
- std::tr1::shared_ptr<SetName>(new SetName(*line)),
- std::tr1::shared_ptr<const DepSpec>()));
- else
- {
- std::tr1::shared_ptr<const PackageDepSpec> a(new PackageDepSpec(*line, pds_pm_unspecific));
- if (a->package_ptr())
- _imp->user_masks[*a->package_ptr()].push_back(a);
- else
- _imp->set_masks.push_back(SetMaskConfigEntry(
- std::tr1::shared_ptr<SetName>(), a));
- }
- }
+ _imp->package_mask_conf->add(*file);
}
}
@@ -757,211 +488,8 @@ PaludisConfig::PaludisConfig(PaludisEnvironment * const e, const std::string & s
if (! file->is_regular_file())
continue;
- std::tr1::shared_ptr<LineConfigFile> f;
-
- if (is_file_with_extension(*file, ".bash", IsFileWithOptions()))
- {
- Command cmd(Command("bash '" + stringify(*file) + "'")
- .with_setenv("PALUDIS_LOG_LEVEL", stringify(Log::get_instance()->log_level()))
- .with_setenv("PALUDIS_EBUILD_DIR", getenv_with_default("PALUDIS_EBUILD_DIR", LIBEXECDIR "/paludis"))
- .with_stderr_prefix(file->basename() + "> "));
- PStream s(cmd);
- f.reset(new LineConfigFile(s, LineConfigFileOptions()));
-
- if (s.exit_status() != 0)
- {
- Log::get_instance()->message(ll_warning, lc_context, "Script '" + stringify(*file)
- + "' returned non-zero exit status '" + stringify(s.exit_status()) + "'");
- f.reset();
- }
- }
- else
- f.reset(new LineConfigFile(*file, LineConfigFileOptions()));
-
- if (! f)
- continue;
-
- for (LineConfigFile::Iterator line(f->begin()), line_end(f->end()) ;
- line != line_end ; ++line)
- {
- if (line->empty())
- continue;
-
- if (std::string::npos == line->find('/'))
- _imp->set_unmasks.push_back(SetMaskConfigEntry(
- std::tr1::shared_ptr<SetName>(new SetName(*line)),
- std::tr1::shared_ptr<const DepSpec>()));
- else
- {
- std::tr1::shared_ptr<const PackageDepSpec> a(new PackageDepSpec(*line, pds_pm_unspecific));
- if (a->package_ptr())
- _imp->user_unmasks[*a->package_ptr()].push_back(a);
- else
- _imp->set_unmasks.push_back(SetMaskConfigEntry(
- std::tr1::shared_ptr<SetName>(), a));
- }
- }
- }
- }
-
- /* use */
- {
- std::list<FSEntry> files;
- files.push_back(local_config_dir / "use.conf");
- files.push_back(local_config_dir / "use.bash");
- if ((local_config_dir / "use.conf.d").exists())
- {
- std::copy(DirIterator(local_config_dir / "use.conf.d"), DirIterator(),
- filter_inserter(std::back_inserter(files), std::tr1::bind(&is_file_with_extension, _1, ".conf", IsFileWithOptions())));
- std::copy(DirIterator(local_config_dir / "use.conf.d"), DirIterator(),
- filter_inserter(std::back_inserter(files), std::tr1::bind(&is_file_with_extension, _1, ".bash", IsFileWithOptions())));
- }
-
- for (std::list<FSEntry>::const_iterator file(files.begin()), file_end(files.end()) ;
- file != file_end ; ++file)
- {
- Context local_context("When reading use file '" + stringify(*file) + "':");
-
- if (! file->is_regular_file())
- continue;
-
- std::tr1::shared_ptr<LineConfigFile> f;
-
- if (is_file_with_extension(*file, ".bash", IsFileWithOptions()))
- {
- Command cmd(Command("bash '" + stringify(*file) + "'")
- .with_setenv("PALUDIS_LOG_LEVEL", stringify(Log::get_instance()->log_level()))
- .with_setenv("PALUDIS_EBUILD_DIR", getenv_with_default("PALUDIS_EBUILD_DIR", LIBEXECDIR "/paludis"))
- .with_stderr_prefix(file->basename() + "> "));
- PStream s(cmd);
- f.reset(new LineConfigFile(s, LineConfigFileOptions()));
-
- if (s.exit_status() != 0)
- {
- Log::get_instance()->message(ll_warning, lc_context, "Script '" + stringify(*file)
- + "' returned non-zero exit status '" + stringify(s.exit_status()) + "'");
- f.reset();
- }
- }
- else
- f.reset(new LineConfigFile(*file, LineConfigFileOptions()));
-
- if (! f)
- continue;
-
- for (LineConfigFile::Iterator line(f->begin()), line_end(f->end()) ;
- line != line_end ; ++line)
- {
- std::vector<std::string> tokens;
- WhitespaceTokeniser::get_instance()->tokenise(*line, std::back_inserter(tokens));
- if (tokens.empty())
- continue;
-
- std::string prefix;
- if ("*" == tokens.at(0))
- {
- for (std::vector<std::string>::const_iterator t(next(tokens.begin())), t_end(tokens.end()) ;
- t != t_end ; ++t)
- {
- if ('-' == t->at(0))
- {
- if (*t == "-*")
- {
- _imp->default_use_prefixes_that_have_minus_star.push_back(prefix);
- if (prefix.empty())
- Log::get_instance()->message(ll_warning, lc_no_context,
- "Using '* -*' in use.conf is dangerous. You have been warned.");
- }
- else
- _imp->default_use.push_back(std::make_pair(UseFlagName(
- prefix + t->substr(1)), use_disabled));
- }
- else if (':' == t->at(t->length() - 1))
- {
- prefix.clear();
- std::transform(t->begin(), previous(t->end()), std::back_inserter(prefix),
- &::tolower);
- prefix.append("_");
- }
- else
- _imp->default_use.push_back(std::make_pair(UseFlagName(
- prefix + *t), use_enabled));
- }
- }
- else if (std::string::npos == tokens.at(0).find('/'))
- {
- for (std::vector<std::string>::const_iterator t(next(tokens.begin())), t_end(tokens.end()) ;
- t != t_end ; ++t)
- {
- if ('-' == t->at(0))
- {
- if ("-*" == *t)
- _imp->set_use_prefixes_that_have_minus_star.push_back(SetUseConfigMinusStarEntry(
- std::tr1::shared_ptr<SetName>(new SetName(tokens.at(0))),
- std::tr1::shared_ptr<const DepSpec>(), prefix));
- else
- _imp->set_use.push_back(SetUseConfigEntry(
- std::tr1::shared_ptr<const SetName>(new SetName(tokens.at(0))),
- std::tr1::shared_ptr<const DepSpec>(),
- UseFlagName(prefix + t->substr(1)), use_disabled));
- }
- else if (':' == t->at(t->length() - 1))
- {
- prefix.clear();
- std::transform(t->begin(), previous(t->end()), std::back_inserter(prefix),
- &::tolower);
- prefix.append("_");
- }
- else
- _imp->set_use.push_back(SetUseConfigEntry(
- std::tr1::shared_ptr<SetName>(new SetName(tokens.at(0))),
- std::tr1::shared_ptr<const DepSpec>(), UseFlagName(prefix + *t), use_enabled));
- }
- }
- else
- {
- std::tr1::shared_ptr<const PackageDepSpec> a(new PackageDepSpec(tokens.at(0), pds_pm_unspecific));
- for (std::vector<std::string>::const_iterator t(next(tokens.begin())), t_end(tokens.end()) ;
- t != t_end ; ++t)
- {
- if ('-' == t->at(0))
- {
- if ("-*" == *t)
- {
- if (a->package_ptr())
- _imp->use_prefixes_that_have_minus_star[*a->package_ptr()].push_back(
- std::make_pair(a, prefix));
- else
- _imp->set_use_prefixes_that_have_minus_star.push_back(
- SetUseConfigMinusStarEntry(std::tr1::shared_ptr<SetName>(),
- a, prefix));
- }
- else
- _imp->use[*a->package_ptr()].push_back(UseConfigEntry(
- a, UseFlagName(prefix + t->substr(1)), use_disabled));
- }
- else if (':' == t->at(t->length() - 1))
- {
- prefix.clear();
- std::transform(t->begin(), previous(t->end()), std::back_inserter(prefix),
- &::tolower);
- prefix.append("_");
- }
- else if (a->package_ptr())
- _imp->use[*a->package_ptr()].push_back(UseConfigEntry(
- a, UseFlagName(prefix + *t), use_enabled));
- else
- _imp->set_use.push_back(SetUseConfigEntry(
- std::tr1::shared_ptr<SetName>(), a, UseFlagName(prefix + *t),
- use_enabled));
- }
- }
- }
+ _imp->package_unmask_conf->add(*file);
}
-
- if (_imp->default_keywords.empty())
- throw PaludisConfigError("No default keywords specified (a keywords.conf file should "
- "contain an entry in the form '* keyword')");
}
/* mirrors */
@@ -985,52 +513,18 @@ PaludisConfig::PaludisConfig(PaludisEnvironment * const e, const std::string & s
if (! file->is_regular_file())
continue;
- std::tr1::shared_ptr<LineConfigFile> f;
-
- if (is_file_with_extension(*file, ".bash", IsFileWithOptions()))
- {
- Command cmd(Command("bash '" + stringify(*file) + "'")
- .with_setenv("PALUDIS_LOG_LEVEL", stringify(Log::get_instance()->log_level()))
- .with_setenv("PALUDIS_EBUILD_DIR", getenv_with_default("PALUDIS_EBUILD_DIR", LIBEXECDIR "/paludis"))
- .with_stderr_prefix(file->basename() + "> "));
- PStream s(cmd);
- f.reset(new LineConfigFile(s, LineConfigFileOptions()));
-
- if (s.exit_status() != 0)
- {
- Log::get_instance()->message(ll_warning, lc_context, "Script '" + stringify(*file)
- + "' returned non-zero exit status '" + stringify(s.exit_status()) + "'");
- f.reset();
- }
- }
- else
- f.reset(new LineConfigFile(*file, LineConfigFileOptions()));
-
- if (! f)
- continue;
-
- for (LineConfigFile::Iterator line(f->begin()), line_end(f->end()) ;
- line != line_end ; ++line)
- {
- std::vector<std::string> m;
- WhitespaceTokeniser::get_instance()->tokenise(*line, std::back_inserter(m));
- if (m.size() < 2)
- continue;
- for (std::vector<std::string>::const_iterator mm(next(m.begin())),
- mm_end(m.end()) ; mm != mm_end ; ++mm)
- _imp->mirrors.insert(std::make_pair(m.at(0), *mm));
- }
+ _imp->mirrors_conf->add(*file);
}
}
- _imp->bashrc_files = stringify(local_config_dir / "bashrc");
+ _imp->bashrc_files->push_back(local_config_dir / "bashrc");
}
PaludisConfig::~PaludisConfig()
{
}
-std::string
+std::tr1::shared_ptr<const FSEntryCollection>
PaludisConfig::bashrc_files() const
{
return _imp->bashrc_files;
@@ -1048,146 +542,6 @@ PaludisConfig::end_repositories() const
return RepositoryIterator(_imp->repos.end());
}
-PaludisConfig::PackageKeywordsIterator
-PaludisConfig::begin_package_keywords(const QualifiedPackageName & d) const
-{
- std::map<QualifiedPackageName, std::vector<
- std::pair<std::tr1::shared_ptr<const PackageDepSpec>, KeywordName> > >::const_iterator r;
- if (_imp->keywords.end() != ((r = _imp->keywords.find(d))))
- return PackageKeywordsIterator(r->second.begin());
- else
- return PackageKeywordsIterator(_imp->empty_keywords.begin());
-}
-
-PaludisConfig::PackageKeywordsIterator
-PaludisConfig::end_package_keywords(const QualifiedPackageName & d) const
-{
- std::map<QualifiedPackageName, std::vector<
- std::pair<std::tr1::shared_ptr<const PackageDepSpec>, KeywordName> > >::const_iterator r;
- if (_imp->keywords.end() != ((r = _imp->keywords.find(d))))
- return PackageKeywordsIterator(r->second.end());
- else
- return PackageKeywordsIterator(_imp->empty_keywords.end());
-}
-
-PaludisConfig::DefaultKeywordsIterator
-PaludisConfig::begin_default_keywords() const
-{
- return DefaultKeywordsIterator(_imp->default_keywords.begin());
-}
-
-PaludisConfig::DefaultKeywordsIterator
-PaludisConfig::end_default_keywords() const
-{
- return DefaultKeywordsIterator(_imp->default_keywords.end());
-}
-
-PaludisConfig::PackageLicensesIterator
-PaludisConfig::begin_package_licenses(const QualifiedPackageName & d) const
-{
- std::map<QualifiedPackageName, std::vector<
- std::pair<std::tr1::shared_ptr<const PackageDepSpec>, std::string> > >::const_iterator r;
- if (_imp->licenses.end() != ((r = _imp->licenses.find(d))))
- return PackageLicensesIterator(r->second.begin());
- else
- return PackageLicensesIterator(_imp->empty_licenses.begin());
-}
-
-PaludisConfig::PackageLicensesIterator
-PaludisConfig::end_package_licenses(const QualifiedPackageName & d) const
-{
- std::map<QualifiedPackageName, std::vector<
- std::pair<std::tr1::shared_ptr<const PackageDepSpec>, std::string> > >::const_iterator r;
- if (_imp->licenses.end() != ((r = _imp->licenses.find(d))))
- return PackageLicensesIterator(r->second.end());
- else
- return PackageLicensesIterator(_imp->empty_licenses.end());
-}
-
-PaludisConfig::DefaultLicensesIterator
-PaludisConfig::begin_default_licenses() const
-{
- return DefaultLicensesIterator(_imp->default_licenses.begin());
-}
-
-PaludisConfig::DefaultLicensesIterator
-PaludisConfig::end_default_licenses() const
-{
- return DefaultLicensesIterator(_imp->default_licenses.end());
-}
-
-PaludisConfig::UserMasksIterator
-PaludisConfig::begin_user_masks(const QualifiedPackageName & d) const
-{
- std::map<QualifiedPackageName, std::vector<std::tr1::shared_ptr<const PackageDepSpec> > >::const_iterator r;
- if (_imp->user_masks.end() != ((r = _imp->user_masks.find(d))))
- return UserMasksIterator(indirect_iterator<const PackageDepSpec>(r->second.begin()));
- else
- return UserMasksIterator(indirect_iterator<const PackageDepSpec>(_imp->empty_masks.begin()));
-}
-
-PaludisConfig::UserMasksIterator
-PaludisConfig::end_user_masks(const QualifiedPackageName & d) const
-{
- std::map<QualifiedPackageName, std::vector<std::tr1::shared_ptr<const PackageDepSpec> > >::const_iterator r;
- if (_imp->user_masks.end() != ((r = _imp->user_masks.find(d))))
- return UserMasksIterator(indirect_iterator<const PackageDepSpec>(r->second.end()));
- else
- return UserMasksIterator(indirect_iterator<const PackageDepSpec>(_imp->empty_masks.end()));
-}
-
-PaludisConfig::UserUnmasksIterator
-PaludisConfig::begin_user_unmasks(const QualifiedPackageName & d) const
-{
- std::map<QualifiedPackageName, std::vector<std::tr1::shared_ptr<const PackageDepSpec> > >::const_iterator r;
- if (_imp->user_unmasks.end() != ((r = _imp->user_unmasks.find(d))))
- return UserUnmasksIterator(indirect_iterator<const PackageDepSpec>(r->second.begin()));
- else
- return UserUnmasksIterator(indirect_iterator<const PackageDepSpec>(_imp->empty_masks.begin()));
-}
-
-PaludisConfig::UserUnmasksIterator
-PaludisConfig::end_user_unmasks(const QualifiedPackageName & d) const
-{
- std::map<QualifiedPackageName, std::vector<std::tr1::shared_ptr<const PackageDepSpec> > >::const_iterator r;
- if (_imp->user_unmasks.end() != ((r = _imp->user_unmasks.find(d))))
- return UserUnmasksIterator(indirect_iterator<const PackageDepSpec>(r->second.end()));
- else
- return UserUnmasksIterator(indirect_iterator<const PackageDepSpec>(_imp->empty_masks.end()));
-}
-
-PaludisConfig::UseConfigIterator
-PaludisConfig::begin_use_config(const QualifiedPackageName & q) const
-{
- std::map<QualifiedPackageName, std::vector<UseConfigEntry> >::const_iterator r;
- if (_imp->use.end() != ((r = _imp->use.find(q))))
- return UseConfigIterator(r->second.begin());
- else
- return UseConfigIterator(_imp->empty_use.begin());
-}
-
-PaludisConfig::UseConfigIterator
-PaludisConfig::end_use_config(const QualifiedPackageName & q) const
-{
- std::map<QualifiedPackageName, std::vector<UseConfigEntry> >::const_iterator r;
- if (_imp->use.end() != ((r = _imp->use.find(q))))
- return UseConfigIterator(r->second.end());
- else
- return UseConfigIterator(_imp->empty_use.end());
-}
-
-PaludisConfig::DefaultUseIterator
-PaludisConfig::begin_default_use() const
-{
- return DefaultUseIterator(_imp->default_use.begin());
-}
-
-PaludisConfig::DefaultUseIterator
-PaludisConfig::end_default_use() const
-{
- return DefaultUseIterator(_imp->default_use.end());
-}
-
std::string
PaludisConfig::root() const
{
@@ -1200,134 +554,6 @@ PaludisConfig::config_dir() const
return _imp->config_dir;
}
-PaludisConfig::MirrorIterator
-PaludisConfig::begin_mirrors(const std::string & m) const
-{
- return MirrorIterator(_imp->mirrors.lower_bound(m));
-}
-
-PaludisConfig::MirrorIterator
-PaludisConfig::end_mirrors(const std::string & m) const
-{
- return MirrorIterator(_imp->mirrors.upper_bound(m));
-}
-
-PaludisConfig::UseMinusStarIterator
-PaludisConfig::begin_use_prefixes_with_minus_star() const
-{
- return UseMinusStarIterator(_imp->default_use_prefixes_that_have_minus_star.begin());
-}
-
-PaludisConfig::UseMinusStarIterator
-PaludisConfig::end_use_prefixes_with_minus_star() const
-{
- return UseMinusStarIterator(_imp->default_use_prefixes_that_have_minus_star.end());
-}
-
-PaludisConfig::PackageUseMinusStarIterator
-PaludisConfig::begin_package_use_prefixes_with_minus_star(const QualifiedPackageName & d) const
-{
- std::map<QualifiedPackageName, std::vector<std::pair<std::tr1::shared_ptr<const PackageDepSpec>, std::string> > >::const_iterator r;
- if (_imp->use_prefixes_that_have_minus_star.end() != ((r = _imp->use_prefixes_that_have_minus_star.find(d))))
- return PackageUseMinusStarIterator(r->second.begin());
- else
- return PackageUseMinusStarIterator(_imp->empty_use_prefixes.begin());
-}
-
-PaludisConfig::PackageUseMinusStarIterator
-PaludisConfig::end_package_use_prefixes_with_minus_star(const QualifiedPackageName & d) const
-{
- std::map<QualifiedPackageName, std::vector<std::pair<std::tr1::shared_ptr<const PackageDepSpec>, std::string> > >::const_iterator r;
- if (_imp->use_prefixes_that_have_minus_star.end() != ((r = _imp->use_prefixes_that_have_minus_star.find(d))))
- return PackageUseMinusStarIterator(r->second.end());
- else
- return PackageUseMinusStarIterator(_imp->empty_use_prefixes.end());
-}
-
-PaludisConfig::SetUseMinusStarIterator
-PaludisConfig::begin_set_use_prefixes_with_minus_star() const
-{
- _imp->need_sets_expanded();
- return SetUseMinusStarIterator(_imp->set_use_prefixes_that_have_minus_star.begin());
-}
-
-PaludisConfig::SetUseMinusStarIterator
-PaludisConfig::end_set_use_prefixes_with_minus_star() const
-{
- _imp->need_sets_expanded();
- return SetUseMinusStarIterator(_imp->set_use_prefixes_that_have_minus_star.end());
-}
-
-PaludisConfig::SetUseConfigIterator
-PaludisConfig::begin_set_use_config() const
-{
- _imp->need_sets_expanded();
- return SetUseConfigIterator(_imp->set_use.begin());
-}
-
-PaludisConfig::SetUseConfigIterator
-PaludisConfig::end_set_use_config() const
-{
- _imp->need_sets_expanded();
- return SetUseConfigIterator(_imp->set_use.end());
-}
-
-PaludisConfig::SetKeywordsIterator
-PaludisConfig::begin_set_keywords() const
-{
- _imp->need_sets_expanded();
- return SetKeywordsIterator(_imp->set_keywords.begin());
-}
-
-PaludisConfig::SetKeywordsIterator
-PaludisConfig::end_set_keywords() const
-{
- _imp->need_sets_expanded();
- return SetKeywordsIterator(_imp->set_keywords.end());
-}
-
-PaludisConfig::SetLicensesIterator
-PaludisConfig::begin_set_licenses() const
-{
- _imp->need_sets_expanded();
- return SetLicensesIterator(_imp->set_licenses.begin());
-}
-
-PaludisConfig::SetLicensesIterator
-PaludisConfig::end_set_licenses() const
-{
- _imp->need_sets_expanded();
- return SetLicensesIterator(_imp->set_licenses.end());
-}
-
-PaludisConfig::UserMasksSetsIterator
-PaludisConfig::begin_user_masks_sets() const
-{
- _imp->need_sets_expanded();
- return UserMasksSetsIterator(_imp->set_masks.begin());
-}
-
-PaludisConfig::UserMasksSetsIterator
-PaludisConfig::end_user_masks_sets() const
-{
- _imp->need_sets_expanded();
- return UserMasksSetsIterator(_imp->set_masks.end());
-}
-
-PaludisConfig::UserMasksSetsIterator
-PaludisConfig::begin_user_unmasks_sets() const
-{
- _imp->need_sets_expanded();
- return UserMasksSetsIterator(_imp->set_unmasks.begin());
-}
-
-PaludisConfig::UserMasksSetsIterator
-PaludisConfig::end_user_unmasks_sets() const
-{
- _imp->need_sets_expanded();
- return UserMasksSetsIterator(_imp->set_unmasks.end());
-}
-
uid_t
PaludisConfig::reduced_uid() const
{
@@ -1401,3 +627,39 @@ PaludisConfig::accept_breaks_portage() const
return _imp->accept_breaks_portage;
}
+std::tr1::shared_ptr<const KeywordsConf>
+PaludisConfig::keywords_conf() const
+{
+ return _imp->keywords_conf;
+}
+
+std::tr1::shared_ptr<const UseConf>
+PaludisConfig::use_conf() const
+{
+ return _imp->use_conf;
+}
+
+std::tr1::shared_ptr<const LicensesConf>
+PaludisConfig::licenses_conf() const
+{
+ return _imp->licenses_conf;
+}
+
+std::tr1::shared_ptr<const PackageMaskConf>
+PaludisConfig::package_mask_conf() const
+{
+ return _imp->package_mask_conf;
+}
+
+std::tr1::shared_ptr<const PackageMaskConf>
+PaludisConfig::package_unmask_conf() const
+{
+ return _imp->package_unmask_conf;
+}
+
+std::tr1::shared_ptr<const MirrorsConf>
+PaludisConfig::mirrors_conf() const
+{
+ return _imp->mirrors_conf;
+}
+
diff --git a/paludis/environments/paludis/paludis_config.hh b/paludis/environments/paludis/paludis_config.hh
index ca1bf21..1c8585c 100644
--- a/paludis/environments/paludis/paludis_config.hh
+++ b/paludis/environments/paludis/paludis_config.hh
@@ -40,6 +40,11 @@ namespace paludis
{
struct EnvironmentMirrorIteratorTag;
struct PaludisEnvironment;
+ struct KeywordsConf;
+ struct UseConf;
+ struct LicensesConf;
+ struct PackageMaskConf;
+ struct MirrorsConf;
/**
* Iterate over environment mirrors.
@@ -110,130 +115,33 @@ namespace paludis
///\}
- ///\name Iterate over our repositories
- ///\{
-
- typedef libwrapiter::ForwardIterator<PaludisConfig, const RepositoryConfigEntry> RepositoryIterator;
-
- RepositoryIterator begin_repositories() const;
-
- RepositoryIterator end_repositories() const;
-
- ///\}
-
- ///\name Iterate over our default, set and per-package keywords
- ///\{
-
- typedef libwrapiter::ForwardIterator<PaludisConfig,
- const std::pair<std::tr1::shared_ptr<const PackageDepSpec>, KeywordName> > PackageKeywordsIterator;
-
- PackageKeywordsIterator begin_package_keywords(const QualifiedPackageName & d) const;
-
- PackageKeywordsIterator end_package_keywords(const QualifiedPackageName & d) const;
-
- typedef libwrapiter::ForwardIterator<PaludisConfig, const KeywordName> DefaultKeywordsIterator;
-
- DefaultKeywordsIterator begin_default_keywords() const;
-
- DefaultKeywordsIterator end_default_keywords() const;
-
- typedef libwrapiter::ForwardIterator<PaludisConfig, SetKeywordConfigEntry> SetKeywordsIterator;
-
- SetKeywordsIterator begin_set_keywords() const;
- SetKeywordsIterator end_set_keywords() const;
-
- ///\}
-
- ///\name Iterate over our default, set and per-package licenses
- ///\{
-
- typedef libwrapiter::ForwardIterator<PaludisConfig,
- const std::pair<std::tr1::shared_ptr<const PackageDepSpec>, std::string> > PackageLicensesIterator;
-
- PackageLicensesIterator begin_package_licenses(const QualifiedPackageName & d) const;
-
- PackageLicensesIterator end_package_licenses(const QualifiedPackageName & d) const;
-
- typedef libwrapiter::ForwardIterator<PaludisConfig, const std::string> DefaultLicensesIterator;
-
- DefaultLicensesIterator begin_default_licenses() const;
-
- DefaultLicensesIterator end_default_licenses() const;
-
- typedef libwrapiter::ForwardIterator<PaludisConfig, SetLicenseConfigEntry> SetLicensesIterator;
-
- SetLicensesIterator begin_set_licenses() const;
- SetLicensesIterator end_set_licenses() const;
-
- ///\}
-
- ///\name Iterate over our masks and unmasks
+ ///\name Config files
///\{
- typedef libwrapiter::ForwardIterator<PaludisConfig, const PackageDepSpec> UserMasksIterator;
-
- UserMasksIterator begin_user_masks(const QualifiedPackageName & d) const;
-
- UserMasksIterator end_user_masks(const QualifiedPackageName & d) const;
-
- typedef libwrapiter::ForwardIterator<PaludisConfig, const PackageDepSpec> UserUnmasksIterator;
-
- UserUnmasksIterator begin_user_unmasks(const QualifiedPackageName & d) const;
-
- UserUnmasksIterator end_user_unmasks(const QualifiedPackageName & d) const;
-
- typedef libwrapiter::ForwardIterator<PaludisConfig, SetMaskConfigEntry> UserMasksSetsIterator;
-
- UserMasksSetsIterator begin_user_masks_sets() const;
- UserMasksSetsIterator end_user_masks_sets() const;
- UserMasksSetsIterator begin_user_unmasks_sets() const;
- UserMasksSetsIterator end_user_unmasks_sets() const;
+ std::tr1::shared_ptr<const KeywordsConf> keywords_conf() const;
+ std::tr1::shared_ptr<const UseConf> use_conf() const;
+ std::tr1::shared_ptr<const LicensesConf> licenses_conf() const;
+ std::tr1::shared_ptr<const PackageMaskConf> package_mask_conf() const;
+ std::tr1::shared_ptr<const PackageMaskConf> package_unmask_conf() const;
+ std::tr1::shared_ptr<const MirrorsConf> mirrors_conf() const;
///\}
- ///\name Iterate over our default and per-package and per-set use flags
+ ///\name Iterate over our repositories
///\{
- typedef libwrapiter::ForwardIterator<PaludisConfig, const UseConfigEntry> UseConfigIterator;
-
- UseConfigIterator begin_use_config(const QualifiedPackageName & q) const;
-
- UseConfigIterator end_use_config(const QualifiedPackageName & q) const;
-
- typedef libwrapiter::ForwardIterator<PaludisConfig,
- const std::pair<UseFlagName, UseFlagState> > DefaultUseIterator;
-
- DefaultUseIterator begin_default_use() const;
-
- DefaultUseIterator end_default_use() const;
-
- typedef libwrapiter::ForwardIterator<PaludisConfig, const std::string> UseMinusStarIterator;
-
- UseMinusStarIterator begin_use_prefixes_with_minus_star() const;
- UseMinusStarIterator end_use_prefixes_with_minus_star() const;
-
- typedef libwrapiter::ForwardIterator<PaludisConfig,
- const std::pair<std::tr1::shared_ptr<const PackageDepSpec>, std::string> > PackageUseMinusStarIterator;
-
- PackageUseMinusStarIterator begin_package_use_prefixes_with_minus_star(const QualifiedPackageName &) const;
- PackageUseMinusStarIterator end_package_use_prefixes_with_minus_star(const QualifiedPackageName &) const;
-
- typedef libwrapiter::ForwardIterator<PaludisConfig, const SetUseConfigEntry> SetUseConfigIterator;
-
- SetUseConfigIterator begin_set_use_config() const;
- SetUseConfigIterator end_set_use_config() const;
+ typedef libwrapiter::ForwardIterator<PaludisConfig, const RepositoryConfigEntry> RepositoryIterator;
- typedef libwrapiter::ForwardIterator<PaludisConfig, const SetUseConfigMinusStarEntry> SetUseMinusStarIterator;
+ RepositoryIterator begin_repositories() const;
- SetUseMinusStarIterator begin_set_use_prefixes_with_minus_star() const;
- SetUseMinusStarIterator end_set_use_prefixes_with_minus_star() const;
+ RepositoryIterator end_repositories() const;
///\}
/**
* Our bashrc files.
*/
- std::string bashrc_files() const;
+ std::tr1::shared_ptr<const FSEntryCollection> bashrc_files() const;
/**
* The ROOT.
@@ -258,17 +166,6 @@ namespace paludis
* The config directory.
*/
std::string config_dir() const;
-
- ///\name Iterate over our mirrors
- ///\{
-
- typedef EnvironmentMirrorIterator MirrorIterator;
-
- MirrorIterator begin_mirrors(const std::string & m) const;
-
- MirrorIterator end_mirrors(const std::string & m) const;
-
- ///\}
};
}
diff --git a/paludis/environments/paludis/paludis_environment.cc b/paludis/environments/paludis/paludis_environment.cc
index 6757392..eee556e 100644
--- a/paludis/environments/paludis/paludis_environment.cc
+++ b/paludis/environments/paludis/paludis_environment.cc
@@ -17,30 +17,30 @@
* Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <paludis/config_file.hh>
-#include <paludis/hooker.hh>
#include <paludis/environments/paludis/paludis_config.hh>
#include <paludis/environments/paludis/paludis_environment.hh>
-#include <paludis/match_package.hh>
-#include <paludis/package_database.hh>
-#include <paludis/query.hh>
-#include <paludis/set_file.hh>
-#include <paludis/repository.hh>
+#include <paludis/environments/paludis/keywords_conf.hh>
+#include <paludis/environments/paludis/use_conf.hh>
+#include <paludis/environments/paludis/package_mask_conf.hh>
+#include <paludis/environments/paludis/licenses_conf.hh>
+#include <paludis/environments/paludis/mirrors_conf.hh>
+
#include <paludis/repositories/repository_maker.hh>
+
+#include <paludis/config_file.hh>
+#include <paludis/hooker.hh>
+#include <paludis/set_file.hh>
+
#include <paludis/util/collection_concrete.hh>
-#include <paludis/util/is_file_with_extension.hh>
#include <paludis/util/log.hh>
-#include <paludis/util/stringify.hh>
-#include <paludis/util/strip.hh>
#include <paludis/util/system.hh>
-#include <paludis/util/tokeniser.hh>
#include <paludis/util/dir_iterator.hh>
-
-#include <list>
-#include <vector>
+#include <paludis/util/is_file_with_extension.hh>
+#include <paludis/util/strip.hh>
#include <tr1/functional>
#include <functional>
#include <algorithm>
+#include <list>
using namespace paludis;
@@ -57,10 +57,13 @@ namespace paludis
std::string paludis_command;
std::list<UseConfigEntry> forced_use;
- Implementation(std::tr1::shared_ptr<PaludisConfig> c) :
+ std::tr1::shared_ptr<PackageDatabase> package_database;
+
+ Implementation(PaludisEnvironment * const e, std::tr1::shared_ptr<PaludisConfig> c) :
done_hooks(false),
config(c),
- paludis_command("paludis")
+ paludis_command("paludis"),
+ package_database(new PackageDatabase(e))
{
}
@@ -103,9 +106,8 @@ namespace paludis
}
PaludisEnvironment::PaludisEnvironment(const std::string & s) :
- Environment(std::tr1::shared_ptr<PackageDatabase>(new PackageDatabase(this))),
PrivateImplementationPattern<PaludisEnvironment>(new Implementation<PaludisEnvironment>(
- std::tr1::shared_ptr<PaludisConfig>(new PaludisConfig(this, s))))
+ this, std::tr1::shared_ptr<PaludisConfig>(new PaludisConfig(this, s))))
{
Context context("When loading paludis environment:");
@@ -131,7 +133,7 @@ PaludisEnvironment::PaludisEnvironment(const std::string & s) :
+ stringify(r->importance) + "', keys " + keys);
}
- package_database()->add_repository(r->importance,
+ _imp->package_database->add_repository(r->importance,
RepositoryMaker::get_instance()->find_maker(r->format)(this, r->keys));
}
}
@@ -141,219 +143,40 @@ PaludisEnvironment::~PaludisEnvironment()
}
bool
-PaludisEnvironment::query_use(const UseFlagName & f, const PackageDatabaseEntry * e) const
+PaludisEnvironment::query_use(const UseFlagName & f, const PackageDatabaseEntry & e) const
{
/* first check package database use masks... */
- const Repository * const repo((e ? package_database()->fetch_repository(e->repository).get() : 0));
+ std::tr1::shared_ptr<const Repository> repo(package_database()->fetch_repository(e.repository));
- if (repo && repo->use_interface)
+ if (repo->use_interface)
{
- if (repo->use_interface->query_use_mask(f, e))
+ if (repo->use_interface->query_use_mask(f, &e))
return false;
- if (repo->use_interface->query_use_force(f, e))
+ if (repo->use_interface->query_use_force(f, &e))
return true;
}
- /* check use: forced use config */
- for (std::list<UseConfigEntry>::const_iterator
- u(_imp->forced_use.begin()), u_end(_imp->forced_use.end()) ; u != u_end ; ++u)
- {
- if (u->flag_name != f)
- continue;
-
- if (! match_package(*this, *u->dep_spec, *e))
- continue;
-
- Log::get_instance()->message(ll_debug, lc_no_context, "Forced use flag: "
- + stringify(u->flag_name) + ", state: "
- + ((u->flag_state == use_enabled) ? "enabled" : "disabled"));
-
- return u->flag_state == use_enabled;
- }
-
- /* check use: per package user config */
- if (e)
- {
- UseFlagState s(use_unspecified);
-
- for (PaludisConfig::UseConfigIterator
- u(_imp->config->begin_use_config(e->name)),
- u_end(_imp->config->end_use_config(e->name)) ;
- u != u_end ; ++u)
- {
- if (f != u->flag_name)
- continue;
-
- if (! match_package(*this, *u->dep_spec, *e))
- continue;
-
- switch (u->flag_state)
- {
- case use_enabled:
- s = use_enabled;
- continue;
-
- case use_disabled:
- s = use_disabled;
- continue;
-
- case use_unspecified:
- continue;
- }
-
- throw InternalError(PALUDIS_HERE, "Bad state");
- }
-
- do
- {
- switch (s)
- {
- case use_enabled:
- return true;
-
- case use_disabled:
- return false;
-
- case use_unspecified:
- continue;
- }
- throw InternalError(PALUDIS_HERE, "Bad state");
- } while (false);
-
- /* and the -* bit */
- for (PaludisConfig::PackageUseMinusStarIterator
- i(_imp->config->begin_package_use_prefixes_with_minus_star(e->name)),
- i_end(_imp->config->end_package_use_prefixes_with_minus_star(e->name)) ;
- i != i_end ; ++i)
- {
- if (! match_package(*this, *i->first, *e))
- continue;
-
- if (0 == i->second.compare(0, i->second.length(), stringify(f), 0, i->second.length()))
- return false;
- }
- }
-
- /* check use: set user config */
- if (e)
+ /* check configs */
+ do
{
- UseFlagState s(use_unspecified);
-
- for (PaludisConfig::SetUseConfigIterator
- u(_imp->config->begin_set_use_config()),
- u_end(_imp->config->end_set_use_config()) ;
- u != u_end ; ++u)
+ switch (_imp->config->use_conf()->query(f, e))
{
- if (f != u->flag_name)
- continue;
-
- if (! match_package_in_heirarchy(*this, *u->dep_spec, *e))
- continue;
-
- switch (u->flag_state)
- {
- case use_enabled:
- s = use_enabled;
- continue;
-
- case use_disabled:
- s = use_disabled;
- continue;
-
- case use_unspecified:
- continue;
- }
-
- throw InternalError(PALUDIS_HERE, "Bad state");
- }
-
- do
- {
- switch (s)
- {
- case use_enabled:
- return true;
-
- case use_disabled:
- return false;
-
- case use_unspecified:
- continue;
- }
- throw InternalError(PALUDIS_HERE, "Bad state");
- } while (false);
-
- /* and the -* bit */
- for (PaludisConfig::SetUseMinusStarIterator
- i(_imp->config->begin_set_use_prefixes_with_minus_star()),
- i_end(_imp->config->end_set_use_prefixes_with_minus_star()) ;
- i != i_end ; ++i)
- {
- if (! match_package_in_heirarchy(*this, *i->dep_spec, *e))
- continue;
-
- if (0 == i->prefix.compare(0, i->prefix.length(), stringify(f), 0, i->prefix.length()))
+ case use_disabled:
return false;
- }
- }
- /* check use: general user config */
- do
- {
- UseFlagState state(use_unspecified);
-
- for (PaludisConfig::DefaultUseIterator
- u(_imp->config->begin_default_use()),
- u_end(_imp->config->end_default_use()) ;
- u != u_end ; ++u)
- if (f == u->first)
- state = u->second;
-
- switch (state)
- {
case use_enabled:
return true;
- case use_disabled:
- return false;
-
case use_unspecified:
continue;
}
-
- throw InternalError(PALUDIS_HERE, "bad state " + stringify(state));
+ throw InternalError(PALUDIS_HERE, "bad state");
} while (false);
- /* and -* again. slight gotcha: "* -*" should not override use expand things. if it
- * does, USERLAND etc get emptied. */
- bool consider_minus_star(true);
- if (e && repo && repo->use_interface)
- {
- std::tr1::shared_ptr<const UseFlagNameCollection> prefixes(repo->use_interface->use_expand_prefixes());
- for (UseFlagNameCollection::Iterator i(prefixes->begin()), i_end(prefixes->end()) ;
- i != i_end ; ++i)
- if (0 == i->data().compare(0, i->data().length(), stringify(f), 0, i->data().length()))
- {
- consider_minus_star = false;
- break;
- }
- }
-
- for (PaludisConfig::UseMinusStarIterator
- i(_imp->config->begin_use_prefixes_with_minus_star()),
- i_end(_imp->config->end_use_prefixes_with_minus_star()) ;
- i != i_end ; ++i)
- {
- if ((! consider_minus_star) && i->empty())
- continue;
- if (0 == i->compare(0, i->length(), stringify(f), 0, i->length()))
- return false;
- }
-
/* check use: package database config */
- if (repo && repo->use_interface)
+ if (repo->use_interface)
{
- switch (repo->use_interface->query_use(f, e))
+ switch (repo->use_interface->query_use(f, &e))
{
case use_disabled:
case use_unspecified:
@@ -365,210 +188,49 @@ PaludisEnvironment::query_use(const UseFlagName & f, const PackageDatabaseEntry
throw InternalError(PALUDIS_HERE, "bad state");
}
- else
- {
- return false;
- }
+
+ return false;
}
bool
-PaludisEnvironment::accept_breaks_portage() const
+PaludisEnvironment::accept_breaks_portage(const PackageDatabaseEntry &) const
{
return _imp->config->accept_breaks_portage();
}
bool
-PaludisEnvironment::accept_keyword(const KeywordName & keyword, const PackageDatabaseEntry * const d,
- const bool override_tilde_keywords) const
+PaludisEnvironment::accept_keywords(std::tr1::shared_ptr<const KeywordNameCollection> k,
+ const PackageDatabaseEntry & e) const
{
- static KeywordName star_keyword("*");
- static KeywordName minus_star_keyword("-*");
-
- if (keyword == star_keyword)
- return true;
-
- Context context("When checking accept_keyword of '" + stringify(keyword) +
- (d ? "' for " + stringify(*d) : stringify("'")) + ":");
-
- bool result(false);
-
- if (keyword != minus_star_keyword)
- {
- result |= _imp->config->end_default_keywords() !=
- std::find(_imp->config->begin_default_keywords(),
- _imp->config->end_default_keywords(),
- keyword);
- }
-
- result |= _imp->config->end_default_keywords() !=
- std::find(_imp->config->begin_default_keywords(),
- _imp->config->end_default_keywords(),
- star_keyword);
-
- if (d)
- {
- for (PaludisConfig::SetKeywordsIterator
- k(_imp->config->begin_set_keywords()),
- k_end(_imp->config->end_set_keywords()) ;
- k != k_end ; ++k)
- {
- if (! match_package_in_heirarchy(*this, *k->dep_spec, *d))
- continue;
-
- if (k->keyword == minus_star_keyword)
- result = false;
- else
- {
- result |= k->keyword == keyword;
- result |= k->keyword == star_keyword;
- }
- }
-
- for (PaludisConfig::PackageKeywordsIterator
- k(_imp->config->begin_package_keywords(d->name)),
- k_end(_imp->config->end_package_keywords(d->name)) ;
- k != k_end ; ++k)
- {
- if (! match_package(*this, *k->first, *d))
- continue;
-
- if (k->second == minus_star_keyword)
- result = false;
- else
- {
- result |= k->second == keyword;
- result |= k->second == star_keyword;
- }
- }
-
- }
-
- if ((! result) && override_tilde_keywords && ('~' == stringify(keyword).at(0)))
- result = accept_keyword(KeywordName(stringify(keyword).substr(1)), d, false);
-
- return result;
+ return _imp->config->keywords_conf()->query(k, e);
}
bool
-PaludisEnvironment::accept_license(const std::string & license, const PackageDatabaseEntry * const d) const
+PaludisEnvironment::accept_license(const std::string & license, const PackageDatabaseEntry & d) const
{
if (license == "*")
return true;
if (license == "-*")
return false;
- Context context("When checking license of '" + license +
- (d ? "' for " + stringify(*d) : stringify("'")) + ":");
-
- bool result(false);
-
- result |= _imp->config->end_default_licenses() !=
- std::find(_imp->config->begin_default_licenses(),
- _imp->config->end_default_licenses(),
- license);
-
- result |= _imp->config->end_default_licenses() !=
- std::find(_imp->config->begin_default_licenses(),
- _imp->config->end_default_licenses(),
- "*");
-
- if (d)
- {
- for (PaludisConfig::SetLicensesIterator
- k(_imp->config->begin_set_licenses()),
- k_end(_imp->config->end_set_licenses()) ;
- k != k_end ; ++k)
- {
- if (! match_package_in_heirarchy(*this, *k->dep_spec, *d))
- continue;
-
- if (k->license == "-*")
- result = false;
- else
- {
- result |= k->license == license;
- result |= k->license == "*";
- }
- }
-
- for (PaludisConfig::PackageLicensesIterator
- k(_imp->config->begin_package_licenses(d->name)),
- k_end(_imp->config->end_package_licenses(d->name)) ;
- k != k_end ; ++k)
- {
- if (! match_package(*this, *k->first, *d))
- continue;
+ Context context("When checking license of '" + license + "' for '" + stringify(d) + "':");
- if (k->second == "-*")
- result = false;
- else
- {
- result |= k->second == license;
- result |= k->second == "*";
- }
- }
- }
-
- return result;
+ return _imp->config->licenses_conf()->query(license, d);
}
bool
-PaludisEnvironment::query_user_masks(const PackageDatabaseEntry & d) const
+PaludisEnvironment::masked_by_user(const PackageDatabaseEntry & d) const
{
- for (PaludisConfig::UserMasksIterator
- k(_imp->config->begin_user_masks(d.name)),
- k_end(_imp->config->end_user_masks(d.name)) ;
- k != k_end ; ++k)
- {
- if (! match_package(*this, *k, d))
- continue;
-
- return true;
- }
-
- for (PaludisConfig::UserMasksSetsIterator
- k(_imp->config->begin_user_masks_sets()),
- k_end(_imp->config->end_user_masks_sets()) ;
- k != k_end ; ++k)
- {
- if (! match_package_in_heirarchy(*this, *k->dep_spec, d))
- continue;
-
- return true;
- }
-
- return false;
+ return _imp->config->package_mask_conf()->query(d);
}
bool
-PaludisEnvironment::query_user_unmasks(const PackageDatabaseEntry & d) const
+PaludisEnvironment::unmasked_by_user(const PackageDatabaseEntry & d) const
{
- for (PaludisConfig::UserMasksIterator
- k(_imp->config->begin_user_unmasks(d.name)),
- k_end(_imp->config->end_user_unmasks(d.name)) ;
- k != k_end ; ++k)
- {
- if (! match_package(*this, *k, d))
- continue;
-
- return true;
- }
-
- for (PaludisConfig::UserMasksSetsIterator
- k(_imp->config->begin_user_unmasks_sets()),
- k_end(_imp->config->end_user_unmasks_sets()) ;
- k != k_end ; ++k)
- {
- if (! match_package_in_heirarchy(*this, *k->dep_spec, d))
- continue;
-
- return true;
- }
-
- return false;
+ return _imp->config->package_unmask_conf()->query(d);
}
-std::string
+std::tr1::shared_ptr<const FSEntryCollection>
PaludisEnvironment::bashrc_files() const
{
return _imp->config->bashrc_files();
@@ -601,43 +263,52 @@ PaludisEnvironment::perform_hook(const Hook & hook) const
return _imp->hooker->perform_hook(hook);
}
-std::string
+std::tr1::shared_ptr<const FSEntryCollection>
PaludisEnvironment::hook_dirs() const
{
_imp->need_hook_dirs(_imp->config->config_dir());
- std::string result;
- for (std::list<std::pair<FSEntry, bool> >::const_iterator h(_imp->hook_dirs.begin()),
- h_end(_imp->hook_dirs.end()) ; h != h_end ; ++h)
- {
- if (! result.empty())
- result.append(" ");
- result.append(stringify(h->first));
- }
+ std::tr1::shared_ptr<FSEntryCollection> result(new FSEntryCollection::Concrete);
+ std::copy(_imp->hook_dirs.begin(), _imp->hook_dirs.end(),
+ transform_inserter(result->inserter(), SelectFirst<FSEntry, bool>()));
return result;
}
-std::string
+std::tr1::shared_ptr<const FSEntryCollection>
PaludisEnvironment::fetchers_dirs() const
{
- std::string dirs(stringify(FSEntry(_imp->config->config_dir()) / "fetchers"));
+ std::tr1::shared_ptr<FSEntryCollection> result(new FSEntryCollection::Concrete);
+
+ result->push_back(FSEntry(_imp->config->config_dir()) / "fetchers");
+
if (getenv_with_default("PALUDIS_NO_GLOBAL_FETCHERS", "").empty())
- dirs += " " + Environment::fetchers_dirs();
- return dirs;
+ {
+ std::tr1::shared_ptr<const FSEntryCollection> r(EnvironmentImplementation::fetchers_dirs());
+ std::copy(r->begin(), r->end(), result->inserter());
+ }
+
+ return result;
}
-std::string
+std::tr1::shared_ptr<const FSEntryCollection>
PaludisEnvironment::syncers_dirs() const
{
- std::string dirs(stringify(FSEntry(_imp->config->config_dir()) / "syncers"));
+ std::tr1::shared_ptr<FSEntryCollection> result(new FSEntryCollection::Concrete);
+
+ result->push_back(FSEntry(_imp->config->config_dir()) / "syncers");
+
if (getenv_with_default("PALUDIS_NO_GLOBAL_SYNCERS", "").empty())
- dirs += " " + Environment::syncers_dirs();
- return dirs;
+ {
+ std::tr1::shared_ptr<const FSEntryCollection> r(EnvironmentImplementation::syncers_dirs());
+ std::copy(r->begin(), r->end(), result->inserter());
+ }
+
+ return result;
}
std::tr1::shared_ptr<CompositeDepSpec>
-PaludisEnvironment::local_package_set(const SetName & s) const
+PaludisEnvironment::local_set(const SetName & s) const
{
Context context("When looking for package set '" + stringify(s) + "' in paludis environment:");
@@ -668,10 +339,10 @@ PaludisEnvironment::local_package_set(const SetName & s) const
return std::tr1::shared_ptr<AllDepSpec>();
}
-std::tr1::shared_ptr<const SetsCollection>
-PaludisEnvironment::sets_list() const
+std::tr1::shared_ptr<const SetNameCollection>
+PaludisEnvironment::set_names() const
{
- std::tr1::shared_ptr<SetsCollection> result(new SetsCollection::Concrete);
+ std::tr1::shared_ptr<SetNameCollection> result(new SetNameCollection::Concrete);
if ((FSEntry(_imp->config->config_dir()) / "sets").exists())
for (DirIterator d(FSEntry(_imp->config->config_dir()) / "sets"), d_end ;
@@ -686,61 +357,19 @@ PaludisEnvironment::sets_list() const
return result;
}
-PaludisEnvironment::MirrorIterator
-PaludisEnvironment::begin_mirrors(const std::string & mirror) const
+std::tr1::shared_ptr<const MirrorsCollection>
+PaludisEnvironment::mirrors(const std::string & m) const
{
- return _imp->config->begin_mirrors(mirror);
-}
-
-PaludisEnvironment::MirrorIterator
-PaludisEnvironment::end_mirrors(const std::string & mirror) const
-{
- return _imp->config->end_mirrors(mirror);
+ return _imp->config->mirrors_conf()->query(m);
}
std::tr1::shared_ptr<const UseFlagNameCollection>
-PaludisEnvironment::known_use_expand_names(const UseFlagName & prefix, const PackageDatabaseEntry * pde) const
+PaludisEnvironment::known_use_expand_names(const UseFlagName & prefix, const PackageDatabaseEntry & e) const
{
- std::tr1::shared_ptr<UseFlagNameCollection> result(new UseFlagNameCollection::Concrete);
-
- std::string prefix_lower;
- std::transform(prefix.data().begin(), prefix.data().end(), std::back_inserter(prefix_lower), &::tolower);
- for (PaludisConfig::DefaultUseIterator i(_imp->config->begin_default_use()),
- i_end(_imp->config->end_default_use()) ; i != i_end ; ++i)
- if (i->first.data().length() > prefix_lower.length() &&
- 0 == i->first.data().compare(0, prefix_lower.length(), prefix_lower, 0, prefix_lower.length()))
- result->insert(i->first);
-
- if (pde)
- {
- for (std::list<UseConfigEntry>::const_iterator i(_imp->forced_use.begin()),
- i_end(_imp->forced_use.end()) ; i != i_end ; ++i)
- {
- if (! i->dep_spec)
- continue;
-
- if (! match_package(*this, *i->dep_spec, *pde))
- continue;
-
- if (i->flag_name.data().length() > prefix_lower.length() &&
- 0 == i->flag_name.data().compare(0, prefix_lower.length(), prefix_lower, 0, prefix_lower.length()))
- result->insert(i->flag_name);
- }
-
- for (PaludisConfig::UseConfigIterator i(_imp->config->begin_use_config(pde->name)),
- i_end(_imp->config->end_use_config(pde->name)) ; i != i_end ; ++i)
- if (i->flag_name.data().length() > prefix_lower.length() &&
- 0 == i->flag_name.data().compare(0, prefix_lower.length(), prefix_lower, 0, prefix_lower.length()))
- result->insert(i->flag_name);
- }
-
- Log::get_instance()->message(ll_debug, lc_no_context, "PaludisEnvironment::known_use_expand_names("
- + stringify(prefix) + ", " + (pde ? stringify(*pde) : stringify("0")) + ") -> ("
- + join(result->begin(), result->end(), ", ") + ")");
- return result;
+ return _imp->config->use_conf()->known_use_expand_names(prefix, e);
}
-FSEntry
+const FSEntry
PaludisEnvironment::root() const
{
return _imp->config->root();
@@ -766,22 +395,21 @@ PaludisEnvironment::reduced_gid() const
return g;
}
-void
-PaludisEnvironment::force_use(std::tr1::shared_ptr<const PackageDepSpec> a,
- const UseFlagName & f, const UseFlagState s)
+std::string
+PaludisEnvironment::config_dir() const
{
- _imp->forced_use.push_back(UseConfigEntry(a, f, s));
+ return _imp->config->config_dir();
}
-void
-PaludisEnvironment::clear_forced_use()
+std::tr1::shared_ptr<PackageDatabase>
+PaludisEnvironment::package_database()
{
- _imp->forced_use.clear();
+ return _imp->package_database;
}
-std::string
-PaludisEnvironment::config_dir() const
+std::tr1::shared_ptr<const PackageDatabase>
+PaludisEnvironment::package_database() const
{
- return _imp->config->config_dir();
+ return _imp->package_database;
}
diff --git a/paludis/environments/paludis/paludis_environment.hh b/paludis/environments/paludis/paludis_environment.hh
index 27acb14..0446388 100644
--- a/paludis/environments/paludis/paludis_environment.hh
+++ b/paludis/environments/paludis/paludis_environment.hh
@@ -21,7 +21,7 @@
#define PALUDIS_GUARD_PALUDIS_DEFAULT_ENVIRONMENT_HH 1
#include <paludis/package_database.hh>
-#include <paludis/environment.hh>
+#include <paludis/environment_implementation.hh>
/** \file
* Declarations for the PaludisEnvironment class.
@@ -40,12 +40,28 @@ namespace paludis
* \ingroup grppaludisenvironment
*/
class PALUDIS_VISIBLE PaludisEnvironment :
- public Environment,
+ public EnvironmentImplementation,
public InstantiationPolicy<PaludisEnvironment, instantiation_method::SingletonTag>,
private PrivateImplementationPattern<PaludisEnvironment>
- {
+ {
protected:
- std::tr1::shared_ptr<CompositeDepSpec> local_package_set(const SetName &) const;
+ virtual bool accept_keywords(std::tr1::shared_ptr<const KeywordNameCollection>, const PackageDatabaseEntry &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual bool accept_license(const std::string &, const PackageDatabaseEntry &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual bool accept_breaks_portage(const PackageDatabaseEntry &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual bool masked_by_user(const PackageDatabaseEntry &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual bool unmasked_by_user(const PackageDatabaseEntry &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual std::tr1::shared_ptr<CompositeDepSpec> local_set(const SetName &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
public:
///\name Basic operations
@@ -57,56 +73,63 @@ namespace paludis
///\}
- virtual std::tr1::shared_ptr<const SetsCollection> sets_list() const;
-
- virtual bool query_use(const UseFlagName &, const PackageDatabaseEntry *) const;
-
- virtual bool accept_keyword(const KeywordName &, const PackageDatabaseEntry * const,
- const bool) const;
-
- virtual bool accept_license(const std::string &, const PackageDatabaseEntry * const) const;
+ ///\name PaludisEnvironment-specific information
+ ///\{
- virtual bool query_user_masks(const PackageDatabaseEntry &) const;
+ /**
+ * The config directory.
+ */
+ std::string config_dir() const;
- virtual bool query_user_unmasks(const PackageDatabaseEntry &) const;
+ ///\}
- virtual std::string bashrc_files() const;
+ virtual bool query_use(const UseFlagName &, const PackageDatabaseEntry &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual std::string hook_dirs() const;
+ virtual std::tr1::shared_ptr<const UseFlagNameCollection> known_use_expand_names(
+ const UseFlagName &, const PackageDatabaseEntry &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual std::string fetchers_dirs() const;
+ virtual std::tr1::shared_ptr<const FSEntryCollection> bashrc_files() const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual std::string syncers_dirs() const;
+ virtual std::tr1::shared_ptr<const FSEntryCollection> syncers_dirs() const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual std::string paludis_command() const;
+ virtual std::tr1::shared_ptr<const FSEntryCollection> fetchers_dirs() const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual void set_paludis_command(const std::string &);
+ virtual std::tr1::shared_ptr<const FSEntryCollection> hook_dirs() const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual std::tr1::shared_ptr<const UseFlagNameCollection> known_use_expand_names(const UseFlagName &,
- const PackageDatabaseEntry *) const;
+ virtual const FSEntry root() const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual int perform_hook(const Hook & hook) const PALUDIS_ATTRIBUTE((warn_unused_result));
+ virtual uid_t reduced_uid() const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual MirrorIterator begin_mirrors(const std::string & mirror) const;
+ virtual gid_t reduced_gid() const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual MirrorIterator end_mirrors(const std::string & mirror) const;
+ virtual std::tr1::shared_ptr<const MirrorsCollection> mirrors(const std::string &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual FSEntry root() const;
+ virtual std::tr1::shared_ptr<const SetNameCollection> set_names() const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual uid_t reduced_uid() const;
- virtual gid_t reduced_gid() const;
+ virtual int perform_hook(const Hook &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
- void force_use(std::tr1::shared_ptr<const PackageDepSpec>, const UseFlagName &,
- const UseFlagState);
+ virtual std::string paludis_command() const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual void clear_forced_use();
+ virtual void set_paludis_command(const std::string &);
- virtual bool accept_breaks_portage() const;
+ virtual std::tr1::shared_ptr<PackageDatabase> package_database()
+ PALUDIS_ATTRIBUTE((warn_unused_result));
- /**
- * The config directory.
- */
- std::string config_dir() const;
+ virtual std::tr1::shared_ptr<const PackageDatabase> package_database() const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
};
}
#endif
diff --git a/paludis/environments/paludis/paludis_environment_TEST.cc b/paludis/environments/paludis/paludis_environment_TEST.cc
index b242dd2..a456467 100644
--- a/paludis/environments/paludis/paludis_environment_TEST.cc
+++ b/paludis/environments/paludis/paludis_environment_TEST.cc
@@ -40,23 +40,24 @@ namespace test_cases
std::tr1::shared_ptr<Environment> env(new PaludisEnvironment(""));
- TEST_CHECK(env->query_use(UseFlagName("foo"), 0));
- TEST_CHECK(! env->query_use(UseFlagName("foofoo"), 0));
+ PackageDatabaseEntry x(QualifiedPackageName("x/x"), VersionSpec("0"), RepositoryName("foo"));
+ TEST_CHECK(env->query_use(UseFlagName("foo"), x));
+ TEST_CHECK(! env->query_use(UseFlagName("foofoo"), x));
PackageDatabaseEntry pde(QualifiedPackageName("cat-one/pkg-one"), VersionSpec("1"), RepositoryName("foo"));
- TEST_CHECK(env->query_use(UseFlagName("foo"), &pde));
- TEST_CHECK(! env->query_use(UseFlagName("foofoo"), &pde));
- TEST_CHECK(env->query_use(UseFlagName("moo"), &pde));
+ TEST_CHECK(env->query_use(UseFlagName("foo"), pde));
+ TEST_CHECK(! env->query_use(UseFlagName("foofoo"), pde));
+ TEST_CHECK(env->query_use(UseFlagName("moo"), pde));
- TEST_CHECK(env->query_use(UseFlagName("more_exp_one"), &pde));
- TEST_CHECK(env->query_use(UseFlagName("exp_two"), &pde));
- TEST_CHECK(env->query_use(UseFlagName("exp_one"), &pde));
- TEST_CHECK(env->query_use(UseFlagName("third_exp_one"), &pde));
- TEST_CHECK(! env->query_use(UseFlagName("third_exp_two"), &pde));
+ TEST_CHECK(env->query_use(UseFlagName("more_exp_one"), pde));
+ TEST_CHECK(env->query_use(UseFlagName("exp_two"), pde));
+ TEST_CHECK(env->query_use(UseFlagName("exp_one"), pde));
+ TEST_CHECK(env->query_use(UseFlagName("third_exp_one"), pde));
+ TEST_CHECK(! env->query_use(UseFlagName("third_exp_two"), pde));
PackageDatabaseEntry f(QualifiedPackageName("cat-one/pkg-two"), VersionSpec("3"), RepositoryName("foo"));
- TEST_CHECK(env->query_use(UseFlagName("third_exp_one"), &f));
- TEST_CHECK(env->query_use(UseFlagName("third_exp_two"), &f));
+ TEST_CHECK(env->query_use(UseFlagName("third_exp_one"), f));
+ TEST_CHECK(env->query_use(UseFlagName("third_exp_two"), f));
}
} paludis_environment_use_test;
@@ -71,23 +72,24 @@ namespace test_cases
std::tr1::shared_ptr<Environment> env(new PaludisEnvironment(""));
- TEST_CHECK(env->query_use(UseFlagName("foo"), 0));
- TEST_CHECK(! env->query_use(UseFlagName("foofoo"), 0));
+ PackageDatabaseEntry x(QualifiedPackageName("x/x"), VersionSpec("0"), RepositoryName("foo"));
+ TEST_CHECK(env->query_use(UseFlagName("foo"), x));
+ TEST_CHECK(! env->query_use(UseFlagName("foofoo"), x));
PackageDatabaseEntry pde(QualifiedPackageName("cat-one/pkg-one"), VersionSpec("1"), RepositoryName("foo"));
- TEST_CHECK(env->query_use(UseFlagName("foo"), &pde));
- TEST_CHECK(! env->query_use(UseFlagName("foofoo"), &pde));
- TEST_CHECK(! env->query_use(UseFlagName("moo"), &pde));
+ TEST_CHECK(env->query_use(UseFlagName("foo"), pde));
+ TEST_CHECK(! env->query_use(UseFlagName("foofoo"), pde));
+ TEST_CHECK(! env->query_use(UseFlagName("moo"), pde));
- TEST_CHECK(env->query_use(UseFlagName("more_exp_one"), &pde));
- TEST_CHECK(env->query_use(UseFlagName("exp_two"), &pde));
- TEST_CHECK(! env->query_use(UseFlagName("exp_one"), &pde));
- TEST_CHECK(env->query_use(UseFlagName("third_exp_one"), &pde));
- TEST_CHECK(! env->query_use(UseFlagName("third_exp_two"), &pde));
+ TEST_CHECK(env->query_use(UseFlagName("more_exp_one"), pde));
+ TEST_CHECK(env->query_use(UseFlagName("exp_two"), pde));
+ TEST_CHECK(! env->query_use(UseFlagName("exp_one"), pde));
+ TEST_CHECK(env->query_use(UseFlagName("third_exp_one"), pde));
+ TEST_CHECK(! env->query_use(UseFlagName("third_exp_two"), pde));
PackageDatabaseEntry f(QualifiedPackageName("cat-one/pkg-two"), VersionSpec("3"), RepositoryName("foo"));
- TEST_CHECK(! env->query_use(UseFlagName("third_exp_one"), &f));
- TEST_CHECK(env->query_use(UseFlagName("third_exp_two"), &f));
+ TEST_CHECK(! env->query_use(UseFlagName("third_exp_one"), f));
+ TEST_CHECK(env->query_use(UseFlagName("third_exp_two"), f));
}
} paludis_environment_use_test_minus_star;
@@ -102,23 +104,24 @@ namespace test_cases
std::tr1::shared_ptr<Environment> env(new PaludisEnvironment(""));
- TEST_CHECK(env->query_use(UseFlagName("foo"), 0));
- TEST_CHECK(! env->query_use(UseFlagName("foofoo"), 0));
+ PackageDatabaseEntry x(QualifiedPackageName("x/x"), VersionSpec("0"), RepositoryName("foo"));
+ TEST_CHECK(env->query_use(UseFlagName("foo"), x));
+ TEST_CHECK(! env->query_use(UseFlagName("foofoo"), x));
PackageDatabaseEntry pde(QualifiedPackageName("cat-one/pkg-one"), VersionSpec("1"), RepositoryName("foo"));
- TEST_CHECK(env->query_use(UseFlagName("foo"), &pde));
- TEST_CHECK(! env->query_use(UseFlagName("foofoo"), &pde));
- TEST_CHECK(env->query_use(UseFlagName("moo"), &pde));
+ TEST_CHECK(env->query_use(UseFlagName("foo"), pde));
+ TEST_CHECK(! env->query_use(UseFlagName("foofoo"), pde));
+ TEST_CHECK(env->query_use(UseFlagName("moo"), pde));
- TEST_CHECK(env->query_use(UseFlagName("more_exp_one"), &pde));
- TEST_CHECK(env->query_use(UseFlagName("exp_two"), &pde));
- TEST_CHECK(! env->query_use(UseFlagName("exp_one"), &pde));
- TEST_CHECK(env->query_use(UseFlagName("third_exp_one"), &pde));
- TEST_CHECK(! env->query_use(UseFlagName("third_exp_two"), &pde));
+ TEST_CHECK(env->query_use(UseFlagName("more_exp_one"), pde));
+ TEST_CHECK(env->query_use(UseFlagName("exp_two"), pde));
+ TEST_CHECK(! env->query_use(UseFlagName("exp_one"), pde));
+ TEST_CHECK(env->query_use(UseFlagName("third_exp_one"), pde));
+ TEST_CHECK(! env->query_use(UseFlagName("third_exp_two"), pde));
PackageDatabaseEntry f(QualifiedPackageName("cat-one/pkg-two"), VersionSpec("3"), RepositoryName("foo"));
- TEST_CHECK(! env->query_use(UseFlagName("third_exp_one"), &f));
- TEST_CHECK(env->query_use(UseFlagName("third_exp_two"), &f));
+ TEST_CHECK(! env->query_use(UseFlagName("third_exp_one"), f));
+ TEST_CHECK(env->query_use(UseFlagName("third_exp_two"), f));
}
} paludis_environment_use_test_minus_star_partial;
diff --git a/paludis/environments/paludis/paludis_environment_TEST_setup.sh b/paludis/environments/paludis/paludis_environment_TEST_setup.sh
index 9f76c89..402bf36 100755
--- a/paludis/environments/paludis/paludis_environment_TEST_setup.sh
+++ b/paludis/environments/paludis/paludis_environment_TEST_setup.sh
@@ -43,15 +43,15 @@ END
mkdir -p home1/.paludis/repositories
cat <<END > home1/.paludis/use.conf
-* foo bar baz -fnord
-* EXP: two
+*/* foo bar baz -fnord
+*/* EXP: two
>=cat-one/pkg-two-2 THIRD_EXP: two
END
cat <<END > home1/.paludis/keywords.conf
-* keyword
+*/* keyword
END
cat <<END > home1/.paludis/licenses.conf
-* keyword
+*/* keyword
END
cat <<END > home1/.paludis/repositories/foo.conf
format = ebuild
@@ -63,15 +63,15 @@ END
mkdir -p home2/.paludis/repositories
cat <<END > home2/.paludis/use.conf
-* -* foo bar baz -fnord
-* EXP: -* two
+*/* -* foo bar baz -fnord
+*/* EXP: -* two
>=cat-one/pkg-two-2 THIRD_EXP: -* two
END
cat <<END > home2/.paludis/keywords.conf
-* keyword
+*/* keyword
END
cat <<END > home2/.paludis/licenses.conf
-* *
+*/* *
END
cat <<END > home2/.paludis/repositories/foo.conf
format = ebuild
@@ -83,15 +83,15 @@ END
mkdir -p home3/.paludis/repositories
cat <<END > home3/.paludis/use.conf
-* foo bar baz -fnord
-* EXP: -* two
+*/* foo bar baz -fnord
+*/* EXP: -* two
>=cat-one/pkg-two-2 THIRD_EXP: -* two
END
cat <<END > home3/.paludis/keywords.conf
-* keyword
+*/* keyword
END
cat <<END > home3/.paludis/licenses.conf
-* *
+*/* *
END
cat <<END > home3/.paludis/repositories/foo.conf
format = ebuild
@@ -103,13 +103,13 @@ END
mkdir -p home4/.paludis/repositories
cat <<END > home4/.paludis/use.conf
-* foo
+*/* foo
END
cat <<END > home4/.paludis/keywords.conf
-* keyword
+*/* keyword
END
cat <<END > home4/.paludis/licenses.conf
-* *
+*/* *
END
cat <<END > home4/.paludis/repositories/first.conf
format = ebuild
diff --git a/paludis/environments/paludis/use_conf.cc b/paludis/environments/paludis/use_conf.cc
new file mode 100644
index 0000000..503e58e
--- /dev/null
+++ b/paludis/environments/paludis/use_conf.cc
@@ -0,0 +1,357 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 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
+ * 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 "use_conf.hh"
+#include <paludis/environment.hh>
+#include <paludis/package_database_entry.hh>
+#include <paludis/hashed_containers.hh>
+#include <paludis/name.hh>
+#include <paludis/dep_spec.hh>
+#include <paludis/match_package.hh>
+#include <paludis/environments/paludis/paludis_environment.hh>
+#include <paludis/environments/paludis/bashable_conf.hh>
+#include <paludis/util/log.hh>
+#include <paludis/util/tokeniser.hh>
+#include <paludis/util/iterator.hh>
+#include <paludis/util/strip.hh>
+#include <paludis/util/collection_concrete.hh>
+#include <list>
+#include <vector>
+
+using namespace paludis;
+
+typedef MakeHashedMap<UseFlagName, UseFlagState>::Type UseFlagWithStateMap;
+typedef std::list<std::string> MinusStarPrefixList;
+typedef std::pair<UseFlagWithStateMap, MinusStarPrefixList> UseInfo;
+typedef std::pair<std::tr1::shared_ptr<const PackageDepSpec>, UseInfo> PDSWithUseInfo;
+typedef std::pair<std::tr1::shared_ptr<const DepSpec>, UseInfo> DSWithUseInfo;
+typedef std::list<PDSWithUseInfo> PDSWithUseInfoList;
+typedef MakeHashedMap<QualifiedPackageName, PDSWithUseInfoList>::Type Qualified;
+typedef std::list<PDSWithUseInfo> Unqualified;
+typedef MakeHashedMap<SetName, DSWithUseInfo>::Type Sets;
+
+namespace paludis
+{
+ template<>
+ struct Implementation<UseConf>
+ {
+ const PaludisEnvironment * const env;
+ Qualified qualified;
+ Unqualified unqualified;
+ mutable Sets sets;
+
+ Implementation(const PaludisEnvironment * const e) :
+ env(e)
+ {
+ }
+ };
+}
+
+UseConf::UseConf(const PaludisEnvironment * const e) :
+ PrivateImplementationPattern<UseConf>(new Implementation<UseConf>(e))
+{
+}
+
+UseConf::~UseConf()
+{
+}
+
+void
+UseConf::add(const FSEntry & filename)
+{
+ Context context("When adding source '" + stringify(filename) + "' as a use file:");
+
+ std::tr1::shared_ptr<LineConfigFile> f(make_bashable_conf(filename));
+ if (! f)
+ return;
+
+ for (LineConfigFile::Iterator line(f->begin()), line_end(f->end()) ;
+ line != line_end ; ++line)
+ {
+ std::vector<std::string> tokens;
+ WhitespaceTokeniser::get_instance()->tokenise(*line, std::back_inserter(tokens));
+
+ if (tokens.size() < 2)
+ continue;
+
+ if ("*" == tokens.at(0))
+ {
+ Log::get_instance()->message(ll_warning, lc_context) << "Use of token '*' is deprecated, use '*/*' instead";
+ tokens.at(0) = "*/*";
+ }
+
+ if (std::string::npos == tokens.at(0).find("/"))
+ {
+ Sets::iterator i(_imp->sets.insert(std::make_pair(SetName(tokens.at(0)), DSWithUseInfo())).first);
+ std::string prefix_upper, prefix_lower;
+ for (std::vector<std::string>::const_iterator t(next(tokens.begin())), t_end(tokens.end()) ;
+ t != t_end ; ++t)
+ {
+ if (*t == "-*")
+ i->second.second.second.push_back(strip_trailing(prefix_lower, "_"));
+ else if ('-' == t->at(0))
+ i->second.second.first.insert(std::make_pair(
+ UseFlagName(prefix_lower + t->substr(1)), use_disabled)).first->second = use_disabled;
+ else if (':' == t->at(t->length() - 1))
+ {
+ std::transform(t->begin(), previous(t->end()), std::back_inserter(prefix_lower), &::tolower);
+ std::transform(t->begin(), previous(t->end()), std::back_inserter(prefix_upper), &::toupper);
+ prefix_lower.append("_");
+ prefix_upper.append("_");
+ }
+ else
+ i->second.second.first.insert(std::make_pair(
+ UseFlagName(prefix_lower + *t), use_enabled)).first->second = use_enabled;
+ }
+ }
+ else
+ {
+ std::tr1::shared_ptr<PackageDepSpec> d(new PackageDepSpec(tokens.at(0), pds_pm_unspecific));
+ if (d->package_ptr())
+ {
+ Qualified::iterator ii(_imp->qualified.insert(std::make_pair(*d->package_ptr(), PDSWithUseInfoList())).first);
+ PDSWithUseInfoList::iterator i(ii->second.insert(ii->second.end(), PDSWithUseInfo(d, UseInfo())));
+
+ std::string prefix_upper, prefix_lower;
+ for (std::vector<std::string>::const_iterator t(next(tokens.begin())), t_end(tokens.end()) ;
+ t != t_end ; ++t)
+ {
+ if (*t == "-*")
+ i->second.second.push_back(strip_trailing(prefix_lower, "_"));
+ else if ('-' == t->at(0))
+ i->second.first.insert(std::make_pair(
+ UseFlagName(prefix_lower + t->substr(1)), use_disabled)).first->second = use_disabled;
+ else if (':' == t->at(t->length() - 1))
+ {
+ std::transform(t->begin(), previous(t->end()), std::back_inserter(prefix_lower), &::tolower);
+ std::transform(t->begin(), previous(t->end()), std::back_inserter(prefix_upper), &::toupper);
+ prefix_lower.append("_");
+ prefix_upper.append("_");
+ }
+ else
+ i->second.first.insert(std::make_pair(UseFlagName(prefix_lower + *t), use_enabled)).first->second = use_enabled;
+ }
+ }
+ else
+ {
+ Unqualified::iterator i(_imp->unqualified.insert(_imp->unqualified.end(), PDSWithUseInfo(d, UseInfo())));
+
+ std::string prefix_upper, prefix_lower;
+ for (std::vector<std::string>::const_iterator t(next(tokens.begin())), t_end(tokens.end()) ;
+ t != t_end ; ++t)
+ {
+ if (*t == "-*")
+ i->second.second.push_back(strip_trailing(prefix_lower, "_"));
+ else if ('-' == t->at(0))
+ i->second.first.insert(
+ std::make_pair(UseFlagName(prefix_lower + t->substr(1)), use_disabled)).first->second = use_disabled;
+ else if (':' == t->at(t->length() - 1))
+ {
+ std::transform(t->begin(), previous(t->end()), std::back_inserter(prefix_lower), &::tolower);
+ std::transform(t->begin(), previous(t->end()), std::back_inserter(prefix_upper), &::toupper);
+ prefix_lower.append("_");
+ prefix_upper.append("_");
+ }
+ else
+ i->second.first.insert(std::make_pair(UseFlagName(prefix_lower + *t), use_enabled)).first->second = use_enabled;
+ }
+ }
+ }
+ }
+}
+
+UseFlagState
+UseConf::query(const UseFlagName & f, const PackageDatabaseEntry & e) const
+{
+ Context context("When checking state of flag '" + stringify(f) + "' for '" + stringify(e) + "':");
+
+ UseFlagState result(use_unspecified);
+
+ bool ignore_empty_minus_star(false);
+ std::tr1::shared_ptr<const Repository> repo(_imp->env->package_database()->fetch_repository(e.repository));
+ if (repo->use_interface)
+ {
+ std::tr1::shared_ptr<const UseFlagNameCollection> prefixes(repo->use_interface->use_expand_prefixes());
+ for (UseFlagNameCollection::Iterator p(prefixes->begin()), p_end(prefixes->end()) ;
+ p != p_end ; ++p)
+ if (0 == p->data().compare(0, p->data().length(), stringify(f), 0, p->data().length()))
+ {
+ ignore_empty_minus_star = true;
+ break;
+ }
+ }
+
+ /* highest priority: specific */
+ Qualified::const_iterator q(_imp->qualified.find(e.name));
+ if (_imp->qualified.end() != q)
+ {
+ for (PDSWithUseInfoList::const_iterator p(q->second.begin()), p_end(q->second.end()) ; p != p_end ; ++p)
+ {
+ if (! match_package(*_imp->env, *p->first, e))
+ continue;
+
+ UseFlagWithStateMap::const_iterator i(p->second.first.find(f));
+ if (p->second.first.end() != i)
+ result = i->second;
+
+ if (use_unspecified == result)
+ for (MinusStarPrefixList::const_iterator m(p->second.second.begin()), m_end(p->second.second.end()) ;
+ m != m_end ; ++m)
+ {
+ if (m->empty() && ignore_empty_minus_star)
+ continue;
+
+ if (0 == m->compare(0, m->length(), stringify(f), 0, m->length()))
+ {
+ result = use_disabled;
+ break;
+ }
+ }
+ }
+ }
+
+ if (use_unspecified != result)
+ return result;
+
+ /* next: named sets */
+ for (Sets::iterator r(_imp->sets.begin()), r_end(_imp->sets.end()) ; r != r_end ; ++r)
+ {
+ if (! r->second.first)
+ {
+ r->second.first = _imp->env->set(r->first);
+ if (! r->second.first)
+ {
+ Log::get_instance()->message(ll_warning, lc_no_context) << "Set name '"
+ << r->first << "' does not exist";
+ r->second.first.reset(new AllDepSpec);
+ }
+ }
+
+ if (! match_package_in_heirarchy(*_imp->env, *r->second.first, e))
+ continue;
+
+ UseFlagWithStateMap::const_iterator i(r->second.second.first.find(f));
+ if (r->second.second.first.end() != i)
+ result = i->second;
+
+ if (use_unspecified == result)
+ for (MinusStarPrefixList::const_iterator m(r->second.second.second.begin()), m_end(r->second.second.second.end()) ;
+ m != m_end ; ++m)
+ {
+ if (m->empty() && ignore_empty_minus_star)
+ continue;
+
+ if (0 == m->compare(0, m->length(), stringify(f), 0, m->length()))
+ {
+ result = use_disabled;
+ break;
+ }
+ }
+ }
+
+ if (use_unspecified != result)
+ return result;
+
+ /* last: unspecific */
+
+ for (Unqualified::const_iterator p(_imp->unqualified.begin()), p_end(_imp->unqualified.end()) ; p != p_end ; ++p)
+ {
+ if (! match_package(*_imp->env, *p->first, e))
+ continue;
+
+ UseFlagWithStateMap::const_iterator i(p->second.first.find(f));
+ if (p->second.first.end() != i)
+ result = i->second;
+
+ if (use_unspecified == result)
+ for (MinusStarPrefixList::const_iterator m(p->second.second.begin()), m_end(p->second.second.end()) ;
+ m != m_end ; ++m)
+ {
+ if (m->empty() && ignore_empty_minus_star)
+ continue;
+
+ if (0 == m->compare(0, m->length(), stringify(f), 0, m->length()))
+ {
+ result = use_disabled;
+ break;
+ }
+ }
+ }
+
+ return result;
+}
+
+std::tr1::shared_ptr<const UseFlagNameCollection>
+UseConf::known_use_expand_names(const UseFlagName & prefix, const PackageDatabaseEntry & e) const
+{
+ Context context("When loading known use expand names for prefix '" + stringify(prefix) + ":");
+
+ std::tr1::shared_ptr<UseFlagNameCollection> result(new UseFlagNameCollection::Concrete);
+ std::string prefix_lower;
+ std::transform(prefix.data().begin(), prefix.data().end(), std::back_inserter(prefix_lower), &::tolower);
+
+ Qualified::const_iterator q(_imp->qualified.find(e.name));
+ if (_imp->qualified.end() != q)
+ for (PDSWithUseInfoList::const_iterator p(q->second.begin()), p_end(q->second.end()) ; p != p_end ; ++p)
+ {
+ if (! match_package(*_imp->env, *p->first, e))
+ continue;
+
+ for (UseFlagWithStateMap::const_iterator i(p->second.first.begin()), i_end(p->second.first.end()) ;
+ i != i_end ; ++i)
+ if (0 == i->first.data().compare(0, i->first.data().length(), stringify(prefix_lower), 0, i->first.data().length()))
+ result->insert(i->first);
+ }
+
+ for (Sets::iterator r(_imp->sets.begin()), r_end(_imp->sets.end()) ; r != r_end ; ++r)
+ {
+ if (! r->second.first)
+ {
+ r->second.first = _imp->env->set(r->first);
+ if (! r->second.first)
+ {
+ Log::get_instance()->message(ll_warning, lc_no_context) << "Set name '"
+ << r->first << "' does not exist";
+ r->second.first.reset(new AllDepSpec);
+ }
+ }
+
+ if (! match_package_in_heirarchy(*_imp->env, *r->second.first, e))
+ continue;
+
+ for (UseFlagWithStateMap::const_iterator i(r->second.second.first.begin()), i_end(r->second.second.first.end()) ;
+ i != i_end ; ++i)
+ if (0 == i->first.data().compare(0, i->first.data().length(), stringify(prefix_lower), 0, i->first.data().length()))
+ result->insert(i->first);
+ }
+
+ for (Unqualified::const_iterator p(_imp->unqualified.begin()), p_end(_imp->unqualified.end()) ; p != p_end ; ++p)
+ {
+ if (! match_package(*_imp->env, *p->first, e))
+ continue;
+
+ for (UseFlagWithStateMap::const_iterator i(p->second.first.begin()), i_end(p->second.first.end()) ;
+ i != i_end ; ++i)
+ if (0 == i->first.data().compare(0, i->first.data().length(), stringify(prefix_lower), 0, i->first.data().length()))
+ result->insert(i->first);
+ }
+
+ return result;
+}
+
diff --git a/paludis/environments/paludis/use_conf.hh b/paludis/environments/paludis/use_conf.hh
new file mode 100644
index 0000000..f4c1f94
--- /dev/null
+++ b/paludis/environments/paludis/use_conf.hh
@@ -0,0 +1,52 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 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
+ * 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_PALUDIS_ENVIRONMENTS_PALUDIS_USE_CONF_HH
+#define PALUDIS_GUARD_PALUDIS_PALUDIS_ENVIRONMENTS_PALUDIS_USE_CONF_HH 1
+
+#include <paludis/util/private_implementation_pattern.hh>
+#include <paludis/util/instantiation_policy.hh>
+#include <paludis/config_file.hh>
+#include <paludis/name.hh>
+
+namespace paludis
+{
+ class PaludisEnvironment;
+ class PackageDatabaseEntry;
+
+ class UseConf :
+ private PrivateImplementationPattern<UseConf>,
+ private InstantiationPolicy<UseConf, instantiation_method::NonCopyableTag>
+ {
+ public:
+ UseConf(const PaludisEnvironment * const);
+ ~UseConf();
+
+ void add(const FSEntry &);
+
+ UseFlagState query(const UseFlagName &, const PackageDatabaseEntry &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ std::tr1::shared_ptr<const UseFlagNameCollection> known_use_expand_names(
+ const UseFlagName &, const PackageDatabaseEntry &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+ };
+}
+
+#endif
diff --git a/paludis/environments/portage/portage_environment.cc b/paludis/environments/portage/portage_environment.cc
index 4894236..e1ade6c 100644
--- a/paludis/environments/portage/portage_environment.cc
+++ b/paludis/environments/portage/portage_environment.cc
@@ -29,6 +29,7 @@
#include <paludis/config_file.hh>
#include <paludis/hooker.hh>
#include <paludis/match_package.hh>
+#include <paludis/package_database.hh>
#include <algorithm>
#include <tr1/functional>
#include <functional>
@@ -74,11 +75,14 @@ namespace paludis
int overlay_importance;
- Implementation(const std::string & s) :
+ std::tr1::shared_ptr<PackageDatabase> package_database;
+
+ Implementation(Environment * const e, const std::string & s) :
conf_dir(FSEntry(s.empty() ? "/" : s) / SYSCONFDIR),
paludis_command("paludis"),
done_hooks(false),
- overlay_importance(10)
+ overlay_importance(10),
+ package_database(new PackageDatabase(e))
{
}
@@ -143,8 +147,7 @@ namespace
}
PortageEnvironment::PortageEnvironment(const std::string & s) :
- Environment(std::tr1::shared_ptr<PackageDatabase>(new PackageDatabase(this))),
- PrivateImplementationPattern<PortageEnvironment>(new Implementation<PortageEnvironment>(s))
+ PrivateImplementationPattern<PortageEnvironment>(new Implementation<PortageEnvironment>(this, s))
{
using namespace std::tr1::placeholders;
@@ -223,8 +226,8 @@ PortageEnvironment::PortageEnvironment(const std::string & s) :
if ((_imp->conf_dir / "portage" / "mirrors").exists())
{
- LineConfigFile mirrors(_imp->conf_dir / "portage" / "mirrors", LineConfigFileOptions());
- for (LineConfigFile::Iterator line(mirrors.begin()), line_end(mirrors.end()) ;
+ LineConfigFile m(_imp->conf_dir / "portage" / "mirrors", LineConfigFileOptions());
+ for (LineConfigFile::Iterator line(m.begin()), line_end(m.end()) ;
line != line_end ; ++line)
{
std::vector<std::string> tokens;
@@ -412,16 +415,16 @@ PortageEnvironment::~PortageEnvironment()
}
bool
-PortageEnvironment::query_use(const UseFlagName & f, const PackageDatabaseEntry * e) const
+PortageEnvironment::query_use(const UseFlagName & f, const PackageDatabaseEntry & e) const
{
/* first check package database use masks... */
- const Repository * const repo((e ? package_database()->fetch_repository(e->repository).get() : 0));
+ std::tr1::shared_ptr<const Repository> repo(package_database()->fetch_repository(e.repository));
- if (repo && repo->use_interface)
+ if (repo->use_interface)
{
- if (repo->use_interface->query_use_mask(f, e))
+ if (repo->use_interface->query_use_mask(f, &e))
return false;
- if (repo->use_interface->query_use_force(f, e))
+ if (repo->use_interface->query_use_force(f, &e))
return true;
}
@@ -433,19 +436,16 @@ PortageEnvironment::query_use(const UseFlagName & f, const PackageDatabaseEntry
state = use_enabled;
/* check use: per package config */
- if (e)
+ for (PackageUse::const_iterator i(_imp->package_use.begin()), i_end(_imp->package_use.end()) ;
+ i != i_end ; ++i)
{
- for (PackageUse::const_iterator i(_imp->package_use.begin()), i_end(_imp->package_use.end()) ;
- i != i_end ; ++i)
- {
- if (! match_package(*this, *i->first, *e))
- continue;
+ if (! match_package(*this, *i->first, e))
+ continue;
- if (i->second == stringify(f))
- state = use_enabled;
- else if (i->second == "-" + stringify(f))
- state = use_disabled;
- }
+ if (i->second == stringify(f))
+ state = use_enabled;
+ else if (i->second == "-" + stringify(f))
+ state = use_disabled;
}
switch (state)
@@ -473,56 +473,46 @@ PortageEnvironment::set_paludis_command(const std::string & s)
_imp->paludis_command = s;
}
-void
-PortageEnvironment::force_use(std::tr1::shared_ptr<const PackageDepSpec>,
- const UseFlagName &, const UseFlagState)
-{
- throw InternalError(PALUDIS_HERE, "force_use not currently available for PortageEnvironment");
-}
-
-void
-PortageEnvironment::clear_forced_use()
-{
-}
-
bool
-PortageEnvironment::accept_keyword(const KeywordName & k, const PackageDatabaseEntry * const d,
- const bool override_tilde_keywords) const
+PortageEnvironment::accept_keywords(std::tr1::shared_ptr <const KeywordNameCollection> keywords,
+ const PackageDatabaseEntry & d) const
{
bool result(false);
- if (stringify(k) == "*")
+ if (keywords->end() != keywords->find(KeywordName("*")))
return true;
- if (_imp->accept_keywords.end() != _imp->accept_keywords.find(stringify(k)))
- result = true;
-
- if (d)
+ for (KeywordNameCollection::Iterator k(keywords->begin()), k_end(keywords->end()) ;
+ k != k_end ; ++k)
{
+ bool local_result(false);
+
+ if (_imp->accept_keywords.end() != _imp->accept_keywords.find(stringify(*k)))
+ local_result = true;
+
for (PackageKeywords::const_iterator i(_imp->package_keywords.begin()), i_end(_imp->package_keywords.end()) ;
i != i_end ; ++i)
{
- if (! match_package(*this, *i->first, *d))
+ if (! match_package(*this, *i->first, d))
continue;
- if (i->second == stringify(k))
- result = true;
- else if (i->second == "-" + stringify(k))
- result = false;
+ if (i->second == stringify(*k))
+ local_result = true;
+ else if (i->second == "-" + stringify(*k))
+ local_result = false;
else if (i->second == "-*")
- result = false;
+ local_result = false;
else if (i->second == "**")
- result = true;
+ local_result = true;
}
- }
- if ((! result) && override_tilde_keywords && ('~' == stringify(k).at(0)))
- result = accept_keyword(KeywordName(stringify(k).substr(1)), d, false);
+ result |= local_result;
+ }
return result;
}
-FSEntry
+const FSEntry
PortageEnvironment::root() const
{
if (_imp->vars->get("ROOT").empty())
@@ -532,7 +522,7 @@ PortageEnvironment::root() const
}
bool
-PortageEnvironment::query_user_masks(const PackageDatabaseEntry & e) const
+PortageEnvironment::masked_by_user(const PackageDatabaseEntry & e) const
{
for (PackageMask::const_iterator i(_imp->package_mask.begin()), i_end(_imp->package_mask.end()) ;
i != i_end ; ++i)
@@ -543,7 +533,7 @@ PortageEnvironment::query_user_masks(const PackageDatabaseEntry & e) const
}
bool
-PortageEnvironment::query_user_unmasks(const PackageDatabaseEntry & e) const
+PortageEnvironment::unmasked_by_user(const PackageDatabaseEntry & e) const
{
for (PackageUnmask::const_iterator i(_imp->package_unmask.begin()), i_end(_imp->package_unmask.end()) ;
i != i_end ; ++i)
@@ -555,7 +545,7 @@ PortageEnvironment::query_user_unmasks(const PackageDatabaseEntry & e) const
std::tr1::shared_ptr<const UseFlagNameCollection>
PortageEnvironment::known_use_expand_names(const UseFlagName & prefix,
- const PackageDatabaseEntry * pde) const
+ const PackageDatabaseEntry & pde) const
{
Context context("When loading known use expand names for prefix '" + stringify(prefix) + ":");
@@ -568,22 +558,18 @@ PortageEnvironment::known_use_expand_names(const UseFlagName & prefix,
if (0 == i->compare(0, prefix_lower.length(), prefix_lower, 0, prefix_lower.length()))
result->insert(UseFlagName(*i));
- if (pde)
+ for (PackageUse::const_iterator i(_imp->package_use.begin()), i_end(_imp->package_use.end()) ;
+ i != i_end ; ++i)
{
- for (PackageUse::const_iterator i(_imp->package_use.begin()), i_end(_imp->package_use.end()) ;
- i != i_end ; ++i)
- {
- if (! match_package(*this, *i->first, *pde))
- continue;
+ if (! match_package(*this, *i->first, pde))
+ continue;
- if (0 == i->second.compare(0, prefix_lower.length(), prefix_lower, 0, prefix_lower.length()))
- result->insert(UseFlagName(i->second));
- }
+ if (0 == i->second.compare(0, prefix_lower.length(), prefix_lower, 0, prefix_lower.length()))
+ result->insert(UseFlagName(i->second));
}
- Log::get_instance()->message(ll_debug, lc_no_context, "PortageEnvironment::known_use_expand_names("
- + stringify(prefix) + ", " + (pde ? stringify(*pde) : stringify("0")) + ") -> ("
- + join(result->begin(), result->end(), ", ") + ")");
+ Log::get_instance()->message(ll_debug, lc_no_context) << "PortageEnvironment::known_use_expand_names("
+ << prefix << ", " << pde << ") -> (" << join(result->begin(), result->end(), ", ") << ")";
return result;
}
@@ -604,36 +590,50 @@ PortageEnvironment::perform_hook(const Hook & hook) const
return _imp->hooker->perform_hook(hook);
}
-std::string
+std::tr1::shared_ptr<const FSEntryCollection>
PortageEnvironment::hook_dirs() const
{
_imp->need_hook_dirs();
- return join(_imp->hook_dirs.begin(), _imp->hook_dirs.end(), " ");
+ std::tr1::shared_ptr<FSEntryCollection> result(new FSEntryCollection::Concrete);
+ std::copy(_imp->hook_dirs.begin(), _imp->hook_dirs.end(), result->inserter());
+ return result;
}
-std::string
+std::tr1::shared_ptr<const FSEntryCollection>
PortageEnvironment::bashrc_files() const
{
- return stringify(_imp->conf_dir / "make.globals") + " " +
- stringify(_imp->conf_dir / "make.conf") + " " +
- stringify(FSEntry(LIBEXECDIR) / "paludis" / "environments" / "portage" / "bashrc");
+ std::tr1::shared_ptr<FSEntryCollection> result(new FSEntryCollection::Concrete);
+ result->push_back(_imp->conf_dir / "make.globals");
+ result->push_back(_imp->conf_dir / "make.conf");
+ result->push_back(FSEntry(LIBEXECDIR) / "paludis" / "environments" / "portage" / "bashrc");
+ return result;
}
-PortageEnvironment::MirrorIterator
-PortageEnvironment::begin_mirrors(const std::string & m) const
+bool
+PortageEnvironment::accept_breaks_portage(const PackageDatabaseEntry &) const
{
- return MirrorIterator(_imp->mirrors.lower_bound(m));
+ return false;
}
-PortageEnvironment::MirrorIterator
-PortageEnvironment::end_mirrors(const std::string & m) const
+std::tr1::shared_ptr<PackageDatabase>
+PortageEnvironment::package_database()
{
- return MirrorIterator(_imp->mirrors.upper_bound(m));
+ return _imp->package_database;
}
-bool
-PortageEnvironment::accept_breaks_portage() const
+std::tr1::shared_ptr<const PackageDatabase>
+PortageEnvironment::package_database() const
{
- return false;
+ return _imp->package_database;
+}
+
+std::tr1::shared_ptr<const MirrorsCollection>
+PortageEnvironment::mirrors(const std::string & m) const
+{
+ std::pair<std::multimap<std::string, std::string>::const_iterator, std::multimap<std::string, std::string>::const_iterator>
+ p(_imp->mirrors.equal_range(m));
+ std::tr1::shared_ptr<MirrorsCollection> result(new MirrorsCollection::Concrete);
+ std::copy(p.first, p.second, transform_inserter(result->inserter(), SelectSecond<std::string, std::string>()));
+ return result;
}
diff --git a/paludis/environments/portage/portage_environment.hh b/paludis/environments/portage/portage_environment.hh
index 980bca9..28a70f0 100644
--- a/paludis/environments/portage/portage_environment.hh
+++ b/paludis/environments/portage/portage_environment.hh
@@ -20,7 +20,7 @@
#ifndef PALUDIS_GUARD_PALUDIS_ENVIRONMENTS_PORTAGE_PORTAGE_ENVIRONMENT_HH
#define PALUDIS_GUARD_PALUDIS_ENVIRONMENTS_PORTAGE_PORTAGE_ENVIRONMENT_HH 1
-#include <paludis/environment.hh>
+#include <paludis/environment_implementation.hh>
namespace paludis
{
@@ -50,7 +50,7 @@ namespace paludis
* \nosubgrouping
*/
class PortageEnvironment :
- public Environment,
+ public EnvironmentImplementation,
private PrivateImplementationPattern<PortageEnvironment>
{
private:
@@ -69,6 +69,19 @@ namespace paludis
template<typename I_>
void _load_atom_file(const FSEntry &, I_, const std::string &);
+ protected:
+ virtual bool accept_keywords(std::tr1::shared_ptr<const KeywordNameCollection>, const PackageDatabaseEntry &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual bool accept_breaks_portage(const PackageDatabaseEntry &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual bool masked_by_user(const PackageDatabaseEntry &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual bool unmasked_by_user(const PackageDatabaseEntry &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
public:
///\name Basic operations
///\{
@@ -78,51 +91,38 @@ namespace paludis
///\}
- virtual bool query_use(const UseFlagName &, const PackageDatabaseEntry *) const
- PALUDIS_ATTRIBUTE((warn_unused_result));
-
- virtual void force_use(std::tr1::shared_ptr<const PackageDepSpec>, const UseFlagName &,
- const UseFlagState);
-
- virtual void clear_forced_use();
-
- virtual bool accept_keyword(const KeywordName &, const PackageDatabaseEntry * const,
- const bool override_tilde_keywords = false) const
+ virtual bool query_use(const UseFlagName &, const PackageDatabaseEntry &) const
PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual std::tr1::shared_ptr<const UseFlagNameCollection> known_use_expand_names(const UseFlagName &,
- const PackageDatabaseEntry *) const
+ virtual std::tr1::shared_ptr<const UseFlagNameCollection> known_use_expand_names(
+ const UseFlagName &, const PackageDatabaseEntry &) const
PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual bool query_user_masks(const PackageDatabaseEntry &) const
+ virtual std::tr1::shared_ptr<const FSEntryCollection> bashrc_files() const
PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual bool query_user_unmasks(const PackageDatabaseEntry &) const
+ virtual std::tr1::shared_ptr<const FSEntryCollection> hook_dirs() const
PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual std::string paludis_command() const
+ virtual const FSEntry root() const
PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual void set_paludis_command(const std::string &);
-
- virtual MirrorIterator begin_mirrors(const std::string & mirror) const
+ virtual std::tr1::shared_ptr<const MirrorsCollection> mirrors(const std::string &) const
PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual MirrorIterator end_mirrors(const std::string & mirror) const
+ virtual int perform_hook(const Hook &) const
PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual FSEntry root() const
+ virtual std::tr1::shared_ptr<PackageDatabase> package_database()
PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual int perform_hook(const Hook & hook) const PALUDIS_ATTRIBUTE((warn_unused_result));
-
- virtual std::string hook_dirs() const
+ virtual std::tr1::shared_ptr<const PackageDatabase> package_database() const
PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual std::string bashrc_files() const
+ virtual std::string paludis_command() const
PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual bool accept_breaks_portage() const;
+ virtual void set_paludis_command(const std::string &);
};
}
diff --git a/paludis/environments/portage/portage_environment_TEST.cc b/paludis/environments/portage/portage_environment_TEST.cc
index a1a2e88..ded6bcc 100644
--- a/paludis/environments/portage/portage_environment_TEST.cc
+++ b/paludis/environments/portage/portage_environment_TEST.cc
@@ -20,10 +20,35 @@
#include "portage_environment.hh"
#include <test/test_runner.hh>
#include <test/test_framework.hh>
+#include <paludis/package_database_entry.hh>
+#include <paludis/util/collection_concrete.hh>
using namespace paludis;
using namespace test;
+namespace
+{
+ class TestPortageEnvironment :
+ public PortageEnvironment
+ {
+ public:
+ using PortageEnvironment::accept_keywords;
+
+ TestPortageEnvironment(const std::string & e) :
+ PortageEnvironment(e)
+ {
+ }
+ };
+
+ bool accept_keyword(const TestPortageEnvironment & env,
+ const KeywordName & k, const PackageDatabaseEntry & e)
+ {
+ std::tr1::shared_ptr<KeywordNameCollection> kk(new KeywordNameCollection::Concrete);
+ kk->insert(k);
+ return env.accept_keywords(kk, e);
+ }
+}
+
namespace test_cases
{
struct QueryUseTest : TestCase
@@ -34,20 +59,22 @@ namespace test_cases
{
PortageEnvironment env("portage_environment_TEST_dir/query_use");
- TEST_CHECK(env.query_use(UseFlagName("one"), 0));
- TEST_CHECK(env.query_use(UseFlagName("two"), 0));
- TEST_CHECK(! env.query_use(UseFlagName("three"), 0));
- TEST_CHECK(! env.query_use(UseFlagName("four"), 0));
- TEST_CHECK(! env.query_use(UseFlagName("five"), 0));
+ PackageDatabaseEntry x(QualifiedPackageName("x/x"), VersionSpec("0"), RepositoryName("repo"));
+
+ TEST_CHECK(env.query_use(UseFlagName("one"), x));
+ TEST_CHECK(env.query_use(UseFlagName("two"), x));
+ TEST_CHECK(! env.query_use(UseFlagName("three"), x));
+ TEST_CHECK(! env.query_use(UseFlagName("four"), x));
+ TEST_CHECK(! env.query_use(UseFlagName("five"), x));
PackageDatabaseEntry d(QualifiedPackageName("app/one"), VersionSpec("1"),
RepositoryName("repo"));
- TEST_CHECK(! env.query_use(UseFlagName("one"), &d));
- TEST_CHECK(env.query_use(UseFlagName("two"), &d));
- TEST_CHECK(! env.query_use(UseFlagName("three"), &d));
- TEST_CHECK(env.query_use(UseFlagName("four"), &d));
- TEST_CHECK(! env.query_use(UseFlagName("five"), &d));
+ TEST_CHECK(! env.query_use(UseFlagName("one"), d));
+ TEST_CHECK(env.query_use(UseFlagName("two"), d));
+ TEST_CHECK(! env.query_use(UseFlagName("three"), d));
+ TEST_CHECK(env.query_use(UseFlagName("four"), d));
+ TEST_CHECK(! env.query_use(UseFlagName("five"), d));
}
} test_query_use;
@@ -57,33 +84,35 @@ namespace test_cases
void run()
{
- PortageEnvironment env("portage_environment_TEST_dir/accept_keywords");
+ TestPortageEnvironment env("portage_environment_TEST_dir/accept_keywords");
+
+ PackageDatabaseEntry x(QualifiedPackageName("x/x"), VersionSpec("0"), RepositoryName("repo"));
- TEST_CHECK(env.accept_keyword(KeywordName("arch"), 0));
- TEST_CHECK(env.accept_keyword(KeywordName("other_arch"), 0));
- TEST_CHECK(! env.accept_keyword(KeywordName("~arch"), 0));
+ TEST_CHECK(accept_keyword(env, KeywordName("arch"), x));
+ TEST_CHECK(accept_keyword(env, KeywordName("other_arch"), x));
+ TEST_CHECK(! accept_keyword(env, KeywordName("~arch"), x));
PackageDatabaseEntry d1(QualifiedPackageName("app/one"), VersionSpec("1"),
RepositoryName("repo"));
- TEST_CHECK(env.accept_keyword(KeywordName("arch"), &d1));
- TEST_CHECK(env.accept_keyword(KeywordName("other_arch"), &d1));
- TEST_CHECK(env.accept_keyword(KeywordName("~arch"), &d1));
+ TEST_CHECK(accept_keyword(env, KeywordName("arch"), d1));
+ TEST_CHECK(accept_keyword(env, KeywordName("other_arch"), d1));
+ TEST_CHECK(accept_keyword(env, KeywordName("~arch"), d1));
PackageDatabaseEntry d2(QualifiedPackageName("app/two"), VersionSpec("1"),
RepositoryName("repo"));
- TEST_CHECK(env.accept_keyword(KeywordName("other_arch"), &d2));
- TEST_CHECK(env.accept_keyword(KeywordName("arch"), &d2));
- TEST_CHECK(env.accept_keyword(KeywordName("~arch"), &d2));
+ TEST_CHECK(accept_keyword(env, KeywordName("other_arch"), d2));
+ TEST_CHECK(accept_keyword(env, KeywordName("arch"), d2));
+ TEST_CHECK(accept_keyword(env, KeywordName("~arch"), d2));
PackageDatabaseEntry d3(QualifiedPackageName("app/three"), VersionSpec("1"),
RepositoryName("repo"));
- TEST_CHECK(! env.accept_keyword(KeywordName("other_arch"), &d3));
- TEST_CHECK(! env.accept_keyword(KeywordName("arch"), &d3));
- TEST_CHECK(! env.accept_keyword(KeywordName("~arch"), &d3));
+ TEST_CHECK(! accept_keyword(env, KeywordName("other_arch"), d3));
+ TEST_CHECK(! accept_keyword(env, KeywordName("arch"), d3));
+ TEST_CHECK(! accept_keyword(env, KeywordName("~arch"), d3));
PackageDatabaseEntry d4(QualifiedPackageName("app/four"), VersionSpec("1"),
RepositoryName("repo"));
- TEST_CHECK(env.accept_keyword(KeywordName("fred"), &d4));
+ TEST_CHECK(accept_keyword(env, KeywordName("fred"), d4));
}
} test_accept_keywords;
diff --git a/paludis/environments/test/test_environment.cc b/paludis/environments/test/test_environment.cc
index 42c9cb1..e8ad882 100644
--- a/paludis/environments/test/test_environment.cc
+++ b/paludis/environments/test/test_environment.cc
@@ -19,79 +19,69 @@
#include <paludis/environments/test/test_environment.hh>
#include <paludis/util/collection_concrete.hh>
-#include <map>
+#include <paludis/package_database.hh>
#include <string>
-/** \file
- * Implementation of TestEnvironment.
- *
- * \ingroup grptestenvironment
- */
-
using namespace paludis;
-TestEnvironment::TestEnvironment() :
- Environment(std::tr1::shared_ptr<PackageDatabase>(new PackageDatabase(this)))
+namespace paludis
{
+ template<>
+ struct Implementation<TestEnvironment>
+ {
+ std::tr1::shared_ptr<PackageDatabase> package_database;
+ std::string paludis_command;
+
+ Implementation(Environment * const e) :
+ package_database(new PackageDatabase(e)),
+ paludis_command("")
+ {
+ }
+ };
}
-bool
-TestEnvironment::query_use(const UseFlagName & u, const PackageDatabaseEntry *) const
-{
- return (std::string::npos != u.data().find("enabled"));
-}
-
-bool
-TestEnvironment::accept_keyword(const KeywordName & k, const PackageDatabaseEntry * const,
- const bool override_tilde_keywords) const
+TestEnvironment::TestEnvironment() :
+ PrivateImplementationPattern<TestEnvironment>(new Implementation<TestEnvironment>(this))
{
- return k == KeywordName("test") || (override_tilde_keywords && k == KeywordName("~test"));
}
-bool
-TestEnvironment::accept_license(const std::string &, const PackageDatabaseEntry * const) const
+TestEnvironment::~TestEnvironment()
{
- return true;
}
bool
-TestEnvironment::query_user_masks(const PackageDatabaseEntry &) const
+TestEnvironment::query_use(const UseFlagName & u, const PackageDatabaseEntry &) const
{
- return false;
+ return (std::string::npos != u.data().find("enabled"));
}
bool
-TestEnvironment::query_user_unmasks(const PackageDatabaseEntry &) const
+TestEnvironment::accept_keywords(std::tr1::shared_ptr<const KeywordNameCollection> k, const PackageDatabaseEntry &) const
{
- return false;
+ return k->end() != k->find(KeywordName("test")) || k->end() != k->find(KeywordName("*"));
}
-namespace
+std::tr1::shared_ptr<PackageDatabase>
+TestEnvironment::package_database()
{
- static const std::multimap<std::string, std::string> test_environment_mirrors;
+ return _imp->package_database;
}
-TestEnvironment::MirrorIterator
-TestEnvironment::begin_mirrors(const std::string &) const
+std::tr1::shared_ptr<const PackageDatabase>
+TestEnvironment::package_database() const
{
- return MirrorIterator(test_environment_mirrors.begin());
+ return _imp->package_database;
}
-TestEnvironment::MirrorIterator
-TestEnvironment::end_mirrors(const std::string &) const
-{
- return MirrorIterator(test_environment_mirrors.end());
-}
-
-void
-TestEnvironment::force_use(std::tr1::shared_ptr<const PackageDepSpec>, const UseFlagName &,
- const UseFlagState)
+std::string
+TestEnvironment::paludis_command() const
{
- throw InternalError(PALUDIS_HERE, "force_use not currently available for TestEnvironment");
+ return _imp->paludis_command;
}
void
-TestEnvironment::clear_forced_use()
+TestEnvironment::set_paludis_command(const std::string & s)
{
+ _imp->paludis_command = s;
}
diff --git a/paludis/environments/test/test_environment.hh b/paludis/environments/test/test_environment.hh
index 9f7aadd..ff9d11a 100644
--- a/paludis/environments/test/test_environment.hh
+++ b/paludis/environments/test/test_environment.hh
@@ -21,7 +21,8 @@
#define PALUDIS_GUARD_PALUDIS_TEST_ENVIRONMENT_HH 1
#include <paludis/package_database_entry.hh>
-#include <paludis/environment.hh>
+#include <paludis/environment_implementation.hh>
+#include <paludis/util/private_implementation_pattern.hh>
/** \file
* Declarations for the TestEnvironment class.
@@ -38,61 +39,37 @@ namespace paludis
*
* \ingroup grptestenvironment
*/
- class PALUDIS_VISIBLE TestEnvironment : public Environment
+ class PALUDIS_VISIBLE TestEnvironment :
+ private PrivateImplementationPattern<TestEnvironment>,
+ public EnvironmentImplementation
{
- private:
- std::string _paludis_command;
+ protected:
+ virtual bool accept_keywords(std::tr1::shared_ptr<const KeywordNameCollection>, const PackageDatabaseEntry &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
public:
- /**
- * Constructor.
- */
- TestEnvironment();
-
- virtual bool query_use(const UseFlagName &, const PackageDatabaseEntry *) const;
-
- virtual void force_use(std::tr1::shared_ptr<const PackageDepSpec>, const UseFlagName &,
- const UseFlagState) PALUDIS_ATTRIBUTE((noreturn));
-
- virtual void clear_forced_use();
+ ///\name Basic operations
+ ///\{
- virtual bool accept_keyword(const KeywordName &, const PackageDatabaseEntry * const,
- const bool) const;
+ TestEnvironment();
- virtual bool query_user_masks(const PackageDatabaseEntry &) const;
+ ~TestEnvironment();
- virtual bool query_user_unmasks(const PackageDatabaseEntry &) const;
+ ///\}
- virtual bool accept_license(const std::string &, const PackageDatabaseEntry * const) const;
+ virtual bool query_use(const UseFlagName &, const PackageDatabaseEntry &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual std::string bashrc_files() const
- {
- return "";
- }
+ virtual std::tr1::shared_ptr<PackageDatabase> package_database()
+ PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual std::string hook_dirs() const
- {
- return "";
- }
+ virtual std::tr1::shared_ptr<const PackageDatabase> package_database() const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
virtual std::string paludis_command() const
- {
- return _paludis_command;
- }
-
- virtual void set_paludis_command(const std::string & c)
- {
- _paludis_command = c;
- }
-
- virtual int perform_hook(const Hook &) const PALUDIS_ATTRIBUTE((warn_unused_result))
- {
- return 0;
- }
-
- virtual MirrorIterator begin_mirrors(const std::string &) const;
+ PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual MirrorIterator end_mirrors(const std::string &) const;
+ virtual void set_paludis_command(const std::string &);
};
}
diff --git a/paludis/files.m4 b/paludis/files.m4
index 9bb9fa9..9131ee8 100644
--- a/paludis/files.m4
+++ b/paludis/files.m4
@@ -15,8 +15,10 @@ add(`dep_spec', `hh', `cc', `se', `test')
add(`dep_spec_flattener', `hh', `cc')
add(`dep_spec_pretty_printer', `hh', `cc')
add(`dep_tag', `hh', `cc', `sr')
-add(`environment', `hh', `cc')
+add(`environment', `hh', `cc', `se')
+add(`environment_implementation', `hh', `cc', `test')
add(`hashed_containers', `hhx', `cc', `test')
+add(`hook', `hh', `cc')
add(`hooker', `hh', `cc', `test', `testscript')
add(`host_tuple_name', `hh', `cc', `sr', `test')
add(`mask_reasons', `hh', `cc', `se')
@@ -28,7 +30,7 @@ add(`paludis', `hh', `cc')
add(`portage_dep_lexer', `hh', `cc', `test')
add(`portage_dep_parser', `hh', `cc', `test')
add(`query', `hh', `cc')
-add(`repository', `hh', `cc', `sr')
+add(`repository', `hh', `fwd', `cc', `sr')
add(`repository_name_cache', `hh', `cc', `test', `testscript')
add(`set_file', `hh', `cc', `se', `sr', `test', `testscript')
add(`syncer', `hh', `cc', `sr')
diff --git a/paludis/hook.cc b/paludis/hook.cc
new file mode 100644
index 0000000..86ef44f
--- /dev/null
+++ b/paludis/hook.cc
@@ -0,0 +1,80 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2005, 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
+ * 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 "hook.hh"
+#include <map>
+
+using namespace paludis;
+
+namespace paludis
+{
+ template<>
+ struct Implementation<Hook>
+ {
+ std::string name;
+ std::map<std::string, std::string> extra_env;
+
+ Implementation(const std::string & n, const std::map<std::string, std::string> & e) :
+ name(n),
+ extra_env(e)
+ {
+ }
+ };
+}
+
+Hook::Hook(const std::string & n) :
+ PrivateImplementationPattern<Hook>(new Implementation<Hook>(n, std::map<std::string, std::string>()))
+{
+}
+
+Hook::Hook(const Hook & h) :
+ PrivateImplementationPattern<Hook>(new Implementation<Hook>(h._imp->name, h._imp->extra_env))
+{
+}
+
+Hook::~Hook()
+{
+}
+
+Hook
+Hook::operator() (const std::string & k, const std::string & v) const
+{
+ Hook result(*this);
+ result._imp->extra_env.insert(std::make_pair(k, v));
+ return result;
+}
+
+Hook::Iterator
+Hook::begin() const
+{
+ return Iterator(_imp->extra_env.begin());
+}
+
+Hook::Iterator
+Hook::end() const
+{
+ return Iterator(_imp->extra_env.end());
+}
+
+std::string
+Hook::name() const
+{
+ return _imp->name;
+}
+
diff --git a/paludis/hook.hh b/paludis/hook.hh
new file mode 100644
index 0000000..0ac74ed
--- /dev/null
+++ b/paludis/hook.hh
@@ -0,0 +1,75 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2005, 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
+ * 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_HOOK_HH
+#define PALUDIS_GUARD_PALUDIS_HOOK_HH 1
+
+#include <paludis/util/attributes.hh>
+#include <paludis/util/private_implementation_pattern.hh>
+#include <utility>
+#include <string>
+#include <libwrapiter/libwrapiter_forward_iterator.hh>
+
+namespace paludis
+{
+ /**
+ * Represents the data for an Environment hook call.
+ *
+ * \ingroup grpenvironment
+ * \nosubgrouping
+ */
+ class Hook :
+ private PrivateImplementationPattern<Hook>
+ {
+ public:
+ ///\name Basic operations
+ ///\{
+
+ Hook(const std::string & name);
+
+ Hook(const Hook &);
+
+ ~Hook();
+
+ ///\}
+
+ /// Add data to the hook.
+ Hook operator() (const std::string & key, const std::string & value) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ ///\name Iterate over environment data
+ ///\{
+
+ typedef libwrapiter::ForwardIterator<Hook, const std::pair<const std::string, std::string> > Iterator;
+
+ Iterator begin() const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ Iterator end() const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ ///\}
+
+ /// Our name.
+ std::string name() const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+ };
+}
+
+#endif
diff --git a/paludis/hooker.cc b/paludis/hooker.cc
index 5fa7b9f..532606c 100644
--- a/paludis/hooker.cc
+++ b/paludis/hooker.cc
@@ -19,7 +19,9 @@
#include "hooker.hh"
#include <paludis/environment.hh>
+#include <paludis/hook.hh>
#include <paludis/hashed_containers.hh>
+#include <paludis/package_database.hh>
#include <paludis/util/collection_concrete.hh>
#include <paludis/util/log.hh>
#include <paludis/util/dir_iterator.hh>
diff --git a/paludis/hooker_TEST.cc b/paludis/hooker_TEST.cc
index 2576cf9..e04dd54 100644
--- a/paludis/hooker_TEST.cc
+++ b/paludis/hooker_TEST.cc
@@ -18,6 +18,7 @@
*/
#include <paludis/hooker.hh>
+#include <paludis/hook.hh>
#include <paludis/environments/test/test_environment.hh>
#include <test/test_runner.hh>
#include <test/test_framework.hh>
diff --git a/paludis/match_package.cc b/paludis/match_package.cc
index c395d89..c2eaeb6 100644
--- a/paludis/match_package.cc
+++ b/paludis/match_package.cc
@@ -18,12 +18,10 @@
*/
#include <paludis/match_package.hh>
-
-/** \file
- * Implementation for match_package.hh.
- *
- * \ingroup grpmatchpackage
- */
+#include <paludis/dep_spec.hh>
+#include <paludis/environment.hh>
+#include <paludis/version_metadata.hh>
+#include <paludis/package_database.hh>
using namespace paludis;
@@ -97,12 +95,12 @@ paludis::match_package(
continue;
case use_enabled:
- if (! env.query_use(u->first, &entry))
+ if (! env.query_use(u->first, entry))
return false;
continue;
case use_disabled:
- if (env.query_use(u->first, &entry))
+ if (env.query_use(u->first, entry))
return false;
continue;
}
diff --git a/paludis/match_package.hh b/paludis/match_package.hh
index 6d30390..5f04647 100644
--- a/paludis/match_package.hh
+++ b/paludis/match_package.hh
@@ -13,12 +13,15 @@
* \ingroup grpmatchpackage
*/
-#include <paludis/dep_spec.hh>
-#include <paludis/environment.hh>
#include <paludis/util/attributes.hh>
namespace paludis
{
+ class Environment;
+ class DepSpec;
+ class PackageDepSpec;
+ class PackageDatabaseEntry;
+
/**
* Return whether the specified spec matches the specified target.
*
diff --git a/paludis/merger/merger.cc b/paludis/merger/merger.cc
index 8078340..ffe052c 100644
--- a/paludis/merger/merger.cc
+++ b/paludis/merger/merger.cc
@@ -24,6 +24,7 @@
#include <paludis/util/log.hh>
#include <paludis/selinux/security_context.hh>
#include <paludis/environment.hh>
+#include <paludis/hook.hh>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
diff --git a/paludis/merger/unmerger.cc b/paludis/merger/unmerger.cc
index fac00b6..5d90c09 100644
--- a/paludis/merger/unmerger.cc
+++ b/paludis/merger/unmerger.cc
@@ -19,6 +19,7 @@
#include "unmerger.hh"
#include <paludis/environment.hh>
+#include <paludis/hook.hh>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
diff --git a/paludis/name.hh b/paludis/name.hh
index ffa833a..6cc6179 100644
--- a/paludis/name.hh
+++ b/paludis/name.hh
@@ -364,6 +364,13 @@ namespace paludis
typedef Validated<std::string, KeywordNameValidator> KeywordName;
/**
+ * Holds a collection of KeywordName instances.
+ *
+ * \ingroup grpnames
+ */
+ typedef SortedCollection<KeywordName> KeywordNameCollection;
+
+ /**
* A USE flag can be on, off or unspecified.
*
* \ingroup grpnames
@@ -413,6 +420,13 @@ namespace paludis
* \ingroup grpnames
*/
typedef Validated<std::string, SetNameValidator> SetName;
+
+ /**
+ * A collection of set names.
+ *
+ * \ingroup grpnames
+ */
+ typedef SortedCollection<SetName> SetNameCollection;
}
#endif
diff --git a/paludis/qa/deps_visible_check.cc b/paludis/qa/deps_visible_check.cc
index 0fd7e72..f8dc4ad 100644
--- a/paludis/qa/deps_visible_check.cc
+++ b/paludis/qa/deps_visible_check.cc
@@ -203,8 +203,54 @@ DepsVisibleCheck::operator() (const PerProfileEbuildCheckData & e) const
{
e.environment->set_accept_unstable(unstable);
- if (e.environment->mask_reasons(ee).any())
- result << Message(qal_skip, "Masked, so skipping checks");
+ MaskReasons m(e.environment->mask_reasons(ee));
+ if (m.any())
+ {
+ std::string reasons;
+ for (MaskReason rr(MaskReason(0)) ; rr < last_mr ;
+ rr = MaskReason(static_cast<int>(rr) + 1))
+ {
+ if (! m[rr])
+ continue;
+
+ switch (rr)
+ {
+ case mr_keyword:
+ reasons.append("K");
+ break;
+ case mr_user_mask:
+ reasons.append("U");
+ break;
+ case mr_profile_mask:
+ reasons.append("P");
+ break;
+ case mr_repository_mask:
+ reasons.append("R");
+ break;
+ case mr_eapi:
+ reasons.append("E");
+ break;
+ case mr_license:
+ reasons.append("L");
+ break;
+ case mr_by_association:
+ reasons.append("A");
+ break;
+ case mr_chost:
+ reasons.append("C");
+ break;
+ case mr_breaks_portage:
+ reasons.append("B");
+ break;
+ case mr_interactive:
+ reasons.append("I");
+ break;
+ case last_mr:
+ break;
+ }
+ }
+ result << Message(qal_skip, "Masked (" + reasons + "), so skipping checks");
+ }
else
{
Checker depend_checker(result, "DEPEND", e.environment, ee, unstable);
diff --git a/paludis/qa/keywords_check.cc b/paludis/qa/keywords_check.cc
index b8d78e3..617f22f 100644
--- a/paludis/qa/keywords_check.cc
+++ b/paludis/qa/keywords_check.cc
@@ -49,7 +49,7 @@ KeywordsCheck::operator() (const EbuildCheckData & e) const
//std::set<KeywordName> keywords(metadata->begin_keywords(), metadata->end_keywords());
std::set<KeywordName> keywords;
WhitespaceTokeniser::get_instance()->tokenise(metadata->ebuild_interface->
- keywords, create_inserter<KeywordName>(std::inserter(keywords, keywords.begin())));
+ keywords_string, create_inserter<KeywordName>(std::inserter(keywords, keywords.begin())));
if (keywords.end() != keywords.find(KeywordName("-*")) &&
keywords.size() == 1)
diff --git a/paludis/repositories/cran/cran_description.cc b/paludis/repositories/cran/cran_description.cc
index 15a0f11..d3f4658 100644
--- a/paludis/repositories/cran/cran_description.cc
+++ b/paludis/repositories/cran/cran_description.cc
@@ -47,7 +47,7 @@ CRANDescription::CRANDescription(const std::string & n, const FSEntry & f, bool
// Fill in default values
metadata->slot = SlotName("0");
- metadata->cran_interface->keywords = std::string("*");
+ metadata->cran_interface->keywords_string = std::string("*");
metadata->eapi = "CRAN-1";
std::string key;
diff --git a/paludis/repositories/cran/cran_installed_repository.cc b/paludis/repositories/cran/cran_installed_repository.cc
index a238794..19a0082 100644
--- a/paludis/repositories/cran/cran_installed_repository.cc
+++ b/paludis/repositories/cran/cran_installed_repository.cc
@@ -21,6 +21,7 @@
#include <paludis/config_file.hh>
#include <paludis/match_package.hh>
#include <paludis/package_database.hh>
+#include <paludis/environment.hh>
#include <paludis/repositories/cran/cran_description.hh>
#include <paludis/repositories/cran/cran_dep_parser.hh>
#include <paludis/repositories/cran/cran_installed_repository.hh>
@@ -523,13 +524,14 @@ CRANInstalledRepository::do_uninstall(const QualifiedPackageName & q, const Vers
stringify(v) + "' because its location ('" + stringify(_imp->location) + "') is not a directory");
std::tr1::shared_ptr<const VersionMetadata> vm(do_version_metadata(q, v));
+ std::tr1::shared_ptr<const FSEntryCollection> bashrc_files(_imp->env->bashrc_files());
Command cmd(Command(LIBEXECDIR "/paludis/cran.bash unmerge")
.with_setenv("PN", vm->cran_interface->package)
.with_setenv("PV", stringify(v))
.with_setenv("PALUDIS_CRAN_LIBRARY", stringify(_imp->location))
.with_setenv("PALUDIS_EBUILD_DIR", std::string(LIBEXECDIR "/paludis/"))
- .with_setenv("PALUDIS_BASHRC_FILES", _imp->env->bashrc_files()));
+ .with_setenv("PALUDIS_BASHRC_FILES", join(bashrc_files->begin(), bashrc_files->end(), " ")));
if (0 != run_command(cmd))
throw PackageUninstallActionError("Couldn't unmerge '" + stringify(q) + "-" + stringify(v) + "'");
@@ -572,7 +574,7 @@ CRANInstalledRepository::do_package_set(const SetName & s) const
{
if (std::string::npos == line->find('/'))
{
- std::tr1::shared_ptr<DepSpec> spec(_imp->env->package_set(SetName(*line)));
+ std::tr1::shared_ptr<DepSpec> spec(_imp->env->set(SetName(*line)));
if (spec)
result->add_child(spec);
else
@@ -604,12 +606,12 @@ CRANInstalledRepository::do_package_set(const SetName & s) const
return std::tr1::shared_ptr<DepSpec>();
}
-std::tr1::shared_ptr<const SetsCollection>
+std::tr1::shared_ptr<const SetNameCollection>
CRANInstalledRepository::sets_list() const
{
Context context("While generating the list of sets:");
- std::tr1::shared_ptr<SetsCollection> result(new SetsCollection::Concrete);
+ std::tr1::shared_ptr<SetNameCollection> result(new SetNameCollection::Concrete);
result->insert(SetName("everything"));
result->insert(SetName("world"));
return result;
@@ -741,6 +743,8 @@ CRANInstalledRepository::want_pre_post_phases() const
void
CRANInstalledRepository::merge(const MergeOptions & m)
{
+ std::tr1::shared_ptr<const FSEntryCollection> bashrc_files(_imp->env->bashrc_files());
+
Command cmd = Command(LIBEXECDIR "/paludis/cran.bash merge")
.with_setenv("IMAGE", stringify(m.image_dir))
.with_setenv("PN", stringify(m.package.name.package))
@@ -748,7 +752,7 @@ CRANInstalledRepository::merge(const MergeOptions & m)
.with_setenv("PALUDIS_CRAN_LIBRARY", stringify(_imp->location))
.with_setenv("PALUDIS_EBUILD_DIR", std::string(LIBEXECDIR "/paludis/"))
.with_setenv("PALUDIS_EBUILD_LOG_LEVEL", stringify(Log::get_instance()->log_level()))
- .with_setenv("PALUDIS_BASHRC_FILES", _imp->env->bashrc_files())
+ .with_setenv("PALUDIS_BASHRC_FILES", join(bashrc_files->begin(), bashrc_files->end(), " "))
.with_setenv("ROOT", stringify(root()))
.with_setenv("REPOSITORY", stringify(m.package.repository));
diff --git a/paludis/repositories/cran/cran_installed_repository.hh b/paludis/repositories/cran/cran_installed_repository.hh
index 5dbda46..3890640 100644
--- a/paludis/repositories/cran/cran_installed_repository.hh
+++ b/paludis/repositories/cran/cran_installed_repository.hh
@@ -86,7 +86,7 @@ namespace paludis
virtual std::tr1::shared_ptr<DepSpec> do_package_set(const SetName &) const;
- virtual std::tr1::shared_ptr<const SetsCollection> sets_list() const;
+ virtual std::tr1::shared_ptr<const SetNameCollection> sets_list() const;
/**
* Add a string to world.
diff --git a/paludis/repositories/cran/cran_repository.cc b/paludis/repositories/cran/cran_repository.cc
index dc59cf5..c083ef4 100644
--- a/paludis/repositories/cran/cran_repository.cc
+++ b/paludis/repositories/cran/cran_repository.cc
@@ -498,6 +498,8 @@ CRANRepository::do_install(const QualifiedPackageName &q, const VersionSpec &vn,
std::string p(vm->cran_interface->package);
std::string v(vm->cran_interface->version);
+ std::tr1::shared_ptr<const FSEntryCollection> bashrc_files(_imp->env->bashrc_files());
+
Command cmd(Command(LIBEXECDIR "/paludis/cran.bash fetch")
.with_setenv("CATEGORY", "cran")
.with_setenv("DISTDIR", stringify(_imp->distdir))
@@ -507,7 +509,7 @@ CRANRepository::do_install(const QualifiedPackageName &q, const VersionSpec &vn,
.with_setenv("PALUDIS_CRAN_MIRRORS", _imp->mirror)
.with_setenv("PALUDIS_EBUILD_DIR", std::string(LIBEXECDIR "/paludis/"))
.with_setenv("PALUDIS_EBUILD_LOG_LEVEL", stringify(Log::get_instance()->log_level()))
- .with_setenv("PALUDIS_BASHRC_FILES", _imp->env->bashrc_files()));
+ .with_setenv("PALUDIS_BASHRC_FILES", join(bashrc_files->begin(), bashrc_files->end(), " ")));
if (0 != run_command(cmd))
@@ -532,7 +534,7 @@ CRANRepository::do_install(const QualifiedPackageName &q, const VersionSpec &vn,
.with_setenv("PALUDIS_CRAN_LIBRARY", stringify(_imp->library))
.with_setenv("PALUDIS_EBUILD_DIR", std::string(LIBEXECDIR "/paludis/"))
.with_setenv("PALUDIS_EBUILD_LOG_LEVEL", stringify(Log::get_instance()->log_level()))
- .with_setenv("PALUDIS_BASHRC_FILES", _imp->env->bashrc_files())
+ .with_setenv("PALUDIS_BASHRC_FILES", join(bashrc_files->begin(), bashrc_files->end(), " "))
.with_setenv("ROOT", stringify(get_root(o.destinations)))
.with_setenv("WORKDIR", stringify(workdir));
@@ -566,7 +568,7 @@ CRANRepository::do_install(const QualifiedPackageName &q, const VersionSpec &vn,
.with_setenv("PALUDIS_CRAN_LIBRARY", stringify(_imp->library))
.with_setenv("PALUDIS_EBUILD_DIR", std::string(LIBEXECDIR "/paludis/"))
.with_setenv("PALUDIS_EBUILD_LOG_LEVEL", stringify(Log::get_instance()->log_level()))
- .with_setenv("PALUDIS_BASHRC_FILES", _imp->env->bashrc_files())
+ .with_setenv("PALUDIS_BASHRC_FILES", join(bashrc_files->begin(), bashrc_files->end(), " "))
.with_setenv("ROOT", stringify(get_root(o.destinations)))
.with_setenv("WORKDIR", stringify(workdir))
.with_setenv("REPOSITORY", stringify(name()));
@@ -592,12 +594,12 @@ CRANRepository::do_package_set(const SetName & s) const
return std::tr1::shared_ptr<DepSpec>();
}
-std::tr1::shared_ptr<const SetsCollection>
+std::tr1::shared_ptr<const SetNameCollection>
CRANRepository::sets_list() const
{
Context context("While generating the list of sets:");
- std::tr1::shared_ptr<SetsCollection> result(new SetsCollection::Concrete);
+ std::tr1::shared_ptr<SetNameCollection> result(new SetNameCollection::Concrete);
result->insert(SetName("base"));
return result;
}
diff --git a/paludis/repositories/cran/cran_repository.hh b/paludis/repositories/cran/cran_repository.hh
index ac92c7f..bad1925 100644
--- a/paludis/repositories/cran/cran_repository.hh
+++ b/paludis/repositories/cran/cran_repository.hh
@@ -85,7 +85,7 @@ namespace paludis
virtual std::tr1::shared_ptr<DepSpec> do_package_set(const SetName &) const;
- virtual std::tr1::shared_ptr<const SetsCollection> sets_list() const;
+ virtual std::tr1::shared_ptr<const SetNameCollection> sets_list() const;
virtual bool do_sync() const;
diff --git a/paludis/repositories/fake/fake_repository_base.cc b/paludis/repositories/fake/fake_repository_base.cc
index 157f51b..78941e4 100644
--- a/paludis/repositories/fake/fake_repository_base.cc
+++ b/paludis/repositories/fake/fake_repository_base.cc
@@ -262,10 +262,10 @@ FakeRepositoryBase::do_package_set(const SetName & id) const
return i->second;
}
-std::tr1::shared_ptr<const SetsCollection>
+std::tr1::shared_ptr<const SetNameCollection>
FakeRepositoryBase::sets_list() const
{
- std::tr1::shared_ptr<SetsCollection> result(new SetsCollection::Concrete);
+ std::tr1::shared_ptr<SetNameCollection> result(new SetNameCollection::Concrete);
std::copy(_imp->sets.begin(), _imp->sets.end(),
transform_inserter(result->inserter(), SelectFirst<SetName, std::tr1::shared_ptr<DepSpec> >()));
return result;
@@ -305,7 +305,7 @@ FakeVersionMetadata::FakeVersionMetadata() :
VersionMetadataDepsInterface(&PortageDepParser::parse_depend),
VersionMetadataLicenseInterface(&PortageDepParser::parse_license)
{
- keywords = "test";
+ keywords_string = "test";
}
FakeVersionMetadata::~FakeVersionMetadata()
diff --git a/paludis/repositories/fake/fake_repository_base.hh b/paludis/repositories/fake/fake_repository_base.hh
index 4a788d1..2b2b4a5 100644
--- a/paludis/repositories/fake/fake_repository_base.hh
+++ b/paludis/repositories/fake/fake_repository_base.hh
@@ -140,7 +140,7 @@ namespace paludis
const VersionSpec &) const;
virtual std::tr1::shared_ptr<DepSpec> do_package_set(const SetName & id) const;
- virtual std::tr1::shared_ptr<const SetsCollection> sets_list() const;
+ virtual std::tr1::shared_ptr<const SetNameCollection> sets_list() const;
protected:
/**
diff --git a/paludis/repositories/gems/gems_repository.cc b/paludis/repositories/gems/gems_repository.cc
index d0cc3f4..48329a7 100644
--- a/paludis/repositories/gems/gems_repository.cc
+++ b/paludis/repositories/gems/gems_repository.cc
@@ -186,10 +186,10 @@ GemsRepository::do_package_set(const SetName &) const
return std::tr1::shared_ptr<DepSpec>();
}
-std::tr1::shared_ptr<const SetsCollection>
+std::tr1::shared_ptr<const SetNameCollection>
GemsRepository::sets_list() const
{
- return std::tr1::shared_ptr<SetsCollection>(new SetsCollection::Concrete);
+ return std::tr1::shared_ptr<SetNameCollection>(new SetNameCollection::Concrete);
}
bool
@@ -206,17 +206,14 @@ GemsRepository::do_sync() const
std::string protocol(_imp->params.yaml_uri.substr(0, p));
- std::list<std::string> fetchers_dirs;
- WhitespaceTokeniser::get_instance()->tokenise(_imp->params.environment->fetchers_dirs(),
- std::back_inserter(fetchers_dirs));
-
- Log::get_instance()->message(ll_debug, lc_context, "looking for syncer protocol '"
- + stringify(protocol) + "'");
+ Log::get_instance()->message(ll_debug, lc_context) << "looking for syncer protocol '"
+ + stringify(protocol) + "'";
FSEntry fetcher("/var/empty");
bool ok(false);
- for (std::list<std::string>::const_iterator d(fetchers_dirs.begin()),
- d_end(fetchers_dirs.end()) ; d != d_end && ! ok; ++d)
+ std::tr1::shared_ptr<const FSEntryCollection> fetchers_dirs(_imp->params.environment->fetchers_dirs());
+ for (FSEntryCollection::Iterator d(fetchers_dirs->begin()),
+ d_end(fetchers_dirs->end()) ; d != d_end && ! ok; ++d)
{
fetcher = FSEntry(*d) / ("do" + protocol);
if (fetcher.exists() && fetcher.has_permission(fs_ug_owner, fs_perm_execute))
diff --git a/paludis/repositories/gems/gems_repository.hh b/paludis/repositories/gems/gems_repository.hh
index 7a36242..1cb9460 100644
--- a/paludis/repositories/gems/gems_repository.hh
+++ b/paludis/repositories/gems/gems_repository.hh
@@ -45,7 +45,7 @@ namespace paludis
virtual std::tr1::shared_ptr<DepSpec> do_package_set(const SetName &) const;
- virtual std::tr1::shared_ptr<const SetsCollection> sets_list() const;
+ virtual std::tr1::shared_ptr<const SetNameCollection> sets_list() const;
virtual bool do_sync() const;
diff --git a/paludis/repositories/gentoo/ebin.cc b/paludis/repositories/gentoo/ebin.cc
index 99164db..7732985 100644
--- a/paludis/repositories/gentoo/ebin.cc
+++ b/paludis/repositories/gentoo/ebin.cc
@@ -95,6 +95,11 @@ EbinCommand::operator() ()
if (use_sandbox())
cmd.with_sandbox();
+ std::tr1::shared_ptr<const FSEntryCollection> syncers_dirs(params.environment->syncers_dirs());
+ std::tr1::shared_ptr<const FSEntryCollection> bashrc_files(params.environment->bashrc_files());
+ std::tr1::shared_ptr<const FSEntryCollection> fetchers_dirs(params.environment->fetchers_dirs());
+ std::tr1::shared_ptr<const FSEntryCollection> hook_dirs(params.environment->hook_dirs());
+
cmd = extend_command(cmd
.with_setenv("P", stringify(params.db_entry->name.package) + "-" +
stringify(params.db_entry->version.remove_revision()))
@@ -115,10 +120,10 @@ EbinCommand::operator() ()
std::string("") : "-r" + std::string(PALUDIS_SUBVERSION_REVISION)))
.with_setenv("PALUDIS_TMPDIR", stringify(params.buildroot))
.with_setenv("PALUDIS_CONFIG_DIR", SYSCONFDIR "/paludis/")
- .with_setenv("PALUDIS_BASHRC_FILES", params.environment->bashrc_files())
- .with_setenv("PALUDIS_HOOK_DIRS", params.environment->hook_dirs())
- .with_setenv("PALUDIS_FETCHERS_DIRS", params.environment->fetchers_dirs())
- .with_setenv("PALUDIS_SYNCERS_DIRS", params.environment->syncers_dirs())
+ .with_setenv("PALUDIS_BASHRC_FILES", join(bashrc_files->begin(), bashrc_files->end(), " "))
+ .with_setenv("PALUDIS_HOOK_DIRS", join(hook_dirs->begin(), hook_dirs->end(), " "))
+ .with_setenv("PALUDIS_FETCHERS_DIRS", join(fetchers_dirs->begin(), fetchers_dirs->end(), " "))
+ .with_setenv("PALUDIS_SYNCERS_DIRS", join(syncers_dirs->begin(), syncers_dirs->end(), " "))
.with_setenv("PALUDIS_COMMAND", params.environment->paludis_command())
.with_setenv("PALUDIS_REDUCED_GID", stringify(params.environment->reduced_gid()))
.with_setenv("PALUDIS_REDUCED_UID", stringify(params.environment->reduced_uid()))
diff --git a/paludis/repositories/gentoo/ebin_entries.cc b/paludis/repositories/gentoo/ebin_entries.cc
index 95087d2..3d82c4c 100644
--- a/paludis/repositories/gentoo/ebin_entries.cc
+++ b/paludis/repositories/gentoo/ebin_entries.cc
@@ -92,7 +92,7 @@ EbinEntries::generate_version_metadata(const QualifiedPackageName & q,
result->provide_string = f.get("PROVIDE");
result->src_uri_string = f.get("SRC_URI");
result->restrict_string = f.get("RESTRICT");
- result->keywords = f.get("KEYWORDS");
+ result->keywords_string = f.get("KEYWORDS");
result->iuse = f.get("IUSE");
result->inherited = f.get("INHERITED");
@@ -157,11 +157,9 @@ EbinEntries::install(const QualifiedPackageName & q, const VersionSpec & v,
binaries.append(" ");
/* add * mirror entries */
- for (Environment::MirrorIterator
- m(_imp->params.environment->begin_mirrors("*")),
- m_end(_imp->params.environment->end_mirrors("*")) ;
- m != m_end ; ++m)
- flat_bin_uri.append(m->second + "/" + (*ff)->text().substr(pos + 1) + " ");
+ std::tr1::shared_ptr<const MirrorsCollection> star_mirrors(_imp->params.environment->mirrors("*"));
+ for (MirrorsCollection::Iterator m(star_mirrors->begin()), m_end(star_mirrors->end()) ; m != m_end ; ++m)
+ flat_bin_uri.append(*m + "/" + (*ff)->text().substr(pos + 1) + " ");
if (0 == (*ff)->text().compare(0, 9, "mirror://"))
{
@@ -172,18 +170,15 @@ EbinEntries::install(const QualifiedPackageName & q, const VersionSpec & v,
throw PackageInstallActionError("Can't install '" + stringify(q) + "-"
+ stringify(v) + "' since BIN_URI is broken");
+ std::tr1::shared_ptr<const MirrorsCollection> mirrors(_imp->params.environment->mirrors(mirror.substr(0, spos)));
if (! _imp->portage_repository->is_mirror(mirror.substr(0, spos)) &&
- _imp->params.environment->begin_mirrors(mirror.substr(0, spos)) ==
- _imp->params.environment->end_mirrors(mirror.substr(0, spos)))
+ mirrors->empty())
throw PackageInstallActionError("Can't install '" + stringify(q) + "-"
+ stringify(v) + "' since BIN_URI references unknown mirror:// '" +
mirror.substr(0, spos) + "'");
- for (Environment::MirrorIterator
- m(_imp->params.environment->begin_mirrors(mirror.substr(0, spos))),
- m_end(_imp->params.environment->end_mirrors(mirror.substr(0, spos))) ;
- m != m_end ; ++m)
- flat_bin_uri.append(m->second + "/" + mirror.substr(spos + 1) + " ");
+ for (MirrorsCollection::Iterator m(mirrors->begin()), m_end(mirrors->end()) ; m != m_end ; ++m)
+ flat_bin_uri.append(*m + "/" + mirror.substr(spos + 1) + " ");
for (RepositoryMirrorsInterface::MirrorsIterator
m(_imp->portage_repository->begin_mirrors(mirror.substr(0, spos))),
@@ -199,11 +194,9 @@ EbinEntries::install(const QualifiedPackageName & q, const VersionSpec & v,
std::string master_mirror(strip_trailing_string(stringify(_imp->portage_repository->name()), "x-"));
if (_imp->portage_repository->is_mirror(master_mirror))
{
- for (Environment::MirrorIterator
- m(_imp->params.environment->begin_mirrors(master_mirror)),
- m_end(_imp->params.environment->end_mirrors(master_mirror)) ;
- m != m_end ; ++m)
- flat_bin_uri.append(m->second + "/" + (*ff)->text().substr(pos + 1) + " ");
+ std::tr1::shared_ptr<const MirrorsCollection> repo_mirrors(_imp->params.environment->mirrors(master_mirror));
+ for (MirrorsCollection::Iterator m(repo_mirrors->begin()), m_end(repo_mirrors->end()) ; m != m_end ; ++m)
+ flat_bin_uri.append(*m + "/" + (*ff)->text().substr(pos + 1) + " ");
for (RepositoryMirrorsInterface::MirrorsIterator
m(_imp->portage_repository->begin_mirrors(master_mirror)),
@@ -396,7 +389,7 @@ EbinEntries::merge(const MergeOptions & m)
ebin_file << "PROVIDE=" << metadata->ebuild_interface->provide_string << std::endl;
ebin_file << "SRC_URI=" << metadata->ebuild_interface->src_uri_string << std::endl;
ebin_file << "RESTRICT=" << metadata->ebuild_interface->restrict_string << std::endl;
- ebin_file << "KEYWORDS=" << metadata->ebuild_interface->keywords << std::endl;
+ ebin_file << "KEYWORDS=" << metadata->ebuild_interface->keywords_string << std::endl;
ebin_file << "IUSE=" << metadata->ebuild_interface->iuse << std::endl;
ebin_file << "INHERITED=" << metadata->ebuild_interface->inherited << std::endl;
}
diff --git a/paludis/repositories/gentoo/ebuild.cc b/paludis/repositories/gentoo/ebuild.cc
index 2dfdead..a8b01c3 100644
--- a/paludis/repositories/gentoo/ebuild.cc
+++ b/paludis/repositories/gentoo/ebuild.cc
@@ -77,6 +77,11 @@ EbuildCommand::operator() ()
if (use_sandbox())
cmd.with_sandbox();
+ std::tr1::shared_ptr<const FSEntryCollection> syncers_dirs(params.environment->syncers_dirs());
+ std::tr1::shared_ptr<const FSEntryCollection> bashrc_files(params.environment->bashrc_files());
+ std::tr1::shared_ptr<const FSEntryCollection> fetchers_dirs(params.environment->fetchers_dirs());
+ std::tr1::shared_ptr<const FSEntryCollection> hook_dirs(params.environment->hook_dirs());
+
cmd = extend_command(cmd
.with_setenv("P", stringify(params.db_entry->name.package) + "-" +
stringify(params.db_entry->version.remove_revision()))
@@ -101,10 +106,10 @@ EbuildCommand::operator() ()
std::string("") : "-r" + std::string(PALUDIS_SUBVERSION_REVISION)))
.with_setenv("PALUDIS_TMPDIR", stringify(params.buildroot))
.with_setenv("PALUDIS_CONFIG_DIR", SYSCONFDIR "/paludis/")
- .with_setenv("PALUDIS_BASHRC_FILES", params.environment->bashrc_files())
- .with_setenv("PALUDIS_HOOK_DIRS", params.environment->hook_dirs())
- .with_setenv("PALUDIS_FETCHERS_DIRS", params.environment->fetchers_dirs())
- .with_setenv("PALUDIS_SYNCERS_DIRS", params.environment->syncers_dirs())
+ .with_setenv("PALUDIS_BASHRC_FILES", join(bashrc_files->begin(), bashrc_files->end(), " "))
+ .with_setenv("PALUDIS_HOOK_DIRS", join(hook_dirs->begin(), hook_dirs->end(), " "))
+ .with_setenv("PALUDIS_FETCHERS_DIRS", join(fetchers_dirs->begin(), fetchers_dirs->end(), " "))
+ .with_setenv("PALUDIS_SYNCERS_DIRS", join(syncers_dirs->begin(), syncers_dirs->end(), " "))
.with_setenv("PALUDIS_COMMAND", params.environment->paludis_command())
.with_setenv("PALUDIS_REDUCED_GID", stringify(params.environment->reduced_gid()))
.with_setenv("PALUDIS_REDUCED_UID", stringify(params.environment->reduced_uid()))
@@ -196,7 +201,7 @@ EbuildMetadataCommand::do_run_command(const Command & cmd)
_metadata->homepage = f.get("HOMEPAGE");
_metadata->license_interface->license_string = f.get("LICENSE");
_metadata->description = f.get("DESCRIPTION");
- _metadata->keywords = f.get("KEYWORDS");
+ _metadata->keywords_string = f.get("KEYWORDS");
_metadata->eclass_keywords = f.get("E_KEYWORDS");
_metadata->inherited = f.get("INHERITED");
_metadata->iuse = f.get("IUSE");
@@ -546,6 +551,11 @@ WriteVDBEntryCommand::operator() ()
stringify(params.output_directory) + "' '" +
stringify(params.environment_file) + "'");
+ std::tr1::shared_ptr<const FSEntryCollection> syncers_dirs(params.environment->syncers_dirs());
+ std::tr1::shared_ptr<const FSEntryCollection> bashrc_files(params.environment->bashrc_files());
+ std::tr1::shared_ptr<const FSEntryCollection> fetchers_dirs(params.environment->fetchers_dirs());
+ std::tr1::shared_ptr<const FSEntryCollection> hook_dirs(params.environment->hook_dirs());
+
Command cmd(Command(ebuild_cmd)
.with_setenv("PKGMANAGER", PALUDIS_PACKAGE "-" + stringify(PALUDIS_VERSION_MAJOR) + "." +
stringify(PALUDIS_VERSION_MINOR) + "." +
@@ -553,10 +563,10 @@ WriteVDBEntryCommand::operator() ()
(std::string(PALUDIS_SUBVERSION_REVISION).empty() ?
std::string("") : "-r" + std::string(PALUDIS_SUBVERSION_REVISION)))
.with_setenv("PALUDIS_CONFIG_DIR", SYSCONFDIR "/paludis/")
- .with_setenv("PALUDIS_BASHRC_FILES", params.environment->bashrc_files())
- .with_setenv("PALUDIS_HOOK_DIRS", params.environment->hook_dirs())
- .with_setenv("PALUDIS_FETCHERS_DIRS", params.environment->fetchers_dirs())
- .with_setenv("PALUDIS_SYNCERS_DIRS", params.environment->syncers_dirs())
+ .with_setenv("PALUDIS_BASHRC_FILES", join(bashrc_files->begin(), bashrc_files->end(), " "))
+ .with_setenv("PALUDIS_HOOK_DIRS", join(hook_dirs->begin(), hook_dirs->end(), " "))
+ .with_setenv("PALUDIS_FETCHERS_DIRS", join(fetchers_dirs->begin(), fetchers_dirs->end(), " "))
+ .with_setenv("PALUDIS_SYNCERS_DIRS", join(syncers_dirs->begin(), syncers_dirs->end(), " "))
.with_setenv("PALUDIS_COMMAND", params.environment->paludis_command())
.with_setenv("PALUDIS_EBUILD_LOG_LEVEL", stringify(Log::get_instance()->log_level()))
.with_setenv("PALUDIS_EBUILD_DIR", getenv_with_default("PALUDIS_EBUILD_DIR", LIBEXECDIR "/paludis")));
diff --git a/paludis/repositories/gentoo/ebuild_entries.cc b/paludis/repositories/gentoo/ebuild_entries.cc
index faf6a8f..4e3976b 100644
--- a/paludis/repositories/gentoo/ebuild_entries.cc
+++ b/paludis/repositories/gentoo/ebuild_entries.cc
@@ -302,11 +302,9 @@ EbuildEntries::install(const QualifiedPackageName & q, const VersionSpec & v,
archives.append(" ");
/* add * mirror entries */
- for (Environment::MirrorIterator
- m(_imp->params.environment->begin_mirrors("*")),
- m_end(_imp->params.environment->end_mirrors("*")) ;
- m != m_end ; ++m)
- flat_src_uri.append(m->second + "/" + (*ff)->text().substr(pos + 1) + " ");
+ std::tr1::shared_ptr<const MirrorsCollection> star_mirrors(_imp->params.environment->mirrors("*"));
+ for (MirrorsCollection::Iterator m(star_mirrors->begin()), m_end(star_mirrors->end()) ; m != m_end ; ++m)
+ flat_src_uri.append(*m + "/" + (*ff)->text().substr(pos + 1) + " ");
if (0 == (*ff)->text().compare(0, 9, "mirror://"))
{
@@ -317,18 +315,15 @@ EbuildEntries::install(const QualifiedPackageName & q, const VersionSpec & v,
throw PackageInstallActionError("Can't install '" + stringify(q) + "-"
+ stringify(v) + "' since SRC_URI is broken");
+ std::tr1::shared_ptr<const MirrorsCollection> mirrors(_imp->params.environment->mirrors(mirror.substr(0, spos)));
if (! _imp->portage_repository->is_mirror(mirror.substr(0, spos)) &&
- _imp->params.environment->begin_mirrors(mirror.substr(0, spos)) ==
- _imp->params.environment->end_mirrors(mirror.substr(0, spos)))
+ mirrors->empty())
throw PackageInstallActionError("Can't install '" + stringify(q) + "-"
+ stringify(v) + "' since SRC_URI references unknown mirror:// '" +
mirror.substr(0, spos) + "'");
- for (Environment::MirrorIterator
- m(_imp->params.environment->begin_mirrors(mirror.substr(0, spos))),
- m_end(_imp->params.environment->end_mirrors(mirror.substr(0, spos))) ;
- m != m_end ; ++m)
- flat_src_uri.append(m->second + "/" + mirror.substr(spos + 1) + " ");
+ for (MirrorsCollection::Iterator m(mirrors->begin()), m_end(mirrors->end()) ; m != m_end ; ++m)
+ flat_src_uri.append(*m + "/" + mirror.substr(spos + 1) + " ");
for (RepositoryMirrorsInterface::MirrorsIterator
m(_imp->portage_repository->begin_mirrors(mirror.substr(0, spos))),
@@ -344,11 +339,10 @@ EbuildEntries::install(const QualifiedPackageName & q, const VersionSpec & v,
std::string master_mirror(strip_trailing_string(stringify(_imp->portage_repository->name()), "x-"));
if (! no_mirror && _imp->portage_repository->is_mirror(master_mirror))
{
- for (Environment::MirrorIterator
- m(_imp->params.environment->begin_mirrors(master_mirror)),
- m_end(_imp->params.environment->end_mirrors(master_mirror)) ;
- m != m_end ; ++m)
- flat_src_uri.append(m->second + "/" + (*ff)->text().substr(pos + 1) + " ");
+ std::tr1::shared_ptr<const MirrorsCollection> repo_mirrors(_imp->params.environment->mirrors(master_mirror));
+
+ for (MirrorsCollection::Iterator m(repo_mirrors->begin()), m_end(repo_mirrors->end()) ; m != m_end ; ++m)
+ flat_src_uri.append(*m + "/" + (*ff)->text().substr(pos + 1) + " ");
for (RepositoryMirrorsInterface::MirrorsIterator
m(_imp->portage_repository->begin_mirrors(master_mirror)),
@@ -401,7 +395,7 @@ EbuildEntries::install(const QualifiedPackageName & q, const VersionSpec & v,
iuse, create_inserter<UseFlagName>(std::inserter(iuse, iuse.begin())));
for (std::set<UseFlagName>::const_iterator iuse_it(iuse.begin()), iuse_end(iuse.end()) ;
iuse_it != iuse_end; ++iuse_it)
- if (_imp->params.environment->query_use(*iuse_it, &e))
+ if (_imp->params.environment->query_use(*iuse_it, e))
use += (*iuse_it).data() + " ";
}
@@ -426,7 +420,7 @@ EbuildEntries::install(const QualifiedPackageName & q, const VersionSpec & v,
/* possible values from environment */
std::tr1::shared_ptr<const UseFlagNameCollection> possible_values_from_env(_imp->params.environment->
- known_use_expand_names(*x, &e));
+ known_use_expand_names(*x, e));
for (UseFlagNameCollection::Iterator i(possible_values_from_env->begin()),
i_end(possible_values_from_env->end()) ; i != i_end ; ++i)
possible_values.insert(UseFlagName(stringify(*i).substr(lower_x.length() + 1)));
@@ -434,7 +428,7 @@ EbuildEntries::install(const QualifiedPackageName & q, const VersionSpec & v,
for (std::set<UseFlagName>::const_iterator u(possible_values.begin()), u_end(possible_values.end()) ;
u != u_end ; ++u)
{
- if (! _imp->params.environment->query_use(UseFlagName(lower_x + "_" + stringify(*u)), &e))
+ if (! _imp->params.environment->query_use(UseFlagName(lower_x + "_" + stringify(*u)), e))
continue;
use.append(lower_x + "_" + stringify(*u) + " ");
diff --git a/paludis/repositories/gentoo/ebuild_flat_metadata_cache.cc b/paludis/repositories/gentoo/ebuild_flat_metadata_cache.cc
index 886b941..d5a379e 100644
--- a/paludis/repositories/gentoo/ebuild_flat_metadata_cache.cc
+++ b/paludis/repositories/gentoo/ebuild_flat_metadata_cache.cc
@@ -55,7 +55,7 @@ EbuildFlatMetadataCache::load(std::tr1::shared_ptr<EbuildVersionMetadata> result
std::getline(cache, line); result->homepage = line;
std::getline(cache, line); result->license_string = line;
std::getline(cache, line); result->description = line;
- std::getline(cache, line); result->keywords = line;
+ std::getline(cache, line); result->keywords_string = line;
std::getline(cache, line); result->inherited = line;
std::getline(cache, line); result->iuse = line;
std::getline(cache, line);
@@ -136,7 +136,7 @@ EbuildFlatMetadataCache::save(std::tr1::shared_ptr<const EbuildVersionMetadata>
cache << normalise(v->homepage) << std::endl;
cache << normalise(v->license_string) << std::endl;
cache << normalise(v->description) << std::endl;
- cache << normalise(v->keywords) << std::endl;
+ cache << normalise(v->keywords_string) << std::endl;
cache << normalise(v->inherited) << std::endl;
cache << normalise(v->iuse) << std::endl;
cache << std::endl;
diff --git a/paludis/repositories/gentoo/glsa.cc b/paludis/repositories/gentoo/glsa.cc
index 28ddd51..fba4f42 100644
--- a/paludis/repositories/gentoo/glsa.cc
+++ b/paludis/repositories/gentoo/glsa.cc
@@ -141,13 +141,13 @@ GLSA::~GLSA()
GLSA::PackagesIterator
GLSA::begin_packages() const
{
- return PackagesIterator(indirect_iterator<const GLSAPackage>(_imp->packages.begin()));
+ return PackagesIterator(indirect_iterator(_imp->packages.begin()));
}
GLSA::PackagesIterator
GLSA::end_packages() const
{
- return PackagesIterator(indirect_iterator<const GLSAPackage>(_imp->packages.end()));
+ return PackagesIterator(indirect_iterator(_imp->packages.end()));
}
void
diff --git a/paludis/repositories/gentoo/portage_repository.cc b/paludis/repositories/gentoo/portage_repository.cc
index c69c824..82798ff 100644
--- a/paludis/repositories/gentoo/portage_repository.cc
+++ b/paludis/repositories/gentoo/portage_repository.cc
@@ -34,6 +34,7 @@
#include <paludis/dep_spec_flattener.hh>
#include <paludis/environment.hh>
#include <paludis/hashed_containers.hh>
+#include <paludis/hook.hh>
#include <paludis/match_package.hh>
#include <paludis/package_database.hh>
#include <paludis/package_database_entry.hh>
@@ -852,7 +853,7 @@ PortageRepository::do_package_set(const SetName & s) const
return _imp->sets_ptr->package_set(s);
}
-std::tr1::shared_ptr<const SetsCollection>
+std::tr1::shared_ptr<const SetNameCollection>
PortageRepository::sets_list() const
{
return _imp->sets_ptr->sets_list();
diff --git a/paludis/repositories/gentoo/portage_repository.hh b/paludis/repositories/gentoo/portage_repository.hh
index 5c1eb32..59e2d2d 100644
--- a/paludis/repositories/gentoo/portage_repository.hh
+++ b/paludis/repositories/gentoo/portage_repository.hh
@@ -110,7 +110,7 @@ namespace paludis
virtual std::tr1::shared_ptr<DepSpec> do_package_set(const SetName &) const;
- virtual std::tr1::shared_ptr<const SetsCollection> sets_list() const;
+ virtual std::tr1::shared_ptr<const SetNameCollection> sets_list() const;
virtual bool do_sync() const;
diff --git a/paludis/repositories/gentoo/portage_repository_profile.cc b/paludis/repositories/gentoo/portage_repository_profile.cc
index 4717d8b..91535d5 100644
--- a/paludis/repositories/gentoo/portage_repository_profile.cc
+++ b/paludis/repositories/gentoo/portage_repository_profile.cc
@@ -20,13 +20,12 @@
#include <paludis/repositories/gentoo/portage_repository_profile.hh>
#include <paludis/repositories/gentoo/portage_repository_profile_file.hh>
#include <paludis/repositories/gentoo/portage_repository_exceptions.hh>
-
#include <paludis/util/log.hh>
#include <paludis/util/tokeniser.hh>
#include <paludis/util/iterator.hh>
#include <paludis/util/save.hh>
#include <paludis/util/system.hh>
-
+#include <paludis/util/join.hh>
#include <paludis/config_file.hh>
#include <paludis/environment.hh>
#include <paludis/match_package.hh>
diff --git a/paludis/repositories/gentoo/portage_repository_sets.cc b/paludis/repositories/gentoo/portage_repository_sets.cc
index bfcccb0..ec87840 100644
--- a/paludis/repositories/gentoo/portage_repository_sets.cc
+++ b/paludis/repositories/gentoo/portage_repository_sets.cc
@@ -108,12 +108,12 @@ PortageRepositorySets::package_set(const SetName & s) const
return std::tr1::shared_ptr<DepSpec>();
}
-std::tr1::shared_ptr<const SetsCollection>
+std::tr1::shared_ptr<const SetNameCollection>
PortageRepositorySets::sets_list() const
{
Context context("While generating the list of sets:");
- std::tr1::shared_ptr<SetsCollection> result(new SetsCollection::Concrete);
+ std::tr1::shared_ptr<SetNameCollection> result(new SetNameCollection::Concrete);
result->insert(SetName("insecurity"));
result->insert(SetName("security"));
result->insert(SetName("system"));
diff --git a/paludis/repositories/gentoo/portage_repository_sets.hh b/paludis/repositories/gentoo/portage_repository_sets.hh
index 6bf7646..e93662b 100644
--- a/paludis/repositories/gentoo/portage_repository_sets.hh
+++ b/paludis/repositories/gentoo/portage_repository_sets.hh
@@ -72,7 +72,7 @@ namespace paludis
/**
* Give a list of all the sets in this repo.
*/
- std::tr1::shared_ptr<const SetsCollection> sets_list() const;
+ std::tr1::shared_ptr<const SetNameCollection> sets_list() const;
};
}
diff --git a/paludis/repositories/gentoo/vdb_merger.cc b/paludis/repositories/gentoo/vdb_merger.cc
index c53808b..bac154d 100644
--- a/paludis/repositories/gentoo/vdb_merger.cc
+++ b/paludis/repositories/gentoo/vdb_merger.cc
@@ -21,8 +21,12 @@
#include <paludis/util/log.hh>
#include <paludis/util/tokeniser.hh>
#include <paludis/util/system.hh>
+#include <paludis/util/join.hh>
+#include <paludis/hook.hh>
#include <paludis/digests/md5.hh>
#include <paludis/environment.hh>
+#include <paludis/package_database_entry.hh>
+#include <paludis/package_database.hh>
#include <fstream>
#include <iostream>
#include <iomanip>
@@ -80,6 +84,8 @@ VDBMerger::extend_hook(const Hook & h)
_imp->options.environment->package_database()->fetch_repository(
pde->repository)->version_metadata(pde->name, pde->version)->slot));
+ std::tr1::shared_ptr<const FSEntryCollection> bashrc_files(_imp->options.environment->bashrc_files());
+
return Merger::extend_hook(h)
("P", pn + "-" + pv)
("PN", pn)
@@ -91,7 +97,7 @@ VDBMerger::extend_hook(const Hook & h)
("SLOT", slot)
("CONFIG_PROTECT", _imp->options.config_protect)
("CONFIG_PROTECT_MASK", _imp->options.config_protect_mask)
- ("PALUDIS_BASHRC_FILES", _imp->options.environment->bashrc_files());
+ ("PALUDIS_BASHRC_FILES", join(bashrc_files->begin(), bashrc_files->end(), " "));
}
void
diff --git a/paludis/repositories/gentoo/vdb_repository.cc b/paludis/repositories/gentoo/vdb_repository.cc
index 3c038aa..ff52acb 100644
--- a/paludis/repositories/gentoo/vdb_repository.cc
+++ b/paludis/repositories/gentoo/vdb_repository.cc
@@ -32,6 +32,7 @@
#include <paludis/package_database.hh>
#include <paludis/repository_name_cache.hh>
#include <paludis/set_file.hh>
+#include <paludis/hook.hh>
#include <paludis/util/collection_concrete.hh>
#include <paludis/util/dir_iterator.hh>
@@ -441,7 +442,7 @@ namespace paludis
Context local_context("When loading key 'LICENSE':");
p->metadata->license_string = file_contents(location, p->name, p->version, "LICENSE");
}
- p->metadata->keywords = "*";
+ p->metadata->keywords_string = "*";
{
Context local_context("When loading key 'INHERITED':");
p->metadata->inherited = file_contents(location, p->name, p->version, "INHERITED");
@@ -589,15 +590,9 @@ VDBRepository::do_category_names() const
std::tr1::shared_ptr<CategoryNamePartCollection> result(new CategoryNamePartCollection::Concrete);
-#if 0
- for (std::vector<VDBEntry>::const_iterator c(_imp->entries.begin()), c_end(_imp->entries.end()) ;
- c != c_end ; ++c)
- result->insert(c->name.category);
-#else
fast_unique_copy(_imp->entries.begin(), _imp->entries.end(),
transform_inserter(result->inserter(), VDBEntry::ExtractCategory()),
VDBEntry::CompareCategory());
-#endif
return result;
}
@@ -617,10 +612,6 @@ VDBRepository::do_package_names(const CategoryNamePart & c) const
std::pair<std::vector<VDBEntry>::const_iterator, std::vector<VDBEntry>::const_iterator>
r(std::equal_range(_imp->entries.begin(), _imp->entries.end(), c,
VDBEntry::CompareCategory()));
-#if 0
- for ( ; r.first != r.second ; ++(r.first))
- result->insert(r.first->name);
-#endif
fast_unique_copy(r.first, r.second,
transform_inserter(result->inserter(), VDBEntry::ExtractPackage()),
VDBEntry::ComparePackage());
@@ -1100,12 +1091,12 @@ VDBRepository::do_package_set(const SetName & s) const
return std::tr1::shared_ptr<DepSpec>();
}
-std::tr1::shared_ptr<const SetsCollection>
+std::tr1::shared_ptr<const SetNameCollection>
VDBRepository::sets_list() const
{
Context context("While generating the list of sets:");
- std::tr1::shared_ptr<SetsCollection> result(new SetsCollection::Concrete);
+ std::tr1::shared_ptr<SetNameCollection> result(new SetNameCollection::Concrete);
result->insert(SetName("everything"));
result->insert(SetName("world"));
return result;
diff --git a/paludis/repositories/gentoo/vdb_repository.hh b/paludis/repositories/gentoo/vdb_repository.hh
index 66bab89..5e96679 100644
--- a/paludis/repositories/gentoo/vdb_repository.hh
+++ b/paludis/repositories/gentoo/vdb_repository.hh
@@ -166,7 +166,7 @@ namespace paludis
virtual std::tr1::shared_ptr<const VersionMetadata> provided_package_version_metadata(
const RepositoryProvidesEntry &) const;
- virtual std::tr1::shared_ptr<const SetsCollection> sets_list() const;
+ virtual std::tr1::shared_ptr<const SetNameCollection> sets_list() const;
virtual bool is_suitable_destination_for(const PackageDatabaseEntry &) const;
diff --git a/paludis/repositories/gentoo/vdb_unmerger.cc b/paludis/repositories/gentoo/vdb_unmerger.cc
index 44839ae..4f61d5b 100644
--- a/paludis/repositories/gentoo/vdb_unmerger.cc
+++ b/paludis/repositories/gentoo/vdb_unmerger.cc
@@ -27,6 +27,9 @@ using namespace paludis;
#include <paludis/util/log.hh>
#include <paludis/util/dir_iterator.hh>
#include <paludis/digests/md5.hh>
+#include <paludis/hook.hh>
+#include <paludis/package_database.hh>
+#include <paludis/util/join.hh>
#include <list>
#include <fstream>
#include <iostream>
@@ -77,6 +80,8 @@ VDBUnmerger::extend_hook(const Hook & h)
std::string pv(stringify(_imp->options.version.remove_revision()));
std::string slot(stringify(_imp->options.repository->version_metadata(_imp->options.package_name, _imp->options.version)->slot));
+ std::tr1::shared_ptr<const FSEntryCollection> bashrc_files(_imp->options.environment->bashrc_files());
+
return Unmerger::extend_hook(h)
("P", pn + "-" + pv)
("PN", pn)
@@ -88,7 +93,7 @@ VDBUnmerger::extend_hook(const Hook & h)
("SLOT", slot)
("CONFIG_PROTECT", _imp->options.config_protect)
("CONFIG_PROTECT_MASK", _imp->options.config_protect_mask)
- ("PALUDIS_BASHRC_FILES", _imp->options.environment->bashrc_files());
+ ("PALUDIS_BASHRC_FILES", join(bashrc_files->begin(), bashrc_files->end(), " "));
}
void
diff --git a/paludis/repositories/virtuals/installed_virtuals_repository.cc b/paludis/repositories/virtuals/installed_virtuals_repository.cc
index 0c5750d..8617bbe 100644
--- a/paludis/repositories/virtuals/installed_virtuals_repository.cc
+++ b/paludis/repositories/virtuals/installed_virtuals_repository.cc
@@ -25,6 +25,7 @@
#include <paludis/package_database.hh>
#include <paludis/util/compare.hh>
#include <paludis/util/collection_concrete.hh>
+#include <paludis/hook.hh>
#include <vector>
#include <algorithm>
@@ -261,15 +262,9 @@ InstalledVirtualsRepository::do_package_names(const CategoryNamePart & c) const
std::tr1::shared_ptr<QualifiedPackageNameCollection> result(new QualifiedPackageNameCollection::Concrete);
-#if 0
- /// \todo: in theory, this can be a lot faster
- for ( ; p.first != p.second ; ++p.first)
- result->insert(p.first->virtual_name);
-#else
fast_unique_copy(p.first, p.second,
transform_inserter(result->inserter(), EntriesNameExtractor()),
EntriesNameComparator());
-#endif
return result;
}
@@ -280,14 +275,6 @@ InstalledVirtualsRepository::do_category_names() const
std::tr1::shared_ptr<CategoryNamePartCollection> result(new CategoryNamePartCollection::Concrete);
result->insert(CategoryNamePart("virtual"));
-#if 0
- need_entries();
-
- fast_unique_copy(_imp->entries.begin(), _imp->entries.end(),
- transform_inserter(result->inserter(), EntriesCategoryExtractor()),
- EntriesCategoryComparator());
-#endif
-
return result;
}
diff --git a/paludis/repositories/virtuals/virtuals_repository.cc b/paludis/repositories/virtuals/virtuals_repository.cc
index 529438e..f628602 100644
--- a/paludis/repositories/virtuals/virtuals_repository.cc
+++ b/paludis/repositories/virtuals/virtuals_repository.cc
@@ -325,14 +325,6 @@ VirtualsRepository::do_category_names() const
{
std::tr1::shared_ptr<CategoryNamePartCollection> result(new CategoryNamePartCollection::Concrete);
result->insert(CategoryNamePart("virtual"));
-#if 0
- need_entries();
-
- fast_unique_copy(_imp->entries.begin(), _imp->entries.end(),
- transform_inserter(result->inserter(), EntriesCategoryExtractor()),
- EntriesCategoryComparator());
-#endif
-
return result;
}
diff --git a/paludis/repository-fwd.hh b/paludis/repository-fwd.hh
new file mode 100644
index 0000000..7eaf14b
--- /dev/null
+++ b/paludis/repository-fwd.hh
@@ -0,0 +1,73 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2005, 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
+ * 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_REPOSITORY_FWD_HH
+#define PALUDIS_GUARD_PALUDIS_REPOSITORY_FWD_HH 1
+
+#include <paludis/util/collection-fwd.hh>
+#include <tr1/memory>
+
+namespace paludis
+{
+ class Environment;
+ class RepositoryNameCache;
+ class PortageRepositoryProfile;
+ class Hook;
+
+ class Repository;
+ class RepositoryInstallableInterface;
+ class RepositoryInstalledInterface;
+ class RepositoryMaskInterface;
+ class RepositorySetsInterface;
+ class RepositorySyncableInterface;
+ class RepositoryUninstallableInterface;
+ class RepositoryUseInterface;
+ class RepositoryWorldInterface;
+ class RepositoryEnvironmentVariableInterface;
+ class RepositoryMirrorsInterface;
+ class RepositoryProvidesInterface;
+ class RepositoryVirtualsInterface;
+ class RepositoryDestinationInterface;
+ class RepositoryContentsInterface;
+ class RepositoryConfigInterface;
+ class RepositoryLicensesInterface;
+ class RepositoryPortageInterface;
+ class RepositoryHookInterface;
+
+ /**
+ * A set of destinations.
+ *
+ * \ingroup grpdepresolver
+ */
+ typedef SortedCollection<std::tr1::shared_ptr<Repository> > DestinationsCollection;
+
+ /**
+ * What debug build option to use when installing a package.
+ *
+ * \ingroup grprepository
+ */
+ enum InstallDebugOption
+ {
+ ido_none,
+ ido_split,
+ ido_internal
+ };
+}
+
+#endif
diff --git a/paludis/repository.hh b/paludis/repository.hh
index 8ce76d7..d31878f 100644
--- a/paludis/repository.hh
+++ b/paludis/repository.hh
@@ -20,6 +20,7 @@
#ifndef PALUDIS_GUARD_PALUDIS_REPOSITORY_HH
#define PALUDIS_GUARD_PALUDIS_REPOSITORY_HH 1
+#include <paludis/repository-fwd.hh>
#include <paludis/dep_spec.hh>
#include <paludis/name.hh>
#include <paludis/util/attributes.hh>
@@ -45,49 +46,6 @@
namespace paludis
{
- class Environment;
- class RepositoryNameCache;
- class PortageRepositoryProfile;
- class Hook;
-
- class Repository;
- class RepositoryInstallableInterface;
- class RepositoryInstalledInterface;
- class RepositoryMaskInterface;
- class RepositorySetsInterface;
- class RepositorySyncableInterface;
- class RepositoryUninstallableInterface;
- class RepositoryUseInterface;
- class RepositoryWorldInterface;
- class RepositoryEnvironmentVariableInterface;
- class RepositoryMirrorsInterface;
- class RepositoryProvidesInterface;
- class RepositoryVirtualsInterface;
- class RepositoryDestinationInterface;
- class RepositoryContentsInterface;
- class RepositoryConfigInterface;
- class RepositoryLicensesInterface;
- class RepositoryPortageInterface;
- class RepositoryHookInterface;
-
- /**
- * A set of destinations.
- *
- * \ingroup grpdepresolver
- */
- typedef SortedCollection<std::tr1::shared_ptr<Repository> > DestinationsCollection;
-
- /**
- * What debug build option to use when installing a package.
- *
- * \ingroup grprepository
- */
- enum InstallDebugOption
- {
- ido_none,
- ido_split,
- ido_internal
- };
#include <paludis/repository-sr.hh>
@@ -734,13 +692,6 @@ namespace paludis
};
/**
- * Contains the names of all the sets provided by the repository.
- *
- * \ingroup grpnames
- */
- typedef SortedCollection<SetName> SetsCollection;
-
- /**
* Interface for package sets for repositories.
*
* \see Repository
@@ -776,7 +727,7 @@ namespace paludis
/**
* Gives a list of the names of all the sets provided by this repo.
*/
- virtual std::tr1::shared_ptr<const SetsCollection> sets_list() const
+ virtual std::tr1::shared_ptr<const SetNameCollection> sets_list() const
PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
///\}
diff --git a/paludis/repository_name_cache_TEST.cc b/paludis/repository_name_cache_TEST.cc
index 4faa0c9..d2c20d0 100644
--- a/paludis/repository_name_cache_TEST.cc
+++ b/paludis/repository_name_cache_TEST.cc
@@ -22,6 +22,7 @@
#include <paludis/repositories/fake/fake_repository.hh>
#include <paludis/util/fs_entry.hh>
#include <paludis/util/join.hh>
+#include <paludis/package_database.hh>
#include <test/test_framework.hh>
#include <test/test_runner.hh>
diff --git a/paludis/set_file.cc b/paludis/set_file.cc
index bfb8026..ec720e2 100644
--- a/paludis/set_file.cc
+++ b/paludis/set_file.cc
@@ -25,6 +25,7 @@
#include <paludis/config_file.hh>
#include <paludis/environment.hh>
#include <paludis/query.hh>
+#include <paludis/package_database.hh>
#include <list>
#include <vector>
#include <fstream>
@@ -259,7 +260,7 @@ SimpleHandler::_create_contents() const
{
if (_p.environment && std::string::npos == i->find('/'))
{
- std::tr1::shared_ptr<DepSpec> p(_p.environment->package_set(SetName(*i)));
+ std::tr1::shared_ptr<DepSpec> p(_p.environment->set(SetName(*i)));
if (p)
_contents->add_child(p);
else
diff --git a/paludis/syncer.cc b/paludis/syncer.cc
index 39c2211..e45d06f 100644
--- a/paludis/syncer.cc
+++ b/paludis/syncer.cc
@@ -25,6 +25,7 @@
#include <paludis/util/log.hh>
#include <paludis/util/system.hh>
#include <paludis/util/tokeniser.hh>
+#include <paludis/util/join.hh>
#include <list>
/** \file
@@ -63,17 +64,14 @@ DefaultSyncer::DefaultSyncer(const SyncerParams & params)
if (q < p)
_remote = _remote.substr(q < p ? q + 1 : 0);
- std::list<std::string> syncers_dirs;
- WhitespaceTokeniser::get_instance()->tokenise(_environment->syncers_dirs(),
- std::back_inserter(syncers_dirs));
-
- Log::get_instance()->message(ll_debug, lc_context, "looking for syncer protocol '"
- + stringify(format) + "'");
+ Log::get_instance()->message(ll_debug, lc_context) << "looking for syncer protocol '"
+ + stringify(format) << "'";
+ std::tr1::shared_ptr<const FSEntryCollection> syncer_dirs(_environment->syncers_dirs());
FSEntry syncer("/var/empty");
bool ok(false);
- for (std::list<std::string>::const_iterator d(syncers_dirs.begin()),
- d_end(syncers_dirs.end()) ; d != d_end && ! ok; ++d)
+ for (FSEntryCollection::Iterator d(syncer_dirs->begin()), d_end(syncer_dirs->end()) ;
+ d != d_end && ! ok; ++d)
{
syncer = FSEntry(*d) / ("do" + format);
if (syncer.exists() && syncer.has_permission(fs_ug_owner, fs_perm_execute))
@@ -92,12 +90,15 @@ DefaultSyncer::DefaultSyncer(const SyncerParams & params)
void
DefaultSyncer::sync(const SyncOptions & opts) const
{
+ std::tr1::shared_ptr<const FSEntryCollection> bashrc_files(_environment->bashrc_files());
+ std::tr1::shared_ptr<const FSEntryCollection> fetchers_dirs(_environment->fetchers_dirs());
+ std::tr1::shared_ptr<const FSEntryCollection> syncers_dirs(_environment->syncers_dirs());
Command cmd(Command(stringify(_syncer) + " " + opts.options + " '" + _local + "' '" + _remote + "'")
.with_setenv("PALUDIS_ACTION", "sync")
- .with_setenv("PALUDIS_BASHRC_FILES", _environment->bashrc_files())
- .with_setenv("PALUDIS_FETCHERS_DIRS", _environment->fetchers_dirs())
- .with_setenv("PALUDIS_SYNCERS_DIRS", _environment->syncers_dirs())
+ .with_setenv("PALUDIS_BASHRC_FILES", join(bashrc_files->begin(), bashrc_files->end(), " "))
+ .with_setenv("PALUDIS_FETCHERS_DIRS", join(fetchers_dirs->begin(), fetchers_dirs->end(), " "))
+ .with_setenv("PALUDIS_SYNCERS_DIRS", join(syncers_dirs->begin(), syncers_dirs->end(), " "))
.with_setenv("PALUDIS_EBUILD_DIR", getenv_with_default("PALUDIS_EBUILD_DIR", LIBEXECDIR "/paludis")));
if (run_command(cmd))
diff --git a/paludis/tasks/find_unused_packages_task.cc b/paludis/tasks/find_unused_packages_task.cc
index de4d28d..a5e7e4b 100644
--- a/paludis/tasks/find_unused_packages_task.cc
+++ b/paludis/tasks/find_unused_packages_task.cc
@@ -64,12 +64,9 @@ FindUnusedPackagesTask::execute(const QualifiedPackageName & package)
old_slot = metadata->slot;
}
- std::set<KeywordName> current_keywords;
- WhitespaceTokeniser::get_instance()->tokenise(metadata->ebuild_interface->keywords,
- create_inserter<KeywordName>(std::inserter(current_keywords, current_keywords.end())));
-
+ std::tr1::shared_ptr<const KeywordNameCollection> current_keywords(metadata->ebuild_interface->keywords());
bool used(false);
- for (std::set<KeywordName>::const_iterator k(current_keywords.begin()), k_end(current_keywords.end()) ;
+ for (KeywordNameCollection::Iterator k(current_keywords->begin()), k_end(current_keywords->end()) ;
k != k_end ; ++k)
{
std::string stable_keyword(stringify(*k));
@@ -89,7 +86,7 @@ FindUnusedPackagesTask::execute(const QualifiedPackageName & package)
if (! used)
result->append(PackageDatabaseEntry(package, p->version, _repo->name()));
- keywords.insert(current_keywords.begin(), current_keywords.end());
+ keywords.insert(current_keywords->begin(), current_keywords->end());
}
return result;
diff --git a/paludis/tasks/install_task.cc b/paludis/tasks/install_task.cc
index c87fccb..4643de0 100644
--- a/paludis/tasks/install_task.cc
+++ b/paludis/tasks/install_task.cc
@@ -23,6 +23,9 @@
#include <paludis/util/collection_concrete.hh>
#include <paludis/util/exception.hh>
#include <paludis/query.hh>
+#include <paludis/hook.hh>
+#include <paludis/repository.hh>
+#include <paludis/package_database.hh>
#include <paludis/tasks/exceptions.hh>
#include <list>
@@ -101,7 +104,7 @@ InstallTask::add_target(const std::string & target)
bool done(false);
try
{
- if ((target != "insecurity") && ((s = ((_imp->env->package_set(SetName(target)))))))
+ if ((target != "insecurity") && ((s = ((_imp->env->set(SetName(target)))))))
{
if (_imp->had_set_targets)
throw MultipleSetTargetsSpecified();
@@ -145,42 +148,6 @@ InstallTask::add_target(const std::string & target)
_imp->raw_targets.push_back(modified_target);
}
-namespace
-{
- struct WorldCallbacks :
- public Environment::WorldCallbacks
- {
- InstallTask * const t;
-
- WorldCallbacks(InstallTask * const tt) :
- t(tt)
- {
- }
-
- virtual void add_callback(const PackageDepSpec & a)
- {
- t->on_update_world(a);
- }
-
- virtual void add_callback(const SetName & a)
- {
- t->on_update_world(a);
- }
-
- virtual void skip_callback(const PackageDepSpec & 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);
- }
- };
-}
-
void
InstallTask::execute()
{
@@ -460,22 +427,21 @@ InstallTask::execute()
if (! _imp->preserve_world)
{
on_update_world_pre();
- WorldCallbacks w(this);
if (_imp->had_package_targets)
{
if (_imp->add_to_world_spec)
- _imp->env->add_appropriate_to_world(PortageDepParser::parse_depend(
- *_imp->add_to_world_spec, pds_pm_permissive), &w);
+ world_update_packages(PortageDepParser::parse_depend(
+ *_imp->add_to_world_spec, pds_pm_permissive));
else
- _imp->env->add_appropriate_to_world(_imp->targets, &w);
+ world_update_packages(_imp->targets);
}
else if (_imp->had_set_targets)
{
if (_imp->add_to_world_spec)
- _imp->env->add_set_to_world(SetName(*_imp->add_to_world_spec), &w);
+ world_update_set(SetName(*_imp->add_to_world_spec));
else if (! _imp->raw_targets.empty())
- _imp->env->add_set_to_world(SetName(*_imp->raw_targets.begin()), &w);
+ world_update_set(SetName(*_imp->raw_targets.begin()));
}
on_update_world_post();
@@ -610,3 +576,97 @@ InstallTask::override_target_type(const DepListTargetType t)
_imp->dep_list.options()->target_type = t;
}
+void
+InstallTask::world_update_set(const SetName & s)
+{
+ if (s == SetName("world") || s == SetName("system") || s == SetName("security")
+ || s == SetName("everything") || s == SetName("insecurity"))
+ {
+ on_update_world_skip(s, "special sets cannot be added to world");
+ return;
+ }
+
+ for (PackageDatabase::RepositoryIterator r(_imp->env->package_database()->begin_repositories()),
+ r_end(_imp->env->package_database()->end_repositories()) ;
+ r != r_end ; ++r)
+ if ((*r)->world_interface)
+ (*r)->world_interface->add_to_world(s);
+
+ on_update_world(s);
+}
+
+namespace
+{
+ struct WorldTargetFinder :
+ DepSpecVisitorTypes::ConstVisitor,
+ DepSpecVisitorTypes::ConstVisitor::VisitChildren<WorldTargetFinder, AllDepSpec>
+ {
+ using DepSpecVisitorTypes::ConstVisitor::VisitChildren<WorldTargetFinder, AllDepSpec>::visit;
+
+ InstallTask * const task;
+ std::list<const PackageDepSpec *> items;
+ bool inside_any;
+ bool inside_use;
+
+ WorldTargetFinder(InstallTask * const t) :
+ task(t),
+ inside_any(false),
+ inside_use(false)
+ {
+ }
+
+ void visit(const AnyDepSpec * a)
+ {
+ Save<bool> save_inside_any(&inside_any, true);
+ std::for_each(a->begin(), a->end(), accept_visitor(this));
+ }
+
+ void visit(const UseDepSpec * a)
+ {
+ Save<bool> save_inside_use(&inside_use, true);
+ std::for_each(a->begin(), a->end(), accept_visitor(this));
+ }
+
+ void visit(const PlainTextDepSpec *)
+ {
+ }
+
+ void visit(const PackageDepSpec * a)
+ {
+ if (inside_any)
+ task->on_update_world_skip(*a, "inside || ( ) block");
+ else if (inside_use)
+ task->on_update_world_skip(*a, "inside use? ( ) block");
+ else if (a->slot_ptr())
+ task->on_update_world_skip(*a, ":slot restrictions");
+ else if (a->version_requirements_ptr() && ! a->version_requirements_ptr()->empty())
+ task->on_update_world_skip(*a, "version restrictions");
+ else
+ {
+ items.push_back(a);
+ task->on_update_world(*a);
+ }
+ }
+
+ void visit(const BlockDepSpec *)
+ {
+ }
+ };
+}
+
+void
+InstallTask::world_update_packages(std::tr1::shared_ptr<const DepSpec> a)
+{
+ WorldTargetFinder w(this);
+ a->accept(&w);
+ for (std::list<const PackageDepSpec *>::const_iterator i(w.items.begin()),
+ i_end(w.items.end()) ; i != i_end ; ++i)
+ {
+ for (PackageDatabase::RepositoryIterator r(_imp->env->package_database()->begin_repositories()),
+ r_end(_imp->env->package_database()->end_repositories()) ;
+ r != r_end ; ++r)
+ if ((*r)->world_interface && (*i)->package_ptr())
+ (*r)->world_interface->add_to_world(*(*i)->package_ptr());
+ }
+}
+
diff --git a/paludis/tasks/install_task.hh b/paludis/tasks/install_task.hh
index 31761fb..a64aa72 100644
--- a/paludis/tasks/install_task.hh
+++ b/paludis/tasks/install_task.hh
@@ -23,6 +23,7 @@
#include <paludis/util/instantiation_policy.hh>
#include <paludis/util/private_implementation_pattern.hh>
#include <paludis/dep_list/dep_list.hh>
+#include <paludis/repository-fwd.hh>
#include <libwrapiter/libwrapiter_forward_iterator.hh>
namespace paludis
@@ -131,6 +132,14 @@ namespace paludis
///\}
+ ///\name Logic
+ ///\{
+
+ virtual void world_update_set(const SetName &);
+ virtual void world_update_packages(std::tr1::shared_ptr<const DepSpec>);
+
+ ///\}
+
/**
* Run the task.
*/
diff --git a/paludis/tasks/report_task.cc b/paludis/tasks/report_task.cc
index 9f457d2..91606b5 100644
--- a/paludis/tasks/report_task.cc
+++ b/paludis/tasks/report_task.cc
@@ -22,6 +22,7 @@
#include <paludis/dep_list/uninstall_list.hh>
#include <paludis/environment.hh>
#include <paludis/query.hh>
+#include <paludis/package_database.hh>
#include <set>
using namespace paludis;
diff --git a/paludis/tasks/sync_task.cc b/paludis/tasks/sync_task.cc
index ae97409..cfae99d 100644
--- a/paludis/tasks/sync_task.cc
+++ b/paludis/tasks/sync_task.cc
@@ -20,6 +20,8 @@
#include "sync_task.hh"
#include <paludis/environment.hh>
#include <paludis/syncer.hh>
+#include <paludis/package_database.hh>
+#include <paludis/hook.hh>
#include <list>
using namespace paludis;
diff --git a/paludis/tasks/uninstall_task.cc b/paludis/tasks/uninstall_task.cc
index 50a7506..0808bc0 100644
--- a/paludis/tasks/uninstall_task.cc
+++ b/paludis/tasks/uninstall_task.cc
@@ -24,6 +24,7 @@
#include <paludis/util/collection_concrete.hh>
#include <paludis/tasks/exceptions.hh>
#include <paludis/query.hh>
+#include <paludis/hook.hh>
#include <list>
using namespace paludis;
@@ -110,7 +111,7 @@ UninstallTask::add_target(const std::string & target)
else
try
{
- std::tr1::shared_ptr<DepSpec> spec(_imp->env->package_set(SetName(target)));
+ std::tr1::shared_ptr<DepSpec> spec(_imp->env->set(SetName(target)));
if (spec)
{
if (_imp->had_package_targets)
@@ -165,30 +166,6 @@ UninstallTask::add_unused()
throw InternalError(PALUDIS_HERE, "Trying to mix unused and normal targets?");
}
-namespace
-{
- struct WorldCallbacks :
- public Environment::WorldCallbacks
- {
- UninstallTask * const t;
-
- WorldCallbacks(UninstallTask * const tt) :
- t(tt)
- {
- }
-
- virtual void remove_callback(const PackageDepSpec & a)
- {
- t->on_update_world(a);
- }
-
- virtual void remove_callback(const SetName & a)
- {
- t->on_update_world(a);
- }
- };
-}
-
void
UninstallTask::execute()
{
@@ -254,6 +231,8 @@ UninstallTask::execute()
{
on_update_world_pre();
+#if 0
+
std::tr1::shared_ptr<AllDepSpec> all(new AllDepSpec);
std::map<QualifiedPackageName, std::set<VersionSpec> > being_removed;
@@ -286,6 +265,7 @@ UninstallTask::execute()
for (std::list<std::string>::const_iterator t(_imp->raw_targets.begin()),
t_end(_imp->raw_targets.end()) ; t != t_end ; ++t)
_imp->env->remove_set_from_world(SetName(*t), &w);
+#endif
on_update_world_post();
}
diff --git a/paludis/util/Makefile.am.m4 b/paludis/util/Makefile.am.m4
index 062a7a1..6faf230 100644
--- a/paludis/util/Makefile.am.m4
+++ b/paludis/util/Makefile.am.m4
@@ -23,6 +23,7 @@ $1_TEST_CXXFLAGS = -I$(top_srcdir)
')dnl
define(`addtestscript', `define(`testscriptlist', testscriptlist `$1_TEST_setup.sh $1_TEST_cleanup.sh')')dnl
define(`addhh', `define(`filelist', filelist `$1.hh')define(`headerlist', headerlist `$1.hh')')dnl
+define(`addfwd', `define(`filelist', filelist `$1-fwd.hh')define(`headerlist', headerlist `$1-fwd.hh')')dnl
define(`addhhx', `define(`filelist', filelist `$1.hh')')dnl
define(`addcc', `define(`filelist', filelist `$1.cc')')dnl
define(`addimpl', `define(`filelist', filelist `$1-impl.hh')')dnl
@@ -48,6 +49,7 @@ $1-se.cc : $1.se $(top_srcdir)/misc/make_se.bash
')dnl
define(`addthis', `dnl
ifelse(`$2', `hh', `addhh(`$1')', `')dnl
+ifelse(`$2', `fwd', `addfwd(`$1')', `')dnl
ifelse(`$2', `hhx', `addhhx(`$1')', `')dnl
ifelse(`$2', `cc', `addcc(`$1')', `')dnl
ifelse(`$2', `impl', `addimpl(`$1')', `')dnl
diff --git a/paludis/util/collection-fwd.hh b/paludis/util/collection-fwd.hh
new file mode 100644
index 0000000..fb0013d
--- /dev/null
+++ b/paludis/util/collection-fwd.hh
@@ -0,0 +1,37 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2005, 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
+ * 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_UTIL_COLLECTION_FWD_HH
+#define PALUDIS_GUARD_PALUDIS_UTIL_COLLECTION_FWD_HH 1
+
+#include <functional>
+
+namespace paludis
+{
+ template <typename>
+ class SequentialCollection;
+
+ template <typename T_, typename C_ = std::less<T_> >
+ class SortedCollection;
+
+ template <typename, typename>
+ class AssociativeCollection;
+}
+
+#endif
diff --git a/paludis/util/collection.hh b/paludis/util/collection.hh
index 70c27f7..0989f88 100644
--- a/paludis/util/collection.hh
+++ b/paludis/util/collection.hh
@@ -20,6 +20,7 @@
#ifndef PALUDIS_GUARD_PALUDIS_SEQUENTIAL_COLLECTION_HH
#define PALUDIS_GUARD_PALUDIS_SEQUENTIAL_COLLECTION_HH 1
+#include <paludis/util/collection-fwd.hh>
#include <paludis/util/instantiation_policy.hh>
#include <libwrapiter/libwrapiter.hh>
#include <iterator>
@@ -154,7 +155,7 @@ namespace paludis
* \ingroup grpcollections
* \nosubgrouping
*/
- template <typename T_, typename C_ = std::less<T_> >
+ template <typename T_, typename C_>
class PALUDIS_VISIBLE SortedCollection :
private InstantiationPolicy<SortedCollection<T_, C_>, instantiation_method::NonCopyableTag>,
public std::iterator<typename std::iterator_traits<
diff --git a/paludis/util/files.m4 b/paludis/util/files.m4
index 620cbf4..d3a84f4 100644
--- a/paludis/util/files.m4
+++ b/paludis/util/files.m4
@@ -9,7 +9,7 @@ dnl `test', `impl', `testscript'. Note that there isn't much error checking done
dnl on this file at present...
add(`attributes', `hh')
-add(`collection', `hh')
+add(`collection', `hh', `fwd')
add(`collection_concrete', `hhx')
add(`compare', `hh')
add(`comparison_policy', `hh')
diff --git a/paludis/util/iterator.hh b/paludis/util/iterator.hh
index 61971df..30ed9be 100644
--- a/paludis/util/iterator.hh
+++ b/paludis/util/iterator.hh
@@ -144,9 +144,9 @@ namespace paludis
* \nosubgrouping
*/
template <typename Iter_, typename Value_>
- class IndirectIterator : public std::iterator<typename std::iterator_traits<Iter_>::iterator_category, Value_>,
- public Comparisons<typename std::iterator_traits<Iter_>::iterator_category,
- Iter_, Value_>::Type
+ class IndirectIterator :
+ public std::iterator<typename std::iterator_traits<Iter_>::iterator_category, Value_>,
+ public Comparisons<typename std::iterator_traits<Iter_>::iterator_category, Iter_, Value_>::Type
{
private:
Iter_ _i;
@@ -226,10 +226,13 @@ namespace paludis
*
* \ingroup grpiterators
*/
- template <typename Value_, typename Iter_>
- IndirectIterator<Iter_, Value_> indirect_iterator(const Iter_ & i)
+ template <typename Iter_>
+ IndirectIterator<Iter_,
+ typename RemoveSharedPointer<typename std::tr1::remove_pointer<typename Iter_::value_type>::type>::Type>
+ indirect_iterator(const Iter_ & i)
{
- return IndirectIterator<Iter_, Value_>(i);
+ return IndirectIterator<Iter_,
+ typename RemoveSharedPointer<typename std::tr1::remove_pointer<typename Iter_::value_type>::type>::Type>(i);
}
/**
diff --git a/paludis/version_metadata.cc b/paludis/version_metadata.cc
index f17b10f..87c72b7 100644
--- a/paludis/version_metadata.cc
+++ b/paludis/version_metadata.cc
@@ -22,7 +22,7 @@
#include <paludis/version_metadata.hh>
#include <paludis/portage_dep_parser.hh>
#include <paludis/util/log.hh>
-#include <vector>
+#include <paludis/util/collection_concrete.hh>
/** \file
* Implementation of VersionMetadata.
@@ -72,6 +72,28 @@ VersionMetadataEbinInterface::bin_uri() const
PortageDepParser::Policy::text_is_text_dep_spec(false));
}
+std::tr1::shared_ptr<const KeywordNameCollection>
+VersionMetadataEbuildInterface::keywords() const
+{
+ Context context("When splitting up keyword string '" + keywords_string + "':");
+
+ std::tr1::shared_ptr<KeywordNameCollection> result(new KeywordNameCollection::Concrete);
+ WhitespaceTokeniser::get_instance()->tokenise(keywords_string,
+ create_inserter<KeywordName>(result->inserter()));
+ return result;
+}
+
+std::tr1::shared_ptr<const KeywordNameCollection>
+VersionMetadataCRANInterface::keywords() const
+{
+ Context context("When splitting up keyword string '" + keywords_string + "':");
+
+ std::tr1::shared_ptr<KeywordNameCollection> result(new KeywordNameCollection::Concrete);
+ WhitespaceTokeniser::get_instance()->tokenise(keywords_string,
+ create_inserter<KeywordName>(result->inserter()));
+ return result;
+}
+
VersionMetadataDepsInterface::VersionMetadataDepsInterface(const DepParserFunction & p) :
parser(p)
{
diff --git a/paludis/version_metadata.sr b/paludis/version_metadata.sr
index efb9839..22e7e0e 100644
--- a/paludis/version_metadata.sr
+++ b/paludis/version_metadata.sr
@@ -150,7 +150,7 @@ make_class_VersionMetadataEbuildInterface()
key provide_string std::string
key src_uri_string std::string
key restrict_string std::string
- key keywords std::string
+ key keywords_string std::string
key eclass_keywords std::string
key iuse std::string
key inherited std::string
@@ -166,9 +166,14 @@ END
std::tr1::shared_ptr<const DepSpec> provide() const;
/**
- * SRCU_URI, as a dep atom.
+ * SRC_URI, as a dep atom.
*/
std::tr1::shared_ptr<const DepSpec> src_uri() const;
+
+ /**
+ * Our keywords.
+ */
+ std::tr1::shared_ptr<const KeywordNameCollection> keywords() const;
END
allow_named_args
@@ -213,7 +218,7 @@ make_class_VersionMetadataCRANInterface()
{
inherit "public virtual VersionMetadataHasInterfaces"
- key keywords std::string
+ key keywords_string std::string
key package std::string
key version std::string
key is_bundle bool
@@ -229,6 +234,13 @@ make_class_VersionMetadataCRANInterface()
* \ingroup grpversions
*/
END
+
+ extra_methods <<END
+ /**
+ * Our keywords.
+ */
+ std::tr1::shared_ptr<const KeywordNameCollection> keywords() const;
+END
}
make_class_VersionMetadataVirtualInterface()
diff --git a/ruby/dep_list_TEST_setup.sh b/ruby/dep_list_TEST_setup.sh
index e8eb919..d04d8fb 100755
--- a/ruby/dep_list_TEST_setup.sh
+++ b/ruby/dep_list_TEST_setup.sh
@@ -22,12 +22,12 @@ provides_cache = /var/empty
END
cat <<END > home/.paludis/keywords.conf
-* test
+*/* test
~foo/bar-1.0 ~test
END
cat <<END > home/.paludis/use.conf
-* enabled
+*/* enabled
~foo/bar-1.0 sometimes_enabled
END
@@ -36,7 +36,7 @@ cat <<END > home/.paludis/package_mask.conf
END
cat <<END > home/.paludis/licenses.conf
-* *
+*/* *
END
mkdir -p testrepo/{eclass,distfiles,profiles/testprofile,foo/bar/files} || exit 1
diff --git a/ruby/environment.cc b/ruby/environment.cc
index 6b6ace8..870ca04 100644
--- a/ruby/environment.cc
+++ b/ruby/environment.cc
@@ -37,90 +37,20 @@ namespace
/*
* call-seq:
- * query_use(use_flag)
* query_use(use_flag, package_database_entry)
*
- * Does the user want the specified USE flag set, either globally or for a PackageDatabaseEntry.
+ * Does the user want the specified USE flag set for a PackageDatabaseEntry.
*/
VALUE
- environment_query_use(int argc, VALUE * argv, VALUE self)
+ environment_query_use(VALUE self, VALUE flag, VALUE pdev)
{
EnvironmentData * env_data;
Data_Get_Struct(self, EnvironmentData, env_data);
try
{
- if (1 == argc)
- return env_data->env_ptr->query_use(UseFlagName(StringValuePtr(argv[0])), 0) ? Qtrue : Qfalse;
- else if (2 == argc)
- {
- PackageDatabaseEntry pde = value_to_package_database_entry(argv[1]);
- return env_data->env_ptr->query_use(UseFlagName(StringValuePtr(argv[0])), &pde) ? Qtrue : Qfalse;
- }
- else
- rb_raise(rb_eArgError, "Environment.query_use expects one or two arguments, but got %d", argc);
- }
- catch (const std::exception & e)
- {
- exception_to_ruby_exception(e);
- }
- }
-
- /*
- * call-seq:
- * accept_keyword(keyword)
- * accept_keyword(keyword, package_database_entry)
- *
- * Is the specified KEYWORD set, either globally or for a PackageDatabaseEntry.
- */
- VALUE
- environment_accept_keyword(int argc, VALUE * argv, VALUE self)
- {
- EnvironmentData * env_data;
- Data_Get_Struct(self, EnvironmentData, env_data);
-
- try
- {
- if (1 == argc)
- return env_data->env_ptr->accept_keyword(KeywordName(StringValuePtr(argv[0])), 0) ? Qtrue : Qfalse;
- else if (2 == argc)
- {
- PackageDatabaseEntry pde = value_to_package_database_entry(argv[1]);
- return env_data->env_ptr->accept_keyword(KeywordName(StringValuePtr(argv[0])), &pde) ? Qtrue : Qfalse;
- }
- else
- rb_raise(rb_eArgError, "Environment.accept_keyword expects one or two arguments, but got %d", argc);
- }
- catch (const std::exception & e)
- {
- exception_to_ruby_exception(e);
- }
- }
-
- /*
- * call-seq:
- * accept_license(license)
- * accept_license(license, package_database_entry)
- *
- * Is the specified LICENSE set, either globally or for a PackageDatabaseEntry.
- */
- VALUE
- environment_accept_license(int argc, VALUE * argv, VALUE self)
- {
- EnvironmentData * env_data;
- Data_Get_Struct(self, EnvironmentData, env_data);
-
- try
- {
- if (1 == argc)
- return env_data->env_ptr->accept_license(std::string(StringValuePtr(argv[0])), 0) ? Qtrue : Qfalse;
- else if (2 == argc)
- {
- PackageDatabaseEntry pde = value_to_package_database_entry(argv[1]);
- return env_data->env_ptr->accept_license(std::string(StringValuePtr(argv[0])), &pde) ? Qtrue : Qfalse;
- }
- else
- rb_raise(rb_eArgError, "Environment.accept_license expects one or two arguments, but got %d", argc);
+ PackageDatabaseEntry pde(value_to_package_database_entry(pdev));
+ return env_data->env_ptr->query_use(UseFlagName(StringValuePtr(flag)), pde) ? Qtrue : Qfalse;
}
catch (const std::exception & e)
{
@@ -153,43 +83,6 @@ namespace
}
/*
- * Document-method: query_user_masks
- *
- * call-seq:
- * query_user_masks(package_database_entry) -> true or false
- *
- * Are there any user masks on a PackageDatabaseEntry?
- */
- /*
- * Document-method: query_user_unmasks
- *
- * call-seq:
- * query_user_unmasks(package_database_entry) -> true or false
- *
- * Are there any user unmasks on a PackageDatabaseEntry?
- */
- template <bool (Environment::* m_) (const PackageDatabaseEntry &) const>
- struct EnvBoolStruct
- {
- static VALUE
- fetch(VALUE self, VALUE pde_value)
- {
- EnvironmentData * env_data;
- Data_Get_Struct(self, EnvironmentData, env_data);
- PackageDatabaseEntry pde = value_to_package_database_entry(pde_value);
- try
- {
- return ((env_data->env_ptr)->*m_)(pde) ? Qtrue : Qfalse;
- }
- catch (const std::exception & e)
- {
- exception_to_ruby_exception(e);
- }
-
- }
- };
-
- /*
* Fetch our PackageDatabase.
*/
VALUE
@@ -210,19 +103,19 @@ namespace
/*
* call-seq:
- * package_set(set_name)
+ * set(set_name)
*
* Fetch a named package set as a DepSpec.
*/
VALUE
- environment_package_set(VALUE self, VALUE set_name)
+ environment_set(VALUE self, VALUE set_name)
{
EnvironmentData * env_data;
Data_Get_Struct(self, EnvironmentData, env_data);
try
{
- return dep_spec_to_value(env_data->env_ptr->package_set(SetName(StringValuePtr(set_name))));
+ return dep_spec_to_value(env_data->env_ptr->set(SetName(StringValuePtr(set_name))));
}
catch (const std::exception & e)
{
@@ -481,16 +374,10 @@ namespace
*/
c_environment = environment_class();
rb_funcall(c_environment, rb_intern("private_class_method"), 1, rb_str_new2("new"));
- rb_define_method(c_environment, "query_use", RUBY_FUNC_CAST(&environment_query_use), -1);
- rb_define_method(c_environment, "accept_keyword", RUBY_FUNC_CAST(&environment_accept_keyword), -1);
- rb_define_method(c_environment, "accept_license", RUBY_FUNC_CAST(&environment_accept_license), -1);
+ rb_define_method(c_environment, "query_use", RUBY_FUNC_CAST(&environment_query_use), 2);
rb_define_method(c_environment, "mask_reasons", RUBY_FUNC_CAST(&environment_mask_reasons), 1);
- rb_define_method(c_environment, "query_user_masks",
- RUBY_FUNC_CAST((&EnvBoolStruct<&Environment::query_user_masks>::fetch)), 1);
- rb_define_method(c_environment, "query_user_unmasks",
- RUBY_FUNC_CAST((&EnvBoolStruct<&Environment::query_user_unmasks>::fetch)), 1);
rb_define_method(c_environment, "package_database", RUBY_FUNC_CAST(&environment_package_database), 0);
- rb_define_method(c_environment, "package_set", RUBY_FUNC_CAST(&environment_package_set), 1);
+ rb_define_method(c_environment, "set", RUBY_FUNC_CAST(&environment_set), 1);
rb_define_method(c_environment, "root", RUBY_FUNC_CAST(&environment_root), 0);
rb_define_method(c_environment, "default_destinations", RUBY_FUNC_CAST(&environment_default_destinations), 0);
diff --git a/ruby/environment_TEST.rb b/ruby/environment_TEST.rb
index 44500b7..9c79081 100644
--- a/ruby/environment_TEST.rb
+++ b/ruby/environment_TEST.rb
@@ -78,9 +78,11 @@ module Paludis
end
def test_query_use
- assert env.query_use("enabled")
- assert ! env.query_use("not_enabled")
- assert ! env.query_use("sometimes_enabled")
+ pde = PackageDatabaseEntry.new("x/x", VersionSpec.new("1.0"), "testrepo")
+
+ assert env.query_use("enabled", pde)
+ assert ! env.query_use("not_enabled", pde)
+ assert ! env.query_use("sometimes_enabled", pde)
pde = PackageDatabaseEntry.new("foo/bar", VersionSpec.new("1.0"), "testrepo")
@@ -93,7 +95,7 @@ module Paludis
assert_raise ArgumentError do
env.query_use(1, 2, 3)
end
- assert_raise TypeError do
+ assert_raise ArgumentError do
env.query_use(123)
end
end
@@ -105,7 +107,8 @@ module Paludis
end
def test_query_use
- assert ! env.query_use("foo")
+ pde = PackageDatabaseEntry.new("x/x", VersionSpec.new("1.0"), "testrepo")
+ assert ! env.query_use("foo", pde)
pde = PackageDatabaseEntry.new("foo/bar", VersionSpec.new("1.0"), "testrepo")
assert ! env.query_use("foo", pde)
end
@@ -114,106 +117,8 @@ module Paludis
assert_raise ArgumentError do
env.query_use(1, 2, 3)
end
- assert_raise TypeError do
- env.query_use(123)
- end
- end
- end
-
- class TestCase_EnvironmentAcceptKeyword < Test::Unit::TestCase
- def env
- @env or @env = EnvironmentMaker.instance.make_from_spec("")
- end
-
- def test_accept_keyword
- assert env.accept_keyword("test")
- assert ! env.accept_keyword("bad")
- assert ! env.accept_keyword("~test")
-
- pde = PackageDatabaseEntry.new("foo/bar", "1.0", "testrepo")
-
- assert env.accept_keyword("test", pde)
- assert ! env.accept_keyword("bad", pde)
- assert env.accept_keyword("~test", pde)
- end
-
- def test_accept_keyword_bad
assert_raise ArgumentError do
- env.accept_keyword(1, 2, 3)
- end
- assert_raise TypeError do
- env.accept_keyword(123)
- end
- end
- end
-
- class TestCase_NoConfigEnvironmentAcceptKeyword < Test::Unit::TestCase
- def env
- NoConfigEnvironment.new(Dir.getwd().to_s + "/environment_TEST_dir/testrepo")
- end
-
- def test_accept_keyword
- assert env.accept_keyword("test")
- assert ! env.accept_keyword("bad")
- assert ! env.accept_keyword("~test")
-
- pde = PackageDatabaseEntry.new("foo/bar", "1.0", "testrepo")
-
- assert env.accept_keyword("test", pde)
- assert ! env.accept_keyword("bad", pde)
- assert ! env.accept_keyword("~test", pde)
- end
-
- def test_accept_keyword_bad
- assert_raise ArgumentError do
- env.accept_keyword(1, 2, 3)
- end
- assert_raise TypeError do
- env.accept_keyword(123)
- end
- end
- end
-
- class TestCase_EnvironmentAcceptLicense < Test::Unit::TestCase
- def env
- @env or @env = EnvironmentMaker.instance.make_from_spec("")
- end
-
- def test_accept_license
- assert env.accept_license("test")
-
- pde = PackageDatabaseEntry.new("foo/bar", VersionSpec.new("1.0"), "testrepo")
-
- assert env.accept_license("test", pde)
- end
-
- def test_accept_license_bad
- assert_raise ArgumentError do
- env.accept_license(1, 2, 3)
- end
- assert_raise TypeError do
- env.accept_license(123)
- end
- end
- end
-
- class TestCase_NoConfigEnvironmentAcceptLicense < Test::Unit::TestCase
- def env
- NoConfigEnvironment.new(Dir.getwd().to_s + "/environment_TEST_dir/testrepo")
- end
-
- def test_accept_license
- assert env.accept_license("test")
- pde = PackageDatabaseEntry.new("foo/bar", VersionSpec.new("1.0"), "testrepo")
- assert env.accept_license("test", pde)
- end
-
- def test_accept_license_bad
- assert_raise ArgumentError do
- env.accept_license(1, 2, 3)
- end
- assert_raise TypeError do
- env.accept_license(123)
+ env.query_use(123)
end
end
end
@@ -257,48 +162,6 @@ module Paludis
end
end
- class TestCase_EnvironmentQueryUserMasks < Test::Unit::TestCase
- def env
- @env or @env = EnvironmentMaker.instance.make_from_spec("")
- end
-
- def test_query_user_masks
- p2 = PackageDatabaseEntry.new("foo/bar", VersionSpec.new("2.0"), "testrepo")
- p3 = PackageDatabaseEntry.new("foo/bar", VersionSpec.new("3.0"), "testrepo")
-
- assert ! env.query_user_masks(p2)
- assert env.query_user_masks(p3)
- end
-
- def test_query_user_unmasks
- p2 = PackageDatabaseEntry.new("foo/bar", VersionSpec.new("2.0"), "testrepo")
- p3 = PackageDatabaseEntry.new("foo/bar", VersionSpec.new("3.0"), "testrepo")
-
- assert env.query_user_unmasks(p2)
- assert ! env.query_user_unmasks(p3)
- end
-
- def test_query_user_masks_bad
- p = PackageDatabaseEntry.new("foo/bar", VersionSpec.new("2.0"), "testrepo")
- assert_raise ArgumentError do
- env.query_user_masks(p, p)
- end
- assert_raise TypeError do
- env.query_user_masks(123)
- end
- end
-
- def test_query_user_unmasks_bad
- p = PackageDatabaseEntry.new("foo/bar", VersionSpec.new("2.0"), "testrepo")
- assert_raise ArgumentError do
- env.query_user_unmasks(p, p)
- end
- assert_raise TypeError do
- env.query_user_unmasks(123)
- end
- end
- end
-
class TestCase_EnvironmentPackageDatabase < Test::Unit::TestCase
def env
@env or @env = EnvironmentMaker.instance.make_from_spec("")
@@ -335,12 +198,12 @@ module Paludis
end
def test_package_set
- assert_kind_of DepSpec, env.package_set('everything')
+ assert_kind_of DepSpec, env.set('everything')
end
def test_package_set_error
assert_raise SetNameError do
- env.package_set('broken*')
+ env.set('broken*')
end
end
end
@@ -351,12 +214,12 @@ module Paludis
end
def test_package_set
- assert_kind_of DepSpec, env.package_set('everything')
+ assert_kind_of DepSpec, env.set('everything')
end
def test_package_set_error
assert_raise SetNameError do
- env.package_set('broken*')
+ env.set('broken*')
end
end
end
@@ -378,7 +241,7 @@ module Paludis
def env_master
NoConfigEnvironment.new(Dir.getwd().to_s + "/environment_TEST_dir/testrepo",
- "/var/empty",
+ "/var/empty",
Dir.getwd().to_s + "/environment_TEST_dir/slaverepo")
end
diff --git a/ruby/environment_TEST_setup.sh b/ruby/environment_TEST_setup.sh
index f1ce079..f83a38a 100755
--- a/ruby/environment_TEST_setup.sh
+++ b/ruby/environment_TEST_setup.sh
@@ -15,12 +15,12 @@ profiles = \${location}/profiles/testprofile
END
cat <<END > home/.paludis/keywords.conf
-* test
+*/* test
~foo/bar-1.0 ~test
END
cat <<END > home/.paludis/use.conf
-* enabled
+*/* enabled
~foo/bar-1.0 sometimes_enabled
END
@@ -33,7 +33,7 @@ cat <<END > home/.paludis/package_unmask.conf
END
cat <<END > home/.paludis/licenses.conf
-* *
+*/* *
END
mkdir -p testrepo/{eclass,distfiles,profiles/testprofile,foo/bar/files} || exit 1
diff --git a/ruby/package_database_TEST_setup.sh b/ruby/package_database_TEST_setup.sh
index c8029de..9182e80 100755
--- a/ruby/package_database_TEST_setup.sh
+++ b/ruby/package_database_TEST_setup.sh
@@ -15,17 +15,17 @@ profiles = \${location}/profiles/testprofile
END
cat <<END > home/.paludis/keywords.conf
-* test
+*/* test
~foo/bar-1 ~test
END
cat <<END > home/.paludis/use.conf
-* enabled
+*/* enabled
~foo/bar-1 sometimes_enabled
END
cat <<END > home/.paludis/licenses.conf
-* *
+*/* *
END
mkdir -p testrepo/{eclass,distfiles,profiles/testprofile,foo/bar/files,foo/baz/files,quux/baz/files} || exit 1
diff --git a/ruby/paludis_ruby_TEST_setup.sh b/ruby/paludis_ruby_TEST_setup.sh
index 4a17c7e..5581fd1 100755
--- a/ruby/paludis_ruby_TEST_setup.sh
+++ b/ruby/paludis_ruby_TEST_setup.sh
@@ -15,17 +15,17 @@ profiles = \${location}/profiles/testprofile
END
cat <<END > home/.paludis/keywords.conf
-* test
+*/* test
~foo/bar-1 ~test
END
cat <<END > home/.paludis/use.conf
-* enabled
+*/* enabled
~foo/bar-1 sometimes_enabled
END
cat <<END > home/.paludis/licenses.conf
-* *
+*/* *
END
mkdir -p testrepo/{eclass,distfiles,profiles/testprofile,foo/bar/files} || exit 1
diff --git a/ruby/repository_TEST_setup.sh b/ruby/repository_TEST_setup.sh
index 52f35e0..b32f16d 100755
--- a/ruby/repository_TEST_setup.sh
+++ b/ruby/repository_TEST_setup.sh
@@ -22,17 +22,17 @@ provides_cache = /var/empty
END
cat <<END > home/.paludis/keywords.conf
-* test
+*/* test
~foo/bar-1 ~test
END
cat <<END > home/.paludis/use.conf
-* enabled
+*/* enabled
~foo/bar-1 sometimes_enabled
END
cat <<END > home/.paludis/licenses.conf
-* *
+*/* *
END
mkdir -p testrepo/{eclass,distfiles,profiles/testprofile,foo/bar/files} || exit 1
diff --git a/ruby/version_metadata.cc b/ruby/version_metadata.cc
index be6b368..8d6bfde 100644
--- a/ruby/version_metadata.cc
+++ b/ruby/version_metadata.cc
@@ -455,18 +455,18 @@ namespace
/*
* call-seq:
- * keywords -> String
+ * keywords_string -> String
*
* Fetches the package keywords, if ebuild_interface or cran_interface is not Nil.
*/
- VALUE version_metadata_keywords(VALUE self)
+ VALUE version_metadata_keywords_string(VALUE self)
{
std::tr1::shared_ptr<const VersionMetadata> * self_ptr;
Data_Get_Struct(self, std::tr1::shared_ptr<const VersionMetadata>, self_ptr);
if ((*self_ptr)->ebuild_interface)
- return rb_str_new2(((*self_ptr)->ebuild_interface->keywords).c_str());
+ return rb_str_new2(((*self_ptr)->ebuild_interface->keywords_string).c_str());
if ((*self_ptr)->cran_interface)
- return rb_str_new2(((*self_ptr)->cran_interface->keywords).c_str());
+ return rb_str_new2(((*self_ptr)->cran_interface->keywords_string).c_str());
else
return Qnil;
}
@@ -541,7 +541,7 @@ namespace
&VersionMetadataCRANInterface::version>::fetch)), 0);
rb_define_method(c_version_metadata, "is_bundle?", RUBY_FUNC_CAST(&version_metadata_is_bundle), 0);
- rb_define_method(c_version_metadata, "keywords", RUBY_FUNC_CAST(&version_metadata_keywords), 0);
+ rb_define_method(c_version_metadata, "keywords_string", RUBY_FUNC_CAST(&version_metadata_keywords_string), 0);
}
}
diff --git a/ruby/version_metadata_TEST.rb b/ruby/version_metadata_TEST.rb
index 3e7b122..f4217be 100644
--- a/ruby/version_metadata_TEST.rb
+++ b/ruby/version_metadata_TEST.rb
@@ -76,7 +76,7 @@ module Paludis
assert_equal "", vmd("1.0").provide_string
assert_equal "http://example.com/bar-1.0.tar.bz2", vmd("1.0").src_uri_string
assert_equal "monkey", vmd("1.0").restrict_string
- assert_equal "test", vmd("1.0").keywords.gsub(%r/\s/, "")
+ assert_equal "test", vmd("1.0").keywords_string.gsub(%r/\s/, "")
assert_equal "", vmd("1.0").iuse.gsub(%r/\s/, "")
end
diff --git a/src/clients/adjutrix/Makefile.am b/src/clients/adjutrix/Makefile.am
index 84c69d1..4749c9a 100644
--- a/src/clients/adjutrix/Makefile.am
+++ b/src/clients/adjutrix/Makefile.am
@@ -69,6 +69,7 @@ TESTS_ENVIRONMENT = env \
PALUDIS_REPOSITORY_SO_DIR="`$(top_srcdir)/paludis/repositories/gentoo/ebuild/utils/canonicalise $(top_builddir)/paludis/repositories`" \
SYSCONFDIR="$(sysconfdir)" \
ADJUTRIX_OPTIONS="" \
+ TEST_OUTPUT_WRAPPER="`$(top_srcdir)/paludis/repositories/gentoo/ebuild/utils/canonicalise $(top_srcdir)/paludis/util/outputwrapper`" \
bash $(top_srcdir)/test/run_test.sh bash
TESTS = version_TEST help_TEST find_stable_candidates_TEST args_from_environment_TEST
diff --git a/src/clients/adjutrix/display_default_system_resolution.cc b/src/clients/adjutrix/display_default_system_resolution.cc
index 4545737..e1aa8bd 100644
--- a/src/clients/adjutrix/display_default_system_resolution.cc
+++ b/src/clients/adjutrix/display_default_system_resolution.cc
@@ -75,7 +75,7 @@ namespace
try
{
- d.add(env.package_set(SetName("system")), env.default_destinations());
+ d.add(env.set(SetName("system")), env.default_destinations());
for (DepList::Iterator e(d.begin()), e_end(d.end()) ; e != e_end ; ++e)
cout << " " << e->package << ":" << e->metadata->slot << endl;
diff --git a/src/clients/adjutrix/display_profiles_use.cc b/src/clients/adjutrix/display_profiles_use.cc
index f124684..c767861 100644
--- a/src/clients/adjutrix/display_profiles_use.cc
+++ b/src/clients/adjutrix/display_profiles_use.cc
@@ -21,6 +21,7 @@
#include "command_line.hh"
#include <output/colour.hh>
#include <paludis/config_file.hh>
+#include <paludis/package_database.hh>
#include <paludis/util/log.hh>
#include <paludis/util/tokeniser.hh>
#include <paludis/util/dir_iterator.hh>
@@ -78,7 +79,7 @@ namespace
env.package_database()->favourite_repository());
for (std::set<UseFlagName>::const_iterator u(all_use.begin()), u_end(all_use.end()) ;
u != u_end ; ++u)
- if (env.query_use(*u, &e))
+ if (env.query_use(*u, e))
cout << *u << " ";
std::string current_prefix("not on a boat");
@@ -89,7 +90,7 @@ namespace
cout << endl << std::setw(20) << (upperify(stringify(u->first)) + ":");
current_prefix = u->first;
- if (env.query_use(UseFlagName(current_prefix + "_" + stringify(u->second)), &e))
+ if (env.query_use(UseFlagName(current_prefix + "_" + stringify(u->second)), e))
cout << u->second << " ";
}
diff --git a/src/clients/adjutrix/downgrade_check.cc b/src/clients/adjutrix/downgrade_check.cc
index 991ce9b..2ad5a1c 100644
--- a/src/clients/adjutrix/downgrade_check.cc
+++ b/src/clients/adjutrix/downgrade_check.cc
@@ -20,6 +20,7 @@
#include "downgrade_check.hh"
#include "command_line.hh"
#include <paludis/query.hh>
+#include <paludis/package_database.hh>
#include <paludis/util/sr.hh>
#include <paludis/util/compare.hh>
#include <paludis/util/tokeniser.hh>
diff --git a/src/clients/adjutrix/find_dropped_keywords.cc b/src/clients/adjutrix/find_dropped_keywords.cc
index 86671cd..d984d18 100644
--- a/src/clients/adjutrix/find_dropped_keywords.cc
+++ b/src/clients/adjutrix/find_dropped_keywords.cc
@@ -22,6 +22,10 @@
#include <paludis/util/tokeniser.hh>
#include <paludis/util/compare.hh>
+#include <paludis/util/iterator.hh>
+#include <paludis/version_spec.hh>
+#include <paludis/repository.hh>
+#include <paludis/package_database.hh>
#include <set>
#include <map>
@@ -120,18 +124,15 @@ namespace
if (! metadata->ebuild_interface)
continue;
- std::set<KeywordName> keywords;
- WhitespaceTokeniser::get_instance()->tokenise(metadata->ebuild_interface->keywords,
- create_inserter<KeywordName>(std::inserter(keywords, keywords.end())));
-
+ std::tr1::shared_ptr<const KeywordNameCollection> keywords(metadata->ebuild_interface->keywords());;
/* ensure that there's an entry for this SLOT */
versions_in_slots.insert(std::make_pair(metadata->slot, VersionsEntry(
VersionsEntry::create()
.best_keyworded(VersionSpec("0"))
.best_anywhere(VersionSpec("0")))));
- if (keywords.end() != keywords.find(keyword) ||
- keywords.end() != keywords.find(KeywordName("~" + stringify(keyword))))
+ if (keywords->end() != keywords->find(keyword) ||
+ keywords->end() != keywords->find(KeywordName("~" + stringify(keyword))))
{
is_interesting = true;
versions_in_slots.find(metadata->slot)->second.best_keyworded =
@@ -139,7 +140,7 @@ namespace
worst_keyworded = std::min(worst_keyworded, *v);
}
- if (keywords.end() != std::find_if(keywords.begin(), keywords.end(), IsStableOrUnstableKeyword()))
+ if (keywords->end() != std::find_if(keywords->begin(), keywords->end(), IsStableOrUnstableKeyword()))
versions_in_slots.find(metadata->slot)->second.best_anywhere =
std::max(versions_in_slots.find(metadata->slot)->second.best_anywhere, *v);
}
diff --git a/src/clients/adjutrix/find_insecure_packages.cc b/src/clients/adjutrix/find_insecure_packages.cc
index 540fb5e..b71f5ec 100644
--- a/src/clients/adjutrix/find_insecure_packages.cc
+++ b/src/clients/adjutrix/find_insecure_packages.cc
@@ -23,6 +23,8 @@
#include <paludis/util/tokeniser.hh>
#include <paludis/util/compare.hh>
#include <paludis/query.hh>
+#include <paludis/dep_spec.hh>
+#include <paludis/package_database.hh>
#include <set>
#include <map>
diff --git a/src/clients/adjutrix/find_reverse_deps.cc b/src/clients/adjutrix/find_reverse_deps.cc
index 38bb0e0..256953e 100644
--- a/src/clients/adjutrix/find_reverse_deps.cc
+++ b/src/clients/adjutrix/find_reverse_deps.cc
@@ -26,6 +26,8 @@
#include <paludis/util/save.hh>
#include <paludis/util/log.hh>
#include <paludis/query.hh>
+#include <paludis/dep_spec.hh>
+#include <paludis/package_database.hh>
#include <set>
#include <map>
diff --git a/src/clients/adjutrix/find_stable_candidates.cc b/src/clients/adjutrix/find_stable_candidates.cc
index 3cebc69..adbc5c6 100644
--- a/src/clients/adjutrix/find_stable_candidates.cc
+++ b/src/clients/adjutrix/find_stable_candidates.cc
@@ -22,6 +22,10 @@
#include <paludis/util/tokeniser.hh>
#include <paludis/util/compare.hh>
+#include <paludis/util/iterator.hh>
+#include <paludis/version_spec.hh>
+#include <paludis/repository.hh>
+#include <paludis/package_database.hh>
#include <set>
#include <map>
@@ -119,11 +123,9 @@ namespace
if (! metadata->ebuild_interface)
continue;
- std::set<KeywordName> keywords;
- WhitespaceTokeniser::get_instance()->tokenise(metadata->ebuild_interface->keywords,
- create_inserter<KeywordName>(std::inserter(keywords, keywords.end())));
+ std::tr1::shared_ptr<const KeywordNameCollection> keywords(metadata->ebuild_interface->keywords());
- if (keywords.end() != keywords.find(keyword))
+ if (keywords->end() != keywords->find(keyword))
{
is_interesting = true;
@@ -135,7 +137,7 @@ namespace
.best_version(VersionSpec("0")))));
}
- if (keywords.end() != std::find_if(keywords.begin(), keywords.end(), IsStableKeyword()))
+ if (keywords->end() != std::find_if(keywords->begin(), keywords->end(), IsStableKeyword()))
{
/* ensure that an entry exists */
slots_to_versions.insert(std::make_pair(metadata->slot,
diff --git a/src/clients/adjutrix/keywords_graph.cc b/src/clients/adjutrix/keywords_graph.cc
index 1be0e34..bf9a252 100644
--- a/src/clients/adjutrix/keywords_graph.cc
+++ b/src/clients/adjutrix/keywords_graph.cc
@@ -141,20 +141,18 @@ namespace
cout << std::left << std::setw(version_specs_columns_width) << p->version << "| ";
- std::set<KeywordName> keywords;
- WhitespaceTokeniser::get_instance()->tokenise(metadata->ebuild_interface->keywords,
- create_inserter<KeywordName>(std::inserter(keywords, keywords.end())));
+ std::tr1::shared_ptr<const KeywordNameCollection> keywords(metadata->ebuild_interface->keywords());
for (UseFlagNameCollection::Iterator a(arch_flags->begin()), a_end(arch_flags->end()) ;
a != a_end ; ++a)
{
- if (keywords.end() != keywords.find(KeywordName(stringify(*a))))
+ if (keywords->end() != keywords->find(KeywordName(stringify(*a))))
cout << colour(cl_bold_green, "+ ");
- else if (keywords.end() != keywords.find(KeywordName("~" + stringify(*a))))
+ else if (keywords->end() != keywords->find(KeywordName("~" + stringify(*a))))
cout << colour(cl_bold_yellow, "~ ");
- else if (keywords.end() != keywords.find(KeywordName("-" + stringify(*a))))
+ else if (keywords->end() != keywords->find(KeywordName("-" + stringify(*a))))
cout << colour(cl_red, "- ");
- else if (keywords.end() != keywords.find(KeywordName("-*")))
+ else if (keywords->end() != keywords->find(KeywordName("-*")))
cout << colour(cl_red, "* ");
else
cout << " ";
diff --git a/src/clients/adjutrix/what_needs_keywording.cc b/src/clients/adjutrix/what_needs_keywording.cc
index c9c40c2..74fd437 100644
--- a/src/clients/adjutrix/what_needs_keywording.cc
+++ b/src/clients/adjutrix/what_needs_keywording.cc
@@ -106,14 +106,12 @@ int do_what_needs_keywording(NoConfigEnvironment & env)
p->package.version));
if (m->ebuild_interface)
{
- std::set<std::string> keywords;
- WhitespaceTokeniser::get_instance()->tokenise(m->ebuild_interface->keywords,
- std::inserter(keywords, keywords.end()));
- for (std::set<std::string>::const_iterator k(keywords.begin()), k_end(keywords.end()) ;
+ std::tr1::shared_ptr<const KeywordNameCollection> keywords(m->ebuild_interface->keywords());
+ for (KeywordNameCollection::Iterator k(keywords->begin()), k_end(keywords->end()) ;
k != k_end ; ++k)
- if (*k == "-*"
- || *k == stringify(target_keyword)
- || k->substr(1) == stringify(target_arch))
+ if (*k == KeywordName("-*")
+ || *k == target_keyword
+ || k->data().substr(1) == stringify(target_arch))
current.append(stringify(*k) + " ");
}
diff --git a/src/clients/contrarius/Makefile.am b/src/clients/contrarius/Makefile.am
index 04ef28a..baebf96 100644
--- a/src/clients/contrarius/Makefile.am
+++ b/src/clients/contrarius/Makefile.am
@@ -30,6 +30,7 @@ contrarius_SOURCES = \
contrarius_LDADD = \
$(top_builddir)/paludis/libpaludis.la \
+ $(top_builddir)/paludis/environments/adapted/libpaludisadaptedenvironment.la \
$(top_builddir)/paludis/environments/libpaludisenvironments.la \
$(top_builddir)/paludis/tasks/libpaludistasks.la \
$(top_builddir)/paludis/args/libpaludisargs.la \
diff --git a/src/clients/contrarius/contrarius.cc b/src/clients/contrarius/contrarius.cc
index 4433027..0c8dbee 100644
--- a/src/clients/contrarius/contrarius.cc
+++ b/src/clients/contrarius/contrarius.cc
@@ -20,6 +20,7 @@
#include <paludis/args/args.hh>
#include <paludis/paludis.hh>
#include <paludis/environments/environment_maker.hh>
+#include <paludis/environments/adapted/adapted_environment.hh>
#include <paludis/util/util.hh>
#include <cstdlib>
@@ -72,7 +73,8 @@ int main(int argc, char *argv[])
else
stage = "cxx";
- std::tr1::shared_ptr<Environment> env(EnvironmentMaker::get_instance()->make_from_spec(""));
+ std::tr1::shared_ptr<AdaptedEnvironment> env(
+ new AdaptedEnvironment(EnvironmentMaker::get_instance()->make_from_spec("")));
StageOptions stage_opts(CommandLine::get_instance()->a_pretend.specified(),
CommandLine::get_instance()->a_fetch.specified(),
diff --git a/src/clients/contrarius/install.cc b/src/clients/contrarius/install.cc
index f0d9b9d..237db86 100644
--- a/src/clients/contrarius/install.cc
+++ b/src/clients/contrarius/install.cc
@@ -346,7 +346,7 @@ do_install(std::tr1::shared_ptr<Environment> env, std::string spec_str)
{
cerr << " ";
- LicenceDisplayer ld(cerr, env.get(), &*pp);
+ LicenceDisplayer ld(cerr, env.get(), *pp);
meta->license_interface->license()->accept(&ld);
}
}
@@ -358,14 +358,9 @@ do_install(std::tr1::shared_ptr<Environment> env, std::string spec_str)
pp->name, pp->version));
if (meta->ebuild_interface)
{
- std::set<KeywordName> keywords;
- WhitespaceTokeniser::get_instance()->tokenise(
- meta->ebuild_interface->keywords,
- create_inserter<KeywordName>(
- std::inserter(keywords, keywords.end())));
-
- cerr << " ( " << colour(cl_masked, join(keywords.begin(),
- keywords.end(), " ")) << " )";
+ std::tr1::shared_ptr<const KeywordNameCollection> keywords(meta->ebuild_interface->keywords());
+ cerr << " ( " << colour(cl_masked, join(keywords->begin(),
+ keywords->end(), " ")) << " )";
}
}
diff --git a/src/clients/contrarius/stage.cc b/src/clients/contrarius/stage.cc
index 68b70ad..79285f1 100644
--- a/src/clients/contrarius/stage.cc
+++ b/src/clients/contrarius/stage.cc
@@ -21,6 +21,8 @@
#include <paludis/util/tokeniser.hh>
#include <paludis/config_file.hh>
#include <paludis/portage_dep_parser.hh>
+#include <paludis/package_database.hh>
+#include <paludis/environments/adapted/adapted_environment.hh>
#include <paludis/query.hh>
#include <string>
#include <tr1/memory>
@@ -64,7 +66,7 @@ BinutilsStage::build(const StageOptions &) const
std::tr1::shared_ptr<PackageDepSpec> binutils(new PackageDepSpec(TargetConfig::get_instance()->binutils(),
pds_pm_permissive));
- _env->clear_forced_use();
+ _env->clear_adaptions();
return 0 == do_install(_env, stringify(*binutils));
}
@@ -86,9 +88,9 @@ KernelHeadersStage::build(const StageOptions &) const
std::tr1::shared_ptr<PackageDepSpec> headers(new PackageDepSpec(TargetConfig::get_instance()->headers(),
pds_pm_permissive));
- _env->clear_forced_use();
+ _env->clear_adaptions();
- _env->force_use(headers, UseFlagName("crosscompile_opts_headers-only"), use_enabled);
+ _env->adapt_use(headers, UseFlagName("crosscompile_opts_headers-only"), use_enabled);
return 0 == do_install(_env, stringify(*headers));
}
@@ -110,17 +112,17 @@ MinimalStage::build(const StageOptions &) const
std::tr1::shared_ptr<PackageDepSpec> gcc(new PackageDepSpec(TargetConfig::get_instance()->gcc(),
pds_pm_permissive));
- _env->clear_forced_use();
+ _env->clear_adaptions();
- _env->force_use(gcc, UseFlagName("boundschecking"), use_disabled);
- _env->force_use(gcc, UseFlagName("fortran"), use_disabled);
- _env->force_use(gcc, UseFlagName("gtk"), use_disabled);
- _env->force_use(gcc, UseFlagName("gcj"), use_disabled);
- _env->force_use(gcc, UseFlagName("mudflap"), use_disabled);
- _env->force_use(gcc, UseFlagName("objc"), use_disabled);
- _env->force_use(gcc, UseFlagName("objc-gc"), use_disabled);
- _env->force_use(gcc, UseFlagName("nocxx"), use_enabled);
- _env->force_use(gcc, UseFlagName("crosscompile_opts_bootstrap"), use_enabled);
+ _env->adapt_use(gcc, UseFlagName("boundschecking"), use_disabled);
+ _env->adapt_use(gcc, UseFlagName("fortran"), use_disabled);
+ _env->adapt_use(gcc, UseFlagName("gtk"), use_disabled);
+ _env->adapt_use(gcc, UseFlagName("gcj"), use_disabled);
+ _env->adapt_use(gcc, UseFlagName("mudflap"), use_disabled);
+ _env->adapt_use(gcc, UseFlagName("objc"), use_disabled);
+ _env->adapt_use(gcc, UseFlagName("objc-gc"), use_disabled);
+ _env->adapt_use(gcc, UseFlagName("nocxx"), use_enabled);
+ _env->adapt_use(gcc, UseFlagName("crosscompile_opts_bootstrap"), use_enabled);
return 0 == do_install(_env, stringify(*gcc));
}
@@ -142,7 +144,7 @@ LibCStage::build(const StageOptions &) const
std::tr1::shared_ptr<PackageDepSpec> libc(new PackageDepSpec(TargetConfig::get_instance()->libc(),
pds_pm_permissive));
- _env->clear_forced_use();
+ _env->clear_adaptions();
return 0 == do_install(_env, stringify(*libc));
}
@@ -158,7 +160,7 @@ LibCStage::is_rebuild() const
if (c->empty())
return false;
- return (! _env->query_use(UseFlagName("crosscompile_opts_headers-only"), &(*c->last())));
+ return (! _env->query_use(UseFlagName("crosscompile_opts_headers-only"), *c->last()));
}
int
@@ -169,14 +171,14 @@ FullStage::build(const StageOptions &) const
std::tr1::shared_ptr<PackageDepSpec> gcc(new PackageDepSpec(TargetConfig::get_instance()->gcc(),
pds_pm_permissive));
- _env->clear_forced_use();
+ _env->clear_adaptions();
- _env->force_use(gcc, UseFlagName("boundschecking"), use_disabled);
- _env->force_use(gcc, UseFlagName("gtk"), use_disabled);
- _env->force_use(gcc, UseFlagName("gcj"), use_disabled);
- _env->force_use(gcc, UseFlagName("mudflap"), use_disabled);
- _env->force_use(gcc, UseFlagName("objc"), use_disabled);
- _env->force_use(gcc, UseFlagName("objc-gc"), use_disabled);
+ _env->adapt_use(gcc, UseFlagName("boundschecking"), use_disabled);
+ _env->adapt_use(gcc, UseFlagName("gtk"), use_disabled);
+ _env->adapt_use(gcc, UseFlagName("gcj"), use_disabled);
+ _env->adapt_use(gcc, UseFlagName("mudflap"), use_disabled);
+ _env->adapt_use(gcc, UseFlagName("objc"), use_disabled);
+ _env->adapt_use(gcc, UseFlagName("objc-gc"), use_disabled);
return 0 == do_install(_env, stringify(*gcc));
}
@@ -192,6 +194,6 @@ FullStage::is_rebuild() const
if (c->empty())
return false;
- return (! _env->query_use(UseFlagName("nocxx"), &(*c->last())));
+ return (! _env->query_use(UseFlagName("nocxx"), *c->last()));
}
diff --git a/src/clients/contrarius/stage.hh b/src/clients/contrarius/stage.hh
index 312d149..1e4a7bb 100644
--- a/src/clients/contrarius/stage.hh
+++ b/src/clients/contrarius/stage.hh
@@ -29,7 +29,7 @@
namespace paludis
{
- class Environment;
+ class AdaptedEnvironment;
#include <src/clients/contrarius/contrarius_stage_options-sr.hh>
@@ -37,10 +37,10 @@ namespace paludis
public StageBase
{
protected:
- std::tr1::shared_ptr<Environment> _env;
+ std::tr1::shared_ptr<AdaptedEnvironment> _env;
public:
- ContrariusStage(std::tr1::shared_ptr<Environment> e) :
+ ContrariusStage(std::tr1::shared_ptr<AdaptedEnvironment> e) :
_env(e)
{
}
@@ -50,7 +50,7 @@ namespace paludis
public ContrariusStage
{
public:
- AuxiliaryStage(std::tr1::shared_ptr<Environment> e) :
+ AuxiliaryStage(std::tr1::shared_ptr<AdaptedEnvironment> e) :
ContrariusStage(e)
{
}
@@ -74,7 +74,7 @@ namespace paludis
public ContrariusStage
{
public:
- BinutilsStage(std::tr1::shared_ptr<Environment> e) :
+ BinutilsStage(std::tr1::shared_ptr<AdaptedEnvironment> e) :
ContrariusStage(e)
{
}
@@ -98,7 +98,7 @@ namespace paludis
public ContrariusStage
{
public:
- KernelHeadersStage(std::tr1::shared_ptr<Environment> e) :
+ KernelHeadersStage(std::tr1::shared_ptr<AdaptedEnvironment> e) :
ContrariusStage(e)
{
}
@@ -122,7 +122,7 @@ namespace paludis
public ContrariusStage
{
public:
- MinimalStage(std::tr1::shared_ptr<Environment> e) :
+ MinimalStage(std::tr1::shared_ptr<AdaptedEnvironment> e) :
ContrariusStage(e)
{
}
@@ -146,7 +146,7 @@ namespace paludis
public ContrariusStage
{
public:
- LibCStage(std::tr1::shared_ptr<Environment> e) :
+ LibCStage(std::tr1::shared_ptr<AdaptedEnvironment> e) :
ContrariusStage(e)
{
}
@@ -171,7 +171,7 @@ namespace paludis
public ContrariusStage
{
public:
- FullStage(std::tr1::shared_ptr<Environment> e) :
+ FullStage(std::tr1::shared_ptr<AdaptedEnvironment> e) :
ContrariusStage(e)
{
}
diff --git a/src/clients/contrarius/stage_builder.cc b/src/clients/contrarius/stage_builder.cc
index 661cffb..5575ce1 100644
--- a/src/clients/contrarius/stage_builder.cc
+++ b/src/clients/contrarius/stage_builder.cc
@@ -18,6 +18,7 @@
*/
#include <paludis/tasks/stage_builder_task.hh>
+#include <paludis/environment.hh>
#include <src/clients/contrarius/stage.hh>
#include <src/clients/contrarius/stage_builder.hh>
#include <src/output/colour.hh>
diff --git a/src/clients/inquisitio/description_extractor.cc b/src/clients/inquisitio/description_extractor.cc
index 1e2a506..7c3d919 100644
--- a/src/clients/inquisitio/description_extractor.cc
+++ b/src/clients/inquisitio/description_extractor.cc
@@ -18,6 +18,7 @@
*/
#include "description_extractor.hh"
+#include <paludis/package_database.hh>
using namespace paludis;
using namespace inquisitio;
diff --git a/src/clients/inquisitio/do_search.cc b/src/clients/inquisitio/do_search.cc
index 7659db2..cf8576b 100644
--- a/src/clients/inquisitio/do_search.cc
+++ b/src/clients/inquisitio/do_search.cc
@@ -25,6 +25,8 @@
#include <paludis/environment.hh>
#include <paludis/query.hh>
+#include <paludis/package_database.hh>
+#include <paludis/util/iterator.hh>
#include <list>
#include <set>
#include <iostream>
diff --git a/src/clients/paludis/Makefile.am b/src/clients/paludis/Makefile.am
index 57657c1..be33e4f 100644
--- a/src/clients/paludis/Makefile.am
+++ b/src/clients/paludis/Makefile.am
@@ -85,6 +85,7 @@ TESTS_ENVIRONMENT = env \
PALUDIS_ENVIRONMENT_SO_DIR="`$(top_srcdir)/paludis/repositories/gentoo/ebuild/utils/canonicalise $(top_builddir)/paludis/environments`" \
PALUDIS_NO_CHOWN="yupyup" \
PALUDIS_REDUCED_USERNAME="`id -un`" \
+ TEST_OUTPUT_WRAPPER="`$(top_srcdir)/paludis/repositories/gentoo/ebuild/utils/canonicalise $(top_srcdir)/paludis/util/outputwrapper`" \
SYSCONFDIR="$(sysconfdir)" \
bash $(top_srcdir)/test/run_test.sh bash
diff --git a/src/clients/paludis/applets.cc b/src/clients/paludis/applets.cc
index 955e034..493ab34 100644
--- a/src/clients/paludis/applets.cc
+++ b/src/clients/paludis/applets.cc
@@ -187,12 +187,9 @@ int do_list_sync_protocols(std::tr1::shared_ptr<Environment> env)
{
std::map<std::string, std::string> syncers;
- std::list<std::string> syncers_dirs;
- WhitespaceTokeniser::get_instance()->tokenise(env->syncers_dirs(),
- std::back_inserter(syncers_dirs));
-
- for (std::list<std::string>::const_iterator d(syncers_dirs.begin()),
- d_end(syncers_dirs.end()) ; d != d_end ; ++d)
+ std::tr1::shared_ptr<const FSEntryCollection> sd(env->syncers_dirs());
+ for (FSEntryCollection::Iterator d(sd->begin()),
+ d_end(sd->end()) ; d != d_end ; ++d)
{
FSEntry dir(*d);
if (! dir.is_directory())
@@ -221,7 +218,7 @@ int do_list_sync_protocols(std::tr1::shared_ptr<Environment> env)
{
std::cout << "* " << colour(cl_key_name, s->first) << std::endl;
if (0 != run_command(Command(s->second + " --help")
- .with_setenv("PALUDIS_FETCHERS_DIRS", env->fetchers_dirs())
+ .with_setenv("PALUDIS_FETCHERS_DIRS", join(sd->begin(), sd->end(), " "))
.with_setenv("PALUDIS_EBUILD_DIR", getenv_with_default("PALUDIS_EBUILD_DIR", LIBEXECDIR "/paludis"))))
Log::get_instance()->message(ll_warning, lc_context, "Syncer help command '" +
s->second + " --help' failed");
diff --git a/src/clients/paludis/install.cc b/src/clients/paludis/install.cc
index b63afe2..6b56ffd 100644
--- a/src/clients/paludis/install.cc
+++ b/src/clients/paludis/install.cc
@@ -652,7 +652,7 @@ do_install(std::tr1::shared_ptr<Environment> env)
{
cerr << " ";
- LicenceDisplayer ld(cerr, env.get(), &*pp);
+ LicenceDisplayer ld(cerr, env.get(), *pp);
meta->license_interface->license()->accept(&ld);
}
}
@@ -664,14 +664,9 @@ do_install(std::tr1::shared_ptr<Environment> env)
pp->name, pp->version));
if (meta->ebuild_interface)
{
- std::set<KeywordName> keywords;
- WhitespaceTokeniser::get_instance()->tokenise(
- meta->ebuild_interface->keywords,
- create_inserter<KeywordName>(
- std::inserter(keywords, keywords.end())));
-
- cerr << " ( " << colour(cl_masked, join(keywords.begin(),
- keywords.end(), " ")) << " )";
+ std::tr1::shared_ptr<const KeywordNameCollection> keywords(meta->ebuild_interface->keywords());
+ cerr << " ( " << colour(cl_masked, join(keywords->begin(),
+ keywords->end(), " ")) << " )";
}
}
diff --git a/src/clients/paludis/install_TEST b/src/clients/paludis/install_TEST
index bd42b58..f9abfda 100755
--- a/src/clients/paludis/install_TEST
+++ b/src/clients/paludis/install_TEST
@@ -5,6 +5,7 @@ PALUDIS_HOME=./install_TEST_dir/config/ ./paludis --config-suffix install-test \
PALUDIS_HOME=./install_TEST_dir/config/ ./paludis --config-suffix install-test \
--install target || exit 2
./install_TEST_dir/root/usr/bin/testbin | grep success >/dev/null || exit 3
+grep target install_TEST_dir/root/var/db/pkg/world >/dev/null || exit 4
PALUDIS_HOME=./install_TEST_dir/config/ ./paludis --config-suffix install-test \
- --has-version test-category/target || exit 4
+ --has-version test-category/target || exit 5
diff --git a/src/clients/paludis/install_TEST_setup.sh b/src/clients/paludis/install_TEST_setup.sh
index 279d4e1..bcf616d 100755
--- a/src/clients/paludis/install_TEST_setup.sh
+++ b/src/clients/paludis/install_TEST_setup.sh
@@ -13,15 +13,15 @@ END
mkdir -p root/${SYSCONFDIR}/paludis/repositories
cat <<END > root/${SYSCONFDIR}/paludis/use.conf
-* foo
+*/* foo
END
cat <<END > root/${SYSCONFDIR}/paludis/licenses.conf
-* *
+*/* *
END
cat <<END > root/${SYSCONFDIR}/paludis/keywords.conf
-* test
+*/* test
END
cat <<END > root/${SYSCONFDIR}/paludis/bashrc
@@ -75,6 +75,7 @@ USERLAND=test
KERNEL=test
TESTPROFILE_WAS_SOURCED=yes
PROFILE_ORDERING=1
+USE_EXPAND="USERLAND KERNEL"
END
cat <<END > profiles/anothertestprofile/make.defaults
ARCH=test
@@ -106,6 +107,12 @@ pkg_setup() {
[[ -z "${TESTPROFILE_WAS_SOURCED}" ]] && die "testprofile not sourced"
[[ -z "${ANOTHERTESTPROFILE_WAS_SOURCED}" ]] && die "anothertestprofile not sourced"
[[ ${PROFILE_ORDERING:-0} != 2 ]] && die "bad profile source ordering"
+
+ [[ $USERLAND == test ]] || die "bad userland"
+ [[ $KERNEL == test ]] || die "bad kernel"
+ use userland_test || die "bad use for userland"
+ use kernel_test || die "bad use for kernel"
+ use test || die "bad use for arch"
}
src_unpack() {
diff --git a/src/clients/paludis/list.cc b/src/clients/paludis/list.cc
index cb41f61..b3d49a7 100644
--- a/src/clients/paludis/list.cc
+++ b/src/clients/paludis/list.cc
@@ -17,16 +17,20 @@
* Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <src/output/colour.hh>
#include "command_line.hh"
#include "list.hh"
+
+#include <paludis/environment.hh>
+#include <paludis/package_database.hh>
+#include <paludis/util/log.hh>
+#include <paludis/util/visitor.hh>
+#include <src/output/colour.hh>
+
+#include <tr1/memory>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
-#include <paludis/paludis.hh>
-#include <paludis/util/log.hh>
-#include <paludis/util/visitor.hh>
using namespace paludis;
@@ -221,16 +225,16 @@ do_list_sets(std::tr1::shared_ptr<Environment> env)
r->format()))
continue;
- std::tr1::shared_ptr<const SetsCollection> set_names(r->sets_interface->sets_list());
- for (SetsCollection::Iterator s(set_names->begin()), s_end(set_names->end()) ;
+ std::tr1::shared_ptr<const SetNameCollection> set_names(r->sets_interface->sets_list());
+ for (SetNameCollection::Iterator s(set_names->begin()), s_end(set_names->end()) ;
s != s_end ; ++s)
sets[*s].push_back(stringify(r->name()));
}
if (! CommandLine::get_instance()->a_repository.specified())
{
- std::tr1::shared_ptr<const SetsCollection> set_names(env->sets_list());
- for (SetsCollection::Iterator s(set_names->begin()), s_end(set_names->end()) ;
+ std::tr1::shared_ptr<const SetNameCollection> set_names(env->set_names());
+ for (SetNameCollection::Iterator s(set_names->begin()), s_end(set_names->end()) ;
s != s_end ; ++s)
sets[*s].push_back("environment");
}
diff --git a/src/clients/paludis/query.cc b/src/clients/paludis/query.cc
index ef6b9ca..0ecb7d1 100644
--- a/src/clients/paludis/query.cc
+++ b/src/clients/paludis/query.cc
@@ -100,7 +100,7 @@ void do_one_query(
{
try
{
- set = env->package_set(SetName(q));
+ set = env->set(SetName(q));
}
catch (const SetNameError &)
{
diff --git a/src/clients/paludis/uninstall.cc b/src/clients/paludis/uninstall.cc
index 75f8537..a0794ca 100644
--- a/src/clients/paludis/uninstall.cc
+++ b/src/clients/paludis/uninstall.cc
@@ -23,6 +23,7 @@
#include <paludis/tasks/uninstall_task.hh>
#include <paludis/tasks/exceptions.hh>
#include <paludis/dep_list/uninstall_list.hh>
+#include <paludis/package_database.hh>
#include <iostream>
#include <limits>
diff --git a/src/clients/paludis/upgrade_TEST_setup.sh b/src/clients/paludis/upgrade_TEST_setup.sh
index 1541d56..069820c 100755
--- a/src/clients/paludis/upgrade_TEST_setup.sh
+++ b/src/clients/paludis/upgrade_TEST_setup.sh
@@ -13,15 +13,15 @@ END
mkdir -p root/${SYSCONFDIR}/paludis/repositories
cat <<END > root/${SYSCONFDIR}/paludis/use.conf
-* foo
+*/* foo
END
cat <<END > root/${SYSCONFDIR}/paludis/licenses.conf
-* *
+*/* *
END
cat <<END > root/${SYSCONFDIR}/paludis/keywords.conf
-* test
+*/* test
END
cat <<END > root/${SYSCONFDIR}/paludis/bashrc
diff --git a/src/output/console_install_task.cc b/src/output/console_install_task.cc
index 3816c93..0171349 100644
--- a/src/output/console_install_task.cc
+++ b/src/output/console_install_task.cc
@@ -1101,7 +1101,7 @@ ConsoleInstallTask::display_merge_list_entry_mask_reasons(const DepListEntry & e
{
output_no_endl(" ");
- LicenceDisplayer ld(output_stream(), environment(), &e.package);
+ LicenceDisplayer ld(output_stream(), environment(), e.package);
metadata->license_interface->license()->accept(&ld);
}
}
@@ -1111,11 +1111,8 @@ ConsoleInstallTask::display_merge_list_entry_mask_reasons(const DepListEntry & e
e.package.repository)->version_metadata(e.package.name, e.package.version));
if (meta->ebuild_interface)
{
- std::set<KeywordName> keywords;
- WhitespaceTokeniser::get_instance()->tokenise(meta->ebuild_interface->keywords,
- create_inserter<KeywordName>(std::inserter(keywords, keywords.end())));
-
- output_no_endl(" ( " + render_as_masked(join(keywords.begin(), keywords.end(), " ")) + " )");
+ std::tr1::shared_ptr<const KeywordNameCollection> keywords(meta->ebuild_interface->keywords());
+ output_no_endl(" ( " + render_as_masked(join(keywords->begin(), keywords->end(), " ")) + " )");
}
}
diff --git a/src/output/console_query_task.cc b/src/output/console_query_task.cc
index 859eaef..623a732 100644
--- a/src/output/console_query_task.cc
+++ b/src/output/console_query_task.cc
@@ -230,7 +230,7 @@ ConsoleQueryTask::display_metadata(const PackageDepSpec &, const PackageDatabase
display_metadata_iuse("Use flags", "IUSE", metadata->ebuild_interface->iuse, e);
if (want_raw())
{
- display_metadata_key("Keywords", "KEYWORDS", metadata->ebuild_interface->keywords);
+ display_metadata_key("Keywords", "KEYWORDS", metadata->ebuild_interface->keywords_string);
display_metadata_key("SRC_URI", "SRC_URI", metadata->ebuild_interface->src_uri_string);
display_metadata_key("Restrict", "RESTRICT", metadata->ebuild_interface->restrict_string);
}
@@ -274,7 +274,7 @@ ConsoleQueryTask::display_metadata_license(const std::string & k, const std::str
}
else
{
- LicenceDisplayer d(output_stream(), _imp->env, &display_entry);
+ LicenceDisplayer d(output_stream(), _imp->env, display_entry);
l->accept(&d);
output_right_column("");
}
diff --git a/src/output/licence.cc b/src/output/licence.cc
index bd28aed..08f4d4a 100644
--- a/src/output/licence.cc
+++ b/src/output/licence.cc
@@ -58,9 +58,10 @@ LicenceDisplayer::visit(const paludis::PlainTextDepSpec * spec)
LicenceDisplayer::LicenceDisplayer(
std::ostream & s,
const paludis::Environment * const e,
- const paludis::PackageDatabaseEntry * const d) :
+ const paludis::PackageDatabaseEntry & d) :
stream(s),
env(e),
db_entry(d)
{
}
+
diff --git a/src/output/licence.hh b/src/output/licence.hh
index d93e87c..38ee285 100644
--- a/src/output/licence.hh
+++ b/src/output/licence.hh
@@ -36,13 +36,13 @@ struct LicenceDisplayer :
const paludis::Environment * const env;
/// Our db entry.
- const paludis::PackageDatabaseEntry * const db_entry;
+ const paludis::PackageDatabaseEntry db_entry;
/// Constructor.
LicenceDisplayer(
std::ostream & stream,
const paludis::Environment * const e,
- const paludis::PackageDatabaseEntry * const d);
+ const paludis::PackageDatabaseEntry & d);
///\name Visit methods
///{
diff --git a/src/output/use_flag_pretty_printer.cc b/src/output/use_flag_pretty_printer.cc
index bef83af..7014ffc 100644
--- a/src/output/use_flag_pretty_printer.cc
+++ b/src/output/use_flag_pretty_printer.cc
@@ -20,6 +20,7 @@
#include "use_flag_pretty_printer.hh"
#include <paludis/version_metadata.hh>
#include <paludis/environment.hh>
+#include <paludis/package_database.hh>
#include <paludis/util/tokeniser.hh>
#include <paludis/util/collection_concrete.hh>
#include "colour.hh"
@@ -87,7 +88,7 @@ UseFlagPrettyPrinter::print_package_flags(const PackageDatabaseEntry & pkg,
if (std::string::npos != use_expand_delim_pos(*flag, use_interface->use_expand_prefixes()))
continue;
- if (environment()->query_use(*flag, &pkg))
+ if (environment()->query_use(*flag, pkg))
{
if (use_interface && use_interface->query_use_force(*flag, &pkg))
output_flag(render_as_forced_flag(stringify(*flag)));
@@ -106,7 +107,7 @@ UseFlagPrettyPrinter::print_package_flags(const PackageDatabaseEntry & pkg,
{
if (old_iuse.end() != old_iuse.find(*flag))
{
- if (environment()->query_use(*flag, &pkg) != environment()->query_use(*flag, old_pkg))
+ if (environment()->query_use(*flag, pkg) != environment()->query_use(*flag, *old_pkg))
{
_changed_flags->insert(*flag);
output_flag_changed_mark();
@@ -150,7 +151,7 @@ UseFlagPrettyPrinter::print_package_flags(const PackageDatabaseEntry & pkg,
old_expand_name = expand_name;
}
- if (environment()->query_use(*flag, &pkg))
+ if (environment()->query_use(*flag, pkg))
{
if (use_interface && use_interface->query_use_force(*flag, &pkg))
output_flag(render_as_forced_flag(stringify(expand_value)));
@@ -169,7 +170,7 @@ UseFlagPrettyPrinter::print_package_flags(const PackageDatabaseEntry & pkg,
{
if (old_iuse.end() != old_iuse.find(*flag))
{
- if (environment()->query_use(*flag, &pkg) != environment()->query_use(*flag, old_pkg))
+ if (environment()->query_use(*flag, pkg) != environment()->query_use(*flag, *old_pkg))
{
_changed_flags->insert(*flag);
output_flag_changed_mark();
diff --git a/test/run_test.sh b/test/run_test.sh
index 9b7050b..52e1761 100755
--- a/test/run_test.sh
+++ b/test/run_test.sh
@@ -27,8 +27,14 @@ else
fi
echo ">>> test ${testname}"
-${@}
-code=$?
+if [[ -n "${TEST_OUTPUT_WRAPPER}" ]] ; then
+ $TEST_OUTPUT_WRAPPER --stdout-prefix "${testname#./}> " --stderr-prefix "${testname#./}> " -- ${@}
+ code=$?
+else
+ ${@}
+ code=$?
+fi
+
if [[ 0 != ${code} ]] ; then
echo ">>> test ${testname} returned ${code}"
if test -f "$TEST_SCRIPT_DIR""${testname}"_"cleanup.sh" ; then
diff --git a/tr1/tr1_functional.hh b/tr1/tr1_functional.hh
index 7e71a13..7481054 100644
--- a/tr1/tr1_functional.hh
+++ b/tr1/tr1_functional.hh
@@ -26,6 +26,7 @@
#include <boost/bind.hpp>
#include <boost/mem_fn.hpp>
+#include <boost/ref.hpp>
namespace std
{
@@ -33,6 +34,8 @@ namespace std
{
using boost::bind;
using boost::mem_fn;
+ using boost::ref;
+ using boost::cref;
namespace placeholders
{