/* * update-alternatives * * Copyright © 1995 Ian Jackson * Copyright © 2000-2002 Wichert Akkerman * Copyright © 2006-2017 Guillem Jover * Copyright © 2008 Pierre Habouzit * Copyright © 2009-2010 Raphaël Hertzog * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include /* Global variables: */ #define PROGNAME "update-alternatives" static const char *altdir = SYSCONFDIR "/alternatives"; static const char *admdir; static const char *prog_path = "update-alternatives"; enum action { ACTION_NONE, ACTION_INSTALL, ACTION_SET, ACTION_SET_SELECTIONS, ACTION_GET_SELECTIONS, ACTION_AUTO, ACTION_CONFIG, ACTION_CONFIG_ALL, ACTION_REMOVE, ACTION_REMOVE_ALL, ACTION_LIST, ACTION_QUERY, ACTION_DISPLAY, }; static struct action_name { enum action action; const char *name; } action_names[] = { { ACTION_NONE, "" }, { ACTION_INSTALL, "install" }, { ACTION_SET, "set" }, { ACTION_SET_SELECTIONS, "set-selections" }, { ACTION_GET_SELECTIONS, "get-selections" }, { ACTION_AUTO, "auto" }, { ACTION_CONFIG, "config" }, { ACTION_CONFIG_ALL, "all" }, { ACTION_REMOVE, "remove" }, { ACTION_REMOVE_ALL, "remove-all" }, { ACTION_LIST, "list" }, { ACTION_QUERY, "query" }, { ACTION_DISPLAY, "display" }, }; enum output_mode { OUTPUT_QUIET = -1, OUTPUT_NORMAL = 0, OUTPUT_VERBOSE = 1, OUTPUT_DEBUG = 2, }; /* Action to perform */ static enum action action = ACTION_NONE; static const char *log_file = LOGDIR "/alternatives.log"; /* Skip alternatives properly configured in auto mode (for --config) */ static int opt_skip_auto = 0; static int opt_verbose = OUTPUT_NORMAL; static int opt_force = 0; /* * Functions. */ static void version(void) { printf(_("Debian %s version %s.\n"), PROGNAME, VERSION); printf("\n"); printf(_( "This is free software; see the GNU General Public License version 2 or\n" "later for copying conditions. There is NO warranty.\n")); } static void usage(void) { printf(_( "Usage: %s [