Unix & Linux
package-management freebsd pfsense
Updated Sat, 20 Aug 2022 17:42:30 GMT

How pkg is choosing its repos (FreeBSD 10)

I'm using pfSense, which uses a customised base of FreeBSD 10. pkg -vv shows the following relevant definitions:

PKG_DBDIR = "/var/db/pkg";
PKG_CACHEDIR = "/var/cache/pkg";
PORTSDIR = "/usr/ports";
    pfSense-core: {
      url             : "pkg+https://pkg.pfsense.org/pfSense_v2_3_2_amd64-core",
      enabled         : yes,
      priority        : 0,
      mirror_type     : "SRV"
    pfSense: {
      url             : "pkg+https://pkg.pfsense.org/pfSense_v2_3_2_amd64-pfSense_v2_3_2",
      enabled         : yes,
      priority        : 0,
      mirror_type     : "SRV"

Looking at the two directories named in REPOS_DIR:

  • /etc/pkg contains what looks like a default FreeBSD.conf (enabled=yes).
  • /usr/local/etc/pkg/repos contains a different FreeBSD.conf (enabled=no) and also a pfsense.conf that contains the two repo definitions reported by pkg -vv.
  • There is also /usr/local/share/pfSense/pkg/repos which contains the same FreeBSD.conf and pfsense.conf as /usr/local/etc/pkg/repos (the latter under a different filename though: pfSense-repo.conf), and also a link to further development repos in a separate file pfSense-repo-devel.conf.

I'm trying to work out the logic by which pkg chooses which of these overrides which others, especially since when a priority is given, in each case it's the same (=0).

Does a /usr/local/etc/pkg/*.conf file automatically override a similarly-named file at /etc/pkg/*.conf, if both are present? If not, what's going on and how is pkg choosing which repos to pay attention to?


The behaviour is actually all documented in the manual (q.v.). REPOS_DIR is taken from pkg.conf and its directories are processed in the order given. Files in each directory are processed in alphabetical order. There's no notion of comparing filenames. Rather, a file that is processed later overrides anything earlier that it conflicts with.

Further reading

External Links

External links referenced by this document: