Constructing an OpenSolaris Distro
By Dave Miner on Dec 10, 2008
Solaris releases, including SXCE, are built using a Sun-internal toolkit known as the CDkit (the name is subtly humorous now that we're no longer releasing CD's for SXCE due to media size issues). It's a complex beast, with requirements for raw disk slices and other odd bits of configuration that make it forbidding to all but the most determined user. That might not seem like a big deal at first glance, but one result of its (earned) reputation is that almost nobody actually builds their own Solaris installation images. Most projects that affect the installation environment end up doing their testing by hand-modifying netinstall images. The predictable, and all too frequent, result over the years has been breakage of the installer as projects or bug fixes were added to the product. When we started work on Caiman, it was clear that a course correction would be required to help us keep a consistent level of quality in the installation software. Our decision to build the OpenSolaris distribution as a redistributable, remixable package base led to the requirement for a construction tool which shared those characteristics, too. Finally, we've long had Solaris customers who needed to build their own customized installation images. That wasn't a function provided by the product, so the need was met with various semi-official blueprint documents with instructions on building derivatives for private use, but this was far from ideal since those would usually lag behind changes to the product.
The starting point for DC was the Live Media toolkit that Moinak and I hacked on as a side project for most of 2006 and 2007, which was derived from his early work on BeleniX. That was really just a single script that could build a live CD or DVD (depending on the list of packages provided to it), and we used a version of it modified to use IPS packages to build the preview releases and the 2008.05 release. Over the summer, DC's development reached the point where it could take over this task, and we switched to it for building the images in September.
The basic function of the DC is pretty simple: given a set of packages as input, produce a bootable, installable media image as output. Flexibility, however, is a requirement, as Sun is no longer intending to build just a single Solaris product out of the source base, but instead a range of related, specialized products, such as xVM Server; there's obvious advantage to sharing tooling across them. And there's the previously-mentioned requirements to support both public and private derivatives. Thus, the core of DC is a build engine that uses an XML recipe to install a set of IPS packages, and then runs a series of steps, known as finalizer scripts (though there's no requirement that they actually be scripts) to transform that basic package image into the various product images, which at this release consist of two different live CD ISO images, corresponding USB flash memory stick images, and an ISO image that's used by the automated installation setup tools to configure an automated installation service.
If you were to ask the developers on the Caiman team to name the single thing they like best about DC, the landslide winner would be its checkpointing feature. Simply, the DC uses ZFS snapshots to save the progress of the construction process at key points along the way, allowing the process to be paused and restarted at the various checkpoints. This is a huge productivity boon for distribution developers because the construction process can be quite time- and resource-intensive, and is a great example of how basic technology like ZFS can be exploited to make other products better in ways that would be difficult, if not impossible, to do without it. The DC is not strictly dependent on ZFS, as it will work on a UFS file system, but in that case you lose checkpoints.
At this point in time the DC is purely a command-line tool, and requires you to edit the XML manifest to customize the produced images. As noted, it's a resource-intensive process: you'll want to have good bandwidth to an IPS package repository, fast processors (at least a dual-core 2 GHz processor), and perhaps 8 GB of disk space for DC's work area. You'll need to start by installing the SUNWdistro-const package, then use the shipped example manifest (/usr/share/distro_const/slim_cd/slim_cd.xml for the primary languages image or /usr/share/distro_const/slim_cd/all_lang_slim_cd.xml for the global image) as a starting point. Note that you'll have to run the distro_const(1M) tool as root in order to successfully construct a distribution. Once you've installed the DC package, you can try building your own copy of the primary languages ISO with the simple command:
$ pfexec distro_const build /usr/share/distro_const/slim_cd/slim_cd.xml
It'll take a while, but if all goes well you'll have your very own OpenSolaris.iso in /rpool/dc/media.
We'll be continuing to develop and enhance DC in future releases; if you're interested in participating, come pitch in on the Caiman project!