aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-12-05 14:22:52 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-12-05 21:19:05 +0000
commitd97eebaccb30a9669471516db9e7243420cbae47 (patch)
treec24fe926a4b962459f871a6d9e246e098376adab
parent613882fd03bd4ded8ffd24797df3d7adb065a50e (diff)
downloadpaludis-d97eebaccb30a9669471516db9e7243420cbae47.tar.gz
paludis-d97eebaccb30a9669471516db9e7243420cbae47.tar.xz
Add REQUIRED_USE
-rw-r--r--paludis/repositories/e/e_installed_repository_id.cc16
-rw-r--r--paludis/repositories/e/e_installed_repository_id.hh1
-rw-r--r--paludis/repositories/e/e_key.cc88
-rw-r--r--paludis/repositories/e/e_key.hh24
-rw-r--r--paludis/repositories/e/e_repository_id.hh1
-rw-r--r--paludis/repositories/e/eapi.cc1
-rw-r--r--paludis/repositories/e/eapi.hh2
-rw-r--r--paludis/repositories/e/eapis/0.conf1
-rw-r--r--paludis/repositories/e/eapis/4.conf8
-rw-r--r--paludis/repositories/e/eapis/exheres-0.conf1
-rw-r--r--paludis/repositories/e/eapis/paludis-1.conf1
-rw-r--r--paludis/repositories/e/ebuild.cc3
-rwxr-xr-xpaludis/repositories/e/ebuild/ebuild.bash2
-rw-r--r--paludis/repositories/e/ebuild_flat_metadata_cache.cc9
-rw-r--r--paludis/repositories/e/ebuild_id.cc16
-rw-r--r--paludis/repositories/e/ebuild_id.hh2
16 files changed, 174 insertions, 2 deletions
diff --git a/paludis/repositories/e/e_installed_repository_id.cc b/paludis/repositories/e/e_installed_repository_id.cc
index fd4b01a..e6edae5 100644
--- a/paludis/repositories/e/e_installed_repository_id.cc
+++ b/paludis/repositories/e/e_installed_repository_id.cc
@@ -72,6 +72,7 @@ namespace
std::shared_ptr<const MetadataCollectionKey<Set<std::string > > > raw_iuse;
std::shared_ptr<const MetadataCollectionKey<Set<std::string > > > raw_iuse_effective;
std::shared_ptr<const MetadataSpecTreeKey<PlainTextSpecTree> > raw_myoptions;
+ std::shared_ptr<const MetadataSpecTreeKey<RequiredUseSpecTree> > required_use;
std::shared_ptr<const MetadataCollectionKey<Set<std::string > > > raw_use_expand;
std::shared_ptr<const MetadataCollectionKey<Set<std::string > > > raw_use_expand_hidden;
std::shared_ptr<const MetadataValueKey<std::shared_ptr<const Choices> > > choices;
@@ -279,6 +280,14 @@ EInstalledRepositoryID::need_keys_added() const
add_metadata_key(_imp->keys->raw_myoptions);
}
+ if (! vars->required_use()->name().empty())
+ if ((_imp->dir / vars->required_use()->name()).stat().exists())
+ {
+ _imp->keys->required_use = std::make_shared<ERequiredUseKey>(_imp->environment, shared_from_this(), vars->required_use()->name(),
+ vars->required_use()->description(), file_contents(_imp->dir / vars->required_use()->name()), mkt_internal);
+ add_metadata_key(_imp->keys->required_use);
+ }
+
if (! vars->use_expand()->name().empty())
if ((_imp->dir / vars->use_expand()->name()).stat().exists())
{
@@ -717,6 +726,13 @@ EInstalledRepositoryID::raw_myoptions_key() const
return _imp->keys->raw_myoptions;
}
+const std::shared_ptr<const MetadataSpecTreeKey<RequiredUseSpecTree> >
+EInstalledRepositoryID::required_use_key() const
+{
+ need_keys_added();
+ return _imp->keys->required_use;
+}
+
const std::shared_ptr<const MetadataCollectionKey<Set<std::string> > >
EInstalledRepositoryID::raw_use_expand_key() const
{
diff --git a/paludis/repositories/e/e_installed_repository_id.hh b/paludis/repositories/e/e_installed_repository_id.hh
index 16dea83..d61c66b 100644
--- a/paludis/repositories/e/e_installed_repository_id.hh
+++ b/paludis/repositories/e/e_installed_repository_id.hh
@@ -89,6 +89,7 @@ namespace paludis
virtual const std::shared_ptr<const MetadataCollectionKey<Set<std::string> > > inherited_key() const;
virtual const std::shared_ptr<const MetadataCollectionKey<Set<std::string> > > defined_phases_key() const;
virtual const std::shared_ptr<const MetadataSpecTreeKey<LicenseSpecTree> > license_key() const;
+ virtual const std::shared_ptr<const MetadataSpecTreeKey<RequiredUseSpecTree> > required_use_key() const;
virtual const std::shared_ptr<const MetadataCollectionKey<Set<std::string> > > behaviours_key() const;
diff --git a/paludis/repositories/e/e_key.cc b/paludis/repositories/e/e_key.cc
index fb96a94..921a503 100644
--- a/paludis/repositories/e/e_key.cc
+++ b/paludis/repositories/e/e_key.cc
@@ -681,6 +681,94 @@ EMyOptionsKey::type() const
namespace paludis
{
template <>
+ struct Imp<ERequiredUseKey>
+ {
+ const Environment * const env;
+ const std::shared_ptr<const ERepositoryID> id;
+ const std::string string_value;
+ mutable Mutex value_mutex;
+ mutable std::shared_ptr<const RequiredUseSpecTree> value;
+
+ const std::string raw_name;
+ const std::string human_name;
+ const MetadataKeyType type;
+
+ Imp(const Environment * const e, const std::shared_ptr<const ERepositoryID> & i, const std::string & v,
+ const std::string & r, const std::string & h, const MetadataKeyType t) :
+ env(e),
+ id(i),
+ string_value(v),
+ raw_name(r),
+ human_name(h),
+ type(t)
+ {
+ }
+ };
+}
+
+ERequiredUseKey::ERequiredUseKey(const Environment * const e,
+ const std::shared_ptr<const ERepositoryID> & id,
+ const std::string & r, const std::string & h, const std::string & v, const MetadataKeyType t) :
+ Pimp<ERequiredUseKey>(e, id, v, r, h, t)
+{
+}
+
+ERequiredUseKey::~ERequiredUseKey()
+{
+}
+
+const std::shared_ptr<const RequiredUseSpecTree>
+ERequiredUseKey::value() const
+{
+ Lock l(_imp->value_mutex);
+
+ if (_imp->value)
+ return _imp->value;
+
+ Context context("When parsing metadata key '" + raw_name() + "' from '" + stringify(*_imp->id) + "':");
+ _imp->value = parse_required_use(_imp->string_value, _imp->env, _imp->id, *_imp->id->eapi());
+ return _imp->value;
+}
+
+std::string
+ERequiredUseKey::pretty_print(const RequiredUseSpecTree::ItemFormatter & f) const
+{
+ StringifyFormatter ff(f);
+ DepSpecPrettyPrinter p(_imp->env, _imp->id, ff, 0, true, true);
+ value()->top()->accept(p);
+ return stringify(p);
+}
+
+std::string
+ERequiredUseKey::pretty_print_flat(const RequiredUseSpecTree::ItemFormatter & f) const
+{
+ StringifyFormatter ff(f);
+ DepSpecPrettyPrinter p(_imp->env, _imp->id, ff, 0, false, true);
+ value()->top()->accept(p);
+ return stringify(p);
+}
+
+const std::string
+ERequiredUseKey::raw_name() const
+{
+ return _imp->raw_name;
+}
+
+const std::string
+ERequiredUseKey::human_name() const
+{
+ return _imp->human_name;
+}
+
+MetadataKeyType
+ERequiredUseKey::type() const
+{
+ return _imp->type;
+}
+
+namespace paludis
+{
+ template <>
struct Imp<EProvideKey>
{
const Environment * const env;
diff --git a/paludis/repositories/e/e_key.hh b/paludis/repositories/e/e_key.hh
index 695b677..e43b71d 100644
--- a/paludis/repositories/e/e_key.hh
+++ b/paludis/repositories/e/e_key.hh
@@ -189,6 +189,30 @@ namespace paludis
virtual MetadataKeyType type() const PALUDIS_ATTRIBUTE((warn_unused_result));
};
+ class ERequiredUseKey :
+ public MetadataSpecTreeKey<RequiredUseSpecTree>,
+ private Pimp<ERequiredUseKey>
+ {
+ public:
+ ERequiredUseKey(const Environment * const,
+ const std::shared_ptr<const ERepositoryID> &,
+ const std::string &, const std::string &, const std::string &, const MetadataKeyType);
+ ~ERequiredUseKey();
+
+ virtual const std::shared_ptr<const RequiredUseSpecTree> value() const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual std::string pretty_print(const RequiredUseSpecTree::ItemFormatter &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual std::string pretty_print_flat(const RequiredUseSpecTree::ItemFormatter &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual const std::string raw_name() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ virtual const std::string human_name() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ virtual MetadataKeyType type() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ };
+
class EProvideKey :
public MetadataSpecTreeKey<ProvideSpecTree>,
private Pimp<EProvideKey>
diff --git a/paludis/repositories/e/e_repository_id.hh b/paludis/repositories/e/e_repository_id.hh
index 1584275..6fd3f8c 100644
--- a/paludis/repositories/e/e_repository_id.hh
+++ b/paludis/repositories/e/e_repository_id.hh
@@ -44,6 +44,7 @@ namespace paludis
virtual const std::shared_ptr<const MetadataCollectionKey<Set<std::string> > > raw_use_expand_key() const = 0;
virtual const std::shared_ptr<const MetadataCollectionKey<Set<std::string> > > raw_use_expand_hidden_key() const = 0;
virtual const std::shared_ptr<const MetadataCollectionKey<Set<std::string> > > defined_phases_key() const = 0;
+ virtual const std::shared_ptr<const MetadataSpecTreeKey<RequiredUseSpecTree> > required_use_key() const = 0;
virtual std::shared_ptr<const Set<std::string> > breaks_portage() const PALUDIS_ATTRIBUTE((warn_unused_result));
diff --git a/paludis/repositories/e/eapi.cc b/paludis/repositories/e/eapi.cc
index 07c2146..6fc3bca 100644
--- a/paludis/repositories/e/eapi.cc
+++ b/paludis/repositories/e/eapi.cc
@@ -138,6 +138,7 @@ namespace
n::properties() = make_metadata_variable(k, "properties"),
n::provide() = make_metadata_variable(k, "provide"),
n::remote_ids() = make_metadata_variable(k, "remote_ids"),
+ n::required_use() = make_metadata_variable(k, "required_use"),
n::restrictions() = make_metadata_variable(k, "restrict"),
n::run_depend() = make_metadata_variable(k, "run_depend"),
n::short_description() = make_metadata_variable(k, "short_description"),
diff --git a/paludis/repositories/e/eapi.hh b/paludis/repositories/e/eapi.hh
index bc28929..6a0ace7 100644
--- a/paludis/repositories/e/eapi.hh
+++ b/paludis/repositories/e/eapi.hh
@@ -166,6 +166,7 @@ namespace paludis
typedef Name<struct rdepend_defaults_to_depend_name> rdepend_defaults_to_depend;
typedef Name<struct remote_ids_name> remote_ids;
typedef Name<struct require_use_expand_in_iuse_name> require_use_expand_in_iuse;
+ typedef Name<struct required_use_name> required_use;
typedef Name<struct restrict_fetch_name> restrict_fetch;
typedef Name<struct restrict_mirror_name> restrict_mirror;
typedef Name<struct restrict_primaryuri_name> restrict_primaryuri;
@@ -366,6 +367,7 @@ namespace paludis
NamedValue<n::properties, std::shared_ptr<const EAPIMetadataVariable> > properties;
NamedValue<n::provide, std::shared_ptr<const EAPIMetadataVariable> > provide;
NamedValue<n::remote_ids, std::shared_ptr<const EAPIMetadataVariable> > remote_ids;
+ NamedValue<n::required_use, std::shared_ptr<const EAPIMetadataVariable> > required_use;
NamedValue<n::restrictions, std::shared_ptr<const EAPIMetadataVariable> > restrictions;
NamedValue<n::run_depend, std::shared_ptr<const EAPIMetadataVariable> > run_depend;
NamedValue<n::short_description, std::shared_ptr<const EAPIMetadataVariable> > short_description;
diff --git a/paludis/repositories/e/eapis/0.conf b/paludis/repositories/e/eapis/0.conf
index 7b798f2..a5c79c5 100644
--- a/paludis/repositories/e/eapis/0.conf
+++ b/paludis/repositories/e/eapis/0.conf
@@ -226,6 +226,7 @@ flat_list_defined_phases = 16
flat_list_generated_from = -1
flat_list_generated_time = -1
flat_list_generated_using = -1
+flat_list_required_use = -1
env_use = USE
env_use_expand = USE_EXPAND
diff --git a/paludis/repositories/e/eapis/4.conf b/paludis/repositories/e/eapis/4.conf
index 960391f..3f5730e 100644
--- a/paludis/repositories/e/eapis/4.conf
+++ b/paludis/repositories/e/eapis/4.conf
@@ -35,7 +35,13 @@ env_replacing_versions = REPLACING_VERSIONS
env_replaced_by_version = REPLACED_BY_VERSION
env_merge_type = MERGE_TYPE
-vdb_from_env_variables = ${vdb_from_env_variables}
+flat_list_required_use = 11
+metadata_required_use = REQUIRED_USE
+description_required_use = Required USE flags
+
+vdb_from_env_variables = ${vdb_from_env_variables} REQUIRED_USE
+binary_from_env_variables = ${binary_from_env_variables} REQUIRED_USE
+source_merged_variables = ${source_merged_variables} REQUIRED_USE
package_dep_spec_parse_options = ${package_dep_spec_parse_options} \
allow_use_dep_defaults
diff --git a/paludis/repositories/e/eapis/exheres-0.conf b/paludis/repositories/e/eapis/exheres-0.conf
index ca74e63..37adfed 100644
--- a/paludis/repositories/e/eapis/exheres-0.conf
+++ b/paludis/repositories/e/eapis/exheres-0.conf
@@ -279,6 +279,7 @@ flat_list_defined_phases = -1
flat_list_generated_from = -1
flat_list_generated_time = -1
flat_list_generated_using = -1
+flat_list_required_use = -1
env_use = OPTIONS
env_use_expand = SUBOPTIONS
diff --git a/paludis/repositories/e/eapis/paludis-1.conf b/paludis/repositories/e/eapis/paludis-1.conf
index 25c3f38..0172cf0 100644
--- a/paludis/repositories/e/eapis/paludis-1.conf
+++ b/paludis/repositories/e/eapis/paludis-1.conf
@@ -229,6 +229,7 @@ flat_list_defined_phases = -1
flat_list_generated_from = -1
flat_list_generated_time = -1
flat_list_generated_using = -1
+flat_list_required_use = -1
env_use = USE
env_use_expand = USE_EXPAND
diff --git a/paludis/repositories/e/ebuild.cc b/paludis/repositories/e/ebuild.cc
index 0faed29..cf7a468 100644
--- a/paludis/repositories/e/ebuild.cc
+++ b/paludis/repositories/e/ebuild.cc
@@ -622,6 +622,9 @@ EbuildMetadataCommand::load(const std::shared_ptr<const EbuildID> & id)
if (! m.myoptions()->name().empty())
id->load_myoptions(m.myoptions()->name(), m.myoptions()->description(), get(keys, m.myoptions()->name()));
+ if (! m.required_use()->name().empty())
+ id->load_required_use(m.required_use()->name(), m.required_use()->description(), get(keys, m.required_use()->name()));
+
if (! m.inherited()->name().empty())
id->load_inherited(m.inherited()->name(), m.inherited()->description(), get(keys, m.inherited()->name()));
diff --git a/paludis/repositories/e/ebuild/ebuild.bash b/paludis/repositories/e/ebuild/ebuild.bash
index 3e3ad23..0817f1b 100755
--- a/paludis/repositories/e/ebuild/ebuild.bash
+++ b/paludis/repositories/e/ebuild/ebuild.bash
@@ -86,7 +86,7 @@ EBUILD_METADATA_VARIABLES="DEPEND RDEPEND PDEPEND IUSE SRC_URI DOWNLOADS RESTRIC
GENERATED_USING GENERATED_TIME GENERATED_FROM_REPOSITORY BINARY_PLATFORMS REMOTE_IDS \
SUMMARY BUGS_TO UPSTREAM_DOCUMENTATION UPSTREAM_CHANGELOG \
UPSTREAM_RELEASE_NOTES PROPERTIES PALUDIS_DECLARED_FUNCTIONS SLOT EAPI OPTIONS USE \
- PALUDIS_EBUILD_RDEPEND_WAS_SET PALUDIS_EBUILD_DEPEND"
+ PALUDIS_EBUILD_RDEPEND_WAS_SET PALUDIS_EBUILD_DEPEND REQUIRED_USE"
EBUILD_METADATA_VARIABLES_FROM_CPLUSPLUS="SLOT EAPI OPTIONS USE"
if [[ -z "${PALUDIS_DO_NOTHING_SANDBOXY}" ]] ; then
diff --git a/paludis/repositories/e/ebuild_flat_metadata_cache.cc b/paludis/repositories/e/ebuild_flat_metadata_cache.cc
index a57d806..8b5dc7a 100644
--- a/paludis/repositories/e/ebuild_flat_metadata_cache.cc
+++ b/paludis/repositories/e/ebuild_flat_metadata_cache.cc
@@ -239,6 +239,9 @@ namespace
if (-1 != m.myoptions()->flat_list_index() && ! m.myoptions()->name().empty())
id->load_myoptions(m.myoptions()->name(), m.myoptions()->description(), lines.at(m.myoptions()->flat_list_index()));
+ if (-1 != m.required_use()->flat_list_index() && ! m.required_use()->name().empty())
+ id->load_required_use(m.required_use()->name(), m.required_use()->description(), lines.at(m.required_use()->flat_list_index()));
+
if (-1 != m.pdepend()->flat_list_index() && ! m.pdepend()->name().empty())
id->load_post_depend(m.pdepend()->name(), m.pdepend()->description(), lines.at(m.pdepend()->flat_list_index()), false);
@@ -581,6 +584,9 @@ EbuildFlatMetadataCache::load(const std::shared_ptr<const EbuildID> & id, const
if (! m.myoptions()->name().empty())
id->load_myoptions(m.myoptions()->name(), m.myoptions()->description(), keys[m.myoptions()->name()]);
+ if (! m.required_use()->name().empty())
+ id->load_required_use(m.required_use()->name(), m.required_use()->description(), keys[m.required_use()->name()]);
+
if (! m.pdepend()->name().empty())
id->load_post_depend(m.pdepend()->name(), m.pdepend()->description(), keys[m.pdepend()->name()], false);
@@ -818,6 +824,9 @@ EbuildFlatMetadataCache::save(const std::shared_ptr<const EbuildID> & id)
if (! m.myoptions()->name().empty() && id->raw_myoptions_key())
write_kv(cache, m.myoptions()->name(), flatten(id->raw_myoptions_key()->value()));
+ if (! m.required_use()->name().empty() && id->required_use_key())
+ write_kv(cache, m.required_use()->name(), flatten(id->required_use_key()->value()));
+
if (! m.pdepend()->name().empty() && id->post_dependencies_key())
write_kv(cache, m.pdepend()->name(), flatten(id->post_dependencies_key()->value()));
diff --git a/paludis/repositories/e/ebuild_id.cc b/paludis/repositories/e/ebuild_id.cc
index 86807ab..050ee4f 100644
--- a/paludis/repositories/e/ebuild_id.cc
+++ b/paludis/repositories/e/ebuild_id.cc
@@ -106,6 +106,7 @@ namespace paludis
mutable std::shared_ptr<const EStringSetKey> raw_iuse;
mutable std::shared_ptr<const LiteralMetadataStringSetKey> raw_iuse_effective;
mutable std::shared_ptr<const EMyOptionsKey> raw_myoptions;
+ mutable std::shared_ptr<const ERequiredUseKey> required_use;
mutable std::shared_ptr<const EStringSetKey> inherited;
mutable std::shared_ptr<const EStringSetKey> raw_use;
mutable std::shared_ptr<const LiteralMetadataStringSetKey> raw_use_expand;
@@ -712,6 +713,13 @@ EbuildID::raw_myoptions_key() const
return _imp->raw_myoptions;
}
+const std::shared_ptr<const MetadataSpecTreeKey<RequiredUseSpecTree> >
+EbuildID::required_use_key() const
+{
+ need_keys_added();
+ return _imp->required_use;
+}
+
const std::shared_ptr<const MetadataCollectionKey<Set<std::string> > >
EbuildID::raw_use_key() const
{
@@ -1048,6 +1056,14 @@ EbuildID::load_myoptions(const std::string & r, const std::string & h, const std
}
void
+EbuildID::load_required_use(const std::string & r, const std::string & h, const std::string & v) const
+{
+ Lock l(_imp->mutex);
+ _imp->required_use = std::make_shared<ERequiredUseKey>(_imp->environment, shared_from_this(), r, h, v, mkt_internal);
+ add_metadata_key(_imp->required_use);
+}
+
+void
EbuildID::load_use(const std::string & r, const std::string & h, const std::string & v) const
{
Lock l(_imp->mutex);
diff --git a/paludis/repositories/e/ebuild_id.hh b/paludis/repositories/e/ebuild_id.hh
index 52c8292..299ef3a 100644
--- a/paludis/repositories/e/ebuild_id.hh
+++ b/paludis/repositories/e/ebuild_id.hh
@@ -97,6 +97,7 @@ namespace paludis
virtual const std::shared_ptr<const MetadataCollectionKey<Set<std::string> > > raw_use_expand_key() const;
virtual const std::shared_ptr<const MetadataCollectionKey<Set<std::string> > > raw_use_expand_hidden_key() const;
virtual const std::shared_ptr<const MetadataCollectionKey<Set<std::string> > > defined_phases_key() const;
+ virtual const std::shared_ptr<const MetadataSpecTreeKey<RequiredUseSpecTree> > required_use_key() const;
virtual const std::shared_ptr<const MetadataCollectionKey<Set<std::string> > > behaviours_key() const;
@@ -136,6 +137,7 @@ namespace paludis
void load_provide(const std::string &, const std::string &, const std::string &) const;
void load_iuse(const std::string &, const std::string &, const std::string &) const;
void load_myoptions(const std::string &, const std::string &, const std::string &) const;
+ void load_required_use(const std::string &, const std::string &, const std::string &) const;
void load_use(const std::string &, const std::string &, const std::string &) const;
void load_inherited(const std::string &, const std::string &, const std::string &) const;
void load_keywords(const std::string &, const std::string &, const std::string &) const;