Tuesday, October 9, 2007

Building Eclipse for solaris gtk x86 on Nexenta

As this is my first post, I wanted to contribute something useful.   Hopefully this post will help someone somewhere.  I am trying to solve the following problems:
  • How to install Nexenta and upgrade to the latest version (as of 10-08-2007).  Installation is easy, upgrading is not. 
  • How to install a zone so that we have a clean area for building Eclipse;  hopefully I will give you enough to get started in the latest version of Nexenta.
  • How to unpack Java and SunStudio to setup for an Eclipse build.
  • How to modify the Eclipse build scripts to create a distribution of solaris-gtk-x86 3.3 that runs on Nexenta.  Unfortunately, solaris-gtk-x86 is not a supported Eclipse distribution, and the scripts require a bit of change, but these steps should give you a good starting point and hopefully will give you an understanding of which parts of Eclipse are os-specific.

Without further ado, the first step in this process is below.  This should be an easy one, but it will be time-consuming to burn the .iso image and to install the OS.

Step 1: Install Nexenta Alpha 6


  • This is my hardware: Intel P3 750 with 1GB RAM and an 80GB hard drive.
  • Download the Alpha 6 .iso. I have read some postings that the CD install of Alpha 7 may not work and I have not tried to install this version. I prefer to upgrade instead.

Step 2: Upgrade Nexenta from Alpha 6 to the latest version in the Testing repository



Unfortunately, this is not quite as straightforward as it should be. There are threads in the Nexenta forums with information about why the upgrade process takes a couple of extra steps.

These instuctions can be performed from a terminal.
  • sudo apt-get remove samba (for some reason, when I had tried to upgrade previously with samba installed, I got an error that led to disaster in the form of Nested trap rebooting messages and an inability to reboot because of an incomplete upgrade, so I just took it out of the equation temporarily).
  • sudo reboot
  • sudo apt-get clean
  • sudo apt-get update
  • sudo apt-get dist-upgrade (by this point, you probably should have seen the dreaded message telling you to do an apt-get install -f).
  • sudo apt-get install-f (now allow the package manager to remove all your gnome packages but do NOT reboot).
  • sudo apt-get install gnome gnome-applets gnome-control-center gnome-core gnome-desktop-environment gnome-panel gnome-session gnome-terminal (this should re-install all the removed packages and some more).
  • sudo apt-get install totem-gstreamer-firefox-plugin (this one does not get re-installed in step 7, so do it manually).
  • sudo apt-get install dpkg apt (during the upgrade install previously, I had seen errors about the versions of dpkg and apt being incorrect, so I figured I should just upgrade those up front).
  • sudo apt-get update
  • sudo apt-get dist-upgrade (now there should be only one package that is getting removed -- libnewt0.51, but it will get replaced -- and a whole lot of other packages that will be upgraded and installed. This upgrade took about 45 minutes for me because a couple of connections timed-out, but it completed successfully and successfully rebooted after the upgrade).
  • sudo apt-get install samba (we uninstalled this previously).
  • sudo reboot.

Step 3: Create a New Zone


See these instructions for setting up a new zone for Nexenta. I named my zone eclipse_zone and put it in /export/home/zones/eclipse_zone.

Step 4: Install JDK 6 in the eclipse_zone


See these instructions for setting up the JDK in a new base Nexenta zone.

Step 5: Install Sun Studio 12



Even though Nexenta provides installations of gcc and cc, I chose to include a step in here for installing Sun Studio 12. A standalone, non-solaris package version of this is available for download through the Sun Developer Network. It is free to sign up and the download is free.
Again, do NOT download the solaris package version. Instead, download the standalone archive. This will install both Sun Studio and Netbeans 5.5.1.
I use SunStudio in the Eclipse build for its cc compiler, for all native libraries except the SWT (see the script below for the reason). I have not tried to build Eclipse using just the gcc compiler, but I don't see why this would not work with some changes to the build scripts (for example, all -K PIC arguments would need to be changed to -fPIC for gcc). If you have built Eclipse entirely using gcc on Solaris, please send me a link to your instructions as I would be interested in trying this!
  • copy SunStudio12-solaris-x86-200705-ii.tar to /usr/opt
  • root@eclipse_zone:~# cd /usr/opt
  • root@eclipse_zone:/usr/opt# tar -xf SunStudio12-solaris-x86-200705-ii.tar

You should now have SunStudio and Netbeans installed in the eclipse_zone. I have not tried to start SunStudio or Netbeans from inside a zone -- I would guess offhand that this would not work since there is no X server running inside the zone, but it might be worth trying out sometime.

Step 6: Set up Nexenta packages required for Eclipse compilation



There are a few packages that must be installed in the zone before the Eclipse libraries will compile. Some of these packages are installed with the full Nexenta desktop, so if you are installing in the root zone, they may already be available to you. In a different vein, I originally tried to compile the required gtk+ libraries from scratch (along with all the dependencies such as cairo, pango, freetype, etc.). Unfortunately, this turned out to be a rather large time sink for me, as I was able to install the libraries, but I ran into collisions with some of the libraries that already existed from my nexenta install. If you would like all the latest and greatest versions of gtk+, then it might be a good idea for you to contribute those libraries to nexenta's unstable package installation branch. If you are able to do this successfully, I would really like to see some instructions for this. In any case, I did not pursue this because my goal is to get Eclipse 3.3 compiling and running, and the existing nexenta packages fulfill the Eclipse pre-requisites. The following instructions can be performed from a terminal.
  • root@eclipse_zone:~# apt-get install libgnomeui-dev
  • root@eclipse_zone:~# apt-get install libxtst-dev
  • root@eclipse_zone:~# apt-get install libxt-dev
  • root@eclipse_zone:~# apt-get install make
  • root@eclipse_zone:~# apt-get install gcc
  • root@eclipse_zone:~# apt-get install unzip
  • root@eclipse_zone:~# apt-get install zip

Step 7: Install Apache Ant



Finally, a step that is straightforward and that works as expected!
Download the apache ant binary.
  • copy apache-ant-1.7.0-bin.tar to /usr/opt
  • root@eclipse_zone:~# cd /usr/opt
  • root@eclipse_zone:/usr/opt# tar -xf apache-ant-1.7.0-bin.tar

Step 8: Set your environment variables



These environment variables are necessary for the Eclipse build process.
  • root@eclipse_zone:~# export JAVA_HOME=/usr/opt/jdk1.6.0_02
  • root@eclipse_zone:~# export ANT_HOME=/usr/opt/apache-ant-1.7.0
  • root@eclipse_zone:~# export CC=/usr/opt/SUNWspro/bin/cc
  • root@eclipse_zone:~# export PATH=$ANT_HOME/bin:$PATH

Step 9: Dig into the Eclipse build scripts



In my original post I included just a laundry list of commands to modify the Eclipse build scripts from the command-line, but in the spirit of continuous improvement, I have since extracted the commands from that original post into a shell script both to automate the process and because the script better conveys the intention of the modifications I made. This script for building Eclipse 3.3 is now in a dedicated post of its own, along with similar scripts for building Eclipse 3.4M4 and for building Eclipse 3.4M5.

The versions of Eclipse that I am currently running (Europa and Ganymede) were built from these scripts in the global zone, not in an eclipse-specific build zone. As with my install of Pidgin, I often find that it is best to perform an initial build of some software in a dedicated zone to work out dependencies. Since Pidgin and Eclipse both use the X Server graphics libraries, I plan to run them in the global zone. In this case, I decided to perform my actual Eclipse build in the global zone. The instructions below assume that you are building Eclipse in its own zone, but you can certainly perform the build in the global zone as I did.

Originally, I found directions that provide a good starting point and good ideas for scripting some of the process outlined below, but I was not completely successful with the instructions because of the dependency the Eclipse build process has on compiling the cde libraries for Solaris.  For a Nexenta Solaris build, we will not be using the cde libraries, but rather the gnome libraries.  The Eclipse Nexenta build is more like a combination of the Linux and Solaris builds than a straight port of the Solaris Sparc build.

Download the eclipse source build eclipse-sourceBuild-srcIncluded-3.3.zip

  • root@eclipse_zone:~# mkdir /usr/opt/eclipse
  • copy eclipse-sourceBuild-srcIncluded-3.3.zip to /usr/opt/eclipse
  • root@eclipse_zone:~# cd /usr/opt/eclipse
  • copy the script above to /usr/opt/eclipse and name it build_eclipse.sh
  • root@eclipse_zone:/usr/opt/eclipse# chmod 755 build_eclipse.sh
  • root@eclipse_zone:/usr/opt/eclipse# ./build_eclipse.sh


After a long time (on my P3 750Mhz, it takes about 110 minutes), there should be a packaged version of eclipse for solaris x86 with the gtk windowing libraries named /usr/opt/eclipse/result/solaris-gtk-x86-sdk.zip

Keep in mind that you will need to run this version of Eclipse with Java 6, or else you will see a nasty stack trace about the incorrect Java version if you try to launch eclipse. For my own setup, I created a desktop launcher that points to a small wrapper script that looks like this:

#!/bin/sh

export JAVA_HOME=/path/to/jdk1.6.0_02
export PATH=$JAVA_HOME/bin:$PATH
/path/to/eclipse/eclipse

So you should now (hopefully) have a working version of Eclipse on Nexenta.  If you have found this helpful, or if you find any improvements that can be made, please let me know.

Note: since first posting this entry, I have received a good amount of feedback and it has developed into the Solipse project.  I am happy this initial post was useful to a number of people and am happy to keep contributing toward an officially-supported eclipse solaris-gtk-x86 distribution.

No comments: