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

  1. #!/bin/sh
  2.  
  3. # preinst script for openoffice.org-common
  4.  
  5. THIS_PACKAGE=openoffice.org-common
  6. THIS_SCRIPT=preinst
  7.  
  8. set -e
  9.  
  10. # vim:set ai et sts=2 sw=2 tw=0:
  11.  
  12. # Query the terminal to establish a default number of columns to use for
  13. # displaying messages to the user.  This is used only as a fallback in the
  14. # event the COLUMNS variable is not set.  ($COLUMNS can react to SIGWINCH while
  15. # the script is running, and this cannot, only being calculated once.)
  16. DEFCOLUMNS=$(stty size 2> /dev/null | awk '{print $2}') || true
  17. if ! expr "$DEFCOLUMNS" : "[[:digit:]]\+$" > /dev/null 2>&1; then
  18.   DEFCOLUMNS=80
  19. fi
  20.  
  21. message() {
  22.     echo "$*" | fmt -t -w ${COLUMNS:-$DEFCOLUMNS} >&2
  23. }
  24.  
  25. # Prepare to move a conffile without triggering a dpkg question
  26. prep_rm_conffile() {
  27.     CONFFILE="$1"
  28.  
  29.     if [ -e "$CONFFILE" ]; then
  30.         md5sum="`md5sum \"$CONFFILE\" | sed -e \"s/ .*//\"`"
  31.         old_md5sum="`sed -n -e \"/^Conffiles:/,/^[^ ]/{\\\\' $CONFFILE'{s/.* //;p}}\" /var/lib/dpkg/status`"
  32.         if [ "$md5sum" = "$old_md5sum" ]; then
  33.             mv "$CONFFILE" "$CONFFILE.${THIS_PACKAGE}-tmp"
  34.         fi
  35.     fi
  36. }
  37.  
  38. rm_conffile_commit() {
  39.   CONFFILE="$1"
  40.  
  41.   if [ -e $CONFFILE.${THIS_PACKAGE}-tmp ]; then
  42.     rm $CONFFILE.${THIS_PACKAGE}-tmp
  43.   fi
  44. }
  45.  
  46. # Remove a no-longer used conffile
  47. rm_conffile() {
  48.     CONFFILE="$1"
  49.  
  50.     if [ -e "$CONFFILE" ]; then
  51.         md5sum="`md5sum \"$CONFFILE\" | sed -e \"s/ .*//\"`"
  52.         old_md5sum="`sed -n -e \"/^Conffiles:/,/^[^ ]/{\\\\' $CONFFILE'{s/.* //;p}}\" /var/lib/dpkg/status`"
  53.         if [ "$md5sum" != "$old_md5sum" ]; then
  54.             echo "Obsolete conffile $CONFFILE has been modified by you."
  55.             echo "Saving as $CONFFILE.dpkg-bak ..."
  56.             mv -f "$CONFFILE" "$CONFFILE".bak
  57.         else
  58.             echo "Removing obsolete conffile $CONFFILE ..."
  59.             rm -f "$CONFFILE"
  60.         fi
  61.     fi
  62. }
  63.  
  64. trap "message;\
  65.       message \"Received signal.  Aborting script $0.\";\
  66.       message;\
  67.       exit 1" 1 2 3 15
  68.  
  69. VER=
  70.  
  71.  
  72. case "$1" in install|upgrade)
  73.     if dpkg --compare-versions "$2" lt "2.0.0-2"; then
  74.         rm_conffile "/etc/bash_completion.d/openoffice"
  75.         rm_conffile "/etc/openoffice/autoresponse.conf"
  76.         rm_conffile "/etc/openoffice/openoffice.conf"
  77.     fi
  78.     if dpkg --compare-versions "$2" lt "2.0.2-2"; then
  79.         rm_conffile "/etc/bash_completion.d/ooo-wrapper.sh"
  80.     fi
  81.     ;;
  82. esac
  83.  
  84.  
  85.  
  86. exit 0
  87.