home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2006 November (DVD) / PCWELT_11_2006.ISO / casper / filesystem.squashfs / var / lib / dpkg / info / udev.preinst < prev    next >
Encoding:
Text File  |  2006-08-23  |  1.8 KB  |  74 lines

  1. #!/bin/sh -e
  2. # This script can be called in the following ways:
  3. #
  4. # Before the package is installed:
  5. #    <new-preinst> install
  6. #
  7. # Before removed package is upgraded:
  8. #    <new-preinst> install <old-version>
  9. #
  10. # Before the package is upgraded:
  11. #    <new-preinst> upgrade <old-version>
  12. #
  13. #
  14. # If postrm fails during upgrade or fails on failed upgrade:
  15. #    <old-preinst> abort-upgrade <new-version>
  16.  
  17.  
  18. # Prepare to remove a no-longer used conffile
  19. prep_rm_conffile()
  20. {
  21.     CONFFILE="$1"
  22.  
  23.     if [ -e "$CONFFILE" ]; then
  24.         md5sum="`md5sum \"$CONFFILE\" | sed -e \"s/ .*//\"`"
  25.         old_md5sum="`sed -n -e \"/^Conffiles:/,/^[^ ]/{\\\\' $CONFFILE '{s/ obsolete$//;s/.* //;p}}\" /var/lib/dpkg/status`"
  26.         if [ "$md5sum" != "$old_md5sum" ]; then
  27.             echo "Obsolete conffile $CONFFILE has been modified by you, renaming to .dpkg-bak"
  28.             mv -f "$CONFFILE" "$CONFFILE".dpkg-bak
  29.     fi
  30.     fi
  31. }
  32.  
  33. # Prepare to move a conffile without triggering a dpkg question
  34. prep_mv_conffile() {
  35.     CONFFILE="$1"
  36.  
  37.     if [ -e "$CONFFILE" ]; then
  38.         md5sum="`md5sum \"$CONFFILE\" | sed -e \"s/ .*//\"`"
  39.         old_md5sum="`sed -n -e \"/^Conffiles:/,/^[^ ]/{\\\\' $CONFFILE '{s/ obsolete$//;s/.* //;p}}\" /var/lib/dpkg/status`"
  40.         if [ "$md5sum" = "$old_md5sum" ]; then
  41.             mv -f "$CONFFILE" "$CONFFILE".dpkg-bak
  42.         fi
  43.     fi
  44. }
  45.  
  46.  
  47. # Prepare to rename the persistent-disk.rules file
  48. prep_mv_persistent_disk_rules()
  49. {
  50.     prep_mv_conffile /etc/udev/rules.d/65-persistent-disk.rules \
  51.                  /etc/udev/rules.d/65-persistent-storage.rules
  52. }
  53.  
  54.  
  55. case "$1" in
  56.     install|upgrade)
  57.     # Upgrade from dapper
  58.     if dpkg --compare-versions "$2" lt "093-0ubuntu1"; then
  59.         prep_mv_persistent_disk_rules
  60.     fi
  61.     ;;
  62.  
  63.     abort-upgrade)
  64.     ;;
  65.  
  66.     *)
  67.     echo "$0 called with unknown argument \`$1'" 1>&2
  68.     exit 1
  69.     ;;
  70. esac
  71.  
  72.  
  73. exit 0
  74.