summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Burrows <dburrows@debian.org>2007-10-30 07:47:55 -0700
committerDaniel Burrows <dburrows@debian.org>2007-10-30 07:47:55 -0700
commit9bc6f80392681e16d9c75e7962915ce2a3dc38d0 (patch)
tree650ac0ef6a04be74702c1a2154f30e568fa7f053
parent1193257d676b67976b15c61bedd5e51d3bad83b1 (diff)
downloadaptitude-9bc6f80392681e16d9c75e7962915ce2a3dc38d0.tar.gz
Properly thread pointers to the cache and the package records through match routines, so that matchers work from inside the cache while it's being initialized (e.g., in the garbage detection routine) instead of crashing.
-rw-r--r--src/cmdline/cmdline_action.cc6
-rw-r--r--src/cmdline/cmdline_prompt.cc2
-rw-r--r--src/cmdline/cmdline_search.cc4
-rw-r--r--src/cmdline/cmdline_show.cc6
-rw-r--r--src/cmdline/cmdline_why.cc15
-rw-r--r--src/generic/apt/apt.cc25
-rw-r--r--src/generic/apt/apt.h9
-rw-r--r--src/generic/apt/aptcache.cc19
-rw-r--r--src/generic/apt/aptcache.h9
-rw-r--r--src/generic/apt/infer_reason.cc2
-rw-r--r--src/generic/apt/log.cc2
-rw-r--r--src/generic/apt/matchers.cc529
-rw-r--r--src/generic/apt/matchers.h28
-rw-r--r--src/menu_tree.cc8
-rw-r--r--src/pkg_columnizer.cc3
-rw-r--r--src/pkg_grouppolicy.cc6
-rw-r--r--src/pkg_info_screen.cc2
-rw-r--r--src/pkg_item.cc4
-rw-r--r--src/pkg_tree.cc4
-rw-r--r--src/pkg_ver_item.cc2
-rw-r--r--src/pkg_view.cc2
-rw-r--r--src/reason_fragment.cc2
-rw-r--r--src/solution_item.cc2
-rw-r--r--src/ui.cc2
24 files changed, 463 insertions, 230 deletions
diff --git a/src/cmdline/cmdline_action.cc b/src/cmdline/cmdline_action.cc
index bfc2c5bc..2004168a 100644
--- a/src/cmdline/cmdline_action.cc
+++ b/src/cmdline/cmdline_action.cc
@@ -271,7 +271,7 @@ bool cmdline_applyaction(string s,
for(pkgCache::PkgIterator j=(*apt_cache_file)->PkgBegin();
!j.end(); ++j)
{
- if(!(j.VersionList().end() && j.ProvidesList().end()) && m->matches(j))
+ if(!(j.VersionList().end() && j.ProvidesList().end()) && m->matches(j, *apt_cache_file, *apt_package_records))
possible.push_back(j);
}
@@ -301,7 +301,7 @@ bool cmdline_applyaction(string s,
for(pkgCache::PkgIterator j=(*apt_cache_file)->PkgBegin();
!j.end(); ++j)
{
- if(m->matches(j))
+ if(m->matches(j, *apt_cache_file, *apt_package_records))
possible.push_back(j);
}
@@ -340,7 +340,7 @@ bool cmdline_applyaction(string s,
{
pkgCache::VerIterator testver;
- if(m->matches(pkg))
+ if(m->matches(pkg, *apt_cache_file, *apt_package_records))
rval=cmdline_applyaction(action, pkg,
to_install, to_hold, to_remove, to_purge,
verbose, source,
diff --git a/src/cmdline/cmdline_prompt.cc b/src/cmdline/cmdline_prompt.cc
index b563bee0..2166f432 100644
--- a/src/cmdline/cmdline_prompt.cc
+++ b/src/cmdline/cmdline_prompt.cc
@@ -485,7 +485,7 @@ static bool cmdline_show_preview(bool as_upgrade, pkgset &to_install,
((*apt_cache_file)[pkg].iFlags & pkgDepCache::ReInstall))
++ReInstall;
- pkg_action_state state=find_pkg_state(pkg);
+ pkg_action_state state=find_pkg_state(pkg, *apt_cache_file);
switch(state)
{
diff --git a/src/cmdline/cmdline_search.cc b/src/cmdline/cmdline_search.cc
index d9c5efb8..af4354b9 100644
--- a/src/cmdline/cmdline_search.cc
+++ b/src/cmdline/cmdline_search.cc
@@ -164,7 +164,9 @@ int cmdline_search(int argc, char *argv[], const char *status_fname,
for(vector<pkg_matcher *>::iterator m=matchers.begin();
m!=matchers.end(); ++m)
{
- pkg_match_result *r=(*m)->get_match(pkg);
+ pkg_match_result *r=(*m)->get_match(pkg,
+ *apt_cache_file,
+ *apt_package_records);
if(r != NULL)
output.push_back(pair<pkgCache::PkgIterator, pkg_match_result *>(pkg, r));
diff --git a/src/cmdline/cmdline_show.cc b/src/cmdline/cmdline_show.cc
index 98e39c97..17edf945 100644
--- a/src/cmdline/cmdline_show.cc
+++ b/src/cmdline/cmdline_show.cc
@@ -428,8 +428,8 @@ static fragment *version_file_fragment(pkgCache::VerIterator ver,
fragments.push_back(fragf("%s%ls%n",
_("Description: "),
- get_short_description(ver).c_str()));
- fragments.push_back(indentbox(1, 1, make_desc_fragment(get_long_description(ver))));
+ get_short_description(ver, apt_package_records).c_str()));
+ fragments.push_back(indentbox(1, 1, make_desc_fragment(get_long_description(ver, apt_package_records))));
#ifdef APT_HAS_HOMEPAGE
if(rec.Homepage() != "")
@@ -549,7 +549,7 @@ bool do_cmdline_show(string s, int verbose)
for(pkgCache::PkgIterator P=(*apt_cache_file)->PkgBegin();
!P.end(); ++P)
- if(m->matches(P))
+ if(m->matches(P, *apt_cache_file, *apt_package_records))
{
if(!do_cmdline_show_target(P, source, sourcestr, verbose, has_explicit_source))
return false;
diff --git a/src/cmdline/cmdline_why.cc b/src/cmdline/cmdline_why.cc
index d23838c2..f3bb9742 100644
--- a/src/cmdline/cmdline_why.cc
+++ b/src/cmdline/cmdline_why.cc
@@ -851,7 +851,9 @@ namespace
for(std::vector<pkg_matcher *>::const_iterator it = leaves.begin();
!reached_leaf && it != leaves.end(); ++it)
{
- if((*it)->matches(frontpkg, frontver))
+ if((*it)->matches(frontpkg, frontver,
+ *apt_cache_file,
+ *apt_package_records))
reached_leaf = true;
}
if(reached_leaf)
@@ -895,13 +897,17 @@ namespace
}
bool matches(const pkgCache::PkgIterator &pkg,
- const pkgCache::VerIterator &ver)
+ const pkgCache::VerIterator &ver,
+ aptitudeDepCache &cache,
+ pkgRecords &records)
{
return pkg == match_pkg;
}
pkg_match_result *get_match(const pkgCache::PkgIterator &pkg,
- const pkgCache::VerIterator &ver)
+ const pkgCache::VerIterator &ver,
+ aptitudeDepCache &cache,
+ pkgRecords &records)
{
if(pkg == match_pkg)
return new const_name_result(pkg.Name());
@@ -1248,7 +1254,8 @@ int cmdline_why(int argc, char *argv[],
else
{
matchers.push_back(m);
- if(!pkg.end() && m->matches(pkg, pkg.CurrentVer()))
+ if(!pkg.end() && m->matches(pkg, pkg.CurrentVer(),
+ *apt_cache_file, *apt_package_records))
{
printf(_("The package \"%s\" is manually installed.\n"),
pkg.Name());
diff --git a/src/generic/apt/apt.cc b/src/generic/apt/apt.cc
index 09bb9a55..b34946a9 100644
--- a/src/generic/apt/apt.cc
+++ b/src/generic/apt/apt.cc
@@ -359,10 +359,11 @@ pkg_hier *get_user_pkg_hier()
return user_pkg_hier;
}
-pkg_action_state find_pkg_state(pkgCache::PkgIterator pkg)
+pkg_action_state find_pkg_state(pkgCache::PkgIterator pkg,
+ aptitudeDepCache &cache)
{
- aptitudeDepCache::StateCache &state=(*apt_cache_file)[pkg];
- aptitudeDepCache::aptitude_state &extstate=(*apt_cache_file)->get_ext_state(pkg);
+ aptitudeDepCache::StateCache &state = cache[pkg];
+ aptitudeDepCache::aptitude_state &extstate = cache.get_ext_state(pkg);
if(state.InstBroken())
return pkg_broken;
@@ -869,9 +870,10 @@ bool is_interesting_dep(const pkgCache::DepIterator &d,
}
}
-std::wstring get_short_description(const pkgCache::VerIterator &ver)
+std::wstring get_short_description(const pkgCache::VerIterator &ver,
+ pkgRecords *records)
{
- if(ver.end() || ver.FileList().end() || apt_package_records == NULL)
+ if(ver.end() || ver.FileList().end() || records == NULL)
return std::wstring();
#ifndef HAVE_DDTP
@@ -880,7 +882,7 @@ std::wstring get_short_description(const pkgCache::VerIterator &ver)
if(vf.end())
return std::wstring();
else
- return transcode(apt_package_records->Lookup(vf).ShortDesc());
+ return transcode(records->Lookup(vf).ShortDesc());
#else
pkgCache::DescIterator d = ver.TranslatedDescription();
@@ -895,13 +897,14 @@ std::wstring get_short_description(const pkgCache::VerIterator &ver)
// apt "helpfully" transcodes the description for us, instead of
// providing direct access to it. So I need to assume that the
// description is encoded in the current locale.
- return transcode(apt_package_records->Lookup(df).ShortDesc());
+ return transcode(records->Lookup(df).ShortDesc());
#endif
}
-std::wstring get_long_description(const pkgCache::VerIterator &ver)
+std::wstring get_long_description(const pkgCache::VerIterator &ver,
+ pkgRecords *records)
{
- if(ver.end() || ver.FileList().end() || apt_package_records == NULL)
+ if(ver.end() || ver.FileList().end() || records == NULL)
return std::wstring();
#ifndef HAVE_DDTP
@@ -910,7 +913,7 @@ std::wstring get_long_description(const pkgCache::VerIterator &ver)
if(vf.end())
return std::wstring();
else
- return transcode(apt_package_records->Lookup(vf).LongDesc());
+ return transcode(records->Lookup(vf).LongDesc());
#else
pkgCache::DescIterator d = ver.TranslatedDescription();
@@ -922,6 +925,6 @@ std::wstring get_long_description(const pkgCache::VerIterator &ver)
if(df.end())
return std::wstring();
else
- return transcode(apt_package_records->Lookup(df).LongDesc());
+ return transcode(records->Lookup(df).LongDesc());
#endif
}
diff --git a/src/generic/apt/apt.h b/src/generic/apt/apt.h
index 27cab7e4..4479faea 100644
--- a/src/generic/apt/apt.h
+++ b/src/generic/apt/apt.h
@@ -146,7 +146,8 @@ enum pkg_action_state {pkg_unchanged=-1,
pkg_upgrade,
pkg_unconfigured};
const int num_pkg_action_states=12;
-pkg_action_state find_pkg_state(pkgCache::PkgIterator pkg);
+pkg_action_state find_pkg_state(pkgCache::PkgIterator pkg,
+ aptitudeDepCache &cache);
// A utility routine to return a useful notion of a package's "action-state"
// and an enum associated with it
@@ -168,12 +169,14 @@ void surrounding_or(pkgCache::DepIterator dep,
/** \return a short description string corresponding to the given
* version.
*/
-std::wstring get_short_description(const pkgCache::VerIterator &ver);
+std::wstring get_short_description(const pkgCache::VerIterator &ver,
+ pkgRecords *records);
/** \return a long description string corresponding to the given
* version.
*/
-std::wstring get_long_description(const pkgCache::VerIterator &ver);
+std::wstring get_long_description(const pkgCache::VerIterator &ver,
+ pkgRecords *records);
/** \return true if pkg is suggested by another package which will be
* installed.
diff --git a/src/generic/apt/aptcache.cc b/src/generic/apt/aptcache.cc
index 2331261f..7cdd92da 100644
--- a/src/generic/apt/aptcache.cc
+++ b/src/generic/apt/aptcache.cc
@@ -184,7 +184,8 @@ aptitudeDepCache::action_group::~action_group()
aptitudeDepCache::aptitudeDepCache(pkgCache *Cache, Policy *Plcy)
:pkgDepCache(Cache, Plcy), dirty(false), read_only(true),
- package_states(NULL), lock(-1), group_level(0)
+ package_states(NULL), lock(-1), group_level(0),
+ new_package_count(0), records(NULL)
{
// When the "install recommended packages" flag changes, collect garbage.
#if 0
@@ -213,6 +214,7 @@ bool aptitudeDepCache::Init(OpProgress *Prog, bool WithLock, bool do_initselecti
aptitudeDepCache::~aptitudeDepCache()
{
+ delete records;
delete[] package_states;
if(lock!=-1)
@@ -236,6 +238,8 @@ bool aptitudeDepCache::build_selection_list(OpProgress &Prog, bool WithLock,
if(!pkgDepCache::Init(&Prog))
return false;
+ records = new pkgRecords(*this);
+
// This is necessary so that the Garbage flags are initialized.
// Some of the Mark* methods perturb the Auto flag in largely
// uncontrollable ways, and one defense against this is to get
@@ -1569,6 +1573,9 @@ bool aptitudeDepCache::MarkFollowsSuggests()
class AptitudeInRootSetFunc : public pkgDepCache::InRootSetFunc
{
+ /** \brief A pointer to the cache in which we're matching. */
+ aptitudeDepCache &cache;
+
/** A matcher if one could be created; otherwise NULL. */
pkg_matcher *m;
@@ -1580,8 +1587,9 @@ class AptitudeInRootSetFunc : public pkgDepCache::InRootSetFunc
*/
pkgDepCache::InRootSetFunc *chain;
public:
- AptitudeInRootSetFunc(pkgDepCache::InRootSetFunc *_chain)
- : m(NULL), constructedSuccessfully(false), chain(NULL)
+ AptitudeInRootSetFunc(pkgDepCache::InRootSetFunc *_chain,
+ aptitudeDepCache &_cache)
+ : cache(_cache), m(NULL), constructedSuccessfully(false), chain(NULL)
{
std::string matchterm = aptcfg->Find(PACKAGE "::Keep-Unused-Pattern", "~nlinux-image-.*");
if(matchterm.empty()) // Bug-compatibility with old versions.
@@ -1607,7 +1615,8 @@ public:
bool InRootSet(const pkgCache::PkgIterator &pkg)
{
- if(m != NULL && m->matches(pkg))
+ pkgRecords &records(cache.get_records());
+ if(m != NULL && m->matches(pkg, cache, records))
return true;
else
return chain != NULL && chain->InRootSet(pkg);
@@ -1624,7 +1633,7 @@ pkgDepCache::InRootSetFunc *aptitudeDepCache::GetRootSetFunc()
{
InRootSetFunc *superFunc = pkgDepCache::GetRootSetFunc();
- AptitudeInRootSetFunc *f = new AptitudeInRootSetFunc(superFunc);
+ AptitudeInRootSetFunc *f = new AptitudeInRootSetFunc(superFunc, *this);
if(f->wasConstructedSuccessfully())
return f;
diff --git a/src/generic/apt/aptcache.h b/src/generic/apt/aptcache.h
index 24693dbd..9252ac13 100644
--- a/src/generic/apt/aptcache.h
+++ b/src/generic/apt/aptcache.h
@@ -33,6 +33,7 @@
#include <generic/util/bool_accumulate.h>
#include <apt-pkg/depcache.h>
+#include <apt-pkg/pkgrecords.h>
#include <sigc++/signal.h>
#include <sigc++/trackable.h>
@@ -214,13 +215,11 @@ private:
/** The number of "new" packages. */
int new_package_count;
- bool mark_and_sweep_in_progress;
- // Tracks whether a mark-and-sweep is running to avoid infinite recursion.
- // FIXME: disgusting hack.
-
apt_state_snapshot backup_state;
// Stores what the cache was like just before an action was performed
+ pkgRecords *records;
+
/** Call whenever the cache state is modified; discards the
* state of the active resolver.
*
@@ -275,6 +274,8 @@ public:
bool is_dirty() {return dirty;}
+ pkgRecords &get_records() { return *records; }
+
// If do_initselections is "false", the "sticky states" will not be used
// to initialize packages. (important for the command-line mode)
bool build_selection_list(OpProgress &Prog, bool WithLock,
diff --git a/src/generic/apt/infer_reason.cc b/src/generic/apt/infer_reason.cc
index aee2a8e9..90d1a191 100644
--- a/src/generic/apt/infer_reason.cc
+++ b/src/generic/apt/infer_reason.cc
@@ -146,7 +146,7 @@ static bool is_simple_self_conflict(pkgCache::DepIterator dep) {
void infer_reason(pkgCache::PkgIterator pkg, set<reason> &reasons)
{
- pkg_action_state actionstate=find_pkg_state(pkg);
+ pkg_action_state actionstate=find_pkg_state(pkg, *apt_cache_file);
pkgDepCache::StateCache &state=(*apt_cache_file)[pkg];
pkgCache::VerIterator instver=state.InstVerIter(*apt_cache_file);
diff --git a/src/generic/apt/log.cc b/src/generic/apt/log.cc
index 9613756a..5f1e4cf6 100644
--- a/src/generic/apt/log.cc
+++ b/src/generic/apt/log.cc
@@ -186,7 +186,7 @@ void log_changes()
for(pkgCache::PkgIterator i
= (*apt_cache_file)->PkgBegin(); !i.end(); i++)
{
- pkg_action_state s = find_pkg_state(i);
+ pkg_action_state s = find_pkg_state(i, *apt_cache_file);
if(s != pkg_unchanged)
changed_packages.push_back(logitem(i, s));
}
diff --git a/src/generic/apt/matchers.cc b/src/generic/apt/matchers.cc
index e9a2852c..a9dd5f5b 100644
--- a/src/generic/apt/matchers.cc
+++ b/src/generic/apt/matchers.cc
@@ -1,6 +1,6 @@
// matchers.cc
//
-// Copyright 2000-2005 Daniel Burrows
+// Copyright 2000-2005, 2007 Daniel Burrows
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
@@ -33,6 +33,7 @@
#include "matchers.h"
#include "apt.h"
+#include "aptcache.h"
#include "tags.h"
#include "tasks.h"
@@ -88,29 +89,35 @@ pkg_match_result::~pkg_match_result()
{
}
-bool pkg_matcher::matches(const pkgCache::PkgIterator &pkg)
+bool pkg_matcher::matches(const pkgCache::PkgIterator &pkg,
+ aptitudeDepCache &cache,
+ pkgRecords &records)
{
for(pkgCache::VerIterator v = pkg.VersionList();
!v.end(); ++v)
- if(matches(pkg, v))
+ if(matches(pkg, v, cache, records))
return true;
if(pkg.VersionList().end())
- return matches(pkg, pkgCache::VerIterator(*apt_cache_file, 0));
+ return matches(pkg, pkgCache::VerIterator(cache, 0),
+ cache, records);
else
return false;
}
-pkg_match_result *pkg_matcher::get_match(const pkgCache::PkgIterator &pkg)
+pkg_match_result *pkg_matcher::get_match(const pkgCache::PkgIterator &pkg,
+ aptitudeDepCache &cache,
+ pkgRecords &records)
{
pkg_match_result *rval = NULL;
for(pkgCache::VerIterator v = pkg.VersionList();
rval == NULL && !v.end(); ++v)
- rval = get_match(pkg, v);
+ rval = get_match(pkg, v, cache, records);
if(pkg.VersionList().end())
- rval = get_match(pkg, pkgCache::VerIterator(*apt_cache_file, 0));
+ rval = get_match(pkg, pkgCache::VerIterator(cache, 0),
+ cache, records);
return rval;
}
@@ -135,9 +142,11 @@ class pkg_nonstring_matcher : public pkg_matcher
{
public:
pkg_match_result *get_match(const pkgCache::PkgIterator &pkg,
- const pkgCache::VerIterator &ver)
+ const pkgCache::VerIterator &ver,
+ aptitudeDepCache &cache,
+ pkgRecords &records)
{
- return matches(pkg, ver) ? new empty_match_result : NULL;
+ return matches(pkg, ver, cache, records) ? new empty_match_result : NULL;
}
};
@@ -302,12 +311,16 @@ public:
// If the first element is false, the match fails; otherwise, it
// proceeds using the second element.
virtual match_target val(const pkgCache::PkgIterator &pkg,
- const pkgCache::VerIterator &ver)=0;
+ const pkgCache::VerIterator &ver,
+ aptitudeDepCache &cache,
+ pkgRecords &records)=0;
bool matches(const pkgCache::PkgIterator &pkg,
- const pkgCache::VerIterator &ver)
+ const pkgCache::VerIterator &ver,
+ aptitudeDepCache &cache,
+ pkgRecords &records)
{
- match_target v = val(pkg, ver);
+ match_target v = val(pkg, ver, cache, records);
if(!v.first)
return false;
@@ -316,9 +329,11 @@ public:
}
pkg_match_result *get_match(const pkgCache::PkgIterator &pkg,
- const pkgCache::VerIterator &ver)
+ const pkgCache::VerIterator &ver,
+ aptitudeDepCache &cache,
+ pkgRecords &records)
{
- match_target v = val(pkg, ver);
+ match_target v = val(pkg, ver, cache, records);
if(!v.first)
return NULL;
@@ -333,7 +348,9 @@ public:
pkg_name_matcher(const string &s):pkg_trivial_string_matcher(s) {}
match_target val(const pkgCache::PkgIterator &pkg,
- const pkgCache::VerIterator &ver)
+ const pkgCache::VerIterator &ver,
+ aptitudeDepCache &cache,
+ pkgRecords &records)
{
return match_target(true, pkg.Name());
}
@@ -345,12 +362,14 @@ public:
pkg_description_matcher(const string &s):pkg_trivial_string_matcher(s) {}
match_target val(const pkgCache::PkgIterator &pkg,
- const pkgCache::VerIterator &ver)
+ const pkgCache::VerIterator &ver,
+ aptitudeDepCache &cache,
+ pkgRecords &records)
{
if(ver.end())
return match_target(false, "");
else
- return match_target(true, transcode(get_long_description(ver).c_str()));
+ return match_target(true, transcode(get_long_description(ver, &records).c_str()));
}
};
@@ -362,12 +381,14 @@ public:
}
match_target val(const pkgCache::PkgIterator &pkg,
- const pkgCache::VerIterator &ver)
+ const pkgCache::VerIterator &ver,
+ aptitudeDepCache &cache,
+ pkgRecords &records)
{
if(ver.end())
return match_target(false, "");
else
- return match_target(true, apt_package_records->Lookup(ver.FileList()).Maintainer().c_str());
+ return match_target(true, records.Lookup(ver.FileList()).Maintainer().c_str());
}
};
@@ -379,7 +400,9 @@ public:
}
match_target val(const pkgCache::PkgIterator &pkg,
- const pkgCache::VerIterator &ver)
+ const pkgCache::VerIterator &ver,
+ aptitudeDepCache &cache,
+ pkgRecords &records)
{
if(ver.end())
return match_target(false, "");
@@ -401,7 +424,9 @@ public:
}
match_target val(const pkgCache::PkgIterator &pkg,
- const pkgCache::VerIterator &ver)
+ const pkgCache::VerIterator &ver,
+ aptitudeDepCache &cache,
+ pkgRecords &records)
{
if(ver.end())
return match_target(false, "");
@@ -424,15 +449,19 @@ class pkg_curr_version_matcher : public pkg_matcher
{
public:
bool matches(const pkgCache::PkgIterator &pkg,
- const pkgCache::VerIterator &ver)
+ const pkgCache::VerIterator &ver,
+ aptitudeDepCache &cache,
+ pkgRecords &records)
{
return !ver.end() && ver == pkg.CurrentVer();
}
pkg_match_result *get_match(const pkgCache::PkgIterator &pkg,
- const pkgCache::VerIterator &ver)
+ const pkgCache::VerIterator &ver,
+ aptitudeDepCache &cache,
+ pkgRecords &records)
{
- if(matches(pkg, ver))
+ if(matches(pkg, ver, cache, records))
return new unitary_result(ver.VerStr());
else
return NULL;
@@ -443,16 +472,20 @@ class pkg_cand_version_matcher : public pkg_matcher
{
public:
bool matches(const pkgCache::PkgIterator &pkg,
- const pkgCache::VerIterator &ver)
+ const pkgCache::VerIterator &ver,
+ aptitudeDepCache &cache,
+ pkgRecords &records)
{
return !ver.end() &&
- ver == (*apt_cache_file)[pkg].CandidateVerIter(*apt_cache_file);
+ ver == cache[pkg].CandidateVerIter(cache);
}
pkg_match_result *get_match(const pkgCache::PkgIterator &pkg,
- const pkgCache::VerIterator &ver)
+ const pkgCache::VerIterator &ver,
+ aptitudeDepCache &cache,
+ pkgRecords &records)
{
- if(matches(pkg, ver))
+ if(matches(pkg, ver, cache, records))
return new unitary_result(ver.VerStr());
else
return NULL;
@@ -463,16 +496,20 @@ class pkg_inst_version_matcher : public pkg_matcher
{
public:
bool matches(const pkgCache::PkgIterator &pkg,
- const pkgCache::VerIterator &ver)
+ const pkgCache::VerIterator &ver,
+ aptitudeDepCache &cache,
+ pkgRecords &records)
{
return !ver.end() &&
- ver == (*apt_cache_file)[pkg].InstVerIter(*apt_cache_file);
+ ver == cache[pkg].InstVerIter(cache);
}
pkg_match_result *get_match(const pkgCache::PkgIterator &pkg,
- const pkgCache::VerIterator &ver)
+ const pkgCache::VerIterator &ver,
+ aptitudeDepCache &cache,
+ pkgRecords &records)
{
- if(matches(pkg, ver))
+ if(matches(pkg, ver, cache, records))
return new unitary_result(ver.VerStr());
else
return NULL;
@@ -487,7 +524,9 @@ public:
}
bool matches(const pkgCache::PkgIterator &pkg,
- const pkgCache::VerIterator &v)
+ const pkgCache::VerIterator &v,
+ aptitudeDepCache &cache,
+ pkgRecords &records)
{
list<string> *l=get_tasks(pkg);
@@ -505,7 +544,9 @@ public:
// Uses the fact that the result returns NULL <=> nothing matched
pkg_match_result *get_match(const pkgCache::PkgIterator &pkg,
- const pkgCache::VerIterator &ver)
+ const pkgCache::VerIterator &ver,
+ aptitudeDepCache &cache,
+ pkgRecords &records)
{
list<string> *l=get_tasks(pkg);
@@ -535,7 +576,9 @@ public:
}
bool matches(const pkgCache::PkgIterator &pkg,
- const pkgCache::VerIterator &ver)
+ const pkgCache::VerIterator &ver,
+ aptitudeDepCache &cache,
+ pkgRecords &records)
{
const std::set<tag> *tags = get_tags(pkg);
@@ -550,7 +593,9 @@ public:
}
pkg_match_result *get_match(const pkgCache::PkgIterator &pkg,
- const pkgCache::VerIterator &ver)
+ const pkgCache::VerIterator &ver,
+ aptitudeDepCache &cache,
+ pkgRecords &records)
{
const set<tag> *tags = get_tags(pkg);
@@ -580,7 +625,9 @@ public:
}
bool matches(const pkgCache::PkgIterator &pkg,
- const pkgCache::VerIterator &ver)
+ const pkgCache::VerIterator &ver,
+ aptitudeDepCache &cache,
+ pkgRecords &records)
{
if(ver.end())
return false;
@@ -597,7 +644,9 @@ public:
}
pkg_match_result *get_match(const pkgCache::PkgIterator &pkg,
- const pkgCache::VerIterator &ver)
+ const pkgCache::VerIterator &ver,
+ aptitudeDepCache &cache,
+ pkgRecords &records)
{
if(ver.end())
return NULL;
@@ -627,7 +676,9 @@ public:
}
bool matches(const pkgCache::PkgIterator &pkg,
- const pkgCache::VerIterator &ver)
+ const pkgCache::VerIterator &ver,
+ aptitudeDepCache &cache,
+ pkgRecords &records)
{
if(ver.end() || ver.FileList().end())
return false;
@@ -644,7 +695,9 @@ public:
}
pkg_match_result *get_match(const pkgCache::PkgIterator &pkg,
- const pkgCache::VerIterator &ver)
+ const pkgCache::VerIterator &ver,
+ aptitudeDepCache &cache,
+ pkgRecords &records)
{
if(ver.end() || ver.FileList().end())
return NULL;
@@ -670,17 +723,22 @@ class pkg_auto_matcher:public pkg_matcher
{
public:
bool matches(const pkgCache::PkgIterator &pkg,
- const pkgCache::VerIterator &ver)
+ const pkgCache::VerIterator &ver,
+ aptitudeDepCache &cache,
+ pkgRecords &records)
{
return
- (!pkg.CurrentVer().end() || (*apt_cache_file)[pkg].Install()) &&
- ((*apt_cache_file)[pkg].Flags & pkgCache::Flag::Auto);
+ (!pkg.CurrentVer().end() || cache[pkg].Install()) &&
+ (cache[pkg].Flags & pkgCache::Flag::Auto);
}
pkg_match_result *get_match(const pkgCache::PkgIterator &pkg,
- const pkgCache::VerIterator &ver)
+ const pkgCache::VerIterator &ver,
+ aptitudeDepCache &cache,
+ pkgRecords &records)
{
- return matches(pkg, ver) ? new unitary_result(_("Automatically Installed")) : NULL;
+ return matches(pkg, ver, cache, records)
+ ? new unitary_result(_("Automatically Installed")) : NULL;
}
};
@@ -688,21 +746,25 @@ class pkg_broken_matcher:public pkg_matcher
{
public:
bool matches(const pkgCache::PkgIterator &pkg,
- const pkgCache::VerIterator &ver)
+ const pkgCache::VerIterator &ver,
+ aptitudeDepCache &cache,
+ pkgRecords &records)
{
if(ver.end())
return false;
else
{
- aptitudeDepCache::StateCache &state=(*apt_cache_file)[pkg];
+ aptitudeDepCache::StateCache &state = cache[pkg];
return state.NowBroken() || state.InstBroken();
}
}
pkg_match_result *get_match(const pkgCache::PkgIterator &pkg,
- const pkgCache::VerIterator &ver)
+ const pkgCache::VerIterator &ver,
+ aptitudeDepCache &cache,
+ pkgRecords &records)
{
- return matches(pkg, ver) ? new unitary_result(_("Broken")) : NULL;
+ return matches(pkg, ver, cache, records) ? new unitary_result(_("Broken")) : NULL;
}
};
@@ -714,7 +776,9 @@ public:
:type(_type) {}
bool matches(const pkgCache::PkgIterator &pkg,
- const pkgCache::VerIterator &ver)
+ const pkgCache::VerIterator &ver,
+ aptitudeDepCache &cache,
+ pkgRecords &records)
{
if(ver.end())
return false;
@@ -723,7 +787,9 @@ public:
}
pkg_match_result *get_match(const pkgCache::PkgIterator &pkg,
- const pkgCache::VerIterator &ver)
+ const pkgCache::VerIterator &ver,
+ aptitudeDepCache &cache,
+ pkgRecords &records)
{
if(ver.end())
return NULL;
@@ -779,7 +845,9 @@ public:
:type(_type) {}
bool matches(const pkgCache::PkgIterator &pkg,
- const pkgCache::VerIterator &ver)
+ const pkgCache::VerIterator &ver,
+ aptitudeDepCache &cache,
+ pkgRecords &records)
{
if(ver.end())
return false;
@@ -794,7 +862,7 @@ public:
++dep;
if(dep->Type==type &&
- !((*apt_cache_file)[dep]&pkgDepCache::DepGInstall))
+ !(cache[dep] & pkgDepCache::DepGInstall))
// Oops, it's broken..
return true;
@@ -805,7 +873,9 @@ public:
}
pkg_match_result * get_match(const pkgCache::PkgIterator &pkg,
- const pkgCache::VerIterator &ver)
+ const pkgCache::VerIterator &ver,
+ aptitudeDepCache &cache,
+ pkgRecords &records)
{
if(ver.end())
return NULL;
@@ -820,7 +890,7 @@ public:
++dep;
if(dep->Type==type &&
- !((*apt_cache_file)[dep]&pkgDepCache::DepGInstall))
+ !(cache[dep] & pkgDepCache::DepGInstall))
// Oops, it's broken..
return dep_match(dep);
@@ -847,10 +917,12 @@ public:
}
bool matches(const pkgCache::PkgIterator &pkg,
- const pkgCache::VerIterator &ver)
+ const pkgCache::VerIterator &ver,
+ aptitudeDepCache &cache,
+ pkgRecords &records)
{
if(require_purge &&
- ((*apt_cache_file)[pkg].iFlags & pkgDepCache::Purge) == 0)
+ (cache[pkg].iFlags & pkgDepCache::Purge) == 0)
return false;
else
{
@@ -858,21 +930,21 @@ public:
{
case pkg_install:
{
- pkg_action_state thetype=find_pkg_state(pkg);
+ pkg_action_state thetype = find_pkg_state(pkg, cache);
return thetype==pkg_install || thetype==pkg_auto_install;
}
case pkg_hold:
- return !pkg.CurrentVer().end() && (*apt_cache_file)->get_ext_state(pkg).selection_state==pkgCache::State::Hold;
+ return !pkg.CurrentVer().end() && cache.get_ext_state(pkg).selection_state == pkgCache::State::Hold;
case pkg_remove:
{
- pkg_action_state thetype=find_pkg_state(pkg);
+ pkg_action_state thetype = find_pkg_state(pkg, cache);
return thetype==pkg_remove || thetype==pkg_auto_remove ||
thetype==pkg_unused_remove;
}
default:
{
- pkg_action_state thetype=find_pkg_state(pkg);
+ pkg_action_state thetype = find_pkg_state(pkg, cache);
return thetype==type;
}
@@ -881,9 +953,11 @@ public:
}
pkg_match_result *get_match(const pkgCache::PkgIterator &pkg,
- const pkgCache::VerIterator &ver)
+ const pkgCache::VerIterator &ver,
+ aptitudeDepCache &cache,
+ pkgRecords &records)
{
- if(!matches(pkg, ver))
+ if(!matches(pkg, ver, cache, records))
return NULL;
else
switch(type)
@@ -922,15 +996,19 @@ public:
class pkg_keep_matcher:public pkg_matcher
{
bool matches(const pkgCache::PkgIterator &pkg,
- const pkgCache::VerIterator &ver)
+ const pkgCache::VerIterator &ver,
+ aptitudeDepCache &cache,
+ pkgRecords &records)
{
- return (*apt_cache_file)[pkg].Keep();
+ return cache[pkg].Keep();
}
pkg_match_result *get_match(const pkgCache::PkgIterator &pkg,
- const pkgCache::VerIterator &ver)
+ const pkgCache::VerIterator &ver,
+ aptitudeDepCache &cache,
+ pkgRecords &records)
{
- if((*apt_cache_file)[pkg].Keep())
+ if(cache[pkg].Keep())
return new unitary_result(_("Keep"));
else
return NULL;
@@ -946,13 +1024,17 @@ class pkg_virtual_matcher:public pkg_matcher
{
public:
bool matches(const pkgCache::PkgIterator &pkg,
- const pkgCache::VerIterator &ver)
+ const pkgCache::VerIterator &ver,
+ aptitudeDepCache &cache,
+ pkgRecords &records)
{
return ver.end();
}
pkg_match_result *get_match(const pkgCache::PkgIterator &pkg,
- const pkgCache::VerIterator &ver)
+ const pkgCache::VerIterator &ver,
+ aptitudeDepCache &cache,
+ pkgRecords &records)
{
if(!ver.end())
return NULL;
@@ -967,13 +1049,17 @@ class pkg_installed_matcher:public pkg_matcher
{
public:
bool matches(const pkgCache::PkgIterator &pkg,
- const pkgCache::VerIterator &ver)
+ const pkgCache::VerIterator &ver,
+ aptitudeDepCache &cache,
+ pkgRecords &records)
{
return !pkg.CurrentVer().end() && ver == pkg.CurrentVer();
}
pkg_match_result *get_match(const pkgCache::PkgIterator &pkg,
- const pkgCache::VerIterator &ver)
+ const pkgCache::VerIterator &ver,
+ aptitudeDepCache &cache,
+ pkgRecords &records)
{
if(pkg.CurrentVer().end() || ver != pkg.CurrentVer())
return NULL;
@@ -987,7 +1073,9 @@ class pkg_essential_matcher:public pkg_matcher
{
public:
bool matches(const pkgCache::PkgIterator &pkg,
- const pkgCache::VerIterator &ver)
+ const pkgCache::VerIterator &ver,
+ aptitudeDepCache &cache,
+ pkgRecords &records)
{
return
(pkg->Flags&pkgCache::Flag::Essential)==pkgCache::Flag::Essential ||
@@ -995,9 +1083,11 @@ public:
}
pkg_match_result *get_match(const pkgCache::PkgIterator &pkg,
- const pkgCache::VerIterator &ver)
+ const pkgCache::VerIterator &ver,
+ aptitudeDepCache &cache,
+ pkgRecords &records)
{
- if(!matches(pkg, ver))
+ if(!matches(pkg, ver, cache, records))
return NULL;
else
return new unitary_result(_("Essential"));
@@ -1009,14 +1099,18 @@ class pkg_configfiles_matcher:public pkg_matcher
{
public:
bool matches(const pkgCache::PkgIterator &pkg,
- const pkgCache::VerIterator &ver)
+ const pkgCache::VerIterator &ver,
+ aptitudeDepCache &cache,
+ pkgRecords &records)
{
return pkg->CurrentState==pkgCache::State::ConfigFiles;
}
// ???
pkg_match_result *get_match(const pkgCache::PkgIterator &pkg,
- const pkgCache::VerIterator &ver)
+ const pkgCache::VerIterator &ver,
+ aptitudeDepCache &cache,
+ pkgRecords &records)
{
if(pkg->CurrentState == pkgCache::State::ConfigFiles)
return new unitary_result(_("Config Files Remain"));
@@ -1045,7 +1139,9 @@ public:
~pkg_dep_matcher() {delete pattern;}
bool matches(const pkgCache::PkgIterator &pkg,
- const pkgCache::VerIterator &ver)
+ const pkgCache::VerIterator &ver,
+ aptitudeDepCache &cache,
+ pkgRecords &records)
{
eassert(!pkg.end());
if(ver.end())
@@ -1059,22 +1155,22 @@ public:
{
if(broken)
{
- pkgCache::DepIterator d2(*apt_cache_file, &*dep);
+ pkgCache::DepIterator d2(cache, &*dep);
while(d2->CompareOp & pkgCache::Dep::Or)
++d2;
- if((*apt_cache_file)[d2] & pkgDepCache::DepGInstall)
+ if(cache[d2] & pkgDepCache::DepGInstall)
continue;
}
// See if a versionless match works,.
if(dep.TargetPkg().VersionList().end() &&
- pattern->matches(dep.TargetPkg(), dep.TargetPkg().VersionList()))
+ pattern->matches(dep.TargetPkg(), dep.TargetPkg().VersionList(), cache, records))
return true;
for(pkgCache::VerIterator i=dep.TargetPkg().VersionList(); !i.end(); i++)
if(_system->VS->CheckDep(i.VerStr(), dep->CompareOp, dep.TargetVer()))
{
- if(pattern->matches(dep.TargetPkg(), i))
+ if(pattern->matches(dep.TargetPkg(), i, cache, records))
return true;
}
}
@@ -1084,7 +1180,9 @@ public:
}
pkg_match_result *get_match(const pkgCache::PkgIterator &pkg,
- const pkgCache::VerIterator &ver)
+ const pkgCache::VerIterator &ver,
+ aptitudeDepCache &cache,
+ pkgRecords &records)
{
eassert(!pkg.end());
if(ver.end())
@@ -1098,17 +1196,17 @@ public:
{
if(broken)
{
- pkgCache::DepIterator d2(*apt_cache_file, &*dep);
+ pkgCache::DepIterator d2(cache, &*dep);
while(d2->CompareOp & pkgCache::Dep::Or)
++d2;
- if((*apt_cache_file)[d2] & pkgDepCache::DepGInstall)
+ if(cache[d2] & pkgDepCache::DepGInstall)
continue;
}
// See if a versionless match works,.
if(dep.TargetPkg().VersionList().end())
{
- pkg_match_result *r=pattern->get_match(dep.TargetPkg(), dep.TargetPkg().VersionList());
+ pkg_match_result *r = pattern->get_match(dep.TargetPkg(), dep.TargetPkg().VersionList(), cache, records);
if(r)
return new result_pair(r, dep_match(dep));
@@ -1117,7 +1215,7 @@ public:
for(pkgCache::VerIterator i=dep.TargetPkg().VersionList(); !i.end(); i++)
if(_system->VS->CheckDep(i.VerStr(), dep->CompareOp, dep.TargetVer()))
{
- pkg_match_result *r = pattern->get_match(dep.TargetPkg(), i);
+ pkg_match_result *r = pattern->get_match(dep.TargetPkg(), i, cache, records);
if(r)
return new result_pair(r, dep_match(dep));
@@ -1139,35 +1237,45 @@ public:
}
bool matches(const pkgCache::PkgIterator &pkg,
- const pkgCache::VerIterator &ver)
+ const pkgCache::VerIterator &ver,
+ aptitudeDepCache &cache,
+ pkgRecords &records)
{
- return left->matches(pkg, ver) || right->matches(pkg, ver);
+ return left->matches(pkg, ver, cache, records) ||
+ right->matches(pkg, ver, cache, records);
}
- bool matches(const pkgCache::PkgIterator &pkg)
+ bool matches(const pkgCache::PkgIterator &pkg,
+ aptitudeDepCache &cache,
+ pkgRecords &records)
{
- return left->matches(pkg) || right->matches(pkg);
+ return left->matches(pkg, cache, records) ||
+ right->matches(pkg, cache, records);
}
pkg_match_result *get_match(const pkgCache::PkgIterator &pkg,
- const pkgCache::VerIterator &ver)
+ const pkgCache::VerIterator &ver,
+ aptitudeDepCache &cache,
+ pkgRecords &records)
{
- pkg_match_result *lr = left->get_match(pkg, ver);
+ pkg_match_result *lr = left->get_match(pkg, ver, cache, records);
if(lr != NULL)
return lr;
else
- return right->get_match(pkg, ver);
+ return right->get_match(pkg, ver, cache, records);
}
- pkg_match_result *get_match(const pkgCache::PkgIterator &pkg)
+ pkg_match_result *get_match(const pkgCache::PkgIterator &pkg,
+ aptitudeDepCache &cache,
+ pkgRecords &records)
{
- pkg_match_result *lr = left->get_match(pkg);
+ pkg_match_result *lr = left->get_match(pkg, cache, records);
if(lr != NULL)
return lr;
else
- return right->get_match(pkg);
+ return right->get_match(pkg, cache, records);
}
~pkg_or_matcher()
@@ -1187,25 +1295,33 @@ public:
}
bool matches(const pkgCache::PkgIterator &pkg,
- const pkgCache::VerIterator &ver)
+ const pkgCache::VerIterator &ver,
+ aptitudeDepCache &cache,
+ pkgRecords &records)
{
- return left->matches(pkg, ver) && right->matches(pkg, ver);
+ return left->matches(pkg, ver, cache, records) &&
+ right->matches(pkg, ver, cache, records);
}
- bool matches(const pkgCache::PkgIterator &pkg)
+ bool matches(const pkgCache::PkgIterator &pkg,
+ aptitudeDepCache &cache,
+ pkgRecords &records)
{
- return left->matches(pkg) && right->matches(pkg);
+ return left->matches(pkg, cache, records) &&
+ right->matches(pkg, cache, records);
}
pkg_match_result *get_match(const pkgCache::PkgIterator &pkg,
- const pkgCache::VerIterator &ver)
+ const pkgCache::VerIterator &ver,
+ aptitudeDepCache &cache,
+ pkgRecords &records)
{
- pkg_match_result *r1 = left->get_match(pkg, ver);
+ pkg_match_result *r1 = left->get_match(pkg, ver, cache, records);
if(r1 == NULL)
return NULL;
- pkg_match_result *r2 = right->get_match(pkg, ver);
+ pkg_match_result *r2 = right->get_match(pkg, ver, cache, records);
if(r2 == NULL)
{
@@ -1216,14 +1332,16 @@ public:
return new result_pair(r1, r2);
}
- pkg_match_result *get_match(const pkgCache::PkgIterator &pkg)
+ pkg_match_result *get_match(const pkgCache::PkgIterator &pkg,
+ aptitudeDepCache &cache,
+ pkgRecords &records)
{
- pkg_match_result *r1 = left->get_match(pkg);
+ pkg_match_result *r1 = left->get_match(pkg, cache, records);
if(r1 == NULL)
return NULL;
- pkg_match_result *r2 = right->get_match(pkg);
+ pkg_match_result *r2 = right->get_match(pkg, cache, records);
if(r2 == NULL)
{
@@ -1251,22 +1369,28 @@ public:
}
bool matches(const pkgCache::PkgIterator &pkg,
- const pkgCache::VerIterator &ver)
+ const pkgCache::VerIterator &ver,
+ aptitudeDepCache &cache,
+ pkgRecords &records)
{
- return !child->matches(pkg, ver);
+ return !child->matches(pkg, ver, cache, records);
}
- bool matches(const pkgCache::PkgIterator &pkg)
+ bool matches(const pkgCache::PkgIterator &pkg,
+ aptitudeDepCache &cache,
+ pkgRecords &records)
{
- return !child->matches(pkg);
+ return !child->matches(pkg, cache, records);
}
// Eh, there isn't really a good choice about what to return here...
// just return an empty result if the child doesn't match.
pkg_match_result *get_match(const pkgCache::PkgIterator &pkg,
- const pkgCache::VerIterator &ver)
+ const pkgCache::VerIterator &ver,
+ aptitudeDepCache &cache,
+ pkgRecords &records)
{
- pkg_match_result *child_match = child->get_match(pkg, ver);
+ pkg_match_result *child_match = child->get_match(pkg, ver, cache, records);
if(child_match == NULL)
return new empty_match_result;
@@ -1277,9 +1401,11 @@ public:
}
}
- pkg_match_result *get_match(const pkgCache::PkgIterator &pkg)
+ pkg_match_result *get_match(const pkgCache::PkgIterator &pkg,
+ aptitudeDepCache &cache,
+ pkgRecords &records)
{
- pkg_match_result *child_match = child->get_match(pkg);
+ pkg_match_result *child_match = child->get_match(pkg, cache, records);
if(child_match == NULL)
return new empty_match_result;
@@ -1308,25 +1434,33 @@ public:
}
bool matches(const pkgCache::PkgIterator &pkg,
- const pkgCache::VerIterator &ver)
+ const pkgCache::VerIterator &ver,
+ aptitudeDepCache &cache,
+ pkgRecords &records)
{
- return pattern->matches(pkg);
+ return pattern->matches(pkg, cache, records);
}
- bool matches(const pkgCache::PkgIterator &pkg)
+ bool matches(const pkgCache::PkgIterator &pkg,
+ aptitudeDepCache &cache,
+ pkgRecords &records)
{
- return pattern->matches(pkg);
+ return pattern->matches(pkg, cache, records);
}
pkg_match_result *get_match(const pkgCache::PkgIterator &pkg,
- const pkgCache::VerIterator &ver)
+ const pkgCache::VerIterator &ver,
+ aptitudeDepCache &cache,
+ pkgRecords &records)
{
- return pattern->get_match(pkg);
+ return pattern->get_match(pkg, cache, records);
}
- pkg_match_result *get_match(const pkgCache::PkgIterator &pkg)
+ pkg_match_result *get_match(const pkgCache::PkgIterator &pkg,
+ aptitudeDepCache &cache,
+ pkgRecords &records)
{
- return pattern->get_match(pkg);
+ return pattern->get_match(pkg, cache, records);
}
};
@@ -1349,16 +1483,21 @@ public:
}
bool matches(const pkgCache::PkgIterator &pkg,
- const pkgCache::VerIterator &ver)
+ const pkgCache::VerIterator &ver,
+ aptitudeDepCache &cache,
+ pkgRecords &records)
{
- return filter->matches(pkg, ver) && pattern->matches(pkg, ver);
+ return filter->matches(pkg, ver, cache, records) &&
+ pattern->matches(pkg, ver, cache, records);
}
pkg_match_result *get_match(const pkgCache::PkgIterator &pkg,
- const pkgCache::VerIterator &ver)
+ const pkgCache::VerIterator &ver,
+ aptitudeDepCache &cache,
+ pkgRecords &records)
{
- if(filter->matches(pkg, ver))
- return pattern->get_match(pkg, ver);
+ if(filter->matches(pkg, ver, cache, records))
+ return pattern->get_match(pkg, ver, cache, records);
else
return NULL;
}
@@ -1371,18 +1510,22 @@ public:
pkg_garbage_matcher() {}
bool matches(const pkgCache::PkgIterator &pkg,
- const pkgCache::VerIterator &ver)
+ const pkgCache::VerIterator &ver,
+ aptitudeDepCache &cache,
+ pkgRecords &records)
{
if(ver.end())
return false;
else
- return (*apt_cache_file)[pkg].Garbage;
+ return cache[pkg].Garbage;
}
pkg_match_result *get_match(const pkgCache::PkgIterator &pkg,
- const pkgCache::VerIterator &ver)
+ const pkgCache::VerIterator &ver,
+ aptitudeDepCache &cache,
+ pkgRecords &records)
{
- if(!matches(pkg, ver))
+ if(!matches(pkg, ver, cache, records))
return NULL;
else
return new unitary_result(_("Garbage"));
@@ -1396,13 +1539,17 @@ public:
pkg_true_matcher() {}
bool matches(const pkgCache::PkgIterator &pkg,
- const pkgCache::VerIterator &ver)
+ const pkgCache::VerIterator &ver,
+ aptitudeDepCache &cache,
+ pkgRecords &records)
{
return true;
}
pkg_match_result *get_match(const pkgCache::PkgIterator &pkg,
- const pkgCache::VerIterator &ver)
+ const pkgCache::VerIterator &ver,
+ aptitudeDepCache &cache,
+ pkgRecords &records)
{
return new empty_match_result;
}
@@ -1415,13 +1562,17 @@ public:
pkg_false_matcher() {}
bool matches(const pkgCache::PkgIterator &pkg,
- const pkgCache::VerIterator &ver)
+ const pkgCache::VerIterator &ver,
+ aptitudeDepCache &cache,
+ pkgRecords &records)
{
return false;
}
pkg_match_result *get_match(const pkgCache::PkgIterator &pkg,
- const pkgCache::VerIterator &ver)
+ const pkgCache::VerIterator &ver,
+ aptitudeDepCache &cache,
+ pkgRecords &records)
{
return NULL;
}
@@ -1455,17 +1606,19 @@ public:
}
bool matches(const pkgCache::PkgIterator &pkg,
- const pkgCache::VerIterator &ver)
+ const pkgCache::VerIterator &ver,
+ aptitudeDepCache &cache,
+ pkgRecords &records)
{
// Check direct dependencies.
for(pkgCache::DepIterator d=pkg.RevDependsList(); !d.end(); ++d)
{
if(broken)
{
- pkgCache::DepIterator d2(*apt_cache_file, &*d);
+ pkgCache::DepIterator d2(cache, &*d);
while(d2->CompareOp & pkgCache::Dep::Or)
++d2;
- if((*apt_cache_file)[d2] & pkgDepCache::DepGInstall)
+ if(cache[d2] & pkgDepCache::DepGInstall)
continue;
}
@@ -1473,7 +1626,8 @@ public:
(type==pkgCache::Dep::Depends && d->Type==pkgCache::Dep::PreDepends)) &&
(!d.TargetVer() || (!ver.end() &&
_system->VS->CheckDep(ver.VerStr(), d->CompareOp, d.TargetVer()))) &&
- pattern->matches(d.ParentPkg(), d.ParentVer()))
+ pattern->matches(d.ParentPkg(), d.ParentVer(),
+ cache, records))
return true;
}
@@ -1487,16 +1641,17 @@ public:
{
if(broken)
{
- pkgCache::DepIterator d2(*apt_cache_file, &*d);
+ pkgCache::DepIterator d2(cache, &*d);
while(d2->CompareOp & pkgCache::Dep::Or)
++d2;
- if((*apt_cache_file)[d2] & pkgDepCache::DepGInstall)
+ if(cache[d2] & pkgDepCache::DepGInstall)
continue;
}
// Only unversioned dependencies can match here.
if(d->Type==type && !d.TargetVer() &&
- pattern->matches(d.ParentPkg(), d.ParentVer()))
+ pattern->matches(d.ParentPkg(), d.ParentVer(),
+ cache, records))
return true;
}
}
@@ -1510,17 +1665,19 @@ public:
// Maybe I should just forget trying to be efficient and base
// everything on match results..
pkg_match_result *get_match(const pkgCache::PkgIterator &pkg,
- const pkgCache::VerIterator &ver)
+ const pkgCache::VerIterator &ver,
+ aptitudeDepCache &cache,
+ pkgRecords &records)
{
// Check direct dependencies.
for(pkgCache::DepIterator d=pkg.RevDependsList(); !d.end(); ++d)
{
if(broken)
{
- pkgCache::DepIterator d2(*apt_cache_file, &*d);
+ pkgCache::DepIterator d2(cache, &*d);
while(d2->CompareOp & pkgCache::Dep::Or)
++d2;
- if((*apt_cache_file)[d2] & pkgDepCache::DepGInstall)
+ if(cache[d2] & pkgDepCache::DepGInstall)
continue;
}
@@ -1530,7 +1687,8 @@ public:
_system->VS->CheckDep(ver.VerStr(), d->CompareOp, d.TargetVer()))))
{
pkg_match_result *r = pattern->get_match(d.ParentPkg(),
- d.ParentVer());
+ d.ParentVer(),
+ cache, records);
if(r != NULL)
return new result_pair(r, dep_match(d));
@@ -1550,15 +1708,16 @@ public:
{
if(broken)
{
- pkgCache::DepIterator d2(*apt_cache_file, &*d);
+ pkgCache::DepIterator d2(cache, &*d);
while(d2->CompareOp & pkgCache::Dep::Or)
++d2;
- if((*apt_cache_file)[d2] & pkgDepCache::DepGInstall)
+ if(cache[d2] & pkgDepCache::DepGInstall)
continue;
}
pkg_match_result *r = pattern->get_match(d.ParentPkg(),
- d.ParentVer());
+ d.ParentVer(),
+ cache, records);
if(r != NULL)
return new result_pair(r, dep_match(d));
}
@@ -1588,7 +1747,9 @@ public:
}
bool matches(const pkgCache::PkgIterator &pkg,
- const pkgCache::VerIterator &ver)
+ const pkgCache::VerIterator &ver,
+ aptitudeDepCache &cache,
+ pkgRecords &records)
{
if(ver.end())
return false;
@@ -1596,7 +1757,7 @@ public:
for(pkgCache::PrvIterator p=ver.ProvidesList(); !p.end(); ++p)
{
// Assumes no provided version.
- if(pattern->matches(p.ParentPkg()))
+ if(pattern->matches(p.ParentPkg(), cache, records))
return true;
}
@@ -1604,14 +1765,17 @@ public:
}
pkg_match_result *get_match(const pkgCache::PkgIterator &pkg,
- const pkgCache::VerIterator &ver)
+ const pkgCache::VerIterator &ver,
+ aptitudeDepCache &cache,
+ pkgRecords &records)
{
if(ver.end())
return NULL;
for(pkgCache::PrvIterator p=ver.ProvidesList(); !p.end(); ++p)
{
- pkg_match_result *r = pattern->get_match(p.ParentPkg(), pkgCache::VerIterator(*apt_cache_file));
+ pkg_match_result *r = pattern->get_match(p.ParentPkg(), pkgCache::VerIterator(cache),
+ cache, records);
if(r != NULL)
return new result_pair(r, new unitary_result(_("Provides")));
@@ -1639,11 +1803,13 @@ public:
}
bool matches(const pkgCache::PkgIterator &pkg,
- const pkgCache::VerIterator &ver)
+ const pkgCache::VerIterator &ver,
+ aptitudeDepCache &cache,
+ pkgRecords &records)
{
for(pkgCache::PrvIterator p=pkg.ProvidesList(); !p.end(); ++p)
{
- if(pattern->matches(p.OwnerPkg(), p.OwnerVer()))
+ if(pattern->matches(p.OwnerPkg(), p.OwnerVer(), cache, records))
return true;
}
@@ -1651,12 +1817,15 @@ public:
}
pkg_match_result *get_match(const pkgCache::PkgIterator &pkg,
- const pkgCache::VerIterator &ver)
+ const pkgCache::VerIterator &ver,
+ aptitudeDepCache &cache,
+ pkgRecords &records)
{
for(pkgCache::PrvIterator p=pkg.ProvidesList(); !p.end(); ++p)
{
pkg_match_result *r = pattern->get_match(p.OwnerPkg(),
- p.OwnerVer());
+ p.OwnerVer(),
+ cache, records);
if(r != NULL)
return new result_pair(r,
@@ -1682,7 +1851,9 @@ public:
}
bool matches(const pkgCache::PkgIterator &pkg,
- const pkgCache::VerIterator &ver)
+ const pkgCache::VerIterator &ver,
+ aptitudeDepCache &cache,
+ pkgRecords &records)
{
if(ver.end())
return false;
@@ -1692,7 +1863,7 @@ public:
while(!dep.end())
{
- if((*apt_cache_file)->GetPolicy().IsImportantDep(dep) &&
+ if(cache.GetPolicy().IsImportantDep(dep) &&
!dep.ParentVer().ParentPkg().CurrentVer().end())
return false;
@@ -1704,9 +1875,11 @@ public:
}
pkg_match_result *get_match(const pkgCache::PkgIterator &pkg,
- const pkgCache::VerIterator &ver)
+ const pkgCache::VerIterator &ver,
+ aptitudeDepCache &cache,
+ pkgRecords &records)
{
- if(!matches(pkg, ver))
+ if(!matches(pkg, ver, cache, records))
return NULL;
else
return new unitary_result(_("No reverse dependencies"));
@@ -1725,7 +1898,9 @@ public:
}
bool matches(const pkgCache::PkgIterator &pkg,
- const pkgCache::VerIterator &ver)
+ const pkgCache::VerIterator &ver,
+ aptitudeDepCache &cache,
+ pkgRecords &records)
{
if(ver.end())
return false;
@@ -1747,9 +1922,11 @@ public:
}
pkg_match_result *get_match(const pkgCache::PkgIterator &pkg,
- const pkgCache::VerIterator &ver)
+ const pkgCache::VerIterator &ver,
+ aptitudeDepCache &cache,
+ pkgRecords &records)
{
- if(!matches(pkg, ver))
+ if(!matches(pkg, ver, cache, records))
return NULL;
else
return new unitary_result(pkgCache::DepType(type));
@@ -1760,19 +1937,23 @@ class pkg_new_matcher:public pkg_matcher
{
public:
bool matches(const pkgCache::PkgIterator &pkg,
- const pkgCache::VerIterator &ver)
+ const pkgCache::VerIterator &ver,
+ aptitudeDepCache &cache,
+ pkgRecords &records)
{
// Don't match virtual packages.
if(pkg.VersionList().end())
return false;
else
- return (*apt_cache_file)->get_ext_state(pkg).new_package;
+ return cache.get_ext_state(pkg).new_package;
}
pkg_match_result *get_match(const pkgCache::PkgIterator &pkg,
- const pkgCache::VerIterator &ver)
+ const pkgCache::VerIterator &ver,
+ aptitudeDepCache &cache,
+ pkgRecords &records)
{
- if(!matches(pkg, ver))
+ if(!matches(pkg, ver, cache, records))
return NULL;
else
return new unitary_result(_("New Package"));
@@ -1783,15 +1964,19 @@ class pkg_upgradable_matcher:public pkg_matcher
{
public:
bool matches(const pkgCache::PkgIterator &pkg,
- const pkgCache::VerIterator &ver)
+ const pkgCache::VerIterator &ver,
+ aptitudeDepCache &cache,
+ pkgRecords &records)
{
- return !pkg.CurrentVer().end() && (*apt_cache_file)[pkg].Upgradable();
+ return !pkg.CurrentVer().end() && cache[pkg].Upgradable();
}
pkg_match_result *get_match(const pkgCache::PkgIterator &pkg,
- const pkgCache::VerIterator &ver)
+ const pkgCache::VerIterator &ver,
+ aptitudeDepCache &cache,
+ pkgRecords &records)
{
- if(!matches(pkg, ver))
+ if(!matches(pkg, ver, cache, records))
return NULL;
else
return new unitary_result(_("Upgradable"));
diff --git a/src/generic/apt/matchers.h b/src/generic/apt/matchers.h
index baeb5e39..f6df1bcc 100644
--- a/src/generic/apt/matchers.h
+++ b/src/generic/apt/matchers.h
@@ -29,6 +29,9 @@
#include <apt-pkg/pkgcache.h>
+class aptitudeDepCache;
+class pkgRecords;
+
/* For the cases where you want to investigate just what you matched a
* bit more thoroughly.
*
@@ -52,24 +55,35 @@ class pkg_matcher
{
public:
virtual bool matches(const pkgCache::PkgIterator &pkg,
- const pkgCache::VerIterator &ver)=0;
+ const pkgCache::VerIterator &ver,
+ aptitudeDepCache &cache,
+ pkgRecords &records)=0;
+
+
+
/** \return a match result, or \b NULL if there is no match. It's
* the caller's responsibility to delete this.
*/
virtual pkg_match_result *get_match(const pkgCache::PkgIterator &pkg,
- const pkgCache::VerIterator &ver)=0;
+ const pkgCache::VerIterator &ver,
+ aptitudeDepCache &cache,
+ pkgRecords &records)=0;
/** See whether this matches a versionless package. This applies
* the matcher to every version of the package and returns \b true
* if any version is matched.
*/
- virtual bool matches(const pkgCache::PkgIterator &pkg);
+ virtual bool matches(const pkgCache::PkgIterator &pkg,
+ aptitudeDepCache &cache,
+ pkgRecords &records);
/** Get a match result for a versionless package. This applies the
* matcher to each version of the package, returning \b NULL if
* none matches or the first match found otherwise.
*/
- virtual pkg_match_result *get_match(const pkgCache::PkgIterator &pkg);
+ virtual pkg_match_result *get_match(const pkgCache::PkgIterator &pkg,
+ aptitudeDepCache &cache,
+ pkgRecords &records);
virtual ~pkg_matcher();
};
@@ -127,7 +141,9 @@ inline pkg_matcher *parse_pattern(const std::string &s,
inline bool pkg_matches(const string &s,
const pkgCache::PkgIterator &pkg,
- const pkgCache::VerIterator &ver)
+ const pkgCache::VerIterator &ver,
+ aptitudeDepCache &cache,
+ pkgRecords &records)
{
std::string::const_iterator start=s.begin();
std::auto_ptr<pkg_matcher> m(parse_pattern(start, s.end()));
@@ -135,7 +151,7 @@ inline bool pkg_matches(const string &s,
return false;
else
{
- bool rval=m.get()->matches(pkg, ver);
+ bool rval=m.get()->matches(pkg, ver, cache, records);
return rval;
}
}
diff --git a/src/menu_tree.cc b/src/menu_tree.cc
index 18b5c82a..a241cb79 100644
--- a/src/menu_tree.cc
+++ b/src/menu_tree.cc
@@ -50,13 +50,17 @@ public:
// EWW
const pkg_item *pitem=dynamic_cast<const pkg_item *>(&item);
if(pitem)
- return matcher->matches(pitem->get_package());
+ return matcher->matches(pitem->get_package(),
+ *apt_cache_file,
+ *apt_package_records);
else {
const pkg_ver_item *pvitem=dynamic_cast<const pkg_ver_item *>(&item);
if(pvitem)
return matcher->matches(pvitem->get_package(),
- pvitem->get_version());
+ pvitem->get_version(),
+ *apt_cache_file,
+ *apt_package_records);
else
return false;
}
diff --git a/src/pkg_columnizer.cc b/src/pkg_columnizer.cc
index 2505dc22..2d831a9b 100644
--- a/src/pkg_columnizer.cc
+++ b/src/pkg_columnizer.cc
@@ -329,7 +329,8 @@ column_disposition pkg_item::pkg_columnizer::setup_column(const pkgCache::PkgIte
break;
case description:
- return column_disposition(get_short_description(visible_ver), 0);
+ return column_disposition(get_short_description(visible_ver,
+ apt_package_records), 0);
break;
case maintainer:
diff --git a/src/pkg_grouppolicy.cc b/src/pkg_grouppolicy.cc
index 673d2701..80269db0 100644
--- a/src/pkg_grouppolicy.cc
+++ b/src/pkg_grouppolicy.cc
@@ -416,7 +416,7 @@ public:
virtual void add_package(const pkgCache::PkgIterator &pkg, pkg_subtree *root)
{
- if(filter->matches(pkg))
+ if(filter->matches(pkg, *apt_cache_file, *apt_package_records))
chain->add_package(pkg, root);
}
@@ -458,7 +458,7 @@ public:
void add_package(const pkgCache::PkgIterator &pkg, pkg_subtree *root)
{
- int group=find_pkg_state(pkg);
+ int group = find_pkg_state(pkg, *apt_cache_file);
if(group!=pkg_unchanged)
{
if(!children[group].second)
@@ -1142,7 +1142,7 @@ public:
for(vector<match_pair>::const_iterator i = subgroups.begin();
i != subgroups.end(); ++i)
{
- pkg_match_result *res = i->matcher->get_match(pkg);
+ pkg_match_result *res = i->matcher->get_match(pkg, *apt_cache_file, *apt_package_records);
if(res != NULL)
{
if(i->passthrough)
diff --git a/src/pkg_info_screen.cc b/src/pkg_info_screen.cc
index 42ba773a..8abcf0ce 100644
--- a/src/pkg_info_screen.cc
+++ b/src/pkg_info_screen.cc
@@ -78,7 +78,7 @@ void pkg_grouppolicy_info::setup_package_info(const pkgCache::PkgIterator &pkg,
{
pkgRecords::Parser &rec=apt_package_records->Lookup(ver.FileList());
- std::wstring desc(get_long_description(ver));
+ std::wstring desc(get_long_description(ver, apt_package_records));
std::wstring shortdesc(desc, 0, desc.find(L'\n'));
vector<fragment*> frags;
diff --git a/src/pkg_item.cc b/src/pkg_item.cc
index f7a648c7..278fa739 100644
--- a/src/pkg_item.cc
+++ b/src/pkg_item.cc
@@ -475,7 +475,9 @@ void pkg_item::dispatch_mouse(short id, int x, mmask_t bstate, vs_tree *owner)
bool pkg_item::matches(const string &s) const
{
- return pkg_matches(s, package, visible_version());
+ return pkg_matches(s, package, visible_version(),
+ *apt_cache_file,
+ *apt_package_records);
}
pkgCache::VerIterator pkg_item::visible_version(const pkgCache::PkgIterator &pkg)
diff --git a/src/pkg_tree.cc b/src/pkg_tree.cc
index 2d2c6ef9..3855038c 100644
--- a/src/pkg_tree.cc
+++ b/src/pkg_tree.cc
@@ -1,6 +1,6 @@
// pkg_tree.cc
//
-// Copyright 1999-2005 Daniel Burrows
+// Copyright 1999-2005, 2007 Daniel Burrows
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
@@ -184,7 +184,7 @@ bool pkg_tree::build_tree(OpProgress &progress)
if(i.VersionList().end() && i.ProvidesList().end())
continue;
- if((!limit) || limit->matches(i))
+ if((!limit) || limit->matches(i, *apt_cache_file, *apt_package_records))
{
empty=false;
grouper->add_package(i, mytree);
diff --git a/src/pkg_ver_item.cc b/src/pkg_ver_item.cc
index d61ca590..35908411 100644
--- a/src/pkg_ver_item.cc
+++ b/src/pkg_ver_item.cc
@@ -323,7 +323,7 @@ column_disposition pkg_ver_columnizer::setup_column(const pkgCache::VerIterator
break;
case description:
- return column_disposition(get_short_description(ver), 0);
+ return column_disposition(get_short_description(ver, apt_package_records), 0);
case maintainer:
if(ver.end())
return column_disposition("", 0);
diff --git a/src/pkg_view.cc b/src/pkg_view.cc
index cd487601..97830732 100644
--- a/src/pkg_view.cc
+++ b/src/pkg_view.cc
@@ -228,7 +228,7 @@ public:
{
// Check against pkg.end() to hack around #339533; if ver is a
// default iterator, pkg.end() is true.
- wstring newdesc(pkg.end() ? L"" : get_long_description(ver));
+ wstring newdesc(pkg.end() ? L"" : get_long_description(ver, apt_package_records));
fragment *frag=make_desc_fragment(newdesc);
diff --git a/src/reason_fragment.cc b/src/reason_fragment.cc
index caca79cf..63b00da0 100644
--- a/src/reason_fragment.cc
+++ b/src/reason_fragment.cc
@@ -345,7 +345,7 @@ fragment *reason_fragment(const pkgCache::PkgIterator &pkg, bool &breakage)
infer_reason(pkg, reasons);
vector<fragment *> fragments;
- pkg_action_state actionstate=find_pkg_state(pkg);
+ pkg_action_state actionstate = find_pkg_state(pkg, *apt_cache_file);
aptitudeDepCache::StateCache &state=(*apt_cache_file)[pkg];
aptitudeDepCache::aptitude_state &estate=(*apt_cache_file)->get_ext_state(pkg);
diff --git a/src/solution_item.cc b/src/solution_item.cc
index fad45f73..afd3d496 100644
--- a/src/solution_item.cc
+++ b/src/solution_item.cc
@@ -263,7 +263,7 @@ void solution_act_item::do_highlighted_changed(bool highlighted)
apt_package_records == NULL)
set_short_description(fragf(""));
else
- set_short_description(text_fragment(get_short_description(real_ver)));
+ set_short_description(text_fragment(get_short_description(real_ver, apt_package_records)));
set_active_dep(d);
}
diff --git a/src/ui.cc b/src/ui.cc
index 8d065c04..079f7b84 100644
--- a/src/ui.cc
+++ b/src/ui.cc
@@ -1460,7 +1460,7 @@ void do_package_run_or_show_preview()
bool some_non_simple_keep_happening=false;
for(pkgCache::PkgIterator i=(*apt_cache_file)->PkgBegin(); !i.end(); ++i)
{
- pkg_action_state state=find_pkg_state(i);
+ pkg_action_state state = find_pkg_state(i, *apt_cache_file);
if(state!=pkg_unchanged)
{