home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2007 September / PCWSEP07.iso / Software / Linux / Linux Mint 3.0 Light / LinuxMint-3.0-Light.iso / casper / filesystem.squashfs / var / lib / dpkg / info / udev.postrm < prev    next >
Encoding:
Text File  |  2007-04-10  |  3.1 KB  |  160 lines

  1. #!/bin/sh -e
  2. # This script can be called in the following ways:
  3. #
  4. # After the package was removed:
  5. #    <postrm> remove
  6. #
  7. # After the package was purged:
  8. #    <postrm> purge
  9. #
  10. # After the package was upgraded:
  11. #    <old-postrm> upgrade <new-version>
  12. # if that fails:
  13. #    <new-postrm> failed-upgrade <old-version>
  14. #
  15. #
  16. # After all of the packages files have been replaced:
  17. #    <postrm> disappear <overwriting-package> <version>
  18. #
  19. #
  20. # If preinst fails during install:
  21. #    <new-postrm> abort-install
  22. #
  23. # If preinst fails during upgrade of removed package:
  24. #    <new-postrm> abort-install <old-version>
  25. #
  26. # If preinst fails during upgrade:
  27. #    <new-postrm> abort-upgrade <old-version>
  28.  
  29.  
  30. # Undo removal of a no-longer used conffile
  31. undo_rm_conffile()
  32. {
  33.     CONFFILE="$1"
  34.  
  35.     if [ ! -e "$CONFFILE" ]; then
  36.     if [ -e "$CONFFILE".dpkg-bak ]; then
  37.         echo "Restoring modified conffile $CONFFILE"
  38.         mv -f "$CONFFILE".dpkg-bak "$CONFFILE"
  39.     elif [ -e "$CONFFILE".dpkg-obsolete ]; then
  40.         mv -f "$CONFFILE".dpkg-obsolete "$CONFFILE"
  41.     fi
  42.     fi
  43. }
  44.  
  45. # Finish removal of a no-longer used conffile
  46. finish_rm_conffile()
  47. {
  48.     CONFFILE="$1"
  49.  
  50.     if [ -e "$CONFFILE".dpkg-bak ]; then
  51.     rm -f "$CONFFILE".dpkg-bak
  52.     fi
  53. }
  54.  
  55. # Undo move of a conffile
  56. undo_mv_conffile()
  57. {
  58.     CONFFILE="$1"
  59.  
  60.     if [ ! -e "$CONFFILE" ]; then
  61.     if [ -e "$CONFFILE".dpkg-bak ]; then
  62.         mv -f "$CONFFILE".dpkg-bak "$CONFFILE"
  63.     elif [ -e "$CONFFILE".dpkg-moving ]; then
  64.         mv -f "$CONFFILE".dpkg-moving "$CONFFILE"
  65.     fi
  66.     fi
  67. }
  68.  
  69. # Finish move of a conffile
  70. finish_mv_conffile()
  71. {
  72.     CONFFILE="$1"
  73.  
  74.     if [ -e "$CONFFILE".dpkg-bak ]; then
  75.     rm -f "$CONFFILE".dpkg-bak
  76.     fi
  77. }
  78.  
  79.  
  80. # Undo rename of the persistent-disk.rules file
  81. undo_mv_persistent_disk_rules()
  82. {
  83.     undo_mv_conffile /etc/udev/rules.d/65-persistent-disk.rules
  84. }
  85.  
  86. # Finish rename of the persistent-disk.rules file
  87. finish_mv_persistent_disk_rules()
  88. {
  89.     finish_mv_conffile /etc/udev/rules.d/65-persistent-disk.rules
  90. }
  91.  
  92.  
  93. # Undo rename the cdrom_id.rules file
  94. undo_mv_cdrom_id_rules()
  95. {
  96.     undo_mv_conffile /etc/udev/rules.d/50-cdrom_id.rules \
  97.                 /etc/udev/rules.d/30-cdrom_id.rules
  98. }
  99.  
  100. # Finish rename the cdrom_id.rules file
  101. finish_mv_cdrom_id_rules()
  102. {
  103.     finish_mv_conffile /etc/udev/rules.d/50-cdrom_id.rules \
  104.                    /etc/udev/rules.d/30-cdrom_id.rules
  105. }
  106.  
  107.  
  108.  
  109. # Remove configuration and log files
  110. purge_files()
  111. {
  112.     if [ -f /etc/iftab ]; then
  113.     rm -f /etc/iftab || true
  114.     fi
  115.  
  116.     if [ -f /var/log/udev ]; then
  117.     rm -f /var/log/udev || true
  118.     fi
  119. }
  120.  
  121.  
  122. case "$1" in
  123.     remove)
  124.     ;;
  125.  
  126.     purge)
  127.         finish_mv_persistent_disk_rules
  128.     finish_mv_cdrom_id_rules
  129.     purge_files
  130.     ;;
  131.  
  132.     upgrade|failed-upgrade|disappear)
  133.     ;;
  134.  
  135.     abort-install|abort-upgrade)
  136.     # Abort upgrade from dapper
  137.     if dpkg --compare-versions "$2" lt "093-0ubuntu1"; then
  138.         undo_mv_persistent_disk_rules
  139.     fi
  140.  
  141.     # Abort upgrade within feisty development cycle
  142.     if dpkg --compare-versions "$2" lt "108-0ubuntu1"; then
  143.         mv_cdrom_id_rules
  144.     fi
  145.     ;;
  146.  
  147.     *)
  148.     echo "$0 called with unknown argument \`$1'" 1>&2
  149.     exit 1
  150.     ;;
  151. esac
  152.  
  153. # Automatically added by dh_installinit
  154. if [ "$1" = "purge" ] ; then
  155.     update-rc.d udev remove >/dev/null || exit $?
  156. fi
  157. # End automatically added section
  158.  
  159. exit 0
  160.