diff options
author | Aaron Plattner <aplattner@nvidia.com> | 2021-03-30 10:46:32 -0700 |
---|---|---|
committer | Aaron Plattner <aplattner@nvidia.com> | 2021-03-30 10:46:32 -0700 |
commit | b20eb58b21f0ffc6c007c9e32393cf8c26c14680 (patch) | |
tree | 88e21b808d1172fb58e712072cfae329a69c2544 | |
parent | ce0f258a809f95b58f8fac6a0c84be02a420539f (diff) |
465.19.01
-rw-r--r-- | backup.c | 20 | ||||
-rw-r--r-- | command-list.c | 11 | ||||
-rw-r--r-- | conflicting-kernel-modules.c | 2 | ||||
-rw-r--r-- | files.c | 51 | ||||
-rw-r--r-- | files.h | 1 | ||||
-rw-r--r-- | install-from-cwd.c | 7 | ||||
-rw-r--r-- | kernel.c | 16 | ||||
-rw-r--r-- | manifest.c | 6 | ||||
-rw-r--r-- | misc.c | 110 | ||||
-rw-r--r-- | misc.h | 1 | ||||
-rw-r--r-- | nvidia-installer.c | 15 | ||||
-rw-r--r-- | nvidia-installer.h | 13 | ||||
-rw-r--r-- | option_table.h | 33 | ||||
-rw-r--r-- | utils.mk | 37 | ||||
-rw-r--r-- | version.mk | 2 |
15 files changed, 314 insertions, 11 deletions
@@ -858,6 +858,26 @@ static int do_uninstall(Options *op, const char *version, "after uninstallation: your system may have stale state " "involving recently uninstalled files."); } + + /* + * In case systemd units were just uninstalled, run `systemctl + * daemon-reload` to reflect the change. + */ + if (op->utils[SYSTEMCTL]) { + char *cmd = nvstrcat(op->utils[SYSTEMCTL], " daemon-reload", NULL); + + ui_log(op, "Running `%s`:", cmd); + status = run_command(op, cmd, NULL, FALSE, 0, FALSE); + nvfree(cmd); + + if (status == 0) { + ui_log(op, "done."); + } else { + ui_log(op, "error!"); + ui_warn(op, "An error occurred while reloading the systemd " + "daemon configuration."); + } + } } run_distro_hook(op, "post-uninstall"); diff --git a/command-list.c b/command-list.c index bb55702..7ef9903 100644 --- a/command-list.c +++ b/command-list.c @@ -413,7 +413,16 @@ CommandList *build_command_list(Options *op, Package *p) add_command(c, RUN_CMD, tmp); nvfree(tmp); } - + + /* + * If systemd files were installed, run `systemctl daemon-reload`. + */ + if (op->use_systemd == NV_OPTIONAL_BOOL_TRUE) { + tmp = nvstrcat(op->utils[SYSTEMCTL], " daemon-reload", NULL); + add_command(c, RUN_CMD, tmp); + nvfree(tmp); + } + /* free the FileList */ free_file_list(l); diff --git a/conflicting-kernel-modules.c b/conflicting-kernel-modules.c index c6e6dcb..b957ac4 100644 --- a/conflicting-kernel-modules.c +++ b/conflicting-kernel-modules.c @@ -27,6 +27,8 @@ */ const char * const conflicting_kernel_modules[] = { + "nv_peer_mem", + "nvidia-peermem", "nvidia-vgpu-vfio", "nvidia-uvm", "nvidia-drm", @@ -796,6 +796,34 @@ int set_destinations(Options *op, Package *p) dir = path = ""; break; + case FILE_TYPE_FIRMWARE: + prefix = nvstrcat("/lib/firmware/nvidia/", p->version, "/", NULL); + path = p->entries[i].path; + dir = ""; + break; + + case FILE_TYPE_SYSTEMD_UNIT: + prefix = op->systemd_unit_prefix; + dir = path = ""; + break; + + case FILE_TYPE_SYSTEMD_UNIT_SYMLINK: + /* + * Construct the symlink target from the systemd unit prefix and + * symlink name. + */ + p->entries[i].target = nvstrcat(op->systemd_unit_prefix, "/", p->entries[i].name, NULL); + + prefix = op->systemd_sysconf_prefix; + path = p->entries[i].path; + dir = ""; + break; + + case FILE_TYPE_SYSTEMD_SLEEP_SCRIPT: + prefix = op->systemd_sleep_prefix; + dir = path = ""; + break; + default: /* @@ -1103,6 +1131,22 @@ void remove_opengl_files_from_package(Options *op, Package *p) } +/* + * Invalidate each package entry that is a systemd file + */ +void remove_systemd_files_from_package(Options *op, Package *p) +{ + int i; + + for (i = 0; i < p->num_entries; i++) { + if (p->entries[i].type == FILE_TYPE_SYSTEMD_UNIT || + p->entries[i].type == FILE_TYPE_SYSTEMD_UNIT_SYMLINK || + p->entries[i].type == FILE_TYPE_SYSTEMD_SLEEP_SCRIPT) { + invalidate_package_entry(&(p->entries[i])); + } + } +} + /* * mode_string_to_mode() - convert the string s @@ -2311,6 +2355,13 @@ void get_default_prefixes_and_paths(Options *op) op->module_signing_key_path = DEFAULT_MODULE_SIGNING_KEY_PATH; /* kernel_module_src_dir's default value is set in set_destinations() */ + if (!op->systemd_unit_prefix) + op->systemd_unit_prefix = DEFAULT_SYSTEMD_UNIT_PREFIX; + if (!op->systemd_sleep_prefix) + op->systemd_sleep_prefix = DEFAULT_SYSTEMD_SLEEP_PREFIX; + if (!op->systemd_sysconf_prefix) + op->systemd_sysconf_prefix = DEFAULT_SYSTEMD_SYSCONF_PREFIX; + } /* get_default_prefixes_and_paths() */ @@ -34,6 +34,7 @@ int get_prefixes(Options *op); /* XXX move? */ void add_kernel_modules_to_package(Options *op, Package *p); void remove_non_kernel_module_files_from_package(Options *op, Package *p); void remove_opengl_files_from_package(Options *op, Package *p); +void remove_systemd_files_from_package(Options *op, Package *p); int mode_string_to_mode(Options *op, char *s, mode_t *mode); char *mode_to_permission_string(mode_t mode); int confirm_path(Options *op, const char *path); diff --git a/install-from-cwd.c b/install-from-cwd.c index 7e6842c..1f50a9b 100644 --- a/install-from-cwd.c +++ b/install-from-cwd.c @@ -253,6 +253,13 @@ int install_from_cwd(Options *op) } /* + * determine whether systemd files should be installed + */ + if (op->use_systemd != NV_OPTIONAL_BOOL_TRUE) { + remove_systemd_files_from_package(op, p); + } + + /* * now that we have the installation prefixes, build the * destination for each file to be installed */ @@ -1324,10 +1324,20 @@ int test_kernel_modules(Options *op, Package *p) for (i = 0; i < p->num_kernel_modules; i++) { int module_success = FALSE, insmod_ret; - char *module_path = nvstrcat(p->kernel_module_build_directory, "/", - p->kernel_modules[i].module_filename, - NULL); const char *module_opts = ""; + char *module_path; + + /* + * nvidia-peermem depends on out-of-tree kernel modules, + * so we can't reliably test-insmod it here + */ + if (strcmp(p->kernel_modules[i].module_name, "nvidia-peermem") == 0) { + continue; + } + + module_path = nvstrcat(p->kernel_module_build_directory, "/", + p->kernel_modules[i].module_filename, + NULL); if (strcmp(p->kernel_modules[i].module_name, "nvidia") == 0) { module_opts = "NVreg_DeviceFileUID=0 NVreg_DeviceFileGID=0 " @@ -111,7 +111,7 @@ static const struct { { ENTRY(NVIFR_LIB, T, T, F, F, T, F, F, T, F) }, { ENTRY(NVIFR_LIB_SYMLINK, T, F, F, T, F, F, F, T, F) }, { ENTRY(XORG_OUTPUTCLASS_CONFIG, F, T, F, F, F, F, F, T, F) }, - { ENTRY(DKMS_CONF , F, T, F, F, F, F, T, T, T) }, + { ENTRY(DKMS_CONF, F, T, F, F, F, F, T, T, T) }, { ENTRY(GLVND_LIB, T, T, F, F, T, T, F, T, F) }, { ENTRY(GLVND_SYMLINK, T, F, F, T, F, T, F, T, F) }, { ENTRY(GLX_CLIENT_LIB, T, T, F, F, T, T, F, T, F) }, @@ -127,6 +127,10 @@ static const struct { { ENTRY(INTERNAL_UTILITY_BINARY, T, T, F, F, F, F, F, T, F) }, { ENTRY(INTERNAL_UTILITY_LIB, T, T, F, F, T, F, F, T, F) }, { ENTRY(INTERNAL_UTILITY_DATA, F, T, F, F, F, F, F, T, F) }, + { ENTRY(FIRMWARE, F, T, F, F, F, F, F, F, T) }, + { ENTRY(SYSTEMD_UNIT, F, T, F, F, F, F, F, F, F) }, + { ENTRY(SYSTEMD_UNIT_SYMLINK, F, F, T, T, F, F, F, F, F) }, + { ENTRY(SYSTEMD_SLEEP_SCRIPT, F, T, F, F, F, F, F, F, F) }, }; /* @@ -468,6 +468,7 @@ static const Util __utils[] = { [XSERVER] = { "X", "xserver" }, [OPENSSL] = { "openssl", "openssl" }, [DKMS] = { "dkms", "dkms" }, + [SYSTEMCTL] = { "systemctl", "systemd" }, /* ModuleUtils */ [MODPROBE] = { "modprobe", "module-init-tools' or 'kmod" }, @@ -2927,3 +2928,112 @@ to detect the number of processors. op->concurrency_level = val; } } + +static void +free_path_if_empty(char **path) +{ + char *str = *path; + + if (str && str[0] == '\0') { + nvfree(*path); + *path = NULL; + } +} + +/* + * check_systemd() - check if systemd is available. + * + * If op->use_systemd is NV_OPTIONAL_BOOL_DEFAULT, this sets it to _TRUE or + * _FALSE depending on whether systemctl is available. + * + * Also assigns op->systemd_unit_prefix, op->systemd_sleep_prefix, and + * op->systemd_sysconf_prefix if pkg-config is available. + * + * Returns TRUE on success, FALSE otherwise. + */ +int check_systemd(Options *op) +{ + /* + * If the user specified --no-systemd, skip everything else. + */ + if (op->use_systemd == NV_OPTIONAL_BOOL_FALSE) { + return TRUE; + } + + if (op->utils[SYSTEMCTL] == NULL) { + if (op->use_systemd == NV_OPTIONAL_BOOL_TRUE) { + ui_error(op, "Option '--systemd' was specified but systemctl was " + "not found on this system"); + return FALSE; + } + + op->use_systemd = NV_OPTIONAL_BOOL_FALSE; + return TRUE; + } + + op->use_systemd = NV_OPTIONAL_BOOL_TRUE; + + /* + * Determine the path for unit files and systemd-sleep scripts if pkg-config + * and systemd.pc are available. + */ + if (op->utils[PKG_CONFIG]) { + if (op->systemd_unit_prefix == NULL) { + char *cmd, *prefix; + int ret; + + cmd = nvstrcat(op->utils[PKG_CONFIG], + " --variable=systemdsystemunitdir systemd", + NULL); + ret = run_command(op, cmd, &prefix, FALSE, 0, TRUE); + if (ret == 0) { + op->systemd_unit_prefix = prefix; + } + + nvfree(cmd); + } + + if (op->systemd_sleep_prefix == NULL) { + char *cmd, *prefix; + int ret; + + cmd = nvstrcat(op->utils[PKG_CONFIG], + " --variable=systemdsleepdir systemd", + NULL); + ret = run_command(op, cmd, &prefix, FALSE, 0, TRUE); + if (ret == 0) { + op->systemd_sleep_prefix = prefix; + } + + nvfree(cmd); + } + + if (op->systemd_sysconf_prefix == NULL) { + char *cmd, *prefix; + int ret; + + cmd = nvstrcat(op->utils[PKG_CONFIG], + " --variable=systemdsystemconfdir systemd", + NULL); + ret = run_command(op, cmd, &prefix, FALSE, 0, TRUE); + if (ret == 0) { + op->systemd_sysconf_prefix = prefix; + } + + nvfree(cmd); + } + + /* + * Rather than returning an error if a package exists but doen't have a + * particular variable, pkg-config will return success and write a blank + * line to stdout. + * + * If the paths are empty, use the defaults. + */ + free_path_if_empty(&op->systemd_unit_prefix); + free_path_if_empty(&op->systemd_sleep_prefix); + free_path_if_empty(&op->systemd_sysconf_prefix); + } + + return TRUE; +} @@ -93,5 +93,6 @@ int verify_crc(Options *op, const char *filename, unsigned int crc, int secure_boot_enabled(void); ElfFileType get_elf_architecture(const char *filename); void set_concurrency_level(Options *op); +int check_systemd(Options *op); #endif /* __NVIDIA_INSTALLER_MISC_H__ */ diff --git a/nvidia-installer.c b/nvidia-installer.c index 48e684e..fdf81b4 100644 --- a/nvidia-installer.c +++ b/nvidia-installer.c @@ -144,6 +144,7 @@ static Options *load_default_options(void) op->install_libglvnd_libraries = NV_OPTIONAL_BOOL_DEFAULT; op->external_platform_json_path = DEFAULT_EGL_EXTERNAL_PLATFORM_JSON_PATH; op->skip_depmod = FALSE; + op->use_systemd = NV_OPTIONAL_BOOL_DEFAULT; return op; @@ -491,6 +492,19 @@ static void parse_commandline(int argc, char *argv[], Options *op) case SKIP_DEPMOD_OPTION: op->skip_depmod = TRUE; break; + case SYSTEMD_OPTION: + op->use_systemd = boolval ? NV_OPTIONAL_BOOL_TRUE : + NV_OPTIONAL_BOOL_FALSE; + break; + case SYSTEMD_UNIT_PREFIX_OPTION: + op->systemd_unit_prefix = strval; + break; + case SYSTEMD_SLEEP_PREFIX_OPTION: + op->systemd_sleep_prefix = strval; + break; + case SYSTEMD_SYSCONF_PREFIX_OPTION: + op->systemd_sysconf_prefix = strval; + break; default: goto fail; } @@ -614,6 +628,7 @@ int main(int argc, char *argv[]) if (!find_system_utils(op)) goto done; if (!find_module_utils(op)) goto done; if (!check_selinux(op)) goto done; + if (!check_systemd(op)) goto done; /* check for X server properties based on the version of the server */ diff --git a/nvidia-installer.h b/nvidia-installer.h index 464cf81..b94bc80 100644 --- a/nvidia-installer.h +++ b/nvidia-installer.h @@ -58,6 +58,7 @@ typedef enum { XSERVER, OPENSSL, DKMS, + SYSTEMCTL, MAX_SYSTEM_OPTIONAL_UTILS } SystemOptionalUtils; @@ -155,6 +156,10 @@ typedef enum { FILE_TYPE_INTERNAL_UTILITY_BINARY, FILE_TYPE_INTERNAL_UTILITY_LIB, FILE_TYPE_INTERNAL_UTILITY_DATA, + FILE_TYPE_FIRMWARE, + FILE_TYPE_SYSTEMD_UNIT, + FILE_TYPE_SYSTEMD_UNIT_SYMLINK, + FILE_TYPE_SYSTEMD_SLEEP_SCRIPT, FILE_TYPE_MAX } PackageEntryFileType; @@ -285,6 +290,11 @@ typedef struct __options { int ignore_cc_version_check; + NVOptionalBool use_systemd; + char *systemd_unit_prefix; + char *systemd_sleep_prefix; + char *systemd_sysconf_prefix; + } Options; typedef enum { @@ -467,6 +477,9 @@ typedef struct __package { #define DEFAULT_MODULE_SIGNING_KEY_PATH "/usr/share/nvidia" #define DEFAULT_KERNEL_MODULE_SRC_PREFIX "/usr/src" #define DEFAULT_X_DATAROOT_PATH "/usr/share" +#define DEFAULT_SYSTEMD_UNIT_PREFIX "/usr/lib/systemd/system" +#define DEFAULT_SYSTEMD_SLEEP_PREFIX "/usr/lib/systemd/system-sleep" +#define DEFAULT_SYSTEMD_SYSCONF_PREFIX "/etc/systemd/system" /* * As of Xorg 7.x, X components need not be installed relative diff --git a/option_table.h b/option_table.h index def4755..f1d0941 100644 --- a/option_table.h +++ b/option_table.h @@ -106,6 +106,10 @@ enum { EGL_EXTERNAL_PLATFORM_CONFIG_FILE_PATH_OPTION, OVERRIDE_FILE_TYPE_DESTINATION_OPTION, SKIP_DEPMOD_OPTION, + SYSTEMD_OPTION, + SYSTEMD_UNIT_PREFIX_OPTION, + SYSTEMD_SLEEP_PREFIX_OPTION, + SYSTEMD_SYSCONF_PREFIX_OPTION, }; static const NVGetoptOption __options[] = { @@ -639,6 +643,35 @@ static const NVGetoptOption __options[] = { "running nvidia-installer." }, + { "systemd", SYSTEMD_OPTION, NVGETOPT_IS_BOOLEAN, NULL, + "By default, the installer will install systemd unit files if systemctl " + "is detected. Specifying --no-systemd will disable installation of " + "systemd units." }, + + { "systemd-unit-prefix", + SYSTEMD_UNIT_PREFIX_OPTION, NVGETOPT_STRING_ARGUMENT, NULL, + "The path to which systemd unit files should be installed. By default, " + "the installer uses `pkg-config --variable=systemdsystemunitdir systemd` " + "to determine the location to install systemd unit files, or " + "'/usr/lib/systemd/system' if pkg-config is not available. Ignored if " + "--no-systemd is specified." }, + + { "systemd-sleep-prefix", + SYSTEMD_SLEEP_PREFIX_OPTION, NVGETOPT_STRING_ARGUMENT, NULL, + "The path to which systemd-sleep script files should be installed. By " + "default, the installer uses `pkg-config --variable=systemdsleepdir " + "systemd` to determine the location to install systemd-sleep script " + "files, or '/usr/lib/systemd/system-sleep' if pkg-config is not " + "available. Ignored if --no-systemd is specified." }, + + { "systemd-sysconf-prefix", + SYSTEMD_SYSCONF_PREFIX_OPTION, NVGETOPT_STRING_ARGUMENT, NULL, + "The path to which systemd unit enable symlinks should be installed. By " + "default, the installer uses `pkg-config " + "--variable=systemdsystemconfdir systemd` to determine the location to " + "install these symlinks, or '/etc/systemd/system' if pkg-config is not " + "available. Ignored if --no-systemd is specified." }, + /* Orphaned options: These options were in the long_options table in * nvidia-installer.c but not in the help. */ { "debug", 'd', 0, NULL,NULL }, @@ -33,6 +33,7 @@ ############################################################################## CC ?= gcc +CXX ?= g++ LD ?= ld AR ?= ar # only set these warnings and optimizations if CFLAGS is unset @@ -58,16 +59,25 @@ CFLAGS += -Wno-unused-parameter HOST_CC_ONLY_CFLAGS += -Wno-format-zero-length HOST_CFLAGS += -Wno-unused-parameter +DEBUG ?= +DEVELOP ?= + ifeq ($(DEBUG),1) STRIP_CMD ?= true DO_STRIP ?= CFLAGS += -O0 -g CFLAGS += -DDEBUG=1 -else - STRIP_CMD ?= strip - DO_STRIP ?= 1 endif +ifeq ($(DEVELOP),1) + STRIP_CMD ?= true + DO_STRIP ?= + CFLAGS += -DDEVELOP=1 +endif + +STRIP_CMD ?= strip +DO_STRIP ?= 1 + INSTALL ?= install INSTALL_BIN_ARGS ?= -m 755 INSTALL_LIB_ARGS ?= -m 644 @@ -186,6 +196,21 @@ endif ############################################################################## +# Test passing $(1) to $(CC). If $(CC) succeeds, then echo $(1). +# +# Because this uses $(shell), it is best to use this to assign simply expanded +# variables (e.g., ":="). +# +# Example usage: +# CONDITIONAL_CFLAGS := $(call TEST_CC_ARG, -ffoo) +############################################################################## + +TEST_CC_ARG = \ + $(shell $(CC) -c -x c /dev/null $(1) -o /dev/null > /dev/null 2>&1 && \ + $(ECHO) $(1)) + + +############################################################################## # define variables used when installing the open source utilities from # the source tarball ############################################################################## @@ -486,8 +511,9 @@ endif define GENERATE_NVIDSTRING # g_nvid_string.c depends on all objects except g_nvid_string.o, and version.mk $(NVIDSTRING): $$(filter-out $$(call BUILD_OBJECT_LIST,$$(NVIDSTRING)), $(3)) $$(VERSION_MK) - @$$(ECHO) "const char $(1)[] = \"nvidia id: NVIDIA $$(strip $(2)) for $$(TARGET_ARCH) $$(NVIDIA_VERSION) $$(NVIDSTRING_BUILD_TYPE_STRING) (`$$(WHOAMI)`@`$$(HOSTNAME)`) `$$(DATE)`\";" > $$@ - @$$(ECHO) "const char *const p$$(strip $(1)) = $(1) + 11;" >> $$@; + $(at_if_quiet)$$(MKDIR) $$(dir $$@) + $(at_if_quiet)$$(ECHO) "const char $(1)[] = \"nvidia id: NVIDIA $$(strip $(2)) for $$(TARGET_ARCH) $$(NVIDIA_VERSION) $$(NVIDSTRING_BUILD_TYPE_STRING) (`$$(WHOAMI)`@`$$(HOSTNAME)`) `$$(DATE)`\";" > $$@ + $(at_if_quiet)$$(ECHO) "const char *const p$$(strip $(1)) = $(1) + 11;" >> $$@; endef @@ -510,6 +536,7 @@ endef define READ_ONLY_OBJECT_FROM_FILE_RULE $$(OUTPUTDIR)/$$(notdir $(1)).o: $(1) + $(at_if_quiet)$$(MKDIR) $$(OUTPUTDIR) $(at_if_quiet)cd $$(dir $(1)); \ $$(call quiet_cmd_no_at,LD) -r -z noexecstack --format=binary \ $$(notdir $(1)) -o $$(OUTPUTDIR_ABSOLUTE)/$$(notdir $$@) @@ -1,4 +1,4 @@ -NVIDIA_VERSION = 460.67 +NVIDIA_VERSION = 465.19.01 # This file. VERSION_MK_FILE := $(lastword $(MAKEFILE_LIST)) |