Solaris 11 pkg repository commands Cheat sheet (Part – 3)

Continuing the package repository cheat sheet series. In this post I am going to cover the pkg contents, pkg search, pkg history commands.

  • SYNTAX: For pkg contents command

pkg contents [-Hmr] [-a attribute=pattern …] [-g path_or_uri …]

[-o attribute …] [-s sort_key] [-t action_type …]
[pkg_fmri_pattern …]

A package manifest describes how a package is assembled and provides basic information about the package (such as the name, version, description, categorization, and so on), what files the package includes, and what other packages or services the package relies on to meet its dependencies.

root@solaris11:~# pkg contents -m diffstat
set name=pkg.fmri value=pkg://solaris/text/diffstat@1.51,5.11-0.175.1.0.0.9.0:20120207T035254Z
set name=pkg.summary value=”A utility which provides statistics based on the output of diff”
set name=info.classification value=”org.opensolaris.category.2008:System/Text Tools”
set name=variant.arch value=i386 value=sparc

How to see the directories and path related to package.

root@solaris11:~# pkg contents diffstat
PATH
usr
usr/bin
usr/bin/diffstat
usr/share
usr/share/man
usr/share/man/man1
usr/share/man/man1/diffstat.1

How to see the information related to files installed on server corresponding to package.

root@solaris11:~# pkg contents -o owner,group,mode,pkg.size,path -s pkg.size -t file diffstat
OWNER GROUP MODE PKG.SIZE PATH
root bin 0755 36272 usr/bin/diffstat
root bin 0644 7275 usr/share/man/man1/diffstat.1

If the package is not installed package then use -r option to list the install able package files.

How to see the dependency in packages. Suppose I want to install the package php-52 on my server to check the dependencies I will issue below command.
It will show me different types in TYPE column like require, conditional and optional.

root@solaris11:~# pkg contents -r -o fmri,type -t depend php-52
FMRI TYPE
pkg:/compress/bzip2@1.0.6-0.175.1.0.0.23.0 require
pkg:/image/library/libjpeg@6.0.2-0.175.0.0.0.0.0 require
pkg:/image/library/libpng@1.4.11-0.175.1.0.0.16.0 require
pkg:/library/libtool/libltdl@2.4.2-0.175.1.0.0.23.0 require

Now to see what are packages present in group package.

root@solaris11:~# pkg contents -Hro fmri -t depend -a type=group solaris-large-server | more
archiver/gnu-tar
compress/bzip2
compress/gzip
compress/p7zip
compress/unzip

To see whether they are installed or not.

root@solaris11:~# pkg list -a `pkg contents -Hro fmri -t depend -a type=group solaris-large-server` | more
NAME (PUBLISHER) VERSION IFO
archiver/gnu-tar 1.26-0.175.1.0.0.24.0 i–
compress/bzip2 1.0.6-0.175.1.0.0.24.0 i–
compress/gzip 1.4-0.175.1.0.0.24.0 i–
compress/p7zip 9.20.1-0.175.1.0.0.24.0 i–
compress/unzip 6.0-0.175.1.0.0.24.0 i–
compress/xz 5.0.1-0.175.1.0.0.24.0 i–
compress/zip 3.0-0.175.1.0.0.24.0 i–

  • SYNTAX: for pkg search command

pkg search [-HIaflpr] [-o attribute …] [-s repo_uri] query
pkg_name:action:index:token

How to search the name of package from file.

root@solaris11:~# pkg search -o pkg.name /usr/bin/gzegrep
PKG.NAME
compress/gzip

How to list the packages which depend on package.

root@solaris11:~# pkg search -o pkg.name require:system/kernel/power
PKG.NAME
system/kernel/dynamic-reconfiguration/i86pc
system/hal
SUNWpm

  • SYNTAX: for pkg history command

pkg history [-HNl] [-t [time|time-time],…] [-n number] [-o column,…]

Command to check the history of recent operations:

root@solaris11:~# pkg history
START OPERATION CLIENT OUTCOME
2012-09-20T01:17:38 set-property transfer module Succeeded
2012-09-20T01:17:38 add-publisher transfer module Succeeded
2012-09-20T01:17:38 refresh-publishers transfer module Succeeded
2012-09-20T01:17:38 image-create transfer module Succeeded
2012-09-20T01:17:46 rebuild-image-catalogs transfer module Succeeded

To see the recent Four pkg commands.

root@solaris11:~# pkg history -n 4
START OPERATION CLIENT OUTCOME
2014-06-14T21:03:42 refresh-publishers pkg Succeeded
2014-06-14T21:03:48 rebuild-image-catalogs pkg Succeeded
2014-06-14T21:05:30 install pkg Succeeded
2014-06-16T16:23:14 uninstall pkg Succeeded

Adding more spice to history command

root@solaris11:~# pkg history -o user,be,time,command | tail -4
root solaris 0:00:10 /usr/bin/pkg set-publisher -G * -M * -g /repo-pool/zfs1/ solaris
root solaris 0:00:04 /usr/bin/pkg set-publisher -G * -M * -g /repo-pool/zfs1/ solaris
root solaris 0:00:46 /usr/bin/pkg install diffstat
root solaris 0:02:24 /usr/bin/pkg uninstall diffstat

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s