Search Packages

Before installing a package using pkgsrc, you can check if the package is available and already installed. To browse the online index of packages, visit the package list.

Search Installed Packages

Before installing a package check if the package is already installed. pkgsrc has a tool that shows all installed packages pkg_info.

To show all installed packages, run:

$ pkg_info
libidn2-2.3.4       Convert internationalized domain names to/from ASCII Encoding
nano-7.2            Small and friendly text editor (a free replacement for Pico)
help2man-1.49.3     Generate simple manual pages from program output
libxml2-2.10.4nb2   XML parser library from the GNOME project
digest-20220214     Message digest wrapper utility

To check if a specific package is installed, run:

$ pkg_info | grep nano
nano-7.2            Small and friendly text editor (a free replacement for Pico)

Check Available Packages

pkgsrc contains the source of more than 20,000 packages that were installed in the bootstrap step. The sources are organized into categories. Foe example editor category contains more than 190 packages.

To check if a package is available, you need to explore the root directory of pkgsrc and look for the intended package.

$ ls /path/to/pkgsrc
archivers   biology    chat        cross      devel      editors      finance  geography  inputmethod  mail      mbone      mk          _NetBSD-pkgdb  parallel   print      science   sysutils   time  x11
audio       bootstrap  comms       CVS        distfiles  emulators    fonts    graphics   lang         Makefile  meta-pkgs  multimedia  news           pkglocate  README.md  security  templates  wm
benchmarks  cad        converters  databases  doc        filesystems  games    ham        licenses     math      misc       net         packages       pkgtools   regress    shells    textproc   www

To find if a specific package is available, and locate it, you can use either the find or ls command in the source directory in the pkgsrc root directory.

For example, to search for nano, change directory to the root of pkgsrc:

$ cd /path/to/pkgsrc
$ ls
archivers   biology    chat        cross      devel      editors      finance  geography  inputmethod  mail      mbone      mk          _NetBSD-pkgdb  parallel   print      science   sysutils   time  x11
audio       bootstrap  comms       CVS        distfiles  emulators    fonts    graphics   lang         Makefile  meta-pkgs  multimedia  news           pkglocate  README.md  security  templates  wm
benchmarks  cad        converters  databases  doc        filesystems  games    ham        licenses     math      misc       net         packages       pkgtools   regress    shells    textproc   www

Then, you find if the nano is available using ls command:

$ ls -d */nano
editors/nano

This shows that nano is available and its location.

Or, use find command:

$ find /path/to/pkgsrc -type d -name "nano"
/path/to/pkgsrc/editors/nano

To find all packages that start with py-, run:

$ ls -d */py-*
archivers/py-brotli                          devel/py-pkginfo                                            graphics/py-mcomix                                textproc/py-dominate
archivers/py-brotlicffi                      devel/py-pkgutil_resolve_name                               graphics/py-nwdiag                                textproc/py-ejson
archivers/py-brotlipy                        devel/py-plaster                                            graphics/py-objgraph                              textproc/py-elementpath
archivers/py-bz2file
...

Search Packages in SStack

SStack tools has a binary that can accomplish this using pkgsrc tool pkg_info to search the installed package. Regarding finding if the package is available, SStack searches the pkgsrc directory which contains a set of packages, organized into categories.

You can install the package if available and not installed. In case the package is installed you can either uninstall using pkg-uninstall binary or update it using pkg-updatepkg-update binary.

The following shows the syntax of pkg-search binary.

pkg-search <pkgname.*> or <pkgname>

For example, to search for all packages that starts with hdf, run:

pkg-search hdf.*

The following output shows the available packages that match the specified regular expression. No installed packages match the regular expression.

Available Packages
hdf5-c++
hdf5
hdf

The following output shows that one installed package hdf5 matches the regular expression.

Installed Packages
hdf5-1.12.2         Hierarchical Data Format (new generation)

Available Packages
hdf5-c++
hdf5
hdf

This means that hdf5-1.12.2 was installed. You can either uninstall or update the package.