#Maintainer: Pedro Pinto (pnboy~AT~pinguix.com)
#Anything commented out is optional and can be deleted.
pkgname=openoffice
pkgver=3.2.0
_minorver=9483
_toExtra=(ooobasis${pkgver%.*}-base-$pkgver-$_minorver.i586.rpm ooobasis${pkgver%.*}-en-US-math-$pkgver-$_minorver.i586.rpm openoffice.org3-math-$pkgver-$_minorver.i586.rpm ooobasis${pkgver%.*}-en-US-base-$pkgver-$_minorver.i586.rpm openoffice.org3-base-$pkgver-$_minorver.i586.rpm ooobasis${pkgver%.*}-math-$pkgver-$_minorver.i586.rpm ooobasis${pkgver%.*}-ooofonts-$pkgver-$_minorver.i586.rpm)
pkgrel=1
zenver=64
arch=i586
sourcetemplate=http://pnboy.pinguix.com/my_packages/zenwalk/$pkgname/$pkgver/
_startDir=http://go-oo.mirrorbrain.org/stable/linux-i586/${pkgver%.*}
source=($_startDir/ooobasis${pkgver%.*}-images-$pkgver-$_minorver.i586.rpm $_startDir/ooobasis${pkgver%.*}-base-$pkgver-$_minorver.i586.rpm $_startDir/ooobasis${pkgver%.*}-binfilter-$pkgver-$_minorver.i586.rpm $_startDir/ooobasis${pkgver%.*}-calc-$pkgver-$_minorver.i586.rpm $_startDir/ooobasis${pkgver%.*}-core01-$pkgver-$_minorver.i586.rpm $_startDir/ooobasis${pkgver%.*}-core02-$pkgver-$_minorver.i586.rpm $_startDir/ooobasis${pkgver%.*}-core03-$pkgver-$_minorver.i586.rpm $_startDir/ooobasis${pkgver%.*}-core04-$pkgver-$_minorver.i586.rpm $_startDir/ooobasis${pkgver%.*}-core05-$pkgver-$_minorver.i586.rpm $_startDir/ooobasis${pkgver%.*}-core06-$pkgver-$_minorver.i586.rpm $_startDir/ooobasis${pkgver%.*}-core07-$pkgver-$_minorver.i586.rpm $_startDir/ooobasis${pkgver%.*}-draw-$pkgver-$_minorver.i586.rpm $_startDir/ooobasis${pkgver%.*}-en-US-$pkgver-$_minorver.i586.rpm $_startDir/ooobasis${pkgver%.*}-en-US-base-$pkgver-$_minorver.i586.rpm $_startDir/ooobasis${pkgver%.*}-en-US-binfilter-$pkgver-$_minorver.i586.rpm $_startDir/ooobasis${pkgver%.*}-en-US-calc-$pkgver-$_minorver.i586.rpm $_startDir/ooobasis${pkgver%.*}-en-US-draw-$pkgver-$_minorver.i586.rpm $_startDir/ooobasis${pkgver%.*}-en-US-impress-$pkgver-$_minorver.i586.rpm $_startDir/ooobasis${pkgver%.*}-en-US-math-$pkgver-$_minorver.i586.rpm $_startDir/ooobasis${pkgver%.*}-en-US-res-$pkgver-$_minorver.i586.rpm $_startDir/ooobasis${pkgver%.*}-en-US-writer-$pkgver-$_minorver.i586.rpm $_startDir/ooobasis${pkgver%.*}-gnome-integration-$pkgver-$_minorver.i586.rpm $_startDir/ooobasis${pkgver%.*}-graphicfilter-$pkgver-$_minorver.i586.rpm $_startDir/ooobasis${pkgver%.*}-impress-$pkgver-$_minorver.i586.rpm $_startDir/ooobasis${pkgver%.*}-javafilter-$pkgver-$_minorver.i586.rpm $_startDir/ooobasis${pkgver%.*}-kde-integration-$pkgver-$_minorver.i586.rpm $_startDir/ooobasis${pkgver%.*}-math-$pkgver-$_minorver.i586.rpm $_startDir/ooobasis${pkgver%.*}-ooolinguistic-$pkgver-$_minorver.i586.rpm $_startDir/ooobasis${pkgver%.*}-pyuno-$pkgver-$_minorver.i586.rpm $_startDir/ooobasis${pkgver%.*}-testtool-$pkgver-$_minorver.i586.rpm $_startDir/ooobasis${pkgver%.*}-writer-$pkgver-$_minorver.i586.rpm $_startDir/ooobasis${pkgver%.*}-xsltfilter-$pkgver-$_minorver.i586.rpm $_startDir/openoffice.org-ure-1.6.0-$_minorver.i586.rpm $_startDir/openoffice.org3-$pkgver-$_minorver.i586.rpm $_startDir/openoffice.org3-base-$pkgver-$_minorver.i586.rpm $_startDir/openoffice.org3-calc-$pkgver-$_minorver.i586.rpm $_startDir/openoffice.org3-draw-$pkgver-$_minorver.i586.rpm $_startDir/openoffice.org3-en-US-$pkgver-$_minorver.i586.rpm $_startDir/openoffice.org3-impress-$pkgver-$_minorver.i586.rpm $_startDir/openoffice.org3-math-$pkgver-$_minorver.i586.rpm $_startDir/openoffice.org3-writer-$pkgver-$_minorver.i586.rpm $_startDir/openoffice.org${pkgver%.*}-freedesktop-menus-${pkgver%.*}-$_minorver.noarch.rpm $_startDir/ooobasis${pkgver%.*}-ooofonts-$pkgver-$_minorver.i586.rpm openoffice.org3.scim.patch ${sourcetemplate}openintro_go-oo.bmp ${sourcetemplate}openabout_go-oo.bmp)
url=http://go-oo.org/
extradepends=(atk avahi cxxlibs dbus dbus-glib e2fsprogs expat fontconfig freetype gcc gconf glib2 glitz gnome-vfs gst-plugins-base gstreamer gtk+2 icu libICE libSM libX11 libXau libXaw libXcomposite libXcursor libXdamage libXdmcp libXext libXfixes libXft libXi libXinerama libXmu libXpm libXrandr libXrender libXt libXtst libXxf86vm libdrm libpng libxcb libxml2 mesa net-tools openssl orbit2 pango perl pixman python qt-base xcb-util zlib)
options=('noextract' 'norequiredbuilder')
doinst() {
# update the mime desktop database
if [ -x usr/bin/update-desktop-database ]; then
usr/bin/update-desktop-database -q
fi
# update the mime database
if [ -x usr/bin/update-mime-database ]; then
usr/bin/update-mime-database usr/share/mime > /dev/null 2>&1
fi
}
slackdesc=\
(
#|-----handy-ruler------------------------------------------------------|
"$pkgname (OpenOffice.org Office Suite)"
"OpenOffice.org the product is a multi-platform office productivity"
"suite. It includes the key desktop applications, such as a word"
"processor, spreadsheet, presentation manager, and drawing program,"
"with a user interface and feature set similar to other office suites."
"Sophisticated and flexible, OpenOffice.org also works transparently"
"with a variety of file formats, including those of Microsoft Office."
)
build() {
cd $startdir/src/
for file in *.rpm; do
if ! `echo ${_toExtra[@]} | grep "${file}" 1>/dev/null 2>&1`
then
echo $file
/usr/bin/rpm2targz $file
tar xf $(basename "$file" .rpm).tar.gz -C $startdir/pkg
fi
done
#for i in $startdir/src/*.rpm; do
# rpm2cpio $i | cpio -id --quiet
# cp -r $startdir/src/tmp/* $startdir/pkg
# rm -rf $startdir/src/tmp/*
#done
STRIMVER=${pkgver%.*}
mkdir -p $startdir/pkg/usr/lib/openoffice.org${pkgver%.*}
cd $startdir/pkg/opt
mv */* $startdir/pkg/usr/lib/openoffice.org${pkgver%.*}
rm -rf $startdir/pkg/usr/lib/openoffice.org${pkgver%.*}/basis${pkgver%.*}/program/python-core*
cd $startdir/pkg/usr/lib/openoffice.org${pkgver%.*}
rm basis-link
ln -s basis${pkgver%.*} basis-link
mkdir -p $startdir/pkg/usr/share/applications/
cd $startdir/pkg/usr/share/applications/
for APPS in base calc draw impress math writer ; do
ln -sf ../../lib/openoffice.org${pkgver%.*}/share/xdg/$APPS.desktop openoffice.org-${pkgver%.*}-$APPS.desktop
done
STRIMVER=${STRIMVER%.*}
cd $startdir/pkg/usr/lib/openoffice.org${pkgver%.*}/share/xdg/
sed -i -e "s|openoffice.org$STRIMVER -calc %U|oocalc|g" calc.desktop
sed -i -e "s|openoffice.org$STRIMVER -draw %U|oodraw|g" draw.desktop
sed -i -e "s|openoffice.org$STRIMVER -impress %U|ooimpress|g" impress.desktop
sed -i -e "s|openoffice.org$STRIMVER -writer %U|oowriter|g" writer.desktop
mkdir -p $startdir/pkg/usr/bin/
cd $startdir/pkg/usr/bin/
ln -sf ../lib/openoffice.org${pkgver%.*}/program/soffice soffice
ln -sf ../lib/openoffice.org${pkgver%.*}/program/unopkg unopkg
mkdir -p $PKG/usr/share/icons/hicolor/48x48/mimetypes/
install -d -m755 $startdir/pkg/usr/share/icons/hicolor/48x48/apps/
install -v -m644 $startdir/pkg/usr/share/icons/hicolor/48x48/mimetypes/openofficeorg3-oasis-{text,presentation,database,drawing,spreadsheet,formula}.png $startdir/pkg/usr/share/icons/hicolor/48x48/apps/
sed -i "s|opt/openoffice.org3|usr/lib/openoffice.org${pkgver%.*}|g" $startdir/pkg/usr/bin/openoffice.org3
sed -i "s|opt/openoffice.org3|usr/lib/openoffice.org${pkgver%.*}|g" $startdir/pkg/usr/bin/openoffice.org3-printeradmin
# Make symlinks to the binaries
for APPS in base calc draw math writer padmin impress ; do
cat << EoF > $startdir/pkg/usr/bin/oo$APPS
#!/bin/bash
exec /usr/lib/openoffice.org${pkgver%.*}/program/s$APPS "\$@"
EoF
chmod +x $startdir/pkg/usr/bin/oo$APPS
done
cp $startdir/src/openabout_go-oo.bmp $startdir/pkg/usr/lib/openoffice.org${pkgver%.*}/program/openabout_go-oo.bmp
cp $startdir/src/openintro_go-oo.bmp $startdir/pkg/usr/lib/openoffice.org${pkgver%.*}/program/openintro_go-oo.bmp
rm -rvf $startdir/pkg/usr/share/applications/openoffice.org3*.desktop
rm -rfv $startdir/pkg/opt
sed -i -e "s|auto|tango|g" $startdir/pkg/usr/lib/openoffice.org${pkgver%.*}/basis${pkgver%.*}/share/registry/schema/org/openoffice/Office/Common.xcs
package2=$pkgname-extra-$pkgver-$arch-$zenver.$pkgrel
mkdir -p $startdir/pkg2/install/
cat << EOF > $startdir/pkg2/install/slack-desc
$pkgname-extra: $pkgname-extra (Extra open-office files)
$pkgname-extra:
$pkgname-extra: Extra files for open-office(Math and Base).
EOF
cd $startdir/src
for file in *.rpm; do
if `echo ${_toExtra[@]} | grep "${file}" 1>/dev/null 2>&1`
then
echo $file
/usr/bin/rpm2targz $file
tar xf $(basename "$file" .rpm).tar.gz -C $startdir/pkg2
fi
done
cd $startdir/pkg2/opt
mkdir -p $startdir/pkg2/usr/lib/openoffice.org${pkgver%.*}
cp -r */* $startdir/pkg2/usr/lib/openoffice.org${pkgver%.*}
mkdir -p $startdir/pkg2/usr/share/applications/
mkdir -p $startdir/pkg2/usr/bin/
cd $startdir/pkg/usr/bin/
mv oo{base,math} $startdir/pkg2/usr/bin/
mkdir -p $startdir/pkg2/usr/lib/openoffice.org${pkgver%.*}/share/xdg/
mv $startdir/pkg/usr/lib/openoffice.org${pkgver%.*}/share/xdg/{base,math}.desktop $startdir/pkg2/usr/lib/openoffice.org${pkgver%.*}/share/xdg/
mv $startdir/pkg/usr/share/applications/openoffice.org-${pkgver%.*}-{base,math}.desktop $startdir/pkg2/usr/share/applications/
cd $startdir/pkg2/usr/lib/openoffice.org${pkgver%.*}/share/xdg/
sed -i -e "s|openoffice.org$STRIMVER -base %U|oobase|g" base.desktop
sed -i -e "s|openoffice.org$STRIMVER -math %U|oomath|g" math.desktop
mkdir -p $startdir/pkg2/usr/lib/openoffice.org${pkgver%.*}/basis${pkgver%.*}/share/config/
mv $startdir/pkg/usr/lib/openoffice.org${pkgver%.*}/basis${pkgver%.*}/share/config/{images.zip,images_crystal.zip,images_industrial.zip,images_classic.zip,images_hicontrast.zip} $startdir/pkg2/usr/lib/openoffice.org${pkgver%.*}/basis${pkgver%.*}/share/config/
mkdir -p $startdir/pkg2/usr/lib/openoffice.org${pkgver%.*}/basis${pkgver%.*}/share/gallery/sounds
mv $startdir/pkg/usr/lib/openoffice.org${pkgver%.*}/basis${pkgver%.*}/share/gallery/sounds $startdir/pkg2/usr/lib/openoffice.org${pkgver%.*}/basis${pkgver%.*}/share/gallery/sounds
mkdir -p $startdir/pkg2/usr/lib/openoffice.org${pkgver%.*}/basis${pkgver%.*}/program/
mv $startdir/pkg/usr/lib/openoffice.org${pkgver%.*}/basis${pkgver%.*}/program/classes $startdir/pkg2/usr/lib/openoffice.org${pkgver%.*}/basis${pkgver%.*}/program/classes/
rm -rvf $startdir/pkg2/opt
cd $startdir/pkg2
/sbin/makepkg -l y -c n $startdir/$package2.txz
cd $startdir
md5sum $package2.txz > $startdir/$package2.md5
#create dep file
echo "${extradepends[@]} openoffice" | sed 's/ /\n/g' | sort -u | tr '\n' ','>$startdir/$package2.dep
rm -rvf $startdir/pkg2
unset package2
cd $startdir/pkg/usr/bin/
# patch to make OOo work with SCIM, as suggested by Ejis / Aymeric
patch -p0 -i $startdir/src/openoffice.org3.scim.patch
#fix symlinks problems
cd $startdir/pkg/usr/lib
ln -s libcrypto.so libcrypto.so.4
ln -s libkdeui.so libkdeui.so.4
ln -s libkdecore.so libkdecore.so.4
ln -s libkabc.so libkabc.so.1
ln -s libkio.so libkio.so.4
}