[Aptitude-devel] [PATCH 1/3] Add search pattern: ~f = ?forbidden = ?version(FORBIDDEN)
Marcel Partap
mpartap at gmx.net
Fri Jun 29 13:43:33 BST 2012
---
src/defaults.cc | 4 ++++
src/generic/apt/matching/compare_patterns.cc | 3 +++
src/generic/apt/matching/match.cc | 17 +++++++++++++++++
src/generic/apt/matching/parse.cc | 10 +++++++++-
src/generic/apt/matching/pattern.cc | 1 +
src/generic/apt/matching/pattern.h | 18 ++++++++++++++++++
src/generic/apt/matching/serialize.cc | 4 ++++
src/pkg_item.cc | 5 ++++-
8 files changed, 60 insertions(+), 2 deletions(-)
diff --git a/src/defaults.cc b/src/defaults.cc
index 73d91dd..0df5ada 100644
--- a/src/defaults.cc
+++ b/src/defaults.cc
@@ -92,6 +92,7 @@ static void init_styles()
cw::set_style("PkgToHold", cw::style_fg(COLOR_WHITE) + cw::style_attrs_on(A_REVERSE));
cw::set_style("PkgToRemove", cw::style_fg(COLOR_MAGENTA) + cw::style_attrs_on(A_REVERSE));
cw::set_style("PkgBroken", cw::style_fg(COLOR_RED) + cw::style_attrs_on(A_REVERSE));
+ cw::set_style("PkgForbidden", cw::style_fg(COLOR_BLUE) + cw::style_attrs_on(A_REVERSE));
cw::set_style("PkgToInstall", cw::style_fg(COLOR_GREEN) + cw::style_attrs_on(A_REVERSE));
cw::set_style("PkgToUpgrade", cw::style_fg(COLOR_CYAN) + cw::style_attrs_on(A_REVERSE));
cw::set_style("PkgToDowngrade", cw::style_attrs_on(A_BOLD));
@@ -107,6 +108,9 @@ static void init_styles()
cw::style_fg(COLOR_MAGENTA));
cw::set_style("PkgBrokenHighlighted",
cw::style_fg(COLOR_RED));
+ cw::set_style("PkgForbiddenHighlighted",
+ cw::style_fg(COLOR_MAGENTA) + cw::style_attrs_on(A_DIM) +
+ cw::style_attrs_flip(A_REVERSE));
cw::set_style("PkgToInstallHighlighted",
cw::style_fg(COLOR_GREEN));
cw::set_style("PkgToUpgradeHighlighted",
diff --git a/src/generic/apt/matching/compare_patterns.cc b/src/generic/apt/matching/compare_patterns.cc
index f8414ae..33ba16a 100644
--- a/src/generic/apt/matching/compare_patterns.cc
+++ b/src/generic/apt/matching/compare_patterns.cc
@@ -183,6 +183,9 @@ namespace aptitude
p2->get_for_pattern());
}
+ case pattern::forbidden_version:
+ return 0;
+
case pattern::foreign_architecture:
return 0;
diff --git a/src/generic/apt/matching/match.cc b/src/generic/apt/matching/match.cc
index 2054529..a27d181 100644
--- a/src/generic/apt/matching/match.cc
+++ b/src/generic/apt/matching/match.cc
@@ -1165,6 +1165,18 @@ namespace aptitude
return NULL;
break;
+ case pattern::forbidden_version:
+ {
+ pkgCache::PkgIterator pkg(target.get_package_iterator(cache));
+ aptitudeDepCache::aptitude_state &estate = cache.get_ext_state(pkg);
+ if(target.get_has_version() &&
+ target.get_version_iterator(cache).VerStr() == estate.forbidver)
+ return match::make_atomic(p);
+ else
+ return NULL;
+ }
+ break;
+
case pattern::foreign_architecture:
if(!target.get_has_version())
return NULL;
@@ -2106,6 +2118,7 @@ namespace aptitude
case pattern::equal:
case pattern::exact_name:
case pattern::false_tp:
+ case pattern::forbidden_version:
case pattern::foreign_architecture:
case pattern::garbage:
case pattern::install_version:
@@ -2319,6 +2332,7 @@ namespace aptitude
case pattern::essential:
case pattern::equal:
case pattern::false_tp:
+ case pattern::forbidden_version:
case pattern::foreign_architecture:
case pattern::garbage:
case pattern::install_version:
@@ -2445,6 +2459,7 @@ namespace aptitude
case pattern::essential:
case pattern::equal:
case pattern::false_tp:
+ case pattern::forbidden_version:
case pattern::foreign_architecture:
case pattern::garbage:
case pattern::install_version:
@@ -2645,6 +2660,7 @@ namespace aptitude
case pattern::equal:
case pattern::exact_name:
case pattern::false_tp:
+ case pattern::forbidden_version:
case pattern::foreign_architecture:
case pattern::garbage:
case pattern::install_version:
@@ -2936,6 +2952,7 @@ namespace aptitude
case pattern::essential:
case pattern::equal:
case pattern::false_tp:
+ case pattern::forbidden_version:
case pattern::foreign_architecture:
case pattern::garbage:
case pattern::install_version:
diff --git a/src/generic/apt/matching/parse.cc b/src/generic/apt/matching/parse.cc
index f114cd8..fc697cc 100644
--- a/src/generic/apt/matching/parse.cc
+++ b/src/generic/apt/matching/parse.cc
@@ -118,6 +118,7 @@ namespace
term_type_exact_name,
term_type_false,
term_type_for,
+ term_type_forbidden,
term_type_garbage,
term_type_installed,
term_type_maintainer,
@@ -174,6 +175,7 @@ namespace
{ "false", term_type_false },
// ForTranslators: As in the sentence "for x = 5, do BLAH".
{ "for", term_type_for },
+ { "forbidden", term_type_forbidden },
{ "garbage", term_type_garbage },
{ "installed", term_type_installed },
{ "maintainer", term_type_maintainer },
@@ -760,7 +762,7 @@ ref_ptr<pattern> maybe_bind(const string &bound_variable,
}
/** \brief Return a ?version term giving consideration
- * to the special values CURRENT, CANDIDATE, TARGET.
+ * to the special values CURRENT, CANDIDATE, FORBIDDEN, TARGET.
*/
ref_ptr<pattern> parse_version(const string &version)
{
@@ -770,6 +772,8 @@ ref_ptr<pattern> parse_version(const string &version)
return pattern::make_install_version();
else if(version == "CANDIDATE")
return pattern::make_candidate_version();
+ else if(version == "FORBIDDEN")
+ return pattern::make_forbidden_version();
else
return pattern::make_version(version);
}
@@ -984,6 +988,8 @@ ref_ptr<pattern> parse_term_args(const string &term_name,
return pattern::make_false();
case term_type_for:
return parse_explicit_term(term_name, start, end, terminators, wide_context, partial, name_context);
+ case term_type_forbidden:
+ return pattern::make_forbidden_version();
case term_type_garbage:
return pattern::make_garbage();
case term_type_installed:
@@ -1225,6 +1231,8 @@ ref_ptr<pattern> parse_atom(string::const_iterator &start,
return pattern::make_true();
case 'U':
return pattern::make_upgradable();
+ case 'f':
+ return pattern::make_forbidden_version();
case 'o':
return pattern::make_obsolete();
case 'P':
diff --git a/src/generic/apt/matching/pattern.cc b/src/generic/apt/matching/pattern.cc
index 56cea31..99f4826 100644
--- a/src/generic/apt/matching/pattern.cc
+++ b/src/generic/apt/matching/pattern.cc
@@ -128,6 +128,7 @@ switch(p->get_type())
case pattern::equal:
case pattern::false_tp:
case pattern::foreign_architecture:
+ case pattern::forbidden_version:
case pattern::garbage:
case pattern::install_version:
case pattern::installed:
diff --git a/src/generic/apt/matching/pattern.h b/src/generic/apt/matching/pattern.h
index b1870ac..8583ec3 100644
--- a/src/generic/apt/matching/pattern.h
+++ b/src/generic/apt/matching/pattern.h
@@ -369,6 +369,11 @@ namespace aptitude
*
* Matches packages of foreign architectures.
*/
+ forbidden_version,
+ /** \brief ?version(FORBIDDEN)
+ *
+ * Matches package versions which are marked as forbidden.
+ */
foreign_architecture,
/** \brief ?garbage
*
@@ -1327,6 +1332,19 @@ namespace aptitude
// @}
+ /** \name forbidden_version term constructor. */
+
+ // @{
+
+ /** \brief Create a ?version(FORBIDDEN) term. */
+ static cwidget::util::ref_ptr<pattern>
+ make_forbidden_version()
+ {
+ return new pattern(forbidden_version);
+ }
+
+ // @}
+
/** \name foreign_architecture term constructor */
// @{
diff --git a/src/generic/apt/matching/serialize.cc b/src/generic/apt/matching/serialize.cc
index ea506b1..ecf567f 100644
--- a/src/generic/apt/matching/serialize.cc
+++ b/src/generic/apt/matching/serialize.cc
@@ -358,6 +358,10 @@ namespace aptitude
variable_name_stack.pop_back();
break;
+ case pattern::forbidden_version:
+ out << "?version(forbidden)";
+ break;
+
case pattern::foreign_architecture:
out << "?architecture(foreign)";
break;
diff --git a/src/pkg_item.cc b/src/pkg_item.cc
index e9d70df..f49b2ae 100644
--- a/src/pkg_item.cc
+++ b/src/pkg_item.cc
@@ -278,12 +278,15 @@ cw::style pkg_item::pkg_style(pkgCache::PkgIterator package, bool highlighted)
else
{
pkgDepCache::StateCache &state=(*apt_cache_file)[package];
+ aptitudeDepCache::aptitude_state &estate=(*apt_cache_file)->get_ext_state(package);
if(!state.InstBroken() &&
(state.NewInstall() || (state.iFlags&pkgDepCache::ReInstall)))
return cw::get_style(MAYBE_HIGHLIGHTED("PkgToInstall"));
+ else if (package.VersionList().VerStr() == estate.forbidver)
+ return cw::get_style(MAYBE_HIGHLIGHTED("PktBroken"));
else if(state.Status!=2 && // Not being upgraded
- (*apt_cache_file)->get_ext_state(package).selection_state==pkgCache::State::Hold // Flagged for hold
+ estate.selection_state==pkgCache::State::Hold // Flagged for hold
&& !state.InstBroken()) // Not currently broken.
return cw::get_style(MAYBE_HIGHLIGHTED("PkgToHold"));
else if(state.Delete())
--
1.7.10.4
More information about the Aptitude-devel
mailing list