summaryrefslogtreecommitdiff
path: root/files.c
diff options
context:
space:
mode:
authorAaron Plattner <aplattner@nvidia.com>2008-02-13 10:20:38 -0800
committerAaron Plattner <aplattner@nvidia.com>2008-02-13 10:20:38 -0800
commit4d3c391aebad3c67ef9e77eba3fe86acc79541f5 (patch)
tree36bca53f74716b5bd9c474c0ef933006faf1a2bb /files.c
parent184ddefeab802bc3b119c49dede0d49fc5e01670 (diff)
100.14.03100.14.03
Diffstat (limited to 'files.c')
-rw-r--r--files.c214
1 files changed, 146 insertions, 68 deletions
diff --git a/files.c b/files.c
index fb028d5..9c1afef 100644
--- a/files.c
+++ b/files.c
@@ -1409,7 +1409,6 @@ int copy_directory_contents(Options *op, const char *src, const char *dst)
int pack_precompiled_kernel_interface(Options *op, Package *p)
{
char *cmd, time_str[256], *proc_version_string;
- char major[16], minor[16], patch[16];
char *result, *descr;
time_t t;
struct utsname buf;
@@ -1430,12 +1429,6 @@ int pack_precompiled_kernel_interface(Options *op, Package *p)
proc_version_string = read_proc_version(op);
- /* get the version strings */
-
- snprintf(major, 16, "%d", p->major);
- snprintf(minor, 16, "%d", p->minor);
- snprintf(patch, 16, "%d", p->patch);
-
/* use the uname string as the description */
uname(&buf);
@@ -1451,12 +1444,10 @@ int pack_precompiled_kernel_interface(Options *op, Package *p)
PRECOMPILED_KERNEL_INTERFACE_FILENAME,
" --output=", p->precompiled_kernel_interface_directory,
"/", PRECOMPILED_KERNEL_INTERFACE_FILENAME,
- "-", p->version_string, ".", time_str,
+ "-", p->version, ".", time_str,
" --description=\"", descr, "\"",
" --proc-version=\"", proc_version_string, "\"",
- " --major=", major,
- " --minor=", minor,
- " --patch=", patch, NULL);
+ " --version=", p->version, NULL);
/* execute the command */
@@ -1977,6 +1968,66 @@ static char *get_xdg_data_dir(void)
}
+
+/*
+ * extract_x_path() - take a comma-separated list of directories, and
+ * extract the next available directory in the list. Assign the
+ * 'next' pointer so that it points to where we should continue during
+ * the next call of extract_x_path().
+ *
+ * On success, return a pointer to the next directory in the string,
+ * and update the 'next' pointer. When we have exhausted the list,
+ * NULL is returned.
+ *
+ * Note that this will destructively replace commas with NULL
+ * terminators in the string.
+ */
+
+static char *extract_x_path(char *str, char **next)
+{
+ char *start;
+
+ /*
+ * choose where to start in the string: either we start at the
+ * beginning, or we start immediately after where we found a comma
+ * last time
+ */
+
+ start = str;
+
+ if (*next) start = *next;
+
+ /* skip past any commas at the start */
+
+ while (*start == ',') start++;
+
+ /* if we hit the end of the string, return now */
+
+ if (*start == '\0') return NULL;
+
+ /*
+ * find the next comma in the string; if we find one, change it to
+ * a NULL terminator (and move 'next' to the character immediately
+ * after the comma); if we don't find a comma, move the 'next'
+ * pointer to the end of the string, so that we terminate on the
+ * next call to extract_x_path()
+ */
+
+ *next = strchr(start, ',');
+
+ if (*next) {
+ **next = '\0';
+ (*next)++;
+ } else {
+ *next = strchr(start, '\0');
+ }
+
+ return start;
+
+} /* extract_x_path() */
+
+
+
/*
* get_x_paths_helper() - helper function for determining the X
* library and module paths; returns 'TRUE' if we had to guess at the
@@ -1990,7 +2041,7 @@ static int get_x_paths_helper(Options *op,
char *name,
char **path)
{
- char *dir, *cmd;
+ char *dirs, *cmd, *dir, *next;
int ret, guessed = 0;
/*
@@ -2003,94 +2054,121 @@ static int get_x_paths_helper(Options *op,
}
/*
- * if this is a modular X server, then attempt to determine the
- * path through the various query mechanisms
+ * attempt to determine the path through the various query mechanisms
+ *
+ * xorg-server >= 1.3 has a stupid version number regression because the
+ * reported Xorg version was tied to the server version, meaning what used
+ * to report 7.2 now reports, for example, 1.2.99.903. This means we set
+ * op->modular_xorg to FALSE. However, any server with this regression will
+ * also support the -showDefaultModulePath option so we should still be able
+ * to get the right path.
*/
-
- if (op->modular_xorg) {
-
- /*
- * first, try the X server commandline option; this is the
- * recommended query mechanism as of X.Org 7.2
- */
-
- if (op->utils[XSERVER]) {
-
- dir = NULL;
- cmd = nvstrcat(op->utils[XSERVER], " ", xserver_cmd, NULL);
- ret = run_command(op, cmd, &dir, FALSE, 0, TRUE);
- nvfree(cmd);
+
+ /*
+ * first, try the X server commandline option; this is the
+ * recommended query mechanism as of X.Org 7.2
+ */
+ if (op->utils[XSERVER]) {
+
+ dirs = NULL;
+ cmd = nvstrcat(op->utils[XSERVER], " ", xserver_cmd, NULL);
+ ret = run_command(op, cmd, &dirs, FALSE, 0, TRUE);
+ nvfree(cmd);
+
+ if ((ret == 0) && dirs) {
+
+ next = NULL;
+
+ dir = extract_x_path(dirs, &next);
- if ((ret == 0) && dir) {
+ while (dir) {
if (directory_exists(op, dir)) {
ui_expert(op, "X %s path '%s' determined from `%s %s`",
name, dir, op->utils[XSERVER], xserver_cmd);
- *path = dir;
+ *path = nvstrdup(dir);
+
+ nvfree(dirs);
+
return FALSE;
-
+
} else {
ui_warn(op, "You appear to be using a modular X.Org "
"release, but the X %s installation "
- "path reported by `%s %s` does not exist. "
+ "path, '%s', reported by `%s %s` does not exist. "
"Please check your X.Org installation.",
- name, op->utils[XSERVER], xserver_cmd);
+ name, dir, op->utils[XSERVER], xserver_cmd);
}
+
+ dir = extract_x_path(dirs, &next);
}
-
- nvfree(dir);
}
-
- /*
- * then, try the pkg-config command; this was the the
- * pseudo-recommended query mechanism between X.Org 7.0 and
- * X.Org 7.2
- */
-
- if (op->utils[PKG_CONFIG]) {
-
- dir = NULL;
- cmd = nvstrcat(op->utils[PKG_CONFIG], " ",
- pkg_config_cmd, NULL);
- ret = run_command(op, cmd, &dir, FALSE, 0, TRUE);
- nvfree(cmd);
+
+ nvfree(dirs);
+ }
+
+ /*
+ * then, try the pkg-config command; this was the the
+ * pseudo-recommended query mechanism between X.Org 7.0 and
+ * X.Org 7.2
+ */
+ if (op->utils[PKG_CONFIG]) {
+
+ dirs = NULL;
+ cmd = nvstrcat(op->utils[PKG_CONFIG], " ",
+ pkg_config_cmd, NULL);
+ ret = run_command(op, cmd, &dirs, FALSE, 0, TRUE);
+ nvfree(cmd);
+
+ if ((ret == 0) && dirs) {
+
+ next = NULL;
- if ((ret == 0) && dir) {
+ dir = extract_x_path(dirs, &next);
+
+ while (dir) {
if (directory_exists(op, dir)) {
-
+
ui_expert(op, "X %s path '%s' determined from `%s %s`",
name, dir, op->utils[PKG_CONFIG],
pkg_config_cmd);
+
+ *path = nvstrdup(dir);
+
+ nvfree(dirs);
- *path = dir;
return FALSE;
-
+
} else {
ui_warn(op, "You appear to be using a modular X.Org "
"release, but the X %s installation "
- "path reported by `%s %s` does not exist. "
+ "path, '%s', reported by `%s %s` does not exist. "
"Please check your X.Org installation.",
- name, op->utils[PKG_CONFIG], pkg_config_cmd);
+ name, dir, op->utils[PKG_CONFIG], pkg_config_cmd);
}
+
+ dir = extract_x_path(dirs, &next);
}
-
- nvfree(dir);
}
-
- /*
- * neither of the above mechanisms yielded a usable path; fall
- * through to constructing the path by hand; record that we
- * have to guess the path so that we can print a warning when
- * we are done
- */
-
- guessed = TRUE;
+
+ nvfree(dirs);
}
-
-
+
+ /*
+ * neither of the above mechanisms yielded a usable path; fall
+ * through to constructing the path by hand. If this is a modular X server,
+ * record that we have to guess the path so that we can print a warning when
+ * we are done. For non-modular X, the default of /usr/X11R6/lib is
+ * standard.
+ */
+
+ if (op->modular_xorg)
+ guessed = TRUE;
+
+
/* build the path */
if (library) {