summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Plattner <aplattner@nvidia.com>2021-12-16 12:24:56 -0800
committerAaron Plattner <aplattner@nvidia.com>2021-12-16 12:24:56 -0800
commitb6905bb81e74c804f1286c315ce6194351fc1b25 (patch)
tree7632d4cf22f27fc3f53c236dc617c668b9ff0008
parent6fe7e9846c75cdf239efaca6e3ffaab4533e3386 (diff)
390.147390.147390
-rw-r--r--files.c14
-rw-r--r--misc.c41
-rw-r--r--misc.h2
-rw-r--r--version.mk2
4 files changed, 48 insertions, 11 deletions
diff --git a/files.c b/files.c
index cac020c..12d1d28 100644
--- a/files.c
+++ b/files.c
@@ -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);
}
}
diff --git a/misc.c b/misc.c
index 168b99e..db66a5d 100644
--- a/misc.c
+++ b/misc.c
@@ -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;
+}
diff --git a/misc.h b/misc.h
index 93f8d49..f63e047 100644
--- a/misc.h
+++ b/misc.h
@@ -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__ */
diff --git a/version.mk b/version.mk
index 23b9e07..45f8240 100644
--- a/version.mk
+++ b/version.mk
@@ -1 +1 @@
-NVIDIA_VERSION = 390.144
+NVIDIA_VERSION = 390.147