merge MultiArch-ABI. We don't support MultiArch yet (as most other tools),
[ntk/apt.git] / apt-pkg / orderlist.cc
index 7302f02..7c95029 100644 (file)
@@ -39,7 +39,7 @@
          ordering.  
    
    Each of the features can be enabled in the sorting routine at an 
-   arbitary priority to give quite abit of control over the final unpacking
+   arbitrary priority to give quite abit of control over the final unpacking
    order.
 
    The rules listed above may never be violated and are called Critical.
@@ -126,10 +126,14 @@ bool pkgOrderList::IsMissing(PkgIterator Pkg)
    
    if (FileList[Pkg->ID].empty() == false)
       return false;
+
+   // Missing Pseudo packages are missing if the real package is missing
+   if (pkgCache::VerIterator(Cache, Cache[Pkg].CandidateVer).Pseudo() == true)
+      return IsMissing(Pkg.Group().FindPkg("all"));
+
    return true;
 }
                                                                        /*}}}*/
-
 // OrderList::DoRun - Does an order run                                        /*{{{*/
 // ---------------------------------------------------------------------
 /* The caller is expeted to have setup the desired probe state */
@@ -175,22 +179,35 @@ bool pkgOrderList::DoRun()
 bool pkgOrderList::OrderCritical()
 {
    FileList = 0;
-   
-   Primary = &pkgOrderList::DepUnPackPre;
+
+   Primary = &pkgOrderList::DepUnPackPreD;
    Secondary = 0;
    RevDepends = 0;
    Remove = 0;
    LoopCount = 0;
-   
+
    // Sort
    Me = this;
-   qsort(List,End - List,sizeof(*List),&OrderCompareB);   
-   
+   qsort(List,End - List,sizeof(*List),&OrderCompareB);
+
    if (DoRun() == false)
       return false;
-   
+
    if (LoopCount != 0)
       return _error->Error("Fatal, predepends looping detected");
+
+   if (Debug == true)
+   {
+      clog << "** Critical Unpack ordering done" << endl;
+
+      for (iterator I = List; I != End; I++)
+      {
+        PkgIterator P(Cache,*I);
+        if (IsNow(P) == true)
+           clog << "  " << P.FullName() << ' ' << IsMissing(P) << ',' << IsFlag(P,After) << endl;
+      }
+   }
+
    return true;
 }
                                                                        /*}}}*/
@@ -206,7 +223,7 @@ bool pkgOrderList::OrderUnpack(string *FileList)
    if (FileList != 0)
    {
       WipeFlags(After);
-      
+
       // Set the inlist flag
       for (iterator I = List; I != End; I++)
       {
@@ -215,7 +232,7 @@ bool pkgOrderList::OrderUnpack(string *FileList)
             Flag(*I,After);
       }
    }
-   
+
    Primary = &pkgOrderList::DepUnPackCrit;
    Secondary = &pkgOrderList::DepConfigure;
    RevDepends = &pkgOrderList::DepUnPackDep;
@@ -230,7 +247,7 @@ bool pkgOrderList::OrderUnpack(string *FileList)
       clog << "** Pass A" << endl;
    if (DoRun() == false)
       return false;
-   
+
    if (Debug == true)
       clog << "** Pass B" << endl;
    Secondary = 0;
@@ -244,7 +261,7 @@ bool pkgOrderList::OrderUnpack(string *FileList)
    Remove = 0;             // Otherwise the libreadline remove problem occures
    if (DoRun() == false)
       return false;
-      
+
    if (Debug == true)
       clog << "** Pass D" << endl;
    LoopCount = 0;
@@ -260,9 +277,9 @@ bool pkgOrderList::OrderUnpack(string *FileList)
       {
         PkgIterator P(Cache,*I);
         if (IsNow(P) == true)
-           clog << P.Name() << ' ' << IsMissing(P) << ',' << IsFlag(P,After) << endl;
+           clog << "  " << P.FullName() << ' ' << IsMissing(P) << ',' << IsFlag(P,After) << endl;
       }
-   }   
+   }
 
    return true;
 }
@@ -282,35 +299,40 @@ bool pkgOrderList::OrderConfigure()
    return DoRun();
 }
                                                                        /*}}}*/
-
 // OrderList::Score - Score the package for sorting                    /*{{{*/
 // ---------------------------------------------------------------------
 /* Higher scores order earlier */
 int pkgOrderList::Score(PkgIterator Pkg)
 {
+   static int const ScoreDelete = _config->FindI("OrderList::Score::Delete", 500);
+
    // Removal is always done first
    if (Cache[Pkg].Delete() == true)
-      return 200;
-   
+      return ScoreDelete;
+
    // This should never happen..
    if (Cache[Pkg].InstVerIter(Cache).end() == true)
       return -1;
-   
+
+   static int const ScoreEssential = _config->FindI("OrderList::Score::Essential", 200);
+   static int const ScoreImmediate = _config->FindI("OrderList::Score::Immediate", 10);
+   static int const ScorePreDepends = _config->FindI("OrderList::Score::PreDepends", 50);
+
    int Score = 0;
    if ((Pkg->Flags & pkgCache::Flag::Essential) == pkgCache::Flag::Essential)
-      Score += 100;
+      Score += ScoreEssential;
 
    if (IsFlag(Pkg,Immediate) == true)
-      Score += 10;
-   
-   for (DepIterator D = Cache[Pkg].InstVerIter(Cache).DependsList(); 
+      Score += ScoreImmediate;
+
+   for (DepIterator D = Cache[Pkg].InstVerIter(Cache).DependsList();
        D.end() == false; D++)
       if (D->Type == pkgCache::Dep::PreDepends)
       {
-        Score += 50;
+        Score += ScorePreDepends;
         break;
       }
-      
+
    // Important Required Standard Optional Extra
    signed short PrioMap[] = {0,5,4,3,1,0};
    if (Cache[Pkg].InstVerIter(Cache)->Priority <= 5)
@@ -388,6 +410,7 @@ int pkgOrderList::OrderCompareA(const void *a, const void *b)
    
    int ScoreA = Me->Score(A);
    int ScoreB = Me->Score(B);
+
    if (ScoreA > ScoreB)
       return -1;
    
@@ -424,6 +447,7 @@ int pkgOrderList::OrderCompareB(const void *a, const void *b)
    
    int ScoreA = Me->Score(A);
    int ScoreB = Me->Score(B);
+
    if (ScoreA > ScoreB)
       return -1;
    
@@ -433,7 +457,6 @@ int pkgOrderList::OrderCompareB(const void *a, const void *b)
    return strcmp(A.Name(),B.Name());
 }
                                                                        /*}}}*/
-
 // OrderList::VisitDeps - Visit forward install dependencies           /*{{{*/
 // ---------------------------------------------------------------------
 /* This calls the dependency function for the normal forwards dependencies
@@ -488,11 +511,13 @@ bool pkgOrderList::VisitProvides(DepIterator D,bool Critical)
         continue;
       
       if (D->Type != pkgCache::Dep::Conflicts &&
+         D->Type != pkgCache::Dep::DpkgBreaks &&
          D->Type != pkgCache::Dep::Obsoletes &&
          Cache[Pkg].InstallVer != *I)
         continue;
       
       if ((D->Type == pkgCache::Dep::Conflicts ||
+          D->Type == pkgCache::Dep::DpkgBreaks ||
           D->Type == pkgCache::Dep::Obsoletes) &&
          (Version *)Pkg.CurrentVer() != *I)
         continue;
@@ -523,7 +548,7 @@ bool pkgOrderList::VisitNode(PkgIterator Pkg)
    if (Debug == true)
    {
       for (int j = 0; j != Depth; j++) clog << ' ';
-      clog << "Visit " << Pkg.Name() << endl;
+      clog << "Visit " << Pkg.FullName() << endl;
    }
    
    Depth++;
@@ -582,13 +607,12 @@ bool pkgOrderList::VisitNode(PkgIterator Pkg)
    if (Debug == true)
    {
       for (int j = 0; j != Depth; j++) clog << ' ';
-      clog << "Leave " << Pkg.Name() << ' ' << IsFlag(Pkg,Added) << ',' << IsFlag(Pkg,AddPending) << endl;
+      clog << "Leave " << Pkg.FullName() << ' ' << IsFlag(Pkg,Added) << ',' << IsFlag(Pkg,AddPending) << endl;
    }
    
    return true;
 }
                                                                        /*}}}*/
-
 // OrderList::DepUnPackCrit - Critical UnPacking ordering              /*{{{*/
 // ---------------------------------------------------------------------
 /* Critical unpacking ordering strives to satisfy Conflicts: and 
@@ -627,6 +651,7 @@ bool pkgOrderList::DepUnPackCrit(DepIterator D)
         /* Forward critical dependencies MUST be correct before the 
            package can be unpacked. */
         if (D->Type != pkgCache::Dep::Conflicts &&
+            D->Type != pkgCache::Dep::DpkgBreaks &&
             D->Type != pkgCache::Dep::Obsoletes &&
             D->Type != pkgCache::Dep::PreDepends)
            continue;
@@ -670,8 +695,7 @@ bool pkgOrderList::DepUnPackCrit(DepIterator D)
 // ---------------------------------------------------------------------
 /* Critical PreDepends (also configure immediate and essential) strives to
    ensure not only that all conflicts+predepends are met but that this
-   package will be immediately configurable when it is unpacked. 
-
+   package will be immediately configurable when it is unpacked.
    Loops are preprocessed and logged. */
 bool pkgOrderList::DepUnPackPreD(DepIterator D)
 {
@@ -800,9 +824,20 @@ bool pkgOrderList::DepUnPackDep(DepIterator D)
               return false;
         }
         else
+        {
            if (D->Type == pkgCache::Dep::Depends)
               if (VisitProvides(D,false) == false)
                  return false;
+
+           if (D->Type == pkgCache::Dep::DpkgBreaks)
+           {
+              if (CheckDep(D) == true)
+                continue;
+
+              if (VisitNode(D.TargetPkg()) == false)
+                return false;
+           }
+        }
       }
    return true;
 }
@@ -878,7 +913,6 @@ bool pkgOrderList::DepRemove(DepIterator D)
    return true;
 }
                                                                        /*}}}*/
-
 // OrderList::AddLoop - Add a loop to the loop list                    /*{{{*/
 // ---------------------------------------------------------------------
 /* We record the loops. This is a relic since loop breaking is done 
@@ -950,6 +984,7 @@ bool pkgOrderList::CheckDep(DepIterator D)
       /* Conflicts requires that all versions are not present, depends
          just needs one */
       if (D->Type != pkgCache::Dep::Conflicts && 
+         D->Type != pkgCache::Dep::DpkgBreaks && 
          D->Type != pkgCache::Dep::Obsoletes)
       {
         /* Try to find something that does not have the after flag set