Vince Rants

My FreeBSD packages are out of date, how do I fix that?

One of the main important tasks of a system administrator is keeping software up to date. There are tutorials all over the place about using apt with Debian based Linux distributions, and yum with Redhat based Linux distributions. But what about the FreeBSD world? It should be just as easy, right? Well, you're mostly correct!

If you're already experienced with managing packages with pkg and are simply looking for the solution as to why it is only installing old and stable packages, simply jump to the end of this article!.

Updating the package repository

root@jail:~ # pkg update
The package management tool is not yet installed on your system.
Do you want to fetch and install it now? [y/N]: y
Bootstrapping pkg from pkg+http://pkg.FreeBSD.org/FreeBSD:11:amd64/quarterly, please wait...
Verifying signature with trusted certificate pkg.freebsd.org.2013102301... done
[jail] Installing pkg-1.10.5_1...
[jail] Extracting pkg-1.10.5_1: 100%
Updating FreeBSD repository catalogue...
pkg: Repository FreeBSD load error: access repo file(/var/db/pkg/repo-FreeBSD.sqlite) failed: No such file or directory
[jail] Fetching meta.txz: 100% 944 B 0.9kB/s 00:01
[jail] Fetching packagesite.txz: 100% 6 MiB 3.3MB/s 00:02
Processing entries: 100%
FreeBSD repository update completed. 32191 packages processed.
All repositories are up to date.

The pkg update command will update the information on what packages are available to install. Because this is a fresh FreeBSD installation, there is no existing information locally to update, hense the error message about the missing file. This particular error is perfectly fine, as this file will be generated automatically.

Upgrading already installed packages

root@jail ~# pkg upgrade Updating FreeBSD repository catalogue... FreeBSD repository is up to date. All repositories are up to date. Checking for upgrades (7 candidates): 100% Processing candidates (7 candidates): 100% The following 9 package(s) will be affected (of 0 checked): New packages to be INSTALLED: p5-IO-Socket-INET6: 2.72_1 p5-Socket6: 0.28 Installed packages to be UPGRADED: usbids: 20180703 -> 20180815 p5-IO-Socket-SSL: 2.058 -> 2.059 libnghttp2: 1.32.1 -> 1.33.0 libevent: 2.1.8_1 -> 2.1.8_2 expat: 2.2.5 -> 2.2.6_1 curl: 7.61.0_1 -> 7.61.1 ca_root_nss: 3.38 -> 3.39 Number of packages to be installed: 2 Number of packages to be upgraded: 7 2 MiB to be downloaded. Proceed with this action? [y/N]: y [1/9] Fetching usbids-20180815.txz: 100% 178 KiB 181.9kB/s 00:01 [2/9] Fetching p5-IO-Socket-SSL-2.059.txz: 100% 162 KiB 166.1kB/s 00:01 [3/9] Fetching libnghttp2-1.33.0.txz: 100% 111 KiB 113.6kB/s 00:01 [4/9] Fetching libevent-2.1.8_2.txz: 100% 305 KiB 312.5kB/s 00:01 [5/9] Fetching expat-2.2.6_1.txz: 100% 117 KiB 120.2kB/s 00:01 [6/9] Fetching curl-7.61.1.txz: 100% 1 MiB 1.3MB/s 00:01 [7/9] Fetching ca_root_nss-3.39.txz: 100% 289 KiB 295.8kB/s 00:01 [8/9] Fetching p5-IO-Socket-INET6-2.72_1.txz: 100% 13 KiB 13.1kB/s 00:01 [9/9] Fetching p5-Socket6-0.28.txz: 100% 16 KiB 16.9kB/s 00:01 Checking integrity... done (0 conflicting) [1/9] Installing p5-Socket6-0.28... [1/9] Extracting p5-Socket6-0.28: 100% [2/9] Upgrading libnghttp2 from 1.32.1 to 1.33.0... [2/9] Extracting libnghttp2-1.33.0: 100% [3/9] Upgrading ca_root_nss from 3.38 to 3.39... [3/9] Extracting ca_root_nss-3.39: 100% [4/9] Installing p5-IO-Socket-INET6-2.72_1... [4/9] Extracting p5-IO-Socket-INET6-2.72_1: 100% [5/9] Upgrading usbids from 20180703 to 20180815... [5/9] Extracting usbids-20180815: 100% [6/9] Upgrading p5-IO-Socket-SSL from 2.058 to 2.059... [6/9] Extracting p5-IO-Socket-SSL-2.059: 100% [7/9] Upgrading libevent from 2.1.8_1 to 2.1.8_2... [7/9] Extracting libevent-2.1.8_2: 100% [8/9] Upgrading expat from 2.2.5 to 2.2.6_1... [8/9] Extracting expat-2.2.6_1: 100% [9/9] Upgrading curl from 7.61.0_1 to 7.61.1... [9/9] Extracting curl-7.61.1: 100%

The pkg upgrade will search through all packages currently installed on FreeBSD and see if there are updates to any of them. Sometimes packages will have additional dependancies on other packages that they didn't before, so there may be a case when brand new packages will be installed as well.

Searching for available packages

root@jail ~# pkg search nano nano-2.9.8 Nano's ANOther editor, an enhanced free Pico clone nano-devel-2.5.3 Nano's ANOther editor, an enhanced free Pico clone nanoblogger-3.4.2_1 Small weblog engine written in Bash for the command line nanoblogger-extra-3.4.2_1 Extras for nanoblogger, a small weblog engine nanogui-g20180318 Minimalistic GUI library for OpenGL nanomsg-1.1.0 Socket library that provides several common communication patterns rubygem-nanoc-4.7.14 Simple but flexible static site generator u-boot-nanopi_a64-2018.07_3 Cross-build das u-boot for model nanopi_a64 u-boot-nanopi_m1plus-2018.07_3 Cross-build das u-boot for model nanopi_m1plus u-boot-nanopi_neo-2018.07_3 Cross-build das u-boot for model nanopi_neo u-boot-nanopi_neo_air-2018.07_3 Cross-build das u-boot for model nanopi_neo_air

Using the pkg search [name] command, you'll get a listing of all packages which matches the name specified that are available from the FreeBSD repository.

Installing a new package

root@jail ~# pkg install nano Updating FreeBSD repository catalogue... FreeBSD repository is up to date. All repositories are up to date. The following 1 package(s) will be affected (of 0 checked): New packages to be INSTALLED: nano: 2.9.8 Number of packages to be installed: 1 The process will require 2 MiB more space. 487 KiB to be downloaded. Proceed with this action? [y/N]: y [1/1] Fetching nano-2.9.8.txz: 100% 487 KiB 498.5kB/s 00:01 Checking integrity... done (0 conflicting) [1/1] Installing nano-2.9.8... [1/1] Extracting nano-2.9.8: 100%

Installing packages is as simple as running pkg install [name]. Even though the pkg search results show a version number, that is not needed when installing the package.

Uninstalling a package

root@jail ~# pkg remove nano Checking integrity... done (0 conflicting) Deinstallation has been requested for the following 1 packages (of 0 packages in the universe): Installed packages to be REMOVED: nano-2.9.8 Number of packages to be removed: 1 The operation will free 2 MiB. Proceed with deinstalling packages? [y/N]: y [1/1] Deinstalling nano-2.9.8... [1/1] Deleting files for nano-2.9.8: 100%

Uninstalling a package is just as simple. Run pkg uninstall [name], and the package will simply be removed.

Changing package repositories

AND NOW FOR THE FUN STUFF. What happens when pkg is showing and installing older versions of packages that you absolutely KNOW have been updated and show as such on the official FreshPorts web site?

In my particular case, the mariadb103-server package being installed would segfault at startup. This was a known issue that was quickly resolved and pushed live. The problem, however, is that it was only pushed live for the latest package repository, leaving those on the quarterly repository with a version of MariaDB that simply didn't function at all.

If you're in this scenario as well, which is the default with some FreeBSD jail configurations, then simply edit the file /etc/pkg/FreeBSD.conf and change quarterly to latest on the url line.

FreeBSD: { url: "pkg+http://pkg.FreeBSD.org/${ABI}/latest", mirror_type: "srv", signature_type: "fingerprints", fingerprints: "/usr/share/keys/pkg", enabled: yes }

Enabling FreeBSD's repository on FreeNAS and OPNsense

And the final change for today. What happens when you want to install packages into the global area of FreeNAS, or install packages on OPNsense? By default, both of these FreeBSD distributions have pkg disabled. This is another quick, simple, easy fix. But before we begin, a quick note. Others will warn that installing packages on FreeNAS is bad, and that they should be installed into private jails instead. The one flaw with this argument is that the packages I've personally wanted to install on FreeNAS have all been system management related, such as more advanced process monitoring, I/O monitoring, network monitoring, things of this nature. These types of packages are required to run in the main part of the OS, because if they ran inside of the jail, they would only have visibility into what that particular jail is doing, not the rest of the system.

Edit the following file, changing FreeBSD enabled from no to yes/usr/local/etc/pkg/repos/FreeBSD.conf - After this change is made, pkg will function as normal with the ability to install standard FreeBSD packages.

FreeBSD: { enabled: yes }