UPDATE: I have updated the README.md at https://github.com/omniosorg/omnios-extra with a much more detailed view on building packages for OmniOS and this should be your first port of call, should you be interested in creating packages for OmniOS.

omniosce Logo OmniOS Community Edition is a free and open-source Unix operating system derived from OpenSolaris and based on Illumos. Developers forked OpenSolaris after Oracle Corporation discontinued it, in order to continue development and distribution of the source code. The OmniOSce project is stewarded by the OmniOS Community Edition Association. OmniOSce’s goal is to produce a self-hosting, minimalist Illumos-based release suitable for production deployment.

The Image Packaging System, also known as IPS, is a cross-platform (written in Python) package management system created by the OpenSolaris community in coordination with Sun Microsystems. IPS is designed to eliminate some long-standing issues with previous software distribution, installation, and maintenance mechanisms that have caused significant problems for Solaris users, developers, and maintainers.

Today I will be using the build system for the OmniOS Extra IPS Repository. This allows a convenient and standardized manner to build IPS Packages. I will package the Apache httpd web server as I have been demonstrating in the last two posts.

Setup the Build Environment from the OmniOS Extra Source at Github

Grab the git repo and drop it into a directory of your choice.

cd /var/git
git clone https://github.com/omniosorg/omnios-extra.git

The source contains a file called site.sh.template that can be copied as site.sh and used as an environment for your own publishing environment:

cd omnios-extra/
cp lib/site.sh.template lib/site.sh

Edit the variables; I have set the following to use in my own environment:

PREFIX=/opt/pbdigital
CCACHE_PATH=/opt/pbdigital/ccache/bin
MIRROR=https://pbdigital.org/ips-src
PKGPUBLISHER=pbdigital
PKGSRVR=file:///export/ips-repo
IPS_REPO=file:///export/ips-repo

Note: I am using the IPS repo I setup in the previous post to publish the packages.

Further, the lib/global-tranforms.mog file needs to be edited to represent my environment. I edit all transforms to point to the PREFIX in the site.sh file. This can be accomplished as follows:

mv lib/global-transforms.mog{,.ooce}
sed 's/ooce/pbdigital/g' lib/global-transforms.mog.ooce > lib/global-transforms.mog

Tada! The environment is now set up.

Building Apache Portable Runtime Library

Making the Source Available at $MIRROR Location

Make sure source is available under the $MIRROR set in site.sh. For this example the build.sh will search under https://pbdigital.org/ips-src/apr and also expects to find a sha256 checksum file. For the Apache Portable Runtime source, this will be named apr-1.7.0.tar.bz2.sha256 and the contents should read:

e2e148f0b2e99b8e5c6caa09f6d4fb4dd3e83f744aa72a952f94f5a14436f7ea

Now we can create our build directory:

mkdir omnios-extra/build/apr
cd omnios-extra/build/apr

The build directory needs at least two file, build.sh & local.mog. Viewing these two files should be explanation enough. You can also browse the files in the OmniOS Extra IPS Repository to help you create your own local files.

vi build.sh
vi local.mog

Add Patches

To get the automatic build to work, we need to add any changes that we made manually in the previous posts, as patches. These reside under the patches directory. As well as just copying the patch to the patches directory, we need to create the file series, which contains a list of patches we wish to apply. In this case the following takes care of proc_mutex.c.patch.

mkdir patches
cp proc_mutex.c.patch patches/
echo "proc_mutex.c.patch" >> patches/series

Building Apache Portable Runtime

Now we have all the files in place, the directory structure should look as follows:

# tree apr/
apr/
|-- build.sh
|-- local.mog
`-- patches
    |-- proc_mutex.c.patch
    `-- series

1 directory, 4 files

Time to build! When the build is being published, it needs the permissions of pkg5srv to do so. So before the build I make sure all the permissions are set accordingly and then issue the ./build.sh command as the pkg5srv user.

chown -R pkg5srv:pkg5srv /var/git/omnios-extra
su pkg5srv -c ./build.sh -l

You may receive some warnings through the build but can choose to continue as the package should build correctly. Of note I skip pkglint as I have done these checks manually in the previous posts.

Building Apache Portable Runtime Utilities

This follows exactly as above. The files need for the package are as follows: build.sh, local.mog, apr_crypto.c.patch & configure.patch.

Building Apache httpd Server

The only addition we need to make to the httpd build is that we need to add the SMF Manifest and Method into the files directory:

mkdir files
cp apache24 files/
cp apache24.xml files/

And in the build.sh file, we need to include the install_smf command to install these files and restart the SMF process.

build
strip_install
install_smf network apache24.xml apache24
make_package
clean_up

The files for the httpd build are build.sh, local.mog, apache24 & apache24.xml.

Wrapping Up

This concludes this series on IPS packaging for OmniOS. Happy Hacking!