Defining Additional Objects to Be Created at Install Time
You can use the prototype file to define objects that are not actually delivered on the installation medium. During installation, using the pkgadd command, these objects are created with the required file types, if they do not already exist at the time of installation.
To specify that an object be created on the target system, add an entry for it in the prototype file with the appropriate file type.
For example, if you want a directory created on the target system, but do not want to deliver it on the installation medium, make the following entry for the directory in the prototype file:
d none /directory 0644 root other
If you want to create an empty file on the target system, an entry for the file in the prototype file might look like:
f none filename=/dev/null 0644 bin bin
The only objects that must be delivered on the installation medium are regular files and edit scripts (file types e, v, f) and the directories required to contain them. Any additional objects are created without reference to the delivered objects, directories, named pipes, devices, hard links, and symbolic links.
Creating Links at Install Time
Its file type as l (a link) or s (a symbolic link).
Its path name with the format path1=path2 where path1 is the destination and path2 is the source file. As a general rule, path2 of a link should never be absolute, but should instead be relative to the directory portion of path1. For example, a prototype file entry defining a symbolic link could be:
s none etc/mount=../usr/etc/mount
Relative links would be specified in this manner whether the package is installed as absolute or relocatable.
Distributing Packages Over Multiple Volumes
However, you can use the optional part field in the prototype file to define in which part you want an object to be located. A number in this field overrides the pkgmk command and forces the placement of the component into the part given in the field. Note that there is a one-to-one correspondence between parts and volumes for removable media formatted as file systems. If the volumes are preassigned by the developer, the pkgmk command will issue an error if there is insufficient space on any volume.
Nesting prototype Files
In the following example there are three prototype files, the main one (prototype) being edited, and the two (proto2 and proto3) that are being included.
!include /source-dir/proto2 !include /source-dir/proto3
Setting Default Values for the mode, owner, and group Fields
!default 0644 root other
Note - This command's range starts from where it is inserted and extends to the end of the file, but does not span to included files.
However, for directories (file type d) and editable files (file type e) that you know exist on target systems (like /usr or /etc/vfstab), make sure that the mode, owner, and group fields in the prototype file are set to question marks (?). That way you will not destroy existing settings that a site administrator may have modified.
Providing a Search Path for the pkgmk Command
If the source location for package objects is different than their destination location, and you do not want to use the path1=path2 format as described in "A Brief Word on an Object's Source and Destination Locations", then you can use the !search command in the prototype file. For example, if you created a directory, pkgfiles, in your home directory, and it contains all of your information files and installation scripts, you can specify that that directory be searched when the package is built with the pkgmk command.
The command in the prototype file would look like:
Note - Search requests do not span to included files. In addition, a search is limited to the specific directories listed, and will not search recursively.
Set Environment Variables
You can also add commands to the prototype file of the form !PARAM=value. Commands of this form define variables in the current environment. If you have multiple prototype files, the scope of this command is local to the prototype file where it is defined.
The variable PARAM can begin with either a lowercase or uppercase letter, but its value must be known at build time, or the pkgmk command will abort with an error. For more information on the difference between build and install variables, see "Package Environment Variables".
How to Create a prototype File Using the pkgproto Command
Note - It is easier to create information files and installation scripts before creating a prototype file. However, this is not required, and you can always edit the prototype file after changing your package contents. For more information on information files and installation scripts, see Chapter 3, Enhancing the Functionality of a Package.
Determine which package objects will be absolute and which will be relocatable, if not done already.
For information that will help you complete this task, see "The path Field".
Organize your package's objects to mimic their location on the target system.
If you already organized your packages as described in "Organizing a Package's Contents", note that you may need to make some changes based on your decisions in Step 1. If you have not organized your package yet, you should do so now (otherwise you cannot use the pkgproto command to create a basic prototype file).
If your package has collectively relocatable objects, edit the pkginfo file to set the BASEDIR parameter to the appropriate value.
For information on collectively relocatable objects, see "Collectively Relocatable Objects".
If your package has individually relocatable objects, create a request script to prompt the installer for the appropriate path name or a checkinstall script to determine the appropriate path from file system data.
For Information On ...
Creating a request script
Creating a checkinstall script
Individually relocatable objects
Change the owner and group on all of your package components to be the intended owner and group on the target systems.
Use the chown -R and the chgrp -R commands on your package directory and information files directory.
Execute the pkgproto command to create a basic prototype file.
The pkgproto command scans your directories to create a basic file. For example:
$ cd package-directory $ pkgproto ./package-directory > prototype
Like the pkginfo file, the prototype file can be located anywhere on your system. However, it might be a good idea to keep your information files and installation scripts in one place, for easy access and maintenance. For additional information on the pkgproto command, see the pkgproto(1) man page.
Edit the prototype file using your favorite text editor, and add entries for files of type v, e, x, and i.
For information on the specific changes you may need to make, see "Fine-Tuning a prototype File Created With the pkgproto Command".
Optional. If you are using multiple classes, edit the prototype and pkginfo files using your favorite text editor to make the necessary changes, and create corresponding class action scripts.
For information on the specific changes you may need to make, see "Fine-Tuning a prototype File Created With the pkgproto Command" and "Writing Class Action Scripts".
Edit the prototype file using your favorite text editor to redefine path names and change other field settings.
For more information, see "Fine-Tuning a prototype File Created With the pkgproto Command".
Optional. Edit the prototype file using your favorite text editor to add functionality to your prototype file.
For more information, see "Adding Functionality to a prototype File".
Save your changes and quit the editor.
Where to Go Next
If you are ready to go to the next task, see "How to Build a Package".