summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Plattner <aplattner@nvidia.com>2014-04-08 09:48:59 -0700
committerAaron Plattner <aplattner@nvidia.com>2014-04-08 09:48:59 -0700
commit734efd3a0959650fee628ebb54bd07a85a784ccf (patch)
tree0175e8e93519ff0770c1a71621d2b2ee22aa4627
parentd0b611041d8ad79dd0a102833885f984d5a16ad6 (diff)
337.12337.12
-rw-r--r--backup.c18
-rw-r--r--files.c21
-rw-r--r--install-from-cwd.c29
-rw-r--r--misc.c58
-rw-r--r--ncurses-ui.c21
-rw-r--r--nvidia-installer-ui.h4
-rw-r--r--stream-ui.c10
-rw-r--r--user-interface.c17
-rw-r--r--user-interface.h11
-rw-r--r--version.mk2
10 files changed, 100 insertions, 91 deletions
diff --git a/backup.c b/backup.c
index 82c2cff..50dfd2a 100644
--- a/backup.c
+++ b/backup.c
@@ -1285,11 +1285,6 @@ int check_for_existing_driver(Options *op, Package *p)
int ret = FALSE;
int localRet;
- const char *choices[2] = {
- "Continue installation",
- "Abort installation"
- };
-
if (!check_for_existing_rpms(op)) goto done;
localRet = get_installed_driver_version_and_descr(op, &version, &descr);
@@ -1332,11 +1327,14 @@ int check_for_existing_driver(Options *op, Package *p)
* downgrading is any different than upgrading.
*/
- if (ui_multiple_choice(op, choices, 2, 0, "There appears to already be a "
- "driver installed on your system (version: %s). As "
- "part of installing this driver (version: %s), the "
- "existing driver will be uninstalled. Are you sure "
- "you want to continue?", version, p->version) == 1) {
+ if (ui_multiple_choice(op, CONTINUE_ABORT_CHOICES,
+ NUM_CONTINUE_ABORT_CHOICES,
+ CONTINUE_CHOICE, /* Default choice */
+ "There appears to already be a driver installed on "
+ "your system (version: %s). As part of installing "
+ "this driver (version: %s), the existing driver will "
+ "be uninstalled. Are you sure you want to continue?",
+ version, p->version) == ABORT_CHOICE) {
ui_log(op, "Installation aborted.");
goto done;
diff --git a/files.c b/files.c
index c5af2df..592b9c8 100644
--- a/files.c
+++ b/files.c
@@ -1580,18 +1580,15 @@ int check_for_existing_rpms(Options *op)
nvfree(cmd);
if (ret == 0) {
-
- const char *choices[2] = {
- "Continue installation",
- "Abort installation"
- };
-
- if (ui_multiple_choice(op, choices, 2, 0, "An %s rpm appears to "
- "already be installed on your system. As "
- "part of installing the new driver, this %s "
- "rpm will be uninstalled. Are you sure you "
- "want to continue?",
- rpms[i], rpms[i]) == 1) {
+ if (ui_multiple_choice(op, CONTINUE_ABORT_CHOICES,
+ NUM_CONTINUE_ABORT_CHOICES,
+ CONTINUE_CHOICE, /* Default choice */
+ "An %s rpm appears to already be installed "
+ "on your system. As part of installing the "
+ "new driver, this %s rpm will be "
+ "uninstalled. Are you sure you want to "
+ "continue?",
+ rpms[i], rpms[i]) == ABORT_CHOICE) {
ui_log(op, "Installation aborted.");
return FALSE;
}
diff --git a/install-from-cwd.c b/install-from-cwd.c
index d3fc30c..ff73644 100644
--- a/install-from-cwd.c
+++ b/install-from-cwd.c
@@ -91,11 +91,6 @@ int install_from_cwd(Options *op)
"appropriate; see the file /usr/share/doc/"
"NVIDIA_GLX-1.0/README.txt for details.";
- const char *choices[2] = {
- "Continue installation",
- "Abort installation"
- };
-
/*
* validate the manifest file in the cwd, and process it, building
* a Package struct
@@ -145,20 +140,26 @@ int install_from_cwd(Options *op)
res = run_distro_hook(op, "pre-install");
if (res == HOOK_SCRIPT_FAIL) {
- if (ui_multiple_choice(op, choices, 2, 0, "The distribution-provided "
- "pre-install script failed! Are you sure you "
- "want to continue?") == 1) {
+ if (ui_multiple_choice(op, CONTINUE_ABORT_CHOICES,
+ NUM_CONTINUE_ABORT_CHOICES,
+ CONTINUE_CHOICE, /* Default choice */
+ "The distribution-provided pre-install "
+ "script failed! Are you sure you want "
+ "to continue?") == ABORT_CHOICE) {
goto failed;
}
} else if (res == HOOK_SCRIPT_SUCCESS) {
- if (ui_multiple_choice(op, choices, 2, 0, "The distribution-provided "
- "pre-install script completed successfully. If "
- "this is the first time you have run the "
- "installer, this script may have helped disable "
- "Nouveau, but a reboot may be required first. "
+ if (ui_multiple_choice(op, CONTINUE_ABORT_CHOICES,
+ NUM_CONTINUE_ABORT_CHOICES,
+ CONTINUE_CHOICE, /* Default choice */
+ "The distribution-provided pre-install script "
+ "completed successfully. If this is the first "
+ "time you have run the installer, this script "
+ "may have helped disable Nouveau, but a reboot "
+ "may be required first. "
"Would you like to continue, or would you "
"prefer to abort installation to reboot the "
- "system?") == 1) {
+ "system?") == ABORT_CHOICE) {
goto exit_install;
}
ran_pre_install_hook = TRUE;
diff --git a/misc.c b/misc.c
index 9a71dab..5d2b589 100644
--- a/misc.c
+++ b/misc.c
@@ -157,22 +157,19 @@ int check_runlevel(Options *op)
nvfree(data);
if (runlevel == 's' || runlevel == 'S' || runlevel == '1') {
-
- const char *choices[2] = {
- "Continue installation",
- "Abort installation"
- };
-
- ret = (ui_multiple_choice(op, choices, 2, 1, "You appear to be running "
- "in runlevel 1; this may cause problems. "
- "For example: some distributions that use "
- "devfs do not run the devfs daemon in "
- "runlevel 1, making it difficult for "
- "`nvidia-installer` to correctly setup the "
- "kernel module configuration files. It is "
- "recommended that you quit installation now "
- "and switch to runlevel 3 (`telinit 3`) "
- "before installing.") == 1);
+ ret = (ui_multiple_choice(op, CONTINUE_ABORT_CHOICES,
+ NUM_CONTINUE_ABORT_CHOICES,
+ ABORT_CHOICE, /* Default choice */
+ "You appear to be running in runlevel 1; "
+ "this may cause problems. For example: some "
+ "distributions that use devfs do not run the "
+ "devfs daemon in runlevel 1, making it "
+ "difficult for `nvidia-installer` to "
+ "correctly set up the kernel module "
+ "configuration files. It is recommended "
+ "that you quit installation now and switch "
+ "to runlevel 3 (`telinit 3`) before "
+ "installing.") == ABORT_CHOICE);
if (ret) return FALSE;
}
@@ -892,17 +889,15 @@ int continue_after_error(Options *op, const char *fmt, ...)
char *msg;
int ret;
- const char *choices[2] = {
- "Continue installation",
- "Abort installation"
- };
-
NV_VSNPRINTF(msg, fmt);
- ret = (ui_multiple_choice(op, choices, 2, 0, "The installer has encountered "
- "the following error during installation: '%s'. "
- "Would you like to continue installation anyway?",
- msg) == 0);
+ ret = (ui_multiple_choice(op, CONTINUE_ABORT_CHOICES,
+ NUM_CONTINUE_ABORT_CHOICES,
+ CONTINUE_CHOICE, /* Default choice */
+ "The installer has encountered the following "
+ "error during installation: '%s'. Would you "
+ "like to continue installation anyway?",
+ msg) == CONTINUE_CHOICE);
nvfree(msg);
@@ -2625,13 +2620,11 @@ done:
* returns FALSE if the user decides not to cancel.
*/
static int prompt_for_user_cancel(Options *op, const char *file,
- int default_cancel, const char *text)
+ int default_choice, const char *text)
{
int ret, file_read, msglen;
char *message = NULL, *prompt;
- const char *buttons[2] = {"Continue Installation", "Cancel Installation"};
-
file_read = read_text_file(file, &message);
if (!file_read || !message) {
@@ -2647,12 +2640,13 @@ static int prompt_for_user_cancel(Options *op, const char *file,
ret = ui_paged_prompt(op, prompt, msglen > 0 ? "Information about the "
"alternate installation method" : "", message,
- buttons, 2, default_cancel);
+ CONTINUE_ABORT_CHOICES, NUM_CONTINUE_ABORT_CHOICES,
+ default_choice);
nvfree(message);
nvfree(prompt);
- if (ret == 1) {
+ if (ret == ABORT_CHOICE) {
ui_error(op, "The installation was canceled due to the availability "
"or presence of an alternate driver installation. Please "
"see %s for more details.", op->log_file_name);
@@ -2702,7 +2696,7 @@ int check_for_alternate_install(Options *op)
"uninstall the existing installation before installing this "
"driver.";
- return !prompt_for_user_cancel(op, alt_inst_present, 1, msg);
+ return !prompt_for_user_cancel(op, alt_inst_present, ABORT_CHOICE, msg);
}
if (access(alt_inst_avail, F_OK) == 0) {
@@ -2714,7 +2708,7 @@ int check_for_alternate_install(Options *op)
"better with your system than a driver installed by "
"nvidia-installer.";
- return !prompt_for_user_cancel(op, alt_inst_avail, 0, msg);
+ return !prompt_for_user_cancel(op, alt_inst_avail, CONTINUE_CHOICE, msg);
}
return TRUE;
diff --git a/ncurses-ui.c b/ncurses-ui.c
index 10ce732..621846e 100644
--- a/ncurses-ui.c
+++ b/ncurses-ui.c
@@ -162,7 +162,7 @@ static int nv_ncurses_approve_command_list(Options*, CommandList*,
const char*);
static int nv_ncurses_yes_no (Options*, const int, const char*);
static int nv_ncurses_multiple_choice (Options *, const char*,
- const char **, int, int);
+ const char * const *, int, int);
static void nv_ncurses_status_begin (Options*, const char*,
const char*);
static void nv_ncurses_status_update (Options*, const float,
@@ -191,9 +191,9 @@ static void nv_ncurses_destroy_region(RegionStruct *);
static void nv_ncurses_draw_button(DataStruct *, RegionStruct *, int, int,
int, int, const char *, bool, bool);
static void nv_ncurses_erase_button(RegionStruct *, int, int, int, int);
-static void draw_buttons(DataStruct *d, const char **buttons, int num_buttons,
- int button, int button_w, const int *buttons_x,
- int button_y);
+static void draw_buttons(DataStruct *d, const char * const *buttons,
+ int num_buttons, int button, int button_w,
+ const int *buttons_x, int button_y);
/* helper functions for drawing regions and stuff */
@@ -212,7 +212,7 @@ static void nv_ncurses_pager_update(DataStruct *, PagerStruct *);
static void nv_ncurses_pager_handle_events(DataStruct *, PagerStruct *, int);
static void nv_ncurses_destroy_pager(PagerStruct *);
static int nv_ncurses_paged_prompt(Options *, const char*, const char*,
- const char*, const char **, int, int);
+ const char*, const char * const *, int, int);
/* progress bar helper functions */
@@ -823,7 +823,7 @@ static int nv_ncurses_yes_no(Options *op, const int def, const char *msg)
*/
static int nv_ncurses_multiple_choice(Options *op, const char *question,
- const char **buttons, int num_buttons,
+ const char * const *buttons, int num_buttons,
int default_button)
{
return nv_ncurses_paged_prompt(op, question, NULL, NULL, buttons,
@@ -1587,9 +1587,9 @@ static void nv_ncurses_pager_handle_events(DataStruct *d,
}
} /* nv_ncurses_pager_handle_events() */
-static void draw_buttons(DataStruct *d, const char **buttons, int num_buttons,
- int button, int button_w, const int *buttons_x,
- int button_y)
+static void draw_buttons(DataStruct *d, const char * const *buttons,
+ int num_buttons, int button, int button_w,
+ const int *buttons_x, int button_y)
{
int i;
@@ -1608,7 +1608,8 @@ static void draw_buttons(DataStruct *d, const char **buttons, int num_buttons,
static int nv_ncurses_paged_prompt(Options *op, const char *question,
const char *pager_title,
- const char *pager_text, const char **buttons,
+ const char *pager_text,
+ const char * const *buttons,
int num_buttons, int default_button)
{
DataStruct *d = (DataStruct *) op->ui_priv;
diff --git a/nvidia-installer-ui.h b/nvidia-installer-ui.h
index 8594cb0..77feab0 100644
--- a/nvidia-installer-ui.h
+++ b/nvidia-installer-ui.h
@@ -137,7 +137,7 @@ typedef struct __nv_installer_ui {
*/
int (*multiple_choice)(Options *op, const char *question,
- const char **answers, int num_answers,
+ const char * const *answers, int num_answers,
int default_answer);
/*
@@ -151,7 +151,7 @@ typedef struct __nv_installer_ui {
int (*paged_prompt)(Options *op, const char *question,
const char *pager_title, const char *pager_text,
- const char **answers, int num_answers,
+ const char * const *answers, int num_answers,
int default_answer);
/*
diff --git a/stream-ui.c b/stream-ui.c
index 04b5eab..364ad0a 100644
--- a/stream-ui.c
+++ b/stream-ui.c
@@ -46,10 +46,10 @@ void stream_message (Options*, int level, const char*);
void stream_command_output (Options*, const char*);
int stream_approve_command_list(Options*, CommandList*, const char*);
int stream_yes_no (Options*, const int, const char*);
-int stream_multiple_choice (Options *op, const char *, const char **,
+int stream_multiple_choice (Options *op, const char *, const char * const *,
int, int);
int stream_paged_prompt (Options *op, const char *, const char *,
- const char *, const char **, int, int);
+ const char *, const char * const *, int, int);
void stream_status_begin (Options*, const char*, const char*);
void stream_status_update (Options*, const float, const char*);
void stream_status_end (Options*, const char*);
@@ -429,7 +429,7 @@ int stream_yes_no(Options *op, const int def, const char *msg)
* matched the user's input.
*/
-static int select_option(const char **options, int num_options,
+static int select_option(const char * const *options, int num_options,
int default_option, const char *selection)
{
int i;
@@ -466,7 +466,7 @@ static int select_option(const char **options, int num_options,
*/
int stream_multiple_choice(Options *op, const char *question,
- const char **answers, int num_answers,
+ const char * const *answers, int num_answers,
int default_answer)
{
int ret = default_answer;
@@ -509,7 +509,7 @@ int stream_multiple_choice(Options *op, const char *question,
int stream_paged_prompt(Options *op, const char *question,
const char *pager_title, const char *pager_text,
- const char **answers, int num_answers,
+ const char * const *answers, int num_answers,
int default_answer)
{
nv_info_msg(NULL, "");
diff --git a/user-interface.c b/user-interface.c
index 7770f70..8009672 100644
--- a/user-interface.c
+++ b/user-interface.c
@@ -75,6 +75,16 @@ static int extract_user_interface(Options *op, user_interface_attribute_t *ui);
static void ui_signal_handler(int n);
/*
+ * Definitions of very common answer choices used by callers of
+ * ui_multiple_choice() or ui_paged_prompt()
+ */
+
+const char * const CONTINUE_ABORT_CHOICES[] = {
+ [CONTINUE_CHOICE] = "Continue installation",
+ [ABORT_CHOICE] = "Abort installation"
+};
+
+/*
* ui_init() - initialize the user interface; we start by looping over
* each of the possible ui shared libs (gtk, ncurses) until we find
* one that will work; if neither will work, then fall back to the
@@ -394,8 +404,9 @@ int ui_yes_no (Options *op, const int def, const char *fmt, ...)
} /* ui_yes_no() */
-int ui_multiple_choice (Options *op, const char **answers, int num_answers,
- int default_answer, const char *fmt, ...)
+int ui_multiple_choice (Options *op, const char * const *answers,
+ int num_answers, int default_answer,
+ const char *fmt, ...)
{
char *question, *tmp = NULL;
int ret;
@@ -425,7 +436,7 @@ int ui_multiple_choice (Options *op, const char **answers, int num_answers,
int ui_paged_prompt (Options *op, const char *question, const char *pager_title,
- const char *pager_text, const char **answers,
+ const char *pager_text, const char * const *answers,
int num_answers, int default_answer)
{
char *tmp;
diff --git a/user-interface.h b/user-interface.h
index eeee533..ff8afd7 100644
--- a/user-interface.h
+++ b/user-interface.h
@@ -26,6 +26,13 @@
#include "nvidia-installer.h"
#include "command-list.h"
+enum {
+ CONTINUE_CHOICE = 0,
+ ABORT_CHOICE,
+ NUM_CONTINUE_ABORT_CHOICES /* Must be the last one */
+};
+extern const char * const CONTINUE_ABORT_CHOICES[];
+
int ui_init (Options*);
void ui_set_title (Options*, const char*, ...) NV_ATTRIBUTE_PRINTF(2, 3);
char *ui_get_input (Options*, const char*, const char*, ...) NV_ATTRIBUTE_PRINTF(3, 4);
@@ -38,10 +45,10 @@ void ui_expert (Options*, const char*, ...) NV_ATTRIB
void ui_command_output (Options*, const char*, ...) NV_ATTRIBUTE_PRINTF(2, 3);
int ui_approve_command_list(Options*, CommandList*,const char*, ...) NV_ATTRIBUTE_PRINTF(3, 4);
int ui_yes_no (Options*, const int, const char*, ...) NV_ATTRIBUTE_PRINTF(3, 4);
-int ui_multiple_choice (Options *, const char **, int, int,
+int ui_multiple_choice (Options *, const char * const*, int, int,
const char *, ...) NV_ATTRIBUTE_PRINTF(5, 6);
int ui_paged_prompt (Options *, const char *, const char *,
- const char *, const char **, int, int);
+ const char *, const char * const *, int, int);
void ui_status_begin (Options*, const char*, const char*, ...) NV_ATTRIBUTE_PRINTF(3, 4);
void ui_status_update (Options*, const float, const char*, ...) NV_ATTRIBUTE_PRINTF(3, 4);
void ui_status_end (Options*, const char*, ...) NV_ATTRIBUTE_PRINTF(2, 3);
diff --git a/version.mk b/version.mk
index 434103e..64bf1a5 100644
--- a/version.mk
+++ b/version.mk
@@ -1 +1 @@
-NVIDIA_VERSION = 334.21
+NVIDIA_VERSION = 337.12