Application Packaging Developer's Guide

Package Environment Variables

You can use variables in the required information files, pkginfo and prototype, as well as an option to the pkgmk command (which is used to build a package). As each of these files and commands are discussed in this chapter, more context-sensitive information on variables is provided. However, before you begin building your package, you should understand the different types of variables and how they can affect a package's successful creation.

There are two types of variables:

General Rules on Using Environment Variables

In the pkginfo file, a variable definition is of the form PARAM=value, where the first letter of PARAM is an uppercase letter. These variables are evaluated only at install time, and if any cannot be evaluated, the pkgadd command will abort with an error.

In the prototype file, a variable definition can take the form !PARAM=value or $variable. Both PARAM and variable can begin with either an uppercase or lowercase letter; however, only variables whose values are known at build time will be evaluated. This means that if PARAM or variable is a build or install variable whose value is not known at build time, the pkgmk command will abort with an error.

You can also include the option PARAM=value as an option to the pkgmk command. This option works the same as in the prototype file, except that its scope is global to the entire package. The !PARAM=value definition in a prototype file is local to that file and the part of the package it defines.

If PARAM is an install variable, and variable is an install or build variable with a known value, the pkgmk command inserts the definition into the pkginfo file so that it will be available at install time. However, it will not evaluate PARAM in any path names specified in the prototype file.

Package Environment Variables Summary

The table below summarizes variable specification formats, location, and scope.

Table 2–2 Package Environment Variables Summary

Variable Defined In The ... 

Variable Definition Format 

Variable Type Being Defined 

When The Variable Is Resolved 

Where The Variable Is Resolved 

The Variable May Be Used As Part Of The ... 

pkginfo file

PARAM=value

Build 

Ignored at build time 

N/A 

None 

Install 

Install time 

In the pkgmap file

owner, group, path, or link target

prototype file

!PARAM=value

Build 

Build time 

In the prototype file and any included files

mode, owner, group, or path

Install 

Build time 

In the prototype file and any included files

!search and !command commands only

pkgmk command line

PARAM=value

Build 

Build time 

In the prototype file

mode, owner, group, or path

Install 

Build time 

In the prototype file

!search command only

Install time 

In the pkgmap file

owner, group, path, or link target