( cd usr/bin ; rm -rf soffice3.2 )
( cd usr/bin ; ln -sf /usr/lib/ooo-3.2/program/soffice3.2 soffice3.2 )
( cd usr/doc/openoffice3-3.2.0.10 ; rm -rf README )
( cd usr/doc/openoffice3-3.2.0.10 ; ln -sf /alternative/tmp/package-openoffice3/usr/lib/ooo-3.2/README README )
( cd usr/doc/openoffice3-3.2.0.10 ; rm -rf LICENSE.html )
( cd usr/doc/openoffice3-3.2.0.10 ; ln -sf /alternative/tmp/package-openoffice3/usr/lib/ooo-3.2/LICENSE.html LICENSE.html )
( cd usr/doc/openoffice3-3.2.0.10 ; rm -rf README.html )
( cd usr/doc/openoffice3-3.2.0.10 ; ln -sf /alternative/tmp/package-openoffice3/usr/lib/ooo-3.2/README.html README.html )
( cd usr/doc/openoffice3-3.2.0.10 ; rm -rf LICENSE )
( cd usr/doc/openoffice3-3.2.0.10 ; ln -sf /alternative/tmp/package-openoffice3/usr/lib/ooo-3.2/LICENSE LICENSE )
( cd usr/doc/openoffice3-3.2.0.10 ; rm -rf THIRDPARTYLICENSEREADME.html )
( cd usr/doc/openoffice3-3.2.0.10 ; ln -sf /alternative/tmp/package-openoffice3/usr/lib/ooo-3.2/THIRDPARTYLICENSEREADME.html THIRDPARTYLICENSEREADME.html )
( cd usr/pixmaps ; rm -rf ooo-base3.2.png )
( cd usr/pixmaps ; ln -sf /usr/share/icons/hicolor/48x48/apps/ooo-base3.2.png ooo-base3.2.png )
( cd usr/pixmaps ; rm -rf ooo-impress3.2.png )
( cd usr/pixmaps ; ln -sf /usr/share/icons/hicolor/48x48/apps/ooo-impress3.2.png ooo-impress3.2.png )
( cd usr/pixmaps ; rm -rf ooo-draw3.2.png )
( cd usr/pixmaps ; ln -sf /usr/share/icons/hicolor/48x48/apps/ooo-draw3.2.png ooo-draw3.2.png )
( cd usr/pixmaps ; rm -rf ooo-writer3.2.png )
( cd usr/pixmaps ; ln -sf /usr/share/icons/hicolor/48x48/apps/ooo-writer3.2.png ooo-writer3.2.png )
( cd usr/pixmaps ; rm -rf ooo-calc3.2.png )
( cd usr/pixmaps ; ln -sf /usr/share/icons/hicolor/48x48/apps/ooo-calc3.2.png ooo-calc3.2.png )
( cd usr/pixmaps ; rm -rf ooo-math3.2.png )
( cd usr/pixmaps ; ln -sf /usr/share/icons/hicolor/48x48/apps/ooo-math3.2.png ooo-math3.2.png )
( cd usr/lib/ooo-3.2/basis3.2 ; rm -rf ure-link )
( cd usr/lib/ooo-3.2/basis3.2 ; ln -sf ../ure ure-link )
( cd usr/lib/ooo-3.2 ; rm -rf basis-link )
( cd usr/lib/ooo-3.2 ; ln -sf basis3.2 basis-link )
( cd usr/lib/ooo-3.2/ure/bin ; rm -rf uno )
( cd usr/lib/ooo-3.2/ure/bin ; ln -sf startup.sh uno )
( cd usr/lib/ooo-3.2/ure/bin ; rm -rf regcomp )
( cd usr/lib/ooo-3.2/ure/bin ; ln -sf startup.sh regcomp )
( cd usr/share/pixmaps ; rm -rf ooo-web3.2.png )
( cd usr/share/pixmaps ; ln -sf /usr/share/icons/hicolor/48x48/apps/ooo-web3.2.png ooo-web3.2.png )
( cd usr/share/pixmaps ; rm -rf ooo-template3.2.png )
( cd usr/share/pixmaps ; ln -sf /usr/share/icons/hicolor/48x48/apps/ooo-template3.2.png ooo-template3.2.png )
( cd usr/share/pixmaps ; rm -rf ooo-base3.2.png )
( cd usr/share/pixmaps ; ln -sf /usr/share/icons/hicolor/48x48/apps/ooo-base3.2.png ooo-base3.2.png )
( cd usr/share/pixmaps ; rm -rf ooo-impress3.2.png )
( cd usr/share/pixmaps ; ln -sf /usr/share/icons/hicolor/48x48/apps/ooo-impress3.2.png ooo-impress3.2.png )
( cd usr/share/pixmaps ; rm -rf ooo-draw3.2.png )
( cd usr/share/pixmaps ; ln -sf /usr/share/icons/hicolor/48x48/apps/ooo-draw3.2.png ooo-draw3.2.png )
( cd usr/share/pixmaps ; rm -rf ooo-gulls3.2.png )
( cd usr/share/pixmaps ; ln -sf /usr/share/icons/hicolor/48x48/apps/ooo-gulls3.2.png ooo-gulls3.2.png )
( cd usr/share/pixmaps ; rm -rf ooo-writer3.2.png )
( cd usr/share/pixmaps ; ln -sf /usr/share/icons/hicolor/48x48/apps/ooo-writer3.2.png ooo-writer3.2.png )
( cd usr/share/pixmaps ; rm -rf ooo-calc3.2.png )
( cd usr/share/pixmaps ; ln -sf /usr/share/icons/hicolor/48x48/apps/ooo-calc3.2.png ooo-calc3.2.png )
( cd usr/share/pixmaps ; rm -rf ooo-math3.2.png )
( cd usr/share/pixmaps ; ln -sf /usr/share/icons/hicolor/48x48/apps/ooo-math3.2.png ooo-math3.2.png )

# Preserve new configuration files
install_file() {
  NEW="$1"
  OLD="`dirname $NEW`/`basename $NEW .new`"
  # If there's no config file by that name, mv it over:
  if [ ! -r $OLD ]; then
    mv $NEW $OLD
  elif [ "`cat $OLD | md5sum`" = "`cat $NEW | md5sum`" ]; then # toss the redundant copy
    rm $NEW
  fi
  # Otherwise, we leave the .new copy for the admin to consider...
}

install_file etc/bash_completion.d/ooffice3.2.sh.new

# Install dictionary extensions for spellchecking
if [ -x "usr/lib/ooo-3.2/program/unopkg" ]; then
  UNOPKGTMP=$TMP/$$$$$$
  if [ -f "usr/lib/ooo-3.2/share/extension/install/dict-en.oxt" ]; then
    usr/lib/ooo-3.2/program/unopkg add --shared \
        usr/lib/ooo-3.2/share/extension/install/dict-en.oxt \
        "-env:UserInstallation=file:///$UNOPKGTMP" 2>/dev/null 1>/dev/null
  fi;
  rm -rf $UNOPKGTMP
fi

# update desktop entries
if [ -x usr/bin/update-desktop-database ]; then
  usr/bin/update-desktop-database -q usr/share/applications
fi

# update mime database
if [ -x usr/bin/update-mime-database ]; then
  usr/bin/update-mime-database usr/share/mime >/dev/null 2>&1
fi

# update hicolor icon cache
if [ -e usr/share/icons/hicolor/icon-theme.cache ]; then
        rm -f usr/share/icons/hicolor/icon-theme.cache
fi
usr/bin/gtk-update-icon-cache -f -q usr/share/icons/hicolor
