#!/bin/sh # Copyright (C) 2007-2008 Mario Limonciello # Copyright (C) 2009 Canonical Ltd # Authors: Alberto Milone set -e PACKAGE_NAME=nvidia-current CVERSION=`dpkg-query -W -f='${Version}' $PACKAGE_NAME | awk -F "-" '{print $1}' | cut -d\: -f2` INIT_SCRIPT="/etc/init/build-$PACKAGE_NAME.conf" TMP_FILE="/tmp/do_not_build_dkms_module" ARCH=`dpkg --print-architecture` case $ARCH in amd64) ARCH="x86_64" ;; lpia) ARCH="i686" ;; i386) ARCH="i686" ;; *) echo "WARNING: unsupported arch: $ARCH" ARCH="$ARCH" ;; esac # Check the existence of a kernel named as $1 _is_kernel_name_correct() { CORRECT="no" KERNEL_NAME=$1 for kernel in /boot/config-*; do KERNEL=${kernel#*-} if [ "${KERNEL}" = "${KERNEL_NAME}" ]; then CORRECT="yes" break fi done echo $CORRECT } # Get the most recent kernel on Debian based systems. This keeps # into account both the version and the ABI. If the current kernel # is the most recent kernel then the function will print a null string. _get_newest_kernel_debian() { NEWEST_KERNEL= NEWEST_VERSION= NEWEST_ABI= for kernel in /boot/config-*; do KERNEL=${kernel#*-} KERNEL_VERSION=${KERNEL%%-*} ABI=${KERNEL#*-} ABI=${ABI%%-*} if [ -z "$NEWEST_KERNEL" ]; then # The 1st time get a version which is bigger than $1 COMPARE_TO=$1 else # Get the biggest version COMPARE_TO="$NEWEST_VERSION-$NEWEST_ABI" fi # if $kernel is greater than $COMPARE_TO if [ `dpkg --compare-versions "$KERNEL_VERSION-$ABI" gt "$COMPARE_TO" && echo "yes" || \ echo "no"` = "yes" ]; then NEWEST_KERNEL=$KERNEL NEWEST_VERSION=$KERNEL_VERSION NEWEST_ABI=$ABI fi done echo "$NEWEST_KERNEL" } get_newest_kernel() { NEWEST_KERNEL= # Try Debian first as rpm can be installed in Debian based distros if [ -e /usr/bin/dpkg ]; then # If DEB based CURRENT_KERNEL=$1 CURRENT_VERSION=${CURRENT_KERNEL%%-*} CURRENT_ABI=${CURRENT_KERNEL#*-} CURRENT_FLAVOUR=${CURRENT_ABI#*-} CURRENT_ABI=${CURRENT_ABI%%-*} NEWEST_KERNEL=$(_get_newest_kernel_debian "$CURRENT_VERSION-$CURRENT_ABI") elif [ `which rpm &>/dev/null` ]; then # If RPM based NEWEST_KERNEL=$(_get_newest_kernel_rhel) fi # Make sure that kernel name that we extracted corresponds to an installed # kernel if [ -n "$NEWEST_KERNEL" ] && [ `_is_kernel_name_correct $NEWEST_KERNEL` = "no" ]; then NEWEST_KERNEL= fi echo $NEWEST_KERNEL } case "$1" in configure) # Deal with alternatives # Deal with multi-arch ugliness until dpkg supports multi-arch: # - On amd64 we need to install an additional slave link for 32bit vdpau # which - obviously - doesn't exist on i386 # - It is fine if we get the following: # + warning: skip creation of /usr/lib32/vdpau/libvdpau_nvidia.so.1 because associated # + file /usr/lib32/nvidia-current/vdpau/libvdpau_nvidia.so.1 (of link group gl_conf) doesn't exist. # update-alternatives --force \ --install /etc/ld.so.conf.d/GL.conf gl_conf /usr/lib/nvidia-current/ld.so.conf 9700 \ --slave /usr/share/man/man1/nvidia-xconfig.1.gz man_nvidiaxconfig.gz /usr/share/man/man1/alt-nvidia-current-xconfig.1.gz \ --slave /usr/share/man/man1/nvidia-smi.1.gz nvidia-smi.1.gz /usr/share/man/man1/alt-nvidia-current-smi.1.gz \ --slave /usr/share/applications/ubuntu-nvidia-settings.desktop nvidia_desktop /usr/share/nvidia-current/ubuntu-nvidia-settings.desktop \ --slave /usr/bin/nvidia-smi nvidia_smi /usr/lib/nvidia-current/bin/nvidia-smi \ --slave /usr/bin/nvidia-xconfig nvidia_xconfig /usr/lib/nvidia-current/bin/nvidia-xconfig \ --slave /usr/bin/nvidia-bug-report.sh nvidia_bug_report /usr/lib/nvidia-current/bin/nvidia-bug-report.sh \ --slave /usr/lib/XvMCConfig xvmcconfig /usr/lib/nvidia-current/XvMCConfig \ --slave /etc/xdg/autostart/nvidia-autostart.desktop nvidia-autostart.desktop /usr/share/nvidia-current/nvidia-autostart.desktop \ --slave /usr/lib/xorg/modules/drivers/nvidia_drv.so nvidia_drv /usr/lib/nvidia-current/xorg/nvidia_drv.so \ --slave /etc/modprobe.d/nvidia-graphics-drivers.conf nvidia_modconf /lib/nvidia-current/modprobe.conf \ --slave /usr/lib/xorg/extra-modules xorg_extra_modules /usr/lib/nvidia-current/xorg \ --slave /usr/lib/vdpau/libvdpau_nvidia.so.1 libvdpau_nvidia.so.1 /usr/lib/nvidia-current/vdpau/libvdpau_nvidia.so.1 \ --slave /usr/lib/libvdpau_nvidia.so libvdpau_nvidia.so /usr/lib/nvidia-current/vdpau/libvdpau_nvidia.so \ --slave /usr/lib32/vdpau/libvdpau_nvidia.so.1 libvdpau_nvidia.so.1_lib32 /usr/lib32/nvidia-current/vdpau/libvdpau_nvidia.so.1 \ --slave /usr/lib32/libvdpau_nvidia.so libvdpau_nvidia.so_lib32 /usr/lib32/nvidia-current/vdpau/libvdpau_nvidia.so # ldconfig needs to be run immediately as we're changing /etc/ld.so.conf.d/ with # alternatives. LDCONFIG_NOTRIGGER=y ldconfig # Trigger gmenu so that the icons will show up in the menu dpkg-trigger --by-package=$PACKAGE_NAME gmenucache || true CURRENT_KERNEL=$(uname -r) NEWEST_KERNEL=$(get_newest_kernel "$KERNELS") ALTERNATIVE=$(readlink /etc/alternatives/gl_conf) if [ "$ALTERNATIVE" = "/usr/lib/nvidia-current/ld.so.conf" ]; then # Update initramfs so that the blacklist ends up in the initramfs update-initramfs -u if [ -n "$NEWEST_KERNEL" ] && [ ${CURRENT_KERNEL} != ${NEWEST_KERNEL} ]; then # This can fail when dealing with a chroot see LP: #556653 update-initramfs -u -k $CURRENT_KERNEL || true fi fi # If the delayed module build feature is enabled # i.e. if $DONT_BUILD_MODULE is set to 1 # or if $TMP_FILE exists if [ "${DONT_BUILD_MODULE}1" -eq "11" ] || [ -e $TMP_FILE ]; then # Do not build the module and create # the Upstart script which will # build the module on next boot cat > $INIT_SCRIPT <&2 exit 1 ;; esac #DEBHELPER#