home *** CD-ROM | disk | FTP | other *** search
- #!/bin/bash -x
- ##########################################################################
- #
- # $RCSfile: postflight,v $
- #
- # $Revision: 1.60 $
- #
- # last change: $Author: pluby $ $Date: 2008/02/08 21:47:15 $
- #
- # The Contents of this file are made available subject to the terms of
- # either of the following licenses
- #
- # - GNU General Public License Version 2.1
- #
- # Patrick Luby, June 2003
- #
- # GNU General Public License Version 2.1
- # =============================================
- # Copyright 2003 Planamesa Inc.
- #
- # This library is free software; you can redistribute it and/or
- # modify it under the terms of the GNU General Public
- # License version 2.1, as published by the Free Software Foundation.
- #
- # This library is distributed in the hope that it will be useful,
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- # General Public License for more details.
- #
- # You should have received a copy of the GNU General Public
- # License along with this library; if not, write to the Free Software
- # Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- # MA 02111-1307 USA
- #
- ##########################################################################
-
- PATH=/bin:/sbin:/usr/bin:/usr/sbin
- export PATH
-
- umask 022
-
- mdimporter_id="org.neooffice.neolight.NeoOffice-2.2.3-Intel"
- qlplugin_id="org.neooffice.quicklookplugin.NeoOffice-2.2.3-Intel"
-
- if [ -d "$2" ]; then
-
- # Fix Apple installer bug described in bug 1373
- 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
- exit 1;
- fi
-
- # Fix bug 2711 by updating plugin bundle IDs
- mdimporter_file="$2/Contents/Library/Spotlight/neolight.mdimporter/Contents/Info.plist"
- rm -f "$mdimporter_file.tmp"
- if [ ! -z "$mdimporter_id" -a -f "$mdimporter_file" ] ; then
- sed "s#$mdimporter_id#$mdimporter_id.`date '+%Y%m%d%H%M%S'`#g" "$mdimporter_file" > "$mdimporter_file.tmp"
- if [ -s "$mdimporter_file.tmp" ] ; then
- mv -f "$mdimporter_file.tmp" "$mdimporter_file"
- chmod -f 444 "$mdimporter_file"
- fi
- rm -f "$mdimporter_file.tmp"
- fi
-
- qlplugin_file="$2/Contents/Library/QuickLook/neopeek.qlgenerator/Contents/Info.plist"
- rm -f "$qlplugin_file.tmp"
- if [ ! -z "$qlplugin_id" -a -f "$qlplugin_file" ] ; then
- sed "s#$qlplugin_id#$qlplugin_id.`date '+%Y%m%d%H%M%S'`#g" "$qlplugin_file" > "$qlplugin_file.tmp"
- if [ -s "$qlplugin_file.tmp" ] ; then
- mv -f "$qlplugin_file.tmp" "$qlplugin_file"
- chmod -f 444 "$qlplugin_file"
- fi
- rm -f "$qlplugin_file.tmp"
- fi
-
- tempfile="$INSTALLER_TEMP/out"
- touch "$tempfile" || exit 1
-
- # Put back user's custom dictionary files
- if [ -d "$2/ooo" ]; then
- for i in `cd "$2/ooo" ; find . -name "*.aff" -o -name "*.dat" -o -name "*.dic" -o -name "*.idx" -maxdepth 1`; do
- if [ ! -e "$2/Contents/share/dict/ooo/$i" ]; then
- mv -f "$2/ooo/$i" "$2/Contents/share/dict/ooo" || exit 1
- if [ -e "$2/ooo/dictionary.lst" ]; then
- base=`basename "$i" | awk -F. '{ print $1 }'`
- grep -E '[^][#:space:]*(DICT|HYPH|THES)[[:space:]]*[[:alpha:]]*[[:space:]]*[[:alpha:]]*[[:space:]]*'"$base"'[[:space:]]*$' "$2/ooo/dictionary.lst" >> "$tempfile"
- fi
- fi
- done
- if [ -s "$tempfile" ]; then
- sort -u "$tempfile" >> "$2/Contents/share/dict/ooo/dictionary.lst"
- fi
- chown -Rf root:admin "$2/Contents/share/dict/ooo" || exit 1
- chmod -Rf u-w,u+r "$2/Contents/share/dict/ooo" || exit 1
- rm -Rf "$2/ooo" || exit 1
- fi
-
- # Put back user's custom help files
- if [ -d "$2/help" ]; then
- for i in `cd "$2/help" ; find . -maxdepth 1`; do
- if [ -h "$2/Contents/help/$i" ]; then
- rm -f "$2/Contents/help/$i" || exit 1
- fi
- if [ ! -e "$2/Contents/help/$i" ]; then
- mv -f "$2/help/$i" "$2/Contents/help" || exit 1
- fi
- done
- chown -Rf root:admin "$2/Contents/help" || exit 1
- chmod -Rf u-w,u+r "$2/Contents/help" || exit 1
- rm -Rf "$2/help" || exit 1
- fi
-
- # Put back user's custom jar files
- if [ -d "$2/classes" ]; then
- for i in `cd "$2/classes" ; find . -maxdepth 1`; do
- if [ ! -e "$2/Contents/MacOS/classes/$i" ]; then
- mv -f "$2/classes/$i" "$2/Contents/MacOS/classes" || exit 1
- fi
- done
- chown -Rf root:admin "$2/Contents/MacOS/classes" || exit 1
- chmod -Rf u-w,u+r "$2/Contents/MacOS/classes" || exit 1
- rm -Rf "$2/classes" || exit 1
- fi
-
- # Put back user's custom resource files
- if [ -d "$2/resource" ]; then
- for i in `cd "$2/resource" ; find . -maxdepth 1`; do
- if [ ! -e "$2/Contents/MacOS/resource/$i" ]; then
- mv -f "$2/resource/$i" "$2/Contents/MacOS/resource" || exit 1
- fi
- done
- chown -Rf root:admin "$2/Contents/MacOS/resource" || exit 1
- chmod -Rf u-w,u+r "$2/Contents/MacOS/resource" || exit 1
- rm -Rf "$2/resource" || exit 1
- fi
-
- # Put back user's custom localization files
- if [ -d "$2/share" ]; then
- for i in `cd "$2/share" ; find . -type d`; do
- mkdir -p "$2/Contents/share/$i" || exit 1
- done
- for i in `cd "$2/share" ; find . -type f`; do
- if [ ! -e "$2/Contents/share/$i" ]; then
- cp -f "$2/share/$i" "$2/Contents/share/$i" || exit 1
- fi
- done
- chown -Rf root:admin "$2/Contents/share" || exit 1
- chmod -Rf u-w,u+r "$2/Contents/share" || exit 1
- rm -Rf "$2/share" || exit 1
- fi
-
- # Put back user's custom font files
- if [ -d "$2/truetype" ]; then
- for i in `cd "$2/truetype" ; find . -maxdepth 1`; do
- # Keep old fonts as they may have been loaded by the ATS server
- if [ ! -d "$2/Contents/share/fonts/truetype/$i" ]; then
- if [ -e "$2/Contents/share/fonts/truetype/$i" ]; then
- rm -f "$2/Contents/share/fonts/truetype/$i"
- fi
- mv -f "$2/truetype/$i" "$2/Contents/share/fonts/truetype" || exit 1
- fi
- done
- chown -Rf root:admin "$2/Contents/share/fonts/truetype" || exit 1
- chmod -Rf u-w,u+r "$2/Contents/share/fonts/truetype" || exit 1
- rm -Rf "$2/truetype" || exit 1
- fi
-
- # Install shared .oxt files
- if [ "$INSTALLER_TEMP" != "$HOME" -a `cd "$INSTALLER_TEMP" ; pwd` != "$HOME" ] ; then
- for i in `find "$1/Contents/Resources" -name "*.oxt"` ; do
- ( 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" )
- done
- fi
-
- sync
-
- # Mark certain directories writable for admin group
- chmod -f 775 "$2" || exit 1
- chmod -Rf a+r,a-w "$2/Contents" || exit 1
- chmod -f 775 "$2/Contents" || exit 1
- chmod -Rf ug+w "$2/Contents/Resources" || exit 1
- chmod -Rf ug+w "$2/Contents/share/dict/ooo" || exit 1
-
- # Fix bug 1584 by marking certain directories writable for root user
- chmod -Rf u+w "$2/Contents/presets" || exit 1
- chmod -Rf u+w "$2/Contents/share" || exit 1
-
- # Touch shared libraries to fix bug 280
- for i in `cd "$2/Contents/MacOS" ; find . -type f -name "*.dylib*" ; find . -type f -name "*.bin"`; do
- touch -f "$2/Contents/MacOS/$i"
- done
-
- sudo_user=
- if [ ! -z "$USER" -a `id -u "$USER"` != "0" ] ; then
- sudouser="$USER"
- fi
-
- if [ ! -z "$sudouser" ] ; then
- sudo -H -u "$sudouser" -b -i -- -c "$2/Contents/MacOS/soffice.bin"
- sleep 15
- fi
-
- lsregister="/System/Library/Frameworks/ApplicationServices.framework/Frameworks/LaunchServices.framework/Versions/Current/Support/lsregister"
- if [ ! -x "$lsregister" ] ; then
- lsregister="/System/Library/Frameworks/CoreServices.framework/Versions/Current/Frameworks/LaunchServices.framework/Versions/Current/Support/lsregister"
- if [ ! -x "$lsregister" ] ; then
- lsregister=
- fi
- fi
-
- if [ ! -z "$lsregister" ] ; then
- "$lsregister" -f "$2"
- if [ ! -z "$sudouser" ] ; then
- sudo -H -u "$sudouser" -i -- -c "$lsregister -f \"$2\""
- fi
- fi
-
- # Touch installation directory to force activation of any bundled Spotlight
- # plugins
- touch -f "$2"
-
- # Do a full reindexing of OOo file types
- if [ -x "/usr/bin/mdimport" ] ; then
- /usr/bin/mdimport -r "$2/Contents/Library/Spotlight/neolight.mdimporter"
- if [ ! -z "$sudouser" ] ; then
- sudo -H -u "$sudouser" -i -- -c "/usr/bin/mdimport -r \"$2\"/Contents/Library/Spotlight/neolight.mdimporter"
- fi
- fi
-
- # Register the QuickLook plugin
- if [ -x "/usr/bin/qlmanage" ] ; then
- /usr/bin/qlmanage -r
- fi
-
- fi
-
- exit 0
-