Michael Short at Berkeley first educated me on the basic steps to create a pkgadd format software package. Here I will add to his steps and try to make them as clear as I can. No doubt, there are more sophisticated or general ways to do this, but I will not attempt anything harder here. Comments are welcome.
There now exists a detailed discussion of the packaging process in the Answerbook 2 on the Solaris 2.6 CD or on the Application Packaging Developer's Guide . See also and article on-line at Inside Solaris. Check them out. I will add updates to this basic process on the FAQ as I learn them.
Find the source code to the package you want to compile. Read all the installation and other instructions carefully. In particular look at the Makefile and understand which executables are created and how they are linked to other executables and libraries. Also figure out exactly what parts of the compiled code, libraries, include files, data, etc. are required to run the program. Some programs require other programs in order to run. You will have to find that software and package it also. Find the documentation, README, Copyright, manual, and any other files that might be of use to your end users.
As difficult and unpleasant as this is to do, read the man pages for at least the following commands:
pkgadd, pkginfo, pkgmk, pkgparam, pkgproto, pkgtrans, pkgrm
There are a lot of options and details that you might need to know beyond what I will describe here.
Typically, we set up a directory in the /opt directory to contain
our package. For illustration, we will install a ficticious
program called
I next go into /opt/SCprog and create the subdirectories - lets say bin, doc, man, lib - needed by the program.
You now must get your program to compile and run. Be careful to test things like the help files which often do not get installed properly so that the main program can find them. Once this is done, you can move the files into the /opt/SCprog/bin, etc. directories. I put all documentation and other instructional files into the doc subdirectory and the manual pages into the man subdirectory. If you need a lib directory, an examples directory, or a data directory, you can create those also and put the appropriate files there. It is very important to remember that if your Makefile links the executable to files in a related subdirectory, then that directory will need to be established at compile time. You will need to edit the Makefile to indicate that you will be putting the files in /opt/SCprog subdirectories. My simple test example has subdirectories and files:
SCprog: bin doc lib man SCprog/bin: prog SCprog/doc: doc1 SCprog/lib: lib1 SCprog/man: man1(where
Go into the /opt/SCprog directory with
and run the command
This will produce the
Now take your editor and edit out the line that has the prototype file name in it. Then add a line like
on the first line.
Finally, convert all the user and group ownerships from whatever they are to bin and bin. An example file looks like
i pkginfo=/opt/SCprog/pkginfo d none bin 0755 bin bin f none bin/prog 0755 bin bin d none doc 0755 bin bin f none doc/doc1 0644 bin bin d none lib 0755 bin bin f none lib/lib1 0644 bin bin d none man 0755 bin bin f none man/man1 0644 bin binIt is very important that you change the ownerships. The program might not work when installed if owned by another user. Not changing these properly is one of the most common problems we have encountered.
Now in /opt/SCprog create a file
PKG="SCprog" NAME="prog" ARCH="Solaris 2.5" VERSION="1.00" CATEGORY="application" VENDOR="Christensen and Associates, Inc." EMAIL="steve@smc.vnet.net" PSTAMP="Steve Christensen" BASEDIR="/opt/SCprog" CLASSES="none"These values are fairly obvious, but they mean
PKG = the name you have chosen for the package directory
NAME = the program name
ARCH = the operating system version
VERSION = the version number for your program
CATEGORY = the program is an application
VENDOR = whoever wrote the software
EMAIL = an email contact
PSTAMP = the person who did the port perhaps
BASEDIR = the /opt directory you have created
CLASSES = just put none here
Now while in /opt/SCprog, run
This places a file in /var/spool/pkg called SCprog.
Now do
and then
which creates a file called
Now run
in /tmp to produce the gzipped version
I usually test the
to get back prog-1.00. Then running as root user, I do
and follow the instructions to create the /opt/SCprog. You can then put /opt/SCprog/bin into your UNIX path or make the executables and man pages available in whatever way you typically choose.
If you have any problems with this technique, please study the man pages for the pkg programs above or contact your local UNIX guru. Please report any successes or failures in your understanding of these instructions.
Good luck and happy packaging.
Steve Christensen
Send comments or questions to steve@smc.vnet.net