OpenSolaris 2009.06 Image Packaging System Guide
Previous Next

Installing and Managing Packages

The Image Packaging System enables users to connect to a repository and download and install software applications. These software applications are available as packages in a repository. The default repository for the OpenSolaris 2009.06 system is http://pkg.opensolaris.org.

How to Install or Update a Package

Before You Begin

When installing or updating packages, the packages are first searched for in the preferred publisher's repository catalog. If the packages are not found in the preferred publisher's catalog, then the catalogs of the remaining publishers are searched.

The preferred publisher for an OpenSolaris 2009.06 system is opensolaris.org, and the packages are retrieved from the http://pkg.opensolaris.org/release repository.

To change the preferred publisher, see How to Add or Update a Publisher.

  • Use the following command to install or update a package.

    $ pfexec pkg install [-vq] pkg_fmri


    Note - The pkg install command will automatically retrieve the newest package information available from the configured publishers for an image when necessary. The pkg install command can also be used to upgrade one or more packages, and will automatically upgrade package dependencies when necessary.


Example 3-1 Install a Package

This example installs the SUNWphp524-mysql package. The output displays the status of the download, number of packages that were installed, number of files that were installed and the size (in megabytes) of the download.

$ pfexec pkg install SUNWphp524-mysql
DOWNLOAD                PKGS       FILES     XFER (MB)
Completed                     4/4     362/362   86.93/86.93

PHASE                   ACTIONS
Install Phase           493/493
PHASE                    ITEMS
Reading Existing Index   7/7
Example 3-2 Install a Package From a Specific Publisher

When an image is created, a preferred publisher is set and this is the default publisher from which packages are downloaded and installed.

This example installs the SUNWphp524-mysql package from the example.opensolaris.org publisher.

$ pfexec pkg install pkg://example.opensolaris.org/SUNWphp524-mysql
More Information
Dry-Run Installation

Before installing packages, you have the option to perform a dry—run installation. A dry run enables you to execute the command without making persistent changes to the image. The dry—run option does not install any packages and only shows the changes that are made if the packages are installed. For details on how to perform a dry-run installation, see How to Perform a Dry-Run Installation Inside a New Image.

How to Perform a Dry-Run Installation Inside a New Image

  • Use the following command to execute a dry-run installation.

    $ pfexec pkg install -n [-v] pkg_fmri


    Note - pkg_fmri refers to a package name along with a version number and a sub-version number, if applicable. See the pkg(1) Uses FMRIs section for more information about fmris.


Example 3-3 Performing a Dry-Run Installation of the amp Package

The following example shows a dry-run installation of the amp package with verbose (-v) output.

$ pfexec pkg install -nv amp
$ pfexec pkg install -nv amp
Creating Plan | Before evaluation:
UNEVALUATED:
+pkg:/[email protected],5.11-0.110:20090320T185834Z

After evaluation:
None -> pkg:/[email protected],5.11-0.110:20090320T185834Z
None -> pkg:/[email protected],5.11-0.110:20090320T183517Z
None -> pkg:/[email protected],5.11-0.110:20090320T182401Z
None -> pkg:/[email protected],5.11-0.110:20090320T184937Z
None -> pkg:/[email protected],5.11-0.110:20090320T181123Z
None -> pkg:/[email protected],5.11-0.110:20090320T174003Z
None -> pkg:/[email protected],5.11-0.110:20090320T173257Z
None -> pkg:/[email protected],5.11-0.110:20090320T173337Z
None -> pkg:/[email protected],5.11-0.110:20090320T173342Z
None -> pkg:/[email protected],5.11-0.110:20090320T173316Z
None -> pkg:/[email protected],5.11-0.110:20090320T173320Z
None -> pkg:/[email protected],5.11-0.110:20090320T173324Z
None -> pkg:/[email protected],5.11-0.110:20090320T173330Z
Actuators:
      restart_fmri: svc:/system/manifest-import:default

How to Search for Packages

  • Use the following command to search for packages based on the various properties indexed by the packaging system. The server represents the origin_uri of a repository.

    $ pkg search [-alprI] [-s server] query

    By default, the search command searches for the package in the repository or repositories associated with the current image. Use the -l option to search only the installed packages for the current image.

    By default, the search results list the matching actions contained within a package's manifest. Use the -p option to display the results as a list of unique packages instead.

Example 3-4 Search for a Package in the Installed Image

The following example searches for the SUNWbash package in the installed image.

$ pkg search -l SUNWbash
INDEX      ACTION    VALUE        PACKAGE
fmri       set       fmri         pkg:/[email protected]
legacy_pkg legacy    SUNWbash     pkg:/[email protected]
Example 3-5 Search for a Package in a Remote Repository

The following example searches for the amp package in the remote (-r) repository associated with the current image.

$ pkg search -r amp
INDEX      ACTION    VALUE     PACKAGE
description set       AMP    pkg:/[email protected]
description set       AMP    pkg:/[email protected]
description set       AMP    pkg:/[email protected]
description set       AMP    pkg:/[email protected]
description set       AMP    pkg:/[email protected]
description set       AMP    pkg:/[email protected]
description set       AMP    pkg:/[email protected]
description set       AMP    pkg:/[email protected]
description set       AMP    pkg:/[email protected]
Example 3-6 Search for a Package by Description

The following example searches for a book package. Generally, the complete metadata of the package, such as attribute values, path names, file names, descriptions and so on are searched. Hence, the search results will display a list of all packages that contain the search term in path, file name, description, and so on.

$ pkg search book
INDEX      ACTION    VALUE                                 PACKAGE
basename   dir       usr/share/doc/gtkmm-2.4/examples/book pkg:/[email protected]
basename   dir       usr/share/doc/gtkmm-2.4/examples/book pkg:/[email protected]
basename   dir       usr/share/doc/gtkmm-2.4/examples/book pkg:/[email protected]
basename   dir       usr/share/doc/gtkmm-2.4/examples/book pkg:/[email protected]
basename   dir       usr/share/doc/gtkmm-2.4/examples/book pkg:/[email protected]
basename   dir       usr/share/doc/gtkmm-2.4/examples/book pkg:/[email protected]
basename   dir       usr/share/doc/gtkmm-2.4/examples/book pkg:/[email protected]
basename   dir       usr/share/doc/gtkmm-2.4/examples/book pkg:/[email protected]
basename   dir       usr/share/doc/gtkmm-2.4/examples/book pkg:/[email protected]
basename   dir       usr/share/doc/gtkmm-2.4/examples/book pkg:/[email protected]
basename   dir       usr/share/doc/gtkmm-2.4/examples/book pkg:/[email protected]
description set       book                                 pkg:/[email protected]
~

How to List the Contents of a Package

  • Use the following command to list the action attributes of a package.

    $ pkg contents [-Hmr] [-o attribute] [-s sort_key] [-t action_type] pkg_fmri

Example 3-7 Listing the Contents of a Package

This example lists the name, mode of the file, size, path and the target of the following actions in the SUNWzfs package:

  • dir

  • file

  • link

  • hardlink

If the package is not installed, use the -r option to retrieve the contents of the package from the server.

$ pkg contents -t dir,file,link,hardlink -o action.name,mode,pkg.size,path,target zfs
NAME  MODE   SIZE PATH                      TARGET
dir   0755        etc
dir   0755        etc/fs
dir   0755        etc/fs/zfs
link              etc/fs/zfs/mount          ../../../sbin/zfs
link              etc/fs/zfs/umount         ../../../sbin/zfs
dir   0755        etc/zfs
dir   0755        lib
dir   0755        lib/amd64
link              lib/amd64/libzfs.so        libzfs.so.1
file  0755 469616 lib/amd64/libzfs.so.1
file  0644  62057 lib/amd64/llib-lzfs.ln
link              lib/libzfs.so              libzfs.so.1
     [ ... ]

How to Display Information About a Package

  • Use the following command to display information about a package. If no pkg_fmri is specified, information about all installed packages is displayed.
    $ pkg info [-lr] [--license] pkg_fmri
Example 3-8 Display Package Information

This example displays information about the amp package. This example uses the -r option to retrieve the data from the servers if the package is not installed.

$ pkg info -r amp
          Name: amp
       Summary: Cluster containing an AMP (Apache, MySQL, PHP) deployment kit
      Category: Web Services/Application and Web Servers
         State: Not installed
     Publisher: OpenSolaris
       Version: 0.5.11
 Build Release: 5.11
        Branch: 0.110
Packaging Date: Fri Mar 20 18:58:34 2009
          Size: 0.00 B
          FMRI: pkg:/[email protected],5.11-0.110:20090320T185834Z
Example 3-9 Display Copyright and License Information About a Package

This example displays the copyright and license information about the SUNWGlib package. This example uses the -r option to retrieve the data from the servers if the package is not installed.

$ pkg info --license -r SUNWGlib
Copyright (C) 1995-1997  Peter Mattis, Spencer Kimball and Josh MacDonald

 This library is free software; you can redistribute it and/or
 modify it under the terms of the GNU Library General Public
 License as published by the Free Software Foundation; either
 version 2 of the License, or (at your option) any later version.

 This library is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 Library General Public License for more details.

 You should have received a copy of the GNU Library General Public
 License along with this library; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.

 Modified by the GLib Team and others 1997-1999.  See the AUTHORS
 file for a list of people on the GLib Team.  See the ChangeLog
 files for a list of changes.  These files are distributed with
 GLib at ftp://ftp.gtk.org/pub/gtk/. 

How to Display Package State and Version Information

  • Use the following command to uninstall existing packages.

    $ pfexec pkg list [-aHsuvf] pkg_fmri

Example 3-10 Display the most recent version information of all known versions of a package.

This example uses the -a option to retrieve the information about all known versions of the package, whether installed or not.

$ pkg list -a amp
NAME (PUBLISHER)         VERSION         STATE      UFIX
amp                      0.5.11-0.110    known      ----
amp (osrelease)          0.5.11-0.101    known      u---

How to Uninstall Packages

  • Use the following command to uninstall existing packages.

    $ pfexec pkg uninstall [-nvr] pkg_fmri

Example 3-11 Uninstalling a Package

This example uninstalls the SUNWphp524-mysqlpackage.

$ pfexec pkg uninstall SUNWphp524-mysql
PHASE        ACTIONS
Removal Phase  39/39 

How to Display Publisher Information

  • Type the following command to display information about a publisher. If no arguments are specified, the associated repositories, the repository's associated origins and any available mirrors are displayed along with the name of the publisher.

    $ pkg publisher [-H] publisher

Example 3-12 Displaying Publisher Information
$ pkg publisher
publisher                   TYPE    STATUS   URL
opensolaris.org (preferred) origin  online   http://pkg.opensolaris.org/release

How to Add or Update a Publisher

  • Type the following command to update an existing publisher or add an additional package publisher.

    $ pfexec pkg set-publisher [-P] [-k ssl_key] [-c ssl_cert] [-O origin_url] publisher


    Note - Command-line options are case-sensitive. Specify -O and -P in uppercase.


Example 3-13 Adding an Additional Package Publisher
$ pfexec pkg set-publisher -O  http://pkg.opensolaris.org/release osrelease
$ pkg publisher
PUBLISHER                     TYPE     STATUS   URI
OpenSolaris      (preferred)  origin   online   http://pkg.opensolaris.org/dev/
osrelease                     origin   online   http://pkg.opensolaris.org/release/
Example 3-14 Setting a Preferred Publisher

Use the -P option along with the -O option to set a publisher as the preferred publisher. The preferred publisher's repository will be searched first when performing package operations such as install or upgrade.

$ pfexec pkg set-publisher -P -O http://pkg.sunfreeware.com sunfreeware.com
$ pkg publisher
PUBLISHER                     TYPE     STATUS   URI
OpenSolaris                   origin   online   http://pkg.opensolaris.org/dev/
osrelease                     origin   online   http://pkg.opensolaris.org/release/
sunfreeware.com (preferred)   origin   online   http://pkg.sunfreeware.com
More Information
Naming of Publishers

A publisher is an identifier for a person, groups of persons, or a corporation that publishes a package.

A publisher name can be any one of the following types:

  • A host-like string such as opensolaris.org, sunfreeware.org and so on

  • A forward domain name such as extra.opensolaris.org

  • A reverse domain name such as org.opensolaris.extra

  • An identifier such as opensolarisextra

See Also

The pkg set-publisher command is also used to add and remove mirror repositories. For more information, see Chapter 8, Mirroring Repositories.

How to Remove Publisher Configuration

  1. (Optional) A publisher cannot be removed if it is set to be the preferred publisher. Set a different publisher to be the preferred publisher before removing the publisher.

    $ pfexec pkg set-publisher -P -O repository publisher

  2. Type the following command to remove the configuration information associated with a given publisher.

    $ pfexec pkg unset-publisher publisher

Example 3-15 Removing a Preferred Publisher

In this example, the preferred publisher is first changed from sunfreeware.com to opensolaris.org using the set-publisher command. Then the sunfreeware.com publisher is removed.

$ pkg publisher
PUBLISHER                     TYPE     STATUS   URI
OpenSolaris                   origin   online   http://pkg.opensolaris.org/dev/
osrelease                     origin   online   http://pkg.opensolaris.org/release/
sunfreeware.com (preferred)   origin   online   http://pkg.sunfreeware.com
$ pfexec pkg set-publisher -P -O http://pkg.opensolaris.org/release opensolaris.org
$ pfexec pkg unset-publisher sunfreeware.com
$ pkg publisher
publisher                    TYPE    STATUS URL
opensolaris.org (preferred)  origin  online http://pkg.opensolaris.org/release

How to Update a Package

  • If a newer version of an installed package is available in the repository, install the package to obtain the latest available version.

    $ pfexec pkg install package_fmri

How to View the Operation History

  • Type the following command to view the operation history of the current image.

    $ pkg history [-Hl]

Example 3-16 View Detailed Command History
$ pkg history -l
      Operation: purge-history
        Outcome: Succeeded
         Client: pkg
        Version: 216d2efd0c27
           User: root (0)
     Start Time: 2008-11-06T09:33:44
       End Time: 2008-11-06T09:33:44
        Command: /usr/bin/pkg -R /export/home/dc/build_data/pkg_image purge-history

      Operation: uninstall
        Outcome: Succeeded
         Client: pkg
        Version: 216d2efd0c27
           User: jack (65432)
     Start Time: 2008-11-07T14:04:34
       End Time: 2008-11-07T14:04:59
        Command: /usr/bin/pkg -R /a uninstall -q --no-index SUNWslim-utils
    Start State:
        UNEVALUATED:
    -pkg:/[email protected],5.11-0.101:20081104T034320Z
     End State:
     pkg:/[email protected],5.11-0.101:20081104T034320Z -> None

      Operation: set-authority
        Outcome: Succeeded
         Client: pkg
        Version: 216d2efd0c27
           User: jack (65432)
     Start Time: 2008-11-07T14:05:01
       End Time: 2008-11-07T14:05:01
        Command: /usr/bin/pkg -R /a set-authority --reset-uuid opensolaris.org

      End State:
pkg:/[email protected],5.11-0.100:20081025T020505Z -> None

      Operation: install
        Outcome: Failed (Unknown)
         Client: packagemanager
        Version: 71eab3488987
           User: jack (101)
     Start Time: 2008-10-29T11:31:13
       End Time: 2008-10-29T11:32:04
        Command: /usr/bin/packagemanager

How to Delete Operation History

  • Type the following command to delete all the existing history information.

    $ pfexec pkg purge-history

How to View the List of Available Commands

  • Type the following command to view the list of available commands.

    $ pkg help

Previous Next