Published : 2014-11-11

Pkgng mirrors

FreeBSD 10.0 will mark a turning point in its binary package management system. The legacy pkg_* tools will be removed and definitively replaced by pkgng.

Since pkgng was introduced, there was no mirror available to download and install these packages. That’s no longer the case. The FreeBSD team has announced the ability to use mirrors to download packages in binary form.

How the Mirror Works

Unlike most Linux mirrors, FreeBSD (pkg_*) and OpenBSD, pkgng does not rely on a DNS A record.

The development team decided that using SRV records to manage pkg mirrors is more interesting, as it lets you manage the priority of each server.

So when pkg wants to reach http://pkg.FreeBSD.org/${ABI}/latest it will resolve the SRV record _http._tcp.pkg.freebsd.org and connect to one of the priority mirrors:

_http._tcp.pkg.freebsd.org. 60  IN  SRV 10 10 80 pkg1.nyi.freebsd.org.
_http._tcp.pkg.freebsd.org. 60  IN  SRV 10 10 80 pkg0.bme.freebsd.org.
_http._tcp.pkg.freebsd.org. 60  IN  SRV 10 10 80 pkg0.isc.freebsd.org.

Note that the TTL of the record is 60 seconds, in order to balance the load as needed.

Supported Versions

The mirrors support every version currently maintained by the FreeBSD team (8.3, 8.4, 9.1, 9.2, 10.0, and 11).

Switching to pkgng

8.X Series

To switch to pkgng on 8.3 and 8.4, you’ll need to go through the ports:

cd /usr/ports/ports-mgmt/pkg
make install clean
echo WITH_PKGNG=yes >> /etc/make.conf
pkg2ng

9.X Series

The 9.x versions (from 9.1) ship an alias to install pkg easily:

pkg
echo WITH_PKGNG=yes >> /etc/make.conf
pkg2ng

10.X Series and Above

pkgng is bundled by default.

Using pkgng

Searching a Package

pkg search <name>

Installing a Package

pkg install <name>

Removing a Package

pkg remove <name>

Removing Obsolete Dependencies

pkg autoremove

Updating the Local Package List

pkg update

Upgrading Installed Packages

pkg upgrade

Listing Installed Packages

pkg info

Locking/Unlocking a Package

This prevents an installed package from being modified (upgraded or removed). It’s very useful in development environments, for instance.

pkg lock <name>
pkg unlock

Package Audit

This feature uses an audit database to identify vulnerable packages on the system.

pkg audit

Conclusion

Now that binary mirrors are available, a new step has been taken for FreeBSD. The next step is a simple and robust package signature system.

For Linux users who wanted to try FreeBSD but were put off by the compilation: you no longer have any excuse not to try FreeBSD!