aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-01-17 03:08:03 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-01-17 03:08:03 +0000
commit257c29ad4b74799e3d183fc4457b820c65606e6e (patch)
tree72de5d31f7ad1c843eb4e28d0468e62de3292109
parent093e77ffc9376d82472f6aed211242db45437d47 (diff)
downloadpaludis-257c29ad4b74799e3d183fc4457b820c65606e6e.tar.gz
paludis-257c29ad4b74799e3d183fc4457b820c65606e6e.tar.xz
Initial use.mask support for Portage repositories
-rw-r--r--paludis/portage_repository.cc55
1 files changed, 52 insertions, 3 deletions
diff --git a/paludis/portage_repository.cc b/paludis/portage_repository.cc
index f8a7289..7662bd2 100644
--- a/paludis/portage_repository.cc
+++ b/paludis/portage_repository.cc
@@ -75,6 +75,11 @@ namespace paludis
/// Have repository mask?
mutable bool has_repo_mask;
+ /// Use mask.
+ mutable std::set<UseFlagName> use_mask;
+
+ mutable bool has_use_mask;
+
/// Constructor.
Implementation(const FSEntry & l, const FSEntry & p) :
location(l),
@@ -83,9 +88,47 @@ namespace paludis
has_repo_mask(false)
{
}
+
+ /// Add a use.mask file from a profile directory, recursive.
+ void add_use_mask(const FSEntry & f) const;
};
}
+void
+Implementation<PortageRepository>::add_use_mask(const FSEntry & f) const
+{
+ Context context("When reading profile directory '" + stringify(f) + "':");
+
+ if (! f.is_directory())
+ throw InternalError(__PRETTY_FUNCTION__, "todo"); /// \bug exception
+
+ if ((f / "parent").exists())
+ {
+ std::ifstream parent_file(stringify(f / "parent").c_str());
+ if (! parent_file)
+ throw InternalError(__PRETTY_FUNCTION__, "todo"); /// \bug exception
+ LineConfigFile parent(&parent_file);
+ if (parent.begin() != parent.end())
+ add_use_mask((f / *parent.begin()).realpath());
+ else
+ throw InternalError(__PRETTY_FUNCTION__, "todo"); /// \bug exception
+ }
+
+ if ((f / "use.mask").exists())
+ {
+ std::ifstream use_mask_file(stringify(f / "use.mask").c_str());
+ if (! use_mask_file)
+ throw InternalError(__PRETTY_FUNCTION__, "todo"); /// \bug exception
+ LineConfigFile use_mask_f(&use_mask_file);
+ for (LineConfigFile::Iterator line(use_mask_f.begin()), line_end(use_mask_f.end()) ;
+ line != line_end ; ++line)
+ if ('-' == line->at(0))
+ use_mask.erase(UseFlagName(line->substr(1)));
+ else
+ use_mask.insert(UseFlagName(*line));
+ }
+}
+
PortageRepository::PortageRepository(const FSEntry & location, const FSEntry & profile) :
Repository(PortageRepository::fetch_repo_name(location)),
PrivateImplementationPattern<PortageRepository>(new Implementation<PortageRepository>(location, profile))
@@ -412,9 +455,15 @@ PortageRepository::do_query_use(const UseFlagName &, const bool & d) const
}
bool
-PortageRepository::do_query_use_mask(const UseFlagName &) const
+PortageRepository::do_query_use_mask(const UseFlagName & u) const
{
- /// \todo;
- return false;
+ if (! _implementation->has_use_mask)
+ {
+ Context context("When checking USE mask for '" + stringify(u) + "':");
+ _implementation->add_use_mask(_implementation->profile.realpath());
+ _implementation->has_use_mask = true;
+ }
+
+ return _implementation->use_mask.end() != _implementation->use_mask.find(u);
}