Before you build a package, you need to know which files you need to create and the commands you need to execute. You also need to consider your application software's requirements and the needs of your customers. Your customers are the administrators who will be installing your package. This chapter discusses the files, commands, and criteria you should know and consider before building a package.
This is a list of the information in this chapter.
Use these task maps to find step-by-step instructions for building and verifying packages.
Application software is delivered in units called packages. A package is a collection of files and directories that are required for a software product. A package is usually designed and built by the application developer after completing the development of the application code. A software product needs to be built into one or more packages so that it can easily be transferred to a distribution medium. Then, the software product can be mass produced and installed by administrators.
A package is a collection of files and directories in a defined format. This format conforms to the application binary interface (ABI), which is a supplement to the System V Interface Definition.
The components of a package fall into two categories.
package objects are the application files to be installed.
control files control how, where, and if the package is installed.
The control files are also divided into two categories: information files and installation scripts. Some control files are required. Some control files are optional.
To package your applications, you must first create the required components, and any optional components, that make up your package. You can then build the package by using the pkgmk command.
To build a package, you must provide the following:
Package objects (the application software's files and directories)
Two required information files (the pkginfo and prototype files)
Optional information files
Optional installation scripts
The following figure describes the contents of a package.
You must create the following components before you build your package:
Package objects
These components make up the application. They can consist of the following items:
Files (executable files or data files)
Directories
Named pipes
Links
Devices
The pkginfo file
The pkginfo file is a required package information file that defines parameter values. Parameter values include the package abbreviation, the full package name, and the package architecture. For more information, see Creating a pkginfo File and the pkginfo(4) man page.
There are two pkginfo(1) man pages. The first man page describes a section 1 command that displays information about installed packages. The second man page describes a section 4 file that describes the characteristics of a package. When accessing the man pages, be sure to specify the applicable man page section. For example: man -s 4 pkginfo.
The prototype file
The prototype file is a required package information file that lists the components of the package. One entry exists for each package object, information file, and installation script. An entry consists of several fields of information that describe each component, including its location, attributes, and file type. For more information, see Creating a prototype File and the prototype(4) man page.
You can include four optional package information files in your package:
Defines previous versions of the package that are compatible with this version of your package.
Indicates other packages that have a special relationship with your package.
Defines disk space requirements for the target environment, beyond what is required by the objects defined in the prototype file. For example, additional space might be needed for files that are dynamically created at installation time.
Defines the text for a copyright message that displays at the time of package installation.
Each package information file should have an entry in the prototype file. See Creating Information Files for more information on creating these files.
Installation scripts are not required. However, you can provide scripts that perform customized actions during the installation of your package. An installation script has the following characteristics:
The script is composed of Bourne shell commands.
The script's file permissions should be set to 0644.
The script does not need to contain the shell identifier (#! /bin/sh).
The four script types are as follows:
The request script
The request script requests input from the administrator who is installing the package.
The checkinstall script
The checkinstall script performs special file system verification.
The checkinstall script is only available with the SolarisTM 2.5 release and compatible releases.
Procedure scripts define actions that occur at particular points during package installation and removal. You can create four procedure scripts with these predefined names: preinstall, postinstall, preremove, and postremove.
Class action scripts define a set of actions to be performed on a group of objects.
See Creating Installation Scripts for a more information on installation scripts.
Before building a package, you need to decide whether your product will consist of one or more packages. Note that many small packages take longer to install than one big package. Although creating a single package is a good idea, doing so is not always possible. If you decide to build more than one package, you need to determine how to segment the application code. This section provides a list of criteria to use when planning to build a package.
Many of the packaging criteria present trade-offs among themselves. Satisfying all requirements equally is often difficult. These criteria are presented in order of importance. However, this sequence is meant to serve as a flexible guide depending on the circumstances. Although each criterion is important, it is up to you to optimize these requirements to produce a good set of packages.
For more design ideas, see Chapter 6, Advanced Techniques for Creating Packages.
All packages must be remotely installable. Being remotely installable means that the administrator installing your package might be trying to install it on a client system, not necessarily to the root (/) file system where the pkgadd command is being executed.
Consider the various types of system software configurations (for example, standalone system and server) when laying out packages. Good packaging design divides the affected files to optimize installation of each configuration type. For example, the contents of the root (/) and /usr file systems should be segmented so that server configurations can easily be supported.
Packages should be self-contained and distinctly identified with a set of functionality. For example, a package that contains UFS should contain all UFS utilities and be limited to only UFS binaries.
Packages should be organized from a customer's point of view into functional units.
Put code that requires royalty payments due to contractual agreements in a dedicated package or group of packages. Do not disperse the code into more packages than necessary.
Keep system-dependent binaries in dedicated packages. For example, the kernel code should be in a dedicated package, with each implementation architecture consisting of a distinct package instance. This rule also applies to binaries for different architectures. For example, binaries for a SPARC system would be in one package and binaries for an x86 system would be in another package.
When constructing packages, eliminate duplicate files whenever possible. Unnecessary duplication of files results in support and version difficulties. If your product has multiple packages, repeatedly compare the contents of these packages for duplicated files.
Localization-specific items should be in their own package. An ideal packaging model would have a product's localizations delivered as one package per locale. Unfortunately, in some cases organizational boundaries conflict with the functional and product boundaries criteria.
International defaults can also be delivered in a package. This design isolates the files that are necessary for localization changes and standardizes the delivery format of localization packages.
This document discusses SVR4 packages. For delivery into the OpenSolaris OS, consider using Image Packaging System (IPS) packages. The OpenSolaris OS supports both SVR4 and IPS packages. The IPS software interacts with network repositories and uses the ZFS file system. In the OpenSolaris OS, you can publish existing SVR4 packages to an IPS repository with the pkgsend(1) command.
The following table contains a comparison of commands for the SVR4 packaging system and the IPS packaging system. For detailed information on IPS, see Getting Started With the Image Packaging System.
Table 1–1 Packaging Tasks: IPS and SVR4
Task |
IPS command |
SVR4 command |
---|---|---|
Install a new package |
pkg install |
pkgadd -a |
Display information about a package's state |
pkg list |
pkginfo |
Verify correct installation of a package |
pkg verify |
pkgchk -v |
Display information about a package |
pkg info |
pkginfo -l |
Listing the contents of a package |
pkg contents |
pkgchk -l |
Uninstall a package |
pkg uninstall |
pkgrm |
This section describes the commands, files, and scripts that you might use when manipulating packages. They are described in man pages and in detail throughout this book, in relation to the specific task they perform.
The following table shows the commands to help you build, verify, install, and obtain information about a package.
Table 1–2 Packaging Commands
Task |
Command/ man Page |
Description |
For More Information |
---|---|---|---|
Create packages |
Generates a prototype file for input to the pkgmk command | ||
Creates an installable package |
|
||
Install, remove, and transfer packages |
Installs a software package onto a system | ||
Stores answers to a request script |
|
||
Copies packages onto a distribution medium |
|
||
Removes a package from a system |
|
||
Obtain information about packages |
Verifies the integrity of a software package | ||
Displays software package information |
|
||
Displays package parameter values |
|
||
Modify installed packages |
Incorporates a new package object into an already installed package |
Design Rules for Procedure Scripts and Chapter 5, Case Studies of Package Creation |
|
Removes a package object from an already installed package |
|
The following table shows the information files that help you build a package.
Table 1–3 Package Information Files
File |
Description |
For More Information |
---|---|---|
Package installation defaults file | ||
Package compatibility file | ||
Package copyright information file | ||
Package dependencies file | ||
Package characteristics file | ||
Package contents description file | ||
Package information file | ||
Package disk space requirements file |
The following table describes optional installation scripts that you can write that affect if and how a package is installed.
Table 1–4 Package Installation Scripts
Script |
Description |
For More Information |
---|---|---|
request |
Solicits information from the installer | |
checkinstall |
Gathers file system data | |
preinstall |
Performs any custom installation requirements before class installation | |
postinstall |
Performs any custom installation requirements after all volumes are installed | |
preremove |
Performs any custom removal requirements before class removal | |
postremove |
Performs any custom removal requirements after all classes have been removed | |
Class action |
Performs a series of actions on a specific group of objects |