summaryrefslogtreecommitdiff
path: root/apt-pkg/pkgcache.cc
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2010-01-26 15:51:45 +0100
committerMichael Vogt <michael.vogt@ubuntu.com>2010-01-26 15:51:45 +0100
commit51f9f4d78deabf54dbbb6881139d2b1a319ffbfc (patch)
tree60a2bcd8911acd5c4ab8b4558bfd30344b673ff5 /apt-pkg/pkgcache.cc
parent76fe5db7153957f8fda437e3bd614312b076f19e (diff)
parentc1f168f54be5b4babeb9b91cd7145441ea2489ad (diff)
merge from the mvo branch
Diffstat (limited to 'apt-pkg/pkgcache.cc')
-rw-r--r--apt-pkg/pkgcache.cc69
1 files changed, 61 insertions, 8 deletions
diff --git a/apt-pkg/pkgcache.cc b/apt-pkg/pkgcache.cc
index 6687864ee..b0ce6e598 100644
--- a/apt-pkg/pkgcache.cc
+++ b/apt-pkg/pkgcache.cc
@@ -21,6 +21,7 @@
/*}}}*/
// Include Files /*{{{*/
#include <apt-pkg/pkgcache.h>
+#include <apt-pkg/policy.h>
#include <apt-pkg/indexfile.h>
#include <apt-pkg/version.h>
#include <apt-pkg/error.h>
@@ -49,7 +50,7 @@ pkgCache::Header::Header()
/* Whenever the structures change the major version should be bumped,
whenever the generator changes the minor version should be bumped. */
- MajorVersion = 7;
+ MajorVersion = 8;
MinorVersion = 0;
Dirty = false;
@@ -223,7 +224,7 @@ const char *pkgCache::DepType(unsigned char Type)
{
const char *Types[] = {"",_("Depends"),_("PreDepends"),_("Suggests"),
_("Recommends"),_("Conflicts"),_("Replaces"),
- _("Obsoletes"),_("Breaks")};
+ _("Obsoletes"),_("Breaks"), _("Enhances")};
if (Type < sizeof(Types)/sizeof(*Types))
return Types[Type];
return "";
@@ -274,13 +275,13 @@ pkgCache::PkgIterator::OkState pkgCache::PkgIterator::State() const
return NeedsUnpack;
if (Pkg->CurrentState == pkgCache::State::UnPacked ||
- Pkg->CurrentState == pkgCache::State::HalfConfigured ||
- //we don't need to care for triggers awaiting packages
- //dpkg will deal with them automatically when the
- //trigger pending action is run (those packages are usually
- //in half-configured or triggers-pending state)
+ Pkg->CurrentState == pkgCache::State::HalfConfigured)
+ // we leave triggers alone complettely. dpkg deals with
+ // them in a hard-to-predict manner and if they get
+ // resolved by dpkg before apt run dpkg --configure on
+ // the TriggersPending package dpkg returns a error
//Pkg->CurrentState == pkgCache::State::TriggersAwaited
- Pkg->CurrentState == pkgCache::State::TriggersPending)
+ //Pkg->CurrentState == pkgCache::State::TriggersPending)
return NeedsConfigure;
if (Pkg->CurrentState == pkgCache::State::HalfInstalled ||
@@ -290,6 +291,56 @@ pkgCache::PkgIterator::OkState pkgCache::PkgIterator::State() const
return NeedsNothing;
}
/*}}}*/
+// PkgIterator::CandVersion - Returns the candidate version string /*{{{*/
+// ---------------------------------------------------------------------
+/* Return string representing of the candidate version. */
+const char *
+pkgCache::PkgIterator::CandVersion() const
+{
+ //TargetVer is empty, so don't use it.
+ VerIterator version = pkgPolicy::pkgPolicy(Owner).GetCandidateVer(*this);
+ if (version.IsGood())
+ return version.VerStr();
+ return 0;
+};
+ /*}}}*/
+// PkgIterator::CurVersion - Returns the current version string /*{{{*/
+// ---------------------------------------------------------------------
+/* Return string representing of the current version. */
+const char *
+pkgCache::PkgIterator::CurVersion() const
+{
+ VerIterator version = CurrentVer();
+ if (version.IsGood())
+ return CurrentVer().VerStr();
+ return 0;
+};
+ /*}}}*/
+// ostream operator to handle string representation of a package /*{{{*/
+// ---------------------------------------------------------------------
+/* Output name < cur.rent.version -> candid.ate.version | new.est.version > (section)
+ Note that the characters <|>() are all literal above. Versions will be ommited
+ if they provide no new information (e.g. there is no newer version than candidate)
+ If no version and/or section can be found "none" is used. */
+std::ostream&
+operator<<(ostream& out, pkgCache::PkgIterator Pkg)
+{
+ if (Pkg.end() == true)
+ return out << "invalid package";
+
+ string current = string(Pkg.CurVersion() == 0 ? "none" : Pkg.CurVersion());
+ string candidate = string(Pkg.CandVersion() == 0 ? "none" : Pkg.CandVersion());
+ string newest = string(Pkg.VersionList().end() ? "none" : Pkg.VersionList().VerStr());
+
+ out << Pkg.Name() << " < " << current;
+ if (current != candidate)
+ out << " -> " << candidate;
+ if ( newest != "none" && candidate != newest)
+ out << " | " << newest;
+ out << " > ( " << string(Pkg.Section()==0?"none":Pkg.Section()) << " )";
+ return out;
+}
+ /*}}}*/
// DepIterator::IsCritical - Returns true if the dep is important /*{{{*/
// ---------------------------------------------------------------------
/* Currently critical deps are defined as depends, predepends and
@@ -607,6 +658,8 @@ string pkgCache::PkgFileIterator::RelStr()
Res = Res + (Res.empty() == true?"o=":",o=") + Origin();
if (Archive() != 0)
Res = Res + (Res.empty() == true?"a=":",a=") + Archive();
+ if (Codename() != 0)
+ Res = Res + (Res.empty() == true?"n=":",n=") + Codename();
if (Label() != 0)
Res = Res + (Res.empty() == true?"l=":",l=") + Label();
if (Component() != 0)