home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2008 February / MAC_easy_02_08.iso / Software / Top-Ten-Programme / NeoOffice-2.2.3-Intel.dmg / NeoOffice-2.2.3-Intel.pkg / Contents / Resources / postflight < prev    next >
Encoding:
Text File  |  2008-03-14  |  8.2 KB  |  237 lines

  1. #!/bin/bash -x
  2. ##########################################################################
  3. #   $RCSfile: postflight,v $
  4. #   $Revision: 1.60 $
  5. #   last change: $Author: pluby $ $Date: 2008/02/08 21:47:15 $
  6. #   The Contents of this file are made available subject to the terms of
  7. #   either of the following licenses
  8. #         - GNU General Public License Version 2.1
  9. #   Patrick Luby, June 2003
  10. #   GNU General Public License Version 2.1
  11. #   =============================================
  12. #   Copyright 2003 Planamesa Inc.
  13. #   This library is free software; you can redistribute it and/or
  14. #   modify it under the terms of the GNU General Public
  15. #   License version 2.1, as published by the Free Software Foundation.
  16. #   This library is distributed in the hope that it will be useful,
  17. #   but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. #   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  19. #   General Public License for more details.
  20. #   You should have received a copy of the GNU General Public
  21. #   License along with this library; if not, write to the Free Software
  22. #   Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  23. #   MA  02111-1307  USA
  24. ##########################################################################
  25.  
  26. PATH=/bin:/sbin:/usr/bin:/usr/sbin
  27. export PATH
  28.  
  29. umask 022
  30.  
  31. mdimporter_id="org.neooffice.neolight.NeoOffice-2.2.3-Intel"
  32. qlplugin_id="org.neooffice.quicklookplugin.NeoOffice-2.2.3-Intel"
  33.  
  34. if [ -d "$2" ]; then
  35.  
  36.     # Fix Apple installer bug described in bug 1373
  37.     if [ "$2" = "/" -o "$2" = "$3" -o `cd "$2" ; pwd` = "/" -o `cd "$2" ; pwd` = "$3" -o "$INSTALLER_TEMP" = "/" -o "$INSTALLER_TEMP" = "$3" -o `cd "$INSTALLER_TEMP" ; pwd` = "/" -o `cd "$INSTALLER_TEMP" ; pwd` = "$3" ]; then
  38.         exit 1;
  39.     fi
  40.  
  41.     # Fix bug 2711 by updating plugin bundle IDs
  42.     mdimporter_file="$2/Contents/Library/Spotlight/neolight.mdimporter/Contents/Info.plist"
  43.     rm -f "$mdimporter_file.tmp"
  44.     if [ ! -z "$mdimporter_id" -a -f "$mdimporter_file" ] ; then
  45.         sed "s#$mdimporter_id#$mdimporter_id.`date '+%Y%m%d%H%M%S'`#g" "$mdimporter_file" > "$mdimporter_file.tmp"
  46.         if [ -s "$mdimporter_file.tmp" ] ; then
  47.             mv -f "$mdimporter_file.tmp" "$mdimporter_file"
  48.             chmod -f 444 "$mdimporter_file"
  49.         fi
  50.         rm -f "$mdimporter_file.tmp"
  51.     fi
  52.  
  53.     qlplugin_file="$2/Contents/Library/QuickLook/neopeek.qlgenerator/Contents/Info.plist"
  54.     rm -f "$qlplugin_file.tmp"
  55.     if [ ! -z "$qlplugin_id" -a -f "$qlplugin_file" ] ; then
  56.         sed "s#$qlplugin_id#$qlplugin_id.`date '+%Y%m%d%H%M%S'`#g" "$qlplugin_file" > "$qlplugin_file.tmp"
  57.         if [ -s "$qlplugin_file.tmp" ] ; then
  58.             mv -f "$qlplugin_file.tmp" "$qlplugin_file"
  59.             chmod -f 444 "$qlplugin_file"
  60.         fi
  61.         rm -f "$qlplugin_file.tmp"
  62.     fi
  63.  
  64.     tempfile="$INSTALLER_TEMP/out"
  65.     touch "$tempfile" || exit 1
  66.  
  67.     # Put back user's custom dictionary files
  68.     if [ -d "$2/ooo" ]; then
  69.         for i in `cd "$2/ooo" ; find . -name "*.aff" -o -name "*.dat" -o -name "*.dic" -o -name "*.idx" -maxdepth 1`; do
  70.             if [ ! -e "$2/Contents/share/dict/ooo/$i" ]; then
  71.                 mv -f "$2/ooo/$i" "$2/Contents/share/dict/ooo" || exit 1
  72.                 if [ -e "$2/ooo/dictionary.lst" ]; then
  73.                     base=`basename "$i" | awk -F. '{ print $1 }'`
  74.                     grep -E '[^][#:space:]*(DICT|HYPH|THES)[[:space:]]*[[:alpha:]]*[[:space:]]*[[:alpha:]]*[[:space:]]*'"$base"'[[:space:]]*$' "$2/ooo/dictionary.lst" >> "$tempfile"
  75.                 fi
  76.             fi
  77.         done
  78.         if [ -s "$tempfile" ]; then
  79.             sort -u "$tempfile" >> "$2/Contents/share/dict/ooo/dictionary.lst"
  80.         fi
  81.         chown -Rf root:admin "$2/Contents/share/dict/ooo" || exit 1
  82.         chmod -Rf u-w,u+r "$2/Contents/share/dict/ooo" || exit 1
  83.         rm -Rf "$2/ooo" || exit 1
  84.     fi
  85.  
  86.     # Put back user's custom help files
  87.     if [ -d "$2/help" ]; then
  88.         for i in `cd "$2/help" ; find . -maxdepth 1`; do
  89.             if [ -h "$2/Contents/help/$i" ]; then
  90.                 rm -f "$2/Contents/help/$i" || exit 1
  91.             fi
  92.             if [ ! -e "$2/Contents/help/$i" ]; then
  93.                 mv -f "$2/help/$i" "$2/Contents/help" || exit 1
  94.             fi
  95.         done
  96.         chown -Rf root:admin "$2/Contents/help" || exit 1
  97.         chmod -Rf u-w,u+r "$2/Contents/help" || exit 1
  98.         rm -Rf "$2/help" || exit 1
  99.     fi
  100.  
  101.     # Put back user's custom jar files
  102.     if [ -d "$2/classes" ]; then
  103.         for i in `cd "$2/classes" ; find . -maxdepth 1`; do
  104.             if [ ! -e "$2/Contents/MacOS/classes/$i" ]; then
  105.                 mv -f "$2/classes/$i" "$2/Contents/MacOS/classes" || exit 1
  106.             fi
  107.         done
  108.         chown -Rf root:admin "$2/Contents/MacOS/classes" || exit 1
  109.         chmod -Rf u-w,u+r "$2/Contents/MacOS/classes" || exit 1
  110.         rm -Rf "$2/classes" || exit 1
  111.     fi
  112.  
  113.     # Put back user's custom resource files
  114.     if [ -d "$2/resource" ]; then
  115.         for i in `cd "$2/resource" ; find . -maxdepth 1`; do
  116.             if [ ! -e "$2/Contents/MacOS/resource/$i" ]; then
  117.                 mv -f "$2/resource/$i" "$2/Contents/MacOS/resource" || exit 1
  118.             fi
  119.         done
  120.         chown -Rf root:admin "$2/Contents/MacOS/resource" || exit 1
  121.         chmod -Rf u-w,u+r "$2/Contents/MacOS/resource" || exit 1
  122.         rm -Rf "$2/resource" || exit 1
  123.     fi
  124.  
  125.     # Put back user's custom localization files
  126.     if [ -d "$2/share" ]; then
  127.         for i in `cd "$2/share" ; find . -type d`; do
  128.             mkdir -p "$2/Contents/share/$i" || exit 1
  129.         done
  130.         for i in `cd "$2/share" ; find . -type f`; do
  131.             if [ ! -e "$2/Contents/share/$i" ]; then
  132.                 cp -f "$2/share/$i" "$2/Contents/share/$i" || exit 1
  133.             fi
  134.         done
  135.         chown -Rf root:admin "$2/Contents/share" || exit 1
  136.         chmod -Rf u-w,u+r "$2/Contents/share" || exit 1
  137.         rm -Rf "$2/share" || exit 1
  138.     fi
  139.  
  140.     # Put back user's custom font files
  141.     if [ -d "$2/truetype" ]; then
  142.         for i in `cd "$2/truetype" ; find . -maxdepth 1`; do
  143.             # Keep old fonts as they may have been loaded by the ATS server
  144.             if [ ! -d "$2/Contents/share/fonts/truetype/$i" ]; then
  145.                 if [ -e "$2/Contents/share/fonts/truetype/$i" ]; then
  146.                     rm -f "$2/Contents/share/fonts/truetype/$i"
  147.                 fi
  148.                 mv -f "$2/truetype/$i" "$2/Contents/share/fonts/truetype" || exit 1
  149.             fi
  150.         done
  151.         chown -Rf root:admin "$2/Contents/share/fonts/truetype" || exit 1
  152.         chmod -Rf u-w,u+r "$2/Contents/share/fonts/truetype" || exit 1
  153.         rm -Rf "$2/truetype" || exit 1
  154.     fi
  155.  
  156.     # Install shared .oxt files
  157.     if [ "$INSTALLER_TEMP" != "$HOME" -a `cd "$INSTALLER_TEMP" ; pwd` != "$HOME" ] ; then
  158.         for i in `find "$1/Contents/Resources" -name "*.oxt"` ; do
  159.             ( cd "$2/Contents/MacOS" || exit 1 ; HOME="$INSTALLER_TEMP" ; export HOME ; rm -Rf "$INSTALLER_TEMP/Library/Preferences/$(PRODUCT_DIR_NAME)-$(PRODUCT_VERSION_FAMILY)" ; "./unopkg.bin" remove --shared --force `basename "$i"` ; rm -Rf "$INSTALLER_TEMP/Library/Preferences/$(PRODUCT_DIR_NAME)-$(PRODUCT_VERSION_FAMILY)" ; "./unopkg.bin" add --shared --force "$i" )
  160.         done
  161.     fi
  162.  
  163.     sync
  164.  
  165.     # Mark certain directories writable for admin group
  166.     chmod -f 775 "$2" || exit 1
  167.     chmod -Rf a+r,a-w "$2/Contents" || exit 1
  168.     chmod -f 775 "$2/Contents" || exit 1
  169.     chmod -Rf ug+w "$2/Contents/Resources" || exit 1
  170.     chmod -Rf ug+w "$2/Contents/share/dict/ooo" || exit 1
  171.  
  172.     # Fix bug 1584 by marking certain directories writable for root user
  173.     chmod -Rf u+w "$2/Contents/presets" || exit 1
  174.     chmod -Rf u+w "$2/Contents/share" || exit 1
  175.  
  176.     # Touch shared libraries to fix bug 280
  177.     for i in `cd "$2/Contents/MacOS" ; find . -type f -name "*.dylib*" ; find . -type f -name "*.bin"`; do
  178.         touch -f "$2/Contents/MacOS/$i"
  179.     done
  180.  
  181.     sudo_user=
  182.     if [ ! -z "$USER" -a `id -u "$USER"` != "0" ] ; then
  183.         sudouser="$USER"
  184.     fi
  185.  
  186.     if [ ! -z "$sudouser" ] ; then
  187.         sudo -H -u "$sudouser" -b -i -- -c "$2/Contents/MacOS/soffice.bin"
  188.         sleep 15
  189.     fi
  190.  
  191.     lsregister="/System/Library/Frameworks/ApplicationServices.framework/Frameworks/LaunchServices.framework/Versions/Current/Support/lsregister"
  192.     if [ ! -x "$lsregister" ] ; then
  193.         lsregister="/System/Library/Frameworks/CoreServices.framework/Versions/Current/Frameworks/LaunchServices.framework/Versions/Current/Support/lsregister"
  194.         if [ ! -x "$lsregister" ] ; then
  195.             lsregister=
  196.         fi
  197.     fi
  198.  
  199.     if [ ! -z "$lsregister" ] ; then
  200.         "$lsregister" -f "$2"
  201.         if [ ! -z "$sudouser" ] ; then
  202.             sudo -H -u "$sudouser" -i -- -c "$lsregister -f \"$2\""
  203.         fi
  204.     fi
  205.  
  206.     # Touch installation directory to force activation of any bundled Spotlight
  207.     # plugins
  208.     touch -f "$2"
  209.  
  210.     # Do a full reindexing of OOo file types
  211.     if [ -x "/usr/bin/mdimport" ] ; then
  212.         /usr/bin/mdimport -r "$2/Contents/Library/Spotlight/neolight.mdimporter"
  213.         if [ ! -z "$sudouser" ] ; then
  214.             sudo -H -u "$sudouser" -i -- -c "/usr/bin/mdimport -r \"$2\"/Contents/Library/Spotlight/neolight.mdimporter"
  215.         fi
  216.     fi
  217.  
  218.     # Register the QuickLook plugin
  219.     if [ -x "/usr/bin/qlmanage" ] ; then
  220.         /usr/bin/qlmanage -r
  221.     fi
  222.  
  223. fi
  224.  
  225. exit 0
  226.