Преглед изворни кода

u-a: Use the current alternative link as the first best value

This makes sure that if there are several alternatives with the same
priority, the current one will always be preferred, regardless of how
they sort alphabetically.

Closes: #699807
Guillem Jover пре 13 година
родитељ
комит
7f1940a118
2 измењених фајлова са 14 додато и 1 уклоњено
  1. 3 0
      debian/changelog
  2. 11 1
      utils/update-alternatives.c

+ 3 - 0
debian/changelog

@@ -12,6 +12,9 @@ dpkg (1.17.0) UNRELEASED; urgency=low
   * Do not use “header” when “format” or “field” is meant in man pages.
   * Do not use “header” when “format” or “field” is meant in man pages.
   * Use colon instead of dot for user:group in dpkg debug output.
   * Use colon instead of dot for user:group in dpkg debug output.
   * Remove support for obsolete DM-Upload-Allowed from Dpkg::Vendor::Debian.
   * Remove support for obsolete DM-Upload-Allowed from Dpkg::Vendor::Debian.
+  * Fix update-alternatives to use the current alternative link as the first
+    best value, to avoid flip-flops of alternatives with equal priority.
+    Closes: #699807
 
 
  -- Guillem Jover <guillem@debian.org>  Fri, 03 Aug 2012 13:21:00 +0200
  -- Guillem Jover <guillem@debian.org>  Fri, 03 Aug 2012 13:21:00 +0200
 
 

+ 11 - 1
utils/update-alternatives.c

@@ -1445,8 +1445,18 @@ static struct fileset *
 alternative_get_best(struct alternative *a)
 alternative_get_best(struct alternative *a)
 {
 {
 	struct fileset *fs, *best;
 	struct fileset *fs, *best;
+	const char *current;
+
+	current = alternative_get_current(a);
+	if (current)
+		best = alternative_get_fileset(a, current);
+	else
+		best = NULL;
+
+	if (best == NULL)
+		best = a->choices;
 
 
-	for (best = fs = a->choices; fs; fs = fs->next)
+	for (fs = a->choices; fs; fs = fs->next)
 		if (fs->priority > best->priority)
 		if (fs->priority > best->priority)
 			best = fs;
 			best = fs;