diff options
author | 2009-12-12 00:49:26 +0000 | |
---|---|---|
committer | 2009-12-22 02:02:55 +0000 | |
commit | bd8aac78fc82be4b87b457a8546f4c37dc4bde60 (patch) | |
tree | 3e5e739750ea345afd066836662f007c17a6eab0 /paludis | |
parent | 94167fdd5fa7200cad1464a9ef5aa64dab2b7928 (diff) | |
download | paludis-bd8aac78fc82be4b87b457a8546f4c37dc4bde60.tar.gz paludis-bd8aac78fc82be4b87b457a8546f4c37dc4bde60.tar.xz |
Exheres profile
Diffstat (limited to 'paludis')
-rw-r--r-- | paludis/distributions/exherbo/e.conf | 1 | ||||
-rw-r--r-- | paludis/distributions/gentoo/e.conf | 1 | ||||
-rw-r--r-- | paludis/repositories/e/Makefile.am | 2 | ||||
-rw-r--r-- | paludis/repositories/e/e_repository.cc | 22 | ||||
-rw-r--r-- | paludis/repositories/e/e_repository_params.hh | 2 | ||||
-rw-r--r-- | paludis/repositories/e/exheres_profile.cc | 338 | ||||
-rw-r--r-- | paludis/repositories/e/exheres_profile.hh | 100 | ||||
-rw-r--r-- | paludis/repositories/e/extra_distribution_data.cc | 3 | ||||
-rw-r--r-- | paludis/repositories/e/extra_distribution_data.hh | 4 | ||||
-rw-r--r-- | paludis/repositories/e/profile.cc | 39 | ||||
-rw-r--r-- | paludis/repositories/e/profile.hh | 22 |
11 files changed, 527 insertions, 7 deletions
diff --git a/paludis/distributions/exherbo/e.conf b/paludis/distributions/exherbo/e.conf index 35a8ff093..377313797 100644 --- a/paludis/distributions/exherbo/e.conf +++ b/paludis/distributions/exherbo/e.conf @@ -5,6 +5,7 @@ default_eapi_when_unspecified = exheres-0 default_layout = exheres default_names_cache = /var/cache/paludis/names default_profile_eapi = exheres-0 +default_profile_layout = traditional default_provides_cache = /var/empty default_write_cache = /var/cache/paludis/metadata news_directory = /var/lib/exherbo/news diff --git a/paludis/distributions/gentoo/e.conf b/paludis/distributions/gentoo/e.conf index f668ee404..62c0c5535 100644 --- a/paludis/distributions/gentoo/e.conf +++ b/paludis/distributions/gentoo/e.conf @@ -3,6 +3,7 @@ default_distdir = distfiles default_eapi_when_unknown = 0 default_eapi_when_unspecified = 0 default_layout = traditional +default_profile_layout = traditional default_names_cache = default_profile_eapi = 0 default_provides_cache = diff --git a/paludis/repositories/e/Makefile.am b/paludis/repositories/e/Makefile.am index 82eae42c9..83e4c20b0 100644 --- a/paludis/repositories/e/Makefile.am +++ b/paludis/repositories/e/Makefile.am @@ -52,6 +52,7 @@ noinst_HEADERS = \ eclass_mtimes.hh \ exheres_layout.hh \ exndbam_id.hh \ + exheres_profile.hh \ exndbam_repository.hh \ extra_distribution_data.hh \ fetch_visitor.hh \ @@ -111,6 +112,7 @@ libpaludiserepository_la_SOURCES = \ exndbam_id.cc \ exndbam_repository.cc \ exheres_layout.cc \ + exheres_profile.cc \ extra_distribution_data.cc \ fetch_visitor.cc \ info_metadata_key.cc \ diff --git a/paludis/repositories/e/e_repository.cc b/paludis/repositories/e/e_repository.cc index 669d6164f..c92bf03c1 100644 --- a/paludis/repositories/e/e_repository.cc +++ b/paludis/repositories/e/e_repository.cc @@ -425,11 +425,12 @@ namespace paludis else main_profile_path.reset(new FSEntry(*params.profiles()->begin())); - profile_ptr.reset(new TraditionalProfile( - params.environment(), repo, repo->name(), *profiles, - EAPIData::get_instance()->eapi_from_string( - params.eapi_when_unknown())->supported()->ebuild_environment_variables()->env_arch(), - params.profiles_explicitly_set())); + profile_ptr = ProfileFactory::get_instance()->create( + params.profile_layout(), + params.environment(), repo, repo->name(), *profiles, + EAPIData::get_instance()->eapi_from_string( + params.eapi_when_unknown())->supported()->ebuild_environment_variables()->env_arch(), + params.profiles_explicitly_set()); } } @@ -1426,6 +1427,16 @@ ERepository::repository_factory_create( env->distribution()))->default_layout(); } + std::string profile_layout(f("profile_layout")); + if (profile_layout.empty()) + { + if (! layout_conf + || (profile_layout = layout_conf->get("profile_layout")).empty()) + profile_layout = EExtraDistributionData::get_instance()->data_from_distribution( + *DistributionData::get_instance()->distribution_from_string( + env->distribution()))->default_profile_layout(); + } + UseManifest use_manifest(manifest_use); if (! f("use_manifest").empty()) { @@ -1474,6 +1485,7 @@ ERepository::repository_factory_create( value_for<n::names_cache>(FSEntry(names_cache).realpath_if_exists()), value_for<n::newsdir>(FSEntry(newsdir).realpath_if_exists()), value_for<n::profile_eapi_when_unspecified>(profile_eapi), + value_for<n::profile_layout>(profile_layout), value_for<n::profiles>(profiles), value_for<n::profiles_explicitly_set>(profiles_explicitly_set), value_for<n::securitydir>(FSEntry(securitydir).realpath_if_exists()), diff --git a/paludis/repositories/e/e_repository_params.hh b/paludis/repositories/e/e_repository_params.hh index 3dfd81f8b..13382f1a5 100644 --- a/paludis/repositories/e/e_repository_params.hh +++ b/paludis/repositories/e/e_repository_params.hh @@ -60,6 +60,7 @@ namespace paludis struct names_cache; struct newsdir; struct profile_eapi_when_unspecified; + struct profile_layout; struct profiles; struct profiles_explicitly_set; struct securitydir; @@ -98,6 +99,7 @@ namespace paludis NamedValue<n::names_cache, FSEntry> names_cache; NamedValue<n::newsdir, FSEntry> newsdir; NamedValue<n::profile_eapi_when_unspecified, std::string> profile_eapi_when_unspecified; + NamedValue<n::profile_layout, std::string> profile_layout; NamedValue<n::profiles, std::tr1::shared_ptr<const FSEntrySequence> > profiles; NamedValue<n::profiles_explicitly_set, bool> profiles_explicitly_set; NamedValue<n::securitydir, FSEntry> securitydir; diff --git a/paludis/repositories/e/exheres_profile.cc b/paludis/repositories/e/exheres_profile.cc new file mode 100644 index 000000000..ed70ed405 --- /dev/null +++ b/paludis/repositories/e/exheres_profile.cc @@ -0,0 +1,338 @@ +/* vim: set sw=4 sts=4 et foldmethod=syntax : */ + +/* + * Copyright (c) 2005, 2006, 2007, 2008, 2009 Ciaran McCreesh + * + * This file is part of the Paludis package manager. Paludis is free software; + * you can redistribute it and/or modify it under the terms of the GNU General + * Public License version 2, as published by the Free Software Foundation. + * + * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., 59 Temple + * Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include <paludis/repositories/e/exheres_profile.hh> +#include <paludis/repositories/e/e_repository_mask_file.hh> +#include <paludis/repositories/e/e_repository_exceptions.hh> +#include <paludis/repositories/e/e_repository.hh> +#include <paludis/repositories/e/profile_file.hh> +#include <paludis/repositories/e/eapi.hh> + +#include <paludis/util/log.hh> +#include <paludis/util/tokeniser.hh> +#include <paludis/util/private_implementation_pattern-impl.hh> +#include <paludis/util/wrapped_forward_iterator.hh> +#include <paludis/util/wrapped_output_iterator.hh> +#include <paludis/util/config_file.hh> +#include <paludis/util/make_shared_ptr.hh> +#include <paludis/util/map.hh> +#include <paludis/util/mutex.hh> +#include <paludis/util/set.hh> +#include <paludis/util/make_named_values.hh> +#include <paludis/util/hashes.hh> +#include <paludis/util/system.hh> +#include <paludis/choice.hh> +#include <paludis/dep_tag.hh> +#include <paludis/environment.hh> +#include <paludis/match_package.hh> +#include <paludis/distribution.hh> +#include <paludis/package_id.hh> +#include <paludis/metadata_key.hh> +#include <paludis/paludislike_options_conf.hh> +#include <tr1/unordered_map> +#include <list> + +using namespace paludis; +using namespace paludis::erepository; + +namespace +{ + const std::tr1::shared_ptr<const LineConfigFile> make_config_file( + const FSEntry & f, + const LineConfigFileOptions & o) + { + return make_shared_ptr(new LineConfigFile(f, o)); + } + + typedef std::tr1::unordered_map<std::string, std::string, Hash<std::string> > EnvironmentVariablesMap; + typedef std::tr1::unordered_map<QualifiedPackageName, + std::list<std::pair<std::tr1::shared_ptr<const PackageDepSpec>, std::tr1::shared_ptr<const RepositoryMaskInfo> > >, + Hash<QualifiedPackageName> > PackageMaskMap; +} + +namespace paludis +{ + template<> + struct Implementation<ExheresProfile> + { + const Environment * const env; + const ERepository * const repository; + + PaludisLikeOptionsConf options_conf; + EnvironmentVariablesMap environment_variables; + PackageMaskMap package_mask; + + ProfileFile<MaskFile> package_mask_file; + ProfileFile<LineConfigFile> packages_file; + + const std::tr1::shared_ptr<Set<std::string> > use_expand; + const std::tr1::shared_ptr<Set<std::string> > use_expand_hidden; + const std::tr1::shared_ptr<Set<std::string> > use_expand_unprefixed; + const std::tr1::shared_ptr<Set<std::string> > use_expand_implicit; + const std::tr1::shared_ptr<Set<std::string> > iuse_implicit; + const std::tr1::shared_ptr<Set<std::string> > use_expand_values; + + const std::tr1::shared_ptr<SetSpecTree> system_packages; + const std::tr1::shared_ptr<GeneralSetDepTag> system_tag; + + Implementation(const Environment * const e, const ERepository * const p, + const RepositoryName & name, const FSEntrySequence &, + const std::string &, const bool) : + env(e), + repository(p), + options_conf(make_named_values<PaludisLikeOptionsConfParams>( + value_for<n::allow_locking>(true), + value_for<n::environment>(e), + value_for<n::make_config_file>(&make_config_file) + )), + package_mask_file(p), + packages_file(p), + use_expand(new Set<std::string>), + use_expand_hidden(new Set<std::string>), + use_expand_unprefixed(new Set<std::string>), + use_expand_implicit(new Set<std::string>), + iuse_implicit(new Set<std::string>), + use_expand_values(new Set<std::string>), + system_packages(new SetSpecTree(make_shared_ptr(new AllDepSpec))), + system_tag(new GeneralSetDepTag(SetName("system"), stringify(name))) + { + environment_variables["CONFIG_PROTECT"] = getenv_with_default("CONFIG_PROTECT", "/etc"); + environment_variables["CONFIG_PROTECT_MASK"] = getenv_with_default("CONFIG_PROTECT_MASK", ""); + } + }; +} + +ExheresProfile::ExheresProfile( + const Environment * const env, const ERepository * const p, const RepositoryName & name, + const FSEntrySequence & location, + const std::string & arch_var_if_special, const bool x) : + PrivateImplementationPattern<ExheresProfile>( + new Implementation<ExheresProfile>(env, p, name, location, arch_var_if_special, x)) +{ + for (FSEntrySequence::ConstIterator l(location.begin()), l_end(location.end()) ; + l != l_end ; ++l) + _load_dir(*l); + + const std::tr1::shared_ptr<const Set<UnprefixedChoiceName> > s(_imp->options_conf.known_choice_value_names( + make_null_shared_ptr(), ChoicePrefixName("suboptions"))); + std::transform(s->begin(), s->end(), _imp->use_expand->inserter(), + paludis::stringify<UnprefixedChoiceName>); + + const std::tr1::shared_ptr<const Set<UnprefixedChoiceName> > sh(_imp->options_conf.known_choice_value_names( + make_null_shared_ptr(), ChoicePrefixName("hidden_suboptions"))); + std::transform(sh->begin(), sh->end(), _imp->use_expand_hidden->inserter(), + paludis::stringify<UnprefixedChoiceName>); + + if (! _imp->repository->params().master_repositories()) + for (ProfileFile<LineConfigFile>::ConstIterator i(_imp->packages_file.begin()), + i_end(_imp->packages_file.end()) ; i != i_end ; ++i) + { + if (0 != i->second.compare(0, 1, "*", 0, 1)) + continue; + + Context context_spec("When parsing '" + i->second + "':"); + std::tr1::shared_ptr<PackageDepSpec> spec(new PackageDepSpec( + parse_elike_package_dep_spec(i->second.substr(1), + i->first->supported()->package_dep_spec_parse_options(), + i->first->supported()->version_spec_options(), + std::tr1::shared_ptr<const PackageID>()))); + + spec->set_tag(_imp->system_tag); + _imp->system_packages->root()->append(spec); + } +} + +ExheresProfile::~ExheresProfile() +{ +} + +void +ExheresProfile::_load_dir(const FSEntry & f) +{ + if (! f.is_directory_or_symlink_to_directory()) + { + Log::get_instance()->message("e.exheres_profile.not_a_directory", ll_warning, lc_context) << + "Profile component '" << f << "' is not a directory"; + return; + } + + if ((f / "options.conf").exists()) + _imp->options_conf.add_file(f / "options.conf"); + + if ((f / "package_mask.conf").exists()) + _imp->package_mask_file.add_file(f / "package_mask.conf"); + + if ((f / "packages").exists()) + _imp->packages_file.add_file(f / "packages"); + + if ((f / "make.defaults").exists()) + { + const std::tr1::shared_ptr<const EAPI> eapi(EAPIData::get_instance()->eapi_from_string( + _imp->repository->eapi_for_file(f / "make.defaults"))); + if (! eapi->supported()) + throw ERepositoryConfigurationError("Can't use profile directory '" + stringify(f) + + "' because it uses an unsupported EAPI"); + + KeyValueConfigFile file(f / "make.defaults", KeyValueConfigFileOptions() + + kvcfo_disallow_source + kvcfo_disallow_space_inside_unquoted_values + + kvcfo_allow_inline_comments + kvcfo_allow_multiple_assigns_per_line, + &KeyValueConfigFile::no_defaults, &KeyValueConfigFile::no_transformation); + + for (KeyValueConfigFile::ConstIterator k(file.begin()), k_end(file.end()) ; + k != k_end ; ++k) + _imp->environment_variables[k->first] = k->second; + } + + if ((f / "parents.conf").exists()) + { + LineConfigFile file(f / "parents.conf", LineConfigFileOptions()); + for (LineConfigFile::ConstIterator line(file.begin()), line_end(file.end()) ; + line != line_end ; ++line) + _load_dir((f / *line).realpath()); + } +} + +bool +ExheresProfile::use_masked( + const std::tr1::shared_ptr<const PackageID> & id, + const std::tr1::shared_ptr<const Choice> & choice, + const UnprefixedChoiceName & value_unprefixed, + const ChoiceNameWithPrefix & + ) const +{ + std::pair<Tribool, bool> enabled_locked(_imp->options_conf.want_choice_enabled_locked( + id, choice->prefix(), value_unprefixed)); + return enabled_locked.first.is_true() && enabled_locked.second; +} + +bool +ExheresProfile::use_forced( + const std::tr1::shared_ptr<const PackageID> & id, + const std::tr1::shared_ptr<const Choice> & choice, + const UnprefixedChoiceName & value_unprefixed, + const ChoiceNameWithPrefix & + ) const +{ + std::pair<Tribool, bool> enabled_locked(_imp->options_conf.want_choice_enabled_locked( + id, choice->prefix(), value_unprefixed)); + return enabled_locked.first.is_false() && enabled_locked.second; +} + +Tribool +ExheresProfile::use_state_ignoring_masks( + const std::tr1::shared_ptr<const PackageID> & id, + const std::tr1::shared_ptr<const Choice> & choice, + const UnprefixedChoiceName & value_unprefixed, + const ChoiceNameWithPrefix & + ) const +{ + std::pair<Tribool, bool> enabled_locked(_imp->options_conf.want_choice_enabled_locked( + id, choice->prefix(), value_unprefixed)); + return enabled_locked.first; +} + +const std::tr1::shared_ptr<const Set<UnprefixedChoiceName> > +ExheresProfile::known_choice_value_names( + const std::tr1::shared_ptr<const erepository::ERepositoryID> & id, + const std::tr1::shared_ptr<const Choice> & choice + ) const +{ + return _imp->options_conf.known_choice_value_names(id, choice->prefix()); +} + +const std::tr1::shared_ptr<const Set<std::string> > +ExheresProfile::use_expand() const +{ + return _imp->use_expand; +} + +const std::tr1::shared_ptr<const Set<std::string> > +ExheresProfile::use_expand_hidden() const +{ + return _imp->use_expand_hidden; +} + +const std::tr1::shared_ptr<const Set<std::string> > +ExheresProfile::use_expand_unprefixed() const +{ + return _imp->use_expand_unprefixed; +} + +const std::tr1::shared_ptr<const Set<std::string> > +ExheresProfile::use_expand_implicit() const +{ + return _imp->use_expand_implicit; +} + +const std::tr1::shared_ptr<const Set<std::string> > +ExheresProfile::iuse_implicit() const +{ + return _imp->iuse_implicit; +} + +const std::tr1::shared_ptr<const Set<std::string> > +ExheresProfile::use_expand_values(const std::string &) const +{ + return _imp->use_expand_values; +} + +const std::string +ExheresProfile::environment_variable(const std::string & s) const +{ + EnvironmentVariablesMap::const_iterator i(_imp->environment_variables.find(s)); + if (_imp->environment_variables.end() == i) + { + Log::get_instance()->message("e.exheres_profile.unknown", ll_warning, lc_context) << + "Something is asking for environment variable '" << s << "' from profiles, but that isn't in " + "our list of special vars. This is probably a bug."; + return ""; + } + else + return i->second; +} + +const std::tr1::shared_ptr<const RepositoryMaskInfo> +ExheresProfile::profile_masked(const PackageID & id) const +{ + PackageMaskMap::const_iterator rr(_imp->package_mask.find(id.name())); + if (_imp->package_mask.end() == rr) + return std::tr1::shared_ptr<const RepositoryMaskInfo>(); + else + { + for (std::list<std::pair<std::tr1::shared_ptr<const PackageDepSpec>, std::tr1::shared_ptr<const RepositoryMaskInfo> > >::const_iterator k(rr->second.begin()), + k_end(rr->second.end()) ; k != k_end ; ++k) + if (match_package(*_imp->env, *k->first, id, MatchPackageOptions())) + return k->second; + } + + return std::tr1::shared_ptr<const RepositoryMaskInfo>(); +} + +const std::tr1::shared_ptr<const SetSpecTree> +ExheresProfile::system_packages() const +{ + return _imp->system_packages; +} + +const std::tr1::shared_ptr<const Map<QualifiedPackageName, PackageDepSpec> > +ExheresProfile::virtuals() const +{ + return make_shared_ptr(new Map<QualifiedPackageName, PackageDepSpec>); +} + diff --git a/paludis/repositories/e/exheres_profile.hh b/paludis/repositories/e/exheres_profile.hh new file mode 100644 index 000000000..4ff761e18 --- /dev/null +++ b/paludis/repositories/e/exheres_profile.hh @@ -0,0 +1,100 @@ +/* vim: set sw=4 sts=4 et foldmethod=syntax : */ + +/* + * Copyright (c) 2005, 2006, 2007, 2008, 2009 Ciaran McCreesh + * + * This file is part of the Paludis package manager. Paludis is free software; + * you can redistribute it and/or modify it under the terms of the GNU General + * Public License version 2, as published by the Free Software Foundation. + * + * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., 59 Temple + * Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef PALUDIS_GUARD_PALUDIS_REPOSITORIES_E_E_REPOSITORY_EXHERES_PROFILE_HH +#define PALUDIS_GUARD_PALUDIS_REPOSITORIES_E_E_REPOSITORY_EXHERES_PROFILE_HH 1 + +#include <paludis/repositories/e/profile.hh> +#include <paludis/repositories/e/e_repository.hh> +#include <string> + +namespace paludis +{ + namespace erepository + { + class PALUDIS_VISIBLE ExheresProfile : + private PrivateImplementationPattern<ExheresProfile>, + public Profile + { + private: + void _load_dir(const FSEntry &); + + public: + ExheresProfile( + const Environment * const, const ERepository * const, const RepositoryName &, + const FSEntrySequence &, + const std::string & arch_var_if_special, + const bool x + ); + + virtual ~ExheresProfile(); + + virtual bool use_masked( + const std::tr1::shared_ptr<const PackageID> &, + const std::tr1::shared_ptr<const Choice> &, + const UnprefixedChoiceName & value_unprefixed, + const ChoiceNameWithPrefix & value_prefixed + ) const PALUDIS_ATTRIBUTE((warn_unused_result)); + + virtual bool use_forced( + const std::tr1::shared_ptr<const PackageID> &, + const std::tr1::shared_ptr<const Choice> &, + const UnprefixedChoiceName & value_unprefixed, + const ChoiceNameWithPrefix & value_prefixed + ) const PALUDIS_ATTRIBUTE((warn_unused_result)); + + virtual Tribool use_state_ignoring_masks( + const std::tr1::shared_ptr<const PackageID> &, + const std::tr1::shared_ptr<const Choice> &, + const UnprefixedChoiceName & value_unprefixed, + const ChoiceNameWithPrefix & value_prefixed + ) const PALUDIS_ATTRIBUTE((warn_unused_result)); + + virtual const std::tr1::shared_ptr<const Set<UnprefixedChoiceName> > known_choice_value_names( + const std::tr1::shared_ptr<const erepository::ERepositoryID> &, + const std::tr1::shared_ptr<const Choice> & + ) const PALUDIS_ATTRIBUTE((warn_unused_result)); + + virtual const std::tr1::shared_ptr<const Set<std::string> > use_expand() const + PALUDIS_ATTRIBUTE((warn_unused_result)); + virtual const std::tr1::shared_ptr<const Set<std::string> > use_expand_hidden() const + PALUDIS_ATTRIBUTE((warn_unused_result)); + + virtual const std::tr1::shared_ptr<const Set<std::string> > use_expand_unprefixed() const + PALUDIS_ATTRIBUTE((warn_unused_result)); + virtual const std::tr1::shared_ptr<const Set<std::string> > use_expand_implicit() const + PALUDIS_ATTRIBUTE((warn_unused_result)); + virtual const std::tr1::shared_ptr<const Set<std::string> > iuse_implicit() const + PALUDIS_ATTRIBUTE((warn_unused_result)); + virtual const std::tr1::shared_ptr<const Set<std::string> > use_expand_values(const std::string &) const + PALUDIS_ATTRIBUTE((warn_unused_result)); + + virtual const std::string environment_variable(const std::string &) const; + + virtual const std::tr1::shared_ptr<const RepositoryMaskInfo> profile_masked(const PackageID &) const; + + virtual const std::tr1::shared_ptr<const SetSpecTree> system_packages() const; + + virtual const std::tr1::shared_ptr<const Map<QualifiedPackageName, PackageDepSpec> > + virtuals() const PALUDIS_ATTRIBUTE((warn_unused_result)); + }; + } +} + +#endif diff --git a/paludis/repositories/e/extra_distribution_data.cc b/paludis/repositories/e/extra_distribution_data.cc index 14852fe6d..dcc0c78fb 100644 --- a/paludis/repositories/e/extra_distribution_data.cc +++ b/paludis/repositories/e/extra_distribution_data.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2008 Ciaran McCreesh + * Copyright (c) 2008, 2009 Ciaran McCreesh * * This file is part of the Paludis package manager. Paludis is free software; * you can redistribute it and/or modify it under the terms of the GNU General @@ -58,6 +58,7 @@ namespace paludis value_for<n::default_layout>(k->get("default_layout")), value_for<n::default_names_cache>(k->get("default_names_cache")), value_for<n::default_profile_eapi>(k->get("default_profile_eapi")), + value_for<n::default_profile_layout>(k->get("default_profile_layout")), value_for<n::default_provides_cache>(k->get("default_provides_cache")), value_for<n::default_write_cache>(k->get("default_write_cache")), value_for<n::news_directory>(FSEntry(k->get("news_directory"))), diff --git a/paludis/repositories/e/extra_distribution_data.hh b/paludis/repositories/e/extra_distribution_data.hh index 6fd44b395..52deee2a0 100644 --- a/paludis/repositories/e/extra_distribution_data.hh +++ b/paludis/repositories/e/extra_distribution_data.hh @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2008 Ciaran McCreesh + * Copyright (c) 2008, 2009 Ciaran McCreesh * * This file is part of the Paludis package manager. Paludis is free software; * you can redistribute it and/or modify it under the terms of the GNU General @@ -38,6 +38,7 @@ namespace paludis struct default_layout; struct default_names_cache; struct default_profile_eapi; + struct default_profile_layout; struct default_provides_cache; struct default_write_cache; struct news_directory; @@ -60,6 +61,7 @@ namespace paludis NamedValue<n::default_layout, std::string> default_layout; NamedValue<n::default_names_cache, std::string> default_names_cache; NamedValue<n::default_profile_eapi, std::string> default_profile_eapi; + NamedValue<n::default_profile_layout, std::string> default_profile_layout; NamedValue<n::default_provides_cache, std::string> default_provides_cache; NamedValue<n::default_write_cache, std::string> default_write_cache; NamedValue<n::news_directory, FSEntry> news_directory; diff --git a/paludis/repositories/e/profile.cc b/paludis/repositories/e/profile.cc index f1c983c6b..76a7d0b56 100644 --- a/paludis/repositories/e/profile.cc +++ b/paludis/repositories/e/profile.cc @@ -18,6 +18,8 @@ */ #include <paludis/repositories/e/profile.hh> +#include <paludis/repositories/e/traditional_profile.hh> +#include <paludis/repositories/e/exheres_profile.hh> #include <paludis/name.hh> #include <paludis/dep_spec.hh> @@ -31,6 +33,43 @@ Profile::~Profile() { } +namespace +{ + template <typename T_> + std::tr1::shared_ptr<Profile> + make_profile( + const Environment * const env, + const ERepository * const repo, + const RepositoryName & name, + const FSEntrySequence & locations, + const std::string & a, + const bool x) + { + return std::tr1::shared_ptr<Profile>(new T_(env, repo, name, locations, a, x)); + } +} + +ProfileFactory::ProfileFactory() +{ +} + +const std::tr1::shared_ptr<Profile> +ProfileFactory::create( + const std::string & s, + const Environment * const env, + const ERepository * const repo, + const RepositoryName & name, + const FSEntrySequence & locations, + const std::string & a, + const bool x) const +{ + if (s == "traditional") + return make_profile<TraditionalProfile>(env, repo, name, locations, a, x); + if (s == "exheres") + return make_profile<ExheresProfile>(env, repo, name, locations, a, x); + throw ConfigurationError("Unrecognised profile '" + s + "'"); +} + template class Map<QualifiedPackageName, PackageDepSpec>; template class WrappedForwardIterator<Map<QualifiedPackageName, PackageDepSpec>::ConstIteratorTag, const std::pair<const QualifiedPackageName, PackageDepSpec> >; diff --git a/paludis/repositories/e/profile.hh b/paludis/repositories/e/profile.hh index 024f2f99d..150de4249 100644 --- a/paludis/repositories/e/profile.hh +++ b/paludis/repositories/e/profile.hh @@ -37,6 +37,8 @@ namespace paludis { + class ERepository; + namespace erepository { class PALUDIS_VISIBLE Profile @@ -93,6 +95,26 @@ namespace paludis virtual const std::tr1::shared_ptr<const Map<QualifiedPackageName, PackageDepSpec> > virtuals() const PALUDIS_ATTRIBUTE((warn_unused_result)) = 0; }; + + class PALUDIS_VISIBLE ProfileFactory : + public InstantiationPolicy<ProfileFactory, instantiation_method::SingletonTag> + { + friend class InstantiationPolicy<ProfileFactory, instantiation_method::SingletonTag>; + + private: + ProfileFactory(); + + public: + const std::tr1::shared_ptr<Profile> create( + const std::string &, + const Environment * const, + const ERepository * const, + const RepositoryName &, + const FSEntrySequence &, + const std::string & arch_var_if_special, + const bool profiles_explicitly_set) + const PALUDIS_ATTRIBUTE((warn_unused_result)); + }; } } |