[Aptitude-devel] r3007 - in branches/aptitude-0.3/aptitude: . src/generic
Daniel Burrows
dburrows@costa.debian.org
Sun, 10 Apr 2005 13:52:51 +0000
Author: dburrows
Date: Sun Apr 10 13:52:48 2005
New Revision: 3007
Modified:
branches/aptitude-0.3/aptitude/ChangeLog
branches/aptitude-0.3/aptitude/src/generic/aptitude_resolver.cc
branches/aptitude-0.3/aptitude/src/generic/aptitude_resolver.h
Log:
Also let scores be tweaked according to Priority
Modified: branches/aptitude-0.3/aptitude/ChangeLog
==============================================================================
--- branches/aptitude-0.3/aptitude/ChangeLog (original)
+++ branches/aptitude-0.3/aptitude/ChangeLog Sun Apr 10 13:52:48 2005
@@ -1,5 +1,10 @@
2005-04-10 Daniel Burrows <dburrows@debian.org>
+ * src/generic/aptitude_resolver.cc, src/generic/aptitude_resolver.h:
+
+ Rename add_scores -> add_actions_scores, and write
+ add_priority_scores (tweaks scores according to Priority).
+
* src/generic/aptitude_resolver.h:
Always normalize solver_iterators. This should fix the problem
Modified: branches/aptitude-0.3/aptitude/src/generic/aptitude_resolver.cc
==============================================================================
--- branches/aptitude-0.3/aptitude/src/generic/aptitude_resolver.cc (original)
+++ branches/aptitude-0.3/aptitude/src/generic/aptitude_resolver.cc Sun Apr 10 13:52:48 2005
@@ -26,10 +26,10 @@
{
}
-void aptitude_resolver::add_scores(int preserve_score, int auto_score,
- int remove_score, int keep_score,
- int install_score, int upgrade_score,
- int non_default_score)
+void aptitude_resolver::add_action_scores(int preserve_score, int auto_score,
+ int remove_score, int keep_score,
+ int install_score, int upgrade_score,
+ int non_default_score)
{
// Should I stick with APT iterators instead? This is a bit more
// convenient, though..
@@ -82,6 +82,43 @@
}
}
+void aptitude_resolver::add_priority_scores(int important,
+ int required,
+ int standard,
+ int optional,
+ int extra)
+{
+ for(aptitude_universe::package_iterator pi=(*apt_cache_file)->PkgBegin();
+ !pi.end(); ++pi)
+ for(aptitude_universe::package::version_iterator vi=(*pi).versions_begin(); !vi.end(); ++vi)
+ {
+ int score_tweak=0;
+ switch(vi.get_ver()->Priority)
+ {
+ case pkgCache::State::Important:
+ score_tweak=important;
+ break;
+ case pkgCache::State::Required:
+ score_tweak=required;
+ break;
+ case pkgCache::State::Standard:
+ score_tweak=standard;
+ break;
+ case pkgCache::State::Optional:
+ score_tweak=optional;
+ break;
+ case pkgCache::State::Extra:
+ score_tweak=extra;
+ break;
+ default:
+ // ??????
+ break;
+ }
+
+ add_version_score(*vi, score_tweak);
+ }
+}
+
std::ostream &operator<<(ostream &out, aptitude_resolver_dep d)
{
out << d.get_source().get_package().get_name()
Modified: branches/aptitude-0.3/aptitude/src/generic/aptitude_resolver.h
==============================================================================
--- branches/aptitude-0.3/aptitude/src/generic/aptitude_resolver.h (original)
+++ branches/aptitude-0.3/aptitude/src/generic/aptitude_resolver.h Sun Apr 10 13:52:48 2005
@@ -1112,10 +1112,22 @@
* non-default version of a package (such as a downgrade or an
* experimental version).
*/
- void add_scores(int preserve_score, int auto_score,
- int remove_score, int keep_score,
- int install_score, int upgrade_score,
- int non_default_score);
+ void add_action_scores(int preserve_score, int auto_score,
+ int remove_score, int keep_score,
+ int install_score, int upgrade_score,
+ int non_default_score);
+
+ /** Score packages/versions according to their priorities. Normally
+ * you wand important>=required>=standard>=optional>=extra.
+ *
+ * \param important score modification for Important versions
+ * \param required score modification for Required versions
+ * \param standard score modification for Standard versions
+ * \param optional score modification for Optional versions
+ * \param extra score modification for Extra versions
+ */
+ void add_priority_scores(int important, int required, int standard,
+ int optional, int extra);
};
std::ostream &operator<<(ostream &out, aptitude_resolver_dep d);