Use the pkg search command to search for packages whose data matches the specified pattern.
Like the pkg contents command, the pkg search command examines the contents of packages. While the pkg contents command returns the contents, the pkg search command returns the names of packages that match the search query. The following table shows some of the similarities and differences between these two commands.
|
By default, the search query is a series of terms to be matched exactly except for case. Use the -I option to specify a case-sensitive search.
You can use ? and * wildcards in query terms. You can use single or double quotation marks to search for phrases. Be sure to take your shell into account when you use wildcards or quotation marks.
You can specify more than one query term. By default, multiple terms are joined with AND. You can explicitly join two terms with OR.
Search queries can be expressed in the following structured form:
package:action:index:token
The name of the package to search or a pattern that might match multiple packages.
Usually selects an attribute of action as listed in the “Actions” section of the pkg(5) man page. See below for more information.
The name of an attribute of action as listed in the “Actions” section of the pkg(5) man page.
The value of index or a pattern that might match the value of index.
Missing fields are implicitly wildcarded. The token string can be explicitly wildcarded. Names of actions and indexes cannot be explicitly wildcarded.
The index is not necessarily the same as the name of an action attribute. For example, the index for the user action is name, while the name of that attribute is username.
Not all action attributes are searchable. For example, mode is an attribute of the file action, but mode is not a valid value for index.
The following example shows one way to find all possible indexes for an action:
$ pkg search :user::
This command shows that the only searchable attribute of a user action is name.
Some values of index are values derived from other attributes. For example, index can be basename, which is the last component of the path attribute of a file or dir action. Examples of useful values for index include basename and path for file and dir actions, the dependency type (require or group, for example) for depend actions, and driver_name and alias for driver actions.
The index can also be a special pseudo attribute name such as action.key (the key attribute of the action) or pkg.name. See the pkg(1) man page for a complete list.
The value of token is compared with the value of the attribute named by index. For example, in the following partial driver action, alias is an attribute name that could be specified for index, and pci108e* could be specified for token.
driver alias=pci108e,1647 alias=pci108e,16a7
The syntax of a set action is slightly different. The two attributes of a set action are name and value. In this case, the value of index is the value of a name attribute, and the value of token is compared with the value of the matching value attribute. The following example shows a set action for a driver package:
set name=pkg.summary value="Broadcom NetXtreme II 10GbE NIC Driver"
The following example specifies set for the action, pkg.summary for index, and Broadcom for token. The search.match and pkg.name column specifiers are pseudo attributes. See the pkg(1) man page.
$ pkg search -o search.match,pkg.name pkg.summary:Broadcom SEARCH.MATCH PKG.NAME Broadcom NetXtreme II 10GbE NIC Driver driver/network/ethernet/bnxe Broadcom 57xx 1GbE NIC Driver driver/network/ethernet/bge Broadcom NetXtreme II 1GbE NIC Driver driver/network/ethernet/bnx Broadcom BCM4401 NIC Driver driver/network/ethernet/bfe Broadcom HT1000 SATA driver driver/storage/bcm_sata
Some well-defined values of set action name attributes include pkg.fmri, info.classification, pkg.description, and pkg.summary. See “Set Actions” in the pkg(5) man page.
By default, matches are displayed only for currently installed or newer package versions. Use the -f option to display all matched versions.
By default, results are displayed for all matching actions, which can yield multiple lines of results for one package. Use the -p option to list each matching package only once.
In the following example, the search token is the full path of a file system object:
$ pkg search /lib/libinetutil.so.1 INDEX ACTION VALUE PACKAGE path file lib/libinetutil.so.1 pkg:/system/library@0.5.11-0.175.3.30.0.4.0
The pkg search command searches package actions. The preceding command found the search token in the path attribute of a file action and shows that this file is delivered by the system/library package.
The following example specifies that the desired output is only the name of the package. Specifying the -l option can quicken the search because only installed packages are searched:
$ pkg search -Hlo pkg.name '*libinetutil*' system/library
If you do not specify the output you want, then using just the base name of the file as the search token, or using wild cards as shown above, shows that this file is delivered to six different directories and is the target of three links. Another way to show each package name only one time, instead of showing many lines of output for one package, is to use the -p option or enclose the search token in angle brackets. Depending on your shell, you might need to escape the angle brackets. The following commands have the same output:
$ pkg search -p '*libinetutil*' $ pkg search \<'*libinetutil*'\> PACKAGE PUBLISHER pkg:/system/library0.5.11-0.175.3.30.0.4.0 solaris
If you cannot find the package that delivers a file on your system, perhaps that file was not delivered by an IPS package.
To show which packages provide a particular SMF service, search for the name of the service as the value of the org.opensolaris.smf.fmri attribute.
$ pkg search -o pkg.name,search.match 'org.opensolaris.smf.fmri:*network/http*' PKG.NAME SEARCH.MATCH web/java-servlet/tomcat svc:/network/http web/proxy/squid svc:/network/http web/proxy/privoxy svc:/network/http web/server/lighttpd-14 svc:/network/http web/server/apache-22 svc:/network/http web/server/apache-22 svc:/network/http:apache22 web/server/lighttpd-14 svc:/network/http:lighttpd14 web/proxy/privoxy svc:/network/http:privoxy web/proxy/squid svc:/network/http:squid web/java-servlet/tomcat svc:/network/http:tomcat6
In this case, each attribute has two values: the service name with and without the service instance name specified. The following example shows how this attribute is specified in the package manifest:
set name=org.opensolaris.smf.fmri value=svc:/network/http value=svc:/network/http:apache22
The following example shows this same information with each package listed only once. The -p option cannot be used when requesting action-level output such as search.match. Escape the colon character so that it is interpreted as part of the token and not as another search query field.
$ pkg search -o pkg.name,search.match 'org.opensolaris.smf.fmri:*network/http\:*' PKG.NAME SEARCH.MATCH web/server/apache-22 svc:/network/http:apache22 web/server/lighttpd-14 svc:/network/http:lighttpd14 web/proxy/privoxy svc:/network/http:privoxy web/proxy/squid svc:/network/http:squid web/java-servlet/tomcat svc:/network/http:tomcat6
IPS packages deliver users for daemons or other software to use.
The following command shows users that are delivered by installed packages:
$ pkg search -lo action.key user::
The following command shows which package delivers a particular user definition:
$ pkg search -o action.key,pkg.name user::nova ACTION.KEY PKG.NAME nova cloud/openstack/nova
The following command shows an example of using the OR keyword:
$ pkg search -o action.key,pkg.name user::nova OR user::neutron ACTION.KEY PKG.NAME nova cloud/openstack/nova neutron cloud/openstack/neutron
The following command shows which package delivers a particular bug fix:
$ pkg search -Ho pkg.shortfmri bugid
All packages that were modified to fix the bug are listed.
See Critical Patch Update Packages to learn how to identify which SRU delivered a particular CVE fix.
The following example identifies all installed packages that have “Source Code Management” in the value of their info.classification attribute:
$ pkg search -Hlo pkg.name info.classification:'source code management' developer/versioning/sccs developer/versioning/mercurial developer/versioning/mercurial-27
The following example shows the package metadata that is matched in this search:
set name=info.classification value="org.opensolaris.category.2008:Development/Source Code Management"
This information is displayed in the “Category” line in output from the pkg info command.
$ pkg info mercurial-27 ... Category: Development/Source Code Management ...
See Classification Values in Packaging and Delivering Software With the Image Packaging System in Oracle Solaris 11.3 for other classifications that you can search for.
You can also use the pkg list command with a guess at one of the components of the package name, as in the following examples:
$ pkg list -a '*versioning*' $ pkg list '*storage*' $ pkg list -n '*database*'
These examples show the packages that are dependencies of the specified package.
The following example shows packages that have a require dependency on the system/kernel/power package:
$ pkg search -Hlo pkg.name require:system/kernel/power system/kernel/dynamic-reconfiguration/i86pc system/hal
The following pkg contents command confirms the results of the search. The requested output action.raw is a pseudo attribute that displays the action exactly as it appears in the package manifest.
$ pkg contents -rt depend -a fmri='*power*' -o pkg.name,action.raw i86pc system/hal PKG.NAME ACTION.RAW system/hal depend fmri=pkg:/system/kernel/power @0.5.11-0.175.2.0.0.34.0 type=require variant.opensolaris.zone=global system/kernel/dynamic-reconfiguration/i86pc depend fmri=pkg:/system/kernel/power type=require
The following example shows that many packages have an exclude dependency on pkg:/x11/server/xorg@1.14.99:
$ pkg search -lo pkg.name,fmri 'depend:exclude:*xorg*' PKG.NAME FMRI x11/server/xorg/driver/xorg-video-ati pkg:/x11/server/xorg@1.14.99 x11/server/xvnc pkg:/x11/server/xorg@1.14.99 x11/server/xserver-common pkg:/x11/server/xorg@1.14.99 x11/server/xorg/driver/xorg-input-vmmouse pkg:/x11/server/xorg@1.14.99 x11/server/xephyr pkg:/x11/server/xorg@1.14.99 ...
The Oracle Solaris 11 GUI installer installs the solaris-desktop group package. The text installer and the default AI manifest in an Automated Installer installation install the solaris-large-server group package. The default installation manifest for non-global zones installs the solaris-small-server group package. The solaris-minimal-server group package installs the minimal supported set of packages required to run Oracle Solaris.
You can use the following search form to display the set of packages that is included in the specified group package.
$ pkg search -o type,fmri '*/solaris-minimal-server:depend::' TYPE FMRI require developer/debug/mdb require editor/vim/vim-core require group/system/solaris-core-platform group network/ping require package/pkg require release/name require release/notices group service/network/ssh-common require shell/bash require shell/ksh93 group shell/tcsh group shell/zsh require system/core-os require system/library/platform group system/network
The depend query field matches depend actions in the package. The -o option displays the values of the type and fmri attributes of the depend action. Use pkg.shortfmri to see the version as well as the name of each package. Recall that group packages do not specify file system content; group packages specify other packages that are part of the group. See Group Packages for more information about group packages.
The pkg search command is returning the value of an attribute of an action in a specified package. In this example, that attribute value is a package name. The number of results from this command can be larger than the number of the results from the similar pkg contents command shown in Listing All Installable Packages in a Group Package because these search results include the names of all packages that are named in depend actions of type group in the specified package, not just installable packages. For example, package variants and facets might be included that are not installable in this image. To see this difference, try both examples with the solaris-large-server package.