This appendix is for system administrators who install or remove packages, especially third-party packages. Following these packaging requirements enables the following:
Avoids modifying the currently running system so you can upgrade with Solaris Live Upgrade and create and maintain non-global zones and diskless clients
Prevents a package from being interactive to automate installations when using installation programs such as custom JumpStart
This chapter contains the following sections:
Following the requirements in this section keeps the currently running OS unaltered.
For an installation of an operating system to be successful, packages must recognize and correctly respect alternate root (/) file systems, such as a Solaris Live Upgrade inactive boot environment.
Packages can include absolute paths in their pkgmap file (package map). If these files exist, they are written relative to the -R option of the pkgadd command. Packages that contain both absolute and relative (relocatable) paths can be installed to an alternative root (/) file system as well. $PKG_INSTALL_ROOT is prepended to both absolute and relocatable files so all paths are resolved properly when being installed by pkgadd.
Packages being installed by using the pkgadd -R option or being removed using the pkgrm -R option must not alter the currently running system. This feature is used by custom JumpStart, Solaris Live Upgrade, non-global zones and diskless client.
Any procedure scripts that are included in the packages being installed with the pkgadd command -R option or being removed by using the pkgrm command -R option must not alter the currently running system. Any installation scripts that you provide must reference any directory or file that is prefixed with the $PKG_INSTALL_ROOT variable. The package must write all directories and files with the $PKG_INSTALL_ROOT prefix. The package must not remove directories without a $PKG_INSTALL_ROOT prefix.
Table B–1 provides examples of script syntax.
Table B–1 Examples of Installation Script Syntax
$PKG_INSTALL_ROOT is the location of the root (/) file system of the machine to which you are adding the package. The location is set to the -R argument of the pkgadd command. For example, if the following command is invoked, then $PKG_INSTALL_ROOT becomes /a during the installation of the package.
# pkgadd -R /a SUNWvxvm |
$BASEDIR points to the relocatable base directory into which relocatable package objects are installed. Only relocatable objects are installed here. Nonrelocatable objects (those that have absolute paths in the pkgmap file) are always installed relative to the inactive boot environment, but not relative to the $BASEDIR in effect. If a package has no relocatable objects, then the package is said to be an absolute package (or nonrelocatable), and $BASEDIR is undefined and not available to package procedure scripts.
For example, suppose a package's pkgmap file has two entries:
1 f none sbin/ls 0555 root sys 3541 12322 1002918510 1 f none /sbin/ls2 0555 root sys 3541 12322 2342423332 |
The pkginfo file has a specification for $BASEDIR:
BASEDIR=/opt |
If this package is installed with the following command, then ls is installed in /a/opt/sbin/ls, but ls2 is installed as /a/sbin/ls2.
# pkgadd -R /a SUNWtest |
Your package procedure scripts must be independent of the currently running OS to prevent modifying the OS. Procedure scripts define actions that occur at particular points during package installation and removal. Four procedure scripts can be created with these predefined names: preinstall, postinstall, preremove, and postremove.
Table B–2 Guidelines For Creating Scripts
Guidelines |
Affects Solaris Live Upgrade |
Affects non-global zones |
---|---|---|
Scripts must be written in Bourne shell (/bin/sh). Bourne shell is the interpreter that is used by the pkgadd command to execute the procedure scripts. |
X |
X |
Scripts must not start or stop any processes or depend on the output of commands such as ps or truss, which are operating system dependent and report information about the currently running system. |
X |
X |
Scripts are free to use other standard UNIX commands such as expr, cp, and ls and other commands that facilitate shell scripting. |
X |
X |
Any commands that a script invokes must be available in all supported releases, since a package must run on all of those releases. Therefore, you cannot use commands that were added or removed after the Solaris 8 release. To verify that a specific command or option is supported in a Solaris 8, 9, or 10 release, see the specific version of Solaris Reference Manual AnswerBook on http://docs.sun.com. |
X |
Packages must not execute commands delivered by the package itself. This is to maintain diskless client compatibility and avoids running commands that might require shared libraries that are not installed yet.
All packages must pass pkgchk validation. After a package is created and before it is installed, it must be checked with the following command.
# pkgchk -d dir_name pkg_name |
Specifies the name of the directory where the package resides
Specifies the name of the package
After a package is created, it must be tested by installing it in an alternate root (/) file system location by using the -R dir_name option to pkgadd. After the package is installed, it must be checked for correctness by using pkgchk, as in this example.
# pkgadd -d . -R /a SUNWvxvm # pkgchk -R /a SUNWvxvm |
No errors should be displayed.
If a package exists at /export/SUNWvxvm, then you would issue the following command.
# pkgchk -d /export SUNWvxvm |
No errors should be displayed.
Other commands can check the package when you are creating, modifying, and deleting files. The following commands are some examples.
For example, the dircmp or fssnap commands can be used to verify that packages behave properly.
Also, the ps command can be used for testing daemon compliance by making sure daemons are not stopped or started by the package.
The truss, pkgadd -v, and pkgrm commands can test runtime package installation compliance, but might not work in all situations. In the following example, the truss command strips out all read-only, non-$TEMPDIR access and shows only non-read-only access to paths that do not lie within the specified inactive boot environment.
# TEMPDIR=/a; export TEMPDIR # truss -t open /usr/sbin/pkgadd -R ${TEMPDIR} SUNWvxvm \ 2>&1 > /dev/null | grep -v O_RDONLY | grep -v \ 'open("'${TEMPDIR} |
Packages must be added or removed without the user being prompted for information when using the following standard Solaris utilities.
The custom JumpStart program
Solaris Live Upgrade
Solaris installation program program
Solaris Zones
To test a package to ensure that it will install with no user interaction, a new administration file can be set up with the pkgadd command -a option. The -a option defines an installation administration file to be used in place of the default administration file. Using the default file might result in the user being prompted for more information. You can create an administration file that indicates to pkgadd that it should bypass these checks and install the package without user confirmation. For details, see the man page admin(4) or pkgadd(1M).
The following examples show how the pkgadd command uses the administration file.
If no administration file is provided, pkgadd uses /var/sadm/install/admin/default. Using this file might result in user interaction.
# pkgadd |
If a relative administration file is provided on the command line, pkgadd looks in /var/sadm/install/admin for the file name and uses it. In this example, the relative administration file is named nocheck and pkgadd looks for /var/sadm/install/admin/nocheck.
# pkgadd -a nocheck |
If an absolute file is provided pkgadd uses it. In this example, pkgadd looks in /tmp for the nocheck administration file.
# pkgadd -a /tmp/nocheck |
The following is an example of an installation administration file that requires very little user interaction with the pkgadd utility. Unless the package requires more space than is available on the system, the pkgadd utility uses this file and installs the package without prompting the user for more information.
mail= instance=overwrite partial=nocheck runlevel=nocheck idepend=nocheck space=ask setuid=nocheck confiict=nocheck action=nocheck basedir=default
Packages have parameters that control how their content is distributed and made visible on a system with non-global zones installed. The SUNW_PKG_ALLZONES, SUNW_PKG_HOLLOW, and SUNW_PKG_THISZONE package parameters define the characteristics of packages on a system with zones installed. These parameters must be set so that packages can be administered in a system with non-global zones.
The following table lists the four valid combinations for setting package parameters. If you choose setting combinations that are not listed in the following table, those settings are invalid and result in the package failing to install.
Ensure that you have set all three package parameters. You can leave all three package parameters blank. The package tools interpret a missing zone package parameter as if the setting were “false,” but not setting the parameters is strongly discouraged. By setting all three package parameters, you specify the exact behavior the package tools should exhibit when installing or removing the package.
SUNW_PKG_ALLZONES Setting |
SUNW_PKG_HOLLOW Setting |
SUNW_PKG_THISZONE Setting |
Package Description |
---|---|---|---|
false |
false |
false |
This is the default setting for packages that do not specify values for all the zone package parameters. A package with these settings can be installed in either the global zone or a non-global zone.
In both cases, the entire contents of the package is visible in all zones where the package is installed. |
false |
false |
true |
A package with these settings can be installed in either the global zone or a non-global zone. If new non-global zones are created after the installation, the package is not propagated to these new non-global zones.
In both cases, the entire contents of the package is visible in the zone where the package is installed. |
true |
false |
false |
A package with these settings can be installed in the global zone only. When the pkgadd command is run, the package is installed in the global zone and in all non-global zones. The entire contents of the package is visible in all zones. Note – Any attempt to install the package in a non-global zone fails. |
true |
true |
false |
A package with these settings can only be installed in the global zone, by the global administrator. When the pkgadd command is run, the contents of the package is fully installed in the global zone. If a package has the package parameters set to these values, the package content itself is not delivered on any non-global zone. Only the package installation information necessary to make the package appear to be installed is installed on all non-global zones. This enables the installation of other packages to be installed that depend on this package. For more information on “hollow” packages, see Chapter 24, About Packages and Patches on a Solaris System With Zones Installed (Overview), in System Administration Guide: Solaris Containers-Resource Management and Solaris Zones. For package dependency checking purposes, the package appears to be installed in all zones.
Note – Any attempt to install the package in a non-global zone fails. |
Description |
For More Information |
---|---|
For more details on packages and zones | |
For an overview of sparse and whole root zones | |
For information about package characteristics and parameters | |
For information about displaying package parameter values |
The following references provide background information about packaging requirements and specific command syntax.
For more specific information about packaging requirements and definitions of terminology |
Chapter 6, Advanced Techniques for Creating Packages, in Application Packaging Developer’s Guide |
For basic information about adding and removing packages and the installation administration file |
Chapter 17, Managing Software (Overview), in System Administration Guide: Basic Administration |
For detailed information about specific commands that are referenced in this appendix, see these man pages |
dircmp(1), fssnap(1M), ps(1), or truss(1) pkgadd(1M), pkgchk(1M), or pkgrm(1M) |
For an overview of Solaris Live Upgrade | |
For an overview of custom JumpStart | |
For an overview of Solaris Zones |