Re: [PATCH] Fix missing pkgbase jail packages [Was: Re: FreeBSD 15.1-RC3 Now Available]

Harry Schmalzbauer <[email protected]> Wed, 1 Jul 2026 13:31:58 +0200
Newsgroups gmane.os.freebsd.stable
Organization OmniLAN
Message-ID <[email protected]>
On 2026-06-22 21:19, Harry Schmalzbauer wrote:
> On 2026-06-20 20:24, Sulev-Madis Silber wrote:
...
>> share them anyway, i'm curious how others make their custom releases...
>
>
> Please find the fix for the missing jail packagase here:
> https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=296202
>
> First pkgbase release customization extensions:
>
> D57742 pkgbase release improvements
> https://reviews.freebsd.org/D57742
>
> D57745 pkgbase release improvements part2
> https://reviews.freebsd.org/D57745
>
> D57751 pkgbase release improvements part3
> https://reviews.freebsd.org/D57751
>

I think creating a review for part4 makes no sense,
since it doesn't fix or improve the official release building.

It's just for customization - here's my part4:
commit efc2dc4bbc6d66b59a3ca051750b47262c027056
Author: chroot (build.FreeBSDi386-15) packages compiling user 
<[email protected]>
Date:   Mon Jun 29 20:52:34 2026 +0200

     Makefile.inc1: Add support for custom (inofficial) pkgbase releases

     Reserve three special BRANCH names: PRE, CUST and PROD.

     If one of these is defined as BRANCH in sys/conf/newvers.sh, a 
special package
     name appendix (-${PKG_VERSION}[.pkg]) will be composed, similar to 
what we
     already do for .a(lpha), .b(eta), .snap (STABLE/CURRENT) etc.

     By adding two resp. three additonal revision components in 
PKG_VERSION we
     ensure that standard release packages won't update custom installations
     (without enforcing downgrading).
     The third component (1st custom addition) always corresponds to the 
last
     three (sub-minor) SRCRELDATE digits.
     The next custom added component is OPTIONAL and corresponds to the 3rd
     REVISION component (if defined) in sys/conf/newvers.sh) and becomes 
the 4th.
     The last custom (inoffical) addition is the lowercase BRANCH 
definition.
     'cust' and 'prod' are ~ (tilde) separated components as is, but 
'pre' becomes
     '*pre' in order to comply to natural updating expectations.

     Examples (SRCRELDATE=1501501, definitions in sys/conf/newvers.sh):
         - BRANCH=CUST; REVISION=15.1      = 
FreeBSD-set-base-15.1.501~cust.pkg
         - BRANCH=CUST; REVISION=15.1.2    = 
FreeBSD-set-base-15.1.501.2~cust.pkg
         - BRANCH=PRE; REVISION=15.1.3     = 
FreeBSD-set-base-15.1.501.3~*pre.pkg
             (15.1.501.3~*pre will update 15.1.501.2~prod,
              15.1.501.2~prod will update 15.1.501.2~*pre,
              15.1.501~cust will update 15.1.501~*pre,
              15.1.501~*pre will update 15.1)
     Standard package name for RELEASE branch (only):
         - BRANCH=RELEASE; REVISION=15.1   = FreeBSD-set-base-15.1.pkg
         - BRANCH=RELEASE; REVISION=15.1.2 = FreeBSD-set-base-15.1.2.pkg

diff --git a/Makefile.inc1 b/Makefile.inc1
index 81484f01a3b5..9504ea140e91 100644
--- a/Makefile.inc1
+++ b/Makefile.inc1
@@ -556,7 +556,7 @@ SRCRELDATE!=    awk 
'/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
  VERSION=    FreeBSD ${_REVISION}-${_BRANCH:C/-p[0-9]+$//} 
${TARGET_ARCH} ${SRCRELDATE}
  .export VERSION
  .endif
-MAJOR_REVISION=    ${_REVISION:R}
+MAJOR_REVISION= ${_REVISION:C/([0-9]?[0-9])\.([0-9]?[0-9]).*/\1/}

  _PKG_REVISION=    ${_REVISION}
  _STRTIMENOW=    %Y%m%d%H%M%S
@@ -566,6 +566,25 @@ BRANCH_EXT=
  _PKG_REVISION:= ${MAJOR_REVISION}
  BRANCH_EXT=    ${MAJOR_REVISION}.snap
  EXTRA_REVISION=    .snap${_TIMENOW}
+.elif ${_BRANCH:MPROD} || ${_BRANCH:MCUST} || ${_BRANCH:MPRE}
+# Inofficial releases will always consist of a third PKG_VERSION component
+# corresponding to the last three SRCRELDATE (sub-minor) digits.
+# This ensures official releases will never update custom releases
+# (but other way round does).
+# Additionally, the lowercase BRANCH will be appended with '~' as separator
+# character ([~cust|~prod]).
+BRANCH_EXT=    ${_BRANCH:tl}
+.  if ${_REVISION:R} == ${MAJOR_REVISION}
+# In order to follow natural upgrade expectations, 'pre' get's a 
leading '*'
+# character (~*pre), see libpkg/pkg_version.c for more details, which 
can be
+# found after 'make extract' in ports/ports-mgmt/pkg in 
${WRKDIR}/pkg-2.7.5/).
+EXTRA_REVISION= .${SRCRELDATE:C/^.{4}//}~${BRANCH_EXT:C/^pre$/*pre/}
+.  else
+# If there is a third (3rd) REVISION component (defined in 
src/sys/newvers.sh)
+# it becomes the 4th component (the inoffical-releases private counter).
+_PKG_REVISION:= ${_REVISION:R}
+EXTRA_REVISION= 
.${SRCRELDATE:C/^.{4}//}.${_REVISION:E}~${BRANCH_EXT:C/^pre$/*pre/}
+.  endif
  .elif ${_BRANCH:MALPHA*}
  BRANCH_EXT=    alpha
  EXTRA_REVISION=    .a${_BRANCH:C/ALPHA([0-9]+).*/\1/}.${_TIMENOW}

The package naming must follow what 
ports.wrkroot/ports-mgmt/pkg/work/pkg-2.7.5/libpkg/pkg_version.c allows.
(the minus (dash) is a reserved name-version separator, _ is also 
treated specially, so this for example can't work:
  EXTRA_REVISION= -${BRANCH_EXT}.${SRCRELDATE:C/^.{4}//}_${_REVISION:E}
)
I've tested the diff above - it works as described in the commit log.

Best,

-harry