]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/pkgcache.cc
* apt-pkg/deb/deblistparser.cc:
[apt.git] / apt-pkg / pkgcache.cc
index 94c58f1f0bc5c42f75ae9896ab530c55d1caeb92..f694a237e2435c446fef9cd0c413f6868c3b1829 100644 (file)
@@ -490,7 +490,7 @@ pkgCache::PkgIterator::CurVersion() const
    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) 
+operator<<(std::ostream& out, pkgCache::PkgIterator Pkg) 
 {
    if (Pkg.end() == true)
       return out << "invalid package";
@@ -619,13 +619,12 @@ pkgCache::Version **pkgCache::DepIterator::AllTargets() const
       // Walk along the actual package providing versions
       for (VerIterator I = DPkg.VersionList(); I.end() == false; ++I)
       {
-        if (Owner->VS->CheckDep(I.VerStr(),S->CompareOp,TargetVer()) == false)
+        if (IsIgnorable(I.ParentPkg()) == true)
            continue;
 
-        if (IsNegative() == true &&
-            ParentPkg() == I.ParentPkg())
+        if (Owner->VS->CheckDep(I.VerStr(),S->CompareOp,TargetVer()) == false)
            continue;
-        
+
         Size++;
         if (Res != 0)
            *End++ = I;
@@ -634,13 +633,12 @@ pkgCache::Version **pkgCache::DepIterator::AllTargets() const
       // Follow all provides
       for (PrvIterator I = DPkg.ProvidesList(); I.end() == false; ++I)
       {
-        if (Owner->VS->CheckDep(I.ProvideVersion(),S->CompareOp,TargetVer()) == false)
+        if (IsIgnorable(I) == true)
            continue;
-        
-        if (IsNegative() == true &&
-            ParentPkg() == I.OwnerPkg())
+
+        if (Owner->VS->CheckDep(I.ProvideVersion(),S->CompareOp,TargetVer()) == false)
            continue;
-        
+
         Size++;
         if (Res != 0)
            *End++ = I.OwnerVer();
@@ -682,10 +680,53 @@ void pkgCache::DepIterator::GlobOr(DepIterator &Start,DepIterator &End)
    }
 }
                                                                        /*}}}*/
+// DepIterator::IsIgnorable - should this packag/providr be ignored?   /*{{{*/
+// ---------------------------------------------------------------------
+/* Deps like self-conflicts should be ignored as well as implicit conflicts
+   on virtual packages. */
+bool pkgCache::DepIterator::IsIgnorable(PkgIterator const &Pkg) const
+{
+   if (ParentPkg() == TargetPkg())
+      return IsNegative();
+
+   return false;
+}
+bool pkgCache::DepIterator::IsIgnorable(PrvIterator const &Prv) const
+{
+   if (IsNegative() == false)
+      return false;
+
+   PkgIterator const Pkg = ParentPkg();
+   /* Provides may never be applied against the same package (or group)
+      if it is a conflicts. See the comment above. */
+   if (Prv.OwnerPkg()->Group == Pkg->Group)
+      return true;
+   // Implicit group-conflicts should not be applied on providers of other groups
+   if (Pkg->Group == TargetPkg()->Group && Prv.OwnerPkg()->Group != Pkg->Group)
+      return true;
+
+   return false;
+}
+                                                                       /*}}}*/
+// DepIterator::IsMultiArchImplicit - added by the cache generation    /*{{{*/
+// ---------------------------------------------------------------------
+/* MultiArch can be translated to SingleArch for an resolver and we did so,
+   by adding dependencies to help the resolver understand the problem, but
+   sometimes it is needed to identify these to ignore them… */
+bool pkgCache::DepIterator::IsMultiArchImplicit() const
+{
+   if (ParentPkg()->Arch != TargetPkg()->Arch &&
+       (S->Type == pkgCache::Dep::Replaces ||
+       S->Type == pkgCache::Dep::DpkgBreaks ||
+       S->Type == pkgCache::Dep::Conflicts))
+      return true;
+   return false;
+}
+                                                                       /*}}}*/
 // ostream operator to handle string representation of a dependecy     /*{{{*/
 // ---------------------------------------------------------------------
 /* */
-std::ostream& operator<<(ostream& out, pkgCache::DepIterator D)
+std::ostream& operator<<(std::ostream& out, pkgCache::DepIterator D)
 {
    if (D.end() == true)
       return out << "invalid dependency";
@@ -894,11 +935,22 @@ pkgCache::DescIterator pkgCache::VerIterator::TranslatedDescription() const
    {
       pkgCache::DescIterator Desc = DescriptionList();
       for (; Desc.end() == false; ++Desc)
-        if (*l == Desc.LanguageCode() ||
-            (*l == "en" && strcmp(Desc.LanguageCode(),"") == 0))
+        if (*l == Desc.LanguageCode())
            break;
       if (Desc.end() == true)
-        continue;
+      {
+        if (*l == "en")
+        {
+           Desc = DescriptionList();
+           for (; Desc.end() == false; ++Desc)
+              if (strcmp(Desc.LanguageCode(), "") == 0)
+                 break;
+           if (Desc.end() == true)
+              continue;
+        }
+        else
+           continue;
+      }
       return Desc;
    }
    for (pkgCache::DescIterator Desc = DescriptionList();
@@ -909,3 +961,17 @@ pkgCache::DescIterator pkgCache::VerIterator::TranslatedDescription() const
 };
 
                                                                        /*}}}*/
+// PrvIterator::IsMultiArchImplicit - added by the cache generation    /*{{{*/
+// ---------------------------------------------------------------------
+/* MultiArch can be translated to SingleArch for an resolver and we did so,
+   by adding provides to help the resolver understand the problem, but
+   sometimes it is needed to identify these to ignore them… */
+bool pkgCache::PrvIterator::IsMultiArchImplicit() const
+{
+   pkgCache::PkgIterator const Owner = OwnerPkg();
+   pkgCache::PkgIterator const Parent = ParentPkg();
+   if (Owner->Arch != Parent->Arch || Owner->Name == Parent->Name)
+      return true;
+   return false;
+}
+                                                                       /*}}}*/