News, tips, partners, and perspectives for the Oracle Solaris operating system

IPS Search and Actions

Guest Author

When searching for an IPS package, I usually type something quick and simple like:

bleonard@opensolaris:~$ pkg search netbeans
description set NetBeans pkg:/libnb-php@6.5.1-0.111
description set NetBeans pkg:/libnb-groovy@6.5-0.86
description set NetBeans pkg:/netbeans-java@6.5.1-0.111

And scroll through the result list hoping to find what I'm looking for. However, in my example above, that's 437 lines!

bleonard@opensolaris:~$ pkg search netbeans | wc -l

Often times I'll shorten the list by grepping for my build:

bleonard@opensolaris:~$ pkg search netbeans | grep 111
description set NetBeans pkg:/libnb-php@6.5.1-0.111
description set NetBeans pkg:/netbeans-java@6.5.1-0.111
description set NetBeans pkg:/libnb-visualweb@6.5.1-0.111

Which reduces the list down to 134 for this example:

bleonard@opensolaris:~$ pkg search netbeans | grep 111 | wc -l

However, I generally tend to ignore the first two columns, INDEX and ACTION. Actions, in the case of IPS, are actually nouns and not verbs as the name would lead you to expect. Actions are the things that get installed (files, directories, links, drivers, licenses, users, groups, etc). Here's a nice description of the Actions in IPS.

When you perform a search, the search string is checked against all of these actions types, which as seen above, can produce a lot of results. For example, 5 of the 134 results above all refer to the same package, pkg:/sunstudioexpress@0.2009.3.1:

bleonard@opensolaris:~$ pkg search netbeans | grep 111 | grep pkg:/sunstudioexpress@0.2009.3.1
basename dir opt/SunStudioExpress/prod/nb-dbxtool/ide10/docs/org/netbeans pkg:/sunstudioexpress@0.2009.3.1-0.111
basename dir opt/netbeans-6.5ss/ide10/docs/org/netbeans pkg:/sunstudioexpress@0.2009.3.1-0.111
basename file opt/SunStudioExpress/prod/nb-dbxtool/bin/netbeans pkg:/sunstudioexpress@0.2009.3.1-0.111
basename file opt/netbeans-6.5ss/bin/netbeans pkg:/sunstudioexpress@0.2009.3.1-0.111
basename link opt/SunStudioExpress/netbeans pkg:/sunstudioexpress@0.2009.3.1-0.111

That's because the search results are returning 3 directories, 2 files and 1 link, all in the same package, that contain the search string "netbeans".

If you just want to see a list packages that match the search string, use the -p option.

bleonard@opensolaris:~$ pkg search -p netbeans | grep 111 
pkg:/amp-dev@0.5.11-0.111 (opensolaris.org)
pkg:/developer/netbeans/plugin/nb-dtrace@1.0-0.111 (opensolaris.org)
pkg:/developer/sunstudio12u1@12.1.1-0.111 (opensolaris.org)

This returns a much more reasonable 60 results with just the package names, making the result list much more easier to read through. I wish -p was the default option, rather than the -a (which shows the matching actions).

Join the discussion

Comments ( 3 )
  • guest Wednesday, October 6, 2010

    All you've really demonstrated is how awful 'pkg search' is.

  • Aidan Thursday, October 7, 2010

    Thanks for the tip.

    The default results are quite overwhelming, I would like to have '-p' behavior as the default too. I might file an enhancement with the pkg team.

  • Alex Thursday, October 14, 2010

    too bad greedy oracle let the OpenSolaris product rot... glad I am migrating away from Solaris in all my environments.

Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.