The following commit has been merged in the master branch:
commit 451b85ed51a7320d359b9235b1ed9e308a4936f8
Author: Guillem Jover <guil...@debian.org>
Date:   Tue Apr 10 06:32:34 2012 +0200

    u-a: Refactor mode selection into alternative_select_mode()

diff --git a/utils/update-alternatives.c b/utils/update-alternatives.c
index fc2e928..17e4a56 100644
--- a/utils/update-alternatives.c
+++ b/utils/update-alternatives.c
@@ -2149,6 +2149,37 @@ alternative_set_selections(FILE *input, const char *desc)
 }
 
 static void
+alternative_select_mode(struct alternative *a, const char *current_choice)
+{
+       if (current_choice) {
+               /* Detect manually modified alternative, switch to manual. */
+               if (!alternative_has_choice(a, current_choice)) {
+                       struct stat st;
+
+                       errno = 0;
+                       if (stat(current_choice, &st) == -1 && errno != ENOENT)
+                               syserr(_("cannot stat file '%s'"), 
current_choice);
+
+                       if (errno == ENOENT) {
+                               warning(_("%s/%s is dangling, it will be 
updated "
+                                         "with best choice."), altdir, 
a->master_name);
+                               alternative_set_status(a, ALT_ST_AUTO);
+                       } else if (a->status != ALT_ST_MANUAL) {
+                               warning(_("%s/%s has been changed (manually or 
by "
+                                         "a script). Switching to manual "
+                                         "updates only."), altdir, 
a->master_name);
+                               alternative_set_status(a, ALT_ST_MANUAL);
+                       }
+               }
+       } else {
+               /* Lack of alternative link => automatic mode. */
+               verbose(_("setting up automatic selection of %s."),
+                       a->master_name);
+               alternative_set_status(a, ALT_ST_AUTO);
+       }
+}
+
+static void
 alternative_evolve(struct alternative *a, struct alternative *b,
                    const char *cur_choice, struct fileset *fs)
 {
@@ -2540,33 +2571,8 @@ main(int argc, char **argv)
 
        /* Actions below might modify the system. */
        log_msg("run with %s", get_argv_string(argc, argv));
-       if (alternative_has_current_link(a)) {
-               current_choice = alternative_get_current(a);
-               /* Detect manually modified alternative, switch to manual. */
-               if (!alternative_has_choice(a, current_choice)) {
-                       struct stat st;
-
-                       errno = 0;
-                       if (stat(current_choice, &st) == -1 && errno != ENOENT)
-                               syserr(_("cannot stat file '%s'"), 
current_choice);
-
-                       if (errno == ENOENT) {
-                               warning(_("%s/%s is dangling, it will be 
updated "
-                                         "with best choice."), altdir, 
a->master_name);
-                               alternative_set_status(a, ALT_ST_AUTO);
-                       } else if (a->status != ALT_ST_MANUAL) {
-                               warning(_("%s/%s has been changed (manually or 
by "
-                                         "a script). Switching to manual "
-                                         "updates only."), altdir, 
a->master_name);
-                               alternative_set_status(a, ALT_ST_MANUAL);
-                       }
-               }
-       } else {
-               /* Lack of alternative link => automatic mode. */
-               verbose(_("setting up automatic selection of %s."),
-                       a->master_name);
-               alternative_set_status(a, ALT_ST_AUTO);
-       }
+       current_choice = alternative_get_current(a);
+       alternative_select_mode(a, current_choice);
 
        if (strcmp(action, "set") == 0) {
                if (alternative_has_choice(a, path))

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to debian-dpkg-cvs-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to