=head1 NAME

package - Provides instructions for the package command

=head1 DESCRIPTION

The package configuration file defines the file system elements that the
B<package> command creates or alters on the local disk of an AFS client
machine it is configuring. Use the B<-config> or B<-fullconfig> argument
to the B<package> command to identify the configuration file to use.

=head2 Summary of Configuration File Instructions

The configuration file can include one or more instances of each of the
following instructions, each on its own line. A more detailed description
of each instruction's syntax follows this list.

=over 4

=item B

Defines a block special device, such as a disk, which deals with input in
units of multi-byte command blocks.

=item C

Defines a character special device, such as a terminal or tty, which deals
with input in single character units.

=item D

Creates a directory.

=item F

Creates or alters a file to match the contents of a specified source file.

=item L

Creates a symbolic link.

=item S

Defines a socket, which is a communications device for UDP and TCP/IP
connections.

=item %define

Defines a variable or declares a string as defined.

=item %ifdef

Specifies an action to perform if a certain string is declared or defined.

=item %ifndef

Specifies an action to perform if a certain string is not declared or
defined.

=item %include

Includes a library file.

=item %undef

Declares a string not to be defined, or a variable no longer to have a
value.

=back

=head2 The B and C Instructions for Defining Special Devices

The C<B> instruction in a package configuration file defines a block
special device, such as a disk, that deals with input in units of
multi-byte command blocks. The C<C> instruction defines a character
special device, such as a terminal or tty, that deals with input in single
character units. They share a common syntax:

   (B | C) <device> <major> <minor> <owner> <group> <mode>

where

=over 4

=item B

Indicates the definition of a block special device. It must be a capital
letter.

=item C

Indicates the definition of character special device. It must be a capital
letter.

=item <device>

Names the special device to define. To learn the name format appropriate
to the machine's system type, consult the hardware or operating system
documentation.

=item <major>

Specifies the device's major device number in decimal format.  To learn
the correct value for the machine's system type, consult the hardware or
operating system documentation.

=item <minor>

Specifies the device's minor device number in one of hexadecimal, octal,
or decimal format. Precede a hexadecimal number with the string C<0x>
(zero and the letter C<x>) or an octal number with a C<0> (zero). A number
without either prefix is interpreted as a decimal. To learn the correct
value for the machine's system type, consult the hardware or operating
system documentation.

=item <owner>

Specifies the username or UNIX user ID (UID) of the user to be designated
the device's owner in the output from the UNIX C<ls -l> command.

=item <group>

Specifies the group name or UNIX group ID (GID) of the group to be
designated the device's group in the output from the UNIX C<ls -lg>
command.

=item <mode>

Defines the device's UNIX mode bits. Acceptable values are the standard
three- or four-digit numbers corresponding to combinations of
permissions. Examples: C<755> corresponds to C<rwxr-xr-x>, and C<644> to
C<rw-r--r-->.

=back

=head2 The D Instruction for Creating a Directory

The C<D> instruction in a package configuration file creates a directory
on the local disk. If a symbolic link, file, or other element on the local
disk has the same name, it is replaced with a directory. If the directory
already exists, its owner, group, and mode bits are changed if necessary
to conform with the instruction. The instruction has the following syntax:

   D[I<update_code>] <directory> <owner> <group> <mode>

where

=over 4

=item D

Indicates the creation of a directory. It must be a capital letter.

=item <update_code>

Modulates the directory creation instruction. It is optional and follows
the letter C<D> directly, without an intervening space.  Choose one of the
two acceptable values:

=over 4

=item X

Indicates that the directory is a lost+found directory (used by the
B<fsck> program).

=item R

Removes any subdirectory (along its contents) or file that exists in the
existing directory on the local disk but for which an instruction does not
appear in the configuration file.

=back

=item <directory>

Specifies the full pathname of the directory to create.

=item <owner>

Specifies the username or UNIX user ID (UID) of the user to be designated
the directory's owner in the output from the UNIX C<ls -ld> command.

=item <group>

Specifies the name or UNIX group ID (GID) of the group to be designated
the directory's group in the output from the UNIX C<ls -lgd> command.

=item <mode>

Defines the directory's UNIX mode bits. Acceptable values are the standard
three- or four-digit numbers corresponding to combinations of
permissions. Examples: C<755> corresponds to C<drwxr-xr-x>, and C<644> to
C<drw-r--r-->.

=back

=head2 The F Instruction for Creating or Updating a File

The C<F> instruction in a package configuration file creates or updates a
file on the local disk by copying in the contents of the indicated source
file, which can reside in AFS or on the local disk. If the B<package>
command interpreter cannot access the source file, it exits without
executing any instruction in the configuration file.

If a file with the same name already exists on disk, the package command
overwrites it with the contents of the source file, unless the C<I> update
code is used to prevent that. To add a C<.old> extension to the current
version of the file, include the C<O> update code. To have the machine
reboot automatically after the B<package> program completes, include the
C<Q> update code.

If a symbolic link, directory, or other element on the local disk has the
same name, it is replaced with the file (a directory's contents are first
removed as necessary).

The instruction has the following syntax:

   F[<update_code>] <file> <source> [<owner> <group> <mode>]

where

=over 4

=item F

Indicates the creation or update of a file. It must be a capital letter.

=item <update_code>

Modulates the file creation instruction. It is optional and follows the
letter C<F> directly, without an intervening space. Choose one or more of
the four acceptable values, and list them in any order:

=over 4

=item A

Indicates that the pathname in the <source> field is the complete pathname
of the source file, including the filename. If this argument is omitted,
the B<package> command appends the pathname in the <file> field to the
pathname in the <source> field to derive the source file's full name. This
code allows the source and target filenames to differ.

=item I

Preserves the existing file called <file>, rather than overwriting it.

=item O

Saves the existing version of the file by appending a C<.old> extension to
it.

=item Q

Causes the package command to exit with status code C<4> if it overwrites
the file. If the standard B<package>-related changes have been made to the
machine's AFS initialization file, then status code C<4> causes the
machine to reboot automatically. Use this code when the machine must
reboot if updates to the file are to have any effect (for example, if the
operating system file -- F</vmunix> or equivalent -- has changed).

=back

=item <file>

Specifies the complete pathname on the local disk of the file to create or
update, including the filename as the final element.

=item <source>

Specifies the pathname (local or AFS) of the file to copy to the local
disk.

If the C<A> update code is included, specify the source file's complete
pathname. Otherwise, the B<package> command derives the source file's full
name by appending the I<file> pathname to this pathname. For example, if
the C<A> update code is not included and the file
F</afs/abc.com/rs_aix42/bin/grep> is the source file for the F</bin/grep>
binary, the proper value in this field is F</afs/abc.com/rs_aix42>.

=item <owner>

Specifies the username or UNIX user ID (UID) of the user to be designated
the file's owner in the output from the UNIX C<ls -l> command.

To copy the source file's owner to the target file, leave this field
empty. In this case, the <group> and <mode> fields must also be empty.

=item <group>

Specifies the name or UNIX group ID (GID) of the group to be designated
the file's group in the output from the UNIX C<ls -lg> command.

To copy the source file's group to the target file, leave this field
empty. In this case, the <owner> and <mode> fields must also be empty.

=item <mode>

Defines the file's UNIX mode bits. Acceptable values are the standard
three- or four-digit numbers corresponding to combinations of
permissions. Examples: C<755> corresponds to C<rwxr-xr-x>, and C<644> to
C<rw-r--r-->.

To copy the source file's mode bits to the target file, leave this field
empty. In this case, the <owner> and <group> fields must also be empty.

=back

=head2 The L Instruction for Creating a Symbolic Link

The C<L> instruction in a package configuration file creates a symbolic
link on the local disk to a directory or file that exists either in AFS or
elsewhere on the local disk. As with the standard UNIX C<ln -s> command,
the link is created even if the actual file or directory does not exist.

If a file or directory on the local disk already has the same name, the
B<package> command replaces it with a symbolic link.

The instruction has the following syntax:

   L[I<update_code>] <link> <path> [<owner> <group> <mode>]

where

=over 4

=item L

Indicates the creation of a symbolic link. It must be a capital letter.

=item <update_code>

Modulates the link creation instruction. It is optional and follows the
letter C<L> directly, without an intervening space. Choose one or both of
the acceptable values, and list them in any order:

=over 4

=item A

Indicates that the pathname in the <path> field is the complete pathname
of the actual directory or file (including the filename for a file). If
this argument is omitted, the B<package> command appends the value in the
<link> field to the pathname in the <path> field to derive the actual
directory or file's full name. This code allows the name of the symbolic
link and actual directory or file to differ.

=item I

Preserves the existing symbolic link called <link>, rather than
overwriting it.

=back

=item <link>

Specifies the complete local disk pathname of the symbolic link to create.

=item <path>

Specifies the pathname (local or AFS) of the directory or file to which
the link refers. If the C<A> update code is included, specify the
directory or file's complete pathname. Otherwise, the B<package> command
derives the actual directory or file's full name by appending the value in
the I<link> field to this pathname. For example, if the C<A> update code
is not included and F</etc/ftpd> is a symbolic link to the file
F</afs/abc.com/sun4x_56/etc/ftpd>, the proper value in this field is
F</afs/abc.com/sun4x_56>.

The package command interpreter correctly handles pathnames that begin
with the C<./> (period, slash) or C<../> (two periods, slash) notation,
interpreting them relative to the current working directory from which the
B<package> command is invoked.

=item <owner>

Specifies the username or UNIX user ID (UID) of the user to be designated
the symbolic link's owner in the output from the UNIX C<ls -l> command.

To designate the issuer of the package command (usually, the local
superuser C<root>) as the symbolic link's owner, leave this field
empty. In this case, the <group> and <mode> fields must also be empty.

=item <group>

Specifies the name or UNIX group ID (GID) of the group to be designated
the link's group in the output from the UNIX C<ls -lg> command.

To have the symbolic link's group match the default group associated with
the B<package> command's issuer, leave this field empty. The issuer is
usually the local superuser C<root> and the default group is designated in
the issuer's entry in the local F</etc/passwd> file or equivalent. If this
field is left empty, the <owner> and <mode> fields must also be empty.

=item <mode>

Defines the symbolic link's UNIX mode bits. Acceptable values are the
standard three- or four-digit numbers corresponding to combinations of
permissions. Examples: C<755> corresponds to C<rwxr-xr-x>, and C<644> to
C<rw-r--r-->.

Leaving this field empty sets the symbolic link's mode bits to C<777>
(C<rwxrwxrwx>). In this case, the <owner> and <group> fields must also be
empty.

=back

=head2 The S Instruction for Creating a Socket

The C<S> instruction in a package configuration file creates a socket (a
communications device for UDP or TCP/IP connections) on the local
disk. The instruction has the following syntax:

   S <socket> [<owner> <group> <mode>]

where

=over 4

=item S

Indicates the creation of a socket. It must be a capital letter.

=item <socket>

Names the socket. The proper format depends on the local machine's
operating system.

=item <owner>

Specifies the username or UNIX user ID (UID) of the user to be designated
the socket's owner in the output from the UNIX C<ls -l> command.

To designate the issuer of the package command (usually, the local
superuser C<root>) as the socket's owner, leave this field empty. In this
case, the <group> and <mode> fields must also be empty.

=item <group>

Specifies the name or UNIX group ID (GID) of the group to be designated
the socket's group in the output from the UNIX C<ls -lg> command.

To have the symbolic link's group match the default group associated with
the B<package> command's issuer, leave this field empty. The issuer is
usually the local superuser C<root> and the default group is designated in
the issuer's entry in the local F</etc/passwd> file or equivalent. If this
field is left empty, the <owner> and <mode> fields must also be empty.

=item <mode>

Defines the socket's UNIX mode bits. Acceptable values are the standard
three- or four-digit numbers corresponding to combinations of
permissions. Examples: C<755> corresponds to C<rwxr-xr-x>, and C<644> to
C<rw-r--r-->.

Leaving this field empty sets the symbolic link's mode bits to C<777>
(C<rwxrwxrwx>), modulated by the cell's umask. In this case, the <owner>
and <group> fields must also be empty.

=back

=head2 The %define or %undef Instructions

The C<%define> instruction in a package configuration file declares or
defines a variable, depending on its number of arguments:

=over 4

=item *

If followed by a single argument, it declares that argument to be
defined. The argument is then available as a controller when mentioned in
C<%ifdef> and C<%ifndef> statements, which evaluate to C<true> and
C<false> respectively.

=item *

If followed by two arguments, it defines the second argument as the value
of the first. When the first argument appears later in this prototype or
other prototype or library files as a variable -- surrounded by curly
braces and preceded by a dollar sign, as in the example C<${variable}> --
the B<package> command interpreter substitutes the second argument for it.

=back

The C<%undef> statement negates the effect of a previous C<%define>
statement, declaring its argument to be defined no longer, or to have a
value no longer if it is a variable.

The syntax for the two types of instruction are as follows:

   %define <declaration>
   %define <variable> <value>
   %undef  <declaration>
   %undef  <variable>

where

=over 4

=item %define

Indicates a definition statement.

=item %undef

Indicates a statement that negates a definition.

=item <declaration>

Names the string being declared by a C<%define> statement, or
negated by an C<%undef> statement.

=item <variable>

Specifies the name of the variable that a C<%define> statement is
defining, or an C<%undef> statement is negating.

=item <value>

Specifies the value to substitute for the string in the <variable> field
when it appears in the appropriate format (surrounded by curly braces and
preceded by a dollar sign, as in the example C<${variable}>), in this or
other prototype and library files. It can include one or more words.

=back

=head2 The %ifdef and %ifndef Instructions

The C<%ifdef> instruction in a package configuration file specifies one or
more actions to perform if the indicated string has been declared by a
single-argument C<%define> statement, or is a variable for which a value
has been defined by a two-argument C<%define> statement.

Similarly, the C<%ifndef> instruction specifies one or more actions to
perform if the indicated string has not been declared or is a variable
without a value, either because no C<%define> statement has defined it or
an C<%undef> statement has undefined it.

In both cases, the optional C<%else> statement specifies one or more
alternate actions to perform if the first statement evaluates to
C<false>. (For an C<%ifdef> statement, the C<%else> statement is executed
if the indicated string has never been declared or is a variable without a
value, or if an C<%undef> statement has undefined either one; for an
C<%ifndef> statement, it is executed if the string has been declared or is
a variable with a value.)

It is possible to nest any number of C<%ifdef> and C<%ifndef> statements.

The two types of statement share a common syntax:

   (%ifdef | %ifndef) <declaration>
       <action>+
   [%else [<declaration>]
       <alternate_action>+]
   %endif <declaration>

where

=over 4

=item %ifdef

Indicates that the statement evaluates as true if the string in the
<declaration> field is declared or is a variable with a defined value.

=item %ifndef

Indicates that the statement evaluates as true if the string in the
<declaration> field is not declared or is a variable without a defined
value.

=item <declaration>

Specifies the string that must be declared or the variable name that must
have a defined value for an C<%ifdef> statement to evaluate as C<true>,
which results in the specified action being performed.  For an C<%ifndef>
statement, the string must not be declared or the variable must have no
defined value for the statement to evaluate as C<true>. The first and
third occurrences of <declaration> (the latter following the string
C<%endif>) are required. The second occurrence (following the string
C<%else>) is optional, serving only to clarify to which C<%ifdef> or
C<%ifndef> statement the C<%else> statement belongs.

=item <action>

Specifies each action to perform if the C<%ifdef> or C<%ifndef> statement
evaluates as C<true>. Each action must appear on a separate
line. Acceptable types of actions are other statements beginning with a
percent sign and definition instructions.

=item <alternate_action>

Specifies each action to perform if the C<%ifdef> or C<%ifndef> statement
evaluates to C<false>. Each action must appear on a separate
line. Acceptable types of actions are other statements beginning with a
percent sign and definition instructions.

=back

=head2 The %include Instruction for Including a Library File

The C<%include> instruction in a package configuration file includes the
contents of the indicated library file in a configuration file that
results from the compilation of the prototype file in which the
C<%include> instruction appears. It has the following syntax:

   %include <pathname>

where

=over 4

=item %include

Indicates a library file include statement.

=item <pathname>

Specifies the complete pathname of the library file to include. It can be
in AFS or on the local disk, and can include one or more variables.

=back

=head1 CAUTIONS

The configuration file must be completely correct. If there are any syntax
errors or incorrect values, the B<package> command interpreter exits
without executing any instruction.

=head1 EXAMPLES

The following example C<B> and C<C> instructions define a disk
F</dev/hd0a> with major and minor device numbers C<1> and C<0> and mode
bits of C<-rw-r--r-->, and a tty F</dev/ttyp5> with major and minor device
numbers C<6> and C<5> and mode bits of C<-rw-rw-rw>. In both cases, the
owner is C<root> and the owning group C<wheel>.

   B /dev/hd0a 1 0 root wheel 644
   C /dev/ttyp5 6 5 root wheel 666

The following example C<D> instruction creates the local F</usr> directory
with owner C<root> and group C<wheel> and mode bits of C<drwxr-xr-x>. The
C<R> update code removes any files and subdirectories that reside in the
F</usr> directory (if it already exists) but do not appear in the
configuration file.

   DR /usr root wheel 755

The following example C<F> instruction, appropriate for a machine running
AIX 4.2 in the ABC Corporation cell, creates or updates the local disk
file F</bin/grep>, using F</afs/abc.com/rs_aix42/bin/grep> as the source.

   F /bin/grep /afs/abc.com/rs_aix42 root wheel 755

The next example C<F> instruction creates the F</usr/vice/etc/ThisCell>
file and specifies an absolute pathname for the source file, as indicated
by the C<A> update code. The C<Q> code makes the B<package> command return
status code 4 as it exits, prompting a reboot of the machine if the
standard B<package>-related changes have been made to the machine's AFS
initialization file. No values are provided for the owner, group and mode
bits, so the file inherits them from the source file.

   FAQ /usr/vice/etc/ThisCell /afs/abc.com/common/etc/ThisCell

The following example C<L> instruction, appropriate for a machine running
AIX 4.2 in the ABC Corporation cell, creates a symbolic link from
F</etc/ftpd> on the local disk to the file
F</afs/abc.com/rs_aix42/etc/ftpd>.

   L /etc/ftpd /afs/abc.com/rs_aix42 root wheel 644

The following example S instruction defines the socket F</dev/printer>.

   S /dev/printer root wheel 777

The following example C<%define> instruction defines the value for the
variable C<${diskmode}>. This variable is used elsewhere in the template
to fill the <owner>, <group>, and <mode> fields in a C<D>, C<F>, or C<L>
instruction.

   %define diskmode root wheel 644

The following example C<%undef> instruction declares the string B<afsd>
not to be defined.

   %undef afsd

The following example C<%ifdef> instruction specifies that if the string
C<rs_aix42> is currently declared, then when the prototype file containing
the instruction is compiled the three indicated library files are
included. There is no alternate action defined. There must be C<%define>
statements earlier in the prototype file to declare C<rs_aix42> and to
assign a value to the C<${wsadmin}> variable.

   %ifdef rs_aix42
   %include ${wsadmin}/lib/rs_aix42.readonly
   %include ${wsadmin}/lib/rs_aix42.generic
   %include ${wsadmin}/lib/rs_aix42.generic.dev
   %endif rs_aix42

The following example C<%ifndef> instruction, appropriate for the State
University cell, defines C<stateu.edu> as the value of the C<${cell}>
variable if it does not already have a value.

   %ifndef cell
   %define cell stateu.edu
   %endif cell

The following example C<%include> instruction includes the library file
C<base.generic> from the F<lib> subdirectory of the directory in which
B<package>-related files reside. The C<${wsadmin}> variable resolves to an
actual pathname (such as F</afs/abc.com/wsadmin>) during compilation.

   %include ${wsadmin}/lib/base.generic

=head1 SEE ALSO

L<package(8)>

=head1 COPYRIGHT

IBM Corporation 2000. <http://www.ibm.com/> All Rights Reserved.

This documentation is covered by the IBM Public License Version 1.0.  It was
converted from HTML to POD by software written by Chas Williams and Russ
Allbery, based on work by Alf Wachsmann and Elizabeth Cassell.
