aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-07-16 19:19:52 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-07-16 19:19:52 +0000
commitae97e3f4b15b180fe0d1bcc4257103c3ad116f83 (patch)
tree6150b02237e5b668b36743d296df0cf799347b55
parent4efa00282a8282be189bcda866a8fad9c448a407 (diff)
downloadpaludis-ae97e3f4b15b180fe0d1bcc4257103c3ad116f83.tar.gz
paludis-ae97e3f4b15b180fe0d1bcc4257103c3ad116f83.tar.xz
Smarter mask reasons code. Fixes: ticket:317
-rw-r--r--paludis/dep_list/Makefile.am6
-rw-r--r--paludis/dep_list/dep_list.cc70
-rw-r--r--paludis/dep_list/dep_list.hh4
-rw-r--r--paludis/dep_list/dep_list.sr2
-rw-r--r--paludis/dep_list/dep_list_TEST.cc25
-rw-r--r--paludis/dep_list/dep_list_TEST.hh3
-rw-r--r--paludis/dep_list/options.hh10
-rw-r--r--paludis/dep_list/options.se20
-rw-r--r--paludis/dep_list/override_functions.cc428
-rw-r--r--paludis/dep_list/override_functions.hh43
-rw-r--r--paludis/dep_list/show_suggest_visitor.cc2
-rw-r--r--paludis/environment.hh37
-rw-r--r--paludis/environment_implementation.cc264
-rw-r--r--paludis/environment_implementation.hh81
-rw-r--r--paludis/environment_implementation_TEST.cc154
-rw-r--r--paludis/environments/adapted/adapted_environment.cc24
-rw-r--r--paludis/environments/adapted/adapted_environment.hh14
-rw-r--r--paludis/environments/no_config/no_config_environment.cc75
-rw-r--r--paludis/environments/no_config/no_config_environment.hh37
-rw-r--r--paludis/environments/paludis/paludis_environment.cc68
-rw-r--r--paludis/environments/paludis/paludis_environment.hh29
-rw-r--r--paludis/environments/paludis/paludis_environment_TEST.cc2
-rw-r--r--paludis/environments/portage/portage_environment.cc100
-rw-r--r--paludis/environments/portage/portage_environment.hh31
-rw-r--r--paludis/environments/test/test_environment.cc74
-rw-r--r--paludis/environments/test/test_environment.hh36
-rw-r--r--paludis/files.m44
-rw-r--r--paludis/mask-fwd.hh (renamed from paludis/mask_reasons.cc)22
-rw-r--r--paludis/mask_reasons.hh45
-rw-r--r--paludis/mask_reasons.se27
-rw-r--r--paludis/package_id.cc28
-rw-r--r--paludis/package_id.hh28
-rw-r--r--paludis/query.cc2
-rw-r--r--paludis/repositories/e/Makefile.am84
-rw-r--r--paludis/repositories/e/e_mask.cc154
-rw-r--r--paludis/repositories/e/e_mask.hh70
-rw-r--r--paludis/repositories/e/e_repository.cc11
-rw-r--r--paludis/repositories/e/e_repository.hh11
-rw-r--r--paludis/repositories/e/e_repository_TEST.cc12
-rw-r--r--paludis/repositories/e/e_repository_news.cc1
-rw-r--r--paludis/repositories/e/e_repository_profile.cc1
-rw-r--r--paludis/repositories/e/ebuild.cc1
-rw-r--r--paludis/repositories/e/ebuild_id.cc117
-rw-r--r--paludis/repositories/e/ebuild_id.hh1
-rw-r--r--paludis/repositories/e/vdb_id.cc5
-rw-r--r--paludis/repositories/e/vdb_id.hh1
-rw-r--r--paludis/repositories/e/vdb_repository.cc1
-rw-r--r--paludis/repositories/fake/fake_installed_repository.cc1
-rw-r--r--paludis/repositories/fake/fake_package_id.cc208
-rw-r--r--paludis/repositories/fake/fake_package_id.hh31
-rw-r--r--paludis/repositories/fake/fake_repository.cc1
-rw-r--r--paludis/repositories/fake/fake_repository_base.cc15
-rw-r--r--paludis/repositories/fake/fake_repository_base.hh9
-rw-r--r--paludis/repositories/gems/gem_specification.cc43
-rw-r--r--paludis/repositories/gems/gem_specification.hh5
-rw-r--r--paludis/repositories/gems/gem_specification_TEST.cc4
-rw-r--r--paludis/repositories/gems/gem_specifications.cc19
-rw-r--r--paludis/repositories/gems/gem_specifications.hh2
-rw-r--r--paludis/repositories/gems/gems_repository.cc3
-rw-r--r--paludis/repositories/gems/installed_gems_repository.cc4
-rw-r--r--paludis/repositories/virtuals/installed_virtuals_repository.cc1
-rw-r--r--paludis/repositories/virtuals/package_id.cc48
-rw-r--r--paludis/repositories/virtuals/package_id.hh1
-rw-r--r--paludis/repositories/virtuals/virtuals_repository.cc1
-rw-r--r--paludis/repository-fwd.hh1
-rw-r--r--paludis/repository.cc16
-rw-r--r--paludis/repository.hh46
-rw-r--r--paludis/repository.sr1
-rw-r--r--paludis/set_file.cc1
-rw-r--r--paludis/tasks/report_task.cc30
-rw-r--r--paludis/tasks/report_task.hh4
-rw-r--r--python/Makefile.am2
-rw-r--r--python/dep_list.cc15
-rwxr-xr-xpython/dep_list_TEST.py1
-rw-r--r--python/environment.cc22
-rwxr-xr-xpython/environment_TEST.py7
-rw-r--r--python/mask_reasons.cc44
-rwxr-xr-xpython/mask_reasons_TEST.py86
-rw-r--r--python/paludis_python_so.cc2
-rw-r--r--python/repository.cc31
-rwxr-xr-xpython/repository_TEST.py13
-rw-r--r--ruby/Makefile.am2
-rw-r--r--ruby/dep_list.cc212
-rw-r--r--ruby/dep_list_TEST.rb53
-rw-r--r--ruby/environment.cc156
-rw-r--r--ruby/environment_TEST.rb39
-rw-r--r--ruby/mask_reasons.cc172
-rw-r--r--ruby/mask_reasons_TEST.rb52
-rw-r--r--ruby/paludis_ruby.hh3
-rw-r--r--ruby/repository.cc44
-rw-r--r--ruby/repository_TEST.rb35
-rw-r--r--src/clients/adjutrix/what_needs_keywording.cc21
-rw-r--r--src/clients/contrarius/install.cc43
-rw-r--r--src/clients/gtkpaludis/libgtkpaludis/versions_list_model.cc44
-rw-r--r--src/clients/inquisitio/do_search.cc2
-rw-r--r--src/clients/paludis/install.cc64
-rw-r--r--src/clients/paludis/query.cc65
-rw-r--r--src/clients/paludis/report.cc22
-rw-r--r--src/output/console_install_task.cc79
-rw-r--r--src/output/console_query_task.cc64
-rw-r--r--src/output/console_query_task.hh6
101 files changed, 1956 insertions, 2205 deletions
diff --git a/paludis/dep_list/Makefile.am b/paludis/dep_list/Makefile.am
index b490511..f46c509 100644
--- a/paludis/dep_list/Makefile.am
+++ b/paludis/dep_list/Makefile.am
@@ -29,7 +29,8 @@ paludis_dep_list_include_HEADERS = \
uninstall_list-sr.hh \
range_rewriter.hh \
options-se.hh \
- uninstall_list-se.hh
+ uninstall_list-se.hh \
+ override_functions.hh
libpaludisdeplist_la_SOURCES = \
options.cc options.hh \
@@ -39,7 +40,8 @@ libpaludisdeplist_la_SOURCES = \
range_rewriter.cc range_rewriter.hh \
query_visitor.cc query_visitor.hh \
show_suggest_visitor.cc show_suggest_visitor.hh \
- condition_tracker.cc condition_tracker.hh
+ condition_tracker.cc condition_tracker.hh \
+ override_functions.cc override_functions.hh
libpaludisdeplist_la_LDFLAGS = -version-info @VERSION_LIB_CURRENT@:@VERSION_LIB_REVISION@:0
diff --git a/paludis/dep_list/dep_list.cc b/paludis/dep_list/dep_list.cc
index c0d9c6f..e6d950e 100644
--- a/paludis/dep_list/dep_list.cc
+++ b/paludis/dep_list/dep_list.cc
@@ -59,6 +59,8 @@
using namespace paludis;
+template class Sequence<tr1::function<bool (const PackageID &, const Mask &)> >;
+
#include <paludis/dep_list/dep_list-sr.cc>
DepListOptions::DepListOptions() :
@@ -386,62 +388,46 @@ DepList::AddVisitor::visit_leaf(const PackageDepSpec & a)
for (PackageIDSequence::ReverseIterator p(installable_candidates->rbegin()),
p_end(installable_candidates->rend()) ; p != p_end ; ++p)
- if (! d->_imp->env->mask_reasons(**p).any())
+ if (! (*p)->masked())
{
best_visible_candidate = *p;
break;
}
/* are we allowed to override mask reasons? */
- if (! best_visible_candidate && d->_imp->opts->override_masks.any())
+ if (! best_visible_candidate && d->_imp->opts->override_masks)
{
- DepListOverrideMask next(static_cast<DepListOverrideMask>(0));
- DepListOverrideMasks masks_to_override;
-
- do
+ for (DepListOverrideMasksFunctions::Iterator of(d->_imp->opts->override_masks->begin()),
+ of_end(d->_imp->opts->override_masks->end()) ; of != of_end ; ++of)
{
- while (next != last_dl_override)
- {
- if (masks_to_override[next])
- next = static_cast<DepListOverrideMask>(static_cast<int>(next) + 1);
- else if (d->_imp->opts->override_masks[next])
- {
- masks_to_override += next;
- break;
- }
- else
- next = static_cast<DepListOverrideMask>(static_cast<int>(next) + 1);
- }
-
- if (next == last_dl_override)
+ if (best_visible_candidate)
break;
- MaskReasons mask_mask;
- if (masks_to_override[dl_override_repository_masks])
- mask_mask += mr_repository_mask;
- if (masks_to_override[dl_override_profile_masks])
- mask_mask += mr_profile_mask;
- if (masks_to_override[dl_override_licenses])
- mask_mask += mr_license;
- mask_mask += mr_by_association;
-
- 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 (PackageIDSequence::ReverseIterator p(installable_candidates->rbegin()),
p_end(installable_candidates->rend()) ; p != p_end ; ++p)
{
- if (! (d->_imp->env->mask_reasons(**p, override_options).subtract(mask_mask).any()))
+ bool success(true);
+ for (PackageID::MasksIterator m((*p)->begin_masks()), m_end((*p)->end_masks()) ;
+ m != m_end ; ++m)
+ {
+ bool local_success(false);
+ for (DepListOverrideMasksFunctions::Iterator o(d->_imp->opts->override_masks->begin()),
+ o_end(next(of)) ; o != o_end ; ++o)
+ if ((*o)(**p, *m))
+ local_success = true;
+
+ success &= local_success;
+ if (! success)
+ break;
+ }
+
+ if (success)
{
d->add_error_package(*p, dlk_masked, a, conditions);
best_visible_candidate = *p;
- break;
}
}
- } while (! best_visible_candidate);
+ }
}
/* no installable candidates. if we're already installed, that's ok (except for top level
@@ -488,7 +474,7 @@ DepList::AddVisitor::visit_leaf(const PackageDepSpec & a)
for (PackageIDSequence::Iterator i(match_except_reqs->begin()),
i_end(match_except_reqs->end()) ; i != i_end ; ++i)
- if (! (d->_imp->env->mask_reasons(**i).any()))
+ if (! (*i)->masked())
throw UseRequirementsNotMetError(stringify(a));
throw AllMaskedError(a);
@@ -678,7 +664,8 @@ DepList::AddVisitor::visit_sequence(const AnyDepSpec & a,
Save<bool> save_t(&d->_imp->throw_on_blocker,
dl_blocks_discard_completely != d->_imp->opts->blocks);
- Save<DepListOverrideMasks> save_o(&d->_imp->opts->override_masks, DepListOverrideMasks());
+ Save<tr1::shared_ptr<DepListOverrideMasksFunctions> > save_o(&d->_imp->opts->override_masks,
+ tr1::shared_ptr<DepListOverrideMasksFunctions>());
d->add_not_top_level(*c, destinations, conditions);
return;
}
@@ -699,7 +686,8 @@ DepList::AddVisitor::visit_sequence(const AnyDepSpec & a,
Save<bool> save_t(&d->_imp->throw_on_blocker,
dl_blocks_discard_completely != d->_imp->opts->blocks);
- Save<DepListOverrideMasks> save_o(&d->_imp->opts->override_masks, DepListOverrideMasks());
+ Save<tr1::shared_ptr<DepListOverrideMasksFunctions> > save_o(&d->_imp->opts->override_masks,
+ tr1::shared_ptr<DepListOverrideMasksFunctions>());
d->add_not_top_level(*c, destinations, conditions);
return;
}
diff --git a/paludis/dep_list/dep_list.hh b/paludis/dep_list/dep_list.hh
index 9da074d..aaab40b 100644
--- a/paludis/dep_list/dep_list.hh
+++ b/paludis/dep_list/dep_list.hh
@@ -21,6 +21,7 @@
#define PALUDIS_GUARD_PALUDIS_DEP_LIST_HH 1
#include <paludis/dep_spec-fwd.hh>
+#include <paludis/mask-fwd.hh>
#include <paludis/dep_tag.hh>
#include <paludis/dep_list/options.hh>
#include <paludis/dep_list/dep_list-fwd.hh>
@@ -29,6 +30,7 @@
#include <paludis/util/instantiation_policy.hh>
#include <paludis/util/private_implementation_pattern.hh>
#include <paludis/util/options.hh>
+#include <paludis/util/tr1_functional.hh>
#include <paludis/version_spec.hh>
#include <iosfwd>
@@ -37,6 +39,8 @@
namespace paludis
{
+ typedef Sequence<tr1::function<bool (const PackageID &, const Mask &)> > DepListOverrideMasksFunctions;
+
#include <paludis/dep_list/dep_list-sr.hh>
/**
diff --git a/paludis/dep_list/dep_list.sr b/paludis/dep_list/dep_list.sr
index d292bff..810bec2 100644
--- a/paludis/dep_list/dep_list.sr
+++ b/paludis/dep_list/dep_list.sr
@@ -26,7 +26,7 @@ make_class_DepListOptions()
key circular DepListCircularOption
key use DepListUseOption
key blocks DepListBlocksOption
- key override_masks DepListOverrideMasks
+ key override_masks "tr1::shared_ptr<DepListOverrideMasksFunctions>"
key dependency_tags bool
diff --git a/paludis/dep_list/dep_list_TEST.cc b/paludis/dep_list/dep_list_TEST.cc
index 8d8ca97..d3803bb 100644
--- a/paludis/dep_list/dep_list_TEST.cc
+++ b/paludis/dep_list/dep_list_TEST.cc
@@ -21,7 +21,9 @@
#include <paludis/util/visitor-impl.hh>
#include <paludis/util/set.hh>
#include <paludis/package_id.hh>
+#include <paludis/mask.hh>
#include <paludis/repositories/fake/fake_package_id.hh>
+#include <paludis/dep_list/override_functions.hh>
#include <paludis/dep_spec_pretty_printer.hh>
#include <libwrapiter/libwrapiter_forward_iterator.hh>
#include <libwrapiter/libwrapiter_output_iterator.hh>
@@ -835,6 +837,21 @@ namespace test_cases
}
} test_dep_list_37;
+ struct DepListTestCase38 : DepListTestCase<38>
+ {
+ void populate_repo()
+ {
+ repo->add_version("cat", "one", "1")->keywords_key()->set_from_string("test");
+ repo->add_version("cat", "one", "2")->keywords_key()->set_from_string("~test");
+ }
+
+ void populate_expected()
+ {
+ merge_target = "cat/one";
+ expected.push_back("cat/one-1:0::repo");
+ }
+ } test_dep_list_38;
+
/**
* \test Test DepList resolution behaviour.
*
@@ -1282,7 +1299,9 @@ namespace test_cases
{
void set_options(DepListOptions & opts)
{
- opts.override_masks += dl_override_tilde_keywords;
+ using namespace tr1::placeholders;
+ opts.override_masks.reset(new DepListOverrideMasksFunctions);
+ opts.override_masks->push_back(tr1::bind(&override_tilde_keywords, &env, _1, _2));
}
void populate_repo()
@@ -1352,7 +1371,9 @@ namespace test_cases
{
void set_options(DepListOptions & opts)
{
- opts.override_masks += dl_override_tilde_keywords;
+ using namespace tr1::placeholders;
+ opts.override_masks.reset(new DepListOverrideMasksFunctions);
+ opts.override_masks->push_back(tr1::bind(&override_tilde_keywords, &env, _1, _2));
}
void populate_repo()
diff --git a/paludis/dep_list/dep_list_TEST.hh b/paludis/dep_list/dep_list_TEST.hh
index 77d78c2..e2a05c6 100644
--- a/paludis/dep_list/dep_list_TEST.hh
+++ b/paludis/dep_list/dep_list_TEST.hh
@@ -136,7 +136,8 @@ namespace test_cases
d.add(PackageDepSpec(merge_target, pds_pm_unspecific), env.default_destinations());
TEST_CHECK(true);
- TestMessageSuffix s("d={ " + join(d.begin(), d.end(), ", ") + " }", false);
+ TestMessageSuffix s("got={ " + join(d.begin(), d.end(), ", ") + " }", false);
+ TestMessageSuffix s2("expected={ " + join(expected.begin(), expected.end(), ", ") + " }", false);
unsigned n(0);
std::list<std::string>::const_iterator exp(expected.begin());
diff --git a/paludis/dep_list/options.hh b/paludis/dep_list/options.hh
index 191401f..127bb93 100644
--- a/paludis/dep_list/options.hh
+++ b/paludis/dep_list/options.hh
@@ -22,20 +22,10 @@
#include <iosfwd>
#include <paludis/util/attributes.hh>
-#include <paludis/util/options.hh>
namespace paludis
{
-
#include <paludis/dep_list/options-se.hh>
-
- /**
- * Set of masks that can be overridden.
- *
- * \ingroup grpdepresolver
- * \see DepListOverrideMask
- */
- typedef Options<DepListOverrideMask> DepListOverrideMasks;
}
#endif
diff --git a/paludis/dep_list/options.se b/paludis/dep_list/options.se
index b8c635d..95cf5c3 100644
--- a/paludis/dep_list/options.se
+++ b/paludis/dep_list/options.se
@@ -253,23 +253,3 @@ make_enum_DepListEntryKind()
END
}
-make_enum_DepListOverrideMask()
-{
- prefix dl_override
-
- key dl_override_licenses "Override unaccepted licences"
- key dl_override_tilde_keywords "Override ~keywords"
- key dl_override_unkeyworded "Override unkeyworded"
- key dl_override_repository_masks "Override repository masks"
- key dl_override_profile_masks "Override profile masks"
-
- doxygen_comment <<"END"
- /**
- * Masks that can be overridden.
- *
- * \ingroup grpdepresolver
- * \see DepListOverrideMasks
- */
-END
-}
-
diff --git a/paludis/dep_list/override_functions.cc b/paludis/dep_list/override_functions.cc
new file mode 100644
index 0000000..739602e
--- /dev/null
+++ b/paludis/dep_list/override_functions.cc
@@ -0,0 +1,428 @@
+/* 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/dep_list/override_functions.hh>
+#include <paludis/util/visitor-impl.hh>
+#include <paludis/util/set.hh>
+#include <paludis/util/stringify.hh>
+#include <paludis/environment.hh>
+#include <paludis/package_id.hh>
+#include <paludis/metadata_key.hh>
+#include <paludis/mask.hh>
+#include <paludis/name.hh>
+
+using namespace paludis;
+
+namespace
+{
+ struct OverrideTildeKeywordsKeyVisitor :
+ ConstVisitor<MetadataKeyVisitorTypes>
+ {
+ const Environment * const env;
+ const PackageID & id;
+ bool result;
+
+ OverrideTildeKeywordsKeyVisitor(const Environment * const e, const PackageID & i) :
+ env(e),
+ id(i),
+ result(false)
+ {
+ }
+
+ void visit(const MetadataPackageIDKey &)
+ {
+ }
+
+ void visit(const MetadataTimeKey &)
+ {
+ }
+
+ void visit(const MetadataContentsKey &)
+ {
+ }
+
+ void visit(const MetadataStringKey &)
+ {
+ }
+
+ void visit(const MetadataSpecTreeKey<RestrictSpecTree> &)
+ {
+ }
+
+ void visit(const MetadataSpecTreeKey<ProvideSpecTree> &)
+ {
+ }
+
+ void visit(const MetadataSpecTreeKey<URISpecTree> &)
+ {
+ }
+
+ void visit(const MetadataSpecTreeKey<LicenseSpecTree> &)
+ {
+ }
+
+ void visit(const MetadataSpecTreeKey<DependencySpecTree> &)
+ {
+ }
+
+ void visit(const MetadataSetKey<InheritedSet> &)
+ {
+ }
+
+ void visit(const MetadataSetKey<KeywordNameSet> & k)
+ {
+ tr1::shared_ptr<KeywordNameSet> kk(new KeywordNameSet);
+ for (KeywordNameSet::Iterator i(k.value()->begin()), i_end(k.value()->end()) ;
+ i != i_end ; ++i)
+ {
+ kk->insert(*i);
+ if ('~' == stringify(*i).at(0))
+ kk->insert(KeywordName(stringify(*i).substr(1)));
+ }
+
+ result |= env->accept_keywords(kk, id);
+ }
+
+ void visit(const MetadataSetKey<IUseFlagSet> &)
+ {
+ }
+
+ void visit(const MetadataSetKey<UseFlagNameSet> &)
+ {
+ }
+ };
+
+ struct OverrideTildeKeywordsMaskVisitor :
+ ConstVisitor<MaskVisitorTypes>
+ {
+ const Environment * const env;
+ const PackageID & id;
+ bool result;
+
+ OverrideTildeKeywordsMaskVisitor(const Environment * const e, const PackageID & i) :
+ env(e),
+ id(i),
+ result(false)
+ {
+ }
+
+ void visit(const UserMask &)
+ {
+ }
+
+ void visit(const UnacceptedMask & m)
+ {
+ OverrideTildeKeywordsKeyVisitor k(env, id);
+ m.unaccepted_key()->accept(k);
+ result |= k.result;
+ }
+
+ void visit(const RepositoryMask &)
+ {
+ }
+
+ void visit(const AssociationMask &)
+ {
+ }
+
+ void visit(const UnsupportedMask &)
+ {
+ }
+ };
+
+ struct OverrideUnkeywordedKeyVisitor :
+ ConstVisitor<MetadataKeyVisitorTypes>
+ {
+ const Environment * const env;
+ const PackageID & id;
+ bool result;
+
+ OverrideUnkeywordedKeyVisitor(const Environment * const e, const PackageID & i) :
+ env(e),
+ id(i),
+ result(false)
+ {
+ }
+
+ void visit(const MetadataPackageIDKey &)
+ {
+ }
+
+ void visit(const MetadataTimeKey &)
+ {
+ }
+
+ void visit(const MetadataContentsKey &)
+ {
+ }
+
+ void visit(const MetadataStringKey &)
+ {
+ }
+
+ void visit(const MetadataSpecTreeKey<RestrictSpecTree> &)
+ {
+ }
+
+ void visit(const MetadataSpecTreeKey<ProvideSpecTree> &)
+ {
+ }
+
+ void visit(const MetadataSpecTreeKey<URISpecTree> &)
+ {
+ }
+
+ void visit(const MetadataSpecTreeKey<LicenseSpecTree> &)
+ {
+ }
+
+ void visit(const MetadataSpecTreeKey<DependencySpecTree> &)
+ {
+ }
+
+ void visit(const MetadataSetKey<InheritedSet> &)
+ {
+ }
+
+ void visit(const MetadataSetKey<KeywordNameSet> & k)
+ {
+ tr1::shared_ptr<KeywordNameSet> kk(new KeywordNameSet);
+ for (KeywordNameSet::Iterator i(k.value()->begin()), i_end(k.value()->end()) ;
+ i != i_end ; ++i)
+ if ('-' == stringify(*i).at(0))
+ kk->insert(KeywordName(stringify(*i).substr(1)));
+
+ result |= ! env->accept_keywords(kk, id);
+ }
+
+ void visit(const MetadataSetKey<IUseFlagSet> &)
+ {
+ }
+
+ void visit(const MetadataSetKey<UseFlagNameSet> &)
+ {
+ }
+ };
+
+ struct OverrideUnkeywordedMaskVisitor :
+ ConstVisitor<MaskVisitorTypes>
+ {
+ const Environment * const env;
+ const PackageID & id;
+ bool result;
+
+ OverrideUnkeywordedMaskVisitor(const Environment * const e, const PackageID & i) :
+ env(e),
+ id(i),
+ result(false)
+ {
+ }
+
+ void visit(const UserMask &)
+ {
+ }
+
+ void visit(const UnacceptedMask & m)
+ {
+ OverrideUnkeywordedKeyVisitor k(env, id);
+ m.unaccepted_key()->accept(k);
+ result |= k.result;
+ }
+
+ void visit(const RepositoryMask &)
+ {
+ }
+
+ void visit(const AssociationMask &)
+ {
+ }
+
+ void visit(const UnsupportedMask &)
+ {
+ }
+ };
+
+ struct OverrideRepositoryMasksVisitor :
+ ConstVisitor<MaskVisitorTypes>
+ {
+ bool result;
+
+ OverrideRepositoryMasksVisitor() :
+ result(false)
+ {
+ }
+
+ void visit(const UserMask &)
+ {
+ }
+
+ void visit(const UnacceptedMask &)
+ {
+ }
+
+ void visit(const RepositoryMask &)
+ {
+ result = true;
+ }
+
+ void visit(const AssociationMask &)
+ {
+ }
+
+ void visit(const UnsupportedMask &)
+ {
+ }
+ };
+
+ struct OverrideLicenseKeyVisitor :
+ ConstVisitor<MetadataKeyVisitorTypes>
+ {
+ bool result;
+
+ OverrideLicenseKeyVisitor() :
+ result(false)
+ {
+ }
+
+ void visit(const MetadataPackageIDKey &)
+ {
+ }
+
+ void visit(const MetadataTimeKey &)
+ {
+ }
+
+ void visit(const MetadataContentsKey &)
+ {
+ }
+
+ void visit(const MetadataStringKey &)
+ {
+ }
+
+ void visit(const MetadataSpecTreeKey<RestrictSpecTree> &)
+ {
+ }
+
+ void visit(const MetadataSpecTreeKey<ProvideSpecTree> &)
+ {
+ }
+
+ void visit(const MetadataSpecTreeKey<URISpecTree> &)
+ {
+ }
+
+ void visit(const MetadataSpecTreeKey<LicenseSpecTree> &)
+ {
+ result = true;
+ }
+
+ void visit(const MetadataSpecTreeKey<DependencySpecTree> &)
+ {
+ }
+
+ void visit(const MetadataSetKey<InheritedSet> &)
+ {
+ }
+
+ void visit(const MetadataSetKey<KeywordNameSet> &)
+ {
+ }
+
+ void visit(const MetadataSetKey<IUseFlagSet> &)
+ {
+ }
+
+ void visit(const MetadataSetKey<UseFlagNameSet> &)
+ {
+ }
+ };
+
+ struct OverrideLicenseVisitor :
+ ConstVisitor<MaskVisitorTypes>
+ {
+ bool result;
+
+ OverrideLicenseVisitor() :
+ result(false)
+ {
+ }
+
+ void visit(const UserMask &)
+ {
+ }
+
+ void visit(const UnacceptedMask & m)
+ {
+ OverrideLicenseKeyVisitor k;
+ m.unaccepted_key()->accept(k);
+ result |= k.result;
+ }
+
+ void visit(const RepositoryMask &)
+ {
+ }
+
+ void visit(const AssociationMask &)
+ {
+ }
+
+ void visit(const UnsupportedMask &)
+ {
+ }
+ };
+}
+
+bool
+paludis::override_tilde_keywords(const Environment * const e, const PackageID & i, const Mask & m)
+{
+ Context c("When working out whether mask is a tilde keyword mask for override:");
+ OverrideTildeKeywordsMaskVisitor k(e, i);
+ m.accept(k);
+ return k.result;
+}
+
+bool
+paludis::override_unkeyworded(const Environment * const e, const PackageID & i, const Mask & m)
+{
+ Context c("When working out whether mask is an unkeyworded mask for override:");
+ OverrideUnkeywordedMaskVisitor k(e, i);
+ m.accept(k);
+ return k.result;
+}
+
+bool
+paludis::override_repository_masks(const Mask & m)
+{
+ Context c("When working out whether mask is a repository mask for override:");
+ OverrideRepositoryMasksVisitor k;
+ m.accept(k);
+ return k.result;
+}
+
+bool
+paludis::override_license(const Mask & m)
+{
+ Context c("When working out whether mask is a license mask for override:");
+ OverrideLicenseVisitor k;
+ m.accept(k);
+ return k.result;
+}
+
+
diff --git a/paludis/dep_list/override_functions.hh b/paludis/dep_list/override_functions.hh
new file mode 100644
index 0000000..a42df3b
--- /dev/null
+++ b/paludis/dep_list/override_functions.hh
@@ -0,0 +1,43 @@
+/* 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_DEP_LIST_OVERRIDE_FUNCTIONS_HH
+#define PALUDIS_GUARD_PALUDIS_DEP_LIST_OVERRIDE_FUNCTIONS_HH 1
+
+#include <paludis/util/attributes.hh>
+#include <paludis/environment-fwd.hh>
+#include <paludis/package_id-fwd.hh>
+#include <paludis/mask-fwd.hh>
+
+namespace paludis
+{
+ bool override_tilde_keywords(const Environment * const e, const PackageID & i, const Mask & m)
+ PALUDIS_ATTRIBUTE((warn_unused_result)) PALUDIS_VISIBLE;
+
+ bool override_unkeyworded(const Environment * const e, const PackageID & i, const Mask & m)
+ PALUDIS_ATTRIBUTE((warn_unused_result)) PALUDIS_VISIBLE;
+
+ bool override_repository_masks(const Mask & m)
+ PALUDIS_ATTRIBUTE((warn_unused_result)) PALUDIS_VISIBLE;
+
+ bool override_license(const Mask & m)
+ PALUDIS_ATTRIBUTE((warn_unused_result)) PALUDIS_VISIBLE;
+}
+
+#endif
diff --git a/paludis/dep_list/show_suggest_visitor.cc b/paludis/dep_list/show_suggest_visitor.cc
index a13fd9e..0bb57e4 100644
--- a/paludis/dep_list/show_suggest_visitor.cc
+++ b/paludis/dep_list/show_suggest_visitor.cc
@@ -120,7 +120,7 @@ ShowSuggestVisitor::visit_leaf(const PackageDepSpec & a)
for (PackageIDSequence::Iterator m(matches->begin()), m_end(matches->end()) ;
m != m_end ; ++m)
{
- if (_imp->environment->mask_reasons(**m).any())
+ if ((*m)->masked())
continue;
_imp->dep_list->add_suggested_package(*m, a, _imp->conditions, _imp->destinations);
diff --git a/paludis/environment.hh b/paludis/environment.hh
index 40fb6e5..913598e 100644
--- a/paludis/environment.hh
+++ b/paludis/environment.hh
@@ -24,12 +24,12 @@
#include <paludis/util/instantiation_policy.hh>
#include <paludis/util/options-fwd.hh>
#include <paludis/util/fs_entry-fwd.hh>
-#include <paludis/mask_reasons.hh>
#include <paludis/name-fwd.hh>
#include <paludis/hook-fwd.hh>
#include <paludis/repository-fwd.hh>
#include <paludis/dep_spec-fwd.hh>
#include <paludis/package_id-fwd.hh>
+#include <paludis/mask-fwd.hh>
/** \file
* Declarations for the Environment class.
@@ -39,7 +39,6 @@
namespace paludis
{
-
/**
* Represents a working environment, which contains an available packages
* database and provides various methods for querying package visibility
@@ -97,30 +96,42 @@ namespace paludis
///\{
/**
- * Return the reasons for a package being masked.
+ * Do we accept a particular license for a particular package?
+ */
+ virtual bool accept_license(const std::string &, const PackageID &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
+
+ /**
+ * Do we accept any of the specified keywords for a particular package?
*
- * \see paludis::query::NotMasked
+ * If the collection includes "*", should return true.
*/
- virtual MaskReasons mask_reasons(const PackageID &,
- const MaskReasonsOptions & = MaskReasonsOptions()) const
+ virtual bool accept_keywords(tr1::shared_ptr<const KeywordNameSet>, const PackageID &) const
PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
/**
- * Do we accept a particular license for a particular package?
+ * Do we have a 'breaks' mask for a particular package?
*
- * Default behaviour: true.
+ * Returns a zero pointer if no.
*/
- virtual bool accept_license(const std::string &, const PackageID &) const
+ virtual const tr1::shared_ptr<const Mask> mask_for_breakage(const PackageID &) const
PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
/**
- * Do we accept any of the specified keywords for a particular package?
+ * Do we have a 'user' mask for a particular package?
*
- * If the collection includes "*", should return true.
+ * Returns a zero pointer if no.
+ */
+ virtual const tr1::shared_ptr<const Mask> mask_for_user(const PackageID &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
+
+ /**
+ * Do we have a user unmask for a particular package?
*
- * Default behaviour: true if the collection includes "*".
+ * This is only applied to repository and profile style masks, not
+ * keywords, licences etc. If true, user_mask shouldn't be used.
*/
- virtual bool accept_keywords(tr1::shared_ptr<const KeywordNameSet>, const PackageID &) const
+ virtual bool unmasked_by_user(const PackageID &) const
PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
///\}
diff --git a/paludis/environment_implementation.cc b/paludis/environment_implementation.cc
index 8d4eeba..9e0fbc9 100644
--- a/paludis/environment_implementation.cc
+++ b/paludis/environment_implementation.cc
@@ -34,122 +34,11 @@
using namespace paludis;
-namespace
-{
- struct LicenceChecker :
- ConstVisitor<LicenseSpecTree>,
- ConstVisitor<LicenseSpecTree>::VisitConstSequence<LicenceChecker, AllDepSpec>
- {
- using ConstVisitor<LicenseSpecTree>::VisitConstSequence<LicenceChecker, AllDepSpec>::visit_sequence;
-
- bool ok;
- const EnvironmentImplementation * const env;
- bool (EnvironmentImplementation::* const func) (const std::string &, const PackageID &) const;
- const PackageID * const id;
-
- LicenceChecker(const EnvironmentImplementation * const e,
- bool (EnvironmentImplementation::* const f) (const std::string &, const PackageID &) const,
- const PackageID * const d) :
- ok(true),
- env(e),
- func(f),
- id(d)
- {
- }
-
- void visit_sequence(const AnyDepSpec &,
- LicenseSpecTree::ConstSequenceIterator begin,
- LicenseSpecTree::ConstSequenceIterator end)
- {
- bool local_ok(false);
-
- if (begin == end)
- local_ok = true;
- else
- {
- for ( ; begin != end ; ++begin)
- {
- Save<bool> save_ok(&ok, true);
- begin->accept(*this);
- local_ok |= ok;
- }
- }
-
- ok &= local_ok;
- }
-
- void visit_sequence(const UseDepSpec & spec,
- LicenseSpecTree::ConstSequenceIterator begin,
- LicenseSpecTree::ConstSequenceIterator end)
- {
- if (env->query_use(spec.flag(), *id))
- std::for_each(begin, end, accept_visitor(*this));
- }
-
- void visit_leaf(const PlainTextDepSpec & spec)
- {
- if (! (env->*func)(spec.text(), *id))
- ok = false;
- }
- };
-}
-
-bool
-EnvironmentImplementation::accept_eapi(const PackageID & e) const
-{
- return e.eapi()->supported;
-}
-
-bool
-EnvironmentImplementation::accept_keywords(tr1::shared_ptr<const KeywordNameSet> k,
- const PackageID &) const
-{
- return k->end() != k->find(KeywordName("*"));
-}
-
-bool
-EnvironmentImplementation::accept_license(const std::string &, const PackageID &) const
-{
- return true;
-}
-
-bool
-EnvironmentImplementation::accept_breaks_portage(const PackageID &) const
-{
- return true;
-}
-
-bool
-EnvironmentImplementation::masked_by_user(const PackageID &) const
-{
- return false;
-}
-
-bool
-EnvironmentImplementation::unmasked_by_user(const PackageID &) const
-{
- return false;
-}
-
-bool
-EnvironmentImplementation::breaks_portage(const PackageID & e) const
-{
- return (e.version().has_try_part() || e.version().has_scm_part()
- || (! e.eapi()->supported) || (e.eapi()->supported->breaks_portage));
-}
-
EnvironmentImplementation::~EnvironmentImplementation()
{
}
-tr1::shared_ptr<const UseFlagNameSet>
-EnvironmentImplementation::known_use_expand_names(const UseFlagName &, const PackageID &) const
-{
- static tr1::shared_ptr<const UseFlagNameSet> result(new UseFlagNameSet);
- return result;
-}
-
tr1::shared_ptr<const FSEntrySequence>
EnvironmentImplementation::bashrc_files() const
{
@@ -175,51 +64,6 @@ EnvironmentImplementation::fetchers_dirs() const
return result;
}
-tr1::shared_ptr<const FSEntrySequence>
-EnvironmentImplementation::hook_dirs() const
-{
- static tr1::shared_ptr<const FSEntrySequence> result(new FSEntrySequence);
- 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();
-}
-
-tr1::shared_ptr<const MirrorsSequence>
-EnvironmentImplementation::mirrors(const std::string &) const
-{
- static tr1::shared_ptr<const MirrorsSequence> result(new MirrorsSequence);
- return result;
-}
-
-tr1::shared_ptr<const SetNameSet>
-EnvironmentImplementation::set_names() const
-{
- static tr1::shared_ptr<const SetNameSet> result(new SetNameSet);
- return result;
-}
-
-HookResult
-EnvironmentImplementation::perform_hook(const Hook &) const
-{
- return HookResult(0, "");
-}
-
tr1::shared_ptr<const DestinationsSet>
EnvironmentImplementation::default_destinations() const
{
@@ -235,94 +79,6 @@ EnvironmentImplementation::default_destinations() const
return result;
}
-MaskReasons
-EnvironmentImplementation::mask_reasons(const PackageID & e, const MaskReasonsOptions & options) const
-{
- Context context("When checking for mask reasons for '" + stringify(e) + "':");
-
- MaskReasons result;
-
- if (! accept_eapi(e))
- {
- result += mr_eapi;
- return result;
- }
-
- if (breaks_portage(e) && ! accept_breaks_portage(e))
- result += mr_breaks_portage;
-
- if (e.virtual_for_key())
- {
- result |= mask_reasons(*e.virtual_for_key()->value());
- if (result.any())
- result += mr_by_association;
- }
-
- if (e.keywords_key())
- {
- tr1::shared_ptr<const KeywordNameSet> keywords(e.keywords_key()->value());
- if (! accept_keywords(keywords, e))
- {
- do
- {
- if (options[mro_override_unkeyworded])
- {
- tr1::shared_ptr<KeywordNameSet> minus_keywords(new KeywordNameSet);
- for (KeywordNameSet::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])
- {
- tr1::shared_ptr<KeywordNameSet> detildeified_keywords(new KeywordNameSet);
- for (KeywordNameSet::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 (e.license_key())
- {
- LicenceChecker lc(this, &EnvironmentImplementation::accept_license, &e);
- e.license_key()->value()->accept(lc);
- if (! lc.ok)
- result += mr_license;
- }
-
- if (! unmasked_by_user(e))
- {
- if (masked_by_user(e))
- result += mr_user_mask;
-
- if (e.repository()->mask_interface)
- {
- if (e.repository()->mask_interface->query_profile_masks(e))
- result += mr_profile_mask;
-
- if (e.repository()->mask_interface->query_repository_masks(e))
- result += mr_repository_mask;
- }
- }
-
- return result;
-}
-
tr1::shared_ptr<SetSpecTree::ConstItem>
EnvironmentImplementation::set(const SetName & s) const
{
@@ -402,15 +158,23 @@ EnvironmentImplementation::query_use(const UseFlagName & f, const PackageID & e)
return false;
}
-tr1::shared_ptr<SetSpecTree::ConstItem>
-EnvironmentImplementation::local_set(const SetName &) const
-{
- return tr1::shared_ptr<SetSpecTree::ConstItem>();
-}
-
std::string
EnvironmentImplementation::default_distribution() const
{
return DEFAULT_DISTRIBUTION;
}
+tr1::shared_ptr<const SetNameSet>
+EnvironmentImplementation::set_names() const
+{
+ static tr1::shared_ptr<const SetNameSet> result(new SetNameSet);
+ return result;
+}
+
+bool
+EnvironmentImplementation::breaks_portage(const PackageID & e) const
+{
+ return (e.version().has_try_part() || e.version().has_scm_part()
+ || (! e.eapi()->supported) || (e.eapi()->supported->breaks_portage));
+}
+
diff --git a/paludis/environment_implementation.hh b/paludis/environment_implementation.hh
index f7159a7..8d9e249 100644
--- a/paludis/environment_implementation.hh
+++ b/paludis/environment_implementation.hh
@@ -36,57 +36,13 @@ namespace paludis
public Environment
{
protected:
- ///\name Mask reasons
-
- /**
- * Do we accept a particular EAPI?
- *
- * Default behaviour: recognised EAPIs accepted.
- */
- virtual bool accept_eapi(const PackageID &) 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 PackageID &) const
- PALUDIS_ATTRIBUTE((warn_unused_result));
-
- /**
- * Is a package masked by user settings?
- *
- * Default behaviour: false.
- */
- virtual bool masked_by_user(const PackageID &) const
- PALUDIS_ATTRIBUTE((warn_unused_result));
- /**
- * Is a package unmasked by user settings?
- *
- * Default behaviour: false.
- */
- virtual bool unmasked_by_user(const PackageID &) const
- PALUDIS_ATTRIBUTE((warn_unused_result));
+ virtual tr1::shared_ptr<SetSpecTree::ConstItem> local_set(const SetName &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
- /**
- * Does a package break Portage?
- */
virtual bool breaks_portage(const PackageID &) 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 tr1::shared_ptr<SetSpecTree::ConstItem> local_set(const SetName &) const
- PALUDIS_ATTRIBUTE((warn_unused_result));
-
public:
///\name Basic operations
///\{
@@ -98,20 +54,6 @@ namespace paludis
virtual bool query_use(const UseFlagName &, const PackageID &) const
PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual tr1::shared_ptr<const UseFlagNameSet> known_use_expand_names(
- const UseFlagName &, const PackageID &) const
- PALUDIS_ATTRIBUTE((warn_unused_result));
-
- virtual MaskReasons mask_reasons(const PackageID &,
- const MaskReasonsOptions & = MaskReasonsOptions()) const
- PALUDIS_ATTRIBUTE((warn_unused_result));
-
- virtual bool accept_license(const std::string &, const PackageID &) const
- PALUDIS_ATTRIBUTE((warn_unused_result));
-
- virtual bool accept_keywords(tr1::shared_ptr<const KeywordNameSet>, const PackageID &) const
- PALUDIS_ATTRIBUTE((warn_unused_result));
-
virtual tr1::shared_ptr<const FSEntrySequence> bashrc_files() const
PALUDIS_ATTRIBUTE((warn_unused_result));
@@ -121,21 +63,6 @@ namespace paludis
virtual tr1::shared_ptr<const FSEntrySequence> fetchers_dirs() const
PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual tr1::shared_ptr<const FSEntrySequence> 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 tr1::shared_ptr<const MirrorsSequence> mirrors(const std::string &) const
- PALUDIS_ATTRIBUTE((warn_unused_result));
-
virtual tr1::shared_ptr<const SetNameSet> set_names() const
PALUDIS_ATTRIBUTE((warn_unused_result));
@@ -145,11 +72,9 @@ namespace paludis
virtual tr1::shared_ptr<const DestinationsSet> default_destinations() const
PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual HookResult perform_hook(const Hook &) const
- PALUDIS_ATTRIBUTE((warn_unused_result));
-
virtual std::string default_distribution() const
PALUDIS_ATTRIBUTE((warn_unused_result));
+
};
}
diff --git a/paludis/environment_implementation_TEST.cc b/paludis/environment_implementation_TEST.cc
deleted file mode 100644
index ab25619..0000000
--- a/paludis/environment_implementation_TEST.cc
+++ /dev/null
@@ -1,154 +0,0 @@
-/* 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 <paludis/repositories/fake/fake_package_id.hh>
-#include <paludis/package_id.hh>
-#include <paludis/name.hh>
-#include <paludis/util/set.hh>
-#include <paludis/util/sequence.hh>
-#include <paludis/util/tr1_functional.hh>
-#include <paludis/util/tr1_memory.hh>
-#include <libwrapiter/libwrapiter_forward_iterator.hh>
-#include <libwrapiter/libwrapiter_output_iterator.hh>
-#include <test/test_framework.hh>
-#include <test/test_runner.hh>
-
-using namespace paludis;
-using namespace test;
-
-namespace
-{
- class EITestEnvironment :
- public EnvironmentImplementation
- {
- private:
- tr1::shared_ptr<PackageDatabase> _package_database;
-
- public:
- EITestEnvironment() :
- _package_database(new PackageDatabase(this))
- {
- tr1::shared_ptr<FakeRepository> repo(new FakeRepository(this, RepositoryName("repo")));
- _package_database->add_repository(1, tr1::shared_ptr<Repository>(repo));
-
- repo->add_version("foo", "one", "0")->keywords_key()->set_from_string("test foo");
- repo->add_version("foo", "two", "0")->keywords_key()->set_from_string("~test foo");
- repo->add_version("foo", "three", "0")->keywords_key()->set_from_string("-test foo");
- repo->add_version("foo", "four", "0")->keywords_key()->set_from_string("-* foo");
- }
-
- ~EITestEnvironment()
- {
- }
-
- tr1::shared_ptr<PackageDatabase> package_database()
- {
- return _package_database;
- }
-
- 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(tr1::shared_ptr<const KeywordNameSet> k, const PackageID &) const
- {
- return k->end() != k->find(KeywordName("test")) || k->end() != k->find(KeywordName("*"));
- }
-
- const tr1::shared_ptr<const PackageID> fetch_package_id(const QualifiedPackageName & q,
- const VersionSpec & v, const RepositoryName & r) const
- {
- using namespace tr1::placeholders;
-
- tr1::shared_ptr<const PackageIDSequence> ids(package_database()->fetch_repository(r)->package_ids(q));
- PackageIDSequence::Iterator i(std::find_if(ids->begin(), ids->end(),
- tr1::bind(std::equal_to<VersionSpec>(), tr1::bind(tr1::mem_fn(&PackageID::version), _1), v)));
- if (i == ids->end())
- throw NoSuchPackageError(stringify(q) + "-" + stringify(v) + "::" + stringify(r));
- return *i;
- }
- };
-}
-
-namespace test_cases
-{
- struct MaskReasonsTest : TestCase
- {
- MaskReasonsTest() : TestCase("mask reasons") { }
-
- void run()
- {
- EITestEnvironment env;
-
- MaskReasons m1(env.mask_reasons(*env.fetch_package_id(
- QualifiedPackageName("foo/one"), VersionSpec("0"), RepositoryName("repo"))));
- TEST_CHECK(! m1[mr_keyword]);
-
- MaskReasons m2(env.mask_reasons(*env.fetch_package_id(
- QualifiedPackageName("foo/two"), VersionSpec("0"), RepositoryName("repo"))));
- TEST_CHECK(m2[mr_keyword]);
- m2 = env.mask_reasons(*env.fetch_package_id(
- QualifiedPackageName("foo/two"), VersionSpec("0"), RepositoryName("repo")),
- MaskReasonsOptions() + mro_override_tilde_keywords);
- TEST_CHECK(! m2[mr_keyword]);
- m2 = env.mask_reasons(*env.fetch_package_id(
- QualifiedPackageName("foo/two"), VersionSpec("0"), RepositoryName("repo")),
- MaskReasonsOptions() + mro_override_unkeyworded);
- TEST_CHECK(! m2[mr_keyword]);
-
- MaskReasons m3(env.mask_reasons(*env.fetch_package_id(
- QualifiedPackageName("foo/three"), VersionSpec("0"), RepositoryName("repo"))));
- TEST_CHECK(m3[mr_keyword]);
- m3 = env.mask_reasons(*env.fetch_package_id(
- QualifiedPackageName("foo/three"), VersionSpec("0"), RepositoryName("repo")),
- MaskReasonsOptions() + mro_override_tilde_keywords);
- TEST_CHECK(m3[mr_keyword]);
- m3 = env.mask_reasons(*env.fetch_package_id(
- QualifiedPackageName("foo/three"), VersionSpec("0"), RepositoryName("repo")),
- MaskReasonsOptions() + mro_override_unkeyworded);
- TEST_CHECK(m3[mr_keyword]);
-
- MaskReasons m4(env.mask_reasons(*env.fetch_package_id(
- QualifiedPackageName("foo/four"), VersionSpec("0"), RepositoryName("repo"))));
- TEST_CHECK(m4[mr_keyword]);
- m4 = env.mask_reasons(*env.fetch_package_id(
- QualifiedPackageName("foo/four"), VersionSpec("0"), RepositoryName("repo")),
- MaskReasonsOptions() + mro_override_tilde_keywords);
- TEST_CHECK(m4[mr_keyword]);
- m4 = env.mask_reasons(*env.fetch_package_id(
- 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/adapted_environment.cc b/paludis/environments/adapted/adapted_environment.cc
index 5c02e51..ec7b0dd 100644
--- a/paludis/environments/adapted/adapted_environment.cc
+++ b/paludis/environments/adapted/adapted_environment.cc
@@ -112,12 +112,6 @@ AdaptedEnvironment::known_use_expand_names(const UseFlagName & u, const PackageI
return _imp->env->known_use_expand_names(u, e);
}
-MaskReasons
-AdaptedEnvironment::mask_reasons(const PackageID & e, const MaskReasonsOptions & r) const
-{
- return _imp->env->mask_reasons(e, r);
-}
-
bool
AdaptedEnvironment::accept_license(const std::string & l, const PackageID & e) const
{
@@ -220,3 +214,21 @@ AdaptedEnvironment::default_distribution() const
return _imp->env->default_distribution();
}
+const tr1::shared_ptr<const Mask>
+AdaptedEnvironment::mask_for_breakage(const PackageID & id) const
+{
+ return _imp->env->mask_for_breakage(id);
+}
+
+const tr1::shared_ptr<const Mask>
+AdaptedEnvironment::mask_for_user(const PackageID & id) const
+{
+ return _imp->env->mask_for_user(id);
+}
+
+bool
+AdaptedEnvironment::unmasked_by_user(const PackageID & id) const
+{
+ return _imp->env->unmasked_by_user(id);
+}
+
diff --git a/paludis/environments/adapted/adapted_environment.hh b/paludis/environments/adapted/adapted_environment.hh
index 7c912e5..833e39e 100644
--- a/paludis/environments/adapted/adapted_environment.hh
+++ b/paludis/environments/adapted/adapted_environment.hh
@@ -21,6 +21,7 @@
#define PALUDIS_GUARD_PALUDIS_ENVIRONMENTS_ADAPTED_ADAPTED_ENVIRONMENT_HH 1
#include <paludis/environment.hh>
+#include <paludis/util/private_implementation_pattern.hh>
namespace paludis
{
@@ -64,10 +65,6 @@ namespace paludis
const UseFlagName &, const PackageID &) const
PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual MaskReasons mask_reasons(const PackageID &,
- const MaskReasonsOptions & = MaskReasonsOptions()) const
- PALUDIS_ATTRIBUTE((warn_unused_result));
-
virtual bool accept_license(const std::string &, const PackageID &) const
PALUDIS_ATTRIBUTE((warn_unused_result));
@@ -119,6 +116,15 @@ namespace paludis
virtual std::string default_distribution() const
PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual const tr1::shared_ptr<const Mask> mask_for_breakage(const PackageID &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual const tr1::shared_ptr<const Mask> mask_for_user(const PackageID &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual bool unmasked_by_user(const PackageID &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
};
}
diff --git a/paludis/environments/no_config/no_config_environment.cc b/paludis/environments/no_config/no_config_environment.cc
index b65f7a3..ba5aafd 100644
--- a/paludis/environments/no_config/no_config_environment.cc
+++ b/paludis/environments/no_config/no_config_environment.cc
@@ -23,12 +23,15 @@
#include <paludis/util/dir_iterator.hh>
#include <paludis/util/map.hh>
#include <paludis/util/set.hh>
+#include <paludis/util/sequence.hh>
+#include <paludis/util/make_shared_ptr.hh>
#include <paludis/repositories/repository_maker.hh>
#include <paludis/util/private_implementation_pattern-impl.hh>
#include <paludis/config_file.hh>
#include <paludis/distribution.hh>
#include <paludis/package_database.hh>
#include <paludis/eapi.hh>
+#include <paludis/hook.hh>
#include <paludis/repositories/e/e_repository_params.hh>
#include <libwrapiter/libwrapiter_forward_iterator.hh>
#include <libwrapiter/libwrapiter_output_iterator.hh>
@@ -330,3 +333,75 @@ NoConfigEnvironment::accept_keywords(tr1::shared_ptr<const KeywordNameSet> keywo
return false;
}
+tr1::shared_ptr<SetSpecTree::ConstItem>
+NoConfigEnvironment::local_set(const SetName &) const
+{
+ return tr1::shared_ptr<SetSpecTree::ConstItem>();
+}
+
+bool
+NoConfigEnvironment::unmasked_by_user(const PackageID &) const
+{
+ return false;
+}
+
+const tr1::shared_ptr<const Mask>
+NoConfigEnvironment::mask_for_breakage(const PackageID &) const
+{
+ return tr1::shared_ptr<const Mask>();
+}
+
+const tr1::shared_ptr<const Mask>
+NoConfigEnvironment::mask_for_user(const PackageID &) const
+{
+ return tr1::shared_ptr<const Mask>();
+}
+
+uid_t
+NoConfigEnvironment::reduced_uid() const
+{
+ return getuid();
+}
+
+gid_t
+NoConfigEnvironment::reduced_gid() const
+{
+ return getgid();
+}
+
+tr1::shared_ptr<const MirrorsSequence>
+NoConfigEnvironment::mirrors(const std::string &) const
+{
+ return make_shared_ptr(new MirrorsSequence);
+}
+
+bool
+NoConfigEnvironment::accept_license(const std::string &, const PackageID &) const
+{
+ return true;
+}
+
+const FSEntry
+NoConfigEnvironment::root() const
+{
+ return FSEntry("/");
+}
+
+HookResult
+NoConfigEnvironment::perform_hook(const Hook &) const
+{
+ return HookResult(0, "");
+}
+
+tr1::shared_ptr<const FSEntrySequence>
+NoConfigEnvironment::hook_dirs() const
+{
+ return make_shared_ptr(new FSEntrySequence);
+}
+
+tr1::shared_ptr<const UseFlagNameSet>
+NoConfigEnvironment::known_use_expand_names(const UseFlagName &, const PackageID &) const
+{
+ return make_shared_ptr(new UseFlagNameSet);
+}
+
diff --git a/paludis/environments/no_config/no_config_environment.hh b/paludis/environments/no_config/no_config_environment.hh
index 868f0c8..eee39ea 100644
--- a/paludis/environments/no_config/no_config_environment.hh
+++ b/paludis/environments/no_config/no_config_environment.hh
@@ -58,7 +58,8 @@ namespace paludis
private InstantiationPolicy<NoConfigEnvironment, instantiation_method::NonCopyableTag>
{
protected:
- virtual bool accept_keywords(tr1::shared_ptr<const KeywordNameSet>, const PackageID &) const
+
+ virtual tr1::shared_ptr<SetSpecTree::ConstItem> local_set(const SetName &) const
PALUDIS_ATTRIBUTE((warn_unused_result));
public:
@@ -121,6 +122,40 @@ namespace paludis
PALUDIS_ATTRIBUTE((warn_unused_result));
virtual void set_paludis_command(const std::string &);
+
+ virtual tr1::shared_ptr<const UseFlagNameSet> known_use_expand_names(
+ const UseFlagName &, const PackageID &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual bool accept_license(const std::string &, const PackageID &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual bool accept_keywords(tr1::shared_ptr<const KeywordNameSet>, const PackageID &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual const tr1::shared_ptr<const Mask> mask_for_breakage(const PackageID &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual const tr1::shared_ptr<const Mask> mask_for_user(const PackageID &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual bool unmasked_by_user(const PackageID &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual tr1::shared_ptr<const FSEntrySequence> hook_dirs() const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual const FSEntry root() const;
+
+ virtual uid_t reduced_uid() const;
+
+ virtual gid_t reduced_gid() const;
+
+ virtual tr1::shared_ptr<const MirrorsSequence> mirrors(const std::string &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual HookResult perform_hook(const Hook &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
};
}
diff --git a/paludis/environments/paludis/paludis_environment.cc b/paludis/environments/paludis/paludis_environment.cc
index 67f9314..d560f5e 100644
--- a/paludis/environments/paludis/paludis_environment.cc
+++ b/paludis/environments/paludis/paludis_environment.cc
@@ -34,12 +34,14 @@
#include <paludis/distribution.hh>
#include <paludis/dep_tag.hh>
#include <paludis/package_id.hh>
+#include <paludis/mask.hh>
#include <paludis/util/log.hh>
#include <paludis/util/system.hh>
#include <paludis/util/dir_iterator.hh>
#include <paludis/util/private_implementation_pattern-impl.hh>
#include <paludis/util/is_file_with_extension.hh>
+#include <paludis/util/make_shared_ptr.hh>
#include <paludis/util/save.hh>
#include <paludis/util/strip.hh>
#include <paludis/util/tr1_functional.hh>
@@ -220,12 +222,6 @@ PaludisEnvironment::query_use(const UseFlagName & f, const PackageID & e) const
}
bool
-PaludisEnvironment::accept_breaks_portage(const PackageID &) const
-{
- return _imp->config->accept_breaks_portage();
-}
-
-bool
PaludisEnvironment::accept_keywords(tr1::shared_ptr<const KeywordNameSet> k,
const PackageID & e) const
{
@@ -246,12 +242,6 @@ PaludisEnvironment::accept_license(const std::string & license, const PackageID
}
bool
-PaludisEnvironment::masked_by_user(const PackageID & d) const
-{
- return _imp->config->package_mask_conf()->query(d);
-}
-
-bool
PaludisEnvironment::unmasked_by_user(const PackageID & d) const
{
return _imp->config->package_unmask_conf()->query(d);
@@ -446,3 +436,57 @@ PaludisEnvironment::default_distribution() const
return _imp->config->distribution();
}
+namespace
+{
+ class BreaksPortageMask :
+ public UnsupportedMask
+ {
+ const char key() const
+ {
+ return 'B';
+ }
+
+ const std::string description() const
+ {
+ return "breaks Portage";
+ }
+
+ const std::string explanation() const
+ {
+ return "";
+ }
+ };
+
+ class UserConfigMask :
+ public UserMask
+ {
+ const char key() const
+ {
+ return 'U';
+ }
+
+ const std::string description() const
+ {
+ return "user";
+ }
+ };
+}
+
+const tr1::shared_ptr<const Mask>
+PaludisEnvironment::mask_for_breakage(const PackageID & id) const
+{
+ if ((! _imp->config->accept_breaks_portage()) && breaks_portage(id))
+ return make_shared_ptr(new BreaksPortageMask);
+
+ return tr1::shared_ptr<const Mask>();
+}
+
+const tr1::shared_ptr<const Mask>
+PaludisEnvironment::mask_for_user(const PackageID & d) const
+{
+ if (_imp->config->package_mask_conf()->query(d))
+ return make_shared_ptr(new UserConfigMask);
+
+ return tr1::shared_ptr<const Mask>();
+}
+
diff --git a/paludis/environments/paludis/paludis_environment.hh b/paludis/environments/paludis/paludis_environment.hh
index 6850acb..2f1f880 100644
--- a/paludis/environments/paludis/paludis_environment.hh
+++ b/paludis/environments/paludis/paludis_environment.hh
@@ -50,20 +50,6 @@ namespace paludis
private PrivateImplementationPattern<PaludisEnvironment>
{
protected:
- virtual bool accept_keywords(tr1::shared_ptr<const KeywordNameSet>, const PackageID &) const
- PALUDIS_ATTRIBUTE((warn_unused_result));
-
- virtual bool accept_license(const std::string &, const PackageID &) const
- PALUDIS_ATTRIBUTE((warn_unused_result));
-
- virtual bool accept_breaks_portage(const PackageID &) const
- PALUDIS_ATTRIBUTE((warn_unused_result));
-
- virtual bool masked_by_user(const PackageID &) const
- PALUDIS_ATTRIBUTE((warn_unused_result));
-
- virtual bool unmasked_by_user(const PackageID &) const
- PALUDIS_ATTRIBUTE((warn_unused_result));
virtual tr1::shared_ptr<SetSpecTree::ConstItem> local_set(const SetName & id) const;
@@ -137,6 +123,21 @@ namespace paludis
virtual std::string default_distribution() const
PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual bool accept_keywords(tr1::shared_ptr<const KeywordNameSet>, const PackageID &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual bool accept_license(const std::string &, const PackageID &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual const tr1::shared_ptr<const Mask> mask_for_breakage(const PackageID &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual const tr1::shared_ptr<const Mask> mask_for_user(const PackageID &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual bool unmasked_by_user(const PackageID &) 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 615f611..911cd06 100644
--- a/paludis/environments/paludis/paludis_environment_TEST.cc
+++ b/paludis/environments/paludis/paludis_environment_TEST.cc
@@ -158,7 +158,6 @@ namespace test_cases
void run()
{
-#if 0
setenv("PALUDIS_HOME", stringify(FSEntry::cwd() / "paludis_environment_TEST_dir" / "home4").c_str(), 1);
unsetenv("PALUDIS_SKIP_CONFIG");
@@ -175,7 +174,6 @@ namespace test_cases
TEST_CHECK(env->package_database()->more_important_than(RepositoryName("fourth"), RepositoryName("third")));
TEST_CHECK(env->package_database()->more_important_than(RepositoryName("fourth"), RepositoryName("fifth")));
TEST_CHECK(env->package_database()->more_important_than(RepositoryName("second"), RepositoryName("fifth")));
-#endif
}
} paludis_environment_repositories;
}
diff --git a/paludis/environments/portage/portage_environment.cc b/paludis/environments/portage/portage_environment.cc
index 165e86c..9f8c2b6 100644
--- a/paludis/environments/portage/portage_environment.cc
+++ b/paludis/environments/portage/portage_environment.cc
@@ -29,10 +29,13 @@
#include <paludis/util/set.hh>
#include <paludis/util/sequence.hh>
#include <paludis/util/map.hh>
+#include <paludis/util/options.hh>
+#include <paludis/util/make_shared_ptr.hh>
#include <paludis/repositories/repository_maker.hh>
#include <paludis/config_file.hh>
#include <paludis/hooker.hh>
#include <paludis/hook.hh>
+#include <paludis/mask.hh>
#include <paludis/match_package.hh>
#include <paludis/package_database.hh>
#include <paludis/package_id.hh>
@@ -549,17 +552,6 @@ PortageEnvironment::root() const
}
bool
-PortageEnvironment::masked_by_user(const PackageID & e) const
-{
- for (PackageMask::const_iterator i(_imp->package_mask.begin()), i_end(_imp->package_mask.end()) ;
- i != i_end ; ++i)
- if (match_package(*this, **i, e))
- return true;
-
- return false;
-}
-
-bool
PortageEnvironment::unmasked_by_user(const PackageID & e) const
{
for (PackageUnmask::const_iterator i(_imp->package_unmask.begin()), i_end(_imp->package_unmask.end()) ;
@@ -637,12 +629,6 @@ PortageEnvironment::bashrc_files() const
return result;
}
-bool
-PortageEnvironment::accept_breaks_portage(const PackageID &) const
-{
- return false;
-}
-
tr1::shared_ptr<PackageDatabase>
PortageEnvironment::package_database()
{
@@ -666,3 +652,83 @@ PortageEnvironment::mirrors(const std::string & m) const
return result;
}
+tr1::shared_ptr<SetSpecTree::ConstItem>
+PortageEnvironment::local_set(const SetName &) const
+{
+ return tr1::shared_ptr<SetSpecTree::ConstItem>();
+}
+
+bool
+PortageEnvironment::accept_license(const std::string &, const PackageID &) const
+{
+ return true;
+}
+
+namespace
+{
+ class BreaksPortageMask :
+ public UnsupportedMask
+ {
+ const char key() const
+ {
+ return 'B';
+ }
+
+ const std::string description() const
+ {
+ return "breaks Portage";
+ }
+
+ const std::string explanation() const
+ {
+ return "";
+ }
+ };
+
+ class UserConfigMask :
+ public UserMask
+ {
+ const char key() const
+ {
+ return 'U';
+ }
+
+ const std::string description() const
+ {
+ return "user";
+ }
+ };
+}
+
+const tr1::shared_ptr<const Mask>
+PortageEnvironment::mask_for_breakage(const PackageID & id) const
+{
+ if (breaks_portage(id))
+ return make_shared_ptr(new BreaksPortageMask);
+
+ return tr1::shared_ptr<const Mask>();
+}
+
+const tr1::shared_ptr<const Mask>
+PortageEnvironment::mask_for_user(const PackageID & d) const
+{
+ for (PackageMask::const_iterator i(_imp->package_mask.begin()), i_end(_imp->package_mask.end()) ;
+ i != i_end ; ++i)
+ if (match_package(*this, **i, d))
+ return make_shared_ptr(new UserConfigMask);
+
+ return tr1::shared_ptr<const Mask>();
+}
+
+gid_t
+PortageEnvironment::reduced_gid() const
+{
+ return getgid();
+}
+
+uid_t
+PortageEnvironment::reduced_uid() const
+{
+ return getuid();
+}
+
diff --git a/paludis/environments/portage/portage_environment.hh b/paludis/environments/portage/portage_environment.hh
index a747815..8d51599 100644
--- a/paludis/environments/portage/portage_environment.hh
+++ b/paludis/environments/portage/portage_environment.hh
@@ -22,6 +22,7 @@
#include <paludis/environment_implementation.hh>
#include <paludis/util/exception.hh>
+#include <paludis/util/private_implementation_pattern.hh>
namespace paludis
{
@@ -74,16 +75,7 @@ namespace paludis
void _load_atom_file(const FSEntry &, I_, const std::string &);
protected:
- virtual bool accept_keywords(tr1::shared_ptr<const KeywordNameSet>, const PackageID &) const
- PALUDIS_ATTRIBUTE((warn_unused_result));
-
- virtual bool accept_breaks_portage(const PackageID &) const
- PALUDIS_ATTRIBUTE((warn_unused_result));
-
- virtual bool masked_by_user(const PackageID &) const
- PALUDIS_ATTRIBUTE((warn_unused_result));
-
- virtual bool unmasked_by_user(const PackageID &) const
+ virtual tr1::shared_ptr<SetSpecTree::ConstItem> local_set(const SetName &) const
PALUDIS_ATTRIBUTE((warn_unused_result));
public:
@@ -127,6 +119,25 @@ namespace paludis
PALUDIS_ATTRIBUTE((warn_unused_result));
virtual void set_paludis_command(const std::string &);
+
+ virtual bool accept_license(const std::string &, const PackageID &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual bool accept_keywords(tr1::shared_ptr<const KeywordNameSet>, const PackageID &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual const tr1::shared_ptr<const Mask> mask_for_breakage(const PackageID &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual const tr1::shared_ptr<const Mask> mask_for_user(const PackageID &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual bool unmasked_by_user(const PackageID &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual uid_t reduced_uid() const;
+
+ virtual gid_t reduced_gid() const;
};
}
diff --git a/paludis/environments/test/test_environment.cc b/paludis/environments/test/test_environment.cc
index 4adc7ab..3e51e15 100644
--- a/paludis/environments/test/test_environment.cc
+++ b/paludis/environments/test/test_environment.cc
@@ -22,8 +22,10 @@
#include <paludis/util/tr1_functional.hh>
#include <paludis/util/set.hh>
#include <paludis/util/sequence.hh>
+#include <paludis/util/make_shared_ptr.hh>
#include <paludis/package_database.hh>
#include <paludis/package_id.hh>
+#include <paludis/hook.hh>
#include <libwrapiter/libwrapiter_forward_iterator.hh>
#include <libwrapiter/libwrapiter_output_iterator.hh>
#include <string>
@@ -67,6 +69,12 @@ TestEnvironment::accept_keywords(tr1::shared_ptr<const KeywordNameSet> k, const
return k->end() != k->find(KeywordName("test")) || k->end() != k->find(KeywordName("*"));
}
+bool
+TestEnvironment::accept_license(const std::string &, const PackageID &) const
+{
+ return true;
+}
+
tr1::shared_ptr<PackageDatabase>
TestEnvironment::package_database()
{
@@ -105,3 +113,69 @@ TestEnvironment::fetch_package_id(const QualifiedPackageName & q,
return *i;
}
+tr1::shared_ptr<SetSpecTree::ConstItem>
+TestEnvironment::local_set(const SetName &) const
+{
+ return tr1::shared_ptr<SetSpecTree::ConstItem>();
+}
+
+uid_t
+TestEnvironment::reduced_uid() const
+{
+ return getuid();
+}
+
+gid_t
+TestEnvironment::reduced_gid() const
+{
+ return getgid();
+}
+
+const FSEntry
+TestEnvironment::root() const
+{
+ return FSEntry("/");
+}
+
+tr1::shared_ptr<const MirrorsSequence>
+TestEnvironment::mirrors(const std::string &) const
+{
+ return make_shared_ptr(new MirrorsSequence);
+}
+
+HookResult
+TestEnvironment::perform_hook(const Hook &) const
+{
+ return HookResult(0, "");
+}
+
+tr1::shared_ptr<const FSEntrySequence>
+TestEnvironment::hook_dirs() const
+{
+ return make_shared_ptr(new FSEntrySequence);
+}
+
+const tr1::shared_ptr<const Mask>
+TestEnvironment::mask_for_breakage(const PackageID &) const
+{
+ return tr1::shared_ptr<const Mask>();
+}
+
+const tr1::shared_ptr<const Mask>
+TestEnvironment::mask_for_user(const PackageID &) const
+{
+ return tr1::shared_ptr<const Mask>();
+}
+
+bool
+TestEnvironment::unmasked_by_user(const PackageID &) const
+{
+ return false;
+}
+
+tr1::shared_ptr<const UseFlagNameSet>
+TestEnvironment::known_use_expand_names(const UseFlagName &, const PackageID &) const
+{
+ return make_shared_ptr(new UseFlagNameSet);
+}
+
diff --git a/paludis/environments/test/test_environment.hh b/paludis/environments/test/test_environment.hh
index 989a986..af6e31d 100644
--- a/paludis/environments/test/test_environment.hh
+++ b/paludis/environments/test/test_environment.hh
@@ -44,7 +44,7 @@ namespace paludis
public EnvironmentImplementation
{
protected:
- virtual bool accept_keywords(tr1::shared_ptr<const KeywordNameSet>, const PackageID &) const
+ virtual tr1::shared_ptr<SetSpecTree::ConstItem> local_set(const SetName &) const
PALUDIS_ATTRIBUTE((warn_unused_result));
public:
@@ -76,6 +76,40 @@ namespace paludis
*/
const tr1::shared_ptr<const PackageID> fetch_package_id(const QualifiedPackageName &,
const VersionSpec &, const RepositoryName &) const PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual tr1::shared_ptr<const UseFlagNameSet> known_use_expand_names(
+ const UseFlagName &, const PackageID &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual bool accept_license(const std::string &, const PackageID &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual bool accept_keywords(tr1::shared_ptr<const KeywordNameSet>, const PackageID &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual const tr1::shared_ptr<const Mask> mask_for_breakage(const PackageID &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual const tr1::shared_ptr<const Mask> mask_for_user(const PackageID &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual bool unmasked_by_user(const PackageID &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual tr1::shared_ptr<const FSEntrySequence> hook_dirs() const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual const FSEntry root() const;
+
+ virtual uid_t reduced_uid() const;
+
+ virtual gid_t reduced_gid() const;
+
+ virtual tr1::shared_ptr<const MirrorsSequence> mirrors(const std::string &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual HookResult perform_hook(const Hook &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
};
}
diff --git a/paludis/files.m4 b/paludis/files.m4
index eb54a05..4ef1b88 100644
--- a/paludis/files.m4
+++ b/paludis/files.m4
@@ -19,12 +19,12 @@ add(`dep_tag', `hh', `cc', `fwd', `sr')
add(`distribution', `hh', `cc', `fwd', `sr')
add(`eapi', `hh', `cc', `fwd', `sr')
add(`environment', `hh', `fwd', `cc', `se')
-add(`environment_implementation', `hh', `cc', `test')
+add(`environment_implementation', `hh', `cc')
add(`hashed_containers', `hh', `cc', `test')
add(`hook', `hh', `cc', `fwd',`se', `sr')
add(`hooker', `hh', `cc', `test', `testscript')
add(`host_tuple_name', `hh', `cc', `sr', `test')
-add(`mask_reasons', `hh', `cc', `se')
+add(`mask', `hh', `cc', `fwd')
add(`match_package', `hh', `cc')
add(`metadata_key', `hh', `cc', `se', `fwd')
add(`name', `hh', `cc', `fwd', `test', `sr', `se')
diff --git a/paludis/mask_reasons.cc b/paludis/mask-fwd.hh
index 8b36d90..d3ba1e5 100644
--- a/paludis/mask_reasons.cc
+++ b/paludis/mask-fwd.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2006, 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
+ * 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
@@ -17,13 +17,21 @@
* Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#ifndef PALUDIS_GUARD_PALUDIS_MASK_FWD_HH
+#define PALUDIS_GUARD_PALUDIS_MASK_FWD_HH 1
-#include <paludis/mask_reasons.hh>
-#include <paludis/util/stringify.hh>
-#include <paludis/util/exception.hh>
-#include <ostream>
+#include <paludis/util/visitor-fwd.hh>
-using namespace paludis;
+namespace paludis
+{
+ class Mask;
+ class UserMask;
+ class UnacceptedMask;
+ class RepositoryMask;
+ class UnsupportedMask;
+ class AssociationMask;
-#include <paludis/mask_reasons-se.cc>
+ class MaskVisitorTypes;
+}
+#endif
diff --git a/paludis/mask_reasons.hh b/paludis/mask_reasons.hh
deleted file mode 100644
index d5aa2f3..0000000
--- a/paludis/mask_reasons.hh
+++ /dev/null
@@ -1,45 +0,0 @@
-/* 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
- */
-
-#ifndef PALUDIS_GUARD_PALUDIS_MASK_REASONS_HH
-#define PALUDIS_GUARD_PALUDIS_MASK_REASONS_HH 1
-
-#include <paludis/util/options.hh>
-#include <iosfwd>
-
-/** \file
- * Declarations for MaskReasons and related classes.
- *
- * \ingroup grpmaskreasons
- */
-
-namespace paludis
-{
-
-#include <paludis/mask_reasons-se.hh>
-
- /**
- * A collection of reasons for why a package is masked.
- *
- * \ingroup grpmaskreasons
- */
- typedef Options<MaskReason> MaskReasons;
-}
-
-#endif
diff --git a/paludis/mask_reasons.se b/paludis/mask_reasons.se
deleted file mode 100644
index 4af4070..0000000
--- a/paludis/mask_reasons.se
+++ /dev/null
@@ -1,27 +0,0 @@
-#!/bin/bash
-# vim: set sw=4 sts=4 et ft=sh :
-
-make_enum_MaskReason()
-{
- prefix mr
-
- key mr_keyword "no keyword match"
- key mr_user_mask "user package.mask"
- key mr_profile_mask "profile package.mask"
- key mr_repository_mask "repository package.mask"
- key mr_eapi "unknown eapi"
- key mr_by_association "masked by association with another package (for virtuals)"
- key mr_chost "masked by chost"
- key mr_breaks_portage "masked because it will break portage"
- key mr_license "unaccepted license"
-
- doxygen_comment << "END"
- /**
- * Each value represents one reason for a package being masked.
- *
- * \see MaskReasons
- * \ingroup grpmaskreasons
- */
-END
-}
-
diff --git a/paludis/package_id.cc b/paludis/package_id.cc
index 37ba514..183aedb 100644
--- a/paludis/package_id.cc
+++ b/paludis/package_id.cc
@@ -51,6 +51,7 @@ namespace paludis
struct Implementation<PackageID>
{
mutable std::list<tr1::shared_ptr<const MetadataKey> > keys;
+ mutable std::list<tr1::shared_ptr<const Mask> > masks;
};
}
@@ -67,6 +68,7 @@ void
PackageID::add_metadata_key(const tr1::shared_ptr<const MetadataKey> & k) const
{
using namespace tr1::placeholders;
+
if (_imp->keys.end() != std::find_if(_imp->keys.begin(), _imp->keys.end(),
tr1::bind(std::equal_to<std::string>(), k->raw_name(), tr1::bind(tr1::mem_fn(&MetadataKey::raw_name), _1))))
throw ConfigurationError("Tried to add duplicate key '" + k->raw_name() + "' to ID '" + stringify(*this) + "'");
@@ -88,6 +90,32 @@ PackageID::end_metadata() const
return MetadataIterator(indirect_iterator(_imp->keys.end()));
}
+void
+PackageID::add_mask(const tr1::shared_ptr<const Mask> & k) const
+{
+ _imp->masks.push_back(k);
+}
+
+PackageID::MasksIterator
+PackageID::begin_masks() const
+{
+ need_masks_added();
+ return MasksIterator(indirect_iterator(_imp->masks.begin()));
+}
+
+PackageID::MasksIterator
+PackageID::end_masks() const
+{
+ need_masks_added();
+ return MasksIterator(indirect_iterator(_imp->masks.end()));
+}
+
+bool
+PackageID::masked() const
+{
+ return begin_masks() != end_masks();
+}
+
PackageID::MetadataIterator
PackageID::find_metadata(const std::string & s) const
{
diff --git a/paludis/package_id.hh b/paludis/package_id.hh
index 2f9a95b..a40ff2b 100644
--- a/paludis/package_id.hh
+++ b/paludis/package_id.hh
@@ -21,18 +21,21 @@
#define PALUDIS_GUARD_PALUDIS_PACKAGE_ID_HH 1
#include <paludis/package_id-fwd.hh>
-#include <paludis/metadata_key-fwd.hh>
-#include <paludis/action-fwd.hh>
+
#include <paludis/util/attributes.hh>
-#include <paludis/util/private_implementation_pattern.hh>
#include <paludis/util/instantiation_policy.hh>
-#include <paludis/util/tr1_memory.hh>
#include <paludis/util/operators.hh>
-#include <paludis/name-fwd.hh>
-#include <paludis/version_spec-fwd.hh>
+#include <paludis/util/private_implementation_pattern.hh>
+#include <paludis/util/tr1_memory.hh>
+
+#include <paludis/action-fwd.hh>
#include <paludis/dep_spec-fwd.hh>
#include <paludis/eapi-fwd.hh>
+#include <paludis/mask-fwd.hh>
+#include <paludis/metadata_key-fwd.hh>
+#include <paludis/name-fwd.hh>
#include <paludis/repository-fwd.hh>
+#include <paludis/version_spec-fwd.hh>
namespace paludis
{
@@ -45,7 +48,10 @@ namespace paludis
{
protected:
virtual void add_metadata_key(const tr1::shared_ptr<const MetadataKey> &) const;
+ virtual void add_mask(const tr1::shared_ptr<const Mask> &) const;
+
virtual void need_keys_added() const = 0;
+ virtual void need_masks_added() const = 0;
public:
PackageID();
@@ -104,6 +110,16 @@ namespace paludis
///\}
+ ///\name Masks
+ ///\{
+
+ typedef libwrapiter::ForwardIterator<PackageID, const Mask> MasksIterator;
+ MasksIterator begin_masks() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ MasksIterator end_masks() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ bool masked() const PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ ///\}
+
///\name Extra comparisons
///\{
diff --git a/paludis/query.cc b/paludis/query.cc
index 326b6e6..999727d 100644
--- a/paludis/query.cc
+++ b/paludis/query.cc
@@ -251,7 +251,7 @@ namespace
tr1::shared_ptr<const PackageIDSequence> i(repo->package_ids(*p));
for (PackageIDSequence::Iterator v(i->begin()), v_end(i->end()) ;
v != v_end ; ++v)
- if (! e.mask_reasons(**v).any())
+ if (! ((*v)->masked()))
result->push_back(*v);
}
}
diff --git a/paludis/repositories/e/Makefile.am b/paludis/repositories/e/Makefile.am
index fb4313a..3063367 100644
--- a/paludis/repositories/e/Makefile.am
+++ b/paludis/repositories/e/Makefile.am
@@ -31,73 +31,75 @@ paludis_repositories_e_includedir = $(includedir)/paludis-$(PALUDIS_PC_SLOT)/pal
libpaludiserepository_la_LDFLAGS = -version-info @VERSION_LIB_CURRENT@:@VERSION_LIB_REVISION@:0
paludis_repositories_e_include_HEADERS = \
- ebuild.hh \
- ebuild-sr.hh \
- ebin.hh \
- ebin-se.hh \
- ebin-sr.hh \
- glsa.hh \
- glsa-sr.hh \
+ e_key.hh \
+ e_mask.hh \
e_repository.hh \
- e_repository_profile_file.hh \
- e_repository_profile.hh \
+ e_repository_entries.hh \
e_repository_exceptions.hh \
e_repository_news.hh \
- e_repository_params.hh \
e_repository_params-sr.hh \
+ e_repository_params.hh \
+ e_repository_profile.hh \
+ e_repository_profile_file.hh \
e_repository_sets.hh \
- e_repository_entries.hh \
- ebuild_entries.hh \
+ eapi_phase.hh \
+ ebin-se.hh \
+ ebin-sr.hh \
+ ebin.hh \
ebin_entries.hh \
+ ebuild-sr.hh \
+ ebuild.hh \
+ ebuild_entries.hh \
ebuild_flat_metadata_cache.hh \
+ ebuild_id.hh \
eclass_mtimes.hh \
- make_ebuild_repository.hh \
+ exheres_layout.hh \
+ glsa-sr.hh \
+ glsa.hh \
+ layout.hh \
make_ebin_repository.hh \
+ make_ebuild_repository.hh \
+ traditional_layout.hh \
use_desc.hh \
- vdb_repository.hh \
- vdb_repository-sr.hh \
+ vdb_id.hh \
vdb_merger-sr.hh \
vdb_merger.hh \
+ vdb_repository-sr.hh \
+ vdb_repository.hh \
vdb_unmerger-sr.hh \
- vdb_unmerger.hh \
- layout.hh \
- traditional_layout.hh \
- exheres_layout.hh \
- eapi_phase.hh \
- ebuild_id.hh \
- vdb_id.hh \
- e_key.hh
+ vdb_unmerger.hh
libpaludiserepository_la_SOURCES = \
- ebuild.cc \
- ebin.cc \
- glsa.cc \
+ e_key.cc \
+ e_mask.cc \
e_repository.cc \
- e_repository_profile_file.cc \
- e_repository_profile.cc \
+ e_repository_entries.cc \
e_repository_exceptions.cc \
e_repository_news.cc \
+ e_repository_params.cc \
+ e_repository_profile.cc \
+ e_repository_profile_file.cc \
e_repository_sets.cc \
- e_repository_entries.cc \
- ebuild_entries.cc \
+ eapi_phase.cc \
+ ebin.cc \
ebin_entries.cc \
+ ebuild.cc \
+ ebuild_entries.cc \
ebuild_flat_metadata_cache.cc \
+ ebuild_id.cc \
eclass_mtimes.cc \
- e_repository_params.cc \
- make_ebuild_repository.cc \
+ exheres_layout.cc \
+ glsa.cc \
+ layout.cc \
make_ebin_repository.cc \
- use_desc.cc \
+ make_ebuild_repository.cc \
registration.cc \
- vdb_repository.cc \
- vdb_merger.cc \
- vdb_unmerger.cc \
- layout.cc \
traditional_layout.cc \
- exheres_layout.cc \
- eapi_phase.cc \
- ebuild_id.cc \
+ use_desc.cc \
vdb_id.cc \
- e_key.cc \
+ vdb_merger.cc \
+ vdb_repository.cc \
+ vdb_unmerger.cc \
$(paludis_repositories_e_include_HEADERS)
if ENABLE_QA
diff --git a/paludis/repositories/e/e_mask.cc b/paludis/repositories/e/e_mask.cc
new file mode 100644
index 0000000..16fcd14
--- /dev/null
+++ b/paludis/repositories/e/e_mask.cc
@@ -0,0 +1,154 @@
+/* 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/repositories/e/e_mask.hh>
+#include <paludis/util/private_implementation_pattern-impl.hh>
+
+using namespace paludis;
+using namespace paludis::erepository;
+
+namespace paludis
+{
+ template <>
+ struct Implementation<EUnacceptedMask>
+ {
+ const char key;
+ const std::string description;
+ const tr1::shared_ptr<const MetadataKey> unaccepted_key;
+
+ Implementation(const char k, const std::string & d, const tr1::shared_ptr<const MetadataKey> & u) :
+ key(k),
+ description(d),
+ unaccepted_key(u)
+ {
+ }
+ };
+}
+
+EUnacceptedMask::EUnacceptedMask(const char k, const std::string & d, const tr1::shared_ptr<const MetadataKey> & u) :
+ PrivateImplementationPattern<EUnacceptedMask>(new Implementation<EUnacceptedMask>(k, d, u))
+{
+}
+
+EUnacceptedMask::~EUnacceptedMask()
+{
+}
+
+const char
+EUnacceptedMask::key() const
+{
+ return _imp->key;
+}
+
+const std::string
+EUnacceptedMask::description() const
+{
+ return _imp->description;
+}
+
+const tr1::shared_ptr<const MetadataKey>
+EUnacceptedMask::unaccepted_key() const
+{
+ return _imp->unaccepted_key;
+}
+
+namespace paludis
+{
+ template <>
+ struct Implementation<EUnsupportedMask>
+ {
+ const char key;
+ const std::string description;
+ const std::string eapi_name;
+
+ Implementation(const char k, const std::string & d, const std::string & n) :
+ key(k),
+ description(d),
+ eapi_name(n)
+ {
+ }
+ };
+}
+
+EUnsupportedMask::EUnsupportedMask(const char k, const std::string & d, const std::string & n) :
+ PrivateImplementationPattern<EUnsupportedMask>(new Implementation<EUnsupportedMask>(k, d, n))
+{
+}
+
+EUnsupportedMask::~EUnsupportedMask()
+{
+}
+
+const char
+EUnsupportedMask::key() const
+{
+ return _imp->key;
+}
+
+const std::string
+EUnsupportedMask::description() const
+{
+ return _imp->description;
+}
+
+const std::string
+EUnsupportedMask::explanation() const
+{
+ if (_imp->eapi_name == "UNKNOWN")
+ return "Unsupported EAPI 'UNKNOWN' (likely a broken package or configuration error)";
+ return "Unsupported EAPI '" + _imp->eapi_name + "'";
+}
+
+namespace paludis
+{
+ template <>
+ struct Implementation<ERepositoryMask>
+ {
+ const char key;
+ const std::string description;
+
+ Implementation(const char k, const std::string & d) :
+ key(k),
+ description(d)
+ {
+ }
+ };
+}
+
+ERepositoryMask::ERepositoryMask(const char k, const std::string & d) :
+ PrivateImplementationPattern<ERepositoryMask>(new Implementation<ERepositoryMask>(k, d))
+{
+}
+
+ERepositoryMask::~ERepositoryMask()
+{
+}
+
+const char
+ERepositoryMask::key() const
+{
+ return _imp->key;
+}
+
+const std::string
+ERepositoryMask::description() const
+{
+ return _imp->description;
+}
+
diff --git a/paludis/repositories/e/e_mask.hh b/paludis/repositories/e/e_mask.hh
new file mode 100644
index 0000000..23bad5e
--- /dev/null
+++ b/paludis/repositories/e/e_mask.hh
@@ -0,0 +1,70 @@
+/* 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_REPOSITORIES_E_E_MASK_HH
+#define PALUDIS_GUARD_PALUDIS_REPOSITORIES_E_E_MASK_HH 1
+
+#include <paludis/mask.hh>
+#include <paludis/util/private_implementation_pattern.hh>
+
+namespace paludis
+{
+ namespace erepository
+ {
+ class EUnacceptedMask :
+ public UnacceptedMask,
+ private PrivateImplementationPattern<EUnacceptedMask>
+ {
+ public:
+ EUnacceptedMask(const char, const std::string &, const tr1::shared_ptr<const MetadataKey> &);
+ ~EUnacceptedMask();
+
+ const char key() const;
+ const std::string description() const;
+ const tr1::shared_ptr<const MetadataKey> unaccepted_key() const;
+ };
+
+ class EUnsupportedMask :
+ public UnsupportedMask,
+ private PrivateImplementationPattern<EUnsupportedMask>
+ {
+ public:
+ EUnsupportedMask(const char, const std::string &, const std::string &);
+ ~EUnsupportedMask();
+
+ virtual const char key() const;
+ virtual const std::string description() const;
+ virtual const std::string explanation() const;
+ };
+
+ class ERepositoryMask :
+ public RepositoryMask,
+ private PrivateImplementationPattern<ERepositoryMask>
+ {
+ public:
+ ERepositoryMask(const char, const std::string &);
+ ~ERepositoryMask();
+
+ const char key() const;
+ const std::string description() const;
+ };
+ }
+}
+
+#endif
diff --git a/paludis/repositories/e/e_repository.cc b/paludis/repositories/e/e_repository.cc
index 0b5dc7f..9aa3eb0 100644
--- a/paludis/repositories/e/e_repository.cc
+++ b/paludis/repositories/e/e_repository.cc
@@ -51,6 +51,7 @@
#include <paludis/util/iterator.hh>
#include <paludis/util/log.hh>
#include <paludis/util/random.hh>
+#include <paludis/util/options.hh>
#include <paludis/util/make_shared_ptr.hh>
#include <paludis/util/stringify.hh>
#include <paludis/util/tokeniser.hh>
@@ -250,7 +251,6 @@ namespace
ERepository::ERepository(const ERepositoryParams & p) :
Repository(fetch_repo_name(p.location),
RepositoryCapabilities::create()
- .mask_interface(this)
.installed_interface(0)
.sets_interface(this)
.syncable_interface(this)
@@ -341,7 +341,7 @@ ERepository::do_package_ids(const QualifiedPackageName & n) const
}
bool
-ERepository::do_query_repository_masks(const PackageID & id) const
+ERepository::repository_masked(const PackageID & id) const
{
if (! _imp->has_repo_mask)
{
@@ -394,13 +394,6 @@ ERepository::do_query_repository_masks(const PackageID & id) const
return false;
}
-bool
-ERepository::do_query_profile_masks(const PackageID & id) const
-{
- _imp->need_profiles();
- return _imp->profile_ptr->profile_masked(id);
-}
-
UseFlagState
ERepository::do_query_use(const UseFlagName & f, const PackageID & e) const
{
diff --git a/paludis/repositories/e/e_repository.hh b/paludis/repositories/e/e_repository.hh
index ed8b9ab..393ad78 100644
--- a/paludis/repositories/e/e_repository.hh
+++ b/paludis/repositories/e/e_repository.hh
@@ -50,7 +50,6 @@ namespace paludis
*/
class PALUDIS_VISIBLE ERepository :
public Repository,
- public RepositoryMaskInterface,
public RepositoryUseInterface,
public RepositorySyncableInterface,
public RepositorySetsInterface,
@@ -84,14 +83,6 @@ namespace paludis
virtual bool do_sync() const;
- /* RepositoryMaskInterface */
-
- virtual bool do_query_repository_masks(const PackageID &) const
- PALUDIS_ATTRIBUTE((warn_unused_result));
-
- virtual bool do_query_profile_masks(const PackageID &) const
- PALUDIS_ATTRIBUTE((warn_unused_result));
-
/* RepositoryUseInterface */
virtual UseFlagState do_query_use(const UseFlagName &, const PackageID &) const
@@ -232,6 +223,8 @@ namespace paludis
const tr1::shared_ptr<const ERepositoryEntries> entries() const;
const tr1::shared_ptr<const ERepositoryProfile> profile() const;
+ bool repository_masked(const PackageID &) const;
+
void regenerate_cache() const;
};
}
diff --git a/paludis/repositories/e/e_repository_TEST.cc b/paludis/repositories/e/e_repository_TEST.cc
index 62bf3ae..42f3e29 100644
--- a/paludis/repositories/e/e_repository_TEST.cc
+++ b/paludis/repositories/e/e_repository_TEST.cc
@@ -652,12 +652,12 @@ namespace test_cases
{
TestMessageSuffix pass_suffix(stringify(pass), true);
- TEST_CHECK(repo->query_profile_masks(**env.package_database()->query(query::Matches(PackageDepSpec(
- "=cat/masked-0", pds_pm_unspecific)), qo_require_exactly_one)->begin()));
- TEST_CHECK(! repo->query_profile_masks(**env.package_database()->query(query::Matches(PackageDepSpec(
- "=cat/not_masked-0", pds_pm_unspecific)), qo_require_exactly_one)->begin()));
- TEST_CHECK(! repo->query_profile_masks(**env.package_database()->query(query::Matches(PackageDepSpec(
- "=cat/was_masked-0", pds_pm_unspecific)), qo_require_exactly_one)->begin()));
+ TEST_CHECK((*env.package_database()->query(query::Matches(PackageDepSpec("=cat/masked-0", pds_pm_unspecific)),
+ qo_require_exactly_one)->begin())->masked());
+ TEST_CHECK((*env.package_database()->query(query::Matches(PackageDepSpec("=cat/was_masked-0", pds_pm_unspecific)),
+ qo_require_exactly_one)->begin())->masked());
+ TEST_CHECK((*env.package_database()->query(query::Matches(PackageDepSpec("=cat/not_masked-0", pds_pm_unspecific)),
+ qo_require_exactly_one)->begin())->masked());
}
}
} test_e_repository_query_profile_masks;
diff --git a/paludis/repositories/e/e_repository_news.cc b/paludis/repositories/e/e_repository_news.cc
index 5009d3e..ab09ecb 100644
--- a/paludis/repositories/e/e_repository_news.cc
+++ b/paludis/repositories/e/e_repository_news.cc
@@ -28,6 +28,7 @@
#include <paludis/util/strip.hh>
#include <paludis/util/private_implementation_pattern-impl.hh>
#include <paludis/util/sequence.hh>
+#include <paludis/util/options.hh>
#include <paludis/query.hh>
#include <libwrapiter/libwrapiter_forward_iterator.hh>
diff --git a/paludis/repositories/e/e_repository_profile.cc b/paludis/repositories/e/e_repository_profile.cc
index 17ed4b0..c971809 100644
--- a/paludis/repositories/e/e_repository_profile.cc
+++ b/paludis/repositories/e/e_repository_profile.cc
@@ -30,6 +30,7 @@
#include <paludis/util/join.hh>
#include <paludis/util/sequence.hh>
#include <paludis/util/set.hh>
+#include <paludis/util/options.hh>
#include <paludis/config_file.hh>
#include <paludis/dep_tag.hh>
#include <paludis/eapi.hh>
diff --git a/paludis/repositories/e/ebuild.cc b/paludis/repositories/e/ebuild.cc
index 2dbb6bc..bc72d57 100644
--- a/paludis/repositories/e/ebuild.cc
+++ b/paludis/repositories/e/ebuild.cc
@@ -26,6 +26,7 @@
#include <paludis/util/pstream.hh>
#include <paludis/util/log.hh>
#include <paludis/util/sequence.hh>
+#include <paludis/util/options.hh>
#include <paludis/util/map.hh>
#include <paludis/about.hh>
diff --git a/paludis/repositories/e/ebuild_id.cc b/paludis/repositories/e/ebuild_id.cc
index 74ee632..be089f8 100644
--- a/paludis/repositories/e/ebuild_id.cc
+++ b/paludis/repositories/e/ebuild_id.cc
@@ -24,6 +24,7 @@
#include <paludis/repositories/e/e_repository_entries.hh>
#include <paludis/repositories/e/eapi_phase.hh>
#include <paludis/repositories/e/e_key.hh>
+#include <paludis/repositories/e/e_mask.hh>
#include <paludis/name.hh>
#include <paludis/version_spec.hh>
@@ -39,6 +40,8 @@
#include <paludis/util/private_implementation_pattern-impl.hh>
#include <paludis/util/idle_action_pool.hh>
#include <paludis/util/visitor-impl.hh>
+#include <paludis/util/make_shared_ptr.hh>
+#include <paludis/util/save.hh>
#include <libwrapiter/libwrapiter_forward_iterator.hh>
@@ -77,6 +80,7 @@ namespace paludis
const time_t master_mtime;
const tr1::shared_ptr<const EclassMtimes> eclass_mtimes;
mutable bool has_keys;
+ mutable bool has_masks;
mutable tr1::shared_ptr<const EStringKey> short_description;
mutable tr1::shared_ptr<const EDependenciesKey> build_dependencies;
@@ -103,7 +107,8 @@ namespace paludis
guessed_eapi(g),
master_mtime(t),
eclass_mtimes(m),
- has_keys(false)
+ has_keys(false),
+ has_masks(false)
{
}
};
@@ -249,6 +254,116 @@ EbuildID::need_keys_added() const
}
}
+namespace
+{
+ struct LicenceChecker :
+ ConstVisitor<LicenseSpecTree>,
+ ConstVisitor<LicenseSpecTree>::VisitConstSequence<LicenceChecker, AllDepSpec>
+ {
+ using ConstVisitor<LicenseSpecTree>::VisitConstSequence<LicenceChecker, AllDepSpec>::visit_sequence;
+
+ bool ok;
+ const Environment * const env;
+ bool (Environment::* const func) (const std::string &, const PackageID &) const;
+ const PackageID * const id;
+
+ LicenceChecker(const Environment * const e,
+ bool (Environment::* const f) (const std::string &, const PackageID &) const,
+ const PackageID * const d) :
+ ok(true),
+ env(e),
+ func(f),
+ id(d)
+ {
+ }
+
+ void visit_sequence(const AnyDepSpec &,
+ LicenseSpecTree::ConstSequenceIterator begin,
+ LicenseSpecTree::ConstSequenceIterator end)
+ {
+ bool local_ok(false);
+
+ if (begin == end)
+ local_ok = true;
+ else
+ {
+ for ( ; begin != end ; ++begin)
+ {
+ Save<bool> save_ok(&ok, true);
+ begin->accept(*this);
+ local_ok |= ok;
+ }
+ }
+
+ ok &= local_ok;
+ }
+
+ void visit_sequence(const UseDepSpec & spec,
+ LicenseSpecTree::ConstSequenceIterator begin,
+ LicenseSpecTree::ConstSequenceIterator end)
+ {
+ if (env->query_use(spec.flag(), *id))
+ std::for_each(begin, end, accept_visitor(*this));
+ }
+
+ void visit_leaf(const PlainTextDepSpec & spec)
+ {
+ if (! (env->*func)(spec.text(), *id))
+ ok = false;
+ }
+ };
+}
+
+void
+EbuildID::need_masks_added() const
+{
+ if (_imp->has_masks)
+ return;
+
+ _imp->has_masks = true;
+
+ Context context("When generating masks for ID '" + canonical_form(idcf_full) + "':");
+
+ if (! eapi()->supported)
+ {
+ add_mask(make_shared_ptr(new EUnsupportedMask('E', "eapi", eapi()->name)));
+ return;
+ }
+
+ if (keywords_key())
+ if (! _imp->environment->accept_keywords(keywords_key()->value(), *this))
+ add_mask(make_shared_ptr(new EUnacceptedMask('K', "keywords", keywords_key())));
+
+ if (license_key())
+ {
+ LicenceChecker c(_imp->environment, &Environment::accept_license, this);
+ license_key()->value()->accept(c);
+ if (! c.ok)
+ add_mask(make_shared_ptr(new EUnacceptedMask('L', "license", license_key())));
+ }
+
+ if (! _imp->environment->unmasked_by_user(*this))
+ {
+ /* repo unless user */
+ if (tr1::static_pointer_cast<const ERepository>(repository())->repository_masked(*this))
+ add_mask(make_shared_ptr(new ERepositoryMask('R', "repository")));
+
+ /* profile unless user */
+ if (tr1::static_pointer_cast<const ERepository>(repository())->profile()->profile_masked(*this))
+ add_mask(make_shared_ptr(new ERepositoryMask('P', "profile")));
+
+ /* user */
+ tr1::shared_ptr<const Mask> user_mask(_imp->environment->mask_for_user(*this));
+ if (user_mask)
+ add_mask(user_mask);
+ }
+
+ /* break portage */
+ tr1::shared_ptr<const Mask> breaks_mask(_imp->environment->mask_for_breakage(*this));
+ if (breaks_mask)
+ add_mask(breaks_mask);
+}
+
const std::string
EbuildID::canonical_form(const PackageIDCanonicalForm f) const
{
diff --git a/paludis/repositories/e/ebuild_id.hh b/paludis/repositories/e/ebuild_id.hh
index cafe338..f54a8f2 100644
--- a/paludis/repositories/e/ebuild_id.hh
+++ b/paludis/repositories/e/ebuild_id.hh
@@ -42,6 +42,7 @@ namespace paludis
protected:
virtual void need_keys_added() const;
+ virtual void need_masks_added() const;
public:
EbuildID(const QualifiedPackageName &, const VersionSpec &,
diff --git a/paludis/repositories/e/vdb_id.cc b/paludis/repositories/e/vdb_id.cc
index e199d85..097b497 100644
--- a/paludis/repositories/e/vdb_id.cc
+++ b/paludis/repositories/e/vdb_id.cc
@@ -321,6 +321,11 @@ VDBID::need_keys_added() const
}
}
+void
+VDBID::need_masks_added() const
+{
+}
+
const std::string
VDBID::canonical_form(const PackageIDCanonicalForm f) const
{
diff --git a/paludis/repositories/e/vdb_id.hh b/paludis/repositories/e/vdb_id.hh
index a0c46b6..52a6a63 100644
--- a/paludis/repositories/e/vdb_id.hh
+++ b/paludis/repositories/e/vdb_id.hh
@@ -39,6 +39,7 @@ namespace paludis
protected:
virtual void need_keys_added() const;
+ virtual void need_masks_added() const;
public:
VDBID(const QualifiedPackageName &, const VersionSpec &,
diff --git a/paludis/repositories/e/vdb_repository.cc b/paludis/repositories/e/vdb_repository.cc
index b7837da..3fdc07f 100644
--- a/paludis/repositories/e/vdb_repository.cc
+++ b/paludis/repositories/e/vdb_repository.cc
@@ -127,7 +127,6 @@ VDBRepository::VDBRepository(const VDBRepositoryParams & p) :
Repository(RepositoryName("installed"),
RepositoryCapabilities::create()
.installed_interface(this)
- .mask_interface(0)
.sets_interface(this)
.syncable_interface(0)
.use_interface(this)
diff --git a/paludis/repositories/fake/fake_installed_repository.cc b/paludis/repositories/fake/fake_installed_repository.cc
index 6b8ec69..52df82e 100644
--- a/paludis/repositories/fake/fake_installed_repository.cc
+++ b/paludis/repositories/fake/fake_installed_repository.cc
@@ -38,7 +38,6 @@ using namespace paludis;
FakeInstalledRepository::FakeInstalledRepository(const Environment * const e, const RepositoryName & our_name) :
FakeRepositoryBase(e, our_name, RepositoryCapabilities::create()
.installed_interface(this)
- .mask_interface(this)
.sets_interface(this)
.syncable_interface(0)
.use_interface(this)
diff --git a/paludis/repositories/fake/fake_package_id.cc b/paludis/repositories/fake/fake_package_id.cc
index 3547e7e..303fd2b 100644
--- a/paludis/repositories/fake/fake_package_id.cc
+++ b/paludis/repositories/fake/fake_package_id.cc
@@ -22,6 +22,7 @@
#include <paludis/eapi.hh>
#include <paludis/name.hh>
#include <paludis/action.hh>
+#include <paludis/environment.hh>
#include <paludis/version_spec.hh>
#include <paludis/portage_dep_parser.hh>
#include <paludis/hashed_containers.hh>
@@ -30,7 +31,9 @@
#include <paludis/util/tokeniser.hh>
#include <paludis/util/iterator.hh>
#include <paludis/util/set.hh>
+#include <paludis/util/save.hh>
#include <paludis/util/visitor-impl.hh>
+#include <paludis/util/make_shared_ptr.hh>
#include <libwrapiter/libwrapiter_output_iterator.hh>
#include <libwrapiter/libwrapiter_forward_iterator.hh>
@@ -177,11 +180,104 @@ FakeMetadataPackageIDKey::value() const
namespace paludis
{
+ template <>
+ struct Implementation<FakeUnacceptedMask>
+ {
+ const char key;
+ const std::string description;
+ const tr1::shared_ptr<const MetadataKey> unaccepted_key;
+
+ Implementation(const char k, const std::string & d, const tr1::shared_ptr<const MetadataKey> & u) :
+ key(k),
+ description(d),
+ unaccepted_key(u)
+ {
+ }
+ };
+}
+
+FakeUnacceptedMask::FakeUnacceptedMask(const char c, const std::string & s, const tr1::shared_ptr<const MetadataKey> & k) :
+ PrivateImplementationPattern<FakeUnacceptedMask>(new Implementation<FakeUnacceptedMask>(c, s, k))
+{
+}
+
+FakeUnacceptedMask::~FakeUnacceptedMask()
+{
+}
+
+const char
+FakeUnacceptedMask::key() const
+{
+ return _imp->key;
+}
+
+const std::string
+FakeUnacceptedMask::description() const
+{
+ return _imp->description;
+}
+
+const tr1::shared_ptr<const MetadataKey>
+FakeUnacceptedMask::unaccepted_key() const
+{
+ return _imp->unaccepted_key;
+}
+
+namespace paludis
+{
+ template <>
+ struct Implementation<FakeUnsupportedMask>
+ {
+ const char key;
+ const std::string description;
+ const std::string eapi_name;
+
+ Implementation(const char k, const std::string & d, const std::string & n) :
+ key(k),
+ description(d),
+ eapi_name(n)
+ {
+ }
+ };
+}
+
+FakeUnsupportedMask::FakeUnsupportedMask(const char c, const std::string & s, const std::string & n) :
+ PrivateImplementationPattern<FakeUnsupportedMask>(new Implementation<FakeUnsupportedMask>(c, s, n))
+{
+}
+
+FakeUnsupportedMask::~FakeUnsupportedMask()
+{
+}
+
+const char
+FakeUnsupportedMask::key() const
+{
+ return _imp->key;
+}
+
+const std::string
+FakeUnsupportedMask::description() const
+{
+ return _imp->description;
+}
+
+const std::string
+FakeUnsupportedMask::explanation() const
+{
+ if (_imp->eapi_name == "UNKNOWN")
+ return "Unsupported EAPI 'UNKNOWN' (likely a broken package or configuration error)";
+ return "Unsupported EAPI '" + _imp->eapi_name + "'";
+}
+
+namespace paludis
+{
using namespace tr1::placeholders;
template <>
struct Implementation<FakePackageID>
{
+ const Environment * const env;
const tr1::shared_ptr<const FakeRepositoryBase> repository;
const QualifiedPackageName name;
const VersionSpec version;
@@ -203,8 +299,11 @@ namespace paludis
tr1::shared_ptr<FakeMetadataSpecTreeKey<URISpecTree> > bin_uri;
tr1::shared_ptr<FakeMetadataSpecTreeKey<URISpecTree> > homepage;
- Implementation(const tr1::shared_ptr<const FakeRepositoryBase> & r,
+ mutable bool has_masks;
+
+ Implementation(const Environment * const e, const tr1::shared_ptr<const FakeRepositoryBase> & r,
const QualifiedPackageName & q, const VersionSpec & v) :
+ env(e),
repository(r),
name(q),
version(v),
@@ -223,15 +322,16 @@ namespace paludis
post_dependencies(new FakeMetadataSpecTreeKey<DependencySpecTree>("PDEPEND", "Post dependencies",
"", tr1::bind(&PortageDepParser::parse_depend, _1, tr1::cref(*eapi)), mkt_dependencies)),
suggested_dependencies(new FakeMetadataSpecTreeKey<DependencySpecTree>("SDEPEND", "Suggested dependencies",
- "", tr1::bind(&PortageDepParser::parse_depend, _1, tr1::cref(*eapi)), mkt_dependencies))
+ "", tr1::bind(&PortageDepParser::parse_depend, _1, tr1::cref(*eapi)), mkt_dependencies)),
+ has_masks(false)
{
}
};
}
-FakePackageID::FakePackageID(const tr1::shared_ptr<const FakeRepositoryBase> & r,
+FakePackageID::FakePackageID(const Environment * const e, const tr1::shared_ptr<const FakeRepositoryBase> & r,
const QualifiedPackageName & q, const VersionSpec & v) :
- PrivateImplementationPattern<FakePackageID>(new Implementation<FakePackageID>(r, q, v)),
+ PrivateImplementationPattern<FakePackageID>(new Implementation<FakePackageID>(e, r, q, v)),
_imp(PrivateImplementationPattern<FakePackageID>::_imp.get())
{
add_metadata_key(_imp->keywords);
@@ -498,6 +598,106 @@ FakePackageID::supports_action(const SupportsActionTestBase & b) const
namespace
{
+ struct LicenceChecker :
+ ConstVisitor<LicenseSpecTree>,
+ ConstVisitor<LicenseSpecTree>::VisitConstSequence<LicenceChecker, AllDepSpec>
+ {
+ using ConstVisitor<LicenseSpecTree>::VisitConstSequence<LicenceChecker, AllDepSpec>::visit_sequence;
+
+ bool ok;
+ const Environment * const env;
+ bool (Environment::* const func) (const std::string &, const PackageID &) const;
+ const PackageID * const id;
+
+ LicenceChecker(const Environment * const e,
+ bool (Environment::* const f) (const std::string &, const PackageID &) const,
+ const PackageID * const d) :
+ ok(true),
+ env(e),
+ func(f),
+ id(d)
+ {
+ }
+
+ void visit_sequence(const AnyDepSpec &,
+ LicenseSpecTree::ConstSequenceIterator begin,
+ LicenseSpecTree::ConstSequenceIterator end)
+ {
+ bool local_ok(false);
+
+ if (begin == end)
+ local_ok = true;
+ else
+ {
+ for ( ; begin != end ; ++begin)
+ {
+ Save<bool> save_ok(&ok, true);
+ begin->accept(*this);
+ local_ok |= ok;
+ }
+ }
+
+ ok &= local_ok;
+ }
+
+ void visit_sequence(const UseDepSpec & spec,
+ LicenseSpecTree::ConstSequenceIterator begin,
+ LicenseSpecTree::ConstSequenceIterator end)
+ {
+ if (env->query_use(spec.flag(), *id))
+ std::for_each(begin, end, accept_visitor(*this));
+ }
+
+ void visit_leaf(const PlainTextDepSpec & spec)
+ {
+ if (! (env->*func)(spec.text(), *id))
+ ok = false;
+ }
+ };
+}
+
+void
+FakePackageID::need_masks_added() const
+{
+ if (_imp->has_masks)
+ return;
+
+ _imp->has_masks = true;
+
+ Context context("When generating masks for ID '" + canonical_form(idcf_full) + "':");
+
+ if (! eapi()->supported)
+ {
+ add_mask(make_shared_ptr(new FakeUnsupportedMask('E', "eapi", eapi()->name)));
+ return;
+ }
+
+ if (keywords_key())
+ if (! _imp->env->accept_keywords(keywords_key()->value(), *this))
+ add_mask(make_shared_ptr(new FakeUnacceptedMask('K', "keywords", keywords_key())));
+
+ if (license_key())
+ {
+ LicenceChecker c(_imp->env, &Environment::accept_license, this);
+ license_key()->value()->accept(c);
+ if (! c.ok)
+ add_mask(make_shared_ptr(new FakeUnacceptedMask('L', "license", license_key())));
+ }
+
+ if (! _imp->env->unmasked_by_user(*this))
+ {
+ tr1::shared_ptr<const Mask> user_mask(_imp->env->mask_for_user(*this));
+ if (user_mask)
+ add_mask(user_mask);
+ }
+
+ tr1::shared_ptr<const Mask> breaks_mask(_imp->env->mask_for_breakage(*this));
+ if (breaks_mask)
+ add_mask(breaks_mask);
+}
+
+namespace
+{
struct PerformAction :
ConstVisitor<ActionVisitorTypes>
{
diff --git a/paludis/repositories/fake/fake_package_id.hh b/paludis/repositories/fake/fake_package_id.hh
index 8c9f54e..60ae6e4 100644
--- a/paludis/repositories/fake/fake_package_id.hh
+++ b/paludis/repositories/fake/fake_package_id.hh
@@ -22,6 +22,7 @@
#include <paludis/package_id.hh>
#include <paludis/metadata_key.hh>
+#include <paludis/mask.hh>
#include <paludis/util/tr1_functional.hh>
namespace paludis
@@ -98,6 +99,32 @@ namespace paludis
PALUDIS_ATTRIBUTE((warn_unused_result));
};
+ class PALUDIS_VISIBLE FakeUnacceptedMask :
+ public UnacceptedMask,
+ private PrivateImplementationPattern<FakeUnacceptedMask>
+ {
+ public:
+ FakeUnacceptedMask(const char, const std::string &, const tr1::shared_ptr<const MetadataKey> &);
+ ~FakeUnacceptedMask();
+
+ const char key() const;
+ const std::string description() const;
+ const tr1::shared_ptr<const MetadataKey> unaccepted_key() const;
+ };
+
+ class PALUDIS_VISIBLE FakeUnsupportedMask :
+ public UnsupportedMask,
+ private PrivateImplementationPattern<FakeUnsupportedMask>
+ {
+ public:
+ FakeUnsupportedMask(const char, const std::string &, const std::string &);
+ ~FakeUnsupportedMask();
+
+ const char key() const;
+ const std::string description() const;
+ const std::string explanation() const;
+ };
+
class PALUDIS_VISIBLE FakePackageID :
public PackageID,
private PrivateImplementationPattern<FakePackageID>
@@ -107,9 +134,11 @@ namespace paludis
protected:
virtual void need_keys_added() const;
+ virtual void need_masks_added() const;
public:
- FakePackageID(const tr1::shared_ptr<const FakeRepositoryBase> &,
+ FakePackageID(const Environment * const e,
+ const tr1::shared_ptr<const FakeRepositoryBase> &,
const QualifiedPackageName &, const VersionSpec &);
~FakePackageID();
diff --git a/paludis/repositories/fake/fake_repository.cc b/paludis/repositories/fake/fake_repository.cc
index d6658dc..89f60eb 100644
--- a/paludis/repositories/fake/fake_repository.cc
+++ b/paludis/repositories/fake/fake_repository.cc
@@ -53,7 +53,6 @@ FakeRepository::FakeRepository(const Environment * const e, const RepositoryName
PrivateImplementationPattern<FakeRepository>(new Implementation<FakeRepository>),
FakeRepositoryBase(e, our_name, RepositoryCapabilities::create()
.installed_interface(0)
- .mask_interface(this)
.sets_interface(this)
.syncable_interface(0)
.use_interface(this)
diff --git a/paludis/repositories/fake/fake_repository_base.cc b/paludis/repositories/fake/fake_repository_base.cc
index 71168c0..a611b84 100644
--- a/paludis/repositories/fake/fake_repository_base.cc
+++ b/paludis/repositories/fake/fake_repository_base.cc
@@ -81,7 +81,6 @@ FakeRepositoryBase::FakeRepositoryBase(const Environment * const e,
const RepositoryName & our_name, const RepositoryCapabilities & caps,
const std::string & f) :
Repository(our_name, caps, f),
- RepositoryMaskInterface(),
RepositoryUseInterface(),
PrivateImplementationPattern<FakeRepositoryBase>(new Implementation<FakeRepositoryBase>(e))
{
@@ -158,23 +157,11 @@ tr1::shared_ptr<FakePackageID>
FakeRepositoryBase::add_version(const QualifiedPackageName & q, const VersionSpec & v)
{
add_package(q);
- tr1::shared_ptr<FakePackageID> id(new FakePackageID(shared_from_this(), q, v));
+ tr1::shared_ptr<FakePackageID> id(new FakePackageID(_imp->env, shared_from_this(), q, v));
_imp->ids.find(q)->second->push_back(id);
return id;
}
-bool
-FakeRepositoryBase::do_query_repository_masks(const PackageID &) const
-{
- return false;
-}
-
-bool
-FakeRepositoryBase::do_query_profile_masks(const PackageID &) const
-{
- return false;
-}
-
UseFlagState
FakeRepositoryBase::do_query_use(const UseFlagName &, const PackageID &) const
{
diff --git a/paludis/repositories/fake/fake_repository_base.hh b/paludis/repositories/fake/fake_repository_base.hh
index 4011dec..c07c9a6 100644
--- a/paludis/repositories/fake/fake_repository_base.hh
+++ b/paludis/repositories/fake/fake_repository_base.hh
@@ -44,7 +44,6 @@ namespace paludis
*/
class PALUDIS_VISIBLE FakeRepositoryBase :
public Repository,
- public RepositoryMaskInterface,
public RepositoryUseInterface,
public RepositorySetsInterface,
private PrivateImplementationPattern<FakeRepositoryBase>,
@@ -57,14 +56,6 @@ namespace paludis
FakeRepositoryBase(const Environment * const env, const RepositoryName & name,
const RepositoryCapabilities & caps, const std::string &);
- /* RepositoryMaskInterface */
-
- virtual bool do_query_repository_masks(const PackageID &) const
- PALUDIS_ATTRIBUTE((warn_unused_result));
-
- virtual bool do_query_profile_masks(const PackageID &) const
- PALUDIS_ATTRIBUTE((warn_unused_result));
-
/* RepositoryUseInterface */
virtual UseFlagState do_query_use(const UseFlagName &, const PackageID &) const
diff --git a/paludis/repositories/gems/gem_specification.cc b/paludis/repositories/gems/gem_specification.cc
index 4a54e55..bd9c74e 100644
--- a/paludis/repositories/gems/gem_specification.cc
+++ b/paludis/repositories/gems/gem_specification.cc
@@ -29,6 +29,7 @@
#include <paludis/repository.hh>
#include <paludis/metadata_key.hh>
#include <paludis/action.hh>
+#include <paludis/environment.hh>
#include <libwrapiter/libwrapiter_forward_iterator.hh>
#include <libwrapiter/libwrapiter_output_iterator.hh>
@@ -85,12 +86,17 @@ namespace paludis
tr1::shared_ptr<const FSEntry> load_from_file;
+ const Environment * const environment;
const tr1::shared_ptr<const Repository> repository;
const tr1::shared_ptr<const EAPI> eapi;
- Implementation(const tr1::shared_ptr<const Repository> & r) :
+ mutable bool has_masks;
+
+ Implementation(const Environment * const e, const tr1::shared_ptr<const Repository> & r) :
+ environment(e),
repository(r),
- eapi(EAPIData::get_instance()->eapi_from_string("gems-1"))
+ eapi(EAPIData::get_instance()->eapi_from_string("gems-1")),
+ has_masks(false)
{
}
};
@@ -268,8 +274,9 @@ namespace
}
}
-GemSpecification::GemSpecification(const tr1::shared_ptr<const Repository> & r, const yaml::Node & node) :
- PrivateImplementationPattern<GemSpecification>(new Implementation<GemSpecification>(r)),
+GemSpecification::GemSpecification(const Environment * const e,
+ const tr1::shared_ptr<const Repository> & r, const yaml::Node & node) :
+ PrivateImplementationPattern<GemSpecification>(new Implementation<GemSpecification>(e, r)),
_imp(PrivateImplementationPattern<GemSpecification>::_imp.get())
{
TopVisitor v(_imp);
@@ -289,9 +296,9 @@ GemSpecification::GemSpecification(const tr1::shared_ptr<const Repository> & r,
}
-GemSpecification::GemSpecification(const tr1::shared_ptr<const Repository> & r,
+GemSpecification::GemSpecification(const Environment * const e, const tr1::shared_ptr<const Repository> & r,
const PackageNamePart & q, const VersionSpec & v, const FSEntry & f) :
- PrivateImplementationPattern<GemSpecification>(new Implementation<GemSpecification>(r)),
+ PrivateImplementationPattern<GemSpecification>(new Implementation<GemSpecification>(e, r)),
_imp(PrivateImplementationPattern<GemSpecification>::_imp.get())
{
_imp->name_part = stringify(q);
@@ -600,3 +607,27 @@ GemSpecification::perform_action(Action & a) const
a.accept(b);
}
+void
+GemSpecification::need_masks_added() const
+{
+ if (_imp->has_masks)
+ return;
+
+ _imp->has_masks = true;
+
+ Context context("When generating masks for ID '" + canonical_form(idcf_full) + "':");
+
+ if (! _imp->environment->unmasked_by_user(*this))
+ {
+ /* user */
+ tr1::shared_ptr<const Mask> user_mask(_imp->environment->mask_for_user(*this));
+ if (user_mask)
+ add_mask(user_mask);
+ }
+
+ /* break portage */
+ tr1::shared_ptr<const Mask> breaks_mask(_imp->environment->mask_for_breakage(*this));
+ if (breaks_mask)
+ add_mask(breaks_mask);
+}
+
diff --git a/paludis/repositories/gems/gem_specification.hh b/paludis/repositories/gems/gem_specification.hh
index e9ae86f..1983e8a 100644
--- a/paludis/repositories/gems/gem_specification.hh
+++ b/paludis/repositories/gems/gem_specification.hh
@@ -68,13 +68,14 @@ namespace paludis
protected:
void need_keys_added() const;
+ virtual void need_masks_added() const;
public:
///\name Basic operations
///\{
- GemSpecification(const tr1::shared_ptr<const Repository> &, const yaml::Node &);
- GemSpecification(const tr1::shared_ptr<const Repository> &, const PackageNamePart &,
+ GemSpecification(const Environment * const e, const tr1::shared_ptr<const Repository> &, const yaml::Node &);
+ GemSpecification(const Environment * const e, const tr1::shared_ptr<const Repository> &, const PackageNamePart &,
const VersionSpec &, const FSEntry &);
~GemSpecification();
diff --git a/paludis/repositories/gems/gem_specification_TEST.cc b/paludis/repositories/gems/gem_specification_TEST.cc
index 06bc812..2752e6e 100644
--- a/paludis/repositories/gems/gem_specification_TEST.cc
+++ b/paludis/repositories/gems/gem_specification_TEST.cc
@@ -21,6 +21,7 @@
#include <test/test_framework.hh>
#include <paludis/repositories/gems/gem_specification.hh>
#include <paludis/repositories/gems/yaml.hh>
+#include <paludis/environments/test/test_environment.hh>
#include <paludis/util/visitor-impl.hh>
#include <paludis/name.hh>
#include <paludis/metadata_key.hh>
@@ -118,7 +119,8 @@ namespace test_cases
yaml::Document spec_doc(spec_text);
TEST_CHECK(spec_doc.top());
- GemSpecification spec(tr1::shared_ptr<Repository>(), *spec_doc.top());
+ TestEnvironment env;
+ GemSpecification spec(&env, tr1::shared_ptr<Repository>(), *spec_doc.top());
TEST_CHECK(spec.short_description_key());
TEST_CHECK_EQUAL(spec.short_description_key()->value(), "This is the summary");
diff --git a/paludis/repositories/gems/gem_specifications.cc b/paludis/repositories/gems/gem_specifications.cc
index de5291f..26cf24f 100644
--- a/paludis/repositories/gems/gem_specifications.cc
+++ b/paludis/repositories/gems/gem_specifications.cc
@@ -101,10 +101,13 @@ namespace
ConstVisitor<yaml::NodeVisitorTypes>
{
Implementation<GemSpecifications> * const _imp;
+ const Environment * const environment;
const tr1::shared_ptr<const Repository> repository;
- GemsVisitor(const tr1::shared_ptr<const Repository> & r, Implementation<GemSpecifications> * const i) :
+ GemsVisitor(const Environment * const e,
+ const tr1::shared_ptr<const Repository> & r, Implementation<GemSpecifications> * const i) :
_imp(i),
+ environment(e),
repository(r)
{
}
@@ -118,7 +121,7 @@ namespace
try
{
- tr1::shared_ptr<GemSpecification> spec(new GemSpecification(repository, *i->second));
+ tr1::shared_ptr<GemSpecification> spec(new GemSpecification(environment, repository, *i->second));
_imp->specs.insert(std::make_pair(std::make_pair(spec->name(), spec->version()), spec));
}
catch (const Exception & e)
@@ -148,10 +151,13 @@ namespace
ConstVisitor<yaml::NodeVisitorTypes>
{
Implementation<GemSpecifications> * const _imp;
+ const Environment * const environment;
const tr1::shared_ptr<const Repository> repository;
- TopVisitor(const tr1::shared_ptr<const Repository> & r, Implementation<GemSpecifications> * const i) :
+ TopVisitor(const Environment * const e,
+ const tr1::shared_ptr<const Repository> & r, Implementation<GemSpecifications> * const i) :
_imp(i),
+ environment(e),
repository(r)
{
}
@@ -162,7 +168,7 @@ namespace
if (n.end() == i)
throw BadSpecificationError("Top level map does not contain 'gems' node");
- GemsVisitor g(repository, _imp);
+ GemsVisitor g(environment, repository, _imp);
i->second->accept(g);
}
@@ -182,10 +188,11 @@ namespace
}
}
-GemSpecifications::GemSpecifications(const tr1::shared_ptr<const Repository> & r, const yaml::Node & n) :
+GemSpecifications::GemSpecifications(const Environment * const e,
+ const tr1::shared_ptr<const Repository> & r, const yaml::Node & n) :
PrivateImplementationPattern<GemSpecifications>(new Implementation<GemSpecifications>)
{
- TopVisitor v(r, _imp.get());
+ TopVisitor v(e, r, _imp.get());
n.accept(v);
}
diff --git a/paludis/repositories/gems/gem_specifications.hh b/paludis/repositories/gems/gem_specifications.hh
index 629abe7..42a08a3 100644
--- a/paludis/repositories/gems/gem_specifications.hh
+++ b/paludis/repositories/gems/gem_specifications.hh
@@ -50,7 +50,7 @@ namespace paludis
///\name Basic operations
///\{
- GemSpecifications(const tr1::shared_ptr<const Repository> &, const yaml::Node &);
+ GemSpecifications(const Environment * const, const tr1::shared_ptr<const Repository> &, const yaml::Node &);
~GemSpecifications();
///\}
diff --git a/paludis/repositories/gems/gems_repository.cc b/paludis/repositories/gems/gems_repository.cc
index 94dab62..20abc71 100644
--- a/paludis/repositories/gems/gems_repository.cc
+++ b/paludis/repositories/gems/gems_repository.cc
@@ -65,7 +65,6 @@ namespace paludis
GemsRepository::GemsRepository(const gems::RepositoryParams & params) :
Repository(RepositoryName("gems"),
RepositoryCapabilities::create()
- .mask_interface(0)
.installed_interface(0)
.sets_interface(0)
.syncable_interface(0)
@@ -192,7 +191,7 @@ GemsRepository::need_ids() const
std::string output((std::istreambuf_iterator<char>(yaml_file)), std::istreambuf_iterator<char>());
yaml::Document master_doc(output);
- gems::GemSpecifications specs(shared_from_this(), *master_doc.top());
+ gems::GemSpecifications specs(_imp->params.environment, shared_from_this(), *master_doc.top());
for (gems::GemSpecifications::Iterator i(specs.begin()), i_end(specs.end()) ;
i != i_end ; ++i)
diff --git a/paludis/repositories/gems/installed_gems_repository.cc b/paludis/repositories/gems/installed_gems_repository.cc
index 517cb68..fee24f5 100644
--- a/paludis/repositories/gems/installed_gems_repository.cc
+++ b/paludis/repositories/gems/installed_gems_repository.cc
@@ -73,7 +73,6 @@ namespace paludis
InstalledGemsRepository::InstalledGemsRepository(const gems::InstalledRepositoryParams & params) :
Repository(RepositoryName("installed-gems"),
RepositoryCapabilities::create()
- .mask_interface(0)
.installed_interface(this)
.sets_interface(0)
.syncable_interface(0)
@@ -212,7 +211,8 @@ InstalledGemsRepository::need_ids() const
if (_imp->ids.end() == _imp->ids.find(gems + p))
_imp->ids.insert(std::make_pair(gems + p, make_shared_ptr(new PackageIDSequence)));
- _imp->ids.find(gems + p)->second->push_back(make_shared_ptr(new gems::GemSpecification(shared_from_this(), p, v, *d)));
+ _imp->ids.find(gems + p)->second->push_back(make_shared_ptr(new gems::GemSpecification(
+ _imp->params.environment, shared_from_this(), p, v, *d)));
}
}
diff --git a/paludis/repositories/virtuals/installed_virtuals_repository.cc b/paludis/repositories/virtuals/installed_virtuals_repository.cc
index bcbda23..625afef 100644
--- a/paludis/repositories/virtuals/installed_virtuals_repository.cc
+++ b/paludis/repositories/virtuals/installed_virtuals_repository.cc
@@ -100,7 +100,6 @@ namespace
InstalledVirtualsRepository::InstalledVirtualsRepository(const Environment * const env,
const FSEntry & r) :
Repository(RepositoryName(make_name(r)), RepositoryCapabilities::create()
- .mask_interface(0)
.installed_interface(this)
.use_interface(0)
.sets_interface(0)
diff --git a/paludis/repositories/virtuals/package_id.cc b/paludis/repositories/virtuals/package_id.cc
index e4b8bf9..2198e3c 100644
--- a/paludis/repositories/virtuals/package_id.cc
+++ b/paludis/repositories/virtuals/package_id.cc
@@ -31,6 +31,7 @@
#include <paludis/metadata_key.hh>
#include <paludis/hashed_containers.hh>
#include <paludis/action.hh>
+#include <paludis/mask.hh>
using namespace paludis;
using namespace paludis::virtuals;
@@ -120,6 +121,7 @@ namespace paludis
const tr1::shared_ptr<const MetadataPackageIDKey> virtual_for;
const tr1::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> > bdep;
const tr1::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> > rdep;
+ mutable bool has_masks;
Implementation(
const tr1::shared_ptr<const Repository> & o,
@@ -131,7 +133,8 @@ namespace paludis
version(p->version()),
virtual_for(new virtuals::VirtualsPackageIDKey(p)),
bdep(new virtuals::VirtualsDepKey("DEPEND", "Build dependencies", p, b)),
- rdep(new virtuals::VirtualsDepKey("RDEPEND", "Run dependencies", p, b))
+ rdep(new virtuals::VirtualsDepKey("RDEPEND", "Run dependencies", p, b)),
+ has_masks(false)
{
}
};
@@ -415,3 +418,46 @@ VirtualsPackageID::supports_action(const SupportsActionTestBase & b) const
return repository()->some_ids_might_support_action(b);
}
+namespace
+{
+ class VirtualsAssociationMask :
+ public AssociationMask
+ {
+ private:
+ const tr1::shared_ptr<const PackageID> _id;
+
+ public:
+ VirtualsAssociationMask(const tr1::shared_ptr<const PackageID> & i) :
+ _id(i)
+ {
+ }
+
+ const char key() const
+ {
+ return 'A';
+ }
+
+ const std::string description() const
+ {
+ return "by association";
+ }
+
+ const tr1::shared_ptr<const PackageID> associated_package() const
+ {
+ return _id;
+ }
+ };
+}
+
+void
+VirtualsPackageID::need_masks_added() const
+{
+ if (_imp->has_masks)
+ return;
+
+ if (_imp->virtual_for->value()->masked())
+ add_mask(make_shared_ptr(new VirtualsAssociationMask(_imp->virtual_for->value())));
+
+ _imp->has_masks = true;
+}
+
diff --git a/paludis/repositories/virtuals/package_id.hh b/paludis/repositories/virtuals/package_id.hh
index 7134451..80e7f17 100644
--- a/paludis/repositories/virtuals/package_id.hh
+++ b/paludis/repositories/virtuals/package_id.hh
@@ -68,6 +68,7 @@ namespace paludis
protected:
virtual void need_keys_added() const;
+ virtual void need_masks_added() const;
public:
VirtualsPackageID(
diff --git a/paludis/repositories/virtuals/virtuals_repository.cc b/paludis/repositories/virtuals/virtuals_repository.cc
index 3b2617a..217c7ee 100644
--- a/paludis/repositories/virtuals/virtuals_repository.cc
+++ b/paludis/repositories/virtuals/virtuals_repository.cc
@@ -95,7 +95,6 @@ namespace
VirtualsRepository::VirtualsRepository(const Environment * const env) :
Repository(RepositoryName("virtuals"), RepositoryCapabilities::create()
- .mask_interface(0)
.installed_interface(0)
.use_interface(0)
.sets_interface(0)
diff --git a/paludis/repository-fwd.hh b/paludis/repository-fwd.hh
index d19d772..c3a7129 100644
--- a/paludis/repository-fwd.hh
+++ b/paludis/repository-fwd.hh
@@ -33,7 +33,6 @@ namespace paludis
class Repository;
class RepositoryInstalledInterface;
- class RepositoryMaskInterface;
class RepositorySetsInterface;
class RepositorySyncableInterface;
class RepositoryUseInterface;
diff --git a/paludis/repository.cc b/paludis/repository.cc
index 6f4680e..c5951da 100644
--- a/paludis/repository.cc
+++ b/paludis/repository.cc
@@ -168,10 +168,6 @@ RepositoryInstalledInterface::~RepositoryInstalledInterface()
{
}
-RepositoryMaskInterface::~RepositoryMaskInterface()
-{
-}
-
RepositorySetsInterface::~RepositorySetsInterface()
{
}
@@ -293,18 +289,6 @@ RepositoryMirrorsInterface::is_mirror(const std::string & s) const
return begin_mirrors(s) != end_mirrors(s);
}
-bool
-RepositoryMaskInterface::query_repository_masks(const PackageID & e) const
-{
- return do_query_repository_masks(e);
-}
-
-bool
-RepositoryMaskInterface::query_profile_masks(const PackageID & e) const
-{
- return do_query_profile_masks(e);
-}
-
tr1::shared_ptr<const PackageIDSequence>
Repository::package_ids(const QualifiedPackageName & p) const
{
diff --git a/paludis/repository.hh b/paludis/repository.hh
index 37010a8..6d37273 100644
--- a/paludis/repository.hh
+++ b/paludis/repository.hh
@@ -237,52 +237,6 @@ namespace paludis
};
/**
- * Interface for handling masks for the Repository class.
- *
- * \see Repository
- * \ingroup grprepository
- * \nosubgrouping
- */
- class PALUDIS_VISIBLE RepositoryMaskInterface
- {
- protected:
- ///\name Implementation details
- ///\{
-
- /**
- * Override in descendents: check for a mask.
- */
- virtual bool do_query_repository_masks(const PackageID &) const
- PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
-
- /**
- * Override in descendents: check for a mask.
- */
- virtual bool do_query_profile_masks(const PackageID &) const
- PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
-
- ///\}
-
- public:
- ///\name Mask queries
- ///\{
-
- /**
- * Query repository masks.
- */
- bool query_repository_masks(const PackageID &) const;
-
- /**
- * Query profile masks.
- */
- bool query_profile_masks(const PackageID &) const;
-
- ///\}
-
- virtual ~RepositoryMaskInterface();
- };
-
- /**
* Interface for handling USE flags for the Repository class.
*
* \see Repository
diff --git a/paludis/repository.sr b/paludis/repository.sr
index 37b6591..45258b9 100644
--- a/paludis/repository.sr
+++ b/paludis/repository.sr
@@ -6,7 +6,6 @@ make_class_RepositoryCapabilities()
visible
key installed_interface "RepositoryInstalledInterface *"
- key mask_interface "RepositoryMaskInterface *"
key sets_interface "RepositorySetsInterface *"
key syncable_interface "RepositorySyncableInterface *"
key use_interface "RepositoryUseInterface *"
diff --git a/paludis/set_file.cc b/paludis/set_file.cc
index 35b6e31..81e40fc 100644
--- a/paludis/set_file.cc
+++ b/paludis/set_file.cc
@@ -24,6 +24,7 @@
#include <paludis/util/pstream.hh>
#include <paludis/util/private_implementation_pattern-impl.hh>
#include <paludis/util/sequence.hh>
+#include <paludis/util/options.hh>
#include <paludis/config_file.hh>
#include <paludis/environment.hh>
#include <paludis/query.hh>
diff --git a/paludis/tasks/report_task.cc b/paludis/tasks/report_task.cc
index 4942111..d2f7a97 100644
--- a/paludis/tasks/report_task.cc
+++ b/paludis/tasks/report_task.cc
@@ -177,32 +177,10 @@ ReportTask::execute()
for (PackageIDSequence::Iterator v(ids->begin()), v_end(ids->end()) ;
v != v_end ; ++v)
{
- bool is_masked(false);
+ bool is_masked((*v)->masked());
bool is_vulnerable(false);
- bool is_missing(false);
bool is_unused(false);
- MaskReasons mr;
- try
- {
-#if 0
- if ((*v)->source_origin_key())
- {
- mr = e->mask_reasons(*((*v)->source_origin_key()->value()));
- if (mr.any())
- is_masked = true;
- }
-#endif
- }
- catch (const NoSuchPackageError &)
- {
- is_missing = true;
- }
- catch (const NoSuchRepositoryError &)
- {
- is_missing = true;
- }
-
std::pair<VulnerableChecker::ConstIterator, VulnerableChecker::ConstIterator> pi(vuln.insecure_tags(*v));
if (pi.first != pi.second)
is_vulnerable = true;
@@ -210,11 +188,11 @@ ReportTask::execute()
if (unused.end() != unused.find(*v))
is_unused = true;
- if (is_masked || is_vulnerable || is_missing || is_unused)
+ if (is_masked || is_vulnerable || is_unused)
{
on_report_package_failure_pre(**v);
if (is_masked)
- on_report_package_is_masked(**v, mr);
+ on_report_package_is_masked(**v);
if (is_vulnerable)
{
on_report_package_is_vulnerable_pre(**v);
@@ -222,8 +200,6 @@ ReportTask::execute()
on_report_package_is_vulnerable(**v, itag->second->short_text());
on_report_package_is_vulnerable_post(**v);
}
- if (is_missing)
- on_report_package_is_missing(**v);
if (is_unused)
on_report_package_is_unused(**v);
on_report_package_failure_post(**v);
diff --git a/paludis/tasks/report_task.hh b/paludis/tasks/report_task.hh
index 77bd10b..5d7efdb 100644
--- a/paludis/tasks/report_task.hh
+++ b/paludis/tasks/report_task.hh
@@ -23,7 +23,6 @@
#include <paludis/util/instantiation_policy.hh>
#include <paludis/util/private_implementation_pattern.hh>
#include <paludis/repository.hh>
-#include <paludis/mask_reasons.hh>
namespace paludis
{
@@ -62,11 +61,10 @@ namespace paludis
virtual void on_report_check_package_pre(const QualifiedPackageName & p) = 0;
virtual void on_report_package_success(const PackageID & id) = 0;
virtual void on_report_package_failure_pre(const PackageID & id) = 0;
- virtual void on_report_package_is_masked(const PackageID & id, const MaskReasons & mr) = 0;
+ virtual void on_report_package_is_masked(const PackageID & id) = 0;
virtual void on_report_package_is_vulnerable_pre(const PackageID & id) = 0;
virtual void on_report_package_is_vulnerable(const PackageID & id, const std::string & tag) = 0;
virtual void on_report_package_is_vulnerable_post(const PackageID & id) = 0;
- virtual void on_report_package_is_missing(const PackageID & id) = 0;
virtual void on_report_package_is_unused(const PackageID & id) = 0;
virtual void on_report_package_failure_post(const PackageID & id) = 0;
virtual void on_report_check_package_post(const QualifiedPackageName & p) = 0;
diff --git a/python/Makefile.am b/python/Makefile.am
index 09a11b5..0b5b6d4 100644
--- a/python/Makefile.am
+++ b/python/Makefile.am
@@ -24,7 +24,6 @@ IF_PYTHON_TESTS = \
version_spec_TEST.py \
version_operator_TEST.py \
version_requirements_TEST.py \
- mask_reasons_TEST.py \
contents_TEST.py \
dep_spec_TEST.py \
eapi_TEST.py \
@@ -51,7 +50,6 @@ IF_PYTHON_SOURCES = \
environment.cc \
exception.hh exception.cc \
fs_entry.cc \
- mask_reasons.cc \
metadata_key.cc \
name.cc \
log.cc \
diff --git a/python/dep_list.cc b/python/dep_list.cc
index f86054e..b0038d8 100644
--- a/python/dep_list.cc
+++ b/python/dep_list.cc
@@ -104,17 +104,6 @@ void PALUDIS_VISIBLE expose_dep_list()
"State of a DepListEntry.");
enum_auto("DepListEntryKind", last_dlk,
"Kind of a DepListEntry.");
- enum_auto("DepListOverrideMask", last_dl_override,
- "Masks that can be overridden.");
-
- /**
- * Options
- */
- class_options<DepListOverrideMasks>
- (
- "DepListOverrideMasks", "DepListOverrideMask",
- "Set of masks that can be overridden."
- );
/**
* DepListOptions
@@ -198,10 +187,6 @@ void PALUDIS_VISIBLE expose_dep_list()
"[rw] DepListBlocksOption"
)
- .def_readwrite("override_masks", &DepListOptions::override_masks,
- "[rw] DepListOverrideMasks"
- )
-
.def_readwrite("dependency_tags", &DepListOptions::dependency_tags,
"[rw] bool"
)
diff --git a/python/dep_list_TEST.py b/python/dep_list_TEST.py
index abaae3a..1100d26 100755
--- a/python/dep_list_TEST.py
+++ b/python/dep_list_TEST.py
@@ -56,7 +56,6 @@ class TestCase_01_DepListOptions(unittest.TestCase):
self.assert_(isinstance(dlo.circular, DepListCircularOption))
self.assert_(isinstance(dlo.use, DepListUseOption))
self.assert_(isinstance(dlo.blocks, DepListBlocksOption))
- self.assert_(isinstance(dlo.override_masks, DepListOverrideMasks))
self.assert_(isinstance(dlo.dependency_tags, bool))
def test_03_data_members_set(self):
diff --git a/python/environment.cc b/python/environment.cc
index f344d1f..5e4ac76 100644
--- a/python/environment.cc
+++ b/python/environment.cc
@@ -66,12 +66,6 @@ void PALUDIS_VISIBLE expose_environment()
"Thrown if the config directory cannot be found by PaludisConfig.");
/**
- * Enums
- */
- enum_auto("MaskReasonsOption", last_mro,
- "Options for Environment.mask_reasons().");
-
- /**
* EnvironmentMaker
*/
bp::class_<EnvironmentMaker, boost::noncopyable>
@@ -92,15 +86,6 @@ void PALUDIS_VISIBLE expose_environment()
;
/**
- * MaskReasonsOptions
- */
- class_options<MaskReasonsOptions>
- (
- "MaskReasonsOptions", "MaskReasonsOption",
- "Options for Environment.mask_reasons()."
- );
-
- /**
* Environment
*/
tr1::shared_ptr<PackageDatabase> (Environment::* package_database)() =
@@ -133,13 +118,6 @@ void PALUDIS_VISIBLE expose_environment()
"Is a particular use flag enabled for a particular package?"
)
- .def("mask_reasons", &Environment::mask_reasons,
- (bp::arg("PackageID"), bp::arg("MaskReasonOptions")=MaskReasonsOptions()),
- "mask_reasons(PackageID, MaskReasonsOptions=MaskReasonsOptions())"
- " -> set of MaskReason\n"
- "Return the reasons for a package being masked."
- )
-
.add_property("root", &Environment::root,
"[ro] string\n"
"Our root location for installs."
diff --git a/python/environment_TEST.py b/python/environment_TEST.py
index 82ea50b..de57e3c 100755
--- a/python/environment_TEST.py
+++ b/python/environment_TEST.py
@@ -61,13 +61,6 @@ class TestCase_01_Environments(unittest.TestCase):
self.assert_(not nce.query_use("foo", pid))
- def test_05_mask_reasons(self):
- pid = iter(nce.package_database.query(Query.Matches(
- PackageDepSpec("=foo/bar-1.0", PackageDepSpecParseMode.PERMISSIVE)),
- QueryOrder.REQUIRE_EXACTLY_ONE)).next()
-
- nce.mask_reasons(pid)
-
def test_06_package_database(self):
self.assert_(isinstance(e.package_database, PackageDatabase))
self.assert_(isinstance(nce.package_database, PackageDatabase))
diff --git a/python/mask_reasons.cc b/python/mask_reasons.cc
deleted file mode 100644
index b48b45b..0000000
--- a/python/mask_reasons.cc
+++ /dev/null
@@ -1,44 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2007 Piotr Jaroszyński <peper@gentoo.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_python.hh>
-
-#include <paludis/mask_reasons.hh>
-
-using namespace paludis;
-using namespace paludis::python;
-namespace bp = boost::python;
-
-void PALUDIS_VISIBLE expose_mask_reasons()
-{
- /**
- * Enums
- */
- enum_auto("MaskReason", last_mr,
- "Each value represents one reason for a package being masked.");
-
- /**
- * MaskReasons
- */
- class_options<MaskReasons>
- (
- "MaskReasons", "MaskReason",
- "A collection of reasons for why a package is masked."
- );
-}
diff --git a/python/mask_reasons_TEST.py b/python/mask_reasons_TEST.py
deleted file mode 100755
index 0dc6dab..0000000
--- a/python/mask_reasons_TEST.py
+++ /dev/null
@@ -1,86 +0,0 @@
-#!/usr/bin/env python
-# vim: set fileencoding=utf-8 sw=4 sts=4 et :
-
-#
-# Copyright (c) 2007 Piotr Jaroszyński <peper@gentoo.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
-#
-
-from paludis import *
-import unittest
-
-class TestCase_MaskReasons(unittest.TestCase):
- def test_01_init(self):
- MaskReasons()
-
- def test_02_none(self):
- self.assert_(MaskReasons().none)
-
- def test_03_any(self):
- self.assert_(not MaskReasons().any)
-
- def test_04_add(self):
- m1 = MaskReasons()
- m1 = m1 + MaskReason.KEYWORD
- self.assert_(m1[MaskReason.KEYWORD])
-
- def test_05_iadd(self):
- m1 = MaskReasons()
- m1 += MaskReason.KEYWORD
- self.assert_(m1[MaskReason.KEYWORD])
-
- def test_06_sub(self):
- m1 = MaskReasons()
- m1 += MaskReason.KEYWORD
- m1 = m1 - MaskReason.KEYWORD
- self.assert_(m1.none)
-
- def test_07_isub(self):
- m1 = MaskReasons()
- m1 += MaskReason.KEYWORD
- m1 -= MaskReason.KEYWORD
- self.assert_(m1.none)
-
- def test_08_or(self):
- m1 = MaskReasons()
- m2 = MaskReasons()
- m1 += MaskReason.KEYWORD
- m2 += MaskReason.EAPI
- m3 = m1 | m2
- self.assert_(m3[MaskReason.KEYWORD])
- self.assert_(m3[MaskReason.EAPI])
-
- def test_09_ior(self):
- m1 = MaskReasons()
- m2 = MaskReasons()
- m1 += MaskReason.KEYWORD
- m2 += MaskReason.EAPI
- m2 |= m1
- self.assert_(m2[MaskReason.KEYWORD])
- self.assert_(m2[MaskReason.EAPI])
-
- def test_10_subtract(self):
- m1 = MaskReasons()
- m2 = MaskReasons()
- m1 += MaskReason.KEYWORD
- m1 += MaskReason.EAPI
- m2 += MaskReason.EAPI
- m1.subtract(m2)
- self.assert_(m1[MaskReason.KEYWORD])
- self.assert_(not m1[MaskReason.EAPI])
-
-
-if __name__ == "__main__":
- unittest.main()
diff --git a/python/paludis_python_so.cc b/python/paludis_python_so.cc
index 21ee40b..f29ddfc 100644
--- a/python/paludis_python_so.cc
+++ b/python/paludis_python_so.cc
@@ -30,7 +30,6 @@ void expose_environment();
void expose_exception();
void expose_fs_entry();
void expose_log();
-void expose_mask_reasons();
void expose_metadata_key();
void expose_name();
void expose_package_database();
@@ -55,7 +54,6 @@ BOOST_PYTHON_MODULE(paludis)
expose_fs_entry();
expose_eapi();
expose_contents();
- expose_mask_reasons();
expose_dep_spec();
expose_dep_tag();
expose_dep_list();
diff --git a/python/repository.cc b/python/repository.cc
index 1b6c873..ad26e3c 100644
--- a/python/repository.cc
+++ b/python/repository.cc
@@ -51,12 +51,6 @@ struct RepositoryWrapper :
return Repository::info(verbose);
}
- static RepositoryMaskInterface *
- get_mask_interface(const Repository & self)
- {
- return self.mask_interface;
- }
-
static RepositorySetsInterface *
get_sets_interface(const Repository & self)
{
@@ -316,11 +310,6 @@ void PALUDIS_VISIBLE expose_repository()
"Fetch our versions."
)
- .add_property("mask_interface", bp::make_function(&RepositoryWrapper::get_mask_interface,
- bp::return_internal_reference<>()),
- "[ro] RepositoryMaskInterface"
- )
-
.add_property("use_interface", bp::make_function(&RepositoryWrapper::get_use_interface,
bp::return_internal_reference<>()),
"[ro] RepositoryUseInterface"
@@ -397,26 +386,6 @@ void PALUDIS_VISIBLE expose_repository()
;
/**
- * RepositoryMaskInterface
- */
- bp::class_<RepositoryMaskInterface, boost::noncopyable>
- (
- "RepositoryMaskInterface",
- "Interface for handling masks for the Repository class.",
- bp::no_init
- )
- .def("query_repository_masks", &RepositoryMaskInterface::query_repository_masks,
- "query_repository_masks(PackageID) -> bool\n"
- "Query repository masks."
- )
-
- .def("query_profile_masks", &RepositoryMaskInterface::query_profile_masks,
- "query_profile_masks(PackageID) -> bool\n"
- "Query profile masks."
- )
- ;
-
- /**
* RepositoryUseInterface
*/
bp::class_<RepositoryUseInterface, boost::noncopyable>
diff --git a/python/repository_TEST.py b/python/repository_TEST.py
index e2007ee..7da8422 100755
--- a/python/repository_TEST.py
+++ b/python/repository_TEST.py
@@ -108,19 +108,6 @@ class TestCase_02_RepositoryInterfaces(unittest.TestCase):
repo = db.fetch_repository("testrepo")
irepo = db.fetch_repository("installed")
- def test_01_mask_interface(self):
- mi = repo.mask_interface
- self.assert_(isinstance(mi, RepositoryMaskInterface))
-
- foo = []
- for i in [1,2,3,4]:
- foo.append(iter(repo.package_ids("foo"+str(i)+"/bar")).next())
-
- self.assert_(mi.query_profile_masks(foo[0]))
- self.assert_(not mi.query_profile_masks(foo[1]))
- self.assert_(mi.query_profile_masks(foo[2]))
- self.assert_(not mi.query_profile_masks(foo[3]))
-
def test_02_sets_interface(self):
si = repo.sets_interface
self.assert_(isinstance(si, RepositorySetsInterface))
diff --git a/ruby/Makefile.am b/ruby/Makefile.am
index 32d864d..a700aef 100644
--- a/ruby/Makefile.am
+++ b/ruby/Makefile.am
@@ -23,7 +23,6 @@ IF_RUBY_TESTS = \
package_database_TEST.rb \
log_TEST.rb \
version_spec_TEST.rb \
- mask_reasons_TEST.rb \
dep_spec_TEST.rb \
portage_dep_parser_TEST.rb \
qualified_package_name_TEST.rb \
@@ -46,7 +45,6 @@ IF_RUBY_SOURCES = \
paludis_ruby.cc paludis_ruby.hh \
environment.cc \
version_spec.cc \
- mask_reasons.cc \
dep_spec.cc \
log.cc \
package_database.cc \
diff --git a/ruby/dep_list.cc b/ruby/dep_list.cc
index ee15001..fb46c38 100644
--- a/ruby/dep_list.cc
+++ b/ruby/dep_list.cc
@@ -43,11 +43,9 @@ namespace
static VALUE c_dep_list_use_option;
static VALUE c_dep_list_entry_state;
static VALUE c_dep_list_entry_kind;
- static VALUE c_dep_list_override_mask;
static VALUE c_dep_list_options;
static VALUE c_dep_list;
static VALUE c_dep_list_entry;
- static VALUE c_dep_list_override_masks;
tr1::shared_ptr<DepListOptions>
value_to_dep_list_options(VALUE v)
@@ -88,27 +86,6 @@ namespace
}
VALUE
- dep_list_override_masks_to_value(const DepListOverrideMasks & m)
- {
- return Data_Wrap_Struct(c_dep_list_override_masks, 0, &Common<DepListOverrideMasks>::free, new DepListOverrideMasks(m));
- }
-
- DepListOverrideMasks
- value_to_dep_list_override_masks(VALUE v)
- {
- if (rb_obj_is_kind_of(v, c_dep_list_override_masks))
- {
- DepListOverrideMasks * v_ptr;
- Data_Get_Struct(v, DepListOverrideMasks, v_ptr);
- return *v_ptr;
- }
- else
- {
- rb_raise(rb_eTypeError, "Can't convert %s into DepListOverrideMasks", rb_obj_classname(v));
- }
- }
-
- VALUE
dep_list_options_init(int, VALUE *, VALUE self)
{
return self;
@@ -143,7 +120,6 @@ namespace
* :circular => DepListCircularOption::Error,
* :use => DepListUseOption::Standard,
* :blocks => DepListBlocksOption::Accumulate,
- * :override_masks => DepListOverrideMasks.new,
* :dependency_tags => false
* }
*/
@@ -188,7 +164,6 @@ namespace
int value_for_circular;
int value_for_use;
int value_for_blocks;
- DepListOverrideMasks value_for_override_masks;
bool value_for_dependency_tags;
if (1 == argc && rb_obj_is_kind_of(argv[0], rb_cHash))
@@ -229,8 +204,6 @@ namespace
rb_raise(rb_eArgError, "Missing Parameter: use");
if (Qnil == rb_hash_aref(argv[0], ID2SYM(rb_intern("blocks"))))
rb_raise(rb_eArgError, "Missing Parameter: blocks");
- if (Qnil == rb_hash_aref(argv[0], ID2SYM(rb_intern("override_masks"))))
- rb_raise(rb_eArgError, "Missing Parameter: override_masks");
if (Qnil == rb_hash_aref(argv[0], ID2SYM(rb_intern("dependency_tags"))))
rb_raise(rb_eArgError, "Missing Parameter: dependency_tags");
value_for_reinstall =
@@ -269,9 +242,6 @@ namespace
NUM2INT(rb_hash_aref(argv[0], ID2SYM(rb_intern("use"))));
value_for_blocks =
NUM2INT(rb_hash_aref(argv[0], ID2SYM(rb_intern("blocks"))));
- value_for_override_masks = value_to_dep_list_override_masks(
- rb_hash_aref(argv[0], ID2SYM(rb_intern("override_masks")))
- );
value_for_dependency_tags =
Qtrue == (rb_hash_aref(argv[0], ID2SYM(rb_intern("dependency_tags")))) ? true : false;
}
@@ -295,7 +265,6 @@ namespace
value_for_circular = NUM2INT(argv[15]);
value_for_use = NUM2INT(argv[16]);
value_for_blocks = NUM2INT(argv[17]);
- value_for_override_masks = value_to_dep_list_override_masks(argv[18]);
value_for_dependency_tags = Qtrue == argv[19] ? true : false;
}
else
@@ -360,7 +329,7 @@ namespace
static_cast<DepListCircularOption>(value_for_circular),
static_cast<DepListUseOption>(value_for_use),
static_cast<DepListBlocksOption>(value_for_blocks),
- value_for_override_masks,
+ tr1::shared_ptr<DepListOverrideMasksFunctions>(),
value_for_dependency_tags
)
);
@@ -703,42 +672,6 @@ namespace
/*
* call-seq:
- * override_masks -> DepListOverrideMasks
- *
- * A copy of our override DepListOverrideMasks.
- */
- VALUE
- dep_list_options_override_masks(VALUE self)
- {
- tr1::shared_ptr<DepListOptions> * p;
- Data_Get_Struct(self, tr1::shared_ptr<DepListOptions>, p);
- return dep_list_override_masks_to_value((*p)->override_masks);
- }
-
- /*
- * call-seq:
- * override_masks=(dep_list_override_masks) -> Qnil
- *
- * Set our override DepListOverrideMasks.
- */
- VALUE
- dep_list_options_override_masks_set(VALUE self, VALUE mr)
- {
- tr1::shared_ptr<DepListOptions> * p;
- Data_Get_Struct(self, tr1::shared_ptr<DepListOptions>, p);
- try
- {
- (*p)->override_masks = value_to_dep_list_override_masks(mr);
- return Qnil;
- }
- catch (const std::exception & e)
- {
- exception_to_ruby_exception(e);
- }
- }
-
- /*
- * call-seq:
* dependancy_tags -> true or false
*
* Our dependency_tags
@@ -1021,120 +954,6 @@ namespace
}
}
- VALUE
- dep_list_override_masks_init(VALUE self)
- {
- return self;
- }
-
- VALUE
- dep_list_override_masks_new(VALUE self)
- {
- DepListOverrideMasks * ptr(0);
- try
- {
- ptr = new DepListOverrideMasks;
- VALUE tdata(Data_Wrap_Struct(self, 0, &Common<DepListOverrideMasks>::free, ptr));
- rb_obj_call_init(tdata, 0, &self);
- return tdata;
- }
- catch (const std::exception & e)
- {
- delete ptr;
- exception_to_ruby_exception(e);
- }
- }
-
- /*
- * call-seq:
- * each {|override_mask| block } -> Nil
- *
- * Iterate through the mask reasons.
- */
- VALUE
- dep_list_override_masks_each(VALUE self)
- {
- DepListOverrideMasks * m_ptr;
- Data_Get_Struct(self, DepListOverrideMasks, m_ptr);
- for (DepListOverrideMask i(static_cast<DepListOverrideMask>(0)), i_end(last_dl_override) ; i != i_end ;
- i = static_cast<DepListOverrideMask>(static_cast<int>(i) + 1))
- if ((*m_ptr)[i])
- rb_yield(INT2FIX(i));
- return Qnil;
- }
-
- /*
- * call-seq:
- * empty? -> true or false
- *
- * Is the collection empty.
- */
- VALUE
- dep_list_override_masks_empty(VALUE self)
- {
- DepListOverrideMasks * m_ptr;
- Data_Get_Struct(self, DepListOverrideMasks, m_ptr);
- return m_ptr->any() ? Qfalse : Qtrue;
- }
-
- /*
- * call-seq:
- * set(mask_reason) -> Nil
- *
- * Add DepListOverrideMask to collection.
- */
- VALUE
- dep_list_override_masks_set(VALUE self, VALUE mask_reason)
- {
- DepListOverrideMasks * m_ptr;
- Data_Get_Struct(self, DepListOverrideMasks, m_ptr);
- try
- {
- int mr = NUM2INT(mask_reason);
- if (mr < 0 || mr >= last_dl_override)
- rb_raise(rb_eArgError, "DepListOverrideMask out of range");
- *m_ptr += static_cast<DepListOverrideMask>(mr);
- return Qnil;
-
- }
- catch (const std::exception & e)
- {
- exception_to_ruby_exception(e);
- }
- }
-
- VALUE
- dep_list_override_masks_reset(int argc, VALUE * argv, VALUE self)
- {
- DepListOverrideMasks * m_ptr;
- Data_Get_Struct(self, DepListOverrideMasks, m_ptr);
- if (argc == 0)
- {
- *m_ptr = DepListOverrideMasks();
- return Qnil;
- }
- else if (argc == 1)
- {
- try
- {
- int mr = NUM2INT(argv[0]);
- if (mr < 0 || mr >= last_dl_override)
- rb_raise(rb_eArgError, "DepListOverrideMask out of range");
- *m_ptr -= static_cast<DepListOverrideMask>(mr);
- return Qnil;
-
- }
- catch (const std::exception & e)
- {
- exception_to_ruby_exception(e);
- }
- }
- else
- {
- rb_raise(rb_eArgError, "clear expects one or zero arguments, but got %d",argc);
- }
- }
-
void do_register_dep_list()
{
/*
@@ -1320,19 +1139,6 @@ namespace
// cc_enum_special<paludis/dep_list/options-se.hh, DepListEntryKind, c_dep_list_entry_kind>
/*
- * Document-module: Paludis::DepListOverrideMask
- *
- * Masks that can be overriden.
- *
- */
- c_dep_list_override_mask = rb_define_module_under(paludis_module(), "DepListOverrideMask");
- for (DepListOverrideMask l(static_cast<DepListOverrideMask>(0)), l_end(last_dl_override) ; l != l_end ;
- l = static_cast<DepListOverrideMask>(static_cast<int>(l) + 1))
- rb_define_const(c_dep_list_override_mask, value_case_to_RubyCase(stringify(l)).c_str(), INT2FIX(l));
-
- // cc_enum_special<paludis/dep_list/options-se.hh, DepListOverrideMask, c_dep_list_override_mask>
-
- /*
* Document-class: Paludis::DepListOptions
*
* Parameters for a DepList.
@@ -1415,9 +1221,7 @@ namespace
RUBY_FUNC_CAST((&OptionsMember<DepListBlocksOption, &DepListOptions::blocks>::set)),1);
- rb_define_method(c_dep_list_options, "override_masks", RUBY_FUNC_CAST(&dep_list_options_override_masks),0);
rb_define_method(c_dep_list_options, "dependency_tags", RUBY_FUNC_CAST(&dep_list_options_dependency_tags),0);
- rb_define_method(c_dep_list_options, "override_masks=", RUBY_FUNC_CAST(&dep_list_options_override_masks_set),1);
rb_define_method(c_dep_list_options, "dependency_tags=", RUBY_FUNC_CAST(&dep_list_options_dependency_tags_set),1);
/*
@@ -1451,20 +1255,6 @@ namespace
#if CIARANM_REMOVED_THIS
rb_define_method(c_dep_list_entry, "tags", RUBY_FUNC_CAST(&dep_list_entry_tags), 0);
#endif
-
- /*
- * Document-class: DepListOverrideMasks
- *
- * Set of masks that can be overriden.
- */
- c_dep_list_override_masks = rb_define_class_under(paludis_module(), "DepListOverrideMasks", rb_cObject);
- rb_define_singleton_method(c_dep_list_override_masks, "new", RUBY_FUNC_CAST(&dep_list_override_masks_new), 0);
- rb_define_method(c_dep_list_override_masks, "initialize", RUBY_FUNC_CAST(&dep_list_override_masks_init), 0);
- rb_define_method(c_dep_list_override_masks, "each", RUBY_FUNC_CAST(&dep_list_override_masks_each), 0);
- rb_include_module(c_dep_list_override_masks, rb_mEnumerable);
- rb_define_method(c_dep_list_override_masks, "empty?", RUBY_FUNC_CAST(&dep_list_override_masks_empty), 0);
- rb_define_method(c_dep_list_override_masks, "set", RUBY_FUNC_CAST(&dep_list_override_masks_set), 1);
- rb_define_method(c_dep_list_override_masks, "reset", RUBY_FUNC_CAST(&dep_list_override_masks_reset), -1);
}
}
diff --git a/ruby/dep_list_TEST.rb b/ruby/dep_list_TEST.rb
index e739c0d..5d8f453 100644
--- a/ruby/dep_list_TEST.rb
+++ b/ruby/dep_list_TEST.rb
@@ -46,7 +46,7 @@ module Paludis
DepListCircularOption::Error,
DepListUseOption::Standard,
DepListBlocksOption::Accumulate,
- DepListOverrideMasks.new,
+ nil,
false
)
end
@@ -71,7 +71,6 @@ module Paludis
:circular => DepListCircularOption::Error,
:use => DepListUseOption::Standard,
:blocks => DepListBlocksOption::Accumulate,
- :override_masks => DepListOverrideMasks.new,
:dependency_tags => false
}
end
@@ -100,7 +99,6 @@ module Paludis
:circular => DepListCircularOption::Discard,
:use => DepListUseOption::TakeAll,
:blocks => DepListBlocksOption::Error,
- :override_masks => DepListOverrideMasks.new,
:dependency_tags => true
}
end
@@ -148,7 +146,6 @@ module Paludis
#This will fail if the defaults change, please also update the rdoc.
default_options.each_pair do |method, value|
assert_respond_to options, method
- next if method == :override_masks
assert_equal value, options.send(method)
#check setters work
assert_nothing_raised do
@@ -156,10 +153,6 @@ module Paludis
assert_equal options_hash[method], options.send(method)
end
end
- assert_kind_of DepListOverrideMasks, options.override_masks
- assert_nothing_raised do
- options.override_masks = DepListOverrideMasks.new
- end
end
def test_bad_create
@@ -265,49 +258,5 @@ module Paludis
### end
### end
### end
-
-
- class TestCase_DepListOverrideMasks < Test::Unit::TestCase
- def test_create
- m = DepListOverrideMasks.new
- end
-
- def test_each
- m = DepListOverrideMasks.new
- assert_equal [], m.to_a
- end
-
- def test_empty
- m = DepListOverrideMasks.new
- assert m.empty?
- m.set DepListOverrideMask::Licenses
- assert !m.empty?
- end
-
- def test_set
- m = DepListOverrideMasks.new
- m.set DepListOverrideMask::Licenses
- m.set DepListOverrideMask::ProfileMasks
-
- assert ! m.empty?
- assert_equal 2, m.entries.length
-
- assert m.include?(DepListOverrideMask::Licenses)
- assert m.include?(DepListOverrideMask::ProfileMasks)
- end
-
- def test_clear
- m = DepListOverrideMasks.new
- m.set DepListOverrideMask::Licenses
- m.set DepListOverrideMask::ProfileMasks
- m.set DepListOverrideMask::TildeKeywords
-
- assert_equal 3, m.entries.length
- m.reset DepListOverrideMask::TildeKeywords
- assert_equal 2, m.entries.length
- m.reset
- assert m.empty?
- end
- end
end
diff --git a/ruby/environment.cc b/ruby/environment.cc
index 1e82ef9..6a291cf 100644
--- a/ruby/environment.cc
+++ b/ruby/environment.cc
@@ -40,23 +40,6 @@ namespace
static VALUE c_no_config_environment;
static VALUE c_adapted_environment;
static VALUE c_environment_maker;
- static VALUE c_mask_reasons_option;
- static VALUE c_mask_reasons_options;
-
- MaskReasonsOptions
- value_to_mask_reasons_options(VALUE v)
- {
- if (rb_obj_is_kind_of(v, c_mask_reasons_options))
- {
- MaskReasonsOptions * v_ptr;
- Data_Get_Struct(v, MaskReasonsOptions, v_ptr);
- return *v_ptr;
- }
- else
- {
- rb_raise(rb_eTypeError, "Can't convert %s into MaskReasonsOptions", rb_obj_classname(v));
- }
- }
tr1::shared_ptr<AdaptedEnvironment>
value_to_adapted_environment(VALUE v)
@@ -95,34 +78,6 @@ namespace
/*
* call-seq:
- * mask_reasons(package_id) -> MaskReasons
- * mask_reasons(package_id, mask_reasons_option) -> MaskReasons
- *
- * Return the reasons for a package being masked.
- */
- VALUE
- environment_mask_reasons(int argc, VALUE* argv, VALUE self)
- {
- try
- {
- MaskReasons r;
- if (1 == argc) {
- r = value_to_environment(self)->mask_reasons(*value_to_package_id(argv[0]));
- } else if (2 == argc) {
- r = value_to_environment(self)->mask_reasons(*value_to_package_id(argv[0]), value_to_mask_reasons_options(argv[1]));
- } else {
- rb_raise(rb_eArgError, "Environment.mask_reasons expects one or two arguments, but got %d", argc);
- }
- return mask_reasons_to_value(r);
- }
- catch (const std::exception & e)
- {
- exception_to_ruby_exception(e);
- }
- }
-
- /*
- * call-seq:
* package_database -> PackageDatabase
*
* Fetch our PackageDatabase.
@@ -518,88 +473,6 @@ namespace
}
}
- VALUE
- mask_reasons_options_init(VALUE self)
- {
- return self;
- }
-
- VALUE
- mask_reasons_options_new(VALUE self)
- {
- MaskReasonsOptions * ptr(0);
- try
- {
- ptr = new MaskReasonsOptions;
- VALUE tdata(Data_Wrap_Struct(self, 0, &Common<MaskReasonsOptions>::free, ptr));
- rb_obj_call_init(tdata, 0, &self);
- return tdata;
- }
- catch (const std::exception & e)
- {
- delete ptr;
- exception_to_ruby_exception(e);
- }
- }
-
- /*
- * call-seq:
- * each {|mask_reasons_option| block } -> Nil
- *
- * Iterate through the mask reasons options.
- */
- VALUE
- mask_reasons_options_each(VALUE self)
- {
- MaskReasonsOptions * m_ptr;
- Data_Get_Struct(self, MaskReasonsOptions, m_ptr);
- for (MaskReasonsOption i(static_cast<MaskReasonsOption>(0)), i_end(last_mro) ; i != i_end ;
- i = static_cast<MaskReasonsOption>(static_cast<int>(i) + 1))
- if ((*m_ptr)[i])
- rb_yield(INT2FIX(i));
- return Qnil;
- }
-
- /*
- * call-seq:
- * empty? -> true or false
- *
- * Is the collection empty.
- */
- VALUE
- mask_reasons_options_empty(VALUE self)
- {
- MaskReasonsOptions * m_ptr;
- Data_Get_Struct(self, MaskReasonsOptions, m_ptr);
- return m_ptr->any() ? Qfalse : Qtrue;
- }
-
- /*
- * call-seq:
- * set(mask_reason) -> Nil
- *
- * Add MaskReason to collection.
- */
- VALUE
- mask_reasons_options_set(VALUE self, VALUE mask_reasons_option)
- {
- MaskReasonsOptions * m_ptr;
- Data_Get_Struct(self, MaskReasonsOptions, m_ptr);
- try
- {
- int mr = NUM2INT(mask_reasons_option);
- if (mr < 0 || mr >= last_mro)
- rb_raise(rb_eArgError, "MaskReasonsOption out of range");
- *m_ptr += static_cast<MaskReasonsOption>(mr);
- return Qnil;
-
- }
- catch (const std::exception & e)
- {
- exception_to_ruby_exception(e);
- }
- }
-
void do_register_environment()
{
rb_require("singleton");
@@ -613,7 +486,6 @@ 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), 2);
- rb_define_method(c_environment, "mask_reasons", RUBY_FUNC_CAST(&environment_mask_reasons), -1);
rb_define_method(c_environment, "package_database", RUBY_FUNC_CAST(&environment_package_database), 0);
#if CIARANM_REMOVED_THIS
rb_define_method(c_environment, "set", RUBY_FUNC_CAST(&environment_set), 1);
@@ -669,34 +541,6 @@ namespace
c_environment_maker = rb_define_class_under(paludis_module(), "EnvironmentMaker", rb_cObject);
rb_funcall(rb_const_get(rb_cObject, rb_intern("Singleton")), rb_intern("included"), 1, c_environment_maker);
rb_define_method(c_environment_maker, "make_from_spec", RUBY_FUNC_CAST(&environment_maker_make_from_spec), 1);
-
- /*
- * Document-class: Paludis::MaskReasons
- *
- * A collection of reasons for why a package is masked. Includes
- * Enumerable[http://www.ruby-doc.org/core/classes/Enumerable.html]
- * but not Comparable.
- */
- c_mask_reasons_options = rb_define_class_under(paludis_module(), "MaskReasonsOptions", rb_cObject);
- rb_define_singleton_method(c_mask_reasons_options, "new", RUBY_FUNC_CAST(&mask_reasons_options_new), 0);
- rb_define_method(c_mask_reasons_options, "initialize", RUBY_FUNC_CAST(&mask_reasons_options_init), 0);
- rb_define_method(c_mask_reasons_options, "each", RUBY_FUNC_CAST(&mask_reasons_options_each), 0);
- rb_include_module(c_mask_reasons_options, rb_mEnumerable);
- rb_define_method(c_mask_reasons_options, "empty?", RUBY_FUNC_CAST(&mask_reasons_options_empty), 0);
- rb_define_method(c_mask_reasons_options, "set", RUBY_FUNC_CAST(&mask_reasons_options_set), 1);
- rb_define_method(c_mask_reasons_options, "add", RUBY_FUNC_CAST(&mask_reasons_options_set), 1);
-
- /*
- * Document-module: Paludis::MaskReasonsOption
- *
- * Options for Environment.mask_reasons
- */
- c_mask_reasons_option = rb_define_module_under(paludis_module(), "MaskReasonsOption");
- for (MaskReasonsOption l(static_cast<MaskReasonsOption>(0)), l_end(last_mro) ; l != l_end ;
- l = static_cast<MaskReasonsOption>(static_cast<int>(l) + 1))
- rb_define_const(c_mask_reasons_option, value_case_to_RubyCase(stringify(l)).c_str(), INT2FIX(l));
-
- // cc_enum_special<paludis/environment-se.hh, MaskReasonsOption, c_mask_reasons_option>
}
}
diff --git a/ruby/environment_TEST.rb b/ruby/environment_TEST.rb
index e046569..16adfa1 100644
--- a/ruby/environment_TEST.rb
+++ b/ruby/environment_TEST.rb
@@ -244,45 +244,6 @@ module Paludis
end
end
- class TestCase_NoConfigEnvironmentMaskReasons < Test::Unit::TestCase
- def env
- NoConfigEnvironment.new(Dir.getwd().to_s + "/environment_TEST_dir/testrepo")
- end
-
- def test_mask_reasons
- pid = env.package_database.query(Query::Matches.new(PackageDepSpec.new('=foo/bar-1.0::testrepo', PackageDepSpecParseMode::Permissive)), QueryOrder::RequireExactlyOne).first
- m = env.mask_reasons(pid)
- assert m.empty?
- end
-
- def test_mask_reasons_not_empty
- pid = env.package_database.query(Query::Matches.new(PackageDepSpec.new('=foo/bar-2.0::testrepo', PackageDepSpecParseMode::Permissive)), QueryOrder::RequireExactlyOne).first
-
- m = env.mask_reasons(pid)
- assert ! m.empty?
- assert m.include?(MaskReason::Keyword)
- assert_equal([MaskReason::Keyword], m.to_a)
- end
-
- def test_mask_reasons_options
- pid = env.package_database.query(Query::Matches.new(PackageDepSpec.new('=foo/bar-2.0::testrepo', PackageDepSpecParseMode::Permissive)), QueryOrder::RequireExactlyOne).first
- mro = MaskReasonsOptions.new
- mro.add MaskReasonsOption::OverrideTildeKeywords
- m = env.mask_reasons(pid, mro)
- assert m.empty?
- end
-
- def test_mask_reasons_bad
- assert_raise ArgumentError do
- env.mask_reasons(1, 2, 3)
- end
-
- assert_raise TypeError do
- env.mask_reasons(123)
- end
- end
- end
-
class TestCase_EnvironmentPackageDatabase < Test::Unit::TestCase
def env
@env or @env = EnvironmentMaker.instance.make_from_spec("")
diff --git a/ruby/mask_reasons.cc b/ruby/mask_reasons.cc
deleted file mode 100644
index 43cd0a5..0000000
--- a/ruby/mask_reasons.cc
+++ /dev/null
@@ -1,172 +0,0 @@
-/* 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 <paludis_ruby.hh>
-#include <paludis/mask_reasons.hh>
-#include <paludis/util/stringify.hh>
-#include <ruby.h>
-
-using namespace paludis;
-using namespace paludis::ruby;
-
-#define RUBY_FUNC_CAST(x) reinterpret_cast<VALUE (*)(...)>(x)
-
-namespace
-{
- static VALUE c_mask_reasons;
- static VALUE c_mask_reason;
-
- VALUE
- mask_reasons_init(VALUE self)
- {
- return self;
- }
-
- VALUE
- mask_reasons_new(VALUE self)
- {
- MaskReasons * ptr(0);
- try
- {
- ptr = new MaskReasons;
- VALUE tdata(Data_Wrap_Struct(self, 0, &Common<MaskReasons>::free, ptr));
- rb_obj_call_init(tdata, 0, &self);
- return tdata;
- }
- catch (const std::exception & e)
- {
- delete ptr;
- exception_to_ruby_exception(e);
- }
- }
-
- /*
- * call-seq:
- * each {|mask_reason| block } -> Nil
- *
- * Iterate through the mask reasons.
- */
- VALUE
- mask_reasons_each(VALUE self)
- {
- MaskReasons * m_ptr;
- Data_Get_Struct(self, MaskReasons, m_ptr);
- for (MaskReason i(static_cast<MaskReason>(0)), i_end(last_mr) ; i != i_end ;
- i = static_cast<MaskReason>(static_cast<int>(i) + 1))
- if ((*m_ptr)[i])
- rb_yield(INT2FIX(i));
- return Qnil;
- }
-
- /*
- * call-seq:
- * empty? -> true or false
- *
- * Is the collection empty.
- */
- VALUE
- mask_reasons_empty(VALUE self)
- {
- MaskReasons * m_ptr;
- Data_Get_Struct(self, MaskReasons, m_ptr);
- return m_ptr->any() ? Qfalse : Qtrue;
- }
-
- /*
- * call-seq:
- * set(mask_reason) -> Nil
- *
- * Add MaskReason to collection.
- */
- VALUE
- mask_reasons_set(VALUE self, VALUE mask_reason)
- {
- MaskReasons * m_ptr;
- Data_Get_Struct(self, MaskReasons, m_ptr);
- try
- {
- int mr = NUM2INT(mask_reason);
- if (mr < 0 || mr >= last_mr)
- rb_raise(rb_eArgError, "MaskReason out of range");
- *m_ptr += static_cast<MaskReason>(mr);
- return Qnil;
-
- }
- catch (const std::exception & e)
- {
- exception_to_ruby_exception(e);
- }
- }
-
- void do_register_mask_reasons()
- {
- /*
- * Document-class: Paludis::MaskReasons
- *
- * A collection of reasons for why a package is masked. Includes
- * Enumerable[http://www.ruby-doc.org/core/classes/Enumerable.html]
- * but not Comparable.
- */
- c_mask_reasons = rb_define_class_under(paludis_module(), "MaskReasons", rb_cObject);
- rb_define_singleton_method(c_mask_reasons, "new", RUBY_FUNC_CAST(&mask_reasons_new), 0);
- rb_define_method(c_mask_reasons, "initialize", RUBY_FUNC_CAST(&mask_reasons_init), 0);
- rb_define_method(c_mask_reasons, "each", RUBY_FUNC_CAST(&mask_reasons_each), 0);
- rb_include_module(c_mask_reasons, rb_mEnumerable);
- rb_define_method(c_mask_reasons, "empty?", RUBY_FUNC_CAST(&mask_reasons_empty), 0);
- rb_define_method(c_mask_reasons, "set", RUBY_FUNC_CAST(&mask_reasons_set), 1);
-
- /*
- * Document-module: Paludis::MaskReason
- *
- * Each value represents one reason for a package being masked.
- */
- c_mask_reason = rb_define_module_under(paludis_module(), "MaskReason");
- for (MaskReason l(static_cast<MaskReason>(0)), l_end(last_mr) ; l != l_end ;
- l = static_cast<MaskReason>(static_cast<int>(l) + 1))
- rb_define_const(c_mask_reason, value_case_to_RubyCase(stringify(l)).c_str(), INT2FIX(l));
-
- // cc_enum_special<paludis/mask_reasons-se.hh, MaskReason, c_mask_reason>
- }
-}
-
-VALUE
-paludis::ruby::mask_reasons_to_value(const MaskReasons & m)
-{
- return Data_Wrap_Struct(c_mask_reasons, 0, &Common<MaskReasons>::free, new MaskReasons(m));
-}
-
-MaskReasons
-paludis::ruby::value_to_mask_reasons(VALUE v)
-{
- if (rb_obj_is_kind_of(v, c_mask_reasons))
- {
- MaskReasons * v_ptr;
- Data_Get_Struct(v, MaskReasons, v_ptr);
- return *v_ptr;
- }
- else
- {
- rb_raise(rb_eTypeError, "Can't convert %s into MaskReasons", rb_obj_classname(v));
- }
-}
-
-RegisterRubyClass::Register paludis_ruby_register_mask_reasons PALUDIS_ATTRIBUTE((used))
- (&do_register_mask_reasons);
-
-
diff --git a/ruby/mask_reasons_TEST.rb b/ruby/mask_reasons_TEST.rb
deleted file mode 100644
index 0a82998..0000000
--- a/ruby/mask_reasons_TEST.rb
+++ /dev/null
@@ -1,52 +0,0 @@
-#!/usr/bin/env ruby
-# vim: set sw=4 sts=4 et tw=80 :
-
-#
-# Copyright (c) 2006 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
-#
-
-require 'test/unit'
-require 'Paludis'
-
-module Paludis
- class TestCase_MaskReasons < Test::Unit::TestCase
- def test_create
- m = MaskReasons.new
- end
-
- def test_each
- m = MaskReasons.new
- assert_equal [], m.to_a
- end
-
- def test_empty
- m = MaskReasons.new
- assert m.empty?
- end
-
- def test_set
- m = MaskReasons.new
- m.set MaskReason::Keyword
- m.set MaskReason::ProfileMask
-
- assert ! m.empty?
-
- assert m.include?(MaskReason::Keyword)
- assert m.include?(MaskReason::ProfileMask)
- end
- end
-end
-
diff --git a/ruby/paludis_ruby.hh b/ruby/paludis_ruby.hh
index dd062bd..8b446de 100644
--- a/ruby/paludis_ruby.hh
+++ b/ruby/paludis_ruby.hh
@@ -27,7 +27,6 @@
#include <paludis/util/private_implementation_pattern.hh>
#include <paludis/util/attributes.hh>
#include <paludis/util/exception.hh>
-#include <paludis/mask_reasons.hh>
#include <paludis/util/fs_entry.hh>
#include <paludis/environment.hh>
#include <paludis/environments/no_config/no_config_environment.hh>
@@ -66,7 +65,6 @@ namespace paludis
/* constructors */
- VALUE mask_reasons_to_value(const MaskReasons &);
VALUE package_database_to_value(tr1::shared_ptr<PackageDatabase>);
VALUE repository_to_value(tr1::shared_ptr<const Repository>);
VALUE version_spec_to_value(const VersionSpec &);
@@ -87,7 +85,6 @@ namespace paludis
tr1::shared_ptr<Environment> value_to_environment(VALUE v);
tr1::shared_ptr<NoConfigEnvironment> value_to_no_config_environment(VALUE v);
RepositoryEInterface::ProfilesDescLine value_to_profiles_desc_line(VALUE v);
- MaskReasons value_to_mask_reasons(VALUE v);
Query value_to_query(VALUE v);
tr1::shared_ptr<const Repository> value_to_repository(VALUE);
diff --git a/ruby/repository.cc b/ruby/repository.cc
index 148edd5..5be5290 100644
--- a/ruby/repository.cc
+++ b/ruby/repository.cc
@@ -592,46 +592,6 @@ namespace
"Repository.query_use_force expects two arguments, but got %d";
/*
- * Document-method: query_repository_masks
- *
- * call-seq:
- * query_repository_masks(package_id) -> true or false or nil
- *
- * Query repository masks. nil if the repository doesn't implement mask_interface.
- */
- /*
- * Document-method: query_profile_masks
- *
- * call-seq:
- * query_profile_masks(package_id) -> true or false or nil
- *
- * Query profile masks. nil if the repository doesn't implement mask_interface.
- */
-
- template <bool (RepositoryMaskInterface::* m_) (const PackageID &) const>
- struct QueryMasks
- {
- static VALUE
- query(VALUE self, VALUE pid)
- {
- try
- {
- tr1::shared_ptr<Repository> * self_ptr;
- Data_Get_Struct(self, tr1::shared_ptr<Repository>, self_ptr);
- RepositoryMaskInterface * const mask_interface ((**self_ptr).mask_interface);
-
- if (mask_interface)
- return ((*mask_interface).*m_)(*value_to_package_id(pid)) ? Qtrue : Qfalse;
- return Qnil;
- }
- catch (const std::exception & e)
- {
- exception_to_ruby_exception(e);
- }
- }
- };
-
- /*
* call-seq:
* describe_use_flag(flag_name) -> String or Nil
* describe_use_flag(flag_name, package_id) -> String or Nil
@@ -967,8 +927,6 @@ namespace
rb_define_method(c_repository, "installed_interface", RUBY_FUNC_CAST((&Interface<RepositoryInstalledInterface,
&Repository::installed_interface>::fetch)), 0);
- rb_define_method(c_repository, "mask_interface", RUBY_FUNC_CAST((&Interface<RepositoryMaskInterface,
- &Repository::mask_interface>::fetch)), 0);
rb_define_method(c_repository, "sets_interface", RUBY_FUNC_CAST((&Interface<RepositorySetsInterface,
&Repository::sets_interface>::fetch)), 0);
rb_define_method(c_repository, "syncable_interface", RUBY_FUNC_CAST((&Interface<RepositorySyncableInterface,
@@ -993,8 +951,6 @@ namespace
rb_define_method(c_repository, "query_use_mask", RUBY_FUNC_CAST((&QueryUse<bool, true, false, &RepositoryUseInterface::query_use_mask>::query)), -1);
rb_define_method(c_repository, "query_use_force", RUBY_FUNC_CAST((&QueryUse<bool, true, false, &RepositoryUseInterface::query_use_force>::query)), -1);
- rb_define_method(c_repository, "query_repository_masks", RUBY_FUNC_CAST(&QueryMasks<&RepositoryMaskInterface::query_repository_masks>::query), 1);
- rb_define_method(c_repository, "query_profile_masks", RUBY_FUNC_CAST(&QueryMasks<&RepositoryMaskInterface::query_profile_masks>::query), 1);
rb_define_method(c_repository, "describe_use_flag", RUBY_FUNC_CAST(&repository_describe_use_flag),-1);
rb_define_method(c_repository, "profiles", RUBY_FUNC_CAST(&repository_profiles),0);
diff --git a/ruby/repository_TEST.rb b/ruby/repository_TEST.rb
index 7b9ddbf..6171696 100644
--- a/ruby/repository_TEST.rb
+++ b/ruby/repository_TEST.rb
@@ -172,8 +172,7 @@ module Paludis
def test_responds
repo = no_config_testrepo.main_repository
- [:installed_interface, :mask_interface,
- :sets_interface, :syncable_interface, :use_interface,
+ [:installed_interface, :sets_interface, :syncable_interface, :use_interface,
:world_interface, :mirrors_interface, :environment_variable_interface,
:provides_interface, :virtuals_interface, :e_interface].each do |sym|
assert_respond_to repo, sym
@@ -181,7 +180,7 @@ module Paludis
end
def test_interfaces
- assert_equal repo.name, repo.mask_interface.name
+ assert_equal repo.name, repo.use_interface.name
assert_nil repo.installed_interface
assert_equal installed_repo.name, installed_repo.provides_interface.name
@@ -340,36 +339,6 @@ module Paludis
end
end
- class TestCase_QueryProfileMasks < Test::Unit::TestCase
- include RepositoryTestCase
-
- def test_profile_masks
-### assert repo.query_profile_masks("foo1/bar","1.0")
-### assert ! repo.query_profile_masks("foo2/bar","1.0")
-### assert repo.query_profile_masks("foo3/bar","1.0")
-### assert ! repo.query_profile_masks("foo4/bar","1.0")
- end
-
- def test_profile_masks_bad
-### assert_raise TypeError do
-### repo.query_profile_masks(42,"1.0")
-### end
-### assert_raise TypeError do
-### repo.query_profile_masks("foo/bar",[])
-### end
-
- assert_raise ArgumentError do
- repo.query_profile_masks
- end
-### assert_raise ArgumentError do
-### repo.query_profile_masks("foo/bar")
-### end
- assert_raise ArgumentError do
- repo.query_profile_masks("foo/bar","1.0","baz")
- end
- end
- end
-
class TestCase_RepositoryInfo < Test::Unit::TestCase
include RepositoryTestCase
diff --git a/src/clients/adjutrix/what_needs_keywording.cc b/src/clients/adjutrix/what_needs_keywording.cc
index bbf9303..c45c467 100644
--- a/src/clients/adjutrix/what_needs_keywording.cc
+++ b/src/clients/adjutrix/what_needs_keywording.cc
@@ -24,11 +24,14 @@
#include <paludis/util/strip.hh>
#include <paludis/util/set.hh>
#include <paludis/util/sequence.hh>
+#include <paludis/util/tr1_functional.hh>
#include <paludis/repositories/fake/fake_installed_repository.hh>
#include <paludis/dep_list/exceptions.hh>
#include <paludis/dep_list/dep_list.hh>
+#include <paludis/dep_list/override_functions.hh>
#include <paludis/package_id.hh>
#include <paludis/metadata_key.hh>
+#include <paludis/mask.hh>
#include <set>
#include <map>
@@ -43,6 +46,8 @@ using std::endl;
int do_what_needs_keywording(NoConfigEnvironment & env)
{
+ using namespace tr1::placeholders;
+
int return_code(0);
Context context("When performing what-needs-keywording action:");
@@ -65,10 +70,10 @@ int do_what_needs_keywording(NoConfigEnvironment & env)
d_options.circular = dl_circular_discard_silently;
d_options.use = dl_use_deps_take_all;
d_options.blocks = dl_blocks_discard_completely;
- d_options.override_masks += dl_override_tilde_keywords;
- d_options.override_masks += dl_override_unkeyworded;
- d_options.override_masks += dl_override_repository_masks;
- d_options.override_masks += dl_override_profile_masks;
+ d_options.override_masks.reset(new DepListOverrideMasksFunctions);
+ d_options.override_masks->push_back(tr1::bind(&override_tilde_keywords, &env, _1, _2));
+ d_options.override_masks->push_back(tr1::bind(&override_unkeyworded, &env, _1, _2));
+ d_options.override_masks->push_back(tr1::bind(&override_repository_masks, _2));
DepList d(&env, d_options);
@@ -118,11 +123,9 @@ int do_what_needs_keywording(NoConfigEnvironment & env)
std::string masks;
- MaskReasons r(env.mask_reasons(*p->package_id));
- if (r[mr_repository_mask])
- masks.append("R");
- if (r[mr_profile_mask])
- masks.append("P");
+ for (PackageID::MasksIterator m(p->package_id->begin_masks()), m_end(p->package_id->end_masks()) ;
+ m != m_end ; ++m)
+ masks.append(stringify(m->key()));
cout << std::setw(10) << std::left << masks;
diff --git a/src/clients/contrarius/install.cc b/src/clients/contrarius/install.cc
index 2b5fb9d..36a1c8a 100644
--- a/src/clients/contrarius/install.cc
+++ b/src/clients/contrarius/install.cc
@@ -40,6 +40,7 @@
#include <paludis/query.hh>
#include <paludis/eapi.hh>
#include <paludis/metadata_key.hh>
+#include <paludis/mask.hh>
/** \file
* Handle the --install action for the contrarius program.
@@ -318,40 +319,14 @@ do_install(tr1::shared_ptr<Environment> env, std::string spec_str)
cerr << " * " << colour(cl_package_name, **pp) << ": Masked by ";
bool need_comma(false);
- MaskReasons m(env->mask_reasons(**pp));
- for (unsigned mm = 0 ; mm < last_mr ; ++mm)
- if (m[static_cast<MaskReason>(mm)])
- {
- if (need_comma)
- cerr << ", ";
- cerr << MaskReason(mm);
-
- if (mr_eapi == mm)
- {
- cerr << " ( " << colour(cl_masked, (*pp)->eapi()->name) << " )";
- }
- else if (mr_license == mm)
- {
- if ((*pp)->license_key())
- {
- cerr << " ";
-
- LicenceDisplayer ld(cerr, env.get(), *pp);
- (*pp)->license_key()->value()->accept(ld);
- }
- }
- else if (mr_keyword == mm)
- {
- if ((*pp)->keywords_key())
- {
- tr1::shared_ptr<const KeywordNameSet> keywords((*pp)->keywords_key()->value());
- cerr << " ( " << colour(cl_masked, join(keywords->begin(),
- keywords->end(), " ")) << " )";
- }
- }
-
- need_comma = true;
- }
+ for (PackageID::MasksIterator m((*pp)->begin_masks()), m_end((*pp)->end_masks()) ;
+ m != m_end ; ++m)
+ {
+ if (need_comma)
+ cerr << ", ";
+ cerr << m->description();
+ need_comma = true;
+ }
cerr << endl;
}
}
diff --git a/src/clients/gtkpaludis/libgtkpaludis/versions_list_model.cc b/src/clients/gtkpaludis/libgtkpaludis/versions_list_model.cc
index 723c2f1..b85125d 100644
--- a/src/clients/gtkpaludis/libgtkpaludis/versions_list_model.cc
+++ b/src/clients/gtkpaludis/libgtkpaludis/versions_list_model.cc
@@ -12,6 +12,7 @@
#include <paludis/package_database.hh>
#include <paludis/query.hh>
#include <paludis/package_id.hh>
+#include <paludis/mask.hh>
#include <libwrapiter/libwrapiter_forward_iterator.hh>
#include <libwrapiter/libwrapiter_output_iterator.hh>
#include <list>
@@ -114,53 +115,16 @@ VersionsListModel::populate_in_paludis_thread()
p != p_end ; ++p)
{
bool prefer_default(true);
-
- MaskReasons mask_reasons(_imp->query_window->environment()->mask_reasons(**p));
std::string mr_string;
- for (MaskReason m(MaskReason(0)) ; m < last_mr ;
- m = MaskReason(static_cast<int>(m) + 1))
+ for (PackageID::MasksIterator m((*p)->begin_masks()), m_end((*p)->end_masks()) ;
+ m != m_end ; ++m)
{
- if (! mask_reasons[m])
- continue;
-
prefer_default = false;
if (! mr_string.empty())
mr_string.append(", ");
- switch (m)
- {
- case mr_keyword:
- mr_string.append("keyword");
- break;
- case mr_user_mask:
- mr_string.append("user mask");
- break;
- case mr_profile_mask:
- mr_string.append("profile mask");
- break;
- case mr_repository_mask:
- mr_string.append("repository mask");
- break;
- case mr_eapi:
- mr_string.append("EAPI");
- break;
- case mr_license:
- mr_string.append("licence");
- break;
- case mr_by_association:
- mr_string.append("by association");
- break;
- case mr_chost:
- mr_string.append("wrong CHOST");
- break;
- case mr_breaks_portage:
- mr_string.append("breaks Portage");
- break;
-
- case last_mr:
- break;
- }
+ mr_string.append(m->description());
}
data->items.push_back(PopulateDataItem(*p, mr_string, prefer_default));
diff --git a/src/clients/inquisitio/do_search.cc b/src/clients/inquisitio/do_search.cc
index 7d5d203..75e5004 100644
--- a/src/clients/inquisitio/do_search.cc
+++ b/src/clients/inquisitio/do_search.cc
@@ -109,7 +109,7 @@ do_search(const Environment & env)
tr1::shared_ptr<const PackageID> display_entry(*preferred_entries->last());
for (PackageIDSequence::Iterator i(preferred_entries->begin()),
i_end(preferred_entries->end()) ; i != i_end ; ++i)
- if (! env.mask_reasons(**i).any())
+ if (! (*i)->masked())
display_entry = *i;
bool match(false);
diff --git a/src/clients/paludis/install.cc b/src/clients/paludis/install.cc
index d46259a..8477298 100644
--- a/src/clients/paludis/install.cc
+++ b/src/clients/paludis/install.cc
@@ -48,11 +48,13 @@
#include <paludis/util/system.hh>
#include <paludis/dep_list/exceptions.hh>
+#include <paludis/dep_list/override_functions.hh>
#include <paludis/hook.hh>
#include <paludis/query.hh>
#include <paludis/eapi.hh>
#include <paludis/metadata_key.hh>
+#include <paludis/mask.hh>
#include <libwrapiter/libwrapiter_forward_iterator.hh>
#include <libwrapiter/libwrapiter_output_iterator.hh>
@@ -439,16 +441,19 @@ do_install(tr1::shared_ptr<Environment> env)
for (args::StringSetArg::Iterator a(CommandLine::get_instance()->dl_override_masks.begin_args()),
a_end(CommandLine::get_instance()->dl_override_masks.end_args()) ; a != a_end ; ++a)
{
+ if (! options.override_masks)
+ options.override_masks.reset(new DepListOverrideMasksFunctions);
+
+ using namespace tr1::placeholders;
+
if (*a == "tilde-keyword")
- options.override_masks += dl_override_tilde_keywords;
+ options.override_masks->push_back(tr1::bind(&override_tilde_keywords, env.get(), _1, _2));
else if (*a == "unkeyworded")
- options.override_masks += dl_override_unkeyworded;
+ options.override_masks->push_back(tr1::bind(&override_unkeyworded, env.get(), _1, _2));
else if (*a == "repository")
- options.override_masks += dl_override_repository_masks;
- else if (*a == "profile")
- options.override_masks += dl_override_repository_masks;
+ options.override_masks->push_back(tr1::bind(&override_repository_masks, _2));
else if (*a == "license")
- options.override_masks += dl_override_licenses;
+ options.override_masks->push_back(tr1::bind(&override_license, _2));
else
throw args::DoHelp("bad value for --dl-override-masks");
}
@@ -641,44 +646,15 @@ do_install(tr1::shared_ptr<Environment> env)
cerr << " * " << colour(cl_package_name, **pp) << ": Masked by ";
bool need_comma(false);
- MaskReasons m(env->mask_reasons(**pp));
- for (unsigned mm = 0 ; mm < last_mr ; ++mm)
- if (m[static_cast<MaskReason>(mm)])
- {
- if (need_comma)
- cerr << ", ";
- cerr << MaskReason(mm);
-
- if (mr_eapi == mm)
- {
- std::string eapi_str((*pp)->eapi()->name);
-
- if (eapi_str == "UNKNOWN")
- cerr << " ( " << colour(cl_masked, eapi_str) <<
- " ) (probably a broken ebuild)";
- else
- cerr << " ( " << colour(cl_masked, eapi_str) << " )";
- }
- else if (mr_license == mm)
- {
- if ((*pp)->license_key())
- {
- cerr << " ";
- LicenceDisplayer ld(cerr, env.get(), *pp);
- (*pp)->license_key()->value()->accept(ld);
- }
- }
- else if (mr_keyword == mm)
- {
- if ((*pp)->keywords_key())
- {
- cerr << " ( " << colour(cl_masked, join((*pp)->keywords_key()->value()->begin(),
- (*pp)->keywords_key()->value()->end(), " ")) << " )";
- }
- }
-
- need_comma = true;
- }
+ for (PackageID::MasksIterator m((*pp)->begin_masks()), m_end((*pp)->end_masks()) ;
+ m != m_end ; ++m)
+ {
+ if (need_comma)
+ cerr << ", ";
+ cerr << m->description();
+
+ need_comma = true;
+ }
cerr << endl;
}
}
diff --git a/src/clients/paludis/query.cc b/src/clients/paludis/query.cc
index 9cfe7c7..841edfa 100644
--- a/src/clients/paludis/query.cc
+++ b/src/clients/paludis/query.cc
@@ -63,19 +63,20 @@ namespace
void do_one_package_query(
const tr1::shared_ptr<Environment> env,
- MaskReasons & mask_reasons_to_explain,
+ const tr1::shared_ptr<Map<char, std::string> > & masks_to_explain,
tr1::shared_ptr<PackageDepSpec> spec)
{
QueryTask query(env);
query.show(*spec);
- mask_reasons_to_explain |= query.mask_reasons_to_explain();
+ std::copy(query.masks_to_explain()->begin(), query.masks_to_explain()->end(),
+ masks_to_explain->inserter());
cout << endl;
}
void do_one_set_query(
const tr1::shared_ptr<Environment>,
const std::string & q,
- MaskReasons &,
+ const tr1::shared_ptr<Map<char, std::string> > &,
tr1::shared_ptr<const SetSpecTree::ConstItem> set)
{
cout << "* " << colour(cl_package_name, q) << endl;
@@ -88,7 +89,7 @@ void do_one_set_query(
void do_one_query(
const tr1::shared_ptr<Environment> env,
const std::string & q,
- MaskReasons & mask_reasons_to_explain)
+ const tr1::shared_ptr<Map<char, std::string> > & masks_to_explain)
{
Context local_context("When handling query '" + q + "':");
@@ -113,9 +114,9 @@ void do_one_query(
spec.reset(new PackageDepSpec(q, pds_pm_permissive));
if (spec)
- do_one_package_query(env, mask_reasons_to_explain, spec);
+ do_one_package_query(env, masks_to_explain, spec);
else
- do_one_set_query(env, q, mask_reasons_to_explain, set);
+ do_one_set_query(env, q, masks_to_explain, set);
}
int do_query(tr1::shared_ptr<Environment> env)
@@ -124,7 +125,7 @@ int do_query(tr1::shared_ptr<Environment> env)
Context context("When performing query action from command line:");
- MaskReasons mask_reasons_to_explain;
+ tr1::shared_ptr<Map<char, std::string> > masks_to_explain(new Map<char, std::string>());
CommandLine::ParametersIterator q(CommandLine::get_instance()->begin_parameters()),
q_end(CommandLine::get_instance()->end_parameters());
@@ -132,7 +133,7 @@ int do_query(tr1::shared_ptr<Environment> env)
{
try
{
- do_one_query(env, *q, mask_reasons_to_explain);
+ do_one_query(env, *q, masks_to_explain);
}
catch (const AmbiguousPackageNameError & e)
{
@@ -163,53 +164,13 @@ int do_query(tr1::shared_ptr<Environment> env)
}
}
- if (mask_reasons_to_explain.any())
+ if (! masks_to_explain->empty())
{
cout << colour(cl_heading, "Key to mask reasons:") << endl << endl;
- /* use for/case to get compiler warnings when new mr_ are added */
- for (MaskReason m(MaskReason(0)) ; m < last_mr ;
- m = MaskReason(static_cast<int>(m) + 1))
- {
- if (! mask_reasons_to_explain[m])
- continue;
-
- switch (m)
- {
- case mr_keyword:
- cout << "* " << colour(cl_masked, "K") << ": keyword";
- break;
- case mr_user_mask:
- cout << "* " << colour(cl_masked, "U") << ": user mask";
- break;
- case mr_profile_mask:
- cout << "* " << colour(cl_masked, "P") << ": profile mask";
- break;
- case mr_repository_mask:
- cout << "* " << colour(cl_masked, "R") << ": repository mask";
- break;
- case mr_eapi:
- cout << "* " << colour(cl_masked, "E") << ": EAPI";
- break;
- case mr_license:
- cout << "* " << colour(cl_masked, "L") << ": licence";
- break;
- case mr_by_association:
- cout << "* " << colour(cl_masked, "A") << ": by association";
- break;
- case mr_chost:
- cout << "* " << colour(cl_masked, "C") << ": wrong CHOST";
- break;
- case mr_breaks_portage:
- cout << "* " << colour(cl_masked, "B") << ": breaks Portage";
- break;
-
- case last_mr:
- break;
- }
-
- cout << endl;
- }
+ for (Map<char, std::string>::Iterator m(masks_to_explain->begin()), m_end(masks_to_explain->end()) ;
+ m != m_end ; ++m)
+ cout << "* " << colour(cl_masked, m->first) << ": " << m->second << endl;
cout << endl;
}
diff --git a/src/clients/paludis/report.cc b/src/clients/paludis/report.cc
index 7735e09..8ae6f5d 100644
--- a/src/clients/paludis/report.cc
+++ b/src/clients/paludis/report.cc
@@ -20,6 +20,8 @@
#include "report.hh"
#include <src/output/colour.hh>
#include <paludis/tasks/report_task.hh>
+#include <paludis/mask.hh>
+#include <paludis/package_id.hh>
#include <iostream>
/** \file
@@ -51,7 +53,7 @@ namespace
virtual void on_report_check_package_pre(const QualifiedPackageName & p);
virtual void on_report_package_success(const PackageID & id);
virtual void on_report_package_failure_pre(const PackageID & id);
- virtual void on_report_package_is_masked(const PackageID & id, const MaskReasons & mr);
+ virtual void on_report_package_is_masked(const PackageID & id);
virtual void on_report_package_is_vulnerable_pre(const PackageID & id);
virtual void on_report_package_is_vulnerable(const PackageID & id, const std::string & tag);
virtual void on_report_package_is_vulnerable_post(const PackageID & id);
@@ -90,19 +92,19 @@ namespace
}
void
- OurReportTask::on_report_package_is_masked(const PackageID &, const MaskReasons & mr)
+ OurReportTask::on_report_package_is_masked(const PackageID & id)
{
cout << endl << " Masked by: ";
bool comma(false);
- for (unsigned i(0), i_end(last_mr); i != i_end; ++i)
- if (mr[static_cast<MaskReason>(i)])
- {
- if (comma)
- cout << ", ";
- cout << colour(cl_masked, MaskReason(i));
- comma = true;
- }
+ for (PackageID::MasksIterator m(id.begin_masks()), m_end(id.end_masks()) ;
+ m != m_end ; ++m)
+ {
+ if (comma)
+ cout << ", ";
+ cout << colour(cl_masked, m->description());
+ comma = true;
+ }
++_n_errors;
}
diff --git a/src/output/console_install_task.cc b/src/output/console_install_task.cc
index 175669d..f413163 100644
--- a/src/output/console_install_task.cc
+++ b/src/output/console_install_task.cc
@@ -37,6 +37,7 @@
#include <paludis/eapi.hh>
#include <paludis/package_id.hh>
#include <paludis/metadata_key.hh>
+#include <paludis/mask.hh>
#include <libwrapiter/libwrapiter_forward_iterator.hh>
#include <libwrapiter/libwrapiter_output_iterator.hh>
@@ -1135,51 +1136,55 @@ EntryDepTagDisplayer::visit(const GeneralSetDepTag & tag)
text() = tag.short_text(); // + "<" + tag->source() + ">";
}
-void
-ConsoleInstallTask::display_merge_list_entry_mask_reasons(const DepListEntry & e)
+namespace
{
- MaskReasons r(environment()->mask_reasons(*e.package_id));
- bool need_comma(false);
-
- output_no_endl(" Masked by: ");
+ struct MaskDisplayer :
+ ConstVisitor<MaskVisitorTypes>
+ {
+ std::ostringstream s;
- for (unsigned mm = 0 ; mm < last_mr ; ++mm)
- if (r[static_cast<MaskReason>(mm)])
+ void visit(const UnacceptedMask & m)
{
- if (need_comma)
- output_no_endl(", ");
- output_no_endl(stringify(MaskReason(mm)));
+ s << m.description();
+ }
- if (mr_eapi == mm)
- {
- std::string eapi_str(e.package_id->eapi()->name);
+ void visit(const RepositoryMask & m)
+ {
+ s << m.description();
+ }
- if (eapi_str == "UNKNOWN")
- output_no_endl(" ( " + render_as_masked(eapi_str) + " ) (probably a broken ebuild)");
- else
- output_no_endl(" ( " + render_as_masked(eapi_str) + " )");
- }
- else if (mr_license == mm)
- {
- if (e.package_id->license_key())
- {
- output_no_endl(" ");
+ void visit(const UserMask & m)
+ {
+ s << m.description();
+ }
- LicenceDisplayer ld(output_stream(), environment(), e.package_id);
- e.package_id->license_key()->value()->accept(ld);
- }
- }
- else if (mr_keyword == mm)
- {
- if (e.package_id->keywords_key())
- {
- tr1::shared_ptr<const KeywordNameSet> keywords(e.package_id->keywords_key()->value());
- output_no_endl(" ( " + render_as_masked(join(keywords->begin(), keywords->end(), " ")) + " )");
- }
- }
+ void visit(const UnsupportedMask & m)
+ {
+ s << m.description();
+ }
- need_comma = true;
+ void visit(const AssociationMask & m)
+ {
+ s << m.description();
}
+ };
+}
+
+void
+ConsoleInstallTask::display_merge_list_entry_mask_reasons(const DepListEntry & e)
+{
+ bool need_comma(false);
+ output_no_endl(" Masked by: ");
+
+ for (PackageID::MasksIterator m(e.package_id->begin_masks()), m_end(e.package_id->end_masks()) ;
+ m != m_end ; ++m)
+ {
+ if (need_comma)
+ output_no_endl(", ");
+ MaskDisplayer d;
+ m->accept(d);
+ output_no_endl(d.s.str());
+ }
output_endl();
}
diff --git a/src/output/console_query_task.cc b/src/output/console_query_task.cc
index 1f5edb0..acab258 100644
--- a/src/output/console_query_task.cc
+++ b/src/output/console_query_task.cc
@@ -25,9 +25,12 @@
#include <paludis/util/visitor-impl.hh>
#include <paludis/util/private_implementation_pattern-impl.hh>
#include <paludis/util/set.hh>
+#include <paludis/util/map.hh>
+#include <paludis/util/map-impl.hh>
#include <libwrapiter/libwrapiter_forward_iterator.hh>
#include <libwrapiter/libwrapiter_output_iterator.hh>
#include <paludis/query.hh>
+#include <paludis/mask.hh>
#include <paludis/metadata_key.hh>
#include <paludis/eapi.hh>
#include <paludis/package_database.hh>
@@ -38,16 +41,19 @@
using namespace paludis;
+template class Map<char, std::string>;
+
namespace paludis
{
template<>
struct Implementation<ConsoleQueryTask>
{
const Environment * const env;
- mutable MaskReasons mask_reasons_to_explain;
+ mutable tr1::shared_ptr<Map<char, std::string> > masks_to_explain;
Implementation(const Environment * const e) :
- env(e)
+ env(e),
+ masks_to_explain(new Map<char, std::string>)
{
}
};
@@ -81,7 +87,7 @@ ConsoleQueryTask::show(const PackageDepSpec & a, tr1::shared_ptr<const PackageID
display_entry = *preferred_entries->last();
for (PackageIDSequence::Iterator i(preferred_entries->begin()),
i_end(preferred_entries->end()) ; i != i_end ; ++i)
- if (! _imp->env->mask_reasons(**i).any())
+ if (! (*i)->masked())
display_entry = *i;
}
@@ -134,53 +140,17 @@ ConsoleQueryTask::display_versions_by_repository(const PackageDepSpec &,
right_column.append(render_as_slot_name("{:" + old_slot + "} "));
old_slot = slot_name;
- const MaskReasons masks(_imp->env->mask_reasons(**e));
-
- if (masks.none())
+ if (! (*e)->masked())
right_column.append(render_as_visible((*e)->canonical_form(idcf_version)));
else
{
std::string reasons;
- for (MaskReason m(MaskReason(0)) ; m < last_mr ;
- m = MaskReason(static_cast<int>(m) + 1))
+ for (PackageID::MasksIterator m((*e)->begin_masks()), m_end((*e)->end_masks()) ;
+ m != m_end ; ++m)
{
- if (! masks[m])
- continue;
-
- switch (m)
- {
- 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 last_mr:
- break;
- }
+ reasons.append(stringify(m->key()));
+ _imp->masks_to_explain->insert(m->key(), m->description());
}
- _imp->mask_reasons_to_explain |= masks;
right_column.append(render_as_masked("(" + (*e)->canonical_form(idcf_version) + ")" + reasons));
}
@@ -517,9 +487,9 @@ ConsoleQueryTask::display_metadata_iuse(const std::string & k, const std::string
}
}
-const MaskReasons
-ConsoleQueryTask::mask_reasons_to_explain() const
+const tr1::shared_ptr<const Map<char, std::string> >
+ConsoleQueryTask::masks_to_explain() const
{
- return _imp->mask_reasons_to_explain;
+ return _imp->masks_to_explain;
}
diff --git a/src/output/console_query_task.hh b/src/output/console_query_task.hh
index 8ab3377..46d44f4 100644
--- a/src/output/console_query_task.hh
+++ b/src/output/console_query_task.hh
@@ -25,8 +25,10 @@
#include <paludis/metadata_key-fwd.hh>
#include <paludis/name-fwd.hh>
#include <paludis/package_id-fwd.hh>
-#include <paludis/mask_reasons.hh>
+#include <paludis/mask-fwd.hh>
#include <paludis/util/private_implementation_pattern.hh>
+#include <paludis/util/map-fwd.hh>
+#include <paludis/util/tr1_memory.hh>
#include <src/output/console_task.hh>
namespace paludis
@@ -69,7 +71,7 @@ namespace paludis
virtual bool want_deps() const = 0;
virtual bool want_raw() const = 0;
- const MaskReasons mask_reasons_to_explain() const;
+ const tr1::shared_ptr<const Map<char, std::string> > masks_to_explain() const;
};
}