martin carpenter


most popular
2012/05/05, updated 2012/12/15
Ubuntu unity lens for vim



tags: ruby gem solaris contents(4)

api documentation
github home
repository URLs


The solaris-contents gem helps with the manipulation of SunOS and Solaris contents entries for SysV packages. Note that the manual page contents(4) states that this interface is declared as unstable although practically speaking this is unlikely to be an issue.

As    shown    above,    the    interface    stability    of
/var/sadm/install/contents  is Unstable (see attributes(5)).
It is common practice to use this file in a read-only manner
to  determine which files belong to which packages installed
on a system. While this  file  has  been  present  for  many
releases  of  the  Solaris operating system, it might not be
present in future  releases.  The  fully  supported  way  to
obtain  information  from  the installed package database is
through pkgchk(1M). It is highly recommended  that  you  use
pkgchk rather than relying on the contents file.

This prescient comment is coming true: Solaris 11 moves to a new packaging format (IPS) and although contents(4) remains on the system and in the manual pages it appears to be unused.

This gem only handles “new style” contents entries. In extensive testing we have not seen any old style entries (these are lines that do not begin with a forward slash, /).

See Errata below from where Oracle’s specification in contents(4) differs from reality.


read and interpret contents(4)

require 'solaris/contents' do |c|
  puts c
  puts c.ftype
  puts c.path
  puts c.rpath
  puts c.install_path
  puts c.packages.inspect
  => /bin=./usr/bin s none SUNWcsr

none 	 [ “SUNWcsr” ]


Testing against a corpus of ~150 contents files revealed the following discrepancies from the specification in the manual pages for contents(4) and pkgmap(4).

multiple packages per entry

Multiple packages are only explicitly stated for ftype d in contents(4). Numerous counterexamples.

installation class name length

pkgmap(4) states that the class name should be “no longer than 12 characters”. Counterexample: “pkcs11confbase”.


pkgadd(1M) writes comments to the tail of the contents file:

# Last modified by pkgadd for SMClintl package
# Tue Sep 20 21:57:16 2011

If the Solaris::Contents#from_line constructor is fed a line like this (or a blank line) then it will return nil.