summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorGuillem Jover <guillem@debian.org>2015-08-08 01:57:37 +0200
committerGuillem Jover <guillem@debian.org>2015-09-14 05:44:08 +0200
commitc9c7a4e39babc7467c42d1c9808c83c05ed2e9bc (patch)
tree386250c238fcf22c605fabcc652e4d24fea0b224 /utils
parent0fd9fb9b031efc0241e0beca6ae66de1820cbc5b (diff)
downloaddpkg-c9c7a4e39babc7467c42d1c9808c83c05ed2e9bc.tar.gz
u-a: Reimplement --all as a fully built-in command
Do not execute itself with --config for each alternative to configure, just handle them all in-process.
Diffstat (limited to 'utils')
-rw-r--r--utils/update-alternatives.c39
1 files changed, 25 insertions, 14 deletions
diff --git a/utils/update-alternatives.c b/utils/update-alternatives.c
index d95fb471e..9722eddaf 100644
--- a/utils/update-alternatives.c
+++ b/utils/update-alternatives.c
@@ -1678,20 +1678,6 @@ alternative_config(struct alternative *a, const char *current_choice)
}
static void
-alternative_config_all(void)
-{
- struct dirent **table;
- int i, count;
-
- count = altdb_get_namelist(&table);
- for (i = 0; i < count; i++) {
- subcall(prog_path, "--config", table[i]->d_name, NULL);
- printf("\n");
- }
- altdb_free_namelist(table, count);
-}
-
-static void
alternative_add_commit_op(struct alternative *a, enum opcode opcode,
const char *arg_a, const char *arg_b)
{
@@ -2343,6 +2329,30 @@ alternative_update(struct alternative *a,
}
static void
+alternative_config_all(void)
+{
+ struct alternative_map *alt_map_obj;
+ struct alternative_map *am;
+
+ alt_map_obj = alternative_map_new(NULL, NULL);
+ alternative_map_load_names(alt_map_obj);
+
+ for (am = alt_map_obj; am && am->item; am = am->next) {
+ const char *current_choice;
+ const char *new_choice;
+
+ current_choice = alternative_get_current(am->item);
+ alternative_select_mode(am->item, current_choice);
+
+ new_choice = alternative_config(am->item, current_choice);
+
+ alternative_update(am->item, current_choice, new_choice);
+ }
+
+ alternative_map_free(alt_map_obj);
+}
+
+static void
alternative_get_selections(void)
{
struct alternative_map *alt_map_obj;
@@ -2790,6 +2800,7 @@ main(int argc, char **argv)
/* Handle actions. */
if (strcmp(action, "all") == 0) {
+ log_msg("run with %s", get_argv_string(argc, argv));
alternative_config_all();
exit(0);
} else if (strcmp(action, "get-selections") == 0) {