[Aptitude-devel] r3009 - in branches/aptitude-0.3/aptitude: . src/cmdline src/generic

Daniel Burrows dburrows@costa.debian.org
Sun, 10 Apr 2005 14:03:44 +0000


Author: dburrows
Date: Sun Apr 10 14:03:41 2005
New Revision: 3009

Modified:
   branches/aptitude-0.3/aptitude/ChangeLog
   branches/aptitude-0.3/aptitude/src/cmdline/cmdline_do_action.cc
   branches/aptitude-0.3/aptitude/src/generic/aptitude_resolver.cc
   branches/aptitude-0.3/aptitude/src/generic/aptitude_resolver.h
Log:
Add a straightforward way to say 'do not remove Essential packages'.

Modified: branches/aptitude-0.3/aptitude/ChangeLog
==============================================================================
--- branches/aptitude-0.3/aptitude/ChangeLog	(original)
+++ branches/aptitude-0.3/aptitude/ChangeLog	Sun Apr 10 14:03:41 2005
@@ -1,5 +1,10 @@
 2005-04-10  Daniel Burrows  <dburrows@debian.org>
 
+	* src/cmdline/cmdline_do_action.cc, src/generic/aptitude_resolver.cc, src/generic/aptitude_resolver.h:
+
+	  Add and use a feature to easily apply heavy penalties to the
+	  removal of Essential packages.
+
 	* src/generic/problemresolver/problemresolver.h:
 
 	  Add missing "const"s to some function prototypes, comment out

Modified: branches/aptitude-0.3/aptitude/src/cmdline/cmdline_do_action.cc
==============================================================================
--- branches/aptitude-0.3/aptitude/src/cmdline/cmdline_do_action.cc	(original)
+++ branches/aptitude-0.3/aptitude/src/cmdline/cmdline_do_action.cc	Sun Apr 10 14:03:41 2005
@@ -179,7 +179,7 @@
   resolver.add_action_scores(50, 25,
 			     -50, -10,
 			     -20, -15,
-			     -40);
+			     -40, -100000);
 
   // Prefer higher-priority versions of packages (not excessively)
   resolver.add_priority_scores(5, 4, 3, 1, -1);

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 14:03:41 2005
@@ -29,7 +29,7 @@
 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)
+					  int non_default_score, int essential_remove)
 {
   // Should I stick with APT iterators instead?  This is a bit more
   // convenient, though..
@@ -78,6 +78,11 @@
 	    //  - it's not a removal
 	    //  - it follows that this is a non-default version.
 	    add_version_score(v, non_default_score);
+
+	  // In addition, add the essential-remoal score:
+	  if((p.get_pkg()->Flags & pkgCache::Flag::Essential) &&
+	     v.get_ver().end())
+	    add_version_score(v, essential_remove);
 	}
     }
 }

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 14:03:41 2005
@@ -1111,14 +1111,18 @@
    * \param non_default_score the score to assign to installing a
    * non-default version of a package (such as a downgrade or an
    * experimental version).
+   *
+   * \param essential_remove an additional modification applied to the
+   * removal of an essential package (typically used to deep-six such
+   * solutions by, eg, setting it to -100000)
    */
   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);
+			 int non_default_score, int essential_remove);
 
   /** Score packages/versions according to their priorities.  Normally
-   *  you wand important>=required>=standard>=optional>=extra.
+   *  you want important>=required>=standard>=optional>=extra.
    *
    *  \param important score modification for Important versions
    *  \param required score modification for Required versions