Variants appear in the following two places in a package:
A set action names the variant and defines the values that apply to this package.
Any action that can only be installed for a subset of the variant values named in the set action has a tag that specifies the name of the variant and the value on which this action is installed.
One example of a mutually exclusive component is system architecture. Actions can contain multiple tags for different variant names. For example, a package might include both debug and nondebug binaries for both SPARC and x86.
A variant has two parts: its name, and the list of possible values. The pkg variant -v command displays all possible variant values that can be set for installed packages:
$ pkg variant -v VARIANT VALUE arch i386 arch sparc debug.container false debug.container true debug.osnet false debug.osnet true opensolaris.zone global opensolaris.zone nonglobal
IPS supports multiple architectures in a single package by specifying different variant tag values on actions for different architectures. Variant tags are applied to any actions that differ between architectures. Components that are delivered on both SPARC and x86 receive no variant tag. For example, a package that delivers the symbolic link /var/ld/64 might include the following definitions:
set name=variant.arch value=sparc value=i386 dir group=bin mode=0755 owner=root path=var/ld dir group=bin mode=0755 owner=root path=var/ld/amd64 variant.arch=i386 dir group=bin mode=0755 owner=root path=var/ld/sparcv9 variant.arch=sparc link path=var/ld/32 target=. link path=var/ld/64 target=sparcv9 variant.arch=sparc link path=var/ld/64 target=amd64 variant.arch=i386
Another mutually exclusive component is global or non-global zones. Kernel components usually are not included in non-global zones. To prevent kernel components from being installed in a non-global zone, apply the opensolaris.zone variant tag to each of those actions with the value set to global.
Use pkgmogrify rules to apply variant tags in the manifest during publication. Using the pkgmogrify command is described in detail in Modifying Package Manifests Programmatically. Then use pkgmerge to merge packages from SPARC and x86 builds. The pkgmerge command merges across multiple different variants at the same time if needed. See the pkgmogrify(1) and pkgmerge(1) man pages for more information.
Unknown variant property values are false in the image by default. Therefore, if you want to introduce a new variant tag name, the values of that variant can only be true or false. Set the variant tag on the action to true, and inform administrators to use the pkg change-variant command to change the value of the variant property in the image to true to install that action.
Variants whose names start with variant.debug. are false in the image by default. You can provide debug versions of components and tag those components with custom variant.debug. variant tags.