aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-03-18 21:44:01 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-03-18 21:44:01 +0000
commit8b8c70f3f119f796fe42a0c5e00f2f98b1cf6cb1 (patch)
treeb3ee0c36cae480b1e395ec043087f53af64060d9
parent2aabc5117e700f24daaded891ec977ba1ca481e9 (diff)
downloadpaludis-8b8c70f3f119f796fe42a0c5e00f2f98b1cf6cb1.tar.gz
paludis-8b8c70f3f119f796fe42a0c5e00f2f98b1cf6cb1.tar.xz
Decouple
-rw-r--r--paludis/repositories/e/e_repository.cc23
-rw-r--r--paludis/repositories/e/exheres_profile.cc34
-rw-r--r--paludis/repositories/e/exheres_profile.hh12
-rw-r--r--paludis/repositories/e/profile.cc43
-rw-r--r--paludis/repositories/e/profile.hh18
-rw-r--r--paludis/repositories/e/traditional_profile.cc62
-rw-r--r--paludis/repositories/e/traditional_profile.hh11
7 files changed, 111 insertions, 92 deletions
diff --git a/paludis/repositories/e/e_repository.cc b/paludis/repositories/e/e_repository.cc
index 1336f8d..9538620 100644
--- a/paludis/repositories/e/e_repository.cc
+++ b/paludis/repositories/e/e_repository.cc
@@ -197,15 +197,15 @@ namespace
{
return layout->repository_mask_files();
}
+
+ bool is_arch_flag_func(const ERepository * const r, const UnprefixedChoiceName & p)
+ {
+ return r->arch_flags()->end() != r->arch_flags()->find(p);
+ }
}
namespace paludis
{
- /**
- * Imp data for a ERepository.
- *
- * \ingroup grperepository
- */
template <>
struct Imp<ERepository>
{
@@ -477,10 +477,15 @@ namespace paludis
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());
+ params.environment(),
+ repo->name(),
+ EAPIForFileFunction(std::bind(&ERepository::eapi_for_file, repo, std::placeholders::_1)),
+ IsArchFlagFunction(std::bind(&is_arch_flag_func, repo, std::placeholders::_1)),
+ *profiles,
+ EAPIData::get_instance()->eapi_from_string(params.eapi_when_unknown())->supported()->ebuild_environment_variables()->env_arch(),
+ params.profiles_explicitly_set(),
+ bool(params.master_repositories()),
+ params.ignore_deprecated_profiles());
}
}
diff --git a/paludis/repositories/e/exheres_profile.cc b/paludis/repositories/e/exheres_profile.cc
index bca3e61..3d85c5d 100644
--- a/paludis/repositories/e/exheres_profile.cc
+++ b/paludis/repositories/e/exheres_profile.cc
@@ -73,6 +73,8 @@ namespace paludis
struct Imp<ExheresProfile>
{
const Environment * const env;
+ const bool has_master_repositories;
+ const EAPIForFileFunction eapi_for_file;
std::shared_ptr<FSPathSequence> profiles_with_parents;
@@ -92,30 +94,28 @@ namespace paludis
const std::shared_ptr<SetSpecTree> system_packages;
- const bool has_master_repositories;
- const EAPIForFileFunction eapi_for_file;
-
- Imp(const Environment * const e, const ERepository * const p,
- const RepositoryName &, const FSPathSequence &,
- const std::string &, const bool) :
+ Imp(
+ const Environment * const e,
+ const EAPIForFileFunction & f,
+ const bool h) :
env(e),
+ has_master_repositories(h),
+ eapi_for_file(f),
profiles_with_parents(std::make_shared<FSPathSequence>()),
options_conf(make_named_values<PaludisLikeOptionsConfParams>(
n::allow_locking() = true,
n::environment() = e,
n::make_config_file() = &make_config_file
)),
- package_mask_file(std::bind(&ERepository::eapi_for_file, p, std::placeholders::_1)),
- packages_file(std::bind(&ERepository::eapi_for_file, p, std::placeholders::_1)),
+ package_mask_file(eapi_for_file),
+ packages_file(eapi_for_file),
use_expand(std::make_shared<Set<std::string>>()),
use_expand_hidden(std::make_shared<Set<std::string>>()),
use_expand_unprefixed(std::make_shared<Set<std::string>>()),
use_expand_implicit(std::make_shared<Set<std::string>>()),
iuse_implicit(std::make_shared<Set<std::string>>()),
use_expand_values(std::make_shared<Set<std::string>>()),
- system_packages(std::make_shared<SetSpecTree>(std::make_shared<AllDepSpec>())),
- has_master_repositories(p->params().master_repositories()),
- eapi_for_file(std::bind(&ERepository::eapi_for_file, p, std::placeholders::_1))
+ system_packages(std::make_shared<SetSpecTree>(std::make_shared<AllDepSpec>()))
{
environment_variables["CONFIG_PROTECT"] = getenv_with_default("CONFIG_PROTECT", "/etc");
environment_variables["CONFIG_PROTECT_MASK"] = getenv_with_default("CONFIG_PROTECT_MASK", "");
@@ -124,10 +124,16 @@ namespace paludis
}
ExheresProfile::ExheresProfile(
- const Environment * const env, const ERepository * const p, const RepositoryName & name,
+ const Environment * const env,
+ const RepositoryName &,
+ const EAPIForFileFunction & eapi_for_file,
+ const IsArchFlagFunction &,
const FSPathSequence & location,
- const std::string & arch_var_if_special, const bool x) :
- _imp(env, p, name, location, arch_var_if_special, x)
+ const std::string &,
+ const bool,
+ const bool has_master_repositories,
+ const bool) :
+ _imp(env, eapi_for_file, has_master_repositories)
{
for (FSPathSequence::ConstIterator l(location.begin()), l_end(location.end()) ;
l != l_end ; ++l)
diff --git a/paludis/repositories/e/exheres_profile.hh b/paludis/repositories/e/exheres_profile.hh
index 449b7cc..0609840 100644
--- a/paludis/repositories/e/exheres_profile.hh
+++ b/paludis/repositories/e/exheres_profile.hh
@@ -38,11 +38,15 @@ namespace paludis
public:
ExheresProfile(
- const Environment * const, const ERepository * const, const RepositoryName &,
- const FSPathSequence &,
+ const Environment * const env,
+ const RepositoryName & name,
+ const EAPIForFileFunction & eapi_for_file,
+ const IsArchFlagFunction & is_arch_flag,
+ const FSPathSequence & dirs,
const std::string & arch_var_if_special,
- const bool x
- );
+ const bool profiles_explicitly_set,
+ const bool has_master_repositories,
+ const bool ignore_deprecated_profiles);
virtual ~ExheresProfile();
diff --git a/paludis/repositories/e/profile.cc b/paludis/repositories/e/profile.cc
index 70ffdf4..9f00c23 100644
--- a/paludis/repositories/e/profile.cc
+++ b/paludis/repositories/e/profile.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2009, 2010 Ciaran McCreesh
+ * Copyright (c) 2009, 2010, 2011 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
@@ -22,6 +22,7 @@
#include <paludis/repositories/e/exheres_profile.hh>
#include <paludis/name.hh>
#include <paludis/dep_spec.hh>
+#include <paludis/choice.hh>
#include <paludis/util/wrapped_forward_iterator-impl.hh>
#include <paludis/util/map-impl.hh>
@@ -33,41 +34,29 @@ Profile::~Profile()
{
}
-namespace
-{
- template <typename T_>
- std::shared_ptr<Profile>
- make_profile(
- const Environment * const env,
- const ERepository * const repo,
- const RepositoryName & name,
- const FSPathSequence & locations,
- const std::string & a,
- const bool x)
- {
- return std::make_shared<T_>(env, repo, name, locations, a, x);
- }
-}
-
ProfileFactory::ProfileFactory()
{
}
const std::shared_ptr<Profile>
ProfileFactory::create(
- const std::string & s,
+ const std::string & format,
const Environment * const env,
- const ERepository * const repo,
const RepositoryName & name,
- const FSPathSequence & locations,
- const std::string & a,
- const bool x) const
+ const EAPIForFileFunction & eapi_for_file,
+ const IsArchFlagFunction & is_arch_flag,
+ const FSPathSequence & dirs,
+ const std::string & arch_var_if_special,
+ const bool profiles_explicitly_set,
+ const bool has_master_repositories,
+ const bool ignore_deprecated_profiles) 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 + "'");
+ if (format == "traditional")
+ return std::make_shared<TraditionalProfile>(env, name, eapi_for_file, is_arch_flag, dirs, arch_var_if_special, profiles_explicitly_set, has_master_repositories, ignore_deprecated_profiles);
+ if (format == "exheres")
+ return std::make_shared<ExheresProfile>(env, name, eapi_for_file, is_arch_flag, dirs, arch_var_if_special, profiles_explicitly_set, has_master_repositories, ignore_deprecated_profiles);
+
+ throw ConfigurationError("Unrecognised profile '" + format + "'");
}
template class Map<QualifiedPackageName, PackageDepSpec>;
diff --git a/paludis/repositories/e/profile.hh b/paludis/repositories/e/profile.hh
index 83d0cd9..6af8228 100644
--- a/paludis/repositories/e/profile.hh
+++ b/paludis/repositories/e/profile.hh
@@ -35,6 +35,7 @@
#include <paludis/repositories/e/e_repository_id.hh>
#include <paludis/repositories/e/mask_info.hh>
#include <string>
+#include <functional>
namespace paludis
{
@@ -42,6 +43,8 @@ namespace paludis
namespace erepository
{
+ typedef std::function<bool (const UnprefixedChoiceName &)> IsArchFlagFunction;
+
class PALUDIS_VISIBLE Profile
{
public:
@@ -110,14 +113,17 @@ namespace paludis
public:
const std::shared_ptr<Profile> create(
- const std::string &,
- const Environment * const,
- const ERepository * const,
+ const std::string & format,
+ const Environment * const env,
const RepositoryName &,
- const FSPathSequence &,
+ const EAPIForFileFunction & eapi_for_file,
+ const IsArchFlagFunction & is_arch_flag,
+ const FSPathSequence & dirs,
const std::string & arch_var_if_special,
- const bool profiles_explicitly_set)
- const PALUDIS_ATTRIBUTE((warn_unused_result));
+ const bool profiles_explicitly_set,
+ const bool has_master_repositories,
+ const bool ignore_deprecated_profiles
+ ) const PALUDIS_ATTRIBUTE((warn_unused_result));
};
}
}
diff --git a/paludis/repositories/e/traditional_profile.cc b/paludis/repositories/e/traditional_profile.cc
index 8a7bad1..4a87b12 100644
--- a/paludis/repositories/e/traditional_profile.cc
+++ b/paludis/repositories/e/traditional_profile.cc
@@ -94,13 +94,6 @@ namespace
};
typedef std::list<StackedValues> StackedValuesList;
-
- typedef std::function<bool (const UnprefixedChoiceName &)> IsArchFlagFunction;
-
- bool is_arch_flag_func(const ERepository * const r, const UnprefixedChoiceName & p)
- {
- return r->arch_flags()->end() != r->arch_flags()->find(p);
- }
}
namespace paludis
@@ -122,10 +115,6 @@ namespace paludis
void handle_profile_arch_var(const std::string &);
void load_special_make_defaults_vars(const FSPath &);
- ProfileFile<LineConfigFile> packages_file;
- ProfileFile<LineConfigFile> virtuals_file;
- ProfileFile<MaskFile> package_mask_file;
-
bool is_incremental(const EAPI &, const std::string & s) const;
const Environment * const env;
@@ -133,6 +122,10 @@ namespace paludis
const IsArchFlagFunction is_arch_flag;
const bool has_master_repositories;
+ ProfileFile<LineConfigFile> packages_file;
+ ProfileFile<LineConfigFile> virtuals_file;
+ ProfileFile<MaskFile> package_mask_file;
+
std::shared_ptr<FSPathSequence> profiles_with_parents;
EnvironmentVariablesMap environment_variables;
@@ -155,16 +148,22 @@ namespace paludis
PackageMaskMap package_mask;
- Imp(const Environment * const e, const ERepository * const p,
- const RepositoryName & name, const FSPathSequence & dirs,
- const std::string & arch_var_if_special, const bool profiles_explicitly_set) :
- packages_file(std::bind(&ERepository::eapi_for_file, p, std::placeholders::_1)),
- virtuals_file(std::bind(&ERepository::eapi_for_file, p, std::placeholders::_1)),
- package_mask_file(std::bind(&ERepository::eapi_for_file, p, std::placeholders::_1)),
+ Imp(const Environment * const e,
+ const RepositoryName & name,
+ const EAPIForFileFunction & p,
+ const IsArchFlagFunction & a,
+ const FSPathSequence & dirs,
+ const std::string & arch_var_if_special,
+ const bool profiles_explicitly_set,
+ const bool h,
+ const bool ignore_deprecated_profiles) :
env(e),
- eapi_for_file(std::bind(&ERepository::eapi_for_file, p, std::placeholders::_1)),
- is_arch_flag(std::bind(&is_arch_flag_func, p, std::placeholders::_1)),
- has_master_repositories(p->params().master_repositories()),
+ eapi_for_file(p),
+ is_arch_flag(a),
+ has_master_repositories(h),
+ packages_file(eapi_for_file),
+ virtuals_file(eapi_for_file),
+ package_mask_file(eapi_for_file),
profiles_with_parents(std::make_shared<FSPathSequence>()),
system_packages(std::make_shared<SetSpecTree>(std::make_shared<AllDepSpec>())),
virtuals(std::make_shared<Map<QualifiedPackageName, PackageDepSpec>>()),
@@ -186,11 +185,10 @@ namespace paludis
{
Context subcontext("When using directory '" + stringify(*d) + "':");
- if (profiles_explicitly_set)
- if (! p->params().ignore_deprecated_profiles())
- if ((*d / "deprecated").stat().is_regular_file_or_symlink_to_regular_file())
- Log::get_instance()->message("e.profile.deprecated", ll_warning, lc_context) << "Profile directory '" << *d
- << "' is deprecated. See the file '" << (*d / "deprecated") << "' for details";
+ if (profiles_explicitly_set && ! ignore_deprecated_profiles)
+ if ((*d / "deprecated").stat().is_regular_file_or_symlink_to_regular_file())
+ Log::get_instance()->message("e.profile.deprecated", ll_warning, lc_context) << "Profile directory '" << *d
+ << "' is deprecated. See the file '" << (*d / "deprecated") << "' for details";
load_profile_directory_recursively(*d);
}
@@ -785,10 +783,16 @@ Imp<TraditionalProfile>::handle_profile_arch_var(const std::string & s)
}
TraditionalProfile::TraditionalProfile(
- const Environment * const env, const ERepository * const p, const RepositoryName & name,
- const FSPathSequence & location,
- const std::string & arch_var_if_special, const bool x) :
- _imp(env, p, name, location, arch_var_if_special, x)
+ const Environment * const env,
+ const RepositoryName & name,
+ const EAPIForFileFunction & eapi_for_file,
+ const IsArchFlagFunction & is_arch_flag,
+ const FSPathSequence & dirs,
+ const std::string & arch_var_if_special,
+ const bool profiles_explicitly_set,
+ const bool has_master_repositories,
+ const bool ignore_deprecated_profiles) :
+ _imp(env, name, eapi_for_file, is_arch_flag, dirs, arch_var_if_special, profiles_explicitly_set, has_master_repositories, ignore_deprecated_profiles)
{
}
diff --git a/paludis/repositories/e/traditional_profile.hh b/paludis/repositories/e/traditional_profile.hh
index e9bd53d..2fd3083 100644
--- a/paludis/repositories/e/traditional_profile.hh
+++ b/paludis/repositories/e/traditional_profile.hh
@@ -36,10 +36,15 @@ namespace paludis
public:
TraditionalProfile(
- const Environment * const, const ERepository * const, const RepositoryName &,
- const FSPathSequence &,
+ const Environment * const env,
+ const RepositoryName &,
+ const EAPIForFileFunction & eapi_for_file,
+ const IsArchFlagFunction & is_arch_flag,
+ const FSPathSequence & dirs,
const std::string & arch_var_if_special,
- const bool x
+ const bool profiles_explicitly_set,
+ const bool has_master_repositories,
+ const bool ignore_deprecated_profiles
);
virtual ~TraditionalProfile();