]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/algorithms.cc
apt-pkg/acquire-item.cc: Fix pkgAcqFile::Custom600Headers() to always return something.
[apt.git] / apt-pkg / algorithms.cc
index 68a4af8ed7b260f69c6a3ee786ab52658f4ecc16..f1e51131a363adefe89f780c90dae5375b19e6dd 100644 (file)
@@ -83,13 +83,28 @@ void pkgSimulate::Describe(PkgIterator Pkg,ostream &out,bool Current,bool Candid
 bool pkgSimulate::Install(PkgIterator iPkg,string /*File*/)
 {
    // Adapt the iterator
-   PkgIterator Pkg = Sim.FindPkg(iPkg.Name());
+   PkgIterator Pkg = Sim.FindPkg(iPkg.Name(), iPkg.Arch());
    Flags[Pkg->ID] = 1;
    
    cout << "Inst ";
    Describe(Pkg,cout,true,true);
    Sim.MarkInstall(Pkg,false);
-   
+
+   if (strcmp(Pkg.Arch(),"all") == 0)
+   {
+      pkgCache::GrpIterator G = Pkg.Group();
+      pkgCache::GrpIterator iG = iPkg.Group();
+      for (pkgCache::PkgIterator P = G.FindPkg("any"); P.end() != true; P = G.NextPkg(P))
+      {
+        if (strcmp(P.Arch(), "all") == 0)
+           continue;
+        if (iG.FindPkg(P.Arch())->CurrentVer == 0)
+           continue;
+        Flags[P->ID] = 1;
+        Sim.MarkInstall(P, false);
+      }
+   }
+
    // Look for broken conflicts+predepends.
    for (PkgIterator I = Sim.PkgBegin(); I.end() == false; I++)
    {
@@ -131,9 +146,22 @@ bool pkgSimulate::Install(PkgIterator iPkg,string /*File*/)
 bool pkgSimulate::Configure(PkgIterator iPkg)
 {
    // Adapt the iterator
-   PkgIterator Pkg = Sim.FindPkg(iPkg.Name());
+   PkgIterator Pkg = Sim.FindPkg(iPkg.Name(), iPkg.Arch());
    
    Flags[Pkg->ID] = 2;
+
+   if (strcmp(Pkg.Arch(),"all") == 0)
+   {
+      pkgCache::GrpIterator G = Pkg.Group();
+      for (pkgCache::PkgIterator P = G.FindPkg("any"); P.end() != true; P = G.NextPkg(P))
+      {
+        if (strcmp(P.Arch(), "all") == 0)
+           continue;
+        if (Flags[P->ID] == 1)
+           Flags[P->ID] = 2;
+      }
+   }
+
 //   Sim.MarkInstall(Pkg,false);
    if (Sim[Pkg].InstBroken() == true)
    {
@@ -181,10 +209,26 @@ bool pkgSimulate::Configure(PkgIterator iPkg)
 bool pkgSimulate::Remove(PkgIterator iPkg,bool Purge)
 {
    // Adapt the iterator
-   PkgIterator Pkg = Sim.FindPkg(iPkg.Name());
+   PkgIterator Pkg = Sim.FindPkg(iPkg.Name(), iPkg.Arch());
 
    Flags[Pkg->ID] = 3;
    Sim.MarkDelete(Pkg);
+
+   if (strcmp(Pkg.Arch(),"all") == 0)
+   {
+      pkgCache::GrpIterator G = Pkg.Group();
+      pkgCache::GrpIterator iG = iPkg.Group();
+      for (pkgCache::PkgIterator P = G.FindPkg("any"); P.end() != true; P = G.NextPkg(P))
+      {
+        if (strcmp(P.Arch(), "all") == 0)
+           continue;
+        if (iG.FindPkg(P.Arch())->CurrentVer == 0)
+           continue;
+        Flags[P->ID] = 3;
+        Sim.MarkDelete(P);
+      }
+   }
+
    if (Purge == true)
       cout << "Purg ";
    else
@@ -491,15 +535,16 @@ void pkgProblemResolver::MakeScores()
    // Important Required Standard Optional Extra
    signed short PrioMap[] = {
       0,
-      _config->FindI("pkgProblemResolver::Scores::Important",3),
-      _config->FindI("pkgProblemResolver::Scores::Required",2),
-      _config->FindI("pkgProblemResolver::Scores::Standard",1),
-      _config->FindI("pkgProblemResolver::Scores::Optional",-1),
-      _config->FindI("pkgProblemResolver::Scores::Extra",-2)
+      (signed short) _config->FindI("pkgProblemResolver::Scores::Important",3),
+      (signed short) _config->FindI("pkgProblemResolver::Scores::Required",2),
+      (signed short) _config->FindI("pkgProblemResolver::Scores::Standard",1),
+      (signed short) _config->FindI("pkgProblemResolver::Scores::Optional",-1),
+      (signed short) _config->FindI("pkgProblemResolver::Scores::Extra",-2)
    };
    signed short PrioEssentials = _config->FindI("pkgProblemResolver::Scores::Essentials",100);
    signed short PrioInstalledAndNotObsolete = _config->FindI("pkgProblemResolver::Scores::NotObsolete",1);
    signed short PrioDepends = _config->FindI("pkgProblemResolver::Scores::Depends",1);
+   signed short PrioRecommends = _config->FindI("pkgProblemResolver::Scores::Recommends",1);
    signed short AddProtected = _config->FindI("pkgProblemResolver::Scores::AddProtected",10000);
    signed short AddEssential = _config->FindI("pkgProblemResolver::Scores::AddEssential",5000);
 
@@ -513,6 +558,7 @@ void pkgProblemResolver::MakeScores()
          << "  Essentials => " << PrioEssentials << endl
          << "  InstalledAndNotObsolete => " << PrioInstalledAndNotObsolete << endl
          << "  Depends => " << PrioDepends << endl
+         << "  Recommends => " << PrioRecommends << endl
          << "  AddProtected => " << AddProtected << endl
          << "  AddEssential => " << AddEssential << endl;
 
@@ -551,8 +597,11 @@ void pkgProblemResolver::MakeScores()
       
       for (pkgCache::DepIterator D = Cache[I].InstVerIter(Cache).DependsList(); D.end() == false; D++)
       {
-        if (D->Type == pkgCache::Dep::Depends || D->Type == pkgCache::Dep::PreDepends)
-           Scores[D.TargetPkg()->ID]+= PrioDepends;
+        if (D->Type == pkgCache::Dep::Depends || 
+            D->Type == pkgCache::Dep::PreDepends)
+           Scores[D.TargetPkg()->ID] += PrioDepends;
+        else if (D->Type == pkgCache::Dep::Recommends)
+           Scores[D.TargetPkg()->ID] += PrioRecommends;
       }
    }   
    
@@ -572,7 +621,9 @@ void pkgProblemResolver::MakeScores()
       {
         // Only do it for the install version
         if ((pkgCache::Version *)D.ParentVer() != Cache[D.ParentPkg()].InstallVer ||
-            (D->Type != pkgCache::Dep::Depends && D->Type != pkgCache::Dep::PreDepends))
+            (D->Type != pkgCache::Dep::Depends && 
+             D->Type != pkgCache::Dep::PreDepends &&
+             D->Type != pkgCache::Dep::Recommends))
            continue;    
         
         Scores[I->ID] += abs(OldScores[D.ParentPkg()->ID]);
@@ -984,26 +1035,11 @@ bool pkgProblemResolver::Resolve(bool BrokenFix)
                        // Consider other options
                        if (InOr == false)
                        {
-                          if (Cache.AutoInstOk(I, Cache[I].CandidateVerIter(Cache),Start) == true)
-                          {
-                             if (Debug == true)
-                                clog << "  Removing " << I.Name() << " rather than change " << Start.TargetPkg().Name() << endl;
-                             Cache.MarkDelete(I);
-                             if (Counter > 1)
-                             {
-                                if (Scores[Pkg->ID] > Scores[I->ID])
-                                   Scores[I->ID] = Scores[Pkg->ID];
-                             }
-                          } else {
-                             /* The dependency of the TargetPkg would be satisfiable with I but it is
-                                forbidden to install I automatical, so anything we can do is hold
-                                back the TargetPkg.
-                             */
-                             if (Debug == true)
-                                clog << "  Hold back " << Start.TargetPkg().Name() <<
-                                       " rather than change denied AutoInstall " << I.Name() << endl;
-                             Cache.MarkKeep(Start.TargetPkg());
-                          }
+                          if (Debug == true)
+                             clog << "  Removing " << I.Name() << " rather than change " << Start.TargetPkg().Name() << endl;
+                          Cache.MarkDelete(I);
+                          if (Counter > 1 && Scores[Pkg->ID] > Scores[I->ID])
+                             Scores[I->ID] = Scores[Pkg->ID];
                        }
                     }
                  }
@@ -1362,7 +1398,9 @@ bool ListUpdate(pkgAcquireStatus &Stat,
                int PulseInterval)
 {
    pkgAcquire::RunResult res;
-   pkgAcquire Fetcher(&Stat);
+   pkgAcquire Fetcher;
+   if (Fetcher.Setup(&Stat, _config->FindDir("Dir::State::Lists")) == false)
+      return false;
 
    // Populate it with the source selection
    if (List.GetIndexes(&Fetcher) == false)