Making Solaris Packages from Commercial Software

(Another example – this is copied from my regular blog.)

Creating a managed infrastructure can go pretty slowly when you’re beset with a combination of bare competence and a work schedule that’s overrun with non-infrastructural tasks. So yes, it’s been just under a year since I wrote up how to make Debian packages from commercial software. On to getting similar capabilities out of the Solaris systems.

The packages

I already use Blastwave and pkg-get to install third-party free software applications, so I figured it would be easiest to use the same tools on my packaging. So for a first example, I installed Maple 11.00 manually into /opt/maple/11 on a Solaris 10 system. Then I made a temporary working folder and build folder, made an opt folder there, and moved the maple folder from the regular opt to my build folder’s opt. I also made a usr/local/bin in my build folder, and made relative symlinks from the main Maple executables to their assumed homes in usr/local/bin. The abridged results from the temporary working folder looked like this:

# pwd
/root/work/maple11-11.00
# ls -l
total 6
drwxr-xr-x   4 root     root         512 May 22 09:27 build
-rw-r--r--   1 root     root          41 May 21 17:59 copyright
-rw-r--r--   1 root     root           0 May 22 09:36 depend
-rw-r--r--   1 root     root         143 May 22 09:35 pkginfo
# cat copyright
Copyright MapleSoft, All Rights Reserved
# cat pkginfo
PKG=MAPLmaple11
NAME=maple11
VERSION=11.00
ARCH=sun4u
DESC=Interactive computer algebra system
BASEDIR=/
CATEGORY=application
VENDOR=MapleSoft
EMAIL=renfro@tntech.edu
# ls -al build/opt/maple/11
total 504
drwxrwxr-x  17 root     other        512 May 22 08:43 .
drwxrwxr-x   3 root     other        512 May 22 08:42 ..
drwxr-xr-x   2 root     other        512 May 22 08:42 afm
drwxr-xr-x   2 root     other        512 May 22 08:42 bin
drwxr-xr-x   3 root     other       2048 May 22 08:42 bin.SUN_SPARC_SOLARIS
drwxr-xr-x   9 root     other        512 May 22 08:42 data
drwxr-xr-x   2 root     other        512 May 22 08:42 etc
drwxr-xr-x   2 root     other       3072 May 22 08:42 examples
drwxr-xr-x   3 root     other        512 May 22 08:42 extern
-rw-r--r--   1 root     other     153861 May 21 14:12 Install.html
drwxr-xr-x   2 root     other       1536 May 22 08:42 java
drwxrwxr-x   7 root     other        512 May 22 08:42 jre.SUN_SPARC_SOLARIS
drwxr-xr-x   4 root     other       1536 May 22 08:43 lib
drwxr-xr-x   2 root     other        512 May 22 08:43 license
drwxr-xr-x   3 root     other        512 May 22 08:43 man
-rw-rw-r--   1 root     other      60064 May 21 14:15 Maple_11_InstallLog.log
-rw-r--r--   1 root     other      10285 May 21 14:12 readme.txt
drwxr-xr-x   6 root     other        512 May 22 08:43 samples
drwxr-xr-x   2 root     other        512 May 22 08:43 test
drwxr-xr-x   2 root     other        512 May 22 08:42 X11_defaults
# ls -al build/usr/local/bin
total 10
drwxr-xr-x   2 root     root         512 May 22 08:56 .
drwxr-xr-x   3 root     root         512 May 22 08:47 ..
lrwxrwxrwx   1 root     root          31 May 22 08:55 maple11 -> ../../../opt/maple/11/bin/maple
lrwxrwxrwx   1 root     root          30 May 22 08:56 mint11 -> ../../../opt/maple/11/bin/mint
lrwxrwxrwx   1 root     root          32 May 22 08:55 xmaple11 -> ../../../opt/maple/11/bin/xmaple

Now, given that folder structure, I could adapt Blastwave’s package creation instructions to create some workable Solaris packages:

# (echo "i pkginfo"; echo "i copyright" ; echo "i depend" ; cd build ; find . | pkgproto ) > prototype
# pkgmk -b / -a `uname -p`
# filename=maple11-11.00-SunOS`uname -r`-`uname -p`.pkg
# pkgtrans -s /var/spool/pkg /root/$filename MAPLmaple11
# cd /root
# gzip $filename

Once mkpkg is all done with its work, I have a valid maple11-11.00-SunOS5.10-sparc.pkg.gz Solaris package in my /root folder. After testing it with regular pkgadd, I’m ready to put it into a private pkg-get repository.

The pkg-get repository

Compared to a Debian repository, a pkg-get repository is pretty simple. From the top-level folder in the repository on the ftp server:

# find sparc -print
sparc
sparc/5.10
sparc/5.10/maple11-11.00-SunOS5.10-sparc.pkg.gz
sparc/5.10/descriptions
sparc/5.10/catalog

A pkg-get repository’s top-level folders are named by processor type, i.e., the results of uname -p. Each processor type folder contains folders for each OS release level (from uname -r). Each release level folder contains packages for that CPU and OS, plus a descriptions and a catalog file.

The catalog file is created with Phil Brown’s makecontents script. It could potentially handle creating the descriptions, file, too, but I guess he never needed them. But the pkg-get script I got from blastwave.org definitely wants a descriptions file, so I’ll need to create that, too.

The way I’m creating the descriptions file is with the following script (on a Debian ftp server, so there may be some GNU-isms or bash-isms in the following code):

#!/bin/sh
PKG_GET_DIR=/wherever/has/the/sparc/and/i386/folders
cd ${PKG_GET_DIR}
for name in sparc i386; do
    if [ -d $name ]; then
        cd $name
        for version in 5*; do
            if [ -d $version ]; then
                cd $version
                for package in *.gz; do
                    name=`grep $package catalog | awk '{print $1}'`
                    echo -ne "$name - "
                    zcat $package | head | strings | grep DESC= | cut -d= -f2-
                done > descriptions
                cd ..
            fi
        done
        cd ..
    fi
done

which leaves me with a catalog file containing (so far, since I’ve only made one package):

maple11 11.00 MAPLmaple11 maple11-11.00-SunOS5.10-sparc.pkg.gz

and a descriptions file containing:

maple11 - Interactive computer algebra system

And now I can install them on a second host that’s never seen Maple installed before with:

pkg-get -s ftp://host/path/to/repository/ -U ; pkg-get -s ftp://host/path/to/repository/ install maple11

and afterwards get:

# which maple11
/usr/local/bin/maple11
# maple11
    |\\^/|     Maple 11 (SUN SPARC SOLARIS)
._|\\|   |/|_. Copyright (c) Maplesoft, a division of Waterloo Maple Inc. 2007
 \\  MAPLE  /  All rights reserved. Maple is a trademark of
 <____ ____>  Waterloo Maple Inc.
      |       Type ? for help.
> quit
bytes used=412112, alloc=393144, time=0.07


Leave a Reply