From d465cb3a77b010a7c0ab791e69012143ad5405b7 Mon Sep 17 00:00:00 2001
From: Ciaran McCreesh
Date: Mon, 21 Feb 2011 19:54:57 +0000
Subject: Allow unmasking by token kind in Paludis configs
---
doc/configuration/packagemask.html.part.in | 7 ++
paludis/environments/paludis/package_mask_conf.cc | 83 +++++++++++++++++------
paludis/environments/paludis/package_mask_conf.hh | 2 +-
paludis/environments/paludis/paludis_config.cc | 4 +-
vim/syntax/paludis-package-mask-conf.vim | 8 ++-
5 files changed, 78 insertions(+), 26 deletions(-)
diff --git a/doc/configuration/packagemask.html.part.in b/doc/configuration/packagemask.html.part.in
index b913ccd8d..1b3e05e06 100644
--- a/doc/configuration/packagemask.html.part.in
+++ b/doc/configuration/packagemask.html.part.in
@@ -15,6 +15,10 @@ configuration files which may be bash files (package_mask.bash
etc)
specifications in package_mask.conf
. If a package version is
matched by entries in both files, it is unmasked.
+Exheres layout repositories allow masks to be categories by a token such as "security" or "scm". To unmask a package,
+but only if its token is of a particular kind, follow the specification by one or more whitespace separated token names.
+If token names are specified this way, an unmask is only taken if at least one of the tokens matches the mask.
+
Example
An example package_mask.conf
:
@@ -32,5 +36,8 @@ sys-apps/portage
# Ignore repository and profile masks for things in the toolchain overlay
*/*::toolchain
+
+# (Exheres layout repositories only) ignore security masks for PHP
+dev-lang/php security
diff --git a/paludis/environments/paludis/package_mask_conf.cc b/paludis/environments/paludis/package_mask_conf.cc
index 5287fc7e1..91cd7dbf1 100644
--- a/paludis/environments/paludis/package_mask_conf.cc
+++ b/paludis/environments/paludis/package_mask_conf.cc
@@ -37,14 +37,16 @@
#include
#include
#include
+#include
#include
+#include
#include
#include
using namespace paludis;
using namespace paludis::paludis_environment;
-typedef std::list > > Sets;
+typedef std::list, std::set > > > Sets;
namespace paludis
{
@@ -52,19 +54,21 @@ namespace paludis
struct Imp
{
const PaludisEnvironment * const env;
- std::list > masks;
+ const bool allow_reasons;
+ std::list, std::set > > masks;
mutable Sets sets;
mutable Mutex set_mutex;
- Imp(const PaludisEnvironment * const e) :
- env(e)
+ Imp(const PaludisEnvironment * const e, const bool a) :
+ env(e),
+ allow_reasons(a)
{
}
};
}
-PackageMaskConf::PackageMaskConf(const PaludisEnvironment * const e) :
- _imp(e)
+PackageMaskConf::PackageMaskConf(const PaludisEnvironment * const e, const bool a) :
+ _imp(e, a)
{
}
@@ -84,28 +88,52 @@ PackageMaskConf::add(const FSPath & filename)
for (LineConfigFile::ConstIterator line(f->begin()), line_end(f->end()) ;
line != line_end ; ++line)
{
+ std::vector tokens;
+ tokenise_whitespace(*line, std::back_inserter(tokens));
+
+ if (tokens.empty())
+ continue;
+
+ std::string spec(tokens.at(0));
+ tokens.erase(tokens.begin(), tokens.begin() + 1);
+
+ std::set reasons(tokens.begin(), tokens.end());
+ if ((! reasons.empty()) && (! _imp->allow_reasons))
+ throw ConfigurationError("Only one token per line is allowed in '" + stringify(filename) + "'");
+
try
{
- _imp->masks.push_back(std::shared_ptr(std::make_shared(parse_user_package_dep_spec(
- *line, _imp->env,
- { updso_allow_wildcards, updso_no_disambiguation, updso_throw_if_set }))));
+ _imp->masks.push_back(std::make_pair(std::shared_ptr(std::make_shared(parse_user_package_dep_spec(
+ spec, _imp->env,
+ { updso_allow_wildcards, updso_no_disambiguation, updso_throw_if_set }))), reasons));
}
catch (const GotASetNotAPackageDepSpec &)
{
- _imp->sets.push_back(std::make_pair(SetName(*line), make_null_shared_ptr()));
+ _imp->sets.push_back(std::make_pair(SetName(*line), std::make_pair(make_null_shared_ptr(), reasons)));
}
}
}
bool
-PackageMaskConf::query(const std::shared_ptr & e, const std::string &) const
+PackageMaskConf::query(const std::shared_ptr & e, const std::string & r) const
{
using namespace std::placeholders;
- if (indirect_iterator(_imp->masks.end()) != std::find_if(
- indirect_iterator(_imp->masks.begin()),
- indirect_iterator(_imp->masks.end()),
- std::bind(&match_package, std::ref(*_imp->env), _1, std::cref(e), make_null_shared_ptr(), MatchPackageOptions())))
- return true;
+
+ for (auto i(_imp->masks.begin()), i_end(_imp->masks.end()) ;
+ i != i_end ; ++i)
+ if (match_package(*_imp->env, *i->first, e, make_null_shared_ptr(), MatchPackageOptions()))
+ {
+ if (r.empty())
+ {
+ if (i->second.empty())
+ return true;
+ }
+ else
+ {
+ if (i->second.empty() || (i->second.end() != i->second.find(r)))
+ return true;
+ }
+ }
{
Lock lock(_imp->set_mutex);
@@ -113,19 +141,30 @@ PackageMaskConf::query(const std::shared_ptr & e, const std::st
for (Sets::iterator it(_imp->sets.begin()),
it_end(_imp->sets.end()); it_end != it; ++it)
{
- if (! it->second)
+ if (! it->second.first)
{
- it->second = _imp->env->set(it->first);
- if (! it->second)
+ it->second.first = _imp->env->set(it->first);
+ if (! it->second.first)
{
Log::get_instance()->message("paludis_environment.package_mask.unknown_set", ll_warning, lc_no_context) << "Set name '"
<< it->first << "' does not exist";
- it->second = std::make_shared(std::make_shared());
+ it->second.first = std::make_shared(std::make_shared());
}
}
- if (match_package_in_set(*_imp->env, *it->second, e, { }))
- return true;
+ if (match_package_in_set(*_imp->env, *it->second.first, e, { }))
+ {
+ if (r.empty())
+ {
+ if (it->second.second.empty())
+ return true;
+ }
+ else
+ {
+ if (it->second.second.empty() || (it->second.second.end() != it->second.second.find(r)))
+ return true;
+ }
+ }
}
}
diff --git a/paludis/environments/paludis/package_mask_conf.hh b/paludis/environments/paludis/package_mask_conf.hh
index cb927d073..931161386 100644
--- a/paludis/environments/paludis/package_mask_conf.hh
+++ b/paludis/environments/paludis/package_mask_conf.hh
@@ -47,7 +47,7 @@ namespace paludis
///\name Basic operations
///\{
- PackageMaskConf(const PaludisEnvironment * const);
+ PackageMaskConf(const PaludisEnvironment * const, const bool allow_reasons);
~PackageMaskConf();
PackageMaskConf(const PackageMaskConf &) = delete;
diff --git a/paludis/environments/paludis/paludis_config.cc b/paludis/environments/paludis/paludis_config.cc
index d69ff6ed6..1376648bb 100644
--- a/paludis/environments/paludis/paludis_config.cc
+++ b/paludis/environments/paludis/paludis_config.cc
@@ -218,8 +218,8 @@ namespace paludis
keywords_conf(std::make_shared(e)),
use_conf(std::make_shared(e)),
licenses_conf(std::make_shared(e)),
- package_mask_conf(std::make_shared(e)),
- package_unmask_conf(std::make_shared(e)),
+ package_mask_conf(std::make_shared(e, false)),
+ package_unmask_conf(std::make_shared(e, true)),
mirrors_conf(std::make_shared(e)),
output_conf(std::make_shared(e)),
suggestions_conf(std::make_shared(e)),
diff --git a/vim/syntax/paludis-package-mask-conf.vim b/vim/syntax/paludis-package-mask-conf.vim
index 2b9e9a676..32bf8d139 100644
--- a/vim/syntax/paludis-package-mask-conf.vim
+++ b/vim/syntax/paludis-package-mask-conf.vim
@@ -1,7 +1,7 @@
" Vim syntax file
" Language: Paludis package_{un,}mask.conf files
" Author: Ciaran McCreesh
-" Copyright: Copyright (c) 2007, 2010 Ciaran McCreesh
+" Copyright: Copyright (c) 2007, 2010, 2011 Ciaran McCreesh
" Licence: You may redistribute this under the same terms as Vim itself
"
" Syntax highlighting for Paludis package_{un,}mask.conf files.
@@ -19,13 +19,19 @@ syn region PaludisPackageMaskConfComment start=/^\s*#/ end=/$/
syn match PaludisPackageMaskConfPDS /^[^ \t#\/]\+\/[^ \t#\/]\+\s*/
\ contains=PaludisPackageMaskConfWildcard
+ \ nextgroup=PaludisPackageMaskToken skipwhite
syn match PaludisPackageMaskConfWildcard contained /\(\*\/\@=\|\/\@<=\*\)/
+ \ nextgroup=PaludisPackageMaskToken skipwhite
syn match PaludisPackageMaskConfSet /^[^ \t#\/]\+\S\@!/
+ \ nextgroup=PaludisPackageMaskToken skipwhite
+syn match PaludisPackageMaskToken /\w\+/
+ \ contained skipwhite nextgroup=PaludisPackageMaskToken
hi def link PaludisPackageMaskConfComment Comment
hi def link PaludisPackageMaskConfPDS Identifier
hi def link PaludisPackageMaskConfSet Special
hi def link PaludisPackageMaskConfWildcard Special
+hi def link PaludisPackageMaskToken Macro
let b:current_syntax = "paludis-package-mask-conf"
--
cgit v1.2.3