Checking which package a file belongs to with IPS
I’d previously written up a brief note on how to use pgchk to check which package a file belongs to in Solaris. With IPS replacing SYSV packages in Solaris 11 and OpenIndiana, I thought I’d add an update to that post, showing how to accomplish the same thing in IPS.
IPS makes things a lot simpler for us, using the ‘search’ option to pkg.
Let’s check it out on an OpenIndiana oi_147 machine:
-bash-4.0$ uname -X System = SunOS Node = grond Release = 5.11 KernelID = oi_147 Machine = i86pc BusType =Serial = Users = OEM# = 0 Origin# = 1 NumCPU = 4
The format of the search option is simple – just give it the full path to the file you’re interested in. In this example, I want to see which IPS package contains /usr/bin/ssh:
-bash-4.0$ pkg search /usr/bin/ssh INDEX ACTION VALUE PACKAGE path file usr/bin/ssh pkg:/network/[email protected]
Nice and simple, and certainly a lot easier than the old method of invoking pgchk.
pkg search will take a number of extra options:
-bash-4.0$ pkg search -? Usage: pkg search [-HIaflpr] [-o attribute ...] [-s repo_uri] query
pkg search will also allow wildcards, like ? and *, as well as specifying a particular IPS repo, with the -s option – which is very handy when you have a custom repo for your infrastructure.