#!/bin/sh # postinst script for nvidia-kernel-common-550 # # see: dh_installdeb(1) # # Copyright (C) 2007-2008 Mario Limonciello # Copyright (C) 2009 Canonical Ltd # Authors: Alberto Milone set -e # Check the existence of a kernel named as $1 _is_kernel_name_correct() { CORRECT="no" KERNEL_NAME=$1 for kernel in /boot/config-*; do [ -f "$kernel" ] || continue 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 [ -f "$kernel" ] || continue 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") 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) CURRENT_KERNEL=$(uname -r) NEWEST_KERNEL=$(get_newest_kernel "$CURRENT_KERNEL") # Update initramfs so that the blacklist ends up in the initramfs if [ -x /usr/sbin/update-initramfs ]; then /usr/sbin/update-initramfs -u if [ -n "$NEWEST_KERNEL" ] && [ ${CURRENT_KERNEL} != ${NEWEST_KERNEL} ]; then # This can fail when dealing with a chroot see LP: #556653 /usr/sbin/update-initramfs -u -k $CURRENT_KERNEL fi fi ;; abort-upgrade|abort-remove|abort-deconfigure) ;; *) echo "postinst called with unknown argument \`$1'" >&2 exit 1 ;; esac # Automatically added by dh_installdeb/13.14.1ubuntu5 dpkg-maintscript-helper rm_conffile /etc/modprobe.d/nvidia-graphics-drivers.conf 390.48-0ubuntu4\~ -- "$@" # End automatically added section # Automatically added by dh_installsystemd/13.14.1ubuntu5 if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then # The following line should be removed in trixie or trixie+1 deb-systemd-helper unmask 'nvidia-hibernate.service' >/dev/null || true # was-enabled defaults to true, so new installations run enable. if deb-systemd-helper --quiet was-enabled 'nvidia-hibernate.service'; then # Enables the unit on first installation, creates new # symlinks on upgrades if the unit file has changed. deb-systemd-helper enable 'nvidia-hibernate.service' >/dev/null || true else # Update the statefile to add new symlinks (if any), which need to be # cleaned up on purge. Also remove old symlinks. deb-systemd-helper update-state 'nvidia-hibernate.service' >/dev/null || true fi fi # End automatically added section # Automatically added by dh_installsystemd/13.14.1ubuntu5 if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then # The following line should be removed in trixie or trixie+1 deb-systemd-helper unmask 'nvidia-resume.service' >/dev/null || true # was-enabled defaults to true, so new installations run enable. if deb-systemd-helper --quiet was-enabled 'nvidia-resume.service'; then # Enables the unit on first installation, creates new # symlinks on upgrades if the unit file has changed. deb-systemd-helper enable 'nvidia-resume.service' >/dev/null || true else # Update the statefile to add new symlinks (if any), which need to be # cleaned up on purge. Also remove old symlinks. deb-systemd-helper update-state 'nvidia-resume.service' >/dev/null || true fi fi # End automatically added section # Automatically added by dh_installsystemd/13.14.1ubuntu5 if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then # The following line should be removed in trixie or trixie+1 deb-systemd-helper unmask 'nvidia-suspend.service' >/dev/null || true # was-enabled defaults to true, so new installations run enable. if deb-systemd-helper --quiet was-enabled 'nvidia-suspend.service'; then # Enables the unit on first installation, creates new # symlinks on upgrades if the unit file has changed. deb-systemd-helper enable 'nvidia-suspend.service' >/dev/null || true else # Update the statefile to add new symlinks (if any), which need to be # cleaned up on purge. Also remove old symlinks. deb-systemd-helper update-state 'nvidia-suspend.service' >/dev/null || true fi fi # End automatically added section