%triggerin -- openoffice.org-core01
# run only for initial install - on updates, triggerun will ensure that only
# one instance is installed when running rpm -q --qf ..
if [ $1 -eq 1 -a $2 -eq 1 ]
then
  # create file in /etc that contains the office installation path
  cat > /tmp/install.$$ << EOF
# wait until rpm is done
while [ "\`pgrep rpm\`" != "" ]
do
  sleep 2
done

# create / update the link in /etc
TARGET=\`rpm -q --qf '%{INSTALLPREFIX}' openoffice.org-core01 2>/dev/null\`
[ "\${TARGET:0:1}" == "/" ] && ln -snf \$TARGET /etc/%unixfilename

# update desktop database (if any)
if [ -x /usr/bin/update-desktop-database ]; then
  /usr/bin/update-desktop-database -q /usr/share/applications
fi
rm -f /tmp/install.$$
EOF

  /bin/sh /tmp/install.$$ &
elif [ $1 -eq 2 ]; then
  # terminate (buggy) script from previous versions if any ..
  for i in `pgrep -f -d ' ' -u root '/bin/sh /tmp/install'`; do
    scriptlet=`ps --pid $i --format args= | cut -d ' ' -f 2`
    kill $i; rm -f $scriptlet
  done
fi
exit 0

%triggerpostun -- openoffice.org-core01
# running the script here ensures that only one instance of core01
# is installed when running rpm -q --qf ..
if [ $1 -gt 0 -a $2 -eq 1 ]
then
  # create file in /etc that contains the office installation path
  cat > /tmp/install.$$ << EOF
# wait until rpm is done
while [ "\`pgrep rpm\`" != "" ]
do
  sleep 2
done

# create / update the link in /etc
TARGET=\`rpm -q --qf '%{INSTALLPREFIX}' openoffice.org-core01 2>/dev/null\`
[ "\${TARGET:0:1}" == "/" ] && ln -snf \$TARGET /etc/%unixfilename

# update desktop database (if any)
if [ -x /usr/bin/update-desktop-database ]; then
  /usr/bin/update-desktop-database -q /usr/share/applications
fi
rm -f /tmp/install.$$
EOF

  /bin/sh /tmp/install.$$ &
fi
exit 0
