home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2006 November (DVD) / PCWELT_11_2006.ISO / casper / filesystem.squashfs / var / lib / dpkg / info / alsa-base.postinst < prev    next >
Encoding:
Text File  |  2006-08-29  |  4.1 KB  |  151 lines

  1. #!/bin/sh
  2.  
  3. set -e
  4.  
  5. MYNAME="$0"
  6.  
  7. # $* message
  8. warn() { echo "${MYNAME}: Warning: $*" >&2 ; }
  9.  
  10. # $* message
  11. report_error() { echo "${MYNAME}: Error: $*" >&2 ; }
  12.  
  13. # Move a conffile without triggering a dpkg question
  14. mv_conffile() {
  15.     OLDCONFFILE="$1"
  16.     NEWCONFFILE="$2"
  17.  
  18.     if [ -e "$OLDCONFFILE" ]; then
  19.         echo "Preserving user changes to $NEWCONFFILE"
  20.         mv -f "$NEWCONFFILE" "$NEWCONFFILE".dpkg-new
  21.         mv -f "$OLDCONFFILE" "$NEWCONFFILE"
  22.     elif [ -e "$OLDCONFFILE".dpkg-bak ]; then
  23.         rm -f "$OLDCONFFILE".dpkg-bak
  24.     fi
  25. }
  26.  
  27. devfs_is_active()
  28. {
  29.     test -e /dev/.devfsd
  30. }
  31.  
  32. kernel_is_2_6_or_above()
  33. {
  34.     case "$(uname -r)" in
  35.         1.*|2.[012345]*) return 1 ;;
  36.         *) return 0 ;;
  37.     esac
  38. }
  39.  
  40. udev_is_active()
  41. {
  42.     test -e /dev/.udev.tdb || test -d /dev/.udevdb || return 1
  43.     kernel_is_2_6_or_above || return 1
  44.     return 0
  45. }
  46.  
  47. case "$1" in
  48. configure|reconfigure)
  49.     if dpkg --compare-versions "$2" lt "1.0.10-4ubuntu2"; then
  50.         mv_conffile /etc/modprobe.d/alsa-base-blacklist \
  51.             /etc/modprobe.d/blacklist-modem
  52.  
  53.         rmdir /etc/alsa/modprobe-post-install.d 2>/dev/null || true
  54.         
  55.         rm -f /etc/discover.d/alsa-base
  56.         rmdir /etc/discover.d 2>/dev/null || true
  57.  
  58.         rm -f /etc/hotplug/blacklist.d/alsa-base
  59.         rmdir /etc/hotplug/blacklist.d 2>/dev/null || true
  60.  
  61.         rm -f /etc/modutils/alsa-base
  62.         rmdir /etc/modutils 2>/dev/null || true
  63.  
  64.         rm -f /etc/init.d/alsa
  65.     fi
  66.  
  67.     # Remove old obsolete configuration files
  68.     # (Keep this until etch)
  69.     if [ -d /etc/sound ]; then 
  70.         rmdir /etc/sound 2> /dev/null || :
  71.     fi
  72.     rm -f \
  73.         /etc/apm/event.d/alsa \
  74.         /etc/apm/event.d/alsa.dpkg-old \
  75.         /etc/default/alsa.debconf-backup \
  76.         /etc/devfs/conf.d/alsa \
  77.         /etc/discover.conf.d/10alsa \
  78.         /etc/discover.conf.d/10alsa.dpkg-old \
  79.         /etc/alsa/alsa-base.conf \
  80.         /etc/alsa/modutils/0.5 \
  81.         /etc/alsa/modutils/0.9 \
  82.         /etc/alsa/modutils/1.0 \
  83.         /etc/alsa/modutils/0.5.debconf-backup \
  84.         /etc/alsa/modutils/0.9.debconf-backup \
  85.         /etc/alsa/modutils/1.0.debconf-backup \
  86.         /etc/alsa/modprobe-post-install.d/alsa-base \
  87.         /etc/alsa/modprobe-post-install.d/alsa-base.dpkg-old \
  88.         /etc/modutils/alsa \
  89.         /etc/modutils/alsa-path \
  90.         /etc/modprobe.d/alsa
  91.     # Delete hotplug blacklist backup file since hotplug doesn't ignore
  92.     # it as it should (#299205)
  93.     rm -f \
  94.         /etc/hotplug/blacklist.d/alsa-base.dpkg-old
  95.     # Delete obsolete rc symlinks to alsa init.d script
  96.     # (update-rc.d produces an unnecessary warning message on stderr (see #164471) so print the error message only if its error status is nonzero)
  97.     STDERR="$(update-rc.d -f alsa remove 2>&1 >/dev/null)" || echo "Warning: 'update-rc.d -f alsa remove' reported: '$STDERR'." >&2
  98.     
  99.     # Decide which conf file to read
  100.     conf_file=""
  101.     if [ -f /etc/default/alsa ] ; then
  102.         conf_file=/etc/default/alsa
  103.     elif [ -f /usr/share/alsa-base/alsa.default ] ; then
  104.         conf_file=/usr/share/alsa-base/alsa.default
  105.     else
  106.         report_error "No configuration file found"
  107.         exit 1
  108.     fi
  109.     # Read variables from conf file
  110.     force_unload_modules_before_suspend="$( 
  111.         . "$conf_file" >/dev/null 2>&1
  112.         echo "$force_unload_modules_before_suspend"
  113.     )"
  114.     # Write new conf file
  115.     cat /usr/share/alsa-base/alsa.default | sed \
  116.         -e "s/force_unload_modules_before_suspend=.*/force_unload_modules_before_suspend=\"${force_unload_modules_before_suspend}\"/" \
  117.         > /etc/default/alsa
  118.     # Set up apm symlinks
  119.     [ -f /etc/apm/scripts.d/alsa ] || warn "/etc/apm/scripts.d/alsa is absent"
  120.     # $1: file to check
  121.     already_linked_to_alsa()
  122.     {
  123.         [ "$1" ] || return 1
  124.         [ -L "$1" ] || return 1
  125.         [ "$(basename "$(readlink "$1")")" = alsa ] || return 1
  126.         return 0
  127.     }
  128.     ALREADY_LINKED=no
  129.     for F in /etc/apm/suspend.d/??alsa ; do
  130.         already_linked_to_alsa "$F" && ALREADY_LINKED=yes && break
  131.     done
  132.     [ "$ALREADY_LINKED" = yes ] || ln -sf ../scripts.d/alsa /etc/apm/suspend.d/80alsa
  133.     ALREADY_LINKED=no
  134.     for F in /etc/apm/resume.d/??alsa ; do
  135.         already_linked_to_alsa "$F" && ALREADY_LINKED=yes && break
  136.     done
  137.     [ "$ALREADY_LINKED" = yes ] || ln -sf ../scripts.d/alsa /etc/apm/resume.d/20alsa
  138.     ;;
  139. abort-upgrade|abort-remove|abort-deconfigure)
  140.     # We don't have to do anything because we didn't do anything in prerm
  141.     exit 0
  142.     ;;
  143. *)
  144.     echo "postinst called with unknown argument \`$1'" >&2
  145.     exit 1
  146.     ;;
  147. esac
  148.  
  149.  
  150.  
  151.