Application Packaging Developer's Guide

Adding Functionality to a prototype File

Besides defining every package object in the prototype file, you can also:

See the following sections for information on making these changes.

Defining Additional Objects to Be Created at Install Time

You can use the prototype file to define objects that are not actually delivered on the installation medium. During installation, using the pkgadd command, these objects are created with the required file types, if they do not already exist at the time of installation.

To specify that an object be created on the target system, add an entry for it in the prototype file with the appropriate file type.

For example, if you want a directory created on the target system, but do not want to deliver it on the installation medium, make the following entry for the directory in the prototype file:

d none /directory 0644 root other

If you want to create an empty file on the target system, an entry for the file in the prototype file might look like:

f none filename=/dev/null 0644 bin bin

The only objects that must be delivered on the installation medium are regular files and edit scripts (file types e, v, f) and the directories required to contain them. Any additional objects are created without reference to the delivered objects, directories, named pipes, devices, hard links, and symbolic links.

Creating Links at Install Time

To create links during package installation, define the following in the prototype file entry for the linked object:

Relative links would be specified in this manner whether the package is installed as absolute or relocatable.

Distributing Packages Over Multiple Volumes

When you build your package with the pkgmk command, it performs the calculations and actions necessary to organize a multiple volume package. A multiple volume package is called a segmented package.

However, you can use the optional part field in the prototype file to define in which part you want an object to be located. A number in this field overrides the pkgmk command and forces the placement of the component into the part given in the field. Note that there is a one-to-one correspondence between parts and volumes for removable media formatted as file systems. If the volumes are preassigned by the developer, the pkgmk command will issue an error if there is insufficient space on any volume.

Nesting prototype Files

You can create multiple prototype files and then include them, using the !include command in the prototype file. You might want to do this for easier maintenance.

In the following example there are three prototype files, the main one (prototype) being edited, and the two (proto2 and proto3) that are being included.

!include /source-dir/proto2
!include /source-dir/proto3

Setting Default Values for the mode, owner, and group Fields

To set default values for the mode, owner, and group fields for specific package objects, you can insert the !default command into the prototype file. For example,

!default 0644 root other

Note –

This command's range starts from where it is inserted and extends to the end of the file, but does not span to included files.

However, for directories (file type d) and editable files (file type e) that you know exist on target systems (like /usr or /etc/vfstab), make sure that the mode, owner, and group fields in the prototype file are set to question marks (?). That way you will not destroy existing settings that a site administrator may have modified.

Providing a Search Path for the pkgmk Command

If the source location for package objects is different than their destination location, and you do not want to use the path1=path2 format as described in A Brief Word on an Object's Source and Destination Locations, then you can use the !search command in the prototype file. For example, if you created a directory, pkgfiles, in your home directory, and it contains all of your information files and installation scripts, you can specify that that directory be searched when the package is built with the pkgmk command.

The command in the prototype file would look like:

!search /home-dir/pkgfiles

Note –

Search requests do not span to included files. In addition, a search is limited to the specific directories listed, and will not search recursively.

Set Environment Variables

You can also add commands to the prototype file of the form !PARAM=value. Commands of this form define variables in the current environment. If you have multiple prototype files, the scope of this command is local to the prototype file where it is defined.

The variable PARAM can begin with either a lowercase or uppercase letter, but its value must be known at build time, or the pkgmk command will abort with an error. For more information on the difference between build and install variables, see Package Environment Variables.