Installing Packages

After obtaining pkgsrc, the pkgsrc directory now contains a set of packages, organized into categories. You can install the packages from source, meaning that each package directory contains a Makefile that is used to install the package using bmake tool.

The default prefix for installed packages is /usr/pkg. You can change the prefix in the bootstrap step. The prefix is the base directory where pkgsrc installs packages. It serves as the root of a separate file system hierarchy for managed packages. For example, the binary of installed package is located in the subdirectory bin.

To install packages from source, you need a working C compiler.

The real power of pkgsrc, though, is the ease of building a package from source. You downloaded all 20,000+ packages in the first setup step, and you can access those by navigating into your pkgsrc tree directly.

For example, to install nano from source, first, locate the source directory of it:

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

Next, change into the source directory:

cd /path/to/pkgsrc/editors/nano

The source directory contains files to help the application build on your system. For example, the DESCR` file, which contains a description of the software, as well as the Makefile that triggers the build.

$ ls
CVS  DESCR  distinfo  Makefile  options.mk  patches  PLIST

To show the description of the package, check the DESCR file.

$ cat DESCR
  GNU `nano' is a small and friendly text editor.  Besides basic text
editing, `nano' offers many extra features like an interactive search
and replace, goto line number, auto-indentation, feature toggles,
internationalization support, and filename tab completion.

   The original goal for `nano' was a complete bug-for-bug compatible
emulation of Pico, but consistency is now a slightly higher priority.

   Nano does not have the restrictive license problems of Pico.

The last step is installing the package using bmake:

bmake install

To use the binary of the package in you envirounment, you should add the path to binary to PATH envirounmental variable.

Install Packages in SStack

To install a package from source, use pkg-install binary. This binary finds the source directory of the package which contains a Makefile. Then it installs the package using bmake tool. Once a package installed, you can use it immediately, because SStack tool adds the bin directory to PATH envirounmental variable.

The following shows the syntax of pkg-install:

pkg-install <package-name>

For example, to install nano, you can first find it using pkg-search.

pkg-search nano.*

The following output shows that nano is available and not installed yet.

To install nano, run:

pkg-install nano

To check if nano installed successfully, you can run pkg-search again, and the output shows it was installed successfully.

Installed Packages
nano-7.2            Small and friendly text editor (a free replacement for Pico)

Available Packages
nano
nanomsgxx
nanomsg
nanotodon
nanoblogger-extra
nanoblogger
nanosaur2
nanosaur

You can also show the location of its binary.

which nano

The output depicts that the system uses the installed package, and the location of the prefix of pkgsrc.

/fs1/project/hpcteam/tahat/stacks/pkgsrc/2024A/prefix/bin/nano