apt/apt-0.5.15cnc5-alt-virtual_scores.patch

107 lines
4.0 KiB
Diff
Raw Normal View History

diff -uprk.orig apt-0.5.5cnc4.1.orig/apt-pkg/algorithms.cc apt-0.5.5cnc4.1/apt-pkg/algorithms.cc
--- apt-0.5.5cnc4.1.orig/apt-pkg/algorithms.cc 2003-09-29 17:21:22 +0400
+++ apt-0.5.5cnc4.1/apt-pkg/algorithms.cc 2003-09-29 17:29:26 +0400
@@ -540,6 +540,9 @@ int pkgProblemResolver::ScoreSort(const
// ProblemResolver::MakeScores - Make the score table /*{{{*/
// ---------------------------------------------------------------------
/* */
+
+#include "rpm/rpmpackagedata.h"
+
void pkgProblemResolver::MakeScores()
{
unsigned long Size = Cache.Head().PackageCount;
@@ -623,13 +626,28 @@ void pkgProblemResolver::MakeScores()
/* Protected things are pushed really high up. This number should put them
ahead of everything */
+ RPMPackageData *rpmdata = new RPMPackageData();
for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++)
{
if ((Flags[I->ID] & Protected) != 0)
Scores[I->ID] += 10000;
if ((I->Flags & pkgCache::Flag::Essential) == pkgCache::Flag::Essential)
Scores[I->ID] += 5000;
+ pkgCache::State::VerPriority p = rpmdata->VerPriority(I.Name());
+ switch (p) {
+ case pkgCache::State::Important:
+ Scores[I->ID] += 1000;
+ case pkgCache::State::Required:
+ Scores[I->ID] += 1000;
+ case pkgCache::State::Standard:
+ Scores[I->ID] += 1000;
+ case pkgCache::State::Optional:
+ case pkgCache::State::Extra:
+ default:
+ break;
+ }
}
+ This = this;
}
/*}}}*/
// ProblemResolver::DoUpgrade - Attempt to upgrade this package /*{{{*/
diff -uprk.orig apt-0.5.5cnc4.1.orig/apt-pkg/algorithms.h apt-0.5.5cnc4.1/apt-pkg/algorithms.h
--- apt-0.5.5cnc4.1.orig/apt-pkg/algorithms.h 2003-03-08 02:11:36 +0300
+++ apt-0.5.5cnc4.1/apt-pkg/algorithms.h 2003-09-29 17:25:17 +0400
@@ -96,7 +96,6 @@ class pkgProblemResolver
// Sort stuff
static pkgProblemResolver *This;
- static int ScoreSort(const void *a,const void *b);
struct PackageKill
{
@@ -104,7 +103,6 @@ class pkgProblemResolver
DepIterator Dep;
};
- void MakeScores();
bool DoUpgrade(pkgCache::PkgIterator Pkg);
public:
@@ -125,6 +123,10 @@ class pkgProblemResolver
pkgProblemResolver(pkgDepCache *Cache);
~pkgProblemResolver();
+
+ // Sort stuff
+ static int ScoreSort(const void *a,const void *b);
+ void MakeScores();
};
bool pkgDistUpgrade(pkgDepCache &Cache);
diff -uprk.orig apt-0.5.15cnc5/apt-pkg/rpm/rpmpackagedata.h.orig apt-0.5.15cnc5/apt-pkg/rpm/rpmpackagedata.h
--- apt-0.5.15cnc5/apt-pkg/rpm/rpmpackagedata.h.orig 2003-12-23 23:19:39 +0300
+++ apt-0.5.15cnc5/apt-pkg/rpm/rpmpackagedata.h 2004-01-12 18:27:13 +0300
@@ -70,7 +70,7 @@
{
if (Priorities.find(Package) != Priorities.end())
return Priorities[Package];
- return pkgCache::State::Standard;
+ return pkgCache::State::Optional;
};
inline pkgCache::Flag::PkgFlags PkgFlags(string Package)
{return Flags[Package];};
diff -uprk.orig apt-0.5.5cnc4.1.orig/cmdline/apt-get.cc apt-0.5.5cnc4.1/cmdline/apt-get.cc
--- apt-0.5.5cnc4.1.orig/cmdline/apt-get.cc 2003-09-29 17:21:22 +0400
+++ apt-0.5.5cnc4.1/cmdline/apt-get.cc 2003-09-29 17:27:28 +0400
@@ -1222,7 +1222,17 @@ bool TryToInstall(pkgCache::PkgIterator
if ((Pkg.ProvidesList()->NextProvides == 0 ||
(!Remove && _config->FindB("APT::Install::Virtual", false))))
{
- pkgCache::PkgIterator Tmp = Pkg.ProvidesList().OwnerPkg();
+ unsigned long Size = 0;
+ for (pkgCache::PrvIterator I = Pkg.ProvidesList(); I.end() == false; I++)
+ Size++;
+ SPtrArray<pkgCache::Package *> PList = new pkgCache::Package *[Size];
+ pkgCache::Package **PEnd = PList;
+ for (pkgCache::PrvIterator I = Pkg.ProvidesList(); I.end() == false; I++)
+ *PEnd++ = I.OwnerPkg();
+ Fix.MakeScores();
+ qsort(PList,PEnd - PList,sizeof(*PList),&(Fix.ScoreSort));
+ pkgCache::PkgIterator Tmp = pkgCache::PkgIterator(*Pkg.Cache(), *PList);
+
ioprintf(c1out,_("Note, selecting %s instead of %s\n"),
Tmp.Name(),Pkg.Name());