<chapter id="ch2buildpkg-22939"><title>Building a Package</title><highlights><para>This chapter describes the process and the tasks involved in building a package.
Some of these tasks are required. Some of these tasks are optional. The required tasks
are discussed in detail in this chapter. For information on the optional tasks, which
enable you to add more features to your package, see <olink targetptr="ch3enhancepkg-11350" remap="internal">Chapter&nbsp;3, Enhancing the Functionality of a Package (Tasks)</olink> and <olink targetptr="ch6advtech-96543" remap="internal">Chapter&nbsp;6, Advanced Techniques for Creating Packages</olink>.</para><para>This is a list of the information in this chapter.</para><itemizedlist><listitem><para><olink targetptr="ch2buildpkg-30163" remap="internal">The Process of Building a Package
(Task Map)</olink></para>
</listitem><listitem><para><olink targetptr="ch2buildpkg-13952" remap="internal">Package Environment Variables</olink></para>
</listitem><listitem><para><olink targetptr="ch2buildpkg-11300" remap="internal">Creating a pkginfo File</olink></para>
</listitem><listitem><para><olink targetptr="ch2buildpkg-26363" remap="internal">Organizing a Package's Contents</olink></para>
</listitem><listitem><para><olink targetptr="ch2buildpkg-16803" remap="internal">Creating a prototype File</olink></para>
</listitem><listitem><para><olink targetptr="ch2buildpkg-17051" remap="internal">Building a Package</olink></para>
</listitem>
</itemizedlist>
</highlights><sect1 id="ch2buildpkg-30163"><title>The Process of Building a Package (Task Map)</title><para><indexterm><primary>building a package</primary><secondary>the process</secondary></indexterm><olink targetptr="ch2buildpkg-tbl-55" remap="internal">Table&nbsp;2&ndash;1</olink> describes
a process for you to follow when building packages, especially if you are inexperienced
at building them. Although it is not mandatory for you to complete the first four
tasks in the exact order listed, your package building experience will be easier if
you do. Once you are an experienced package designer, you can shuffle the sequence
of these tasks to your preference.</para><para>As an experienced package designer, you can automate the package building process
by using the <command>make</command> command and makefiles. For more information,
see the <olink targetdoc="refman1" targetptr="make-1s" remap="external"><citerefentry><refentrytitle>make</refentrytitle><manvolnum>1S</manvolnum></citerefentry></olink> man page.</para><table frame="all" pgwide="1" id="ch2buildpkg-tbl-55"><title>The Process of Building
a Package Task Map</title><tgroup cols="3" colsep="1" rowsep="1"><colspec colwidth="110*"/><colspec colname="col2" colwidth="167*"/><colspec colwidth="119*"/><thead><row><entry><para>Task</para>
</entry><entry><para>Description</para>
</entry><entry><para>For Instructions</para>
</entry>
</row>
</thead><tbody><row><entry><para>1. Create a <filename>pkginfo</filename> file</para>
</entry><entry><para>Create the <filename>pkginfo</filename> file to describe the characteristics
of the package.</para>
</entry><entry><para><olink targetptr="ch2buildpkg-62" remap="internal">How to Create a pkginfo File</olink></para>
</entry>
</row><row><entry><para>2. Organize package contents</para>
</entry><entry><para>Arrange the package components into a hierarchical directory structure.</para>
</entry><entry><para><olink targetptr="ch2buildpkg-26363" remap="internal">Organizing a Package's Contents</olink></para>
</entry>
</row><row><entry><para>3. (optional) Create information files</para>
</entry><entry><para>Define package dependencies, include a copyright message, and reserve additional
space on the target system.</para>
</entry><entry><para><olink targetptr="ch3enhancepkg-11350" remap="internal">Chapter&nbsp;3, Enhancing the Functionality
of a Package (Tasks)</olink></para>
</entry>
</row><row><entry><para>4. (optional) Create installation scripts</para>
</entry><entry><para>Customize the installation and removal processes of the package.</para>
</entry><entry><para><olink targetptr="ch3enhancepkg-11350" remap="internal">Chapter&nbsp;3, Enhancing the Functionality
of a Package (Tasks)</olink></para>
</entry>
</row><row><entry><para>5. Create a <filename>prototype</filename> file</para>
</entry><entry><para>Describe the object in your package in a <filename>prototype</filename> file.</para>
</entry><entry><para><olink targetptr="ch2buildpkg-16803" remap="internal">Creating a prototype File</olink></para>
</entry>
</row><row><entry><para>6. Build the package</para>
</entry><entry><para>Build the package by using the <filename>pkgmk</filename> command.</para>
</entry><entry><para><olink targetptr="ch2buildpkg-17051" remap="internal">Building a Package</olink></para>
</entry>
</row><row><entry><para>7. Verify and transfer the package</para>
</entry><entry><para>Verify the integrity of the package before copying it to a distribution medium.</para>
</entry><entry><para><olink targetptr="ch4verifypkg-18395" remap="internal">Chapter&nbsp;4, Verifying and Transferring
a Package</olink></para>
</entry>
</row>
</tbody>
</tgroup>
</table>
</sect1><sect1 id="ch2buildpkg-13952"><title>Package Environment Variables</title><para><indexterm><primary><command>pkgmk</command> command</primary><secondary>package environment variables</secondary></indexterm><indexterm><primary>package</primary><secondary>environment variables</secondary></indexterm><indexterm><primary><filename>pkginfo</filename> file</primary><secondary>using environment variables in</secondary></indexterm><indexterm><primary><filename>prototype</filename> file</primary><secondary>using environment variables in</secondary></indexterm>You can use variables in the
required information files, <filename>pkginfo</filename> and <filename>prototype</filename>.
You can also use an option to the <command>pkgmk</command> command, which is used
to build a package. As 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 the successful creation of a package.</para><para>There are two types of variables:</para><itemizedlist><listitem><para><indexterm><primary>build variable</primary><secondary>description</secondary></indexterm>Build variables </para><para><indexterm><primary>build time</primary></indexterm><firstterm>Build variables</firstterm> begin with a lowercase
letter and are evaluated at <firstterm>build time</firstterm>, as the package is being
built with the <command>pkgmk</command> command. </para>
</listitem><listitem><para><indexterm><primary>install variable</primary><secondary>description</secondary></indexterm>Install variables </para><para><indexterm><primary>install time</primary></indexterm><firstterm>Install variables</firstterm> begin with an uppercase
letter and are evaluated at <firstterm>install time</firstterm>, as the package is
being installed with the <command>pkgadd</command> command.</para>
</listitem>
</itemizedlist><sect2 id="ch2buildpkg-59"><title>General Rules on Using Environment Variables</title><para>In the <filename>pkginfo</filename> file, a variable definition takes the form <replaceable>PARAM=value</replaceable>, where the first letter of <replaceable>PARAM</replaceable> is
an uppercase letter. These variables are evaluated only at install time. If any of
these variables cannot be evaluated, the <command>pkgadd</command> command aborts
with an error.</para><para>In the <filename>prototype</filename> file, a variable definition can take the
form <literal>!</literal><replaceable>PARAM=value</replaceable> or <literal>$</literal><replaceable>variable</replaceable>. Both <replaceable>PARAM</replaceable> and <replaceable>variable</replaceable> can begin with either an uppercase or a lowercase letter. Only variables
whose values are known at build time are evaluated. If <replaceable>PARAM</replaceable> or <replaceable>variable</replaceable> is a build or install variable whose value is not known at
build time, the <command>pkgmk</command> command aborts with an error. </para><para>You can also include the option <replaceable>PARAM=value</replaceable> as an
option to the <command>pkgmk</command> command. This option works the same as in the <filename>prototype</filename> file, except that its scope is global to the entire package.
The <literal>!</literal><replaceable>PARAM=value</replaceable> definition in a <filename>prototype</filename> file is local to that file and the part of the package it defines.</para><para>If <replaceable>PARAM</replaceable> is an install variable, and <replaceable>variable</replaceable> is an install variable or build variable with a known value,
the <command>pkgmk</command> command inserts the definition into the <filename>pkginfo</filename> file so that the definition will be available at install time. However,
the <command>pkgmk</command> command does not evaluate <replaceable>PARAM</replaceable> that
are in any path names that are specified in the <filename>prototype</filename> file.</para>
</sect2><sect2 id="ch2buildpkg-58"><title>Package Environment Variables Summary</title><para>The following table summarizes variable specification formats, location, and
scope.</para><table frame="topbot" pgwide="1" id="ch2buildpkg-tbl-56"><title>Package Environment
Variables Summary</title><tgroup cols="6" colsep="1" rowsep="1"><colspec colname="col1" colwidth="64*"/><colspec colwidth="79*"/><colspec colname="col3" colwidth="63*"/><colspec colname="col4" colwidth="63*"/><colspec colwidth="63*"/><colspec colname="col6" colwidth="64*"/><thead><row><entry><para>Where Variable Is Defined</para>
</entry><entry><para>Variable Definition Format</para>
</entry><entry><para>Variable Type Being Defined</para>
</entry><entry><para>When the Variable is Evaluated</para>
</entry><entry><para>Where the Variable is Evaluated</para>
</entry><entry><para>Items the VariableMay Substitute For</para>
</entry>
</row>
</thead><tbody><row><entry><para><filename>pkginfo</filename> file</para>
</entry><entry><para><replaceable>PARAM=value</replaceable></para>
</entry><entry><para>Build</para>
</entry><entry><para>Ignored at build time</para>
</entry><entry><para>N/A</para>
</entry><entry><para>None</para>
</entry>
</row><row><entry><para>Install</para>
</entry><entry><para>Install time</para>
</entry><entry><para>In the <filename>pkgmap</filename> file</para>
</entry><entry><para><replaceable>owner</replaceable>, <replaceable>group</replaceable>,  <replaceable>path</replaceable>, or link target</para>
</entry><entry><para></para>
</entry><entry><para></para>
</entry>
</row><row><entry><para><filename>prototype</filename> file</para>
</entry><entry><para><literal>!</literal><replaceable>PARAM=value</replaceable></para>
</entry><entry><para>Build</para>
</entry><entry><para>Build time</para>
</entry><entry><para>In the <filename>prototype</filename> file and any included files</para>
</entry><entry><para><replaceable>mode</replaceable>, <replaceable>owner</replaceable>, <replaceable>group</replaceable>, or <replaceable>path</replaceable></para>
</entry>
</row><row><entry><para>Install</para>
</entry><entry><para>Build time</para>
</entry><entry><para>In the <filename>prototype</filename> file and any included files</para>
</entry><entry><para><command>!search</command> and <command>!command</command> commands only</para>
</entry><entry><para></para>
</entry><entry><para></para>
</entry>
</row><row><entry><para><command>pkgmk</command> command line</para>
</entry><entry><para><replaceable>PARAM=value</replaceable></para>
</entry><entry><para>Build</para>
</entry><entry><para>Build time</para>
</entry><entry><para>In the <filename>prototype</filename> file</para>
</entry><entry><para><replaceable>mode</replaceable>, <replaceable>owner</replaceable>, <replaceable>group</replaceable>, or <replaceable>path</replaceable></para>
</entry>
</row><row><entry><para>Install</para>
</entry><entry><para>Build time</para>
</entry><entry><para>In the <filename>prototype</filename> file</para>
</entry><entry><para><command>!search</command> command only</para>
</entry><entry><para></para>
</entry><entry><para></para>
</entry>
</row><row><entry><para>Install time</para>
</entry><entry><para>In the <filename>pkgmap</filename> file</para>
</entry><entry><para><replaceable>owner</replaceable>, <replaceable>group</replaceable>, <replaceable>path</replaceable>, or link target</para>
</entry><entry><para></para>
</entry><entry><para></para>
</entry><entry><para></para>
</entry>
</row>
</tbody>
</tgroup>
</table>
</sect2>
</sect1><sect1 id="ch2buildpkg-11300"><title>Creating a <filename>pkginfo</filename> File</title><para><indexterm><primary><filename>pkginfo</filename> file</primary><secondary>creating a</secondary></indexterm><indexterm><primary><filename>pkginfo</filename> file</primary><secondary>description</secondary></indexterm>The <filename>pkginfo</filename> file
is an ASCII file that describes the characteristics of a package along with information
that helps control the flow of installation.</para><para>Each entry in the <filename>pkginfo</filename> file is a line that establishes
the value of a parameter using the format <replaceable>PARAM=value</replaceable>. <replaceable>PARAM</replaceable> can be any of the  standard parameters described in the <olink targetdoc="refman4" targetptr="pkginfo-4" remap="external"><citerefentry><refentrytitle>pkginfo</refentrytitle><manvolnum>4</manvolnum></citerefentry></olink> man page. There is no required order
in which the parameters must be specified.</para><note><para>Each <replaceable>value</replaceable> can be enclosed with single or double
quotation marks (for example, '<replaceable>value</replaceable>' or &ldquo;<replaceable>value</replaceable>&rdquo;). If <replaceable>value</replaceable> contains any characters
that are considered special to a shell environment, you should use quotation marks.
The examples and case studies in this book do not use quotation marks. See the <olink targetdoc="refman4" targetptr="pkginfo-4" remap="external"><citerefentry><refentrytitle>pkginfo</refentrytitle><manvolnum>4</manvolnum></citerefentry></olink> man page for an example that uses
double quotation marks.</para>
</note><para>You can also create your own package parameters by assigning a value to them
in the <filename>pkginfo</filename> file. Your parameters must begin with a capital
letter followed by either uppercase or lowercase letters. An uppercase letter indicates
that the parameter (variable) will be evaluated at install time (as opposed to build
time). For information on the difference between install variables and build variables,
see <olink targetptr="ch2buildpkg-13952" remap="internal">Package Environment Variables</olink>.</para><note><para>Trailing whitespace after any parameter value is ignored.</para>
</note><para><indexterm><primary><filename>pkginfo</filename> file</primary><secondary>required parameters</secondary></indexterm>You must define these five parameters in a <filename>pkginfo</filename> file: <envar>PKG</envar>, <envar>NAME</envar>, <envar>ARCH</envar>, <envar>VERSION</envar>, and <envar>CATEGORY</envar>. The <envar>PATH</envar>, <envar>PKGINST</envar>, and <envar>INSTDATE</envar> parameters are inserted automatically by the
software when the package is built. Do not modify these eight parameters. For information
on the remaining parameters, see the <olink targetdoc="refman4" targetptr="pkginfo-4" remap="external"><citerefentry><refentrytitle>pkginfo</refentrytitle><manvolnum>4</manvolnum></citerefentry></olink> man
page.</para><sect2 id="ch2buildpkg-1"><title>Defining a Package Instance</title><para><indexterm><primary>package instance</primary><secondary>description</secondary></indexterm>The same package can have different versions, be compatible with different
architectures, or both. Each variation of a package is known as a <firstterm>package
instance</firstterm>. A package instance is determined by combining the definitions
of the <envar>PKG</envar>, <envar>ARCH</envar>, and <envar>VERSION</envar> parameters
in the <filename>pkginfo</filename> file.</para><para><indexterm><primary>package identifier</primary><secondary>description</secondary></indexterm><indexterm><primary><command>pkgadd</command> command</primary><secondary>and package identifiers</secondary></indexterm>The <command>pkgadd</command> command
assigns a <firstterm>package identifier</firstterm> to each package instance at installation
time. The package identifier is the package abbreviation with a numerical suffix,
for example <literal>SUNWadm.2</literal>. This identifier distinguishes a package
instance from any other package, including instances of the same package.</para><sect3 id="ch2buildpkg-2"><title>Defining a Package Abbreviation (<envar>PKG</envar>)</title><para><indexterm><primary>package abbreviation</primary><secondary>description</secondary></indexterm>A <firstterm>package abbreviation</firstterm> is a short name for a package
that is defined by the <envar>PKG</envar> parameter in the <filename>pkginfo</filename> file.
A package abbreviation must have these characteristics:</para><itemizedlist><listitem><para><indexterm><primary>package abbreviation</primary><secondary>requirements</secondary></indexterm>The abbreviation must consist of alphanumeric characters.
The first character cannot be a number.</para>
</listitem><listitem><para>The abbreviation cannot exceed 32 characters in length.</para>
</listitem><listitem><para>The abbreviation cannot be one of the reserved abbreviations: <literal>install</literal>, <literal>new</literal>, or <literal>all</literal>.</para><note><para>The first four characters should be unique to your company, such as your
company's stock symbol. For example, packages built by <trademark>Sun Microsystems</trademark> all have &ldquo;SUNW&rdquo; as the first four characters of their package
abbreviation.</para>
</note><para>This is an example package abbreviation entry in a <filename>pkginfo</filename> file:</para><screen>PKG=SUNWcadap</screen>
</listitem>
</itemizedlist>
</sect3><sect3 id="ch2buildpkg-3"><title>Specifying a Package Architecture (<envar>ARCH</envar>)</title><para>The <envar>ARCH</envar> parameter in the <filename>pkginfo</filename> file identifies
which architectures are associated with the package. The architecture name has a maximum
length of 16 alphanumeric characters. If a package is associated with more than one
architecture, specify the architectures in a comma-separated list.</para><para>This is an example of a package architecture specification in a <filename>pkginfo</filename> file:</para><screen>ARCH=sparc</screen>
</sect3><sect3 id="ch2buildpkg-35"><title>Specifying a Package Instruction Set Architecture
(<envar>SUNW_ISA</envar>)</title><para>The <envar>SUNW_ISA</envar> parameter in the <filename>pkginfo</filename> file
identifies which instruction set architecture is associated with a Sun Microsystems
package. The values are as follows:</para><itemizedlist><listitem><para><literal>sparcv9</literal>, for a package that contains 64&ndash;bit
objects</para>
</listitem><listitem><para><literal>sparc</literal>, for a package that contains 32&ndash;bit
objects</para>
</listitem>
</itemizedlist><para>For example, the <envar>SUNW_ISA</envar> value in a <filename>pkginfo</filename> file
for a package containing 64&ndash;bit objects would be:</para><screen>SUNW_ISA=sparcv9</screen><para>If <envar>SUNW_ISA</envar> is not set, the default instruction set architecture
of the package is set to the value of the <envar>ARCH</envar> parameter.</para>
</sect3><sect3 id="ch2buildpkg-4"><title>Specifying a Package Version (<envar>VERSION</envar>)</title><para>The <envar>VERSION</envar> parameter in the <filename>pkginfo</filename> file
identifies the version of the package. The version has a maximum length of 256 ASCII
characters, and cannot begin with a left parenthesis.</para><para>This is an example version of a specification in a <filename>pkginfo</filename> file:</para><screen>VERSION=release 1.0</screen>
</sect3>
</sect2><sect2 id="ch2buildpkg-5"><title>Defining a Package Name (<envar>NAME</envar>)</title><para>A <emphasis>package name</emphasis> is the full name of the package, which is
defined by the <envar>NAME</envar> parameter in the <filename>pkginfo</filename> file.</para><para>Because system administrators often use package names to determine whether a
package needs to be installed, writing clear, concise, and complete package names
is important. Package names must meet the following criteria:</para><itemizedlist><listitem><para>State when a package is needed (for example, to provide certain commands
or functionality, or state if the package is needed for specific hardware).</para>
</listitem><listitem><para>State what the package is used for (for example, the development of
device drivers).</para>
</listitem><listitem><para>Include a description of the package abbreviation mnemonic, using
key words that indicate the abbreviation is a short form of the description. For example,
the package name for the package abbreviation <literal>SUNWbnuu</literal> is &ldquo;Basic
Networking UUCP Utilities, (Usr)&rdquo; .</para>
</listitem><listitem><para>Name the partition into which the package is installed.</para>
</listitem><listitem><para>Use terms consistently with their industry meaning.</para>
</listitem><listitem><para>Take advantage of the 256&ndash;character limit.</para>
</listitem>
</itemizedlist><para>Here is an example package name defined in a <filename>pkginfo</filename> file:</para><screen>NAME=Chip designers need CAD application software to design
abc chips.  Runs only on xyz hardware and is installed in the
usr partition.</screen>
</sect2><sect2 id="ch2buildpkg-6"><title>Defining a Package Category (<envar>CATEGORY</envar>)</title><para>The <envar>CATEGORY</envar> parameter in the <filename>pkginfo</filename> file
specifies in which categories a package belongs. At a minimum, a package must belong
to either the <literal>system</literal> or <literal>application</literal> category.
Category names consist of alphanumeric characters. Category names have a maximum length
of 16 characters and are case insensitive.</para><para>If a package belongs to more than one category, specify the categories in a
comma-separated list.</para><para>Here is an example <envar>CATEGORY</envar> specification in a <filename>pkginfo</filename> file:</para><screen>CATEGORY=system</screen>
</sect2><task id="ch2buildpkg-62"><title>How to Create a <filename>pkginfo</filename> File</title><procedure><step id="ch2buildpkg-step-8"><para>Using your favorite text editor, create a file
named <filename>pkginfo</filename>.</para><para><indexterm><primary><filename>pkginfo</filename> file</primary><secondary>how to create</secondary></indexterm>You can
create this file anywhere on your system.</para>
</step><step id="ch2buildpkg-step-9"><para>Edit the file and define the five required parameters.</para><para>The five required parameters are: <envar>PKG</envar>, <envar>NAME</envar>, <envar>ARCH</envar>, <envar>VERSION</envar>, and <envar>CATEGORY</envar>. For more information
on these parameters, see <olink targetptr="ch2buildpkg-11300" remap="internal">Creating a pkginfo File</olink>.</para>
</step><step id="ch2buildpkg-step-10"><para>Add any optional parameters to the file.</para><para>Create your own parameters or see the <olink targetdoc="refman4" targetptr="pkginfo-4" remap="external"><citerefentry><refentrytitle>pkginfo</refentrytitle><manvolnum>4</manvolnum></citerefentry></olink> man
page for information on the standard parameters.</para>
</step><step id="ch2buildpkg-step-11"><para>Save your changes and quit the editor.</para>
</step>
</procedure><example id="ch2buildpkg-13"><title>Creating a <filename>pkginfo</filename> File</title><para><indexterm><primary><filename>pkginfo</filename> file</primary><secondary>example</secondary></indexterm>This example
shows the contents of a valid <filename>pkginfo</filename> file, with the five required
parameters defined, as well as the <envar>BASEDIR</envar> parameter. The <envar>BASEDIR</envar> parameter is discussed in more detail in <olink targetptr="ch2buildpkg-16793" remap="internal">The path Field</olink>.</para><screen>PKG=SUNWcadap
NAME=Chip designers need CAD application software to design abc chips.  
Runs only on xyz hardware and is installed in the usr partition.
ARCH=sparc
VERSION=release 1.0
CATEGORY=system
BASEDIR=/opt</screen>
</example><taskrelated role="see-also"><para>See <olink targetptr="ch2buildpkg-63" remap="internal">How to Organize a Package's Contents</olink>.</para>
</taskrelated>
</task>
</sect1><sect1 id="ch2buildpkg-26363"><title>Organizing a Package's Contents</title><para><indexterm><primary>package</primary><secondary>organization</secondary></indexterm>Organize
your package objects in a hierarchical directory structure that mimics the structure
that the package objects will have on the target system after installation. If you
do this step before you create a <filename>prototype</filename> file, you can save
yourself some time and effort when creating that file.</para><task id="ch2buildpkg-63"><title>How to Organize a Package's Contents</title><procedure><step id="ch2buildpkg-step-15"><para><indexterm><primary>package</primary><secondary>how to organize</secondary></indexterm>Determine how many packages you need to create
and which package objects shall be located in each package.</para><para>For help in
completing this step, see <olink targetptr="ch1designpkg-28244" remap="internal">Considerations Before
Building a Package</olink>.</para>
</step><step id="ch2buildpkg-step-16"><para>Create a directory for each package you need
to build.</para><para>You can create this directory anywhere on your system and name
it anything you like. The examples in this chapter assume that a package directory
has the same name as the package abbreviation.</para><screen>$ <userinput>cd /home/jane</userinput>
$ <userinput>mkdir SUNWcadap</userinput></screen>
</step><step id="ch2buildpkg-step-17"><para>Organize the package objects in each package
into a directory structure beneath their corresponding package directory. The directory
structure must mimic the structure that the package objects will have on the target
system.</para><para>For example, the CAD application package, <literal>SUNWcadap</literal>,
requires the following directory structure.</para><mediaobject><imageobject><imagedata entityref="OrgPkg"/>
</imageobject><textobject><simpara>Diagram shows teh structure of the SUNWcadap package directory.</simpara>
</textobject>
</mediaobject>
</step><step id="ch2buildpkg-step-57"><para>Decide where you will keep your information files.
If appropriate, create a directory to keep the files in one location.</para><para>This example assumes that the example <filename>pkginfo</filename> file from <olink targetptr="ch2buildpkg-62" remap="internal">How to Create a pkginfo File</olink> was created in Jane's
home directory.</para><screen>$ <userinput>cd /home/jane</userinput>
$ <userinput>mkdir InfoFiles</userinput>
$ <userinput>mv pkginfo InfoFiles</userinput></screen>
</step>
</procedure><taskrelated role="see-also"><para>See <olink targetptr="ch2buildpkg-64" remap="internal">How to Create a prototype File by Using
the pkgproto Command</olink>.</para>
</taskrelated>
</task>
</sect1><sect1 id="ch2buildpkg-16803"><title>Creating a <filename>prototype</filename> File</title><para><indexterm><primary><filename>prototype</filename> file</primary><secondary>creating</secondary></indexterm><indexterm><primary><filename>prototype</filename> file</primary><secondary>description</secondary></indexterm>The <filename>prototype</filename> file
is an ASCII file used to specify information about the objects in a package. Each
entry in the <filename>prototype</filename> file describes a single object, such as
a data file, directory, source file, or executable object. Entries in a <filename>prototype</filename> file consist of several fields of information separated by white
space. Note that the fields <emphasis>must</emphasis> appear in a specific order.
Comment lines begin with a pound sign (#) and are ignored.</para><para><indexterm><primary><command>pkgproto</command> command</primary><secondary>creating a <filename>prototype</filename> file</secondary></indexterm>You can create
a <filename>prototype</filename> file with a text editor or by using the <command>pkgproto</command> command. When you first create this file, it is probably easier
to do so with the <command>pkgproto</command> command, because it creates the file
based on the directory hierarchy you created previously. If you have not organized
your files as described in <olink targetptr="ch2buildpkg-26363" remap="internal">Organizing a Package's
Contents</olink>, you have the cumbersome task of creating the <filename>prototype</filename> file from scratch with your favorite text editor.</para><sect2 id="ch2buildpkg-10912"><title>Format of the <filename>prototype</filename> File</title><para><indexterm><primary><filename>prototype</filename> file</primary><secondary>format of</secondary></indexterm>Here is the format for each line in the <filename>prototype</filename> file:</para><screen><replaceable>part</replaceable><replaceable>ftype</replaceable><replaceable>class</replaceable><replaceable>path</replaceable><replaceable>major</replaceable><replaceable>minor</replaceable><replaceable>mode</replaceable><replaceable>owner</replaceable><replaceable>group</replaceable></screen><informaltable frame="none"><tgroup cols="2" colsep="0" rowsep="0"><colspec colname="column1" colwidth="132*"/><colspec colname="column2" colwidth="264*"/><tbody><row><entry><para><replaceable>part</replaceable> </para>
</entry><entry><para>Is an optional, numeric field that enables you to group package objects into
parts. The default value is part 1.</para>
</entry>
</row><row><entry><para><replaceable>ftype</replaceable> </para>
</entry><entry><para>Is a one-character field that specifies the object's type. See <olink targetptr="ch2buildpkg-19" remap="internal">The ftype Field</olink>.</para>
</entry>
</row><row><entry><para><replaceable>class</replaceable> </para>
</entry><entry><para>Is the installation class to which the object belongs. See <olink targetptr="ch2buildpkg-21" remap="internal">The class Field</olink>.</para>
</entry>
</row><row><entry><para><replaceable>path</replaceable> </para>
</entry><entry><para>Is the absolute or relative path name indicating where the package object will
reside on the target system. See <olink targetptr="ch2buildpkg-16793" remap="internal">The path Field</olink>.</para>
</entry>
</row><row><entry><para><replaceable>major</replaceable> </para>
</entry><entry><para>Is the major device number for block or character special devices.</para>
</entry>
</row><row><entry><para><replaceable>minor</replaceable> </para>
</entry><entry><para>Is the minor device number for block or character special devices.</para>
</entry>
</row><row><entry><para><replaceable>mode</replaceable> </para>
</entry><entry><para>Is the octal mode of the object (for example, 0644). See <olink targetptr="ch2buildpkg-22" remap="internal">The mode Field</olink>.</para>
</entry>
</row><row><entry><para><replaceable>owner</replaceable> </para>
</entry><entry><para>Is the owner of the object (for example, <literal>bin</literal> or <literal>root</literal>). See <olink targetptr="ch2buildpkg-23" remap="internal">The owner Field</olink>.</para>
</entry>
</row><row><entry><para><replaceable>group</replaceable> </para>
</entry><entry><para>Is the group to which the object belongs (for example, <literal>bin</literal> or <literal>sys</literal>). See <olink targetptr="ch2buildpkg-24" remap="internal">The group Field</olink>.</para>
</entry>
</row>
</tbody>
</tgroup>
</informaltable><para>Usually, only the <replaceable>ftype</replaceable>, <replaceable>class</replaceable>, <replaceable>path</replaceable>, <replaceable>mode</replaceable>, <replaceable>owner</replaceable>,
and <replaceable>group</replaceable> fields are defined. These fields are described
in the following sections. See the <olink targetdoc="refman4" targetptr="prototype-4" remap="external"><citerefentry><refentrytitle>prototype</refentrytitle><manvolnum>4</manvolnum></citerefentry></olink> man
page for additional information on these fields.</para><sect3 id="ch2buildpkg-19"><title>The ftype Field</title><para><indexterm><primary><filename>prototype</filename> file</primary><secondary>valid file types</secondary></indexterm>The <replaceable>ftype</replaceable>, or file
type, field is a one-character field that specifies a package object's file type.
Valid file types are described in the following table</para><table frame="topbot" id="ch2buildpkg-tbl-20"><title>Valid File Types in the <filename>prototype</filename> File</title><tgroup cols="2" colsep="0" rowsep="0"><colspec colname="column1" colwidth="113*"/><colspec colname="column2" colwidth="283*"/><thead><row rowsep="1"><entry><para>File type field value</para>
</entry><entry><para>File Type Description</para>
</entry>
</row>
</thead><tbody><row><entry><para><literal>f</literal> </para>
</entry><entry><para>Standard executable file or data file</para>
</entry>
</row><row><entry><para><literal>e</literal> </para>
</entry><entry><para>File to be edited upon installation or removal (may be shared by several packages)</para>
</entry>
</row><row><entry><para><literal>v</literal> </para>
</entry><entry><para>Volatile file (whose contents are expected to change, such as a log file)</para>
</entry>
</row><row><entry><para><literal>d</literal> </para>
</entry><entry><para>Directory</para>
</entry>
</row><row><entry><para><literal>x</literal> </para>
</entry><entry><para>Exclusive directory accessible only by this package (may contain unregistered
logs or database information)</para>
</entry>
</row><row><entry><para><literal>l</literal> </para>
</entry><entry><para>Linked file</para>
</entry>
</row><row><entry><para><literal>p</literal> </para>
</entry><entry><para>Named pipe</para>
</entry>
</row><row><entry><para><literal>c</literal> </para>
</entry><entry><para>Character special device</para>
</entry>
</row><row><entry><para><literal>b</literal> </para>
</entry><entry><para>Block special device</para>
</entry>
</row><row><entry><para><literal>i</literal> </para>
</entry><entry><para>Information file or installation script</para>
</entry>
</row><row><entry><para><literal>s</literal> </para>
</entry><entry><para>Symbolic link</para>
</entry>
</row>
</tbody>
</tgroup>
</table>
</sect3><sect3 id="ch2buildpkg-21"><title>The <replaceable>class</replaceable> Field</title><para><indexterm><primary>object classes</primary></indexterm>The <firstterm>class</firstterm> field names the class to which an object belongs. Using classes is an
optional package design feature. This feature is discussed in detail in <olink targetptr="ch3enhancepkg-37319" remap="internal">Writing Class Action Scripts</olink>. </para><para><indexterm><primary><command>pkgmk</command> command</primary><secondary>class field</secondary></indexterm>If you do not use classes, an object belongs to the <literal>none</literal> class. When you execute the <command>pkgmk</command> command to build
your package, the command inserts the <envar>CLASSES=none</envar> parameter in the <filename>pkginfo</filename> file. Files with file type <literal>i</literal> must have a blank <replaceable>class</replaceable> field.</para>
</sect3><sect3 id="ch2buildpkg-16793"><title>The <replaceable>path</replaceable> Field</title><para><indexterm><primary>relocatable object</primary></indexterm><indexterm><primary>package</primary><secondary>object</secondary><tertiary>relocatable</tertiary></indexterm><indexterm><primary>package</primary><secondary>object</secondary><tertiary>path names</tertiary></indexterm>The <replaceable>path</replaceable> field is used to define where the
package object will reside on the target system. You may indicate the location with
either an absolute path name (for example, <filename>/usr/bin/mail</filename>) or
a relative path name (for example, <filename>bin/mail</filename>). Using an absolute
path name means that the object's location on the target system is defined by the
package and cannot be changed. Package objects with relative path names indicate that
the object is <firstterm>relocatable</firstterm>.</para><para>A <firstterm>relocatable object</firstterm> does not need an absolute path location
on the target system. Instead, the object's location is determined during the installation
process.</para><para>All or some of a package's objects can be defined as relocatable. Before writing
any installation scripts or creating the <filename>prototype</filename> file, decide
if package objects will have fixed locations (such as start-up scripts in <filename>/etc</filename>) or be relocatable .</para><para><indexterm><primary>collectively relocatable object</primary></indexterm><indexterm><primary>individually relocatable object</primary></indexterm>There are two kinds
of relocatable objects, <firstterm>collectively relocatable</firstterm> and <firstterm>individually relocatable</firstterm>.</para><sect4 id="ch2buildpkg-33395"><title>Collectively Relocatable Objects</title><para><indexterm><primary>base directory</primary></indexterm><indexterm><primary>package</primary><secondary>base directory</secondary></indexterm><indexterm><primary>collectively relocatable object</primary></indexterm>Collectively relocatable objects
are located relative to a common installation base called the <firstterm>base directory</firstterm>. A base directory is defined in the <filename>pkginfo</filename> file,
using the <envar>BASEDIR</envar> parameter. For example, a relocatable object in the <filename>prototype</filename> file named <filename>tests/generic</filename> requires that the <filename>pkginfo</filename> file define the default <envar>BASEDIR</envar> parameter. For example:</para><screen>BASEDIR=/opt</screen><para>This example means that when the object is installed, it will be located in
the <filename>/opt/tests/generic</filename> directory.</para><note><para>The <filename>/opt</filename> directory is the only directory to which
software that is not part of the base Solaris software may be delivered.</para>
</note><para>Use collectively relocatable objects whenever possible. In general, the major
part of a package can be relocatable with a few files (such as files in <filename>/etc</filename> or <filename>/var</filename>) specified as absolute. However, if a
package contains many different relocations, consider dividing the package into multiple
packages with distinct <envar>BASEDIR</envar> values in their <filename>pkginfo</filename> files.</para>
</sect4><sect4 id="ch2buildpkg-39047"><title>Individually Relocatable Objects</title><para><indexterm><primary>individually relocatable object</primary></indexterm>Individually
relocatable objects are not restricted to the same directory location as collectively
relocatable objects. To define an individually relocatable object, you need to specify
an install variable in the <replaceable>path</replaceable> field in the <filename>prototype</filename> file. After specifying the install variable, create a <filename>request</filename> script to prompt the installer for the relocatable base directory,
or a <filename>checkinstall</filename> script to determine the path name from file
system data. For more information on <filename>request</filename> scripts, see <olink targetptr="ch3enhancepkg-21209" remap="internal">Writing a request Script</olink> and for information
on <filename>checkinstall</filename> scripts, see <olink targetptr="ch3enhancepkg-120" remap="internal">How to Gather File System Data</olink>.</para><caution><para>Individually relocatable objects are difficult to manage. Use of individually
relocatable objects might result in widely scattered package components that are difficult
to isolate when installing multiple versions or architectures of the package. Use
collectively relocatable objects whenever possible.</para>
</caution>
</sect4><sect4 id="ch2buildpkg-55"><title>Parametric Path Names</title><para><indexterm><primary>parametric path name</primary><secondary>description</secondary></indexterm>A <firstterm>parametric path name</firstterm> is a path name that includes
a variable specification. For example, <literal>/opt/$PKGINST/</literal><replaceable>filename</replaceable> is a parametric path name because of the <literal>$PKGINST</literal> variable specification. A default value for the variable specification <emphasis>must</emphasis> be defined in the <filename>pkginfo</filename> file. The value may
then be changed by a <filename>request</filename> script or a <filename>checkinstall</filename> script.</para><para>A variable specification in a path must begin or end the path name, or be bounded
by slashes (/). Valid parametric path names take the following form:</para><screen>$PARAM/tests
tests/$PARAM/generic
/tests/$PARAM</screen><para>The variable specification, once defined, may cause the path to be evaluated
as absolute or relocatable. In the following example, the <filename>prototype</filename> file
contains this entry:</para><screen>f none $DIRLOC/tests/generic</screen><para>The <filename>pkginfo</filename> file contains this entry:</para><screen>DIRLOC=/myopt</screen><para>The path name <literal>$DIRLOC/tests/generic</literal> evaluates to the absolute
path name <literal>/myopt/tests/generic</literal>, regardless of whether the <envar>BASEDIR</envar> parameter is set in the <filename>pkginfo</filename> file.</para><para>In this example, the <filename>prototype</filename> file is identical to the
one in the previous example and the <filename>pkginfo</filename> file contains the
following entries:</para><screen>DIRLOC=firstcut
BASEDIR=/opt</screen><para>The path name <literal>$DIRLOC/tests/generic</literal> will evaluate to the
relocatable path name <literal>/opt/firstcut/tests/generic</literal>.</para><para>For more information on parametric path names, see <olink targetptr="ch6advtech-39" remap="internal">Using Parametric Base Directories</olink>.</para>
</sect4><sect4 id="ch2buildpkg-18286"><title>A Brief Word on an Object's Source and Destination
Locations</title><para><indexterm><primary>package</primary><secondary>object</secondary><tertiary>path names</tertiary></indexterm>The <emphasis>path</emphasis> field in the <filename>prototype</filename> file defines where the object will be located on the target system.
Specify the present location of the package's objects in the <filename>prototype</filename> file
if their directory structure does not mimic the intended structure on the target system.
See <olink targetptr="ch2buildpkg-26363" remap="internal">Organizing a Package's Contents</olink> for
more information on structuring objects in a package.</para><para>If your development area is not structured in the same way that you want your
package structured, you can use the <replaceable>path1=path2</replaceable> format
in the <replaceable>path</replaceable> field. In this format, <replaceable>path1</replaceable> is
the location the object should have on the target system, and <replaceable>path2</replaceable> is
the location the object has on your system.</para><para>You can also use the <replaceable>path1=path2</replaceable> path name format
with <replaceable>path1</replaceable> as a relocatable object name and <replaceable>path2</replaceable> as a full path name to that object on your system. </para><note><para><replaceable>path1</replaceable> may not contain undefined build variables,
but may contain undefined install variables. <replaceable>path2</replaceable> may
not contain any undefined variables, although both build variables and install variables
may be used. For information on the difference between install variables and build
variables, see <olink targetptr="ch2buildpkg-13952" remap="internal">Package Environment Variables</olink>.</para>
</note><para><indexterm><primary>links</primary><secondary>defining in a <filename>prototype</filename> file</secondary></indexterm>Links must use the <replaceable>path1= path2</replaceable> format because they are created by the <command>pkgadd</command> command.
As a general rule, <replaceable>path2</replaceable> of a link should never be absolute,
but should instead be relative to the directory portion of <replaceable>path1</replaceable>.</para><para>An option to using the <replaceable>path1=path2</replaceable> format is to use
the <command>!search</command> command. For more information, see <olink targetptr="ch2buildpkg-13783" remap="internal">Providing a Search Path for the pkgmk Command</olink>.</para>
</sect4>
</sect3><sect3 id="ch2buildpkg-22"><title>The <replaceable>mode</replaceable> Field</title><para>The <replaceable>mode</replaceable> field may contain an octal number, a question
mark (<literal>?</literal>), or a variable specification. An octal number specifies
the mode of the object when it is installed on the target system. A <literal>?</literal> means
that the mode will be unchanged as the object is installed, implying that the object
of the same name already exists on the target system.</para><para>A variable specification of the form <literal>$</literal><replaceable>mode</replaceable>,
where the first letter of the variable must be a lowercase letter, means that this
field will be set as the package is built. Note that this variable must be defined
at build time in either the <filename>prototype</filename> file or as an option to
the <command>pkgmk</command> command. For information on the difference between install
variables and build variables, see <olink targetptr="ch2buildpkg-13952" remap="internal">Package Environment
Variables</olink>.</para><para>Files with file type <literal>i</literal> (information file), <literal>l</literal> (hard
link), and <literal>s</literal> (symbolic link) should leave this field blank.</para>
</sect3><sect3 id="ch2buildpkg-23"><title>The <replaceable>owner</replaceable> Field</title><para>The <replaceable>owner</replaceable> field may contain a user name, a question
mark (<literal>?</literal>), or a variable specification. A user name has a maximum
of 14 characters and should be a name that already exists on the target system (such
as <literal>bin</literal> or <literal>root</literal>). A <literal>?</literal> means
that the owner will be unchanged as the object is installed, implying that the object
of the same name already exists on the target system. </para><para>A variable specification can be of the form <literal>$</literal><replaceable>Owner</replaceable> or <literal>$</literal><replaceable>owner</replaceable>, where
the first letter of the variable is either an uppercase letter or a lowercase letter.
If the variable begins with a lowercase letter, it must be defined as the package
is built, either in the <filename>prototype</filename> file or as an option to the <command>pkgmk</command> command. If the variable begins with an uppercase letter, the variable
specification will be inserted into the <filename>pkginfo</filename> file as a default
value, and may be redefined at install time by a <filename>request</filename> script.
For information on the difference between install variables and build variables, see <olink targetptr="ch2buildpkg-13952" remap="internal">Package Environment Variables</olink>.</para><para>Files with file type <literal>i</literal> (information file) and <literal>l</literal>b (hard link) should leave this field blank.</para>
</sect3><sect3 id="ch2buildpkg-24"><title>The <replaceable>group</replaceable> Field</title><para>The <replaceable>group </replaceable>field may contain a group name, a question
mark (<literal>?</literal>), or a variable specification. A group name has a maximum
of 14 characters and should be a name that already exists on the target system (such
as, <literal>bin</literal> or <literal>sys</literal>). A <literal>?</literal> means
that the group will be unchanged as the object is installed, implying that the object
of the same name already exists on the target system.</para><para>A variable specification can be of the form <literal>$</literal><replaceable>Group</replaceable> or <literal>$</literal><replaceable>group</replaceable>, where
the first letter of the variable is either an uppercase letter or a lowercase letter.
If the variable begins with a lowercase letter, it must be defined as the package
is built, either in the <filename>prototype</filename> file or as an option to the <command>pkgmk</command> command. If the variable begins with an uppercase letter, the variable
specification will be inserted into the <filename>pkginfo</filename> file as a default
value, and may be redefined at install time by a <filename>request</filename> script.
For information on the difference between install variables and build variables, see <olink targetptr="ch2buildpkg-13952" remap="internal">Package Environment Variables</olink>.</para><para>Files with file type <literal>i</literal> (information file) and <literal>l</literal> (hard link) should leave this field blank.</para>
</sect3>
</sect2><sect2 id="ch2buildpkg-12289"><title>Creating a <filename>prototype</filename> File
From Scratch</title><para><indexterm><primary><filename>prototype</filename> file</primary><secondary>creating a</secondary><tertiary>from scratch</tertiary></indexterm>If you want to
create a <filename>prototype</filename> file from scratch, you can do so with your
favorite text editor, adding one entry per package object. See <olink targetptr="ch2buildpkg-10912" remap="internal">Format of the prototype File</olink> and the <olink targetdoc="refman4" targetptr="prototype-4" remap="external"><citerefentry><refentrytitle>prototype</refentrytitle><manvolnum>4</manvolnum></citerefentry></olink> man
page for more information on the format of this file. However, after you have defined
each package object, you might want to include some of the features described in <olink targetptr="ch2buildpkg-31278" remap="internal">Adding Functionality to a prototype File</olink>.</para>
</sect2><sect2 id="ch2buildpkg-35610"><title>Example&mdash;Creating a <filename>prototype</filename> File With the <command>pkgproto</command> Command</title><para><indexterm><primary><filename>prototype</filename> file</primary><secondary>creating a</secondary><tertiary>with the <command>pkgproto</command> command</tertiary></indexterm>You can use the <command>pkgproto</command> command to build a basic <filename>prototype</filename> file, as long as you have organized your package directory structure
as described in <olink targetptr="ch2buildpkg-26363" remap="internal">Organizing a Package's Contents</olink>. For example, using the sample directory structure and <filename>pkginfo</filename> file described in previous sections, the commands for creating the <filename>prototype</filename> file are as follows:</para><screen>$ <userinput>cd /home/jane</userinput>
$ <userinput>pkgproto ./SUNWcadap &gt; InfoFiles/prototype</userinput></screen><para>The <filename>prototype</filename> file looks like the following:</para><programlisting role="complete">d none SUNWcadap 0755 jane staff
d none SUNWcadap/demo 0755 jane staff
f none SUNWcadap/demo/file1 0555 jane staff
d none SUNWcadap/srcfiles 0755 jane staff
f none SUNWcadap/srcfiles/file5 0555 jane staff
f none SUNWcadap/srcfiles/file6 0555 jane staff
d none SUNWcadap/lib 0755 jane staff
f none SUNWcadap/lib/file2 0644 jane staff
d none SUNWcadap/man 0755 jane staff
f none SUNWcadap/man/windex 0644 jane staff
d none SUNWcadap/man/man1 0755 jane staff
f none SUNWcadap/man/man1/file4.1 0444 jane staff
f none SUNWcadap/man/man1/file3.1 0444 jane staff</programlisting><note><para>The actual owner and group of the person building the package is recorded
by the <filename>pkgproto</filename> command. A good technique is to use the <command>chown -R</command> and the <command>chgrp -R</command> commands, setting the owner
and group as intended <emphasis>before</emphasis> running the <filename>pkgproto</filename> command.</para>
</note><para>This example <filename>prototype</filename> file is not complete. See the following
section for information on completing this file.</para>
</sect2><sect2 id="ch2buildpkg-40414"><title>Fine-Tuning a <filename>prototype</filename> File
Created With the <command>pkgproto</command> Command</title><para><indexterm><primary><filename>prototype</filename> file</primary><secondary>fine-tuning a</secondary></indexterm>Although the <command>pkgproto</command> command
is useful in creating an initial <filename>prototype</filename> file, it does not
create entries for every package object that needs to be defined. This command does
not make complete entries. The <command>pkgproto</command> command does not do any
of the following:</para><itemizedlist><listitem><para>Create complete entries for objects with file types <literal>v</literal> (volatile
files), <literal>e</literal> (editable files),  <literal>x</literal> (exclusive directories),
or <literal>i</literal> (information files or installation scripts)</para>
</listitem><listitem><para>Support multiple classes with a single invocation</para>
</listitem>
</itemizedlist><sect3 id="ch2buildpkg-25"><title>Creating Object Entries With File Types <literal>v</literal>, <literal>e</literal>, <literal>x</literal>, and <literal>i</literal></title><para>At the very least, you need to modify the <filename>prototype</filename> file
to add objects with file type <literal>i</literal>. If you stored your information
files and installation scripts in the first level of your package directory (for example, <filename>/home/jane/SUNWcadap/pkginfo</filename>), then an entry in the <filename>prototype</filename> file would look like the following:</para><screen>i pkginfo</screen><para>If you did not store your information files and installation scripts in the
first level of your package directory, then you need to specify their source location.
For example:</para><screen>i pkginfo=/home/jane/InfoFiles/pkginfo</screen><para><indexterm><primary><command>pkgmk</command> command</primary><secondary>information files and installation script locations</secondary></indexterm>Or, you can use the <command>!search</command> command to specify the location for the <command>pkgmk</command> command
to look when building the package. See <olink targetptr="ch2buildpkg-13783" remap="internal">Providing
a Search Path for the pkgmk Command</olink> for more information.</para><para>To add entries for objects with file types <literal>v</literal>, <literal>e</literal>, and <literal>x</literal>, follow the format described in <olink targetptr="ch2buildpkg-10912" remap="internal">Format of the prototype File</olink>, or refer to the <olink targetdoc="refman4" targetptr="prototype-4" remap="external"><citerefentry><refentrytitle>prototype</refentrytitle><manvolnum>4</manvolnum></citerefentry></olink> man
page.</para><note><para>Remember to always assign a class to files with a file type of <literal>e</literal> (editable) and have an associated class action script for that class.
Otherwise, the files will be removed during package removal, even if the path name
is shared with other packages. </para>
</note>
</sect3><sect3 id="ch2buildpkg-26"><title>Using Multiple Class Definitions</title><para>If you use the <command>pkgproto</command> command to create your basic <filename>prototype</filename> file, you can assign all the package objects to the <literal>none</literal> class or to one, specific class. As shown in <olink targetptr="ch2buildpkg-35610" remap="internal">Example&mdash;Creating a prototype File With the pkgproto Command</olink>, the basic <command>pkgproto</command> command assigns all objects to the <literal>none</literal> class.
To assign all objects to a specific class, you can use the <option>c</option> option.
For example:</para><screen>$ <userinput>pkgproto -c <replaceable>classname</replaceable> /home/jane/SUNWcadap &gt; /home/jane/InfoFiles/prototype</userinput></screen><para>If you use multiple classes, you might need to manually edit the <filename>prototype</filename> file and modify the <replaceable>class</replaceable> field for
each object. If you use classes, you also need to define the <envar>CLASSES</envar> parameter
in the <filename>pkginfo</filename> file and write class action scripts. Using classes
is an optional feature and is discussed in detail in <olink targetptr="ch3enhancepkg-37319" remap="internal">Writing Class Action Scripts</olink>.</para>
</sect3><sect3 id="ch2buildpkg-27"><title>Example&mdash;Fine-Tuning a <filename>prototype</filename> File Created Using the <command>pkgproto</command> Command</title><para><indexterm><primary><filename>prototype</filename> file</primary><secondary>fine-tuning a</secondary><tertiary>example</tertiary></indexterm>Given the <filename>prototype</filename> file created by the <command>pkgproto</command> command in <olink targetptr="ch2buildpkg-35610" remap="internal">Example&mdash;Creating a prototype File With the pkgproto
Command</olink>, several modifications need to be made.</para><itemizedlist><listitem><para>There needs to be an entry for the <filename>pkginfo</filename> file.</para>
</listitem><listitem><para>The <replaceable>path</replaceable> fields need to be changed to the <replaceable>path1=path2</replaceable> format because the package source is in <filename>/home/jane</filename>. Since the package source is a hierarchical directory, and the <command>!search</command> command does not search recursively, it might be easier to use the <replaceable>path1=path2</replaceable> format.</para>
</listitem><listitem><para>The <replaceable>owner</replaceable> and <replaceable>group</replaceable> fields
should contain the names of existing users and groups on the target system. That is,
the owner <literal>jane</literal> will result in an error because this owner is not
part of the <trademark>SunOS</trademark> operating system.</para><para>The modified <filename>prototype</filename> file looks like the following:</para><programlisting width="100" role="complete">i pkginfo=/home/jane/InfoFiles/pkginfo
d none SUNWcadap=/home/jane/SUNWcadap 0755 root sys
d none SUNWcadap/demo=/home/jane/SUNWcadap/demo 0755 root bin
f none SUNWcadap/demo/file1=/home/jane/SUNWcadap/demo/file1 0555 root bin
d none SUNWcadap/srcfiles=/home/jane/SUNWcadap/srcfiles 0755 root bin
f none SUNWcadap/srcfiles/file5=/home/jane/SUNWcadap/srcfiles/file5 0555 root bin
f none SUNWcadap/srcfiles/file6=/home/jane/SUNWcadap/srcfiles/file6 0555 root bin
d none SUNWcadap/lib=/home/jane/SUNWcadap/lib 0755 root bin
f none SUNWcadap/lib/file2=/home/jane/SUNWcadap/lib/file2 0644 root bin
d none SUNWcadap/man=/home/jane/SUNWcadap/man 0755 bin bin
f none SUNWcadap/man/windex=/home/jane/SUNWcadap/man/windex 0644 root other
d none SUNWcadap/man/man1=/home/jane/SUNWcadap/man/man1 0755 bin bin
f none SUNWcadap/man/man1/file4.1=/home/jane/SUNWcadap/man/man1/file4.1 0444 bin bin
f none SUNWcadap/man/man1/file3.1=/home/jane/SUNWcadap/man/man1/file3.1 0444 bin bin</programlisting>
</listitem>
</itemizedlist>
</sect3>
</sect2><sect2 id="ch2buildpkg-31278"><title>Adding Functionality to a <filename>prototype</filename> File</title><para><indexterm><primary><filename>prototype</filename> file</primary><secondary>adding functionality to</secondary></indexterm>Besides defining every package object
in the <filename>prototype</filename> file, you can also do the following:</para><itemizedlist><listitem><para>Define additional objects to be created at install time.</para>
</listitem><listitem><para>Create links at install time.</para>
</listitem><listitem><para>Distribute packages over multiple volumes.</para>
</listitem><listitem><para>Nest <filename>prototype</filename> files.</para>
</listitem><listitem><para>Set a default value for the <replaceable>mode</replaceable>, <replaceable>owner</replaceable>, and <replaceable>group</replaceable> fields.</para>
</listitem><listitem><para>Provide a search path for the <command>pkgmk</command> command.</para>
</listitem><listitem><para>Set environment variables.</para>
</listitem>
</itemizedlist><para>See the following sections for information on making these changes.</para><sect3 id="ch2buildpkg-28"><title>Defining Additional Objects to Be Created at Install
Time</title><para><indexterm><primary><filename>prototype</filename> file</primary><secondary>adding functionality to</secondary><tertiary>creating objects at install time</tertiary></indexterm>You can use the <filename>prototype</filename> file to define objects
that are not actually delivered on the installation medium. During installation, using
the <command>pkgadd</command> command, these objects are created with the required
file types, if they do not already exist at the time of installation.</para><para>To specify that an object be created on the target system, add an entry for
it in the <filename>prototype</filename> file with the appropriate file type. </para><para>For example, if you want a directory created on the target system, but do not
want to deliver it on the installation medium, add the following entry for the directory
in the <filename>prototype</filename> file:</para><screen>d none /<replaceable>directory</replaceable> 0644 root other</screen><para>If you want to create an empty file on the target system, an entry for the file
in the <filename>prototype</filename> file might look like the following:</para><screen>f none <replaceable>filename</replaceable>=/dev/null 0644 bin bin</screen><para>The only objects that <emphasis>must</emphasis> be delivered on the installation
medium are regular files and edit scripts (file types <literal>e</literal>, <literal>v</literal>, <literal>f</literal>) 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.</para>
</sect3><sect3 id="ch2buildpkg-29"><title>Creating Links at Install Time</title><para><indexterm><primary><filename>prototype</filename> file</primary><secondary>adding functionality to</secondary><tertiary>creating links at install time</tertiary></indexterm><indexterm><primary>links</primary><secondary>defining in a <filename>prototype</filename> file</secondary></indexterm>To create links during package installation,
define the following in the <filename>prototype</filename> file entry for the linked
object: </para><itemizedlist><listitem><para>Its file type as <literal>l</literal> (a link) or <literal>s</literal> (a
symbolic link). </para>
</listitem><listitem><para>The linked object's path name with the format <replaceable>path1=path2</replaceable> where <replaceable>path1</replaceable> is the destination and <replaceable>path2</replaceable> is the source file. As a general rule, <replaceable>path2</replaceable> of
a link should never be absolute, but should instead be relative to the directory portion
of <replaceable>path1</replaceable>. For example, a <filename>prototype</filename> file
entry that defines a symbolic link could be as follows: </para><screen>s none etc/mount=../usr/etc/mount</screen>
</listitem>
</itemizedlist><para>Relative links would be specified in this manner whether the package is installed
as absolute or relocatable. </para>
</sect3><sect3 id="ch2buildpkg-30"><title>Distributing Packages Over Multiple Volumes</title><para><indexterm><primary><command>pkgmk</command> command</primary><secondary>multiple volume packages</secondary></indexterm><indexterm><primary><filename>prototype</filename> file</primary><secondary>adding functionality to</secondary><tertiary>distributing packages over multiple volumes</tertiary></indexterm>When you build your package with the <command>pkgmk</command> command, the command performs the calculations and actions necessary
to organize a multiple volume package.  A multiple volume package is called a <firstterm>segmented package</firstterm>.</para><para>However, you can use the optional <replaceable>part</replaceable> field in the <filename>prototype</filename> file to define which part you want an object to be located. A
number in this field overrides the <command>pkgmk</command> command and forces the
placement of the component into the part given in the field. Note that a one-to-one
correspondence exists between parts and volumes for removable media formatted as file
systems. If the volumes are preassigned by the developer, the <command>pkgmk</command> command
issues an error if there is insufficient space on any volume.</para>
</sect3><sect3 id="ch2buildpkg-31"><title>Nesting <filename>prototype</filename> Files</title><para><indexterm><primary><filename>prototype</filename> file</primary><secondary>adding functionality to</secondary><tertiary>nesting <filename>prototype</filename> files</tertiary></indexterm>You can create multiple <filename>prototype</filename> files
and then include them by using the <command>!include</command> command in the <filename>prototype</filename> file. You might want to nest files for easier maintenance.</para><para>In the following example there are three <filename>prototype</filename> files.
The main file (<literal>prototype</literal>) is being edited. The other two files
(<literal>proto2</literal> and <literal>proto3</literal>) are being included. </para><screen>!include /<replaceable>source-dir</replaceable>/proto2
!include /<replaceable>source-dir</replaceable>/proto3</screen>
</sect3><sect3 id="ch2buildpkg-32"><title>Setting Default Values for the <replaceable>mode</replaceable>, <replaceable>owner</replaceable>, and <replaceable>group</replaceable> Fields</title><para><indexterm><primary><filename>prototype</filename> file</primary><secondary>adding functionality to</secondary><tertiary>setting default values</tertiary></indexterm>To
set default values for the <replaceable>mode</replaceable>, <replaceable>owner</replaceable>,
and <replaceable>group</replaceable> fields for specific package objects, you can
insert the <literal>!</literal><command>default</command> command into the <filename>prototype</filename> file. For example:</para><screen>!default 0644 root other</screen><note><para>The <literal>!</literal><command>default</command> command's range starts
from where it is inserted and extends to the end of the file. The command's range
does not span to included files.</para>
</note><para>However, for directories (file type <literal>d</literal>) and editable files
(file type <literal>e</literal>) that you know exist on target systems (like <filename>/usr</filename> or <filename>/etc/vfstab</filename>), make sure that the <replaceable>mode</replaceable>, <replaceable>owner</replaceable>, and <replaceable>group</replaceable> fields
in the <filename>prototype</filename> file are set to question marks (<literal>?</literal>).
That way you will not destroy existing settings that a site administrator may have
modified.</para>
</sect3><sect3 id="ch2buildpkg-13783"><title>Providing a Search Path for the <command>pkgmk</command> Command</title><para>If the source location for package objects is different than their destination
location, and you do not want to use the <replaceable>path1=path2</replaceable> format
as described in <olink targetptr="ch2buildpkg-18286" remap="internal">A Brief Word on an Object's Source
and Destination Locations</olink>, then you can use the <command>!search</command> command
in the <filename>prototype</filename> file.</para><para><indexterm><primary><command>pkgmk</command> command</primary><secondary>providing a search path</secondary></indexterm><indexterm><primary><filename>prototype</filename> file</primary><secondary>adding functionality to</secondary><tertiary>specifying a search path</tertiary></indexterm>For example, if you created a directory, <literal>pkgfiles</literal>, in your home directory, and it contains all of your information files
and installation scripts, you can specify that this directory be searched when the
package is built with the <command>pkgmk</command> command.</para><para>The command in the prototype file would look like the following:</para><screen>!search /<replaceable>home-dir</replaceable>/pkgfiles</screen><note><para>Search requests do not span to included files. In addition, a search is
limited to the specific directories listed and does not search recursively.</para>
</note>
</sect3><sect3 id="ch2buildpkg-33"><title>Setting Environment Variables</title><para><indexterm><primary><filename>prototype</filename> file</primary><secondary>adding functionality to</secondary><tertiary>setting environment variables</tertiary></indexterm>You can also add commands to the <filename>prototype</filename> file of
the form <command>!</command><replaceable>PARAM=value</replaceable>. Commands of this
form define variables in the current environment. If you have multiple <filename>prototype</filename> files, the scope of this command is local to the <filename>prototype</filename> file where it is defined.</para><para><indexterm><primary><command>pkgmk</command> command</primary><secondary>setting environment variables</secondary></indexterm>The variable <replaceable>PARAM</replaceable> can
begin with either a lowercase letter or an uppercase letter. If the value of the <replaceable>PARAM</replaceable> variable is not known at build time, the <command>pkgmk</command> command
aborts with an error. For more information on the difference between build variables
and install variables, see <olink targetptr="ch2buildpkg-13952" remap="internal">Package Environment
Variables</olink>.</para>
</sect3>
</sect2><task id="ch2buildpkg-64"><title>How to Create a <filename>prototype</filename> File
by Using the <command>pkgproto</command> Command</title><tasksummary><note><para><indexterm><primary><filename>prototype</filename> file</primary><secondary>how to create</secondary></indexterm>It is easier to create information files and
installation scripts before you create a <filename>prototype</filename> file. However,
this order is not required. You can always edit the <filename>prototype</filename> file
after changing your package contents. For more information on information files and
installation scripts, see <olink targetptr="ch3enhancepkg-11350" remap="internal">Chapter&nbsp;3, Enhancing
the Functionality of a Package (Tasks)</olink>.</para>
</note>
</tasksummary><procedure><step id="ch2buildpkg-step-34"><para>Determine which package objects will be absolute
and which package objects will be relocatable, if not done already.</para><para>For
information that will help you complete this step, see <olink targetptr="ch2buildpkg-16793" remap="internal">The path Field</olink>.</para>
</step><step id="ch2buildpkg-step-35"><para>Organize your package's objects to mimic their
location on the target system.</para><para>If you already organized your packages
as described in <olink targetptr="ch2buildpkg-26363" remap="internal">Organizing a Package's Contents</olink>, note that you might need to make some changes based on your decisions in <olink targetptr="ch2buildpkg-step-34" remap="internal">Step&nbsp;1</olink>. If you have not organized your
package yet, you should do so now. If you do not organize your package, you cannot
use the <command>pkgproto</command> command to create a basic <filename>prototype</filename> file.</para>
</step><step id="ch2buildpkg-step-36"><para>If your package has collectively relocatable
objects, edit the <filename>pkginfo</filename> file to set the <envar>BASEDIR</envar> parameter
to the appropriate value.</para><para>For example:</para><screen>BASEDIR=/opt</screen><para>For information on collectively relocatable objects, see <olink targetptr="ch2buildpkg-33395" remap="internal">Collectively Relocatable Objects</olink>.</para>
</step><step id="ch2buildpkg-step-37"><para>If your package has individually relocatable
objects, create a <filename>request</filename> script to prompt the installer for
the appropriate path name. Alternatively, create a <filename>checkinstall</filename> script
to determine the appropriate path from file system data.</para><para>The following
list gives page numbers for your reference regarding common tasks:</para><itemizedlist><listitem><para>To create a <filename>request</filename> script, see <olink targetptr="ch3enhancepkg-119" remap="internal">How to Write a request Script</olink>.</para>
</listitem><listitem><para>To create a <filename>checkinstall</filename> script, see <olink targetptr="ch3enhancepkg-120" remap="internal">How to Gather File System Data</olink>.</para>
</listitem><listitem><para>For more information on individually relocatable objects, see <olink targetptr="ch2buildpkg-39047" remap="internal">Individually Relocatable Objects</olink>.</para>
</listitem>
</itemizedlist>
</step><step id="ch2buildpkg-step-55"><para>Change the owner and group on all of your package
components to be the intended owner and group on the target systems.</para><para>Use the <command>chown -R</command> and the <command>chgrp -R</command> commands on
your package directory and information files directory.</para>
</step><step id="ch2buildpkg-step-38"><para>Execute the <command>pkgproto</command> command
to create a basic <filename>prototype</filename> file.</para><para>The <command>pkgproto</command> command scans your directories to create a basic file. For example:</para><screen>$ <userinput>cd</userinput> <replaceable>package-directory</replaceable>
$ <userinput>pkgproto ./</userinput><replaceable>package-directory</replaceable><userinput> &gt; prototype</userinput></screen><para>The <filename>prototype</filename> file can be located anywhere on your system.
Keeping your information files and installation scripts in one place simplifies access
and maintenance. For additional information on the <command>pkgproto</command> command,
see the <olink targetdoc="refman1" targetptr="pkgproto-1" remap="external"><citerefentry><refentrytitle>pkgproto</refentrytitle><manvolnum>1</manvolnum></citerefentry></olink> man page.</para>
</step><step id="ch2buildpkg-step-39"><para>Edit the <filename>prototype</filename> file
by using your favorite text editor, and add entries for files of type <literal>v</literal>, <literal>e</literal>, <literal>x</literal>, and <literal>i</literal>.</para><para>For information
on the specific changes you might need to make, see <olink targetptr="ch2buildpkg-40414" remap="internal">Fine-Tuning a prototype File Created With the pkgproto Command</olink>.</para>
</step><step id="ch2buildpkg-step-40"><para>(Optional) If you are using multiple classes,
edit the <filename>prototype</filename> and <filename>pkginfo</filename> files. Use
your favorite text editor to make the necessary changes, and create corresponding
class action scripts.</para><para>For information on the specific changes you might
need to make, see <olink targetptr="ch2buildpkg-40414" remap="internal">Fine-Tuning a prototype File
Created With the pkgproto Command</olink> and <olink targetptr="ch3enhancepkg-37319" remap="internal">Writing Class Action Scripts</olink>. </para>
</step><step id="ch2buildpkg-step-41"><para>Edit the <filename>prototype</filename> file
by using your favorite text editor to redefine path names and change other field settings.</para><para>For more information, see <olink targetptr="ch2buildpkg-40414" remap="internal">Fine-Tuning
a prototype File Created With the pkgproto Command</olink>.</para>
</step><step id="ch2buildpkg-step-42"><para>(Optional) Edit the <filename>prototype</filename> file
by using your favorite text editor to add functionality to your <filename>prototype</filename> file.</para><para>For more information, see <olink targetptr="ch2buildpkg-31278" remap="internal">Adding Functionality to a prototype File</olink>.</para>
</step><step id="ch2buildpkg-step-43"><para>Save your changes and quit the editor.</para>
</step>
</procedure><taskrelated role="see-also"><para>If you are ready for the next task, see <olink targetptr="ch2buildpkg-66" remap="internal">How
to Build a Package</olink>.</para>
</taskrelated>
</task>
</sect1><sect1 id="ch2buildpkg-17051"><title>Building a Package</title><para><indexterm><primary><command>pkgmk</command> command</primary><secondary>building a package</secondary></indexterm>Use the <command>pkgmk</command> command to build
your package. The <command>pkgmk</command> command performs the following tasks:</para><itemizedlist><listitem><para>Puts all the objectes defined in the <filename>prototype</filename> file
into directory format.</para>
</listitem><listitem><para><indexterm><primary><filename>pkgmap</filename> file</primary><secondary>building a package</secondary></indexterm>Creates the <filename>pkgmap</filename> file,
which replaces the <filename>prototype</filename> file.</para>
</listitem><listitem><para>Produces an installable package that is used as input to the <command>pkgadd</command> command.</para>
</listitem>
</itemizedlist><sect2 id="ch2buildpkg-45"><title>Using the Simplest <command>pkgmk</command> Command</title><para>The simplest form of this command is the <command>pkgmk</command> command without
any options. Before using the <command>pkgmk</command> command without options, make
sure that your current working directory contains the package's <filename>prototype</filename> file. The output of the command, files and directories, are written to
the <filename>/var/spool/pkg</filename> directory.</para>
</sect2><sect2 id="ch2buildpkg-10222"><title>The <filename>pkgmap</filename> File</title><para>When you build a package with the <command>pkgmk</command> command, it creates
a <filename>pkgmap</filename> file that replaces the <filename>prototype</filename> file.
The <filename>pkgmap</filename> file from the previous example has the following contents:</para><screen>$ <userinput>more pkgmap</userinput>
: 1 3170
1 d none SUNWcadap 0755 root sys
1 d none SUNWcadap/demo 0755 root bin
1 f none SUNWcadap/demo/file1 0555 root bin 14868 45617 837527496
1 d none SUNWcadap/lib 0755 root bin
1 f none SUNWcadap/lib/file2 0644 root bin 1551792 62372 837527499
1 d none SUNWcadap/man 0755 bin bin
1 d none SUNWcadap/man/man1 0755 bin bin
1 f none SUNWcadap/man/man1/file3.1 0444 bin bin 3700 42989 837527500
1 f none SUNWcadap/man/man1/file4.1 0444 bin bin 1338 44010 837527499
1 f none SUNWcadap/man/windex 0644 root other 157 13275 837527499
1 d none SUNWcadap/srcfiles 0755 root bin
1 f none SUNWcadap/srcfiles/file5 0555 root bin 12208 20280 837527497
1 f none SUNWcadap/srcfiles/file6 0555 root bin 12256 63236 837527497
1 i pkginfo 140 10941 837531104
$</screen><para>The format of this file is very similar to the format of the <filename>prototype</filename> file. However, the <filename>pkgmap</filename> file includes the following
information:</para><itemizedlist><listitem><para>The first line indicates the number of volumes that the package spans,
and the approximate size the package will be when it is installed.</para><para>For
example, <literal>: 1 3170</literal> indicates that the package spans one volume and
will use approximately 3170 512-byte blocks when it is installed.</para>
</listitem><listitem><para>There are three additional fields that define the size, checksum,
and modification time for each package object.</para>
</listitem><listitem><para>The package objects are listed in alphabetical order by class and
by path name to reduce the time it takes to install the package.</para>
</listitem>
</itemizedlist>
</sect2><task id="ch2buildpkg-66"><title>How to Build a Package</title><procedure><step id="ch2buildpkg-step-50"><para>Create a <filename>pkginfo</filename> file, if
not done already.</para><para><indexterm><primary>package</primary><secondary>how to build</secondary></indexterm>For step-by-step instructions, see <olink targetptr="ch2buildpkg-62" remap="internal">How to Create a pkginfo File</olink>.</para>
</step><step id="ch2buildpkg-step-51"><para>Create a <filename>prototype</filename> file,
if not done already.</para><para>For step-by-step instructions, see <olink targetptr="ch2buildpkg-64" remap="internal">How to Create a prototype File by Using the pkgproto Command</olink>.</para>
</step><step id="ch2buildpkg-step-52"><para>Make your current working directory the same
directory that contains your package's <filename>prototype</filename> file.</para>
</step><step id="ch2buildpkg-step-53"><para>Build the package.</para><screen>$ <userinput>pkgmk</userinput> [-o] [-a <replaceable>arch</replaceable>] [-b <replaceable>base-src-dir</replaceable>] [-d <replaceable>device</replaceable>]
   [-f <replaceable>filename</replaceable>] [-l <replaceable>limit</replaceable>] [-p <replaceable>pstamp</replaceable>] [-r <replaceable>rootpath</replaceable>]
   [-v <replaceable>version</replaceable>] [<replaceable>PARAM=value</replaceable>] [<replaceable>pkginst</replaceable>]</screen><variablelist><varlistentry><term><option>o</option></term><listitem><para>Overwrites the existing version of the package.</para>
</listitem>
</varlistentry><varlistentry><term><option>a</option> <replaceable>arch</replaceable></term><listitem><para>Overrides the architecture information in the <filename>pkginfo</filename> file.</para>
</listitem>
</varlistentry><varlistentry><term><option>b</option> <replaceable>base-src-dir</replaceable></term><listitem><para>Requests that <replaceable>base-src-dir</replaceable> be added to
the beginning of relocatable path names when the <command>pkgmk</command> command
is searching for objects on the development system.</para>
</listitem>
</varlistentry><varlistentry><term><option>d</option> <replaceable>device</replaceable></term><listitem><para>Specifies that the package should be copied onto <replaceable>device</replaceable>, which may be a an absolute directory path name, diskette, or removable
disk.</para>
</listitem>
</varlistentry><varlistentry><term><option>f</option> <replaceable>filename</replaceable></term><listitem><para>Names a file, <replaceable>filename</replaceable>, that is used as
your <filename>prototype</filename> file. The default names are <filename>prototype</filename> or <filename>Prototype</filename>.</para>
</listitem>
</varlistentry><varlistentry><term><option>l</option> <replaceable>limit</replaceable></term><listitem><para>Specifies the maximum size, in 512-byte blocks, of the output device.</para>
</listitem>
</varlistentry><varlistentry><term><option>p</option> <replaceable>pstamp</replaceable></term><listitem><para>Overrides the production stamp definition in the <filename>pkginfo</filename> file.</para>
</listitem>
</varlistentry><varlistentry><term><option>r</option> <replaceable>rootpath</replaceable></term><listitem><para>Requests that the root directory <replaceable>rootpath</replaceable> be
used to locate objects on the development system.</para>
</listitem>
</varlistentry><varlistentry><term><option>v</option> <replaceable>version</replaceable></term><listitem><para>Overrides the version information in the <filename>pkginfo</filename> file.</para>
</listitem>
</varlistentry><varlistentry><term><replaceable>PARAM=value</replaceable></term><listitem><para>Sets global environment variables. Variables beginning with lowercase
letters are resolved at build time. Those beginning with uppercase letters are placed
into the <filename>pkginfo</filename> file for use at install time.</para>
</listitem>
</varlistentry><varlistentry><term><replaceable>pkginst</replaceable></term><listitem><para>Specifies a package by its package abbreviation or a specific instance
(for example, <literal>SUNWcadap.4</literal>).</para>
</listitem>
</varlistentry>
</variablelist><para>For more information, see the <olink targetdoc="refman1" targetptr="pkgmk-1" remap="external"><citerefentry><refentrytitle>pkgmk</refentrytitle><manvolnum>1</manvolnum></citerefentry></olink> man
page.</para>
</step><step id="ch2buildpkg-step-60"><para>Verify the contents of the package.</para><screen>$ <userinput>pkgchk -d</userinput> <replaceable>device-name</replaceable> <replaceable>pkg-abbrev</replaceable>
Checking uninstalled directory format package <replaceable>pkg-abbrev</replaceable>
from <replaceable>device-name</replaceable>
## Checking control scripts.
## Checking package objects.
## Checking is complete.
$</screen><variablelist><varlistentry><term><option>d</option> <replaceable>device-name</replaceable></term><listitem><para>Specifies the location of the package. Note that <replaceable>device-name</replaceable> can be a full directory path name or the identifiers for a tape or
removable disk.</para>
</listitem>
</varlistentry><varlistentry><term><replaceable>pkg-abbrev</replaceable></term><listitem><para><indexterm><primary><command>pkgchk</command> command</primary></indexterm>Is
the name of one or more packages (separated by spaces) to be checked. If omitted,
the <command>pkgchk</command> command checks all available packages. </para>
</listitem>
</varlistentry>
</variablelist><para>The <command>pkgchk</command> command prints what aspects of the package are
being checked and displays warnings or errors, as appropriate. For more information
on the <command>pkgchk</command> command, see <olink targetptr="ch4verifypkg-39428" remap="internal">Verifying the Integrity of a Package</olink>.</para><caution><para>Errors should be considered very seriously. An error could mean that
a script needs fixing. Check all errors and move on if you disagree with the output
from the <command>pkgchk</command> command.</para>
</caution>
</step>
</procedure><example id="ch2buildpkg-16898"><title>Building a Package</title><para>This example uses the <filename>prototype</filename> file created in <olink targetptr="ch2buildpkg-40414" remap="internal">Fine-Tuning a prototype File Created With the pkgproto
Command</olink>.</para><screen>$ <userinput>cd /home/jane/InfoFiles</userinput>
$ <userinput>pkgmk</userinput>
## Building pkgmap from package prototype file.
## Processing pkginfo file.
WARNING: parameter  set to "<replaceable>system</replaceable>990708093144"
WARNING: parameter  set to "none"
## Attempting to volumize 13 entries in pkgmap.
part  1 -- 3170 blocks, 17 entries
## Packaging one part.
/var/spool/pkg/SUNWcadap/pkgmap
/var/spool/pkg/SUNWcadap/pkginfo
/var/spool/pkg/SUNWcadap/reloc/SUNWcadap/demo/file1
/var/spool/pkg/SUNWcadap/reloc/SUNWcadap/lib/file2
/var/spool/pkg/SUNWcadap/reloc/SUNWcadap/man/man1/file3.1
/var/spool/pkg/SUNWcadap/reloc/SUNWcadap/man/man1/file4.1
/var/spool/pkg/SUNWcadap/reloc/SUNWcadap/man/windex
/var/spool/pkg/SUNWcadap/reloc/SUNWcadap/srcfiles/file5
/var/spool/pkg/SUNWcadap/reloc/SUNWcadap/srcfiles/file6
## Validating control scripts.
## Packaging complete.
$</screen>
</example><example id="ch2buildpkg-47"><title>Specifying a Source Directory for Relocatable Files</title><para>If your package contains relocatable files, you can use the <option>b</option> <replaceable>base-src-dir</replaceable> option to the <command>pkgmk</command> command to specify
a path name to be added to the beginning of the relocatable path names while the package
is being created. This option is useful if you haven't used the <replaceable>path1=path2</replaceable> format for relocatable files or specified a search path with the <command>!search</command> command in the <filename>prototype</filename> file.</para><para>The following command builds a package with the following characteristics:</para><itemizedlist><listitem><para><indexterm><primary><command>pkgproto</command> command</primary></indexterm>The package is built by using the sample <filename>prototype</filename> file
that is created by the <command>pkgproto</command> command. See <olink targetptr="ch2buildpkg-35610" remap="internal">Example&mdash;Creating a prototype File With the pkgproto Command</olink> for more
information.</para>
</listitem><listitem><para>The package is built without modifying the <replaceable>path</replaceable> fields.</para>
</listitem><listitem><para>The package adds an entry for the <filename>pkginfo</filename> file</para>
</listitem>
</itemizedlist><screen>$ <userinput>cd /home/jane/InfoFiles</userinput>
$ <userinput>pkgmk -o -b /home/jane</userinput>
## Building pkgmap from package prototype file.
## Processing pkginfo file.
WARNING: parameter  set to "<replaceable>system</replaceable>960716102636"
WARNING: parameter  set to "none"
## Attempting to volumize 13 entries in pkgmap.
part  1 -- 3170 blocks, 17 entries
## Packaging one part.
/var/spool/pkg/SUNWcadap/pkgmap
/var/spool/pkg/SUNWcadap/pkginfo
/var/spool/pkg/SUNWcadap/reloc/SUNWcadap/demo/file1
/var/spool/pkg/SUNWcadap/reloc/SUNWcadap/lib/file2
/var/spool/pkg/SUNWcadap/reloc/SUNWcadap/man/man1/file3.1
/var/spool/pkg/SUNWcadap/reloc/SUNWcadap/man/man1/file4.1
/var/spool/pkg/SUNWcadap/reloc/SUNWcadap/man/windex
/var/spool/pkg/SUNWcadap/reloc/SUNWcadap/srcfiles/file5
/var/spool/pkg/SUNWcadap/reloc/SUNWcadap/srcfiles/file6
## Validating control scripts.
## Packaging complete.</screen><para>In this example, the package is built in the default directory, <filename>/var/spool/pkg</filename>, by specifying the <option>o</option> option. This option overwrites the
package that was created in <olink targetptr="ch2buildpkg-16898" remap="internal">Example&nbsp;2&ndash;2</olink>.</para>
</example><example id="ch2buildpkg-48"><title>Specifying Different Source Directories for Information Files and Package Objects</title><para>If you put package information files (such as <filename>pkginfo</filename> and <filename>prototype</filename>) and the package objects in two different directories, you can
create your package by using the <option>b</option> <replaceable>base-src-dir</replaceable> and <option>r</option> <replaceable>rootpath </replaceable>options to the <command>pkgmk</command> command.
If you have your package objects in a directory called <literal>/product/pkgbin</literal> and
the other package information files in a directory called <literal>/product/pkgsrc</literal>, you could use the following command to place the package in the <literal>/var/spool/pkg</literal> directory:</para><screen width="100">$ <userinput>pkgmk -b /product/pkgbin -r /product/pkgsrc -f /product/pkgsrc/prototype</userinput></screen><para>Optionally, you could use these commands to achieve the same result:</para><screen>$ <userinput>cd /product/pkgsrc</userinput>
$ <userinput>pkgmk -o -b /product/pkgbin</userinput></screen><para>In this example, the <command>pkgmk</command> command uses the current working
directory to find the remaining parts of the package (such as the <filename>prototype</filename> and <filename>pkginfo</filename> information files).</para>
</example><taskrelated role="see-also"><para>If you want to add any optional information files and installation scripts to
your package, see <olink targetptr="ch3enhancepkg-11350" remap="internal">Chapter&nbsp;3, Enhancing
the Functionality of a Package (Tasks)</olink>. Otherwise, after you build the package,
you should verify its integrity. <olink targetptr="ch4verifypkg-18395" remap="internal">Chapter&nbsp;4,
Verifying and Transferring a Package</olink> explains how to do so, and provides step-by-step
instructions on how to transfer your verified package to a distribution medium.</para>
</taskrelated>
</task>
</sect1>
</chapter><?Pub *0000091471 0?>