Installing Linux OpenOffice.org

With the availability of a FreeBSD-native version of OpenOffice.org, you might ask "why would I want to install the Linux version?" While there are plenty of reasons, one very good one in my opinion is the incredible amount of time it takes to compile OpenOffice! On my IBM ThinkPad i Series 1300 (700 MHz Intel Celeron), it once took me 50+ hours to compile the behemoth. (A recent attempt to compile version 2.1.0 failed with a compiler error about 40 hours into the process).

While it is true that Good Day occasionally has FreeBSD OpenOffice packages available, the packages are often outdated and sometimes (early January 2007) not available at all. This is not to disparage the efforts of the Good Day maintainer in making FreeBSD OpenOffice packages available to the public, but if you want the current version of OpenOffice, or there is no Good Day package available and you don't want to wait for it to compile, here is a quick alternative.

First, go to www.openoffice.org, click on the "Download OpenOffice.org" link, and select the Linux (x86) version.

Next, run the following command in a terminal window:

kldstat

Check for the following line:

2    1 0xc08a3000 196c8    linux.ko

If you have this line, then you already have the Linux kernel module loaded. If not, run the following command as root:

kldload linux

This will load the Linux kernel module. To automatically load this module each time we start up our system, we need to add a line to /boot/loader.conf:

vi /boot/loader.conf

Add the following line:

linux_load="YES"

Now that we have Linux support, it's time to install OpenOffice.org. The file that we downloaded from www.openoffice.org should be named something like "OOo_2.0.1_LinuxIntel_install.tar.gz", which we'll use in the following example.

mv OOo_2.0.1_LinuxIntel_install.tar.gz /usr/compat/linux/usr
cd /usr/compat/linux/usr
tar -xzf OOo_2.0.1_LinuxIntel_install.tar.gz

This will extract the install files to /usr/compat/linux/usr; doing an 'ls' should reveal the following newly created directory: "OOA680_m1_native_packed-1_en-US.8990".

cd OOA680_m1_native_packed-1_en-US.8990/RPMS/

If you do an 'ls', you'll see about 25 files ending with the extension ".rpm". If there is a particular component/feature that you know you don't want, you can delete that individual .rpm file, or you can just leave them all. Now to install OpenOffice.org:

rpm -Uvih --ignoreos --ignorearch --root /usr/compat/linux --nodeps *.rpm

This will display something very ugly that anyone who's ever used Red Hat Linux will be familiar with. It should look something like this:

Preparing...                ########################################### [100%]
   1:openoffice.org-xsltfilt########################################### [  4%]
   2:openoffice.org-base    ########################################### [  7%]
   3:openoffice.org-calc    ########################################### [ 11%]
   4:openoffice.org-core01  ########################################### [ 15%]
   5:openoffice.org-core02  ########################################### [ 19%]
   6:openoffice.org-core03  ########################################### [ 22%]
   7:openoffice.org-core03u ########################################### [ 26%]
   8:openoffice.org-core04  ########################################### [ 30%]
   9:openoffice.org-core04u ########################################### [ 33%]
  10:openoffice.org-core05  ########################################### [ 37%]
  11:openoffice.org-core05u ########################################### [ 41%]
  12:openoffice.org-core06  ########################################### [ 44%]
  13:openoffice.org-core07  ########################################### [ 48%]
  14:openoffice.org-core08  ########################################### [ 52%]
  15:openoffice.org-core09  ########################################### [ 56%]
  16:openoffice.org-core10  ########################################### [ 59%]
  17:openoffice.org-draw    ########################################### [ 63%]
  18:openoffice.org-emailmer########################################### [ 67%]
  19:openoffice.org-gnome-in########################################### [ 70%]
  20:openoffice.org-graphicf########################################### [ 74%]
  21:openoffice.org-impress ########################################### [ 78%]
  22:openoffice.org-javafilt########################################### [ 81%]
  23:openoffice.org-math    ########################################### [ 85%]
  24:openoffice.org-pyuno   ########################################### [ 89%]
  25:openoffice.org-spellche########################################### [ 93%]
  26:openoffice.org-testtool########################################### [ 96%]
  27:openoffice.org-writer  ########################################### [100%]

If you receive an error message about "failed to open /usr/compat/linux/var/lib/rpm/packages.rpm", there is an easy workaround:

mkdir /usr/compat/linux/var/lib/rpm
touch /usr/compat/linux/var/lib/rpm/packages.rpm

And repeat the above command to install the Linux version of OpenOffice.org.

OpenOffice.org should now be installed at "/usr/compat/linux/opt/openoffice.org2.0". Before we run it, however, there's one last thing we have to set up. . .

cd /usr/compat/linux
ln -s /var/tmp tmp

If you do not do this, OpenOffice.org will create a "tmp" directory at "/usr/compat/linux/tmp", but due to a permissions error you will be unable to save changes to documents from within OpenOffice.org. Not really what you want. By creating a symbolic link to "/var/tmp", the "tmp" directory used by normal FreeBSD apps, we've avoided this pitfall.

That's it, OpenOffice.org is installed and ready to go. To run it,

/usr/compat/linux/bin/sh /usr/compat/linux/opt/openoffice.org2.0/program/soffice &

Yeah, that's really ugly, and not something you want to be typing every time you want to use OpenOffice.org. However, we cannot simply paste this line into our Fluxbox menu. Bad things will happen. Trust me. There is, however, a slightly imperfect workaround. First. 'exit' su mode and become your user again. Then:

vi ~/bin/startopenoffice

If you don't have a "bin" directory in your user's home directory, create one. This will be a handy place to keep scripts we write. The following script is extremely simple, but it will work for our purposes:

#!/bin/sh
/usr/compat/linux/bin/sh /usr/compat/linux/opt/openoffice.org2.0/program/soffice

Told you it was simple. Save your changes and exit. Now we have to make our script executable:

chmod +x ~/bin/startopenoffice

Now to add OpenOffice.org to our Fluxbox menu:

vi ~/.fluxbox/menu

Add the following line to your menu for OpenOffice.org:

[exec] (OpenOffice.org) {xterm -e startopenoffice}

You you should be able to start OpenOffice.org from your Fluxbox menu just as you would any other app. Note that a new xterm window will open allong with OpenOffice.org. Don't worry, this window will close automatically when you close OpenOffice.org.

If you want to use any of OpenOffice.org's features that depend on java (i.e. the Wizards), you can't use the BSD native version of java with Linux OpenOffice.org. The solution is to install Linux Java. As root:

cd /usr/ports/java/linux-sun-jdk14
make install clean

This will give you an error message about having to manually download a file from Sun. Fortunately, the error message gives you the URL you need. Highlight the URL and paste it into a web browser, download the exact file name specified by the error message, and then move the file to /usr/ports/distfiles. Try 'make install clean' again and this time it should work.

After you've installed Linux Java, open Linux OpenOffice.org, go to the Tools menu, and select Options. Click on the Java heading on the left tree, then choose Add to add a new Java Runtime Environment. The path you want is to /usr/local/linux-sun-jdk1.4.2/jre/. Once you add this, OpenOffice.org should list your Linux Java as an option. (It won't say "Linux," but the trailing version number will be newer than on the BSD native version of jdk14). Select this as the Java Runtime you want to use. You'll be warned that you need to start OpenOffice.org before your changes will take effect. Close OpenOffice.org, and the next time you launch it you should be able to use the Wizards.

We hope this proved useful for those users who want to run the Linux version of OpenOffice.org.