diff options
author | Arch Librarian <arch@canonical.com> | 2004-09-20 16:51:03 +0000 |
---|---|---|
committer | Arch Librarian <arch@canonical.com> | 2004-09-20 16:51:03 +0000 |
commit | 7e798dd739883c1f47216578ba8df34dced24777 (patch) | |
tree | d756274fb10d7bb3a6b14306d46390139ce60da2 /apt-pkg/algorithms.cc | |
parent | 7e54a6d6f1d500a4e26dbe34952ff3af65d0b0b7 (diff) |
Sync
Author: jgg
Date: 1998-10-08 04:54:58 GMT
Sync
Diffstat (limited to 'apt-pkg/algorithms.cc')
-rw-r--r-- | apt-pkg/algorithms.cc | 43 |
1 files changed, 40 insertions, 3 deletions
diff --git a/apt-pkg/algorithms.cc b/apt-pkg/algorithms.cc index 2e4ca5c2c..126318b59 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.5 1998/10/08 04:54:58 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); @@ -287,6 +287,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 /*{{{*/ // --------------------------------------------------------------------- |