About pkgsrc

Modified: 17 Jun 2015 14:32 UTC

The preferred method for installing packages on a SmartMachine is through the pkgsrc package management system. You can use pkgsrc to:

In this topic:

All pre-built software packages on a SmartMachine are located in /opt/local and built with pkgsrc. Joyent continually runs building and testing systems, building packages for all software available in a package repository. The resulting packages are used to create SmartMachine templates. If you require a tool that is not installed by default, you do not have to resort to building from source. You can generally find what you need in the Joyent binary package repository and/or use pkgsrc to build your own.

The default pkgsrc tools to manage packages are pkg_add, pkg_delete, and pkg_info.You can install these tools through the pkg_install package, which includes other useful tools. The pkg_install tools work well for adding or removing packages, but are less reliable for updating packages, especially if an update requires dependencies. 

Directory Paths used by pkgsrc

The pkgsrc package management system uses various directories to install configuration files, binaries, documentation, and so on. These directories are as follows:

If you are familiar with other Unix-like operating systems, you might expect to find these files in /usr/local. Joyent SmartMachines include a symlink from /usr/local to /opt/local to accommodate this expectation.
Directory Description
/opt/local This is where pkgsrc installs software including binaries, libraries, configuration files, supporting files, examples, documentation, and so on.
/opt/local/etc This is where pkgsrc stores configuration files and only if they do not already exist in this directory. This ensures that any changes you make to configuration files are preserved when you update, remove, or reinstall a pacakage.
If you break your configuration file, you can always get a clean one from /opt/local/share/examples.

/opt/local/share/examples This is where pkgsrc copies configuration files that are intended as examples. When you add a new package, pkgsrc installs sample configuration files here, and then copies them to /opt/local/etc if they do not already exist.
For some preinstalled software such as Apache and MySQL, your SmartMachine includes pre-configured files in /opt/local/etc that are not mirrored in /opt/local/share/examples.

/var/db/pkg This directory contains two directories that contain the database of installed and available packages. If you delete or damage these directories, you will not be able to use the pkgsrc management tools.

Why your SmartMachine Includes both pkgin and pkg_add

The easiest way to install software is from a package located in the Joyent pkgsrc package repository. You can do this with either pkgin or pkg_add as both come pre-installed on your machine. Both these utilities are included with your SmartMachine to provide for ease-of-use and support.

The pkg_add utility is a core component of pkgsrc and is the native package tool. In addition, pkg_add is a dependency to pkgsrc. The pkgin utility is a light weight third-party tool that provides core functionality of pkg_add in a user friendly fashion familiar to Linux users. Essentially, pkgin sits on top of pkgsrc and serves as an interface for installing packages. However, pkgin is not intended as a replacement to pkg_add because pkgin is not as robust and does not replace pkg_add for other infrequent packaging tasks.

Common pkgin Commands

For managing package releases, we strongly recommend you use pkgin. Pkgin is an apt/yum like tool that serves as an interface to pkgsrc. The below table lists the common pkgin commands.

You must run commands that install or update software as the root user or as admin using sudo.
Command Description
pkgin up Updates the pkgin database. You should run this command before installing any new packages just in case.
pkgin ls Lists all the installed packages
pkgin av Lists all of the available packages
pkgin in Installs a package
pkgin rm Removes a package
pkgin se Searches for a package
pkgin With no additional arugments, lists all of the available pkgin commands.

For example, to install tidy, you run this: