diff options
author | Christian Rößler | 2014-02-18 18:13:53 +0100 |
---|---|---|
committer | Christian Rößler | 2014-02-18 18:13:53 +0100 |
commit | c6a33c3da72715b5a6ea8ca722c0462bdd6d8290 (patch) | |
tree | ee210ff0b276e838911371379f44eb78ad3c8fb4 /data | |
parent | [kernel] Added 'make prepare' and 'make scripts' for eg. nvidia compilation (diff) | |
download | tm-scripts-c6a33c3da72715b5a6ea8ca722c0462bdd6d8290.tar.gz tm-scripts-c6a33c3da72715b5a6ea8ca722c0462bdd6d8290.tar.xz tm-scripts-c6a33c3da72715b5a6ea8ca722c0462bdd6d8290.zip |
nvidia driver extraction: First working script, perhaps useful for someone. Use with care.
Diffstat (limited to 'data')
-rwxr-xr-x | data/nvidia-driver-extraction-experiments.sh | 179 |
1 files changed, 118 insertions, 61 deletions
diff --git a/data/nvidia-driver-extraction-experiments.sh b/data/nvidia-driver-extraction-experiments.sh index edc06424..85617f04 100755 --- a/data/nvidia-driver-extraction-experiments.sh +++ b/data/nvidia-driver-extraction-experiments.sh @@ -1,66 +1,123 @@ #!/bin/bash -ROOT_DIR="$HOME" - -. "/root/tm-scripts/helper/logging.inc" || exit 1 - -# XXX: Mounts stuff from my NFS.... -[ ! -d /mnt/store ] && mkdir -p /mnt/store -if [ "x$(ls /mnt/store/drivers)" == "x" ]; then - mount -t nfs -o ro,async,nolock 132.230.8.113:/srv/vmext /mnt/store || perror "Could not mount vmware bundle directory. Exiting." -fi - -# There is no generic "--root-prefix=" option, so we have to pass a shitload of arguments, and even then the installer -# does some stuff in your actual system tree... :-( better do some sort of chroot? -function gogo() -{ - - local DIR="$ROOT_DIR/build" - mkdir -p "$DIR" || perror "Couldn ot create $DIR" - - local XPREFIX="/usr" - - set -x - - local XLP="$(X -showDefaultLibPath 2>&1)" - [ -z "$XLP" ] && XLP="$(pkg-config --variable=libdir xorg-server 2>&1)" - [ -z "$XLP" ] && XLP="$XPREFIX" - [ -z "$XLP" ] && perror "Could not determine X lib path" - - local XMP="$(X -showDefaultModulePath 2>&1)" - [ -z "$XMP" ] && XMP="$(pkg-config --variable=moduledir xorg-server 2>&1)" - [ -z "$XMP" ] && XMP="$XLP" - [ -z "$XMP" ] && perror "Could not determine X module path" - - cd /mnt/store/drivers || perror "No /mnt/store/drivers" - set -x - # TODO: Insert proper kernel name and path from our own kernel <----- XXX - ./NVIDIA-Linux-x86-319.23.run -a --x-prefix="$DIR/$XPREFIX" --x-module-path="$DIR/$XMP" --x-library-path="$DIR/$XLP" --opengl-prefix="$DIR/usr" --utility-prefix="$DIR/usr" --documentation-prefix="$DIR/garbage" --application-profile-path="$DIR/usr/share/nvidia" --kernel-source-path="/root/tm-scripts/remote/modules/kernel/ksrc" --kernel-install-path="$DIR/lib/modules/nvidia" --log-file-name="$DIR/install-log" --ui=none --no-nvidia-modprobe --kernel-name="3.7.10-1.11-desktop-openslx" --no-precompiled-interface --no-rpms --no-network --no-x-check --no-nouveau-check --no-distro-scripts --kernel-module-source-prefix="$DIR/usr/src" --no-questions - set +x +# This is the first working nvidia extractor. +BASEDIR=/root/temp/ +TMSCRIPTS=/root/tm-scripts/ +MODULE_DIR="$TMSCRIPTS/remote/modules/kernel/" +KERNELSRCDIR="$MODULE_DIR/ksrc" +ROOTLOWERDIR="/" +ROOTUPPERDIR="$BASEDIR/rootupper" +ROOTBINDDIR="$BASEDIR/rootbind" +ROOTMOUNTDIR="$BASEDIR/rootmount" +BINDMOUNTS="/dev /proc /run /sys" + +NVIDIA="$BASEDIR/NVIDIA-Linux-x86_64-331.38.run" +NVIDIAEXTRACTDIR="$ROOTMOUNTDIR/NVIDIA" +NVEXTRACTDIR="/NVIDIA" # this one relative to chroot" +STARTDM="false" + + +# This is just an experiment to look whether the annoying message "could not insert kernel module" +# by the nvidia installer when compiling on a computer lacking a nvidia gpu card could be killed. +# It does not work, as the nvidia-installer uses a self-brewed module loader. +dump_modprobe () { + [ -d "$ROOTMOUNTDIR/sbin" ] || mkdir "$ROOTMOUNTDIR/sbin" + for FILE in insmod modprobe; do + cat>"$ROOTMOUNTDIR/sbin/$FILE"<<-EOF + #/bin/sh + exit 0 + EOF + chmod +x "$ROOTMOUNTDIR/sbin/$FILE" + done +} + +stop_display_managers () { + for DM in kdm gdm lightdm; do + ps a|grep -v grep|grep "$DM" + ERR=$? + if [ "$ERR" -eq 0 ]; then + /etc/init.d/"$DM" stop + killall "$DM" # line above leaves a residue sometimes... + STARTDM="$DM" + echo "Stopped $DM." + break + fi + done +} + +# Several directories for bind mount and overlay mounts. +make_dirs () { + mkdir "$ROOTUPPERDIR" + mkdir "$ROOTBINDDIR" + mkdir "$ROOTMOUNTDIR" +} + +mount_dirs () { + mount -o bind "$ROOTLOWERDIR" "$ROOTBINDDIR" + mount -o remount,ro "$ROOTBINDDIR" + mount -t overlayfs overlayfs -o lowerdir="$ROOTBINDDIR",upperdir="$ROOTUPPERDIR" "$ROOTMOUNTDIR" + for MOUNT in $BINDMOUNTS; do + echo "Erzeuge bind-mount $MOUNT ..." + mount -o bind "$MOUNT" "$ROOTMOUNTDIR/$MOUNT" || echo "Bind mount auf $MOUNT schlug fehl." + done +} + +# We inject a bashrc to be executed within the chroot. +gen_bashrc () { + echo "chroot erfolgreich." + COMMON_OPTIONS=' --no-nouveau-check --no-network --no-backup --no-rpms --no-runlevel-check --no-distro-scripts --no-cc-version-check --no-x-check --no-precompiled-interface --silent ' + cat >"$ROOTMOUNTDIR/$HOME/.bashrc"<<-EOF + alias ll='ls -alF' + PS1='\[\e[1;33m\]chroot@\h:\w\$ \[\e[1;32m\]' + cd "$NVEXTRACTDIR" + echo "First pass... compiling kernel module." + ./nvidia-installer $COMMON_OPTIONS --kernel-source-path /"$KERNELSRCDIR" # compiles .ko, but not always the rest. + echo "Second pass... compiling everything else." + ./nvidia-installer $COMMON_OPTIONS --no-kernel-module # compiles the rest - hopefully. + exit +EOF +} + +unpack_nvidia () { + [ -d "$NVIDIAEXTRACTDIR" ] && rm -rf "$NVIDIAEXTRACTDIR" + echo "Entpacke $NVIDIA ..." + sh "$NVIDIA" --extract-only --target "$NVIDIAEXTRACTDIR" } -gogo - -# --no-questions -# -a -# --x-prefix= ..../usr -# --x-module-path= ... + X -showDefaultModulePath -# --x-library-path= ... + X -showDefaultLibPath (oder --x-prefix) -# --opengl-prefix= .../usr -# --utility-prefix= ..../usr -# --documentation-prefix= müll -# --application-profile-path= ??? /usr/share/nvidia -# --kernel-source-path= unser kack -# --kernel-install-path= .../lib/modules/nvidia -# --log-file-name= -# --ui=none -# --no-nvidia-modprobe -# --kernel-name=UNSERKERNEL -# --no-precompiled-interface -# --no-rpms -# --no-network -# --no-x-check -# --no-nouveau-check -# --no-distro-scripts -# --kernel-module-source-prefix= ..../usr/src +umount_dirs () { + for MOUNT in $BINDMOUNTS; do + umount "$ROOTMOUNTDIR/$MOUNT" + done + umount "$ROOTMOUNTDIR" + umount "$ROOTBINDDIR" +} + +start_display_manager () { + [ "$STARTDM" != "false" ] && echo /etc/init.d/"$DM" start +} + + +# stop_display_managers + +make_dirs +echo "Mounte Verzeichnisse ..." +mount_dirs + +echo "Lege .bashrc ab ..." +gen_bashrc + +echo "Entpacke NVidia-Installer ..." +unpack_nvidia + +echo "Dumpe modprobe / insmod ..." +# dump_modprobe + +echo "Fertig für chroot." +chroot "$ROOTMOUNTDIR" +echo "chroot durch." + +echo "Unmounte Verzeichnisse." +umount_dirs + +# start_display_manager |