Tag Archives: pkginfo

Solaris Packaging Basics

This post intends to serve as a basic introduction/guide for Solaris Packages.

Package Basics:
A package is a collection of directories and files needed by a software product to run. A package contains product objects(app files that need to be installed) and control files(information files and installation scripts) that control what goes where and how.

Creating a Package:
To create a Package you need at least three objects namely “pkginfo” & “prototype” files and “package objects”.

pkginfo: contains the meta data for the package like name, desc, and destination for package objects(BASEDIR) it looks like:

NAME=Demo package for solaris

more on creating pkginfo files here

prototype: contains an entry for each package object detailing their destination path, entry(ies) for source path of those objects and an entry for each installation script.
sample prototype file:

i pkginfo=./pkginfo
i preinstall
i postinstall
!search SOURCE_DIR
d none /etc/ 0755 user other
f none /etc/demo-file.conf 0644 user other
f none /etc/demo-file2.conf 0644 user other
d none /var/log/demo-app 0644 user other

Line 1 specifies the path for information and installation files(all files are on same level here).
Line 2 and 3 signify that two scripts namely preinstall and postinstall are to be included in the package and executed before and after installation of package respectively.
Line 4 specifies the directory where the files mentioned in next two lines will be found
Note: The search is limited to the specific directories listed and does not search recursively.
Line 8 will create the directory demo-app in /var/log.
do “pkgproto ./SOURCE_DIR/ > prototype” to create a basic prototype file(replicating SOURCE_DIR’s structure)

more on prototype file here

do “pkgmk -o” to build the package (once built the packages go to “/var/spool/pkg”)

Installing Packages:
login as root and do “pkgadd” and choose the package you need to install.

GZipping Packages:
move to /var/spool/pkg and do
“tar -cf – DemoPackage | gzip -9 -c > DemoPackage.1.pkg.tar.gz”


1) It would be a better option to write a script that generates “pkginfo” & “prototype” files and builds the package.
2) I wrote such a script in python that
a) reads a config file(using ConfigParser) containing meta data for package.
b) calls a shell script that makes the “pkginfo” file using pkgproto command(and parameters sent by py script) and creates a temp prototype file replicating a directory which has all the directories and files that need to be ported.
c) append multiple “!search SOURCE_DIR” to accommodate sub directories(I couldn’t find a cleaner way).
d) make changes to the destination paths for individual files that need to go to custom locations.

1) Official Documentation
2) http://pkgbuild.sourceforge.net/
3) http://www.sunfreeware.com/pkgadd.html
4) http://www.ibiblio.org/pub/packages/solaris/sparc/html/creating.solaris.packages.html
5) http://www.akadia.com/services/solaris_application_packaging.html