Mar 272022
 

In this post, I will talk about how I modified my pkg configuration so I don’t have to modify it after upgrading a host/jail from one version of FreeBSD to another. You might say that you don’t have to do that. Perhaps you have a different configuration and aren’t doing what I’m doing.

HEADS UP: I hit a problem with this approach when updating a jail using mkjail: see https://github.com/mkjail/mkjail/issues/30

In this post:

  • FreeBSD 12.2 12.3 13.0
  • poudriere 3.3.7_1

The back story

Today, while updating some jails, I noticed that mkjail upgrade doing a pkg upgrade from FreeBSD 12.2 to FreeBSD 12.3. My first thought: that’s of no use to me, because it’s not doing to get anything different. Here’s why.

These are my poudriere build jails:

[pkg01 dan ~] % poudriere jails -l
114R     11.4-RELEASE-p13 amd64 ftp    2022-03-27 20:32:36 /usr/local/poudriere/jails/114R
122amd64 12.2-RELEASE-p15 amd64 ftp    2022-03-27 20:37:50 /usr/local/poudriere/jails/122amd64
123amd64 12.3-RELEASE-p4  amd64 http   2022-03-27 20:41:20 /usr/local/poudriere/jails/123amd64
13amd64  13.0-RELEASE-p10 amd64 ftp    2022-03-27 20:48:40 /usr/local/poudriere/jails/13amd64
13i386   13.0-RELEASE-p10 i386  ftp    2022-03-27 20:50:52 /usr/local/poudriere/jails/13i386
[pkg01 dan ~] % 

I have jails specific to each release of FreeBSD that I am using, either on a host or in a jail on that host.

Yes, a 12.3 jail can run binaries from 12.2, but that’s not the point of what I’m doing here.

These are the various package repos. Not all of them are in use right now, but this gives you an overview which might help see why my repos are configured the way they are.

[pkg01 dan /usr/local/poudriere/data/packages] % ls
13amd64-default                    112i386-default-master-list-i386          121amd64-default-pg13
13amd64-default-deleteme           114R-default                              121amd64-default-pg94
13amd64-default-master-list        114R-dvl                                  121amd64-default-pg95
13amd64-default-mysql56            120amd64-2019Q3                           121amd64-default-pg96
13amd64-default-mysql57            120amd64-default                          121amd64-default-unifi
13amd64-default-mysql80            120amd64-default--i                       121amd64-dvl
13amd64-default-pg10               120amd64-default-master-list              121amd64-dvl-master-list
13amd64-default-pg11               120amd64-default-master-lisys-i           121i386-default-default-master-list-i386
13amd64-default-pg12               120amd64-default-mysql55                  121i386-default-master-list
13amd64-default-pg13               120amd64-default-mysql56                  121i386-default-master-list-386
13amd64-default-pg14               120amd64-default-mysql57                  121i386-default-master-list-i386
13amd64-default-pg95               120amd64-default-mysql80                  122amd64-default
13amd64-default-pg96               120amd64-default-pg6                      122amd64-default-master-li-C
13amd64-default-primary            120amd64-default-pg10                     122amd64-default-master-lis
13amd64-default-unifi              120amd64-default-pg11                     122amd64-default-master-list
13amd64-dvl                        120amd64-default-pg12                     122amd64-default-mysql56
13amd64-dvl-git                    120amd64-default-pg93                     122amd64-default-mysql57
13amd64-dvl-master-list            120amd64-default-pg94                     122amd64-default-mysql80
13i386-default-master-list-i386    120amd64-default-pg95                     122amd64-default-pg10
13i386-default-master-list-i38686  120amd64-default-pg96                     122amd64-default-pg11
13i386-default-primary             120amd64-default-unifi                    122amd64-default-pg12
13i386-default-primaryi386         120amd64-default-working                  122amd64-default-pg12-121
104amd64-default                   120amd64-dvl                              122amd64-default-pg13
104amd64-working                   120amd64-dvl-master-list                  122amd64-default-pg14
110amd64-default                   120amd64-working                          122amd64-default-pg95
111amd64-default                   120amd64-working-master-list              122amd64-default-pg96
111amd64-default-newphp            120i386-default                           122amd64-default-primary
111amd64-working                   120i386-default-default-master-list-i386  122amd64-default-unifi
112amd64-default                   120i386-default-master-list               122amd64-dvl
112amd64-default-master-list       120i386-default-master-list-386           122amd64-dvl-git
112amd64-default-mysql55           120i386-default-master-list-i386          122amd64-dvl-master-list
112amd64-default-mysql56           120i386-working-master-list               122amd64-dvl-primary
112amd64-default-mysql57           121amd64-default                          122amd64-testing
112amd64-default-mysql80           121amd64-default--i                       122i386-default-master-list-i386
112amd64-default-newphp            121amd64-default-master-lisat             122i386-default-primary
112amd64-default-pg10              121amd64-default-master-list              122i386-default-primaryi386
112amd64-default-pg11              121amd64-default-master-listsit           122i386-dvl
112amd64-default-pg93              121amd64-default-mysql56                  123amd64-default
112amd64-default-pg94              121amd64-default-mysql57                  123amd64-default-primary
112amd64-default-pg95              121amd64-default-mysql80                  123amd64-default-unifi
112amd64-default-pg96              121amd64-default-p95                      123amd64-dvl
112amd64-default-unifi             121amd64-default-pg10                     123amd64-dvl-primary
112amd64-working                   121amd64-default-pg11                     130amd64-default-pg13
112amd64-working-master-list       121amd64-default-pg12                     130amd64-default-pg14
112i386-default-master-list        121amd64-default-pg12-121                 130amd64-default-primary

Where do packages come from?

On FreeBSD, by default, this file indicates where packages will come from:

% cat /etc/pkg/FreeBSD.conf
# $FreeBSD$
#
# To disable this repository, instead of modifying or removing this file,
# create a /usr/local/etc/pkg/repos/FreeBSD.conf file:
#
#   mkdir -p /usr/local/etc/pkg/repos
#   echo "FreeBSD: { enabled: no }" > /usr/local/etc/pkg/repos/FreeBSD.conf
#

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

Notice the use of a variable, ABI. See man pkg.conf for more information on available variables.

Here’s a shortcut I use nearly every day to see what repo a host is using:

% pkg -vv | grep url
    url             : "pkg+http://pkg.FreeBSD.org/FreeBSD:12:amd64/quarterly",

The above is the default repository for a host using FreeBSD 12

Using a non-standard repo

[webs02 dan ~] % pkg -vv | grep url url : “pkg+http://fedex.int.unixathome.org/packages/122amd64-default-primary/”,

This configuration appears in the following file:

[webs02 dan ~] % cat /usr/local/etc/pkg/repos/local.conf

FreeBSD: { enabled: no }

local: {
   url: "pkg+http://fedex.int.unixathome.org/packages/122amd64-default-primary/"
   mirror_type: "srv",
   signature_type: "PUBKEY",
   pubkey: "/etc/ssl/slocum.unixathome.org.cert",   
   enabled: true
}

This configuration file disables the use of the FreeBSD repo. In short, it overrides the setting in /etc/pkg/FreeBSD.conf. The resulting URL maps directly to one of the repositories listed above. This jail was recently upgraded to FreeBSD 12.3:

[webs02 dan ~] % file /bin/sh
/bin/sh: ELF 64-bit LSB executable, x86-64, version 1 (FreeBSD), dynamically linked, interpreter /libexec/ld-elf.so.1, for FreeBSD 12.3, FreeBSD-style, stripped

If I want to install the FreeBSD 12.3 packages on this host, I need to modify /usr/local/etc/pkg/repos/local.conf

My goal: not having to update that file and still use my existing naming conventions for poudriere jails and repos.

What I came up with

Reading man pkg.conf I came up with this solution for /usr/local/etc/pkg/repos/local.conf:

url: "pkg+http://fedex.int.unixathome.org/packages/${VERSION_MAJOR}${VERSION_MINOR}${ARCH}-default-primary/"

Which gives this result:

% pkg -vv | grep url
    url             : "pkg+http://fedex.int.unixathome.org/packages/123amd64-default-primary/",

With this, when I use mkjail to upgrade a jail from FreeBSD 12.2 to FreeBSD 12.3 (for example), the packages from the corresponding repo will also be installed.

That’s one less step for me later.

Website Pin Facebook Twitter Myspace Friendfeed Technorati del.icio.us Digg Google StumbleUpon Premium Responsive