summaryrefslogtreecommitdiff
path: root/nvidia-installer.c
blob: 124d5268a31b55d3e2d3be47e5c7c341258487e6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
/*
 * nvidia-installer: A tool for installing NVIDIA software packages on
 * Unix and Linux systems.
 *
 * Copyright (C) 2003 NVIDIA Corporation
 *
 * 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, write to the:
 *
 *      Free Software Foundation, Inc.
 *      59 Temple Place - Suite 330
 *      Boston, MA 02111-1307, USA
 *
 *
 * nv_installer.c
 */


#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <limits.h>
#include <string.h>

#include <sys/types.h>
#include <sys/stat.h>

#include <errno.h>

#define _GNU_SOURCE /* XXX not very portable */
#include <getopt.h>

#include "nvidia-installer.h"
#include "kernel.h"
#include "user-interface.h"
#include "backup.h"
#include "files.h"
#include "misc.h"
#include "update.h"
#include "format.h"
#include "sanity.h"

#define TAB "  "

static void print_version(void);
static void print_help(void);
static void print_advanced_options(void);
static void print_help_args_only(int args_only);
static void print_advanced_options_args_only(int args_only);



/*
 * print_version() - print the current nvidia-installer version number
 */

extern const char *pNV_ID;

static void print_version(void)
{
    fmtout("");
    fmtout(pNV_ID);
    fmtoutp(TAB, "The NVIDIA Software Installer for Unix/Linux.");
    fmtout("");
    fmtoutp(TAB, "This program is used to install and upgrade "
                "The NVIDIA Accelerated Graphics Driver Set for %s-%s.",
                INSTALLER_OS, INSTALLER_ARCH);
    fmtout("");
    fmtoutp(TAB, "Copyright (C) 2003 NVIDIA Corporation.");
    fmtout("");
}



/*
 * print_help() - print usage information
 */

static void print_help(void)
{
    print_version();
    
    fmtout("");
    fmtout("nvidia-installer [options]");
    fmtout("");
    
    print_help_args_only(FALSE);

} /* print_help() */



static void print_advanced_options(void)
{
    print_version();
    
    fmtout("");
    fmtout("nvidia-installer [options]");
    fmtout("");
    
    fmtout("");
    fmtout("COMMON OPTIONS:");
    fmtout("");

    print_help_args_only(FALSE);

    fmtout("");
    fmtout("ADVANCED OPTIONS:");
    fmtout("");
    
    print_advanced_options_args_only(FALSE);

} /* print_advanced_options() */



static void print_help_args_only(int args_only)
{
    /*
     * the args_only parameter is used by makeself.sh to get our
     * argument list and description; in this case we don't want to
     * format to the width of the terminal, so hardcode the width to
     * 65.
     */

    if (args_only) reset_current_terminal_width(65);

    fmtout("-a, --accept-license");
    fmtoutp(TAB, "Bypass the display and prompting for acceptance of the "
            "NVIDIA Software License Agreement.  By passing this option to "
            "nvidia-installer, you indicate that you have read and accept the "
            "License Agreement contained in the file 'LICENSE' (in the top "
            "level directory of the driver package).");
    fmtout("");
    
    fmtout("--update");
    fmtoutp(TAB, "Connect to the NVIDIA ftp server '%s' and determine the "
            "latest available driver version.  If there is a more recent "
            "driver available, automatically download and install it.  Any "
            "other options given on the commandline will be passed on to the "
            "downloaded driver package when installing it.", DEFAULT_FTP_SITE);
    fmtout("");

    fmtout("-v, --version");
    fmtoutp(TAB, "Print the nvidia-installer version and exit.");
    fmtout("");
    
    fmtout("-h, --help");
    fmtoutp(TAB, "Print usage information for the common commandline options "
            "and exit.");
    fmtout("");
    
    fmtout("-A, --advanced-options");
    fmtoutp(TAB, "Print usage information for the common commandline options "
            "as well as the advanced options, and then exit.");
    fmtout("");
    
} /* print_help_args_only() */


static void print_advanced_options_args_only(int args_only)
{
    /*
     * the args_only parameter is used by makeself.sh to get our
     * argument list and description; in this case we don't want to
     * format to the width of the terminal, so hardcode the width to
     * 65.
     */

    if (args_only) reset_current_terminal_width(65);

    fmtout("-i, --driver-info");
    fmtoutp(TAB, "Print information about the currently installed NVIDIA "
            "driver version.");
    fmtout("");
    
    fmtout("--uninstall");
    fmtoutp(TAB, "Uninstall the currently installed NVIDIA driver.");
    fmtout("");
    
    fmtout("--sanity");
    fmtoutp(TAB, "Perform basic sanity tests on an existing NVIDIA "
            "driver installation.");
    fmtout("");
    
    fmtout("-e, --expert");
    fmtoutp(TAB, "Enable 'expert' installation mode; more detailed questions "
            "will be asked, and more verbose output will be printed; "
            "intended for expert users.  The questions may be suppressed "
            "with the '--no-questions' commandline option.");
    fmtout("");

    fmtout("-q, --no-questions");
    fmtoutp(TAB, "Do not ask any questions; the default (normally 'yes') "
            "is assumed for "
            "all yes/no questions, and the default string is assumed in "
            "any situation where the user is prompted for string input.  "
            "The one question that is not bypassed by this option is "
            "license acceptance; the license may be accepted with the "
            "commandline option '--accept-license'.");
    fmtout("");

    fmtout("-s, --silent");
    fmtoutp(TAB, "Run silently; no questions are asked and no output is "
            "printed, except for error messages to stderr.  This option "
            "implies '--ui=none --no-questions --accept-license'.");
    fmtout("");

    fmtout("--x-prefix=[X PREFIX]");
    fmtoutp(TAB, "The prefix under which the X components of the "
            "NVIDIA driver will be installed; the default is: '%s'.  Only "
            "under rare circumstances should this option be used.",
            DEFAULT_XFREE86_INSTALLATION_PREFIX);
    fmtout("");
    
    fmtout("--opengl-prefix=[OPENGL PREFIX]");
    fmtoutp(TAB, "The prefix under which the OpenGL components of the "
            "NVIDIA driver will be installed; the default is: '%s'.  Only ",
            "under rare circumstances should this option be used.  The Linux "
            "OpenGL ABI (http://oss.sgi.com/projects/ogl-sample/ABI/) "
            "mandates this default value.",
            DEFAULT_OPENGL_INSTALLATION_PREFIX);
    fmtout("");
    
    fmtout("--installer-prefix=[INSTALLER PREFIX]");
    fmtoutp(TAB, "The prefix under which the installer binary will be "
            "installed; the default is: '%s'.  Note: use the "
            "\"--utility-prefix\" option instead.",
            DEFAULT_INSTALLER_INSTALLATION_PREFIX);
    fmtout("");
    
    fmtout("--utility-prefix=[UTILITY PREFIX]");
    fmtoutp(TAB, "The prefix under which the various NVIDIA utilities "
            "(nvidia-installer, nvidia-settings, nvidia-bug-report.sh) will "
            "be installed; the default is: '%s'.",
            DEFAULT_UTILITY_INSTALLATION_PREFIX);
    fmtout("");

    fmtout("--kernel-include-path=[KERNEL INCLUDE PATH]");
    fmtoutp(TAB, "The directory containing the kernel include files that "
            "should be used when compiling the NVIDIA kernel module.  "
            "This option is deprecated; please use '--kernel-source-path' "
            "instead.");
    fmtout("");
    
    fmtout("--kernel-source-path=[KERNEL SOURCE PATH]");
    fmtoutp(TAB, "The directory containing the kernel source files that "
            "should be used when compiling the NVIDIA kernel module.  "
            "When not specified, the installer will use "
            "'/lib/modules/`uname -r`/build', if that "
            "directory exists.  Otherwise, it will use "
            "'/usr/src/linux'.");
    fmtout("");
    
    fmtout("--kernel-install-path=[KERNEL INSTALL PATH]");
    fmtoutp(TAB, "The directory in which the NVIDIA kernel module should be "
            "installed.  The default value is either '/lib/modules/`uname "
            "-r`/kernel/drivers/video' (if '/lib/modules/`uname -r`/kernel' "
            "exists) or '/lib/modules/`uname -r`/video'.");
    fmtout("");

    fmtout("--proc-mount-point=[PROC FILESYSTEM MOUNT POINT]");
    fmtoutp(TAB, "The mount point for the proc file system; if not "
            "specified, then this value defaults to '%s' (which is normally "
            "correct).  The mount point of the proc filesystem is needed "
            "because the contents of '<proc filesystem>/version' is used when "
            "identifying if a precompiled kernel interface is available for "
            "the currently running kernel.  This option should only be needed "
            "in very rare circumstances.", DEFAULT_PROC_MOUNT_POINT);
    fmtout("");
    
    fmtout("--log-file-name=[LOG FILE NAME]");
    fmtoutp(TAB, "File name of the installation log file (the default is: "
            "'%s').", DEFAULT_LOG_FILE_NAME);
    fmtout("");

    fmtout("--tmpdir=[TMPDIR]");
    fmtoutp(TAB, "Use the specified directory as a temporary directory when "
            "downloading files from the NVIDIA ftp site; "
            "if not given, then the following list will be searched, and "
            "the first one that exists will be used: $TMPDIR, /tmp, ., "
            "$HOME.");
    fmtout("");

    fmtout("-m, --ftp-mirror=[FTP MIRROR]");
    fmtoutp(TAB, "Use the specified ftp mirror rather than the default '%s' "
            "when downloading driver updates.", DEFAULT_FTP_SITE);
    fmtout("");

    fmtout("-l, --latest");
    fmtoutp(TAB, "Connect to the NVIDIA ftp server %s (or use the ftp mirror "
            "specified with the '--ftp-mirror' option) and query the most "
            "recent %s-%s driver version number.", DEFAULT_FTP_SITE,
            INSTALLER_OS, INSTALLER_ARCH);
    fmtout("");
    
    fmtout("-f, --force-update");
    fmtoutp(TAB, "Forces an update to proceed, even if the installer "
            "thinks the latest driver is already installed; this option "
            "implies '--update'.");
    fmtout("");

    fmtout("--ui=[USER INTERFACE]");
    fmtoutp(TAB, "Specify what user interface to use, if available.  "
            "Valid values are 'ncurses' (the default) or 'none'. "
            "If the ncurses interface fails to initialize, or 'none' "
            "is specified, then a simple printf/scanf interface will "
            "be used.");
    fmtout("");
    
    fmtout("-c, --no-ncurses-color");
    fmtoutp(TAB, "Disable use of color in the ncurses user interface.");
    fmtout("");
    
    fmtout("--opengl-headers");
    fmtoutp(TAB, "Normally, installation does not install NVIDIA's OpenGL "
            "header files.  This option enables installation of the NVIDIA "
            "OpenGL header files.");
    fmtout("");

    fmtout("--force-tls=[TLS TYPE]");
    fmtoutp(TAB, "NVIDIA's OpenGL libraries are compiled with one of two "
            "different thread local storage (TLS) mechanisms: 'classic tls' "
            "which is used on systems with glibc 2.2 or older, and 'new tls' "
            "which is used on systems with tls-enabled glibc 2.3 or newer.  "
            "The nvidia-installer will select the OpenGL "
            "libraries appropriate for your system; however, you may use "
            "this option to force the installer to install one library "
            "type or another.  Valid values for [TLS TYPE] are 'new' and "
            "'classic'.");
    fmtout("");

    fmtout("-k, --kernel-name=[KERNELNAME]");
    fmtoutp(TAB, "Build and install the NVIDIA kernel module for the "
            "non-running kernel specified by [KERNELNAME] ([KERNELNAME] "
            "should be the output of `uname -r` when the target kernel is "
            "actually running).  This option implies "
            "'--no-precompiled-interface'.  If the options "
            "'--kernel-install-path' and '--kernel-source-path' are not "
            "given, then they will be inferred from [KERNELNAME]; eg: "
            "'/lib/modules/[KERNELNAME]/kernel/drivers/video/' and "
            "'/lib/modules/[KERNELNAME]/build/', respectively.");
    fmtout("");
    
    fmtout("-n, --no-precompiled-interface");
    fmtoutp(TAB, "Disable use of precompiled kernel interfaces.");
    fmtout("");

    fmtout("--no-runlevel-check");
    fmtoutp(TAB, "Normally, the installer checks the current runlevel and "
            "warns users if they are in runlevel 1: in runlevel 1, some "
            "services that are normally active are disabled (such as devfs), "
            "making it difficult for the installer to properly setup the "
            "kernel module configuration files.  This option disables the "
            "runlevel check.");
    fmtout("");

    fmtout("--no-abi-note");
    fmtoutp(TAB, "The NVIDIA OpenGL libraries contain an OS ABI note tag, "
            "which identifies the minimum kernel version needed to use the "
            "library.  This option causes the installer to remove this note "
            "from the OpenGL libraries during installation.");
    fmtout("");

    fmtout("--no-rpms");
    fmtoutp(TAB, "Normally, the installer will check for several rpms that "
            "conflict with the driver (specifically: NVIDIA_GLX and "
            "NVIDIA_kernel), and remove them if present.  This option "
            "disables this check.");
    fmtout("");

    fmtout("-b, --no-backup");
    fmtoutp(TAB, "During driver installation, conflicting files are backed "
            "up, so that they can be restored when the driver is "
            "uninstalled.  This option causes the installer to simply delete "
            "conflicting files, rather than back them up.");
    fmtout("");

    fmtout("--no-network");
    fmtoutp(TAB, "This option instructs the installer to not attempt to "
            "connect to the NVIDIA ftp site (for updated precompiled kernel "
            "interfaces, for example).");
    fmtout("");
    
    fmtout("-K, --kernel-module-only");
    fmtoutp(TAB, "Install a kernel module only, and don't uninstall the "
            "existing driver.  This is intended to be used to install kernel "
            "modules for additional kernels (in cases where you might boot "
            "between several different kernels).  To use this option, you "
            "must already have a driver installed, and the version of the "
            "installed driver must match the version of this kernel "
            "module.");
    fmtout("");

    fmtout("--precompiled-kernel-interfaces-path");
    fmtoutp(TAB, "Before searching for a precompiled kernel interface in the "
            ".run file, search in the specified directory.");
    fmtout("");
    
} /* print_advanced_options_args_only() */


/*
 * parse_commandline() - malloc an Options structure, initialize it,
 * and fill in any pertinent data from the commandline arguments; it
 * is intended that this function do only minimal sanity checking --
 * just enough error trapping to ensure correct syntax of the
 * commandline options.  Validation of the actual data specified
 * through the options is left for the functions that use this data.
 *
 * XXX Would it be better to do more validation now?
 *
 * XXX this implementation uses getopt_long(), which isn't portable to
 * non-glibc based systems...
 */

Options *parse_commandline(int argc, char *argv[])
{
    Options *op;
    int c, option_index = 0;

#define XFREE86_PREFIX_OPTION           1
#define OPENGL_PREFIX_OPTION            2
#define KERNEL_INCLUDE_PATH_OPTION      3
#define KERNEL_INSTALL_PATH_OPTION      4
#define UNINSTALL_OPTION                5
#define PROC_MOUNT_POINT_OPTION         6
#define USER_INTERFACE_OPTION           7
#define LOG_FILE_NAME_OPTION            8
#define HELP_ARGS_ONLY_OPTION           9
#define TMPDIR_OPTION                   10
#define OPENGL_HEADERS_OPTION           11
#define INSTALLER_PREFIX_OPTION         12
#define FORCE_TLS_OPTION                13
#define SANITY_OPTION                   14                 
#define ADVANCED_OPTIONS_ARGS_ONLY_OPTION 15
#define UTILITY_PREFIX_OPTION           16
#define ADD_THIS_KERNEL_OPTION          17
#define RPM_FILE_LIST_OPTION            18
#define NO_RUNLEVEL_CHECK_OPTION        19
#define NO_NETWORK_OPTION               20
#define PRECOMPILED_KERNEL_INTERFACES_PATH 21
#define NO_ABI_NOTE_OPTION              22
#define KERNEL_SOURCE_PATH_OPTION       23
#define NO_RPMS_OPTION                  24
#define X_PREFIX_OPTION                 25


    static struct option long_options[] = {
        { "accept-license",           0, NULL, 'a'                        },
        { "update",                   0, NULL, 'u'                        },
        { "force-update",             0, NULL, 'f'                        },
        { "expert",                   0, NULL, 'e'                        },
        { "version",                  0, NULL, 'v'                        },
        { "debug",                    0, NULL, 'd'                        },
        { "driver-info",              0, NULL, 'i'                        },
        { "no-precompiled-interface", 0, NULL, 'n'                        },
        { "no-ncurses-color",         0, NULL, 'c'                        },
        { "latest",                   0, NULL, 'l'                        },
        { "ftp-mirror",               1, NULL, 'm'                        },
        { "no-questions",             0, NULL, 'q'                        },
        { "kernel-name",              1, NULL, 'k'                        },
        { "silent",                   0, NULL, 's'                        },
        { "help",                     0, NULL, 'h'                        },
        { "advanced-options",         0, NULL, 'A'                        },
        { "no-backup",                0, NULL, 'b'                        },
        { "kernel-module-only",       0, NULL, 'K'                        },
        { "xfree86-prefix",           1, NULL, XFREE86_PREFIX_OPTION      },
        { "x-prefix",                 1, NULL, X_PREFIX_OPTION            },
        { "opengl-prefix",            1, NULL, OPENGL_PREFIX_OPTION       },
        { "installer-prefix",         1, NULL, INSTALLER_PREFIX_OPTION    },
        { "utility-prefix",           1, NULL, UTILITY_PREFIX_OPTION      },
        { "kernel-include-path",      1, NULL, KERNEL_INCLUDE_PATH_OPTION },
        { "kernel-source-path",       1, NULL, KERNEL_SOURCE_PATH_OPTION  },
        { "kernel-install-path",      1, NULL, KERNEL_INSTALL_PATH_OPTION },
        { "uninstall",                0, NULL, UNINSTALL_OPTION           },
        { "proc-mount-point",         1, NULL, PROC_MOUNT_POINT_OPTION    },
        { "ui",                       1, NULL, USER_INTERFACE_OPTION      },
        { "log-file-name",            1, NULL, LOG_FILE_NAME_OPTION       },
        { "help-args-only",           0, NULL, HELP_ARGS_ONLY_OPTION      },
        { "tmpdir",                   1, NULL, TMPDIR_OPTION              },
        { "opengl-headers",           0, NULL, OPENGL_HEADERS_OPTION      },
        { "force-tls",                1, NULL, FORCE_TLS_OPTION           },
        { "sanity",                   0, NULL, SANITY_OPTION              },
        { "add-this-kernel",          0, NULL, ADD_THIS_KERNEL_OPTION     },
        { "rpm-file-list",            1, NULL, RPM_FILE_LIST_OPTION       },
        { "no-runlevel-check",        0, NULL, NO_RUNLEVEL_CHECK_OPTION   },
        { "no-network",               0, NULL, NO_NETWORK_OPTION          },
        { "no-abi-note",              0, NULL, NO_ABI_NOTE_OPTION         },
        { "no-rpms",                  0, NULL, NO_RPMS_OPTION             },
        { "precompiled-kernel-interfaces-path", 1, NULL,
          PRECOMPILED_KERNEL_INTERFACES_PATH                              },
        { "advanced-options-args-only", 0, NULL,
          ADVANCED_OPTIONS_ARGS_ONLY_OPTION                               },
        {  0,                         0, NULL, 0                          }
    };
    
    op = (Options *) nvalloc(sizeof(Options));
    
    /* statically initialized strings */
    
    op->xfree86_prefix = DEFAULT_XFREE86_INSTALLATION_PREFIX;
    op->opengl_prefix = DEFAULT_OPENGL_INSTALLATION_PREFIX;
    op->installer_prefix = NULL;
    op->utility_prefix = DEFAULT_UTILITY_INSTALLATION_PREFIX;
    op->proc_mount_point = DEFAULT_PROC_MOUNT_POINT;
    op->log_file_name = DEFAULT_LOG_FILE_NAME;
    op->ftp_site = DEFAULT_FTP_SITE;
    op->tmpdir = get_tmpdir(op);
    op->no_runlevel_check = FALSE;
    op->no_backup = FALSE;
    op->no_network = FALSE;
    op->kernel_module_only = FALSE;
    op->no_abi_note = FALSE;    

    op->logging = TRUE; /* log by default */

    while (1) {
        
        c = getopt_long(argc, argv, "afg:evdinclm:qk:shAbK",
                        long_options, &option_index);
        if (c == -1)
            break;
        
        switch (c) {
            
        case 'a': op->accept_license = TRUE; break;
        case 'u': op->update = TRUE; break;
        case 'e': op->expert = TRUE; break;
        case 'v': print_version(); exit(0); break;
        case 'd': op->debug = TRUE; break;
        case 'i':
            op->driver_info = TRUE;
            op->ui_str = "none";
            break;
            
        case 'n': op->no_precompiled_interface = TRUE; break;
        case 'c': op->no_ncurses_color = TRUE; break;
        case 'l': op->latest = TRUE; break;
        case 'm': op->ftp_site = optarg; break;
        case 'f': op->update = op->force_update = TRUE; break;
        case 'h': print_help(); exit(0); break;
        case 'A': print_advanced_options(); exit(0); break;
        case 'q': op->no_questions = TRUE; break;
        case 'b': op->no_backup = TRUE; break;
        case 'K': op->kernel_module_only = TRUE; break;
        case 's':
            op->silent = op->no_questions = op->accept_license = TRUE;
            op->ui_str = "none";
            break;

        case 'k':
            op->kernel_name = optarg;
            op->no_precompiled_interface = TRUE;
            break;
            
        case XFREE86_PREFIX_OPTION:
        case X_PREFIX_OPTION:
            op->xfree86_prefix = optarg; break;
        case OPENGL_PREFIX_OPTION:
            op->opengl_prefix = optarg; break;
        case INSTALLER_PREFIX_OPTION:
            op->installer_prefix = optarg; break;
        case UTILITY_PREFIX_OPTION:
            op->utility_prefix = optarg; break;
        case KERNEL_SOURCE_PATH_OPTION:
            op->kernel_source_path = optarg; break;
        case KERNEL_INCLUDE_PATH_OPTION:
            op->kernel_include_path = optarg; break;
        case KERNEL_INSTALL_PATH_OPTION:
            op->kernel_module_installation_path = optarg; break;
        case UNINSTALL_OPTION:
            op->uninstall = TRUE; break;
        case PROC_MOUNT_POINT_OPTION:
            op->proc_mount_point = optarg; break;
        case USER_INTERFACE_OPTION:
            op->ui_str = optarg; break;
        case LOG_FILE_NAME_OPTION:
            op->log_file_name = optarg; break;
        case HELP_ARGS_ONLY_OPTION:
            print_help_args_only(TRUE); exit(0); break;
        case TMPDIR_OPTION:
            op->tmpdir = optarg; break;
        case OPENGL_HEADERS_OPTION:
            op->opengl_headers = TRUE; break;
        case FORCE_TLS_OPTION:
            if (strcasecmp(optarg, "new") == 0)
                op->which_tls = FORCE_NEW_TLS;
            else if (strcasecmp(optarg, "classic") == 0)
                op->which_tls = FORCE_CLASSIC_TLS;
            else {
                fmterr("");
                fmterr("Invalid parameter for '--force-tls'; please "
                       "run `%s --help` for usage information.", argv[0]);
                fmterr("");
                exit(1);
            }
            break;
        case SANITY_OPTION:
            op->sanity = TRUE;
            break;
        case ADD_THIS_KERNEL_OPTION:
            op->add_this_kernel = TRUE;
            break;
        case ADVANCED_OPTIONS_ARGS_ONLY_OPTION:
            print_advanced_options_args_only(TRUE); exit(0);
            break;
        case RPM_FILE_LIST_OPTION:
            op->rpm_file_list = optarg;
            break;
        case NO_RUNLEVEL_CHECK_OPTION:
            op->no_runlevel_check = TRUE;
            break;
        case NO_NETWORK_OPTION:
            op->no_network = TRUE;
            break;
        case PRECOMPILED_KERNEL_INTERFACES_PATH:
            op->precompiled_kernel_interfaces_path = optarg;
            break;
        case NO_ABI_NOTE_OPTION:
            op->no_abi_note = TRUE;
            break;
        case NO_RPMS_OPTION:
            op->no_rpms = TRUE;
            break;
            
        default:
            fmterr("");
            fmterr("Invalid commandline, please run `%s --help` "
                   "for usage information.", argv[0]);
            fmterr("");
            exit(1);
        }

        op->update_arguments = append_update_arguments(op->update_arguments,
                                                       c, optarg,
                                                       long_options);
    }
    
    if (optind < argc) {
        fmterr("");
        fmterr("Unrecognized arguments:");
        while (optind < argc)
            fmterrp("  ", argv[optind++]);
        fmterr("Invalid commandline, please run `%s --help` for "
               "usage information.", argv[0]);
        fmterr("");
        exit(1);
    }
    
    op->distro = get_distribution(op);
    
    /*
     * if the installer prefix was not specified, default it to the
     * utility prefix; this is done so that the installer prefix is
     * preferred, but if not specified, we default to what was
     * specified for the utility prefix.
     */

    if (!op->installer_prefix) {
        op->installer_prefix = op->utility_prefix;
    }

    return (op);
    
} /* parse_commandline() */



/*
 * main program entry point
 */

int main(int argc, char *argv[])
{
    Options *op;
    int ret = FALSE;
    
    /* parse the commandline options */
    
    op = parse_commandline(argc, argv);
    
    /* init the log file */
    
    log_init(op);

    /* chdir() to the directory containing the binary */
    
    if (!adjust_cwd(op, argv[0])) return 1;

    /* initialize the user interface */
    
    if (!ui_init(op)) return 1;
    
    /* check that we're running as root */
    
    if (!check_euid(op)) goto done;
    
    /* check that we're in a safe runlevel */

    if (!check_runlevel(op)) goto done;

    /*
     * find the system utilities we'll need
     *
     * XXX we won't always need all of these... should only look for
     * the ones we need.
     */
    
    if (!find_system_utils(op)) goto done;
    
    /* get the latest available driver version */

    if (op->latest) {
        ret = report_latest_driver_version(op);
    }

    /* get driver information */

    else if (op->driver_info) {
        ret = report_driver_information(op);
    }

    /* perform sanity tests */

    else if (op->sanity) {
        ret = sanity(op);
    }
    
    /* uninstall */

    else if (op->uninstall) {
        ret = uninstall_existing_driver(op, TRUE);
    }

    /* update */
    
    else if (op->update) {
        ret = update(op);
    }

    /* add this kernel */

    else if (op->add_this_kernel) {
        ret = add_this_kernel(op);
    }

    /* install from the cwd */
    
    else {
        ret = install_from_cwd(op);
    }

 done:
    
    ui_close(op);
    
    return (ret ? 0 : 1);
    
} /* main() */