X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/0a8e3465cb644e380ab0fc6d66f6d1f17363b34e..2c618e31b932f5c583bae5f144bef8035e68cb22:/apt-pkg/algorithms.cc diff --git a/apt-pkg/algorithms.cc b/apt-pkg/algorithms.cc index 2e4ca5c2c..350b57468 100644 --- a/apt-pkg/algorithms.cc +++ b/apt-pkg/algorithms.cc @@ -1,6 +1,6 @@ // -*- mode: cpp; mode: fold -*- // Description /*{{{*/ -// $Id: algorithms.cc,v 1.4 1998/10/02 04:39:42 jgg Exp $ +// $Id: algorithms.cc,v 1.8 1998/10/24 04:58:04 jgg Exp $ /* ###################################################################### Algorithms - A set of misc algorithms @@ -197,7 +197,7 @@ bool pkgFixBroken(pkgDepCache &Cache) for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++) if (Cache[I].NowBroken() == true) Cache.MarkInstall(I,true); - + /* Fix packages that are in a NeedArchive state but don't have a downloadable install version */ for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++) @@ -209,7 +209,7 @@ bool pkgFixBroken(pkgDepCache &Cache) if (Cache[I].InstVerIter(Cache).Downloadable() == false) continue; - Cache.MarkInstall(I,true); + Cache.MarkInstall(I,true); } pkgProblemResolver Fix(Cache); @@ -245,14 +245,17 @@ bool pkgDistUpgrade(pkgDepCache &Cache) Cache.MarkInstall(I,false); pkgProblemResolver Fix(Cache); - + // Hold back held packages. - for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++) + if (_config->FindB("APT::Ingore-Hold",false) == false) { - if (I->SelectedState == pkgCache::State::Hold) + for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++) { - Fix.Protect(I); - Cache.MarkKeep(I); + if (I->SelectedState == pkgCache::State::Hold) + { + Fix.Protect(I); + Cache.MarkKeep(I); + } } } @@ -277,8 +280,9 @@ bool pkgAllUpgrade(pkgDepCache &Cache) if (Cache[I].Install() == true) Fix.Protect(I); - if (I->SelectedState == pkgCache::State::Hold) - continue; + if (_config->FindB("APT::Ingore-Hold",false) == false) + if (I->SelectedState == pkgCache::State::Hold) + continue; if (I->CurrentVer != 0 && Cache[I].InstallVer != 0) Cache.MarkInstall(I,false); @@ -287,6 +291,43 @@ bool pkgAllUpgrade(pkgDepCache &Cache) return Fix.ResolveByKeep(); } /*}}}*/ +// MinimizeUpgrade - Minimizes the set of packages to be upgraded /*{{{*/ +// --------------------------------------------------------------------- +/* This simply goes over the entire set of packages and tries to keep + each package marked for upgrade. If a conflict is generated then + the package is restored. */ +bool pkgMinimizeUpgrade(pkgDepCache &Cache) +{ + if (Cache.BrokenCount() != 0) + return false; + + // We loop indefinately to get the minimal set size. + bool Change = false; + do + { + Change = false; + for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++) + { + // Not interesting + if (Cache[I].Upgrade() == false || Cache[I].NewInstall() == true) + continue; + + // Keep it and see if that is OK + Cache.MarkKeep(I); + if (Cache.BrokenCount() != 0) + Cache.MarkInstall(I,false); + else + Change = true; + } + } + while (Change == true); + + if (Cache.BrokenCount() != 0) + return _error->Error("Internal Error in pkgMinimizeUpgrade"); + + return true; +} + /*}}}*/ // ProblemResolver::pkgProblemResolver - Constructor /*{{{*/ // --------------------------------------------------------------------- @@ -676,7 +717,7 @@ bool pkgProblemResolver::Resolve(bool BrokenFix) ((Cache[End] & pkgDepCache::DepGNow) == 0 && End->Type != pkgCache::Dep::Conflicts)) { - if ((Flags[I->ID] & Protected) != 0) + if ((Flags[I->ID] & Protected) == Protected) continue; // See if a keep will do @@ -718,7 +759,8 @@ bool pkgProblemResolver::Resolve(bool BrokenFix) } // Hm, nothing can possibly satisify this dep. Nuke it. - if (VList[0] == 0 && End->Type != pkgCache::Dep::Conflicts) + if (VList[0] == 0 && End->Type != pkgCache::Dep::Conflicts && + (Flags[I->ID] & Protected) != Protected) { Cache.MarkKeep(I); if (Cache[I].InstBroken() == false) @@ -866,7 +908,6 @@ bool pkgProblemResolver::ResolveByKeep() // Look at all the possible provides on this package pkgCache::Version **VList = End.AllTargets(); - bool Done = false; for (pkgCache::Version **V = VList; *V != 0; V++) { pkgCache::VerIterator Ver(Cache,*V); @@ -905,3 +946,20 @@ bool pkgProblemResolver::ResolveByKeep() return true; } /*}}}*/ +// ProblemResolver::InstallProtect - Install all protected packages /*{{{*/ +// --------------------------------------------------------------------- +/* This is used to make sure protected packages are installed */ +void pkgProblemResolver::InstallProtect() +{ + for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++) + { + if ((Flags[I->ID] & Protected) == Protected) + { + if ((Flags[I->ID] & ToRemove) == ToRemove) + Cache.MarkDelete(I); + else + Cache.MarkInstall(I,false); + } + } +} + /*}}}*/