diff options
-rw-r--r-- | files.c | 14 | ||||
-rw-r--r-- | misc.c | 41 | ||||
-rw-r--r-- | misc.h | 2 | ||||
-rw-r--r-- | version.mk | 2 |
4 files changed, 48 insertions, 11 deletions
@@ -3225,16 +3225,10 @@ done: static void set_libglvnd_egl_json_path(Options *op) { if (op->libglvnd_json_path == NULL) { - if (op->utils[PKG_CONFIG]) { - char *path = NULL; - char *cmd = nvstrcat(op->utils[PKG_CONFIG], " --variable=datadir libglvnd", NULL); - int ret = run_command(op, cmd, &path, FALSE, 0, TRUE); - nvfree(cmd); - - if (ret == 0) { - op->libglvnd_json_path = nvstrcat(path, "/glvnd/egl_vendor.d", NULL); - collapse_multiple_slashes(op->libglvnd_json_path); - } + char *path = get_pkg_config_variable(op, "libglvnd", "datadir"); + if (path != NULL) { + op->libglvnd_json_path = nvstrcat(path, "/glvnd/egl_vendor.d", NULL); + collapse_multiple_slashes(op->libglvnd_json_path); nvfree(path); } } @@ -3190,3 +3190,44 @@ to detect the number of processors. op->concurrency_level = val; } } + +/* + * get_pkg_config_variable() - call pkg-config to query the value of the given + * variable. + * + * Invokes `pkg-config --variable <VARIABLE> <PKG>` and returns a malloced + * string containing the returned value of the variable, if any. NULL is + * returned if the variable could not be found or some error occurred. + */ +char * +get_pkg_config_variable(Options *op, + const char *pkg, const char *variable) +{ + char *cmd, *prefix = NULL; + int ret; + + if (!op->utils[PKG_CONFIG]) { + return NULL; + } + + cmd = nvstrcat(op->utils[PKG_CONFIG], + " --variable=", variable, " ", pkg, + NULL); + ret = run_command(op, cmd, &prefix, FALSE, 0, TRUE); + nvfree(cmd); + + if (ret != 0 || + /* + * 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 path is empty, return NULL to fall back to the defaults. + */ + (prefix && prefix[0] == '\0')) { + nvfree(prefix); + prefix = NULL; + } + + return prefix; +} @@ -95,5 +95,7 @@ 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); +char *get_pkg_config_variable(Options *op, + const char *pkg, const char *variable); #endif /* __NVIDIA_INSTALLER_MISC_H__ */ @@ -1 +1 @@ -NVIDIA_VERSION = 390.144 +NVIDIA_VERSION = 390.147 |