summaryrefslogtreecommitdiff
path: root/apt-pkg/pkgcache.cc
diff options
context:
space:
mode:
Diffstat (limited to 'apt-pkg/pkgcache.cc')
-rw-r--r--apt-pkg/pkgcache.cc37
1 files changed, 23 insertions, 14 deletions
diff --git a/apt-pkg/pkgcache.cc b/apt-pkg/pkgcache.cc
index 93d09a18e..38e4e904e 100644
--- a/apt-pkg/pkgcache.cc
+++ b/apt-pkg/pkgcache.cc
@@ -220,6 +220,9 @@ pkgCache::PkgIterator pkgCache::FindPkg(const string &Name) {
return FindPkg(Name, "native");
}
string const Arch = Name.substr(found+1);
+ /* Beware: This is specialcased to handle pkg:any in dependencies as
+ these are linked to virtual pkg:any named packages with all archs.
+ If you want any arch from a given pkg, use FindPkg(pkg,arch) */
if (Arch == "any")
return FindPkg(Name, "any");
return FindPkg(Name.substr(0, found), Arch);
@@ -231,7 +234,7 @@ pkgCache::PkgIterator pkgCache::FindPkg(const string &Name) {
pkgCache::PkgIterator pkgCache::FindPkg(const string &Name, string const &Arch) {
if (MultiArchCache() == false) {
if (Arch == "native" || Arch == "all" || Arch == "any" ||
- Arch == _config->Find("APT::Architecture"))
+ Arch == NativeArch())
return SingleArchFindPkg(Name);
else
return PkgIterator(*this,0);
@@ -325,15 +328,15 @@ pkgCache::PkgIterator pkgCache::GrpIterator::FindPkg(string Arch) const {
if (Arch == "any")
return PkgIterator(*Owner, Owner->PkgP + S->FirstPackage);
- static string const myArch = _config->Find("APT::Architecture");
+ char const* const myArch = Owner->NativeArch();
/* Most of the time the package for our native architecture is
the one we add at first to the cache, but this would be the
last one we check, so we do it now. */
if (Arch == "native" || Arch == myArch || Arch == "all") {
- Arch = myArch;
pkgCache::Package *Pkg = Owner->PkgP + S->LastPackage;
- if (stringcasecmp(Arch, Owner->StrP + Pkg->Arch) == 0)
+ if (strcasecmp(myArch, Owner->StrP + Pkg->Arch) == 0)
return PkgIterator(*Owner, Pkg);
+ Arch = myArch;
}
/* Iterate over the list to find the matching arch
@@ -506,7 +509,8 @@ std::string pkgCache::PkgIterator::FullName(bool const &Pretty) const
{
string fullname = Name();
if (Pretty == false ||
- (strcmp(Arch(), "all") != 0 && _config->Find("APT::Architecture") != Arch()))
+ (strcmp(Arch(), "all") != 0 &&
+ strcmp(Owner->NativeArch(), Arch()) != 0))
return fullname.append(":").append(Arch());
return fullname;
}
@@ -517,15 +521,24 @@ std::string pkgCache::PkgIterator::FullName(bool const &Pretty) const
conflicts (including dpkg's Breaks fields). */
bool pkgCache::DepIterator::IsCritical() const
{
- if (S->Type == pkgCache::Dep::Conflicts ||
- S->Type == pkgCache::Dep::DpkgBreaks ||
- S->Type == pkgCache::Dep::Obsoletes ||
+ if (IsNegative() == true ||
S->Type == pkgCache::Dep::Depends ||
S->Type == pkgCache::Dep::PreDepends)
return true;
return false;
}
/*}}}*/
+// DepIterator::IsNegative - Returns true if the dep is a negative one /*{{{*/
+// ---------------------------------------------------------------------
+/* Some dependencies are positive like Depends and Recommends, others
+ are negative like Conflicts which can and should be handled differently */
+bool pkgCache::DepIterator::IsNegative() const
+{
+ return S->Type == Dep::DpkgBreaks ||
+ S->Type == Dep::Conflicts ||
+ S->Type == Dep::Obsoletes;
+}
+ /*}}}*/
// DepIterator::SmartTargetPkg - Resolve dep target pointers w/provides /*{{{*/
// ---------------------------------------------------------------------
/* This intellegently looks at dep target packages and tries to figure
@@ -603,9 +616,7 @@ pkgCache::Version **pkgCache::DepIterator::AllTargets() const
if (Owner->VS->CheckDep(I.VerStr(),S->CompareOp,TargetVer()) == false)
continue;
- if ((S->Type == pkgCache::Dep::Conflicts ||
- S->Type == pkgCache::Dep::DpkgBreaks ||
- S->Type == pkgCache::Dep::Obsoletes) &&
+ if (IsNegative() == true &&
ParentPkg() == I.ParentPkg())
continue;
@@ -620,9 +631,7 @@ pkgCache::Version **pkgCache::DepIterator::AllTargets() const
if (Owner->VS->CheckDep(I.ProvideVersion(),S->CompareOp,TargetVer()) == false)
continue;
- if ((S->Type == pkgCache::Dep::Conflicts ||
- S->Type == pkgCache::Dep::DpkgBreaks ||
- S->Type == pkgCache::Dep::Obsoletes) &&
+ if (IsNegative() == true &&
ParentPkg() == I.OwnerPkg())
continue;