#!/bin/sh # Copyright (C) 2007-2008 Mario Limonciello # Copyright (C) 2009 Canonical Ltd # Authors: Alberto Milone set -e PACKAGE_NAME=#DRIVERNAME# 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 #PKGVDPAUDIR32#/libvdpau_nvidia.so.1 (of link group gl_conf) doesn't exist. # update-alternatives --force \ --install #SYSCONFDIR#/ld.so.conf.d/GL.conf gl_conf #LDSOCONF# #ALTPRIORITY# \ --slave #MANDIR#/nvidia-xconfig.1.gz man_nvidiaxconfig.gz #MANDIR#/alt-#DRIVERNAME#-xconfig.1.gz \ --slave #MANDIR#/nvidia-smi.1.gz nvidia-smi.1.gz #MANDIR#/alt-#DRIVERNAME#-smi.1.gz \ --slave #DATADIR#/applications/ubuntu-nvidia-settings.desktop nvidia_desktop #PKGDESKDIR#/ubuntu-nvidia-settings.desktop \ --slave #BINDIR#/nvidia-smi nvidia_smi #PKGBINDIR#/nvidia-smi \ --slave #BINDIR#/nvidia-xconfig nvidia_xconfig #PKGBINDIR#/nvidia-xconfig \ --slave #BINDIR#/nvidia-bug-report.sh nvidia_bug_report #PKGBINDIR#/nvidia-bug-report.sh \ --slave #LIBDIR#/XvMCConfig xvmcconfig #PKGCONFIGDIR#/XvMCConfig \ --slave #AUTOSTARTDIR#/#AUTOSTARTFILE# nvidia-autostart.desktop #PKGDATADIR#/#AUTOSTARTFILE# \ --slave #LIBDIR#/xorg/modules/drivers/nvidia_drv.so nvidia_drv #PKGDRIVERSDIR#/nvidia_drv.so \ --slave #SYSCONFDIR#/modprobe.d/nvidia-graphics-drivers.conf nvidia_modconf #PKGLIBCONFDIR#/modprobe.conf \ --slave #XORGEXTRA# xorg_extra_modules #NVIDIAEXTENSION# \ --slave #VDPAUDIR#/libvdpau_nvidia.so.1 libvdpau_nvidia.so.1 #PKGVDPAUDIR#/libvdpau_nvidia.so.1 \ --slave #LIBDIR#/libvdpau_nvidia.so libvdpau_nvidia.so #PKGVDPAUDIR#/libvdpau_nvidia.so \ --slave #VDPAUDIR32#/libvdpau_nvidia.so.1 libvdpau_nvidia.so.1_lib32 #PKGVDPAUDIR32#/libvdpau_nvidia.so.1 \ --slave #LIBDIR32#/libvdpau_nvidia.so libvdpau_nvidia.so_lib32 #PKGVDPAUDIR32#/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" = "#LDSOCONF#" ]; 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#