Adventures in Building a Web Stack Component
By jyri on Jul 02, 2008
There are several related questions and concerns that I've been hearing in the past two months, which I'll try to address in one combined article:
- How to build a Web Stack component? Sometimes the question is because someone wants to rebuild a component locally for some reason (such as a small configuration change) while still taking advantage of the configuration details and optimizations the Web Stack project has already figured out for that component. At other times the question is because someone wanted to try and contribute some changes to a component so they want to build it to try out their changes.
- How to build a Web Stack component on OpenSolaris? As you may know, the Web Stack components are currently still built on Nevada but most of our users are on OpenSolaris, so how can they build?
- How to build a Web Stack component on VirtualBox? This one has been a popular question at the Tech Days because it turns out virtually everyone - particularly all students who stopped by the installfest - who are trying to become familiar with OpenSolaris are doing so via virtualized installations.
Building a Web Stack Component
Unfortunately the very first roadblock you will face if you want to build one of the Web Stack components (let's say lighttpd) is that it's not possible to do that. Instead, you will have to build all of SFW (in other words, if you only want to build your local copy of lighttpd you will also have to build Apache and MySQL and PHP and everything else). So it's not going to be easy nor quick.
Building a Web Stack Component in VirtualBox
Unfortunately this is not possible at all. VirtualBox does not yet have 64bit support, which is needed by the SFW build. You might wonder why do you need 64bit support if you only want to build one of the many components which is 32bit-only? But see above - it is because you have to build the entire universe of SFW, some of which does include 64bit support.
For the remained of this experiment I had to switch to VMWare Fusion because it does support 64bit.
Building a Web Stack Component on OpenSolaris
Unfortunately no easy answers here either. I spent a fair amount of time playing around with this but haven't succeeded yet. It should certainly be possible but I've run out of time to dedicate to this, so I'll document the steps I took in case anyone wants to give it a try (if you succeed, please do leave a comment with the info!)
1. While setting up the virtual machine for OpenSolaris, keep in mind that you'll need over 10GB for the workspace alone in addition to the OS install and build tools. Because you're stuck having to build the SFW universe instead of just the component you want to build, it's going to take a lot of space. I gave 25GB to the virtual machine. Unfortunately this means that every OpenSolaris install we did at the Sun Tech Days installfests are unable to build Web Stack components since I don't remember anyone having this much disk space to allocate to their virtual machine. Also, don't allocate any less than 1GB of RAM to the virtual machine or you'll be waiting forever for the build to complete.
2. After completing the OpenSolaris installation you'll need a number of additional packages.
% pfexec pkg install SUNWgm4 SUNWgnu-automake-110 SUNWscp \\ SUNWgmake SUNWant SUNWaconf SUNWtoo SUNWxwinc SUNWugenu \\ SUNWgnome-common-devel SUNWsfwhea SUNWxorg-headers SUNWgcc \\ SUNWgnu-idn SUNWflexlex SUNWbison FSWxorgfirstname.lastname@example.org \\ SUNWlibevent SUNWapch SUNWGlib SUNWlibtool SUNWmysql5 SUNWsvn
3. Install JDK5. OpenSolaris includes JDK6 packages but unfortunately the build didn't work for me with it so as a workaround I installed JDK5. Unfortunately this is not available as a package, so you'll have to get it the bad old way: Download it from java.sun.com and install it manually. You'll also need to manually add a softlink /usr/jdk/instances/jdk1.5.0 pointing to the versioned directory where it installs (which is usr/jdk/instances/jdk1.5.0_\*).
4. Install Sun Studio. OpenSolaris has a 'sunstudioexpress' package but it does not work for building SFW so don't install it. Instead, download Sun Studio 11 and install it manually (note it is not a package, just untar it into /opt).
5. Install the ON build tools package ("ON Specific Build Tools" link).
6. Edit your PATH to include /opt/onbld/bin and /opt/SUNWspro
7. Download the source for your component. Once again, this isn't really possible directly, so you'll have to download all of SFW (about 500MB worth) from http://dlc.sun.com/osol/sfw/downloads/current/. Soon there should be a mercurial repository from where you can check out the source tree but for now the tarball is the only way to get it.
8. Set up for building. Untar the source tree and cd into it, then
% cp usr/src/tools/env/sfw-opensolaris.sh .
and then edit sfw-opensolaris.sh and set
CODEMGR_WS = full path to the top directory of the source tree STAFFER = your login uid
9. Unfortunately there are some dependencies in building SFW which are simply not available in OpenSolaris packages yet. So here we hit a wall. In the interest of trying to get the build to work I broke the system (good thing it's just a virtual install) by copying some files over from a Nevada machine. Obviously I don't really recommend doing this but if you don't mind corrupting your installation and want to forge ahead I guess you can try it too. I had to copy these files from a Nevada installation:
/usr/dt/lib/libXm.so.4 /usr/dt/lib/libtt.so.2 /usr/lib/libXaw\* % (cd /usr/include; pfexec rm X11; pfexec ln -s ../X11/include/X11 X11)
10. TBD ... With the above steps most of SFW builds correctly but there are still some broken parts. I've run out of time to investigate it so maybe I'll try again some other week. By the way, you will need a lot of patience to get through that build - even though the build didn't even fully complete, it took over 6 hours (!!!) on my MacBookPro!
Building a component on Debian
After all this pain to [fail to] build one (though it's not possible to build just one) Web Stack component on OpenSolaris, it seems fitting to try the equivalent operation on Debian.
Here's all the steps to build lighttpd and install the freshly-built package:
# apt-get build-dep lighttpd % apt-get source lighttpd % dpkg-buildpackage -rfakeroot -uc -b # dpkg -i lighttdpd_1.4.13-4etch8_i386.deb
Yes that's it. The build took me 1 minute 38 seconds (instead of 6+ hours). I guess the good news is that we have plenty of room for improvement!