All Solaris software installed as part of the operating environment is included in an archive known as a package. Solaris packages provide an easy way to bring together application binaries, configuration files, and documentation for distribution to other systems. In addition to the Solaris packaging system, Solaris also supports standard UNIX archiving and compression tools, such as tar (tape archive) and compress. In this chapter, we examine how you can manage packages using the standard Solaris packaging tools, CLI (Command Line Interface) and admintool. Operations reviewed include installing packages, displaying information about packages, and removing packages using both the CLI tools and the admintool GUI utility.
Packages are text files that contain archives of binary applications, configuration files, documentation, and even source code. All files in the Solaris operating environment are supplied as part of a package, making it easy for you to group files associated with different applications. If files are installed without packaging, it can become difficult over the years for administrators to remember which files were installed with particular applications. Packaging makes it easy to recognize application dependencies, because all files required by a specific application can be included within the archive.
Administrators can use the pkgchk command to examine the package properties of a file that has already been installed:
# pkgchk -l -p /usr/bin/mkdir Pathname: /usr/bin/mkdir Type: regular file Expected mode: 0555 Expected owner: bin Expected group: bin Expected file size (bytes): 9876 Expected sum(1) of contents: 38188 Expected last modification: Oct 06 05:47:55 PM 1998 Referenced by the following packages: SUNWcsu Current status: installed
Another advantage of using packages is that they make use of the standard installation interface provided to install Solaris packages. This means that all Solaris applications are installed using one of two standard installation applications (pkgadd or the admintool), rather than each application having its own installation program. This reduces coding time and makes it easier for administrators to install software, because only a single interface with standard options, such as overwriting existing files, needs to be learned. Using packages reduces the administrative overhead of software management on Solaris 9.
In this chapter, we examine how to install new packages, display information about downloaded packages, and remove packages that have been previously installed on the system, by using both admintool and the command-line package tools.
At any time, you can examine which packages have been installed on a system using the pkginfo command:
# pkginfo application GNUlstdc libstdc++ application GNUmake make system NCRos86r NCR Platform Support, OS Functionality (Root) system SFWaalib ASCII Art Library system SFWaconf GNU autoconf system SFWamake GNU automake system SFWbison GNU bison system SFWemacs GNU Emacs system SFWflex GNU flex system SFWfvwm fvwm virtual window manager system SFWgcc GNU compilers system SFWgdb GNU source-level debugger system SFWgimp GNU Image Manipulation Program system SFWglib GLIB - Library of useful routines for C programming system SFWgm4 GNU m4 system SFWgmake GNU make system SFWgs GNU Ghostscript system SFWgsfot GNU Ghostscript Other Fonts system SFWgsfst GNU Ghostscript Standard Fonts system SFWgtk GTK - The GIMP Toolkit system SFWjpg The Independent JPEG Groups JPEG software system SFWlxrun lxrun system SFWmpage mpage - print multiple pages per sheet system SFWmpeg The MPEG Library system SFWncur ncurses library system SFWolvwm OPEN LOOK Virtual Window Manager system SFWpng PNG reference library
As you can see, this system has quite a few packages installed in both the system and application categories, including lxrun, the application that allows Linux binaries to be executed on Solaris Intel, and the Gimp, a graphics manipulation program. There are no restrictions on the kinds of files and applications that can be installed with packages.
Viewing information about installed packages is easy using the admintool utility’s graphical user interface (GUI). You execute admintool by using the command /usr/ bin/admintool. After choosing Browse | Software from admintool’s menu bar, you can view all the installed software packages, as shown in Figure 11-1. In the figure, you can see that many packages have already been installed on the system, including PC File Viewer Help in Swedish, Italian, French, and German, as well as support files for the ShowTV multimedia software suite.
Using admintool, you can also display only files that have been installed as packages in the system category by deselecting All Software from the software selection drop-down menu, and selecting System Software, as shown in Figure 11-2. Here you can see that several key system packages have been installed, including operating system (OS), Common Desktop Environment (CDE), Open Windows (OW), and 64-bit architecture support for Eastern European, Central European, Southern European, and German locales.
It is also possible to display only files that have been installed as application packages by deselecting System Software from the software selection drop-down menu and selecting Application Software, as shown in Figure 11-3. You can see that several key application packages have been installed, including many support packages for the ShowTV multimedia software suite.
The best way to learn about adding packages is to use an example. In this section, you’ll download a package from http://www.sunfreeware.com called gpw-6.94-sol8-intel-local .gz, which is Tom Van Vleck’s random password creation application. Let’s look more closely at the package name to determine what software this package contains:
The .gz extension indicates that the package file has been compressed using gzip after it was created. Other possible extensions include .Z, which indicates compression with the compress program, while a .z extension suggests compression by the pack program.
The local string indicates that the package contents will be installed under the directory /usr/local. Other typical installation targets include the /opt directory, where optional packages from the Solaris distribution are installed.
The intel string states that the package is intended for use on Solaris Intel and not Solaris Sparc.
The 6.94 string indicates the current software revision level.
The gpw string states the application’s name.
To use the package file, you first need to decompress it using the gzip command:
# gzip -d gpw-6.94-sol8-intel-local
You can then examine the contents of the file by using the head command:
# head gpw-6.94-sol8-intel-local # PaCkAgE DaTaStReAm TVVgpw 1 150 # end of header NAME=gwp ARCH=intel VERSION=6.94 CATEGORY=application VENDOR=Tom Van Vleck EMAILfirstname.lastname@example.org
This kind of header exists for all Solaris packages and makes it easy to understand what platform a package is designed for, who the vendor was, and who to contact for more information.
Now that the package is decompressed and ready, you can begin the installation process by using the pkgadd command. To install the gpw-6.94-sol8-intel-local package, use the following command:
# pkgadd -d gpw-6.94-sol8-intel-local
You’ll see the following output:
The following packages are available: 1 TVVgpw gwp (sparc) 6.94 Select package(s) you wish to process (or 'all' to process all packages). (default: all) [?,??,q]: all
Press ENTER at this point to proceed with the installation:
Processing package instance <<TVVgpw>> from <</tmp/gpw-6.94-sol8-intel-local>> gwp (sparc) 6.94 Tom Van Vleck Using <</usr/local>> as the package base directory. ## Processing package information. ## Processing system information. 2 package pathnames are already properly installed. ## Verifying disk space requirements. ## Checking for conflicts with packages already installed. ## Checking for setuid/setgid programs. Installing gwp as <<TVVgpw>> ## Installing part 1 of 1. /usr/local/bin/gpw /usr/local/doc/gpw/README.gpw [ verifying class <<none>> ] Installation of <<TVVgpw>> was successful.
After processing package and system information and checking that the required amount of disk space is available, the pkgadd command copies only two files from the archive to the local file system: /usr/local/bin/gpwand/usr/local/doc/ gpw/ README.gpw.
After a package has been installed on the system, it can easily be removed by using the pkgrm command. For example, if you wanted to remove the gpw program after it was installed in the /usr/local directory, you would use this command
# pkgrm TVVgpw
and respond to the following information:
The following package is currently installed: TVVgpw gwp (sparc) 6.94 Do you want to remove this package? y ## Removing installed package instance <<TVVgpw>> ## Verifying package dependencies. ## Processing package information. ## Removing pathnames in class <<none>> /usr/local/doc/gpw/README.gpw /usr/local/doc/gpw /usr/local/doc <<shared pathname not removed>> /usr/local/bin/gpw /usr/local/bin <<shared pathname not removed>> ## Updating system information. Removal of <<TVVgpw>> was successful.
The pkgrm command also operates in an interactive mode, in which multiple packages can be removed using the same interface:
# pkgrm The following packages are available: 1 GNUlstdc libstdc++ (i86pc) 184.108.40.206 2 GNUmake make (i86pc) 3.77 3 NCRos86r NCR Platform Support, OS Functionality (Root) (i386) 1.1.0,REV=1998.08.07.12.41 4 SFWaalib ASCII Art Library (i386) 1.2,REV=19220.127.116.11.32 5 SFWaconf GNU autoconf (i386) 2.13,REV=1918.104.22.168.32 6 SFWamake GNU automake (i386) 1.4,REV=1922.214.171.124.32 7 SFWbison GNU bison (i386) 1.28,REV=19126.96.36.199.32 8 SFWemacs GNU Emacs (i386) 20.4,REV=19188.8.131.52.32 9 SFWflex GNU flex (i386) 2.5.4,REV=19184.108.40.206.32 10 SFWfvwm fvwm virtual window manager (i386) 2.2.2,REV=19220.127.116.11.32 ... 288 more menu choices to follow; <<RETURN>> for more choices, <<CTRL-D>> to stop display:
At this point, you can enter the number of the package that you wish to remove.
As shown in Figure 11-4, admintool provides an easy-to-use interface for installing packages, in which the following options may be selected from drop-down boxes:
Check for existing files.
Check for existing packages.
Check for existing partial installations.
Allow setuid/setgid files to be installed.
Allow setuid/setgid scripts to be run.
Check that installation dependencies have been met.
Check that removal dependencies have been met.
Check for correct run level.
Check for sufficient space.
Run the installation interactively.
Figure 11-4: The admintool GUI for adding packages.
The admintool also allows the administrator to specify an installation source, so that packages may be installed directly from a CD-ROM, as shown in Figure 11-5.
Once a valid CD-ROM directory containing packages has been selected, the Add Software interface is displayed, as shown in Figure 11-6. The left-hand pane shows the full titles for the packages that have been located in the specified directory. The right-hand pane shows the description of the last selected software package. For example, the package SUNWcesh, shown in Figure 11-6, is the Sun Management Center Simplified Chinese Help package distributed by Sun Microsystems and is less than 1MB in size when installed.
You should always verify that sufficient space is available in the indicated partitions by checking the Space Meter shown in Figure 11-7. Here you can see that more than sufficient space is available for installing the required files for the SUNWcesh package.
After checking the boxes associated with every package that you wish to install, you can proceed with installation by clicking the Add button. A separate installation window then appears, as shown in Figure 11-8. In this example, the SUNWescon software package (the Sun Management Center console package) is being installed. After setting the installation target directory (/opt), package and system information is processed. After disk space requirements have been verified, any conflicts with existing packages are identified. Next, all setuid and setgid applications are identified, and assent must be granted to install any setuid or setgid files that are found in the package. Finally, the files are installed into their appropriate target directories.
Packages may also be installed from a special package spooling directory, at /var/spool/pkg, using the admintool utility, or from any directory that contains a valid package file, as shown in Figure 11-9. The /var/spool/pkg folder has an important role in upgrading machines in an automated fashion, since it can be mounted automatically using the Network File System (NFS) and the automounter from another server. It is possible to use a script or a cron job to then noninteractively install or upgrade new software.
After a valid spooling directory containing packages has been selected, the Add Software interface is displayed, as shown in Figure 11-10. The left-hand pane shows all the full titles for the packages that have been located in the specified directory. The right-hand pane shows the description of the last selected software package. The only package shown is SUNWcesh. After checking the boxes associate with the SUNWcesh package, you can proceed with installation by clicking the Add button. A separate installation window appears, and the software is installed.
After a package has been installed on the system, it can easily be removed by using admintool. Choose Browse | Software, highlight the package that you wish to remove, and then choose Edit | Delete. A popup window then appears, as shown in Figure 11-11, asking for confirmation of the deletion instruction.
After you click OK, a separate window will show the output of the package removal:
The following package is currently installed: SUNWdesmt ShowMe TV German Localization Files (sparc) 1.1,REV=1999.04.30 Do you want to remove this package? y ## Removing installed package instance <<SUNWdesmt>> ## Verifying package dependencies. ## Processing package information. ## Removing pathnames in class <<none>> /opt/SUNWsmtv/lib/locale/de/share/showmetv-defaults /opt/SUNWsmtv/lib/locale/de/share /opt/SUNWsmtv/lib/locale/de/help/xdh_saveFile.html /opt/SUNWsmtv/lib/locale/de/help/xdh_printItem.html /opt/SUNWsmtv/lib/locale/de/help/xdh_openFile.html /opt/SUNWsmtv/lib/locale/de/help/xdh_historyDialog.html /opt/SUNWsmtv/lib/locale/de/help/xdh_findText.html /opt/SUNWsmtv/lib/locale/de/help/xdh_entry.html /opt/SUNWsmtv/lib/locale/de/help/watchtimer.html /opt/SUNWsmtv/lib/locale/de/help/videosettings.html /opt/SUNWsmtv/lib/locale/de/help/undelete.html /opt/SUNWsmtv/lib/locale/de/help/transmitterproperties.html /opt/SUNWsmtv/lib/locale/de/help/transmitter.html /opt/SUNWsmtv/lib/locale/de/help/statistics.html /opt/SUNWsmtv/lib/locale/de/help/showcards.html /opt/SUNWsmtv/lib/locale/de/help/recordtimer.html /opt/SUNWsmtv/lib/locale/de/help/record.html /opt/SUNWsmtv/lib/locale/de/help/receiver.html /opt/SUNWsmtv/lib/locale/de/help/properties.html /opt/SUNWsmtv/lib/locale/de/help/programinfo.html /opt/SUNWsmtv/lib/locale/de/help/printsnap.html /opt/SUNWsmtv/lib/locale/de/help/printformat.html /opt/SUNWsmtv/lib/locale/de/help/print.html /opt/SUNWsmtv/lib/locale/de/help/preview.html /opt/SUNWsmtv/lib/locale/de/help/preferences.html /opt/SUNWsmtv/lib/locale/de/help/open.html /opt/SUNWsmtv/lib/locale/de/help/new.html /opt/SUNWsmtv/lib/locale/de/help/mail.html /opt/SUNWsmtv/lib/locale/de/help/import.html /opt/SUNWsmtv/lib/locale/de/help/group.html /opt/SUNWsmtv/lib/locale/de/help/findres.html /opt/SUNWsmtv/lib/locale/de/help/filewindow.html /opt/SUNWsmtv/lib/locale/de/help/exportcards.html /opt/SUNWsmtv/lib/locale/de/help/broadcast.html /opt/SUNWsmtv/lib/locale/de/help/addrbook.html /opt/SUNWsmtv/lib/locale/de/help/addfields.html /opt/SUNWsmtv/lib/locale/de/help ... ## Updating system information. Removal of <SUNWdesmt> was successful. press <Return> to continue
The Solstice Launcher is part of an integrated suite of system administration tools which are an alternative to admintool and the command-line toolset. Solstice maintains a separate application registry that determines which applications are displayed in the Launcher, in addition to Sun’s own tools. Thus, it is possible to customize the interface to suit local requirements. Note that the application package must have been already installed prior to registry addition.
To add an application to the registry, the /usr/snadm/bin/soladdapp command is used. For example, to add an application called Database Query, the following command could be used:
# soladdapp -r /opt/SUNWadm/etc/.solstice_registry \ -n "Database Query" \ -i /usr/local/CSWdbquery/dbquery.xpm \ -e /usr/local/CSWdbquery/bin/dbquery
This would add an item for Database Query with the path to the application set to /usr/local/CSWdbquery/bin/dbquery, an icon located in /usr/local/CSWdbquery/ dbquery.xpm, and the default registry path of /opt/SUNWadm/etc/.solstice_registry.
In a similar fashion, an application can be removed from the registry by using the /usr/snadm/bin/soldelapp command. In this case, the name of the package must be supplied, along with the registry path:
# /usr/snadm/bin/soldelapp \ -r /opt/SUNWadm/etc/.solstice_registry \ -n "Database Query"
Note that this does not delete the application package from the system.
Table 11-1 summarizes the various commands used to create, install, and remove packages.
Creates a prototype file that specifies the files contained in a package
Creates a package directory
Installs a package from a package file
Converts a package directory into a file
Uninstalls a package
Verifies that a package is valid
Prints the contents of a package
The install command is not part of the standard package tools, but is often used in scripts to copy files from a source to destination directory, as part of an installation process. It does not require super-user privileges to execute, and will not overwrite files unless the effective user has permission. However, if the super-user is executing the command, then files can be written with a specific username, group membership, and octal permissions code. This allows a super-user to install multiple files with different permissions, and ownership different to root.
The three ownership and permission options are specified by:
-m Octal permissions code
-u File owner
-g Group membership
There are four options that indicate which operations are to be performed:
-c Copies a source file to a target directory
-f Overwrite the target file with a source file if the former exists
-n Copies a source file to a target directory if and only if it does not exist in any of a specified set of directories
-d Create a directory
To install the file /tmp/setup_server.sh to the directory /opt/scripts, as the user bin and group sysadmin, the following command would be used:
# install –c /opt/scripts –m 0755 –u bin –g sysadmin /tmp/setup_scripts