Просмотр исходного кода

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
Родитель
Сommit
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.
   * Use colon instead of dot for user:group in dpkg debug output.
   * 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
 

+ 11 - 1
utils/update-alternatives.c

@@ -1445,8 +1445,18 @@ static struct fileset *
 alternative_get_best(struct alternative *a)
 {
 	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)
 			best = fs;