Sfoglia il codice sorgente

u-a: Reimplement --set-selections as a built-in command

Do not execute itself with --set or --auto for each alternative to
set a selection for, just handle them in-process.
Guillem Jover 11 anni fa
parent
commit
9e93806ab9
2 ha cambiato i file con 14 aggiunte e 10 eliminazioni
  1. 2 0
      debian/changelog
  2. 12 10
      utils/update-alternatives.c

+ 2 - 0
debian/changelog

@@ -8,6 +8,8 @@ dpkg (1.18.3) UNRELEASED; urgency=low
     in «update-alternatives --display», with a two space indentation.
   * Reimplement «update-alternatives --all» as a fully built-in command
     instead of executing itself with --config per subtask.
+  * Reimplement «update-alternatives --set-selections» as a fully built-in
+    command instead of executing itself with --set or --auto per subtask.
   * Perl modules:
     - Only warn on invalid week days instead of aborting in
       Dpkg::Changelog::Entry::Debian. Regression introduced in dpkg 1.18.2.

+ 12 - 10
utils/update-alternatives.c

@@ -2382,23 +2382,25 @@ alternative_set_selection(struct alternative_map *all, const char *name,
 	debug("set_selection(%s, %s, %s)", name, status, choice);
 	a = alternative_map_find(all, name);
 	if (a) {
-		char *cmd;
+		const char *new_choice = NULL;
 
 		if (strcmp(status, "auto") == 0) {
-			xasprintf(&cmd, "%s --auto %s", PROGNAME, name);
-			pr(_("Call %s."), cmd);
-			free(cmd);
-			subcall(prog_path, "--auto", name, NULL);
+			new_choice = alternative_set_auto(a);
 		} else if (alternative_has_choice(a, choice)) {
-			xasprintf(&cmd, "%s --set %s %s", PROGNAME,
-			          name, choice);
-			pr(_("Call %s."), cmd);
-			free(cmd);
-			subcall(prog_path, "--set", name, choice, NULL);
+			new_choice = alternative_set_manual(a, choice);
 		} else {
 			pr(_("Alternative %s unchanged because choice "
 			     "%s is not available."), name, choice);
 		}
+
+		if (new_choice) {
+			const char *current_choice;
+
+			current_choice = alternative_get_current(a);
+			alternative_select_mode(a, current_choice);
+
+			alternative_update(a, current_choice, new_choice);
+		}
 	} else {
 		pr(_("Skip unknown alternative %s."), name);
 	}