Getting Started With OpenSolaris 2008.05
Previous Next

IPS for End Users (Tasks)

The following section provides information for end users to install, upgrade, search, and manage packages in the IPS repository.

Installing, Upgrading, and Managing Packages

The pkg(1) command is the retrieval client for the image packaging system.

pkg(1) can be invoked to perform the following actions :

  • Create an image – pkg image-create.

  • Install new packages or update existing packages – pkg install.

  • Search for packages – pkg search.

  • Update all existing packages within an image – pkg image-update.

  • Display information about the state of packages – pkg list.

  • Verify packages have been installed correctly – pkg verify.

  • Display information about a package – pkg info.

  • Display attributes of actions – pkg contents.

  • Uninstall packages – pkg uninstall.

  • Update an existing authority or add additional package authority – pkg set-authority.

  • Remove the configuration associated with the given authority – pkg unset-authority.

  • Display authority information – pkg authority.

Refer to the pkg(1) Command Reference and the pkg(1) man page to learn more about the subcommands and options for the pkg(1) command.

pkg(1) Uses FMRIs

Each IPS package is represented by a Fault Management Resource Identifier (FMRI). Thepkg(1) command uses valid FMRI package information to perform its command actions.

The FMRI includes descriptive information about the package, such as the package name, version information, and date.

For example, the FMRI, pkg://opensolaris.org/library/libc@5.11,5.11-0.75:20071001T163427Z, consists of the following sequence of information :

  • Scheme – pkg

  • Authority – opensolaris.org

  • Package Name – libc

  • Version String – Consists of four components :

    • Component Version – 5.11

    • Build Version – 5.11

    • Branch Version – 0.75

    • Timestamp – 20071001T163427Z

Creating Images

The pkg(1) command is used to create an image.

An installed OpenSolaris 2008.05 release on your system, constitutes an image. Packages can be installed directly within this image. New images are created to mark a boundary between the packages installed in different images.

The image-create command sets up a relationship between the image and a server that can be accessed to add packages to the image.

Images can be of three types:

  • Full images, capable of providing a complete system.

  • Partial images, which are linked to a full image (parent image), but do not provide a complete system on their own.

  • User images, which contain only relocatable packages.

How to Create an Image
Before You Begin

Refer to the pkg(1) Command Reference for a table of all the options associated with this command.

Ensure that you have write privileges to the directory where you are attempting to create an image.

  • Use the following command to create an image. A user image is created by default.

    pkg image-create -[FPUz] -a prefix=repository_url directory_location

Example 2-1 Creating a Full Image

In this example, a full image is created with a repository server, http://pkg.example.com. The image is created in the directory, /aux0/example_root. The -a option is used to specify a server such as http://pkg.example.com:10000.

$ pkg image-create -F -a example.com=http://pkg.example.com:10000 /aux0/example_root
How to Perform a Dry-Run Installation Inside a New Image

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.

Before You Begin

Refer to the pkg(1) Command Reference for a table of all the options associated with this command.

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

    $ pkg install [-nv] pkg_fmri


    Note - pkg_fmri refers to a package name along with a version number and a subversion number, if applicable.


Example 2-2 Performing a Dry-Run Installation of the SUNWzsh Package

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

$ pkg install -nv SUNWzsh
UNEVALUATED:+pkg:/SUNWzsh@4.2.5,5.11-0.75:20071019T203321Z
one -> pkg:/SUNWlibms@0.5.11,5.11-0.75:20071024T204210Z
[dir, file, link, and other actions for each resource delivered by
this package and succeeding packages omitted]
None -> pkg:/SUNWzlib@1.2.3,5.11-0.75:20071024T204906Z
None -> pkg:/SUNWlxml@2.6.23,5.11-0.75:20071024T204221Z
None -> pkg:/SUNWpool@0.5.11,5.11-0.75:20071024T204717Z
None -> pkg:/SUNWpr@0.5.11,5.11-0.75:20071024T204720Z
None -> pkg:/SUNWlibsasl@0.5.11,5.11-0.75:20071024T204217Z
None -> pkg:/SUNWtls@0.5.11,5.11-0.75:20071024T202854Z
None -> pkg:/SUNWopenssl@0.9.8,5.11-0.75:20071024T204623Z
None -> pkg:/SUNWcsl@0.5.11,5.11-0.75:20071024T202529Z
None -> pkg:/SUNWlibC@0.5.11,5.11-0.75:20071024T204202Z
None -> pkg:/SUNWpcre@7.0,5.11-0.75:20071019T202909Z
None -> pkg:/SUNWzsh@4.2.5,5.11-0.75:20071019T203321Z
How to Install a Package
Before You Begin

Refer to the pkg(1) Command Reference for a table of all the options associated with this command.

  • Use the following command to install a package.

    $ pkg install [-v] pkg_fmri


    Note - The pkg install command is also used to update specific packages on the system. The pkg install command automatically checks for newer versions of specific packages or package groups and installs them if they are available. Any dependent packages are also automatically updated.


Example 2-3 Install a Package

This example installs a 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.

$ pkg install SUNWphp524-mysql
DOWNLOAD     PKGS       FILES     XFER (MB)
Completed    3/3     301/301     123.70/123.70

PHASE               ACTIONS
Update Phase          2/2
Install Phase       404/404
 
Example 2-4 Install a Package From a Different Repository

See the How to Add or Update an Authority section to set an authority. The package is then installed from the set authority.

This example installs the SUNWphp524-mysql package from the http://example.opensolaris.org authority.

$ pkg install pkg:/example.opensolaris.org/SUNWphp524-mysql
How to Verify a Package Installation
Before You Begin

Refer to the pkg(1) Command Reference for a table of all the options associated with this command.

  • Use the following command to verify the installation of a package. Use the -v option for verbose output.

    # pkg verify [-fv] pkg_fmri


    Note - Switch to root user before executing the pkg verify command.


Example 2-5 Verify Package Installation

In this example, the installation of SUNWphp524-mysql package is verified.

# pkg verify -v SUNWphp524-mysql
PACKAGE                       STATUS
pkg:/SUNWphp524-mysql         OK
How to Search for Packages
Before You Begin

Refer to the pkg(1) Command Reference for a table of all the options associated with this command.


Note - If you are searching for a package in a remote repository, switch to root user and run the pkg refresh command to retrieve updated contents of the repository associated with the current image.


  • Use the following command to search for packages based on the various properties indexed by the packaging system.

    $ pkg search [-lr] [-s repository_url] token

Example 2-6 Search for a Package in the Installed Image

The following example searches and locates the SUNWbash package in the installed image.

pkg search SUNWbash
legacy_pkg legacy SUNWbash pkg:/SUNWbash@3.2.25,5.11-0.79:20080205T152506Z
Example 2-7 Search for a Package in a Remote Repository

In this example, the pkg search command searches for the token bge in the remote (-r) repository associated with the current image.

$ pkg search -r bge
basename pkg:/SUNWbge@0.5.11,5.11-0.75:20071114T203134Z
driver_name pkg:/SUNWbge@0.5.11,5.11-0.75:20071114T203134Z
basename pkg:/SUNWbge@0.5.11,5.11-0.79:20080205T180828Z
driver_name pkg:/SUNWbge@0.5.11,5.11-0.79:20080205T180828Z
basename pkg:/SUNWbge@0.5.11,5.11-0.75:20071031T180039Z
driver_name pkg:/SUNWbge@0.5.11,5.11-0.75:20071031T180039Z
How to Update All Installed Packages
Before You Begin

Refer to the pkg(1) Command Reference for a table of all the options associated with this command.

  • Use the following command to update all packages in the current image to the latest version.

    $ pkg image-update

See Also

The pkg image-update command can also be used to upgrade an installed boot environment. For more information, see theUpgrading a Boot Environment section.

How to Display the State of Packages
Before You Begin

Refer to the pkg(1) Command Reference for a table of all the options associated with this command.

  • Use the following command to see the state of packages.

    $ pkg list [-aHsuv] pkg_fmri

Example 2-8 Displaying the State of an Installed Package

The following example shows the status of the SUNWbash package with the -v option, which displays the full FMRI information. This example shows information only about the installed SUNWbash package.

$ pkg list -v SUNWbash
FMRI                                                    STATE      UFIX
pkg:/SUNWbash@3.2.25,5.11-0.79:20080205T152506Z     installed  ----      
Example 2-9 Displaying the State of All Instances of a Package

This example shows the state of all instances of the SUNWbash package.

pkg list -a SUNWbash
NAME (AUTHORITY) VERSION         STATE      UFIX
SUNWbash         3.2.25-0.86    installed  ----
SUNWbash         3.2.25-0.79    known      u---
SUNWbash         3.2.25-0.75    known      u---
SUNWbash         3.2.25-0.75    known      u---
How to List the Action Attributes of a Package
Before You Begin

Refer to the pkg(1) Command Reference for a table of all the options associated with this command.

See the Actions in IPS section to become familiar with the actions associated with a package.

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

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

Example 2-10 Listing the Contents of a Package

In this example, we will list the name, mode of the file, size, path and the target of the following actions in the zfs package:

  • dir

  • file

  • link

  • hardlink

$ 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
     [ ... ]
Example 2-11 Displaying Complete Contents of a Package

This example uses the -m option with the pkg contents command to display all actions of the SUNWbash package.

                $ pkg contents -m SUNWbash
                set fmri = pkg://opensolaris.org
                /SUNWbash@3.2.25,5.11-0.79:20080205T152506Z
                dir owner=root path=usr group=sys mode=0755
                dir owner=root path=usr/bin group=bin mode=0755
                dir owner=root path=usr/gnu group=bin mode=0755
                dir owner=root path=usr/gnu/bin group=bin mode=0755
                depend fmri=pkg:/SUNWcsl@0.5.11-0.79 type=require
                file 66d09735123ad3a7bdcf7640dd60acbe843d8a13
                elfhash=28106285f73f97274cf99b1a7e63d7d73c31c153 elfarch=i386 mode=0555 
                pkg.size=730604 owner=root group=bin path=usr/bin/bash elfbits=32
                legacy category=system vendor="Sun Microsystems, Inc."
                name="GNU Bourne-Again shell (bash)" 
                version=11.11.0,REV=2007.11.29.14.44 hotline="Please contact your local service provider" 
                pkg=SUNWbash arch=i386 desc="GNU Bourne-Again shell (bash) version 3.2"
                license ed881c52c54b67457db33ba23a1d53615e366440 path=copyright 
                license=SUNWbash.copyright
                transaction_id=1202253906_pkg%3A%2FSUNWbash%
                403.2.25%2C5.11-0.79%3A20080205T152506Z pkg.size=1207
                link path=usr/gnu/bin/sh target=../../bin/bash
                set name=description value="GNU Bourne-Again shell (bash)"
                set fmri = pkg://VERSION_1
                /SUNWbash@3.2.25,5.11-0.79:20080205T152506Z
                dir owner=root path=usr group=sys mode=0755
                dir owner=root path=usr/bin group=bin mode=0755
                dir owner=root path=usr/gnu group=bin mode=0755
                dir owner=root path=usr/gnu/bin group=bin mode=0755
                depend fmri=pkg:/SUNWcsl@0.5.11-0.79 type=require
                file 66d09735123ad3a7bdcf7640dd60acbe843d8a13 
                elfhash=28106285f73f97274cf99b1a7e63d7d73c31c153 
                elfarch=i386 mode=0555 pkg.size=730604 owner=root group=bin path=usr/bin/bash elfbits=32
                legacy category=system vendor="Sun Microsystems, Inc." 
                name="GNU Bourne-Again shell (bash)" version=11.11.0,REV=2007.11.29.14.44 
                hotline="Please contact your local service provider" 
                pkg=SUNWbash arch=i386 desc="GNU Bourne-Again shell (bash) version 3.2"
                license ed881c52c54b67457db33ba23a1d53615e366440 path=copyright 
                license=SUNWbash.copyright 
                transaction_id=1202253906_pkg%3A%2FSUNWbash%403.2.25
                %2C5.11-0.79%3A20080205T152506Z 
                pkg.size=1207
                link path=usr/gnu/bin/sh target=../../bin/bash
                set name=description value="GNU Bourne-Again shell (bash)"
How to List Information About a Package
Before You Begin

Refer to the pkg(1) Command Reference for a table of all the options associated with this command.

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

This example displays information about the SUNWbash package.

Name: SUNWbash
Summary: GNU Bourne-Again shell (bash)
Authority: pkg.com (preferred)
Version: 3.2.25
Build Release: 5.11
Branch: 0.79
Packaging Date: Tue Feb  5 15:25:06 2008
Size: 714 kB
FMRI: pkg:/SUNWbash@3.2.25,5.11-0.79:20080205T152506Z
Example 2-13 Display Copyright and License Information About a Package

This example displays the copyright and license information about the SUNWGlib package.

$ 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 Uninstall Packages
Before You Begin

Refer to the pkg(1) Command Reference for a table of all the options associated with this command.

  • Use the following command to uninstall existing packages.

    $ pkg uninstall [-nvr] pkg_fmri

Example 2-14 Uninstalling a Package

This example uninstalls the SUNWphp524-mysqlpackage.

$ pkg uninstall SUNWphp524-mysql
PHASE        ACTIONS
Removal Phase  39/39 
How to Add or Update an Authority
Before You Begin

Refer to the pkg(1) Command Reference for a table of all the options associated with this command.

Become root user before executing this command.

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

    # pkg set-authority [-P] [-k ssl_key] [-c ssl_cert] [-O origin_url] authority


    Note - The option -O should be specified in upper case.


Example 2-15 Adding an Additional Package Authority
# pkg set-authority -O  http://pkg.sunfreeware.com:80 sunfreeware.com
# pkg authority
AUTHORITY                       URL
opensolaris.org (preferred) http://pkg.opensolaris.org:80/
sunfreeware.com               http://pkg.sunfreeware.com:80/
How to Remove Authority Configuration
Before You Begin

Refer to the pkg(1) Command Reference for a table of all the options associated with this command.

Become root before executing this command.

  • Type the following command to remove the configuration information associated with a given authority.

    # pkg unset-authority authority

Example 2-16 Removing an Authority
# pkg unset-authority sunfreeware.com
# pkg authority
AUTHORITY                       URL
opensolaris.org (preferred)     http://pkg.opensolaris.org:80/
How to Display Authority Information
Before You Begin

Refer to the pkg(1) Command Reference for a table of all the options associated with this command.

  • Type the following command to display information about an authority. If no arguments are specified, a list of configured authorities and their associated URLs is displayed.

    $ pkg authority [-H] authority

Example 2-17 Displaying Authority Information
$ pkg authority
AUTHORITY                     URL
opensolaris.org (preferred)   http://pkg.opensolaris.org:80/
Previous Next