summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Plattner <aplattner@nvidia.com>2009-11-23 18:50:22 -0800
committerAaron Plattner <aplattner@nvidia.com>2009-11-23 18:50:22 -0800
commit3cb604acdf3ee68ff6420372d367768b60383d56 (patch)
tree21a81d7f7861db21f2ee4b4d861f9bccdaa3f715
parentd5357451067ca1320a41299b2ca12937331267da (diff)
195.22195.22
-rw-r--r--ChangeLog97
-rw-r--r--DRIVER_VERSION2
-rw-r--r--Makefile24
-rw-r--r--README8
-rw-r--r--alloc-utils.c90
-rw-r--r--alloc-utils.h35
-rw-r--r--command-list.c5
-rw-r--r--dist-files.mk6
-rw-r--r--files.c44
-rw-r--r--files.h1
-rw-r--r--format.c151
-rw-r--r--format.h4
-rw-r--r--help-args.c123
-rw-r--r--help-args.h33
-rw-r--r--kernel.c67
-rw-r--r--makefile.nvmk183
-rw-r--r--makeself-help-script.c37
-rw-r--r--misc.c291
-rw-r--r--misc.h26
-rw-r--r--nvidia-installer.c91
-rw-r--r--nvidia-installer.h8
-rw-r--r--public.mk44
-rw-r--r--string-utils.c122
-rw-r--r--string-utils.h48
-rw-r--r--user-interface.c1
25 files changed, 1013 insertions, 528 deletions
diff --git a/ChangeLog b/ChangeLog
deleted file mode 100644
index 7a9e6a1..0000000
--- a/ChangeLog
+++ /dev/null
@@ -1,97 +0,0 @@
-
-2004-07-23 version 1.0.7
-
- * Added --kernel-output-path option to support separate KBUILD
- output directories.
-
-2004-01-12 version 1.0.6
-
- * Add support for installing on Linux 2.6 kernels.
-
- * Deprecate the "--kernel-include-path" commandline option,
- in favor of "--kernel-source-path".
-
- * Added "--no-rpms" option to disable the check for conflicting rpms.
-
-2003-12-16 version 1.0.5
-
- * Have nvidia-installer perforce a gcc version check itself (ie:
- check that the current compiler and the compiler used to compile
- the kernel are a close enough match to build the NVIDIA kernel module.
-
- * Remove conflicting libraries in /usr/X11R6/lib/tls/
-
- * Add new option "--no-abi-note".
-
-2003-09-23 version 1.0.4
-
- * When searching for a precompiled kernel interface, also look in
- /lib/modules/precompiled/`uname -r`/nvidia/gfx/, and in
- any directory specified by the new commandline option
- "--precompiled-kernel-interfaces-path".
-
- * When searching for a precompiled kernel interface, ensure that
- the version number stamped in the precompiled kernel interface
- matches that of the driver we are installing.
-
- * Add tls_test binaries for IA64
-
- * Rewrite the tls_test to more closely mimic the tls usage
- pattern of the OpenGL driver: dlopen() a dso that uses the
- local-exec access model to access a thread local variable.
-
-2003-08-13 version 1.0.3
-
- * Add new commandline option "--kernel-module-only" to allow
- users to install additional kernel modules on top of an
- existing installation.
-
- * Add new commandline options "--no-network" and "--no-backup".
-
- * Warn users if they are installing while in runlevel 1.
-
- * Install a libGL.la file.
-
- * Fix SEGV triggered when the signal handler called ui->close().
-
- * When the user does not accept the license agreement,
- print "License not accepted. Aborting installation." with
- ui_message(), rather than ui_log() so that the user gets this
- feedback displayed on screen, rather than just printed to the
- log file.
-
-2003-06-24 version 1.0.2
-
- * Add new .run/installer option "--add-this-kernel"; when this option
- is specified, the installer will build a precompiled kernel
- interface for the running kernel, and the .run file will be
- repackaged to include this new precompiled kernel interface.
-
- * If we are building for a non-running kernel, specify that
- kernel name on the depmod commandline line (see depmod(8)
- manpage for details). Patch provided by Nigel Spowage
- <Nigel.Spowage@energis.com>
-
- * Only execute `/usr/bin/chrc.config` if the distro is SuSE or
- UnitedLinux *and* the file exists. Patch from Stefan Dirsch
- <sndirsch@suse.de>
-
-2003-04-24 version 1.0.1
-
- * Do not install the NVIDIA OpenGL header files by default;
- they will be installed in the documentation directory,
- and can be optionally installed on the system with the
- "--opengl-headers" commandline option.
-
- * Abort installation if any X server is currently running
- (even if it is not using an NVIDIA driver). We check if an
- X server is running by checking for existence of the files
- /tmp/.X[0-7]-lock.
-
- * Add a signal handler to tls_test to avoid dumping core files,
- and prevent error messages from being printed to stdout.
-
-2003-03-31 version 1.0
-
- * Initial Release.
-
diff --git a/DRIVER_VERSION b/DRIVER_VERSION
index 736cc9a..6cdbcbe 100644
--- a/DRIVER_VERSION
+++ b/DRIVER_VERSION
@@ -1 +1 @@
-190.42
+195.22
diff --git a/Makefile b/Makefile
index 10eff53..3d9b3f6 100644
--- a/Makefile
+++ b/Makefile
@@ -89,6 +89,7 @@ INSTALLER_ARCH := $(subst i686,x86,$(INSTALLER_ARCH))
NVIDIA_INSTALLER = nvidia-installer
MKPRECOMPILED = mkprecompiled
+MAKESELF_HELP_SCRIPT = makeself-help-script
NVIDIA_INSTALLER_PROGRAM_NAME = "nvidia-installer"
NVIDIA_INSTALLER_VERSION = "1.0.7"
@@ -153,6 +154,9 @@ SRC = backup.c \
stream-ui.c \
update.c \
user-interface.c \
+ help-args.c \
+ string-utils.c \
+ alloc-utils.c \
sanity.c
ALL_SRC = $(SRC) $(NCURSES_UI_C) $(TLS_TEST_C) $(TLS_TEST_DSO_C) \
@@ -166,13 +170,21 @@ ALL_LDFLAGS = -L. -ldl $(LDFLAGS)
MKPRECOMPILED_SRC = crc.c mkprecompiled.c
MKPRECOMPILED_OBJS = $(MKPRECOMPILED_SRC:.c=.o)
+MAKESELF_HELP_SCRIPT_SRC = makeself-help-script.c \
+ help-args.c \
+ format.c \
+ string-utils.c \
+ alloc-utils.c
+MAKESELF_HELP_SCRIPT_OBJS = $(MAKESELF_HELP_SCRIPT_SRC:.c=.o)
+
# and now, the build rules:
default: all
-all: $(NVIDIA_INSTALLER) $(MKPRECOMPILED) $(MANPAGE)
+all: $(NVIDIA_INSTALLER) $(MKPRECOMPILED) $(MAKESELF_HELP_SCRIPT) $(MANPAGE)
-install: NVIDIA_INSTALLER_install MKPRECOMPILED_install MANPAGE_install
+install: NVIDIA_INSTALLER_install MKPRECOMPILED_install MANPAGE_install \
+ MAKESELF_HELP_SCRIPT_install
NVIDIA_INSTALLER_install: $(NVIDIA_INSTALLER)
$(STRIP) $<
@@ -181,6 +193,9 @@ NVIDIA_INSTALLER_install: $(NVIDIA_INSTALLER)
MKPRECOMPILED_install: $(MKPRECOMPILED)
$(INSTALL) $< $(bindir)/$<
+MAKESELF_HELP_SCRIPT_install: $(MAKESELF_HELP_SCRIPT)
+ $(INSTALL) $< $(bindir)/$<
+
MANPAGE_install: $(MANPAGE)
mkdir -p $(mandir)
$(INSTALL) -m 644 $< $(mandir)/$<
@@ -189,6 +204,9 @@ MANPAGE_install: $(MANPAGE)
$(MKPRECOMPILED): $(CONFIG_H) $(MKPRECOMPILED_OBJS)
$(CC) $(ALL_CFLAGS) $(ALL_LDFLAGS) $(MKPRECOMPILED_OBJS) -o $@
+$(MAKESELF_HELP_SCRIPT): $(CONFIG_H) $(MAKESELF_HELP_SCRIPT_OBJS)
+ $(CC) $(ALL_CFLAGS) $(ALL_LDFLAGS) $(MAKESELF_HELP_SCRIPT_OBJS) -o $@
+
$(NVIDIA_INSTALLER): $(CONFIG_H) $(OBJS)
$(CC) $(ALL_CFLAGS) $(ALL_LDFLAGS) $(OBJS) -Wl,-Bstatic -lpci -Wl,-Bdynamic -o $@
@@ -249,7 +267,7 @@ $(STAMP_C): $(filter-out $(STAMP_C:.c=.o), $(OBJS))
@ echo "const char *pNV_ID = NV_ID + 11;" >> $@
clean clobber:
- rm -rf $(NVIDIA_INSTALLER) $(MKPRECOMPILED) \
+ rm -rf $(NVIDIA_INSTALLER) $(MKPRECOMPILED) $(MAKESELF_HELP_SCRIPT) \
$(NCURSES_UI) $(NCURSES_UI_C) \
$(TLS_TEST_C) $(TLS_TEST_DSO_C) $(RTLD_TEST_C) $(COMPAT_32_SRC) \
$(GEN_UI_ARRAY) $(CONFIG_H) $(STAMP_C) *.o *~ *.d \
diff --git a/README b/README
index 970569a..fdec382 100644
--- a/README
+++ b/README
@@ -6,7 +6,7 @@ __________________________________________________________________________
Information on how to use the nvidia-installer is in:
- (sec-02) INSTALLING THE NVIDIA DRIVER
+ Chapter 4. Installing the NVIDIA Driver
of the NVIDIA driver README (available from the NVIDIA Linux driver
download page, and installed in /usr/share/doc/NVIDIA_GLX-1.0/).
@@ -18,7 +18,7 @@ well commented.
One interesting thing to note is that user interface shared libraries
-are "built into" nvidia-installer to avoid potential problems with
+are built into nvidia-installer to avoid potential problems with
the installer not being able to find the user interface libraries (or
finding the wrong ones, etc): after the shared lib is built, the utility
`gen-ui-array` is run on it to create a source file storing a byte
@@ -89,8 +89,6 @@ is now:
TODO:
-- Edit/generate an XF86Config file
-
- Add new user interfaces (gtk+/qt/your toolkit of choice).
- Add additional tests to be run for the '--sanity' option.
@@ -102,5 +100,3 @@ TODO:
- Internationalization.
Patches are very welcome, and may be submitted to linux-bugs@nvidia.com
-
-
diff --git a/alloc-utils.c b/alloc-utils.c
new file mode 100644
index 0000000..3a4b9ab
--- /dev/null
+++ b/alloc-utils.c
@@ -0,0 +1,90 @@
+/*
+ * 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 of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * 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, write to the:
+ *
+ * Free Software Foundation, Inc.
+ * 59 Temple Place - Suite 330
+ * Boston, MA 02111-1307, USA
+ *
+ *
+ * alloc-utils.c: this file contains heap management helper functions.
+ */
+
+#include <string.h>
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "alloc-utils.h"
+
+/*
+ * nvalloc() - malloc wrapper that checks for errors, and zeros
+ * out the memory; if an error occurs, an error is printed
+ * to stderr and exit is called. This function will only return
+ * on success.
+ */
+
+void *nvalloc(size_t size)
+{
+ void *m = malloc(size);
+
+ if (!m) {
+ fprintf(stderr, "%s: memory allocation failure (%s)! \n",
+ PROGRAM_NAME, strerror(errno));
+ exit(1);
+ }
+ memset((char *) m, 0, size);
+ return m;
+
+} /* nvalloc() */
+
+
+
+/*
+ * nvrealloc() - realloc wrapper that checks for errors; if an
+ * error occurs, an error is printed to stderr and exit
+ * is called. This function will only return on success.
+ */
+
+void *nvrealloc(void *ptr, size_t size)
+{
+ void *m;
+
+ if (ptr == NULL) return nvalloc(size);
+
+ m = realloc(ptr, size);
+ if (!m) {
+ fprintf(stderr, "%s: memory re-allocation failure (%s)! \n",
+ PROGRAM_NAME, strerror(errno));
+ exit(1);
+ }
+ return m;
+
+} /* nvrealloc() */
+
+
+
+/*
+ * nvfree() - frees memory allocated with nvalloc(), provided
+ * a non-NULL pointer is provided.
+ */
+void nvfree(char *s)
+{
+ if (s) free(s);
+
+} /* nvfree() */
diff --git a/alloc-utils.h b/alloc-utils.h
new file mode 100644
index 0000000..a7f3310
--- /dev/null
+++ b/alloc-utils.h
@@ -0,0 +1,35 @@
+/*
+ * 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 of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * 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, write to the:
+ *
+ * Free Software Foundation, Inc.
+ * 59 Temple Place - Suite 330
+ * Boston, MA 02111-1307, USA
+ *
+ *
+ * alloc-utils.h
+ */
+
+#ifndef __ALLOC_UTILS_H__
+#define __ALLOC_UTILS_H__
+
+void *nvalloc(size_t size);
+void *nvrealloc(void *ptr, size_t size);
+void nvfree(char *s);
+
+#endif /* __ALLOC_UTILS_H__ */
diff --git a/command-list.c b/command-list.c
index d78ae24..fcc19a8 100644
--- a/command-list.c
+++ b/command-list.c
@@ -461,8 +461,9 @@ int execute_command_list(Options *op, CommandList *c,
ui_status_update(op, percent, "Creating symlink: %s",
c->cmds[i].s1);
- ret = symlink(c->cmds[i].s1, c->cmds[i].s0);
- if (ret == -1) {
+ ret = install_symlink(op, c->cmds[i].s1, c->cmds[i].s0);
+
+ if (!ret) {
ret = continue_after_error(op, "Cannot create symlink %s (%s)",
c->cmds[i].s0, strerror(errno));
if (!ret) return FALSE;
diff --git a/dist-files.mk b/dist-files.mk
index 8e9a2d2..fd63379 100644
--- a/dist-files.mk
+++ b/dist-files.mk
@@ -48,6 +48,9 @@ SRC += stream-ui.c
SRC += update.c
SRC += user-interface.c
SRC += sanity.c
+SRC += help-args.c
+SRC += string-utils.c
+SRC += alloc-utils.c
DIST_FILES := $(SRC)
@@ -67,6 +70,9 @@ DIST_FILES += snarf-internal.h
DIST_FILES += snarf.h
DIST_FILES += update.h
DIST_FILES += user-interface.h
+DIST_FILES += help-args.h
+DIST_FILES += string-utils.h
+DIST_FILES += alloc-utils.h
DIST_FILES += COPYING
DIST_FILES += README
diff --git a/files.c b/files.c
index 8305023..47d352d 100644
--- a/files.c
+++ b/files.c
@@ -503,6 +503,16 @@ int set_destinations(Options *op, Package *p)
case FILE_TYPE_OPENGL_LIB:
case FILE_TYPE_OPENGL_SYMLINK:
+ if (p->entries[i].flags & FILE_CLASS_COMPAT32) {
+ prefix = op->compat32_prefix;
+ dir = op->compat32_libdir;
+ } else {
+ prefix = op->opengl_prefix;
+ dir = op->opengl_libdir;
+ }
+ path = "";
+ break;
+
case FILE_TYPE_VDPAU_LIB:
case FILE_TYPE_VDPAU_SYMLINK:
if (p->entries[i].flags & FILE_CLASS_COMPAT32) {
@@ -512,7 +522,7 @@ int set_destinations(Options *op, Package *p)
prefix = op->opengl_prefix;
dir = op->opengl_libdir;
}
- path = "";
+ path = p->entries[i].path;
break;
case FILE_TYPE_CUDA_LIB:
@@ -524,7 +534,7 @@ int set_destinations(Options *op, Package *p)
prefix = op->opengl_prefix;
dir = op->opengl_libdir;
}
- path = "";
+ path = p->entries[i].path;
break;
case FILE_TYPE_XLIB_SHARED_LIB:
@@ -1179,6 +1189,36 @@ int install_file(Options *op, const char *srcfile,
} /* install_file() */
+/*
+ * install_symlink() - install dstfile as a symlink to linkname; this
+ * is done by extracting the directory portion of dstfile, creating
+ * that directory if it does not exist, and then calling symlink().
+ */
+
+int install_symlink(Options *op, const char *linkname, const char *dstfile)
+{
+ int retval;
+ char *dirc, *dname;
+
+ dirc = nvstrdup(dstfile);
+ dname = dirname(dirc);
+
+ if (!mkdir_recursive(op, dname, 0755)) {
+ free(dirc);
+ return FALSE;
+ }
+
+ if (symlink(linkname, dstfile)) {
+ free(dirc);
+ return FALSE;
+ }
+
+ free(dirc);
+ return TRUE;
+
+} /* install_symlink() */
+
+
size_t get_file_size(Options *op, const char *filename)
{
diff --git a/files.h b/files.h
index 32c8c40..f864430 100644
--- a/files.h
+++ b/files.h
@@ -48,6 +48,7 @@ int mkdir_recursive(Options *op, const char *path, const mode_t mode);
char *get_symlink_target(Options *op, const char *filename);
int install_file(Options *op, const char *srcfile,
const char *dstfile, mode_t mode);
+int install_symlink(Options *op, const char *linkname, const char *dstfile);
size_t get_file_size(Options *op, const char *filename);
size_t fget_file_size(Options *op, const int fd);
char *get_tmpdir(Options *op);
diff --git a/format.c b/format.c
index 72f05aa..f9fe88f 100644
--- a/format.c
+++ b/format.c
@@ -26,10 +26,12 @@
*/
+#include <ctype.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <stdlib.h>
+#include <string.h>
#include "nvidia-installer.h"
#include "format.h"
@@ -174,3 +176,152 @@ static void vformat(FILE *stream, const int wb,
nv_free_text_rows(t);
} /* vformat() */
+
+
+
+/*
+ * nv_format_text_rows() - this function breaks the given string str
+ * into some number of rows, where each row is not longer than the
+ * specified width.
+ *
+ * If prefix is non-NULL, the first line is prepended with the prefix,
+ * and subsequent lines are indented to line up with the prefix.
+ *
+ * If word_boundary is TRUE, then attempt to only break lines on
+ * boundaries between words.
+ *
+ * XXX Note that we don't use nvalloc() or any of the other wrapper
+ * functions from here, so that this function doesn't require any
+ * non-c library symbols (so that it can be called from dlopen()'ed
+ * user interfaces.
+ */
+
+TextRows *nv_format_text_rows(const char *prefix, const char *str,
+ int width, int word_boundary)
+{
+ int len, prefix_len, z, w, i;
+ char *line, *buf, *local_prefix, *a, *b, *c;
+ TextRows *t;
+
+ /* initialize the TextRows structure */
+
+ t = (TextRows *) malloc(sizeof(TextRows));
+ t->t = NULL;
+ t->n = 0;
+ t->m = 0;
+
+ if (!str) return t;
+
+ buf = strdup(str);
+
+ z = strlen(buf); /* length of entire string */
+ a = buf; /* pointer to the start of the string */
+
+ /* initialize the prefix fields */
+
+ if (prefix) {
+ prefix_len = strlen(prefix);
+ local_prefix = nvstrdup(prefix);
+ } else {
+ prefix_len = 0;
+ local_prefix = NULL;
+ }
+
+ /* adjust the max width for any prefix */
+
+ w = width - prefix_len;
+
+ do {
+ /*
+ * if the string will fit on one line, point b to the end of the
+ * string
+ */
+
+ if (z < w) b = a + z;
+
+ /*
+ * if the string won't fit on one line, move b to where the
+ * end of the line should be, and then move b back until we
+ * find a space; if we don't find a space before we back b all
+ * the way up to a, just assign b to where the line should end.
+ */
+
+ else {
+ b = a + w;
+
+ if (word_boundary) {
+ while ((b >= a) && (!isspace(*b))) b--;
+ if (b <= a) b = a + w;
+ }
+ }
+
+ /* look for any newline inbetween a and b, and move b to it */
+
+ for (c = a; c < b; c++) if (*c == '\n') { b = c; break; }
+
+ /*
+ * copy the string that starts at a and ends at b, prepending
+ * with a prefix, if present
+ */
+
+ len = b-a;
+ len += prefix_len;
+ line = (char *) malloc(len+1);
+ if (local_prefix) strncpy(line, local_prefix, prefix_len);
+ strncpy(line + prefix_len, a, len - prefix_len);
+ line[len] = '\0';
+
+ /* append the new line to the array of text rows */
+
+ t->t = (char **) realloc(t->t, sizeof(char *) * (t->n + 1));
+ t->t[t->n] = line;
+ t->n++;
+
+ if (t->m < len) t->m = len;
+
+ /*
+ * adjust the length of the string and move the pointer to the
+ * beginning of the new line
+ */
+
+ z -= (b - a + 1);
+ a = b + 1;
+
+ /* move to the first non whitespace character (excluding newlines) */
+
+ if (word_boundary && isspace(*b)) {
+ while ((z) && (isspace(*a)) && (*a != '\n')) a++, z--;
+ } else {
+ if (!isspace(*b)) z++, a--;
+ }
+
+ if (local_prefix) {
+ for (i = 0; i < prefix_len; i++) local_prefix[i] = ' ';
+ }
+
+ } while (z > 0);
+
+ if (local_prefix) free(local_prefix);
+ free(buf);
+
+ return t;
+
+} /* nv_format_text_rows() */
+
+
+
+/*
+ * nv_free_text_rows() - free the TextRows data structure allocated by
+ * nv_format_text_rows()
+ */
+
+void nv_free_text_rows(TextRows *t)
+{
+ int i;
+
+ if (!t) return;
+ for (i = 0; i < t->n; i++) free(t->t[i]);
+ if (t->t) free(t->t);
+ free(t);
+
+} /* nv_free_text_rows() */
diff --git a/format.h b/format.h
index b82660b..e33cb55 100644
--- a/format.h
+++ b/format.h
@@ -38,4 +38,8 @@ void fmterr(const char *fmt, ...);
void fmterrp(const char *prefix, const char *fmt, ...);
void format(FILE *stream, const char *prefix, const char *fmt, ...);
+TextRows *nv_format_text_rows(const char *prefix, const char *buf,
+ int width, int word_boundary);
+void nv_free_text_rows(TextRows *t);
+
#endif /* __NVIDIA_INSTALLER_FORMAT_H__ */
diff --git a/help-args.c b/help-args.c
new file mode 100644
index 0000000..15b92b2
--- /dev/null
+++ b/help-args.c
@@ -0,0 +1,123 @@
+/*
+ * 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 of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * 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, write to the:
+ *
+ * Free Software Foundation, Inc.
+ * 59 Temple Place - Suite 330
+ * Boston, MA 02111-1307, USA
+ *
+ *
+ * help-args.c: this file contains a utility function that outputs the
+ * option table in a human readable format.
+ */
+
+#include <ctype.h>
+#include <string.h>
+#include <stdio.h>
+
+#include "string-utils.h"
+#include "alloc-utils.h"
+#include "nvidia-installer.h"
+#include "format.h"
+
+#include "option_table.h"
+
+/*
+ * cook_description() - the description string may contain text
+ * within brackets, which is used by the manpage generator
+ * to denote text to be italicized. We want to omit the bracket
+ * characters here.
+ */
+
+static char *cook_description(const char *description)
+{
+ int len;
+ char *s, *dst;
+ const char *src;
+
+ len = strlen(description);
+ s = nvalloc(len + 1);
+
+ for (src = description, dst = s; *src; src++) {
+ if (*src != '[' && (*src != ']')) {
+ *dst = *src;
+ dst++;
+ }
+ }
+
+ *dst = '\0';
+
+ return s;
+
+} /* cook_description() */
+
+
+
+void print_help_args_only(int args_only, int advanced)
+{
+ int i, j, len;
+ char *msg, *tmp, scratch[64];
+ const NVOption *o;
+
+ /*
+ * the args_only parameter is used by makeself.sh to get our
+ * argument list and description; in this case we don't
+ * want to format to the width of the terminal, so hardcode
+ * the width to 65.
+ */
+ if (args_only) reset_current_terminal_width(65);
+
+ for (i = 0; __options[i].name; i++) {
+ o = &__options[i];
+
+ /*
+ * if non-advanced help is requested, and the ALWAYS flag is
+ * not set, then skip this option
+ */
+
+ if (!advanced && !(o->flags & OPTION_HELP_ALWAYS)) continue;
+
+ /* Skip options with no help text */
+ if (!o->description) continue;
+
+ if (o->flags & NVOPT_IS_BOOLEAN) {
+ msg = nvstrcat("--", o->name, "/--no-", o->name, NULL);
+ } else if (isalnum(o->val)) {
+ sprintf(scratch, "%c", o->val);
+ msg = nvstrcat("-", scratch, ", --", o->name, NULL);
+ } else {
+ msg = nvstrcat("--", o->name, NULL);
+ }
+ if (o->flags & NVOPT_HAS_ARGUMENT) {
+ len = strlen(o->name);
+ for (j = 0; j < len; j++) scratch[j] = toupper(o->name[j]);
+ scratch[len] = '\0';
+ tmp = nvstrcat(msg, "=", scratch, NULL);
+ nvfree(msg);
+ msg = tmp;
+ }
+ fmtoutp(TAB, msg);
+ if (o->description) {
+ tmp = cook_description(o->description);
+ fmtoutp(BIGTAB, tmp);
+ nvfree(tmp);
+ }
+ fmtout("");
+ nvfree(msg);
+ }
+}
diff --git a/help-args.h b/help-args.h
new file mode 100644
index 0000000..63b4be0
--- /dev/null
+++ b/help-args.h
@@ -0,0 +1,33 @@
+/*
+ * 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 of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * 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, write to the:
+ *
+ * Free Software Foundation, Inc.
+ * 59 Temple Place - Suite 330
+ * Boston, MA 02111-1307, USA
+ *
+ *
+ * nvidia-installer.h
+ */
+
+#ifndef __HELP_ARGS_H__
+#define __HELP_ARGS_H__
+
+void print_help_args_only(int args_only, int advanced);
+
+#endif /* __HELP_ARGS_H__ */
diff --git a/kernel.c b/kernel.c
index 626c71e..904a652 100644
--- a/kernel.c
+++ b/kernel.c
@@ -67,6 +67,7 @@ static PrecompiledInfo *scan_dir(Options *op, Package *p,
static char *build_distro_precompiled_kernel_interface_dir(Options *op);
static char *convert_include_path_to_source_path(const char *inc);
static char *guess_kernel_module_filename(Options *op);
+static char *get_machine_arch(Options *op);
/*
* Message text that is used by several error messages.
@@ -160,6 +161,7 @@ int determine_kernel_source_path(Options *op, Package *p)
{
char *CC, *cmd, *result;
char *source_file, *source_path;
+ char *arch;
int ret, count = 0;
/* determine the kernel source path */
@@ -245,13 +247,16 @@ int determine_kernel_source_path(Options *op, Package *p)
}
free(result);
+ arch = get_machine_arch(op);
+ if (!arch)
+ return FALSE;
if (!determine_kernel_output_path(op)) return FALSE;
CC = getenv("CC");
if (!CC) CC = "cc";
cmd = nvstrcat("sh ", p->kernel_module_build_directory,
- "/conftest.sh ", CC, " ", CC, " ",
+ "/conftest.sh ", CC, " ", CC, " ", arch, " ",
op->kernel_source_path, " ",
op->kernel_output_path, " ",
"get_uname", NULL);
@@ -416,8 +421,13 @@ int link_kernel_module(Options *op, Package *p)
int build_kernel_module(Options *op, Package *p)
{
char *CC, *result, *cmd, *tmp;
+ char *arch;
int len, ret;
+ arch = get_machine_arch(op);
+ if (!arch)
+ return FALSE;
+
/*
* touch all the files in the build directory to avoid make time
* skew messages
@@ -433,7 +443,7 @@ int build_kernel_module(Options *op, Package *p)
* no hope for the make rules if this fails.
*/
cmd = nvstrcat("sh ", p->kernel_module_build_directory,
- "/conftest.sh ", CC, " ", CC, " ",
+ "/conftest.sh ", CC, " ", CC, " ", arch, " ",
op->kernel_source_path, " ",
op->kernel_output_path, " ",
"select_makefile just_msg", NULL);
@@ -1457,6 +1467,7 @@ download_updated_kernel_interface(Options *op, Package *p,
int check_cc_version(Options *op, Package *p)
{
char *cmd, *CC, *result;
+ char *arch;
int ret;
/*
@@ -1472,13 +1483,17 @@ int check_cc_version(Options *op, Package *p)
return TRUE;
}
+ arch = get_machine_arch(op);
+ if (!arch)
+ return FALSE;
+
CC = getenv("CC");
if (!CC) CC = "cc";
ui_log(op, "Performing CC version check with CC=\"%s\".", CC);
cmd = nvstrcat("sh ", p->kernel_module_build_directory,
- "/conftest.sh ", CC, " ", CC, " ",
+ "/conftest.sh ", CC, " ", CC, " ", arch, " ",
"DUMMY_SOURCE DUMMY_OUTPUT ",
"cc_version_check just_msg", NULL);
@@ -1514,15 +1529,20 @@ int check_cc_version(Options *op, Package *p)
static int fbdev_check(Options *op, Package *p)
{
char *CC, *cmd, *result;
+ char *arch;
int ret;
+ arch = get_machine_arch(op);
+ if (!arch)
+ return FALSE;
+
CC = getenv("CC");
if (!CC) CC = "cc";
ui_log(op, "Performing rivafb check.");
cmd = nvstrcat("sh ", p->kernel_module_build_directory,
- "/conftest.sh ", CC, " ", CC, " ",
+ "/conftest.sh ", CC, " ", CC, " ", arch, " ",
op->kernel_source_path, " ",
op->kernel_output_path, " ",
"rivafb_sanity_check just_msg", NULL);
@@ -1541,7 +1561,7 @@ static int fbdev_check(Options *op, Package *p)
ui_log(op, "Performing nvidiafb check.");
cmd = nvstrcat("sh ", p->kernel_module_build_directory,
- "/conftest.sh ", CC, " ", CC, " ",
+ "/conftest.sh ", CC, " ", CC, " ", arch, " ",
op->kernel_source_path, " ",
op->kernel_output_path, " ",
"nvidiafb_sanity_check just_msg", NULL);
@@ -1571,15 +1591,20 @@ static int fbdev_check(Options *op, Package *p)
static int xen_check(Options *op, Package *p)
{
char *CC, *cmd, *result;
+ char *arch;
int ret;
+ arch = get_machine_arch(op);
+ if (!arch)
+ return FALSE;
+
CC = getenv("CC");
if (!CC) CC = "cc";
ui_log(op, "Performing Xen check.");
cmd = nvstrcat("sh ", p->kernel_module_build_directory,
- "/conftest.sh ", CC, " ", CC, " ",
+ "/conftest.sh ", CC, " ", CC, " ", arch, " ",
op->kernel_source_path, " ",
op->kernel_output_path, " ",
"xen_sanity_check just_msg", NULL);
@@ -1770,3 +1795,33 @@ static char *guess_kernel_module_filename(Options *op)
return nvstrdup("nvidia.o");
} /* guess_kernel_module_filename() */
+
+
+
+/*
+ * get_machine_arch() - get the machine architecture, substituting
+ * i386 for i586 and i686.
+ */
+
+static char __machine_arch[16];
+
+char *get_machine_arch(Options *op)
+{
+ struct utsname uname_buf;
+
+ if (uname(&uname_buf) == -1) {
+ ui_warn(op, "Unable to determine machine architecture (%s).",
+ strerror(errno));
+ return NULL;
+ } else {
+ if ((strncmp(uname_buf.machine, "i586", 3) == 0) ||
+ (strncmp(uname_buf.machine, "i686", 3) == 0)) {
+ strcpy(__machine_arch, "i386");
+ } else {
+ strncpy(__machine_arch, uname_buf.machine,
+ sizeof(__machine_arch));
+ }
+ return __machine_arch;
+ }
+
+} /* get_machine_arch() */
diff --git a/makefile.nvmk b/makefile.nvmk
new file mode 100644
index 0000000..7ee1fb5
--- /dev/null
+++ b/makefile.nvmk
@@ -0,0 +1,183 @@
+##############################################################################
+# drivers/setup/linux/nvidia-installer/makefile.nvmk
+##############################################################################
+
+##############################################################################
+# Identify this module to nvCommon.nvmk so it can decide the build type
+##############################################################################
+
+NV_MODULE_BUILD_TYPE_ALIASES = utils
+
+include $(NV_SOURCE)/drivers/common/build/nvCommon.nvmk
+
+
+##############################################################################
+# string to prepend in unix builds when executing rules in this gmake instance
+##############################################################################
+
+export NV_MODULE_LOGGING_NAME = "nvidia-installer"
+
+
+##############################################################################
+# export the appropriate variables from nvmake to the gmake that we're
+# going to invoke
+##############################################################################
+
+$(eval $(EXPORT_VARIABLES_TO_PUBLIC_MAKEFILE))
+
+_ncurses_dir = $(NV_TOOLS)/unix/targets/$(NV_TARGET_OS)-$(NV_TARGET_ARCH_UNIX_TOOLS)/ncurses-5.5
+
+NCURSES_INCLUDE_DIR = $(_ncurses_dir)/include
+NCURSES_LIB_DIR = $(_ncurses_dir)/lib
+
+export NCURSES_CFLAGS = -I$(NCURSES_INCLUDE_DIR)
+export NCURSES_LDFLAGS = -L$(NCURSES_LIB_DIR)
+
+_pci_dir = $(NV_TOOLS)/unix/targets/$(NV_TARGET_OS)-$(NV_TARGET_ARCH_UNIX_TOOLS)/pciutils-2.2.1
+
+PCI_INCLUDE_DIR = $(_pci_dir)/include
+PCI_LIB_DIR = $(_pci_dir)/lib
+
+export PCI_CFLAGS = -I$(PCI_INCLUDE_DIR)
+export PCI_LDFLAGS = -L$(PCI_LIB_DIR)
+
+export OUTPUTDIR
+
+export NV_AUTO_DEPEND
+export NV_VERBOSE
+
+# for utils.mk
+NV_MAKE_ARGS = -I $(NV_SOURCE)/drivers/setup/linux/common
+
+
+##############################################################################
+# check that all the directories that we exported above actually
+# exist; trigger a warning if any of them don't exist
+##############################################################################
+
+_extra_dirs += $(NCURSES_INCLUDE_DIR)
+_extra_dirs += $(NCURSES_LIB_DIR)
+_extra_dirs += $(PCI_INCLUDE_DIR)
+_extra_dirs += $(PCI_LIB_DIR)
+
+build :: $(_extra_dirs)
+
+$(sort $(_extra_dirs)) :
+ @$(ECHO) WARNING: nvidia-installer extra directory does not exist: $@
+
+
+##############################################################################
+# generate the legacy GPU header file
+##############################################################################
+
+_nv_common_inc = $(NV_SOURCE)/drivers/common/inc
+_nv_sdk_inc = $(NV_SOURCE)/sdk/nvidia/inc
+
+NV_NAME_H = $(_nv_common_inc)/nv_name.h
+NV_CHIPFLAGS_H = $(_nv_common_inc)/nvChipFlags.h
+NV_CHIPUTILS_H = $(_nv_common_inc)/nvChipUtils.h
+NV_MISC_H = $(_nv_sdk_inc)/nvmisc.h
+
+NV_LEGACY_H = $(OUTPUTDIR)/nvLegacy.h
+
+NV_LEGACY_GENERATOR = $(OUTPUTDIR)/nvLegacyGenerator
+
+NV_LEGACY_GENERATOR_HEADER_DEPS = \
+ $(NV_NAME_H) $(NV_CHIPFLAGS_H) $(NV_CHIPUTILS_H) $(NV_MISC_H)
+
+NV_LEGACY_GENERATOR_INCLUDE_CFLAGS = \
+ $(addprefix -I,$(sort $(dir $(NV_LEGACY_GENERATOR_HEADER_DEPS))))
+
+$(NV_LEGACY_GENERATOR): ../nvLegacy.c $(NV_LEGACY_GENERATOR_HEADER_DEPS)
+ $(call quiet_cmd,HOST_CC) $< -o $@ \
+ $(NV_LEGACY_GENERATOR_INCLUDE_CFLAGS) $(HOST_LDFLAGS) $(HOST_BIN_LDFLAGS)
+
+$(NV_LEGACY_H): $(NV_LEGACY_GENERATOR)
+ ./$(NV_LEGACY_GENERATOR) > $@
+
+OTHER_FILES_TO_REMOVE += $(NV_LEGACY_H) $(NV_LEGACY_GENERATOR)
+
+
+##############################################################################
+# define how to package the nvidia-installer source tarball
+##############################################################################
+
+.PHONY: dist-tarball
+
+# include the list of nvidia-installer source files; defines DIST_FILES
+include dist-files.mk
+
+NVIDIA_INSTALLER_DISTDIR_NO_OUTPUTDIR = nvidia-installer-$(NV_VERSION_STRING)
+NVIDIA_INSTALLER_DISTDIR = $(OUTPUTDIR)/$(NVIDIA_INSTALLER_DISTDIR_NO_OUTPUTDIR)
+NVIDIA_INSTALLER_TARBALL_NO_OUTPUTDIR = $(NVIDIA_INSTALLER_DISTDIR_NO_OUTPUTDIR).tar.bz2
+NVIDIA_INSTALLER_TARBALL = $(NVIDIA_INSTALLER_DISTDIR).tar.bz2
+
+ifeq ($(NV_VERBOSE),1)
+ _tar_verbose_arg = -v
+else
+ _tar_verbose_arg =
+endif
+
+# define rules to copy files from the source tree to
+# $(NVIDIA_INSTALLER_DISTDIR)
+
+$(eval $(call ADD_FILE_TO_TARBALL_RULE, \
+ public.mk, \
+ $(NVIDIA_INSTALLER_DISTDIR)/Makefile, \
+ $(NVIDIA_INSTALLER_TARBALL)))
+
+$(eval $(call ADD_FILE_TO_TARBALL_RULE, \
+ $(OUTPUTDIR)/version.mk, \
+ $(NVIDIA_INSTALLER_DISTDIR)/version.mk, \
+ $(NVIDIA_INSTALLER_TARBALL)))
+
+$(eval $(call ADD_FILE_TO_TARBALL_RULE, \
+ $(NV_SOURCE)/drivers/setup/linux/common/utils.mk, \
+ $(NVIDIA_INSTALLER_DISTDIR)/utils.mk, \
+ $(NVIDIA_INSTALLER_TARBALL)))
+
+$(eval $(call ADD_FILE_TO_TARBALL_RULE, \
+ $(NV_LEGACY_H), \
+ $(NVIDIA_INSTALLER_DISTDIR)/$(notdir $(NV_LEGACY_H)), \
+ $(NVIDIA_INSTALLER_TARBALL)))
+
+$(foreach src, $(DIST_FILES), \
+ $(eval $(call ADD_FILE_TO_TARBALL_RULE, \
+ $(src), \
+ $(NVIDIA_INSTALLER_DISTDIR)/$(src), \
+ $(NVIDIA_INSTALLER_TARBALL))))
+
+$(NVIDIA_INSTALLER_TARBALL):
+ @$(ECHO) "Generating $(OUTPUTDIR)/$(NVIDIA_INSTALLER_TARBALL)"
+ $(RM) $(OUTPUTDIR)/tar-file-list.txt
+ for i in $(patsubst $(OUTPUTDIR)/%,%,$(TARBALL_FILE_LIST_$@)); do \
+ $(ECHO) $${i} >> $(OUTPUTDIR)/tar-file-list.txt; \
+ done
+ cd $(OUTPUTDIR) && \
+ PATH=/bin $(TAR) -c -j $(_tar_verbose_arg) -f \
+ $(NVIDIA_INSTALLER_TARBALL_NO_OUTPUTDIR) \
+ --files-from=tar-file-list.txt
+ $(RM) $(OUTPUTDIR)/tar-file-list.txt
+
+dist-tarball: $(NVIDIA_INSTALLER_TARBALL)
+
+OTHER_FILES_TO_REMOVE += $(NVIDIA_INSTALLER_DISTDIR)
+OTHER_FILES_TO_REMOVE += $(NVIDIA_INSTALLER_TARBALL)
+
+
+##############################################################################
+# to actually build nvidia-settings, hand off control to the public makefile
+##############################################################################
+
+$(eval $(DEFINE_VERSION_MK_RULE))
+
+build:: $(OUTPUTDIR)/version.mk $(NV_LEGACY_H)
+ $(MAKE) $(NV_MAKE_ARGS) -f public.mk $@
+
+
+##############################################################################
+# define the compiler and include the common rules
+##############################################################################
+
+include $(NV_SOURCE)/drivers/common/build/gcc-4.1.1as2.nvmk
+include $(NV_SOURCE)/drivers/common/build/nvCommonRules.nvmk
diff --git a/makeself-help-script.c b/makeself-help-script.c
new file mode 100644
index 0000000..61ace43
--- /dev/null
+++ b/makeself-help-script.c
@@ -0,0 +1,37 @@
+/*
+ * Implements the '--help-args-only' and '--advanced-options-args-only'
+ * nvidia-installer command line options for use by makeself when
+ * generating the .run file during the 'dist' step.
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "nvidia-installer.h"
+#include "help-args.h"
+
+void print_usage(char **argv)
+{
+ fprintf(stderr, "usage: %s --help-args-only|"
+ "--advanced-options-args-only\n", argv[0]);
+}
+
+int main(int argc, char **argv)
+{
+ if (argc != 2) {
+ print_usage(argv);
+ exit(1);
+ }
+
+ if (strcmp(argv[1], "--help-args-only") == 0)
+ print_help_args_only(TRUE, FALSE);
+ else if (strcmp(argv[1], "--advanced-options-args-only") == 0)
+ print_help_args_only(TRUE, TRUE);
+ else {
+ print_usage(argv);
+ exit(1);
+ }
+
+ return 0;
+}
diff --git a/misc.c b/misc.c
index 3d5f181..0e9795f 100644
--- a/misc.c
+++ b/misc.c
@@ -59,149 +59,6 @@ static int check_file(Options*, const char*, const mode_t, const uint32);
/*
- * nvalloc() - malloc wrapper that checks for errors, and zeros out
- * the memory; if an error occurs, an error is printed to stderr and
- * exit is called -- this function will only return on success.
- */
-
-void *nvalloc(size_t size)
-{
- void *m = malloc(size);
-
- if (!m) {
- fprintf(stderr, "%s: memory allocation failure (%s)! \n",
- PROGRAM_NAME, strerror(errno));
- exit(1);
- }
- memset((char *) m, 0, size);
- return m;
-
-} /* nvalloc() */
-
-
-
-/*
- * nvrealloc() - realloc wrapper that checks for errors; if an error
- * occurs, an error is printed to stderr and exit is called -- this
- * function will only return on success.
- */
-
-void *nvrealloc(void *ptr, size_t size)
-{
- void *m;
-
- if (ptr == NULL) return nvalloc(size);
-
- m = realloc(ptr, size);
- if (!m) {
- fprintf(stderr, "%s: memory re-allocation failure (%s)! \n",
- PROGRAM_NAME, strerror(errno));
- exit(1);
- }
- return m;
-
-} /* nvrealloc() */
-
-
-
-/*
- * nvstrdup() - wrapper for strdup() that checks the return value; if
- * an error occurs, an error is printed to stderr and exit is called
- * -- this function will only return on success.
- */
-
-char *nvstrdup(const char *s)
-{
- char *m;
-
- if (!s) return NULL;
-
- m = strdup(s);
-
- if (!m) {
- fprintf(stderr, "%s: memory allocation failure during strdup (%s)! \n",
- PROGRAM_NAME, strerror(errno));
- exit(1);
- }
- return m;
-
-} /* nvstrdup() */
-
-
-
-/*
- * nvfree() -
- */
-void nvfree(char *s)
-{
- if (s) free(s);
-
-} /* nvfree() */
-
-
-
-/*
- * nvstrtolower() - convert the given string to lowercase.
- */
-
-char *nvstrtolower(char *s)
-{
- char *start = s;
-
- if (s == NULL) return NULL;
-
- while (*s) {
- *s = tolower(*s);
- s++;
- }
-
- return start;
-
-} /* nvstrtolower() */
-
-
-
-/*
- * nvstrcat() - allocate a new string, copying all given strings
- * into it. taken from glib
- */
-
-char *nvstrcat(const char *str, ...)
-{
- unsigned int l;
- va_list args;
- char *s;
- char *concat;
-
- l = 1 + strlen(str);
- va_start(args, str);
- s = va_arg(args, char *);
-
- while (s) {
- l += strlen(s);
- s = va_arg(args, char *);
- }
- va_end(args);
-
- concat = nvalloc(l);
- concat[0] = 0;
-
- strcat(concat, str);
- va_start(args, str);
- s = va_arg(args, char *);
- while (s) {
- strcat(concat, s);
- s = va_arg(args, char *);
- }
- va_end(args);
-
- return concat;
-
-} /* nvstrcat() */
-
-
-
-/*
* read_next_word() - given a string buf, skip any whitespace, and
* then copy the next set of characters until more white space is
* encountered. A new string containing this next word is returned.
@@ -2544,151 +2401,3 @@ done:
nvfree(cmd);
return ret;
}
-
-
-/*
- * nv_format_text_rows() - this function breaks the given string str
- * into some number of rows, where each row is not longer than the
- * specified width.
- *
- * If prefix is non-NULL, the first line is prepended with the prefix,
- * and subsequent lines are indented to line up with the prefix.
- *
- * If word_boundary is TRUE, then attempt to only break lines on
- * boundaries between words.
- *
- * XXX Note that we don't use nvalloc() or any of the other wrapper
- * functions from here, so that this function doesn't require any
- * non-c library symbols (so that it can be called from dlopen()'ed
- * user interfaces.
- */
-
-TextRows *nv_format_text_rows(const char *prefix, const char *str,
- int width, int word_boundary)
-{
- int len, prefix_len, z, w, i;
- char *line, *buf, *local_prefix, *a, *b, *c;
- TextRows *t;
-
- /* initialize the TextRows structure */
-
- t = (TextRows *) malloc(sizeof(TextRows));
- t->t = NULL;
- t->n = 0;
- t->m = 0;
-
- if (!str) return t;
-
- buf = strdup(str);
-
- z = strlen(buf); /* length of entire string */
- a = buf; /* pointer to the start of the string */
-
- /* initialize the prefix fields */
-
- if (prefix) {
- prefix_len = strlen(prefix);
- local_prefix = nvstrdup(prefix);
- } else {
- prefix_len = 0;
- local_prefix = NULL;
- }
-
- /* adjust the max width for any prefix */
-
- w = width - prefix_len;
-
- do {
- /*
- * if the string will fit on one line, point b to the end of the
- * string
- */
-
- if (z < w) b = a + z;
-
- /*
- * if the string won't fit on one line, move b to where the
- * end of the line should be, and then move b back until we
- * find a space; if we don't find a space before we back b all
- * the way up to a, just assign b to where the line should end.
- */
-
- else {
- b = a + w;
-
- if (word_boundary) {
- while ((b >= a) && (!isspace(*b))) b--;
- if (b <= a) b = a + w;
- }
- }
-
- /* look for any newline inbetween a and b, and move b to it */
-
- for (c = a; c < b; c++) if (*c == '\n') { b = c; break; }
-
- /*
- * copy the string that starts at a and ends at b, prepending
- * with a prefix, if present
- */
-
- len = b-a;
- len += prefix_len;
- line = (char *) malloc(len+1);
- if (local_prefix) strncpy(line, local_prefix, prefix_len);
- strncpy(line + prefix_len, a, len - prefix_len);
- line[len] = '\0';
-
- /* append the new line to the array of text rows */
-
- t->t = (char **) realloc(t->t, sizeof(char *) * (t->n + 1));
- t->t[t->n] = line;
- t->n++;
-
- if (t->m < len) t->m = len;
-
- /*
- * adjust the length of the string and move the pointer to the
- * beginning of the new line
- */
-
- z -= (b - a + 1);
- a = b + 1;
-
- /* move to the first non whitespace character (excluding newlines) */
-
- if (word_boundary && isspace(*b)) {
- while ((z) && (isspace(*a)) && (*a != '\n')) a++, z--;
- } else {
- if (!isspace(*b)) z++, a--;
- }
-
- if (local_prefix) {
- for (i = 0; i < prefix_len; i++) local_prefix[i] = ' ';
- }
-
- } while (z > 0);
-
- if (local_prefix) free(local_prefix);
- free(buf);
-
- return t;
-
-} /* nv_format_text_rows() */
-
-
-
-/*
- * nv_free_text_rows() - free the TextRows data structure allocated by
- * nv_format_text_rows()
- */
-
-void nv_free_text_rows(TextRows *t)
-{
- int i;
-
- if (!t) return;
- for (i = 0; i < t->n; i++) free(t->t[i]);
- if (t->t) free(t->t);
- free(t);
-
-} /* nv_free_text_rows() */
diff --git a/misc.h b/misc.h
index 72fced0..eda66e2 100644
--- a/misc.h
+++ b/misc.h
@@ -35,6 +35,9 @@
#include "nvidia-installer.h"
#include "command-list.h"
+#include "alloc-utils.h"
+#include "string-utils.h"
+
/*
* NV_VSNPRINTF() - takes a fmt string, and uses vsnprintf to build
* the resulting string whic it assigns to buf. The caller of this
@@ -68,25 +71,6 @@ do { \
} \
} while (0)
-/*
- * NV_STRCAT() - takes a dynamically allocated string followed by a
- * NULL-terminated list of arbitrary strings and concatenates the
- * strings with nvstrcat(); the newly allocated string replaces the
- * original one, which is freed.
- */
-#define NV_STRCAT(str, args...) \
-do { \
- char *__tmp_str = (str); \
- (str) = nvstrcat(__tmp_str, ##args); \
- nvfree(__tmp_str); \
-} while (0)
-
-void *nvalloc(size_t size);
-void *nvrealloc(void *ptr, size_t size);
-char *nvstrdup(const char *s);
-void nvfree(char *s);
-char *nvstrtolower(char *s);
-char *nvstrcat(const char *str, ...);
char *read_next_word (char *buf, char **e);
int check_euid(Options *op);
@@ -121,8 +105,4 @@ int check_for_nvidia_graphics_devices(Options *op, Package *p);
int run_nvidia_xconfig(Options *op);
int run_distro_hook(Options *op, const char *hook);
-TextRows *nv_format_text_rows(const char *prefix, const char *buf,
- int width, int word_boundary);
-void nv_free_text_rows(TextRows *t);
-
#endif /* __NVIDIA_INSTALLER_MISC_H__ */
diff --git a/nvidia-installer.c b/nvidia-installer.c
index 4e91c16..ecd7c39 100644
--- a/nvidia-installer.c
+++ b/nvidia-installer.c
@@ -22,7 +22,7 @@
* Boston, MA 02111-1307, USA
*
*
- * nv_installer.c
+ * nvidia-installer.c
*/
@@ -47,18 +47,15 @@
#include "user-interface.h"
#include "backup.h"
#include "files.h"
+#include "help-args.h"
#include "misc.h"
#include "update.h"
#include "format.h"
#include "sanity.h"
#include "option_table.h"
-#define TAB " "
-#define BIGTAB " "
-
static void print_version(void);
static void print_help(int advanced);
-static void print_help_args_only(int args_only, int advanced);
@@ -84,35 +81,6 @@ static void print_version(void)
/*
- * cook_description() - the description string may contain text within
- * brackets, which is used by the manpage generator to denote text to
- * be italicized. We want to omit the bracket characters here.
- */
-
-static char *cook_description(const char *description)
-{
- int len;
- char *s, *dst;
- const char *src;
-
- len = strlen(description);
- s = nvalloc(len + 1);
-
- for (src = description, dst = s; *src; src++) {
- if (*src != '[' && (*src != ']')) {
- *dst = *src;
- dst++;
- }
- }
-
- *dst = '\0';
-
- return s;
-
-} /* cook_description() */
-
-
-/*
* print_help() - print usage information
*/
@@ -129,61 +97,6 @@ static void print_help(int advanced)
} /* print_help() */
-static void print_help_args_only(int args_only, int advanced)
-{
- int i, j, len;
- char *msg, *tmp, scratch[64];
- const NVOption *o;
- /*
- * the args_only parameter is used by makeself.sh to get our
- * argument list and description; in this case we don't want to
- * format to the width of the terminal, so hardcode the width to
- * 65.
- */
-
- if (args_only) reset_current_terminal_width(65);
-
- for (i = 0; __options[i].name; i++) {
- o = &__options[i];
-
- /*
- * if non-advanced help is requested, and the ALWAYS flag is
- * not set, then skip this option
- */
-
- if (!advanced && !(o->flags & OPTION_HELP_ALWAYS)) continue;
-
- /* Skip options with no help text */
- if (!o->description) continue;
-
- if (o->flags & NVOPT_IS_BOOLEAN) {
- msg = nvstrcat("--", o->name, "/--no-", o->name, NULL);
- } else if (isalnum(o->val)) {
- sprintf(scratch, "%c", o->val);
- msg = nvstrcat("-", scratch, ", --", o->name, NULL);
- } else {
- msg = nvstrcat("--", o->name, NULL);
- }
- if (o->flags & NVOPT_HAS_ARGUMENT) {
- len = strlen(o->name);
- for (j = 0; j < len; j++) scratch[j] = toupper(o->name[j]);
- scratch[len] = '\0';
- tmp = nvstrcat(msg, "=", scratch, NULL);
- nvfree(msg);
- msg = tmp;
- }
- fmtoutp(TAB, msg);
- if (o->description) {
- tmp = cook_description(o->description);
- fmtoutp(BIGTAB, tmp);
- free(tmp);
- }
- fmtout("");
- nvfree(msg);
- }
-} /* print_help_args_only() */
-
-
/*
* parse_commandline() - malloc an Options structure, initialize it,
* and fill in any pertinent data from the commandline arguments; it
diff --git a/nvidia-installer.h b/nvidia-installer.h
index 046ea62..c90e785 100644
--- a/nvidia-installer.h
+++ b/nvidia-installer.h
@@ -22,7 +22,7 @@
* Boston, MA 02111-1307, USA
*
*
- * nv_installer.h
+ * nvidia-installer.h
*/
#ifndef __NVIDIA_INSTALLER_H__
@@ -365,11 +365,15 @@ typedef struct {
FILE_TYPE_XMODULE_NEWSYM | \
FILE_TYPE_MANPAGE | \
FILE_TYPE_OPENGL_HEADER | \
+ FILE_TYPE_CUDA_LIB | \
+ FILE_TYPE_CUDA_SYMLINK | \
FILE_TYPE_CUDA_HEADER | \
FILE_TYPE_TLS_LIB | \
FILE_TYPE_TLS_SYMLINK | \
FILE_TYPE_DOT_DESKTOP | \
FILE_TYPE_DOCUMENTATION | \
+ FILE_TYPE_VDPAU_SYMLINK | \
+ FILE_TYPE_VDPAU_LIB | \
FILE_TYPE_VDPAU_HEADER)
#define FILE_TYPE_HAVE_ARCH (FILE_TYPE_OPENGL_LIB | \
@@ -501,6 +505,8 @@ typedef struct {
#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 */
diff --git a/public.mk b/public.mk
index 250d079..4a905b8 100644
--- a/public.mk
+++ b/public.mk
@@ -51,6 +51,7 @@ PCI_LDFLAGS ?=
NVIDIA_INSTALLER = $(OUTPUTDIR)/nvidia-installer
MKPRECOMPILED = $(OUTPUTDIR)/mkprecompiled
+MAKESELF_HELP_SCRIPT = $(OUTPUTDIR)/makeself-help-script
NVIDIA_INSTALLER_PROGRAM_NAME = "nvidia-installer"
@@ -114,6 +115,18 @@ LDFLAGS += -L. -ldl
MKPRECOMPILED_SRC = crc.c mkprecompiled.c
MKPRECOMPILED_OBJS = $(call BUILD_OBJECT_LIST,$(MKPRECOMPILED_SRC))
+MAKESELF_HELP_SCRIPT_SRC = makeself-help-script.c \
+ help-args.c \
+ format.c \
+ string-utils.c \
+ alloc-utils.c
+
+BUILD_MAKESELF_OBJECT_LIST = \
+ $(patsubst %.o,%.makeself.o,$(call BUILD_OBJECT_LIST,$(1)))
+
+MAKESELF_HELP_SCRIPT_OBJS = \
+ $(call BUILD_MAKESELF_OBJECT_LIST,$(MAKESELF_HELP_SCRIPT_SRC))
+
ALL_SRC = $(sort $(INSTALLER_SRC) $(NCURSES_UI_C) $(MKPRECOMPILED_SRC))
# define a quiet rule for GEN-UI-ARRAY
@@ -125,11 +138,12 @@ quiet_GEN_UI_ARRAY = GEN-UI-ARRAY $@
##############################################################################
.PNONY: all install NVIDIA_INSTALLER_install MKPRECOMPILED_install \
- MANPAGE_install clean clobber
+ MANPAGE_install MAKESELF_HELP_SCRIPT_install clean clobber
-all: $(NVIDIA_INSTALLER) $(MKPRECOMPILED) $(MANPAGE)
+all: $(NVIDIA_INSTALLER) $(MKPRECOMPILED) $(MAKESELF_HELP_SCRIPT) $(MANPAGE)
-install: NVIDIA_INSTALLER_install MKPRECOMPILED_install MANPAGE_install
+install: NVIDIA_INSTALLER_install MKPRECOMPILED_install MANPAGE_install \
+ MAKESELF_HELP_SCRIPT_install
NVIDIA_INSTALLER_install: $(NVIDIA_INSTALLER)
$(MKDIR) $(bindir)
@@ -139,19 +153,29 @@ MKPRECOMPILED_install: $(MKPRECOMPILED)
$(MKDIR) $(bindir)
$(INSTALL) $(INSTALL_BIN_ARGS) $< $(bindir)/$(notdir $<)
+MAKESELF_HELP_SCRIPT_install: $(MAKESELF_HELP_SCRIPT)
+ $(MKDIR) $(bindir)
+ $(INSTALL) $(INSTALL_BIN_ARGS) $< $(bindir)/$(notdir $<)
+
MANPAGE_install: $(MANPAGE)
$(MKDIR) $(mandir)
$(INSTALL) $(INSTALL_DOC_ARGS) $< $(mandir)/$(notdir $<)
$(MKPRECOMPILED): $(MKPRECOMPILED_OBJS)
$(call quiet_cmd,LINK) -o $@ \
- $(MKPRECOMPILED_OBJS) $(CFLAGS) $(LDFLAGS) $(BIN_LDFLAGS) && \
- $(STRIP) $@
+ $(MKPRECOMPILED_OBJS) $(CFLAGS) $(LDFLAGS) $(BIN_LDFLAGS)
+ $(STRIP_CMD) $@
+
+$(MAKESELF_HELP_SCRIPT): $(MAKESELF_HELP_SCRIPT_OBJS)
+ $(call quiet_cmd,HOST_LINK) -o $@ \
+ $(MAKESELF_HELP_SCRIPT_OBJS) $(HOST_CFLAGS) $(HOST_LDFLAGS) \
+ $(HOST_BIN_LDFLAGS)
+ $(STRIP_CMD) $@
$(NVIDIA_INSTALLER): $(INSTALLER_OBJS)
$(call quiet_cmd,LINK) -o $@ $(INSTALLER_OBJS) $(CFLAGS) $(LDFLAGS) \
- -Bstatic $(PCI_LDFLAGS) -lpci -Bdynamic $(BIN_LDFLAGS) && \
- $(STRIP) $@
+ -Bstatic $(PCI_LDFLAGS) -lpci -Bdynamic $(BIN_LDFLAGS)
+ $(STRIP_CMD) $@
$(GEN_UI_ARRAY): gen-ui-array.c $(CONFIG_H)
$(call quiet_cmd,HOST_CC) -o $@ $< $(HOST_CFLAGS) $(HOST_LDFLAGS) \
@@ -194,6 +218,11 @@ $(call BUILD_OBJECT_LIST,ncurses-ui.c): CFLAGS += $(NCURSES_CFLAGS) -fPIC
# define the rule to build each object file
$(foreach src,$(ALL_SRC),$(eval $(call DEFINE_OBJECT_RULE,CC,$(src))))
+# define a rule to build each makeself-help-script object file
+$(foreach src,$(MAKESELF_HELP_SCRIPT_SRC),\
+ $(eval $(call DEFINE_OBJECT_RULE_WITH_OBJECT_NAME,HOST_CC,$(src),\
+ $(call BUILD_MAKESELF_OBJECT_LIST,$(src)))))
+
# define the rule to generate $(STAMP_C)
$(eval $(call DEFINE_STAMP_C_RULE, $(INSTALLER_OBJS), $(NVIDIA_INSTALLER_PROGRAM_NAME)))
@@ -208,6 +237,7 @@ $(CONFIG_H):
@ $(ECHO) "\"$(NVIDIA_INSTALLER_PROGRAM_NAME)\"" >> $@
$(call BUILD_OBJECT_LIST,$(ALL_SRC)): $(CONFIG_H)
+$(call BUILD_MAKESELF_OBJECT_LIST,$(MAKESELF_HELP_SCRIPT_SRC)): $(CONFIG_H)
clean clobber:
rm -rf $(OUTPUTDIR)
diff --git a/string-utils.c b/string-utils.c
new file mode 100644
index 0000000..01ddebc
--- /dev/null
+++ b/string-utils.c
@@ -0,0 +1,122 @@
+/*
+ * 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 of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * 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, write to the:
+ *
+ * Free Software Foundation, Inc.
+ * 59 Temple Place - Suite 330
+ * Boston, MA 02111-1307, USA
+ *
+ *
+ * string-utils.c: this file contains various helper function used for
+ * string manipulation in nvidia-installer.
+ */
+
+#include <ctype.h>
+#include <string.h>
+#include <errno.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "string-utils.h"
+#include "alloc-utils.h"
+
+/*
+ * nvstrdup() - wrapper for strdup() that checks the return
+ * value; if an error occurs, an error is printed to
+ * stderr and exit is called. This function will only return
+ * on success.
+ */
+
+char *nvstrdup(const char *s)
+{
+ char *m;
+
+ if (!s) return NULL;
+
+ m = strdup(s);
+
+ if (!m) {
+ fprintf(stderr, "%s: memory allocation failure during strdup (%s)! \n",
+ PROGRAM_NAME, strerror(errno));
+ exit(1);
+ }
+ return m;
+
+} /* nvstrdup() */
+
+
+
+/*
+ * nvstrtolower() - convert the given string to lowercase.
+ */
+
+char *nvstrtolower(char *s)
+{
+ char *start = s;
+
+ if (s == NULL) return NULL;
+
+ while (*s) {
+ *s = tolower(*s);
+ s++;
+ }
+
+ return start;
+
+} /* nvstrtolower() */
+
+
+
+/*
+ * nvstrcat() - allocate a new string, copying all given strings
+ * into it. taken from glib
+ */
+
+char *nvstrcat(const char *str, ...)
+{
+ unsigned int l;
+ va_list args;
+ char *s;
+ char *concat;
+
+ l = 1 + strlen(str);
+ va_start(args, str);
+ s = va_arg(args, char *);
+
+ while (s) {
+ l += strlen(s);
+ s = va_arg(args, char *);
+ }
+ va_end(args);
+
+ concat = nvalloc(l);
+ concat[0] = 0;
+
+ strcat(concat, str);
+ va_start(args, str);
+ s = va_arg(args, char *);
+ while (s) {
+ strcat(concat, s);
+ s = va_arg(args, char *);
+ }
+ va_end(args);
+
+ return concat;
+
+} /* nvstrcat() */
diff --git a/string-utils.h b/string-utils.h
new file mode 100644
index 0000000..1dcf500
--- /dev/null
+++ b/string-utils.h
@@ -0,0 +1,48 @@
+/*
+ * 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 of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * 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, write to the:
+ *
+ * Free Software Foundation, Inc.
+ * 59 Temple Place - Suite 330
+ * Boston, MA 02111-1307, USA
+ *
+ *
+ * string-utils.h
+ */
+
+#ifndef __STRING_UTILS_H__
+#define __STRING_UTILS_H__
+
+/*
+ * NV_STRCAT() - takes a dynamically allocated string followed by a
+ * NULL-terminated list of arbitrary strings and concatenates the
+ * strings with nvstrcat(); the newly allocated string replaces the
+ * original one, which is freed.
+ */
+#define NV_STRCAT(str, args...) \
+do { \
+ char *__tmp_str = (str); \
+ (str) = nvstrcat(__tmp_str, ##args); \
+ nvfree(__tmp_str); \
+} while (0)
+
+char *nvstrdup(const char *s);
+char *nvstrtolower(char *s);
+char *nvstrcat(const char *str, ...);
+
+#endif /* __STRING_UTILS_H__ */
diff --git a/user-interface.c b/user-interface.c
index c9910fa..a8d3042 100644
--- a/user-interface.c
+++ b/user-interface.c
@@ -41,6 +41,7 @@
#include "nvidia-installer.h"
#include "nvidia-installer-ui.h"
#include "misc.h"
+#include "format.h"
#include "files.h"