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
|
/*
* nvidia-installer: A tool for installing NVIDIA software packages on
* Unix and Linux systems.
*
* Copyright (C) 2003-2009 NVIDIA Corporation
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* 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 <http://www.gnu.org/licenses>.
*
*
* nvidia-installer.h
*/
#ifndef __NVIDIA_INSTALLER_H__
#define __NVIDIA_INSTALLER_H__
#include <sys/types.h>
#include <inttypes.h>
#include "common-utils.h"
/*
* Enumerated type, listing each of the system utilities we'll need.
* Keep this enum in sync with the needed_utils string array in
* misc.c:find_system_utils().
*/
typedef enum {
MIN_SYSTEM_UTILS = 0,
LDCONFIG = MIN_SYSTEM_UTILS,
LDD,
GREP,
DMESG,
TAIL,
CUT,
TR,
SED,
MAX_SYSTEM_UTILS
} SystemUtils;
typedef enum {
MIN_SYSTEM_OPTIONAL_UTILS = MAX_SYSTEM_UTILS,
OBJCOPY = MIN_SYSTEM_OPTIONAL_UTILS,
CHCON,
SELINUX_ENABLED,
GETENFORCE,
EXECSTACK,
PKG_CONFIG,
XSERVER,
OPENSSL,
MAX_SYSTEM_OPTIONAL_UTILS
} SystemOptionalUtils;
/*
* Enumerated type, listing each of the module utilities we'll need.
* Keep this enum in sync with the needed_utils string array in
* misc.c:find_module_utils().
*/
typedef enum {
MIN_MODULE_UTILS = MAX_SYSTEM_OPTIONAL_UTILS,
INSMOD = MIN_MODULE_UTILS,
MODPROBE,
RMMOD,
LSMOD,
DEPMOD,
MAX_MODULE_UTILS
} ModuleUtils;
/*
* Enumerated type, listing each of the develop utilities we'll need.
* Keep this enum in sync with the develop_utils string array in
* misc.c:check_development_tools().
*/
typedef enum {
MIN_DEVELOP_UTILS = MAX_MODULE_UTILS,
CC = MIN_DEVELOP_UTILS,
MAKE,
LD,
MAX_DEVELOP_UTILS
} DevelopUtils;
#define MAX_UTILS MAX_DEVELOP_UTILS
/*
* Enumerated type of distributions; this isn't an exhaustive list of
* supported distributions... just distributions that have asked for
* special behavior.
*/
typedef enum {
SUSE,
UNITED_LINUX,
DEBIAN,
UBUNTU,
GENTOO,
ARCH,
OTHER
} Distribution;
typedef uint32_t uint32;
typedef uint16_t uint16;
typedef uint8_t uint8;
/*
* Options structure; malloced by and initialized by
* parse_commandline() and used by all the other functions in the
* installer.
*/
typedef struct __options {
int accept_license;
int update;
int expert;
int uninstall;
int driver_info;
int debug;
int logging;
int no_precompiled_interface;
int no_ncurses_color;
int latest;
int force_update;
int opengl_headers;
int nvidia_modprobe;
int no_questions;
int silent;
int which_tls;
int which_tls_compat32;
int sanity;
int add_this_kernel;
int no_backup;
int no_network;
int kernel_module_only;
int no_kernel_module;
int no_abi_note;
int no_rpms;
int no_recursion;
int run_nvidia_xconfig;
int selinux_option;
int selinux_enabled;
int sigwinch_workaround;
int no_x_check;
int no_nvidia_xconfig_question;
int run_distro_scripts;
int no_nouveau_check;
int disable_nouveau;
int no_opengl_files;
int no_kernel_module_source;
int dkms;
int check_for_alternate_installs;
int multiple_kernel_modules;
int num_kernel_modules;
int install_uvm;
int uvm_files_packaged;
NVOptionalBool install_vdpau_wrapper;
char *opengl_prefix;
char *opengl_libdir;
char *opengl_incdir;
char *x_prefix;
char *x_libdir;
char *x_moddir;
char *x_module_path;
char *x_library_path;
char *compat32_chroot;
char *compat32_prefix;
char *compat32_libdir;
char *utility_prefix;
char *utility_libdir;
char *utility_bindir;
char *installer_prefix;
char *dot_desktopdir;
char *documentation_prefix;
char *documentation_docdir;
char *documentation_mandir;
char *application_profile_path;
int modular_xorg;
char *kernel_source_path;
char *kernel_output_path;
char *kernel_include_path;
char *kernel_module_installation_path;
char *kernel_module_src_prefix;
char *kernel_module_src_dir;
char *utils[MAX_UTILS];
char *uvm_module_src_dir;
char *proc_mount_point;
char *ui_str;
char *log_file_name;
char *ftp_site;
char *tmpdir;
char *update_arguments;
char *kernel_name;
char *rpm_file_list;
char *precompiled_kernel_interfaces_path;
char *precompiled_kernel_interfaces_url;
const char *selinux_chcon_type;
char *module_signing_secret_key;
char *module_signing_public_key;
char *module_signing_script;
char *module_signing_key_path;
char *module_signing_hash;
char *module_signing_x509_hash;
int kernel_module_signed;
Distribution distro;
void *ui_priv; /* for use by the ui's */
int ignore_cc_version_check;
} Options;
/*
* Types of installed files. Keep in sync with
* manifest.c:packageEntryFileTypeTable[]
*/
typedef enum {
FILE_TYPE_NONE,
FILE_TYPE_KERNEL_MODULE_SRC,
FILE_TYPE_KERNEL_MODULE_CMD,
FILE_TYPE_OPENGL_HEADER,
FILE_TYPE_OPENGL_LIB,
FILE_TYPE_XLIB_STATIC_LIB,
FILE_TYPE_XLIB_SHARED_LIB,
FILE_TYPE_DOCUMENTATION,
FILE_TYPE_OPENGL_SYMLINK,
FILE_TYPE_XLIB_SYMLINK,
FILE_TYPE_KERNEL_MODULE,
FILE_TYPE_INSTALLER_BINARY,
FILE_TYPE_UTILITY_BINARY,
FILE_TYPE_LIBGL_LA,
FILE_TYPE_TLS_LIB,
FILE_TYPE_TLS_SYMLINK,
FILE_TYPE_UTILITY_LIB,
FILE_TYPE_DOT_DESKTOP,
FILE_TYPE_UTILITY_LIB_SYMLINK,
FILE_TYPE_XMODULE_SHARED_LIB,
FILE_TYPE_XMODULE_SYMLINK,
FILE_TYPE_XMODULE_NEWSYM, /* Create a symlink if the file doesn't exist */
FILE_TYPE_MANPAGE,
FILE_TYPE_EXPLICIT_PATH,
FILE_TYPE_CUDA_LIB,
FILE_TYPE_CUDA_SYMLINK,
FILE_TYPE_VDPAU_LIB,
FILE_TYPE_VDPAU_WRAPPER_LIB,
FILE_TYPE_VDPAU_SYMLINK,
FILE_TYPE_VDPAU_WRAPPER_SYMLINK,
FILE_TYPE_UTILITY_BIN_SYMLINK,
FILE_TYPE_CUDA_ICD,
FILE_TYPE_NVCUVID_LIB,
FILE_TYPE_NVCUVID_LIB_SYMLINK,
FILE_TYPE_GLX_MODULE_SHARED_LIB,
FILE_TYPE_GLX_MODULE_SYMLINK,
FILE_TYPE_ENCODEAPI_LIB,
FILE_TYPE_ENCODEAPI_LIB_SYMLINK,
FILE_TYPE_VGX_LIB,
FILE_TYPE_VGX_LIB_SYMLINK,
FILE_TYPE_APPLICATION_PROFILE,
FILE_TYPE_NVIDIA_MODPROBE,
FILE_TYPE_NVIDIA_MODPROBE_MANPAGE,
FILE_TYPE_MODULE_SIGNING_KEY,
FILE_TYPE_NVIFR_LIB,
FILE_TYPE_NVIFR_LIB_SYMLINK,
FILE_TYPE_UVM_MODULE_SRC,
FILE_TYPE_MAX
} PackageEntryFileType;
typedef enum {
FILE_TLS_CLASS_NONE,
FILE_TLS_CLASS_NEW,
FILE_TLS_CLASS_CLASSIC,
} PackageEntryFileTlsClass;
typedef enum {
FILE_COMPAT_ARCH_NONE,
FILE_COMPAT_ARCH_NATIVE,
FILE_COMPAT_ARCH_COMPAT32,
} PackageEntryFileCompatArch;
typedef struct {
unsigned int has_arch : 1;
unsigned int has_tls_class : 1;
unsigned int installable : 1;
unsigned int has_path : 1;
unsigned int is_symlink : 1;
unsigned int is_shared_lib : 1;
unsigned int is_opengl : 1;
unsigned int is_temporary : 1;
} PackageEntryFileCapabilities;
/*
* PackageEntryFileTypeList::types[] are booleans, indexed by
* PackageEntryFileType enum value.
*/
typedef struct {
uint8_t types[FILE_TYPE_MAX];
} PackageEntryFileTypeList;
typedef struct __package_entry {
char *file; /*
* filename in the package, relative to cwd of the
* .manifest file.
*/
char *path; /*
*
*/
char *name; /*
* filename without any leading directory
* components; this is just a pointer into the
* 'file' field.
*/
char *target; /*
* For Package entries that are symbolic links,
* the target indicates the target of the link;
* NULL for non-symbolic link Package entries.
*/
char *dst; /*
* The fully-qualified filename of the destination
* location of the Package entry; NULL for entries
* that are not installed on the filesystem. This
* field is assigned by the set_destinations()
* function.
*/
PackageEntryFileCapabilities caps;
PackageEntryFileType type;
PackageEntryFileTlsClass tls_class;
PackageEntryFileCompatArch compat_arch;
mode_t mode;
ino_t inode;
dev_t device; /*
* inode of the file after extraction from the
* package; this is needed to compare against the
* files on the user's system that we consider for
* removal, so that symlink loops don't confuse us
* into deleting the files from the package.
*/
} PackageEntry;
typedef struct __package {
char *description;
char *version;
char *kernel_module_filename;
char *kernel_interface_filename;
char *kernel_module_name;
char **bad_modules;
char **bad_module_filenames;
char *kernel_module_build_directory;
char *uvm_module_build_directory;
char *precompiled_kernel_interface_directory;
char *kernel_frontend_module_filename;
char *kernel_frontend_module_name;
char *kernel_frontend_interface_filename;
char *uvm_kernel_module_name;
char *uvm_kernel_module_filename;
char *uvm_interface_filename;
PackageEntry *entries; /* array of filename/checksum/bytesize entries */
int num_entries;
} Package;
/* flags for passing into install_from_cwd() */
#define ADJUST_CWD 0x01
/* default line length for strings */
#define NV_LINE_LEN 1024
#define NV_MIN_LINE_LEN 256
#define TLS_LIB_TYPE_FORCED 0x0001
#define TLS_LIB_NEW_TLS 0x0002
#define TLS_LIB_CLASSIC_TLS 0x0004
#define SELINUX_DEFAULT 0x0000
#define SELINUX_FORCE_YES 0x0001
#define SELINUX_FORCE_NO 0x0002
#define FORCE_CLASSIC_TLS (TLS_LIB_CLASSIC_TLS | TLS_LIB_TYPE_FORCED)
#define FORCE_NEW_TLS (TLS_LIB_NEW_TLS | TLS_LIB_TYPE_FORCED)
#define PERM_MASK (S_IRWXU|S_IRWXG|S_IRWXO)
#define PRECOMPILED_PACKAGE_FILENAME "nvidia-precompiled"
/*
* These are the default installation prefixes and the default
* paths relative to the prefixes. Some of the defaults are
* overriden on some distributions or when the new modular Xorg
* is detected, all prefixes/paths can be overriden from the
* command line.
*/
#define DEFAULT_OPENGL_PREFIX "/usr"
#define DEFAULT_X_PREFIX "/usr/X11R6"
#define DEFAULT_UTILITY_PREFIX "/usr"
#define DEFAULT_DOCUMENTATION_PREFIX "/usr"
#define DEFAULT_APPLICATION_PROFILE_PATH "/usr/share/nvidia"
#define DEFAULT_LIBDIR "lib"
#define DEFAULT_64BIT_LIBDIR "lib64"
#define DEFAULT_BINDIR "bin"
#define DEFAULT_INCDIR "include"
#define DEFAULT_X_MODULEDIR "modules"
#define DEFAULT_DOT_DESKTOPDIR "share/applications"
#define DEFAULT_DOCDIR "share/doc"
#define DEFAULT_MANDIR "share/man"
#define DEFAULT_MODULE_SIGNING_KEY_PATH "/usr/share/nvidia"
#define DEFAULT_KERNEL_MODULE_SRC_PREFIX "/usr/src"
/*
* As of Xorg 7.x, X components need not be installed relative
* to a special top-level directory, they can be integrated
* more tightly with the rest of the system. The system must be
* queried for the installation paths, but in the event that
* this fails, the fallbacks below are chosen.
*/
#define XORG7_DEFAULT_X_PREFIX "/usr"
#define XORG7_DEFAULT_X_MODULEDIR "xorg/modules"
/*
* Older versions of Debian GNU/Linux for x86-64 install 32-bit
* compatibility libraries relative to a chroot-like top-level
* directory; the prefix below is prepended to the full paths.
*/
#define DEBIAN_DEFAULT_COMPAT32_CHROOT "/emul/ia32-linux"
/*
* Debian GNU/Linux and Ubuntu do not follow the lib64 library
* path naming convention used by other distributors. 64-bit
* libraries are placed under ../lib.
*/
#define DEBIAN_DEFAULT_64BIT_LIBDIR "lib"
/*
* Ubuntu GNU/Linux and Gentoo Linux do not follow the "lib"
* library path naming convention used for 32-bit compatibility
* libraries by other distributors. These libraries are
* placed under ../lib32.
*/
#define UBUNTU_DEFAULT_COMPAT32_LIBDIR "lib32"
/*
* Newer versions of Debian GNU/Linux may install 32-bit
* compatibility libraries to ../lib/i386-linux-gnu instead
* of ../lib32.
*/
#define DEBIAN_DEFAULT_COMPAT32_LIBDIR "lib/i386-linux-gnu"
#define DEFAULT_PROC_MOUNT_POINT "/proc"
#define DEFAULT_FTP_SITE "ftp://download.nvidia.com"
#define LICENSE_FILE "LICENSE"
#define DEFAULT_LOG_FILE_NAME "/var/log/nvidia-installer.log"
#define DEFAULT_UNINSTALL_LOG_FILE_NAME "/var/log/nvidia-uninstall.log"
#define NUM_TIMES_QUESTIONS_ASKED 3
#define NV_MAX_MODULE_INSTANCES 8
#define LD_OPTIONS "-d -r"
#define NVIDIA_VERSION_PROC_FILE "/proc/driver/nvidia/version"
#define NV_BULLET_STR "-> "
#define NV_CMD_OUT_PREFIX " "
/*
* The OpenCL ICD Loader will look for the NVIDIA ICD
* in /etc/OpenCL/vendors
*/
#define DEFAULT_CUDA_ICD_PREFIX "/etc"
#define DEFAULT_CUDA_ICD_DIR "OpenCL/vendors"
/* useful macros */
#define NV_MIN(x,y) ((x) < (y) ? (x) : (y))
#define NV_MAX(x,y) ((x) > (y) ? (x) : (y))
#define TAB " "
#define BIGTAB " "
/* prototypes of functions used throughout the installer */
void log_init(Options *op, int argc, char * const argv[]);
void log_printf(Options *op, const char *prefix, const char *fmt, ...) NV_ATTRIBUTE_PRINTF(3, 4);
int install_from_cwd(Options *op);
int add_this_kernel(Options *op);
void add_package_entry(Package *p,
char *file,
char *path,
char *name,
char *target,
char *dst,
PackageEntryFileType type,
PackageEntryFileTlsClass tls_class,
PackageEntryFileCompatArch compat_arch,
mode_t mode);
/* XXX */
typedef TextRows *(*FormatTextRows)(const char*, const char*, int, int);
#endif /* __NVIDIA_INSTALLER_H__ */
|