aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-02-21 19:54:57 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-02-26 15:25:00 +0000
commitd465cb3a77b010a7c0ab791e69012143ad5405b7 (patch)
tree7b64a6d88356296a19219f89789d28322fe3a419
parent393adbc779c4bf332e9bb966a14f73fea002ae41 (diff)
downloadpaludis-d465cb3a77b010a7c0ab791e69012143ad5405b7.tar.gz
paludis-d465cb3a77b010a7c0ab791e69012143ad5405b7.tar.xz
Allow unmasking by token kind in Paludis configs
-rw-r--r--doc/configuration/packagemask.html.part.in7
-rw-r--r--paludis/environments/paludis/package_mask_conf.cc83
-rw-r--r--paludis/environments/paludis/package_mask_conf.hh2
-rw-r--r--paludis/environments/paludis/paludis_config.cc4
-rw-r--r--vim/syntax/paludis-package-mask-conf.vim8
5 files changed, 78 insertions, 26 deletions
diff --git a/doc/configuration/packagemask.html.part.in b/doc/configuration/packagemask.html.part.in
index b913ccd..1b3e05e 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 (<code>package_mask.bash</code> etc)
specifications in <code>package_mask.conf</code>. If a package version is
matched by entries in both files, it is unmasked.</p>
+<p>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.</p>
+
<h2>Example</h2>
<p>An example <code>package_mask.conf</code>:</p>
@@ -32,5 +36,8 @@ sys-apps/portage
<pre>
# 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
</pre>
diff --git a/paludis/environments/paludis/package_mask_conf.cc b/paludis/environments/paludis/package_mask_conf.cc
index 5287fc7..91cd7db 100644
--- a/paludis/environments/paludis/package_mask_conf.cc
+++ b/paludis/environments/paludis/package_mask_conf.cc
@@ -37,14 +37,16 @@
#include <paludis/util/mutex.hh>
#include <paludis/util/hashes.hh>
#include <paludis/util/make_null_shared_ptr.hh>
+#include <vector>
#include <list>
+#include <set>
#include <algorithm>
#include <functional>
using namespace paludis;
using namespace paludis::paludis_environment;
-typedef std::list<std::pair<SetName, std::shared_ptr<const SetSpecTree> > > Sets;
+typedef std::list<std::pair<SetName, std::pair<std::shared_ptr<const SetSpecTree>, std::set<std::string> > > > Sets;
namespace paludis
{
@@ -52,19 +54,21 @@ namespace paludis
struct Imp<PackageMaskConf>
{
const PaludisEnvironment * const env;
- std::list<std::shared_ptr<const PackageDepSpec> > masks;
+ const bool allow_reasons;
+ std::list<std::pair<std::shared_ptr<const PackageDepSpec>, std::set<std::string> > > 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<std::string> 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<std::string> 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<PackageDepSpec>(std::make_shared<PackageDepSpec>(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<PackageDepSpec>(std::make_shared<PackageDepSpec>(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<const PackageID> & e, const std::string &) const
+PackageMaskConf::query(const std::shared_ptr<const PackageID> & 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<const PackageID> & 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<SetSpecTree>(std::make_shared<AllDepSpec>());
+ it->second.first = std::make_shared<SetSpecTree>(std::make_shared<AllDepSpec>());
}
}
- 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 cb927d0..9311613 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 d69ff6e..1376648 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<KeywordsConf>(e)),
use_conf(std::make_shared<UseConf>(e)),
licenses_conf(std::make_shared<LicensesConf>(e)),
- package_mask_conf(std::make_shared<PackageMaskConf>(e)),
- package_unmask_conf(std::make_shared<PackageMaskConf>(e)),
+ package_mask_conf(std::make_shared<PackageMaskConf>(e, false)),
+ package_unmask_conf(std::make_shared<PackageMaskConf>(e, true)),
mirrors_conf(std::make_shared<MirrorsConf>(e)),
output_conf(std::make_shared<OutputConf>(e)),
suggestions_conf(std::make_shared<SuggestionsConf>(e)),
diff --git a/vim/syntax/paludis-package-mask-conf.vim b/vim/syntax/paludis-package-mask-conf.vim
index 2b9e9a6..32bf8d1 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"