Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/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
- # Clean up any previous non-multi-arch alternatives
- if [ -n "$(update-alternatives --list gl_conf 2>/dev/null)" ]; then
- set -a $(update-alternatives --list gl_conf 2>/dev/null)
- while [ $# -ge 1 ] && [ "$#" != "configure" ]; do
- ALTERNATIVE=${1}
- update-alternatives --remove gl_conf $ALTERNATIVE
- shift
- done
- fi
- # 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/x86_64-linux-gnu_GL.conf x86_64-linux-gnu_gl_conf /usr/lib/nvidia-current/ld.so.conf 9700 \
- --slave /usr/share/man/man1/nvidia-xconfig.1.gz x86_64-linux-gnu_man_nvidiaxconfig.gz /usr/share/man/man1/alt-nvidia-current-xconfig.1.gz \
- --slave /usr/share/man/man1/nvidia-smi.1.gz x86_64-linux-gnu_nvidia-smi.1.gz /usr/share/man/man1/alt-nvidia-current-smi.1.gz \
- --slave /usr/share/applications/ubuntu-nvidia-settings.desktop x86_64-linux-gnu_nvidia_desktop /usr/share/nvidia-current/ubuntu-nvidia-settings.desktop \
- --slave /usr/bin/nvidia-smi x86_64-linux-gnu_nvidia_smi /usr/lib/nvidia-current/bin/nvidia-smi \
- --slave /usr/bin/nvidia-xconfig x86_64-linux-gnu_nvidia_xconfig /usr/lib/nvidia-current/bin/nvidia-xconfig \
- --slave /usr/bin/nvidia-bug-report.sh x86_64-linux-gnu_nvidia_bug_report /usr/lib/nvidia-current/bin/nvidia-bug-report.sh \
- --slave /usr/lib/XvMCConfig x86_64-linux-gnu_xvmcconfig /usr/lib/nvidia-current/XvMCConfig \
- --slave /etc/xdg/autostart/nvidia-autostart.desktop x86_64-linux-gnu_nvidia-autostart.desktop /usr/share/nvidia-current/nvidia-autostart.desktop \
- --slave /etc/OpenCL/vendors/nvidia.icd x86_64-linux-gnu_nvidia.icd /usr/share/nvidia-current/nvidia.icd \
- --slave /usr/lib/libOpenCL.so x86_64-linux-gnu_libOpenCL.so /usr/lib/nvidia-current/libOpenCL.so \
- --slave /usr/lib32/libOpenCL.so x86_64-linux-gnu_libOpenCL.so_lib32 /usr/lib32/nvidia-current/libOpenCL.so \
- --slave /usr/lib/xorg/modules/drivers/nvidia_drv.so x86_64-linux-gnu_nvidia_drv /usr/lib/nvidia-current/xorg/nvidia_drv.so \
- --slave /etc/modprobe.d/nvidia-graphics-drivers.conf x86_64-linux-gnu_nvidia_modconf /lib/nvidia-current/modprobe.conf \
- --slave /usr/lib/xorg/extra-modules x86_64-linux-gnu_xorg_extra_modules /usr/lib/nvidia-current/xorg \
- --slave /usr/lib/vdpau/libvdpau_nvidia.so.1 x86_64-linux-gnu_libvdpau_nvidia.so.1 /usr/lib/nvidia-current/vdpau/libvdpau_nvidia.so.1 \
- --slave /usr/lib/libvdpau_nvidia.so x86_64-linux-gnu_libvdpau_nvidia.so /usr/lib/nvidia-current/vdpau/libvdpau_nvidia.so \
- --slave /usr/lib32/vdpau/libvdpau_nvidia.so.1 x86_64-linux-gnu_libvdpau_nvidia.so.1_lib32 /usr/lib32/nvidia-current/vdpau/libvdpau_nvidia.so.1 \
- --slave /usr/lib32/libvdpau_nvidia.so x86_64-linux-gnu_libvdpau_nvidia.so_lib32 /usr/lib32/nvidia-current/vdpau/libvdpau_nvidia.so \
- --slave /usr/share/grub-gfxpayload-lists/blacklist/10_$PACKAGE_NAME x86_64-linux-gnu_grub_fb_blacklist /usr/share/nvidia-current/nvidia-current.grub-gfxpayload
- # Install just the ld.so.conf.d alternative for the secondary architecture.
- # We need only to ensure that any mesa ld.so.conf.d alternative isn't active.
- update-alternatives --force \
- --install /etc/ld.so.conf.d/i386-linux-gnu_GL.conf i386-linux-gnu_gl_conf /usr/lib/nvidia-current/alt_ld.so.conf 9700
- # 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/x86_64-linux-gnu_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
- # Update the grub gfxpayload blacklist
- if which update-grub-gfxpayload >/dev/null 2>&1; then
- update-grub-gfxpayload
- 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 <<EOF
- # Warning: This file is autogenerated by $PACKAGE_NAME. All changes to this file will be lost.
- start on (starting oem-config
- or starting gdm
- or starting kdm
- or starting xdm
- or starting uxlaunch)
- task
- script
- dkms add -m $PACKAGE_NAME -v $CVERSION
- /usr/lib/dkms/dkms_autoinstaller start || ( rm -f $INIT_SCRIPT && exit 1 )
- modprobe $PACKAGE_NAME || true
- rm -f $INIT_SCRIPT
- end script
- EOF
- else
- # Build the kernel module
- /usr/lib/dkms/common.postinst $PACKAGE_NAME $CVERSION /usr/share/$PACKAGE_NAME $ARCH $2
- exit $?
- fi
- ;;
- abort-upgrade|abort-remove|abort-deconfigure)
- ;;
- *)
- echo "postinst called with unknown argument \`$1'" >&2
- exit 1
- ;;
- esac
- # Automatically added by dh_makeshlibs
- if [ "$1" = "configure" ]; then
- ldconfig
- fi
- # End automatically added section
Advertisement
Add Comment
Please, Sign In to add comment