Call for testing: pkgbase support in 15.0

one more question: before I did pkg delete -af to have a clean base system, how am I supposed to accomplish that now with pkgbase?
That's been a hot topic on the MLs. In my view some of the responses on the use of pkg delete -a[f] could have been more thoughtful towards users and their practices. I like this response (by jamie at the forums IIRC); my thoughts are along similar lines.

It is not uncommon that unintended use is deployed by users in need of a particular solution. Now that particular use happens in a new environment.

pkg delete --allportspackages does not exist. Have a look at this sequence:
Code:
# pkg query -e '%o~base/* && %k != 1' '%n' > lock-unlock.list
# pkg lock -y $( cat ./lock-unlock.list )
# pkg delete -a
# pkg unlock -y $( cat lock-unlock.list )	
# rm ./lock-unlock.list
Using pkg query -e '%o~base/* && %k != 1' '%n' should be much better served when base packages are saved in
the pkg db stores as such. I imagine, it wouldn't be that hard given freebsd-base(7) states that base packages have as unique property:
Code:
All base packages have names beginning with the string 
"FreeBSD-", and have an origin beginning with "base/".
A specific pkg-query variable could be used, say Z; to list all installed base packages: pkg query -e '%Z=1' '%n'
Conversely, list all non-base packages: pkg query -e '%Z!=1' '%n'

Having implemented this, implementing the much desired delete all installed packages from the ports tree with:
pkg delete -e '%Z!=1'
 
It would be nice if option -r reponame restricts EVERYTHING that are available (or explicitly marked deleted) on the very repo, including option -af.
For example, pkg delete -af would delete even base if installed using pkgbase or pkgbasify'ed from other types of instllation.

But it would be desired that pkg delete -af -r FreeBSD-ports should NOT touch anything installed from FreeBSD-kmods and FreeBSD-base. If I'm not overlooking, it's impossible at least for now.
 
1. I decided to mess with the system. Here's what I did:
# nano /usr/local/etc/pkg.conf
Code:
PKG_DBDIR = "/var/db/pkg";
PKG_CACHEDIR = "/var/cache/pkg";
REPOS_DIR [
"/etc/pkg/",
"/usr/local/etc/pkg/repos/",
]
ABI = "FreeBSD:15:amd64";

2. Something started to work:
# pkg update
Code:
pkg: Setting ABI requires setting OSVERSION, guessing the OSVERSION is: 1500000
pkg: Warning: Major OS version upgrade detected. Running "pkg bootstrap -f" recommended
Updating FreeBSD repository catalogue...
pkg: Repository FreeBSD has a wrong packagesite, need to re-create database
Fetching meta.conf: 100% 179 B 0.2kB/s 00:01
Fetching data.pkg: 100% 10 MiB 1.3MB/s 00:08
Processing entries: 0%
Newer FreeBSD version for package zxfer:
To ignore this error set IGNORE_OSVERSION=yes
- package: 1500068
- running userland: 1500000
Ignore the mismatch and continue? [y/N]: N
3.More:
# pkg bootstrap -f
Code:
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+https://pkg.FreeBSD.org/FreeBSD:14:amd64/quarterly, please wait...
Verifying signature with trusted certificate pkg.freebsd.org.2013102301... done
pkg-static: Setting ABI requires setting OSVERSION, guessing the OSVERSION as: 1500000
pkg-static: Warning: Major OS version upgrade detected. Running "pkg bootstrap -f" recommended
Installing pkg-2.4.2...
pkg-static: wrong architecture: FreeBSD:14:amd64 instead of FreeBSD:15:amd64
pkg-2.4.2 is locked and may not be modified
Failed to install the following 1 package(s): /tmp//pkg.pkg.2HWqdB
Bootstrapping pkg from pkg+https://pkg.FreeBSD.org/FreeBSD:14:amd64/kmods_quarterly_3, please wait...
pkg: Attempted to fetch pkg+https://pkg.FreeBSD.org/FreeBSD:14:amd64/kmods_quarterly_3/Latest/pkg.pkg
pkg: Attempted to fetch pkg+https://pkg.FreeBSD.org/FreeBSD:14:amd64/kmods_quarterly_3/Latest/pkg.txz
pkg: Error: Not Found
A pre-built version of pkg could not be found for your system.
Bootstrapping pkg from pkg+https://pkg.FreeBSD.org/FreeBSD:14:amd64/base_release_0, please wait...
pkg: Attempted to fetch pkg+https://pkg.FreeBSD.org/FreeBSD:14:amd64/base_release_0/Latest/pkg.pkg
pkg: Attempted to fetch pkg+https://pkg.FreeBSD.org/FreeBSD:14:amd64/base_release_0/Latest/pkg.txz
pkg: Error: Not Found
A pre-built version of pkg could not be found for your system.

4. More...
# pkg unlock pkg
Code:
pkg: Setting ABI requires setting OSVERSION, guessing the OSVERSION is: 1500000
pkg: Warning: Major OS version upgrade detected. Running "pkg bootstrap -f" recommended
pkg-2.4.2: unlock this package? [y/N]: y
Unlocking pkg-2.4.2

5. But I decided to deliberately break my system again. Here's where my pkg breaks:
# pkg add -f https://pkg.freebsd.org/FreeBSD:15:$(uname -p)/base_release_0/FreeBSD-pkg-bootstrap-15.0.pkg
Code:
pkg: Setting ABI requires setting OSVERSION, guessing the OSVERSION is: 1500000
pkg: Warning: Major OS version upgrade detected. Running "pkg bootstrap -f" recommended
Fetching FreeBSD-pkg-bootstrap-15.0.pkg: 100% 153 KiB 156.7kB/s 00:01
Installing FreeBSD-pkg-bootstrap-15.0...
Newer FreeBSD version for package FreeBSD-pkg-bootstrap:
To ignore this error set IGNORE_OSVERSION=yes
- package: 1500068
- running userland: 1500000
Ignore the mismatch and continue? [y/N]: y
package FreeBSD-pkg-bootstrap is already installed, forced install
pkg: FreeBSD-pkg-bootstrap-15.0 conflicts with FreeBSD-pkg-bootstrap-man-14.3p6 (installs files into the same place). Problematic file: /usr/share/man/man7/pkg.7.gz ignored by forced mode
Extracting FreeBSD-pkg-bootstrap-15.0: 100%
---
6. Put the system back into a tailspin again:
# pkg -vv | sed -nE -e '/(OSVERSION|ABI|BACKUP)/ p' -e '/^Repositories:/,$ p'
Code:
ld-elf.so.1: Shared object "libcrypto.so.35" not found, required by "pkg"
7. I don't understand how to get the system back to point #2. At least something was working. :)
 
# pkg-static install -f FreeBSD-pkg-bootstrap
Code:
pkg-static: Setting ABI requires setting OSVERSION, guessing the OSVERSION as: 1500000

pkg-static: Warning: Major OS version upgrade detected.  Running "pkg bootstrap -f" recommended

Updating FreeBSD-ports repository catalogue...

pkg-static: Repository FreeBSD-ports has a wrong packagesite, need to re-create database

Fetching meta.conf: 100%    179 B   0.2kB/s    00:01   

Fetching data.pkg: 100%   10 MiB   1.1MB/s    00:10   

Processing entries:   0%

Newer FreeBSD version for package zxfer:

To ignore this error set IGNORE_OSVERSION=yes

- package: 1500068

- running userland: 1500000

Ignore the mismatch and continue? [y/N]:
 
Instead of using:
# pkg -vv | sed -nE -e '/(OSVERSION|ABI|BACKUP)/ p' -e '/^Repositories:/,$ p'
Use:
# pkg-static -vv | sed -nE -e '/(OSVERSION|ABI|BACKUP)/ p' -e '/^Repositories:/,$ p'
Post its output.

1. I decided to mess with the system.
I assume you are attempting to get to a packaged base 15.0-RELEASE, please clarify.


For attempts to get to 15.0-RELEASE, try this change to /usr/local/etc/pkg.conf, instead of:
Code:
ABI = "FreeBSD:15:amd64";
change to:
Code:
ABI = "FreeBSD:15:amd64";
OSVERSION = 1500068

I suggest you keep using pkg-static (not pkg ... ) except when you need to force-install pkg(8), then use: pkg bootstrap -f
 
I also have a VM installed since 15_alplha3 that I successfully upgraded to RC4, but the next upgrade went wrong.
TBH I didn't even try to troubleshoot it, because I did lot of tests and tweaks with it, so for me it's basically just a throw away VM, but I think it worth to mention it.
This the error message:
Code:
root@fbsd ~ > pkg upgrade
Updating FreeBSD-ports repository catalogue...
FreeBSD-ports repository is up to date.
Updating FreeBSD-ports-kmods repository catalogue...
FreeBSD-ports-kmods repository is up to date.
Updating FreeBSD-base repository catalogue...
Fetching data.pkg: 100%   80 KiB  81.6kB/s    00:01
pkg: No trusted public keys found
FreeBSD-base repository is up to date.
All repositories are up to date.
Checking for upgrades (339 candidates): 100%
Processing candidates (339 candidates): 100%
The following 9 package(s) will be affected (of 0 checked):

Installed packages to be UPGRADED:
    FreeBSD-clibs-dev: 15.0.rc2.20251119215629 -> 15.0.rc4.20251126000054 [FreeBSD-base]
    FreeBSD-kernel-generic: 15.0.rc4.20251124184226 -> 15.0.rc4.20251126000054 [FreeBSD-base]

Installed packages to be REINSTALLED:
    FreeBSD-clibs-15.0.rc1.20251116042758 [FreeBSD-base] (Vital flag changed: 'true' -> 'false')
    FreeBSD-runtime-15.0.rc4.20251124184226 [FreeBSD-base] (Vital flag changed: 'true' -> 'false')
    FreeBSD-set-base-15.0.rc1.20251116042758 [FreeBSD-base] (Vital flag changed: 'true' -> 'false')
    FreeBSD-set-devel-15.0.rc1.20251116042758 [FreeBSD-base] (Vital flag changed: 'true' -> 'false')
    FreeBSD-set-lib32-15.0.rc1.20251116042758 [FreeBSD-base] (Vital flag changed: 'true' -> 'false')
    FreeBSD-set-minimal-15.0.rc1.20251116042758 [FreeBSD-base] (Vital flag changed: 'true' -> 'false')
    FreeBSD-set-optional-15.0.rc1.20251116042758 [FreeBSD-base] (Vital flag changed: 'true' -> 'false')

Number of packages to be upgraded: 2
Number of packages to be reinstalled: 7

62 MiB to be downloaded.

Proceed with this action? [y/N]: y
pkg: Failed to fetch https://pkg.FreeBSD.org/FreeBSD:15:amd64/base_release_0/FreeBSD-kernel-generic-15.0.rc4.20251126000054.pkg: Unknown error
pkg: Failed to fetch https://pkg.FreeBSD.org/FreeBSD:15:amd64/base_release_0/FreeBSD-kernel-generic-15.0.rc4.20251126000054.pkg: Unknown error

I found a fix and successfully upgraded it to 15.0-RELEASE, checked dependencies, removed old packages, everything seems in order and works fine.
This a VM that I have since 15.0-ALPHA3, a pkgnew might have slipped in during the last upgrade I imagine and I didn't noticed it.
So it basically changes how FreeBSD.conf is configured, one URL also changed a bit, in my case the file /usr/local/etc/pkg/repos/FreeBSD.conf needed to be removed because all the repositories are now defined in /etc/pkg/FreeBSD.conf.

So just in case, remember to search for any pkgnew,pkgsave and apply modifications accordingly.
find / -type f | grep -E "pkgnew|pkgsave".
pkgnew: it's the new config file, but it's up to the user to actually make modifications manually.
pkgsave: it basically is the previous version of the config file, I suppose it's there to compare changes, or switch back if needed.

I know people won't probably have to go through such adventure since 15.0-RELEASE is now available, but who knows, it might be useful to someone.
 
1. I decided to mess with the system. Here's what I did:
# nano /usr/local/etc/pkg.conf
Code:
PKG_DBDIR = "/var/db/pkg";
PKG_CACHEDIR = "/var/cache/pkg";
REPOS_DIR [
"/etc/pkg/",
"/usr/local/etc/pkg/repos/",
]
ABI = "FreeBSD:15:amd64";
I am not sure but directory should be /usr/local/etc/pkg/repos/FreeBSD.conf
 
Hm, can't pkgbase have it's own command so it is distinguishable for users ?

Like currently we have:
- freebsd-update <-- handles kernel/base
- pkg <-- handles binary packages

Those 2 are pretty easy to identify and use.

Maybe a 'sysupgrade' or 'bsdupgrade' that handles what pkgbase is currently doing now and leave pkg for handling binary packages. As it stands right now, the pkgbase approach is confusing, unlike the freebsd-update method.

Just my 2 cents..
 
I am not sure but directory should be /usr/local/etc/pkg/repos/FreeBSD.conf
I rolled back the entire SSD to 14.3p6+pkgbasify. I'll check everything carefully. I'm not happy with the idea that official commands somehow break the pkg. Or wait for 14.4. Maybe the transition from 14.4 to 15.xx will be clearer to me there.
 
I rolled back the entire SSD to 14.3p6+pkgbasify. I'll check everything carefully. I'm not happy with the idea that official commands somehow break the pkg. Or wait for 14.4. Maybe the transition from 14.4 to 15.xx will be clearer to me there.
...or try upgrade with freebsd-update upgrade and that swith to pkgbasify.
 
I'm pretty sure you already know this, but just in case... if you have an install that's been pkgbasify-ed, you can't use freebsd-update. The last I saw they, whoever they are, were working on a clear way to de-pkgbasify something, but I don't know the details. (And of course, I have my own issues with a pkgbasify system, but I haven't investigated fixing it enough to post on it yet. That is, I could post pkgbasify didn't work, I got some errors, but I don't remember them. :) But I have to get more info before posting.) And, another pkgbasify, my first attempt, really didn't work, but I dunno where I went wrong there and wound up just doing a fresh 15.0 install.
 
After I installed my laptop with 15.0-RELEASE, I have to rebuild the kernel to add a network card driver. In FreeBSD with pkgbase, running make installkernel DESTDIR=/ overriding existing kernel files breaks pkg check -s (checksum). IMHO, it's better to install the kernel with .pkg files. I could only package the whole base system after make buildworld with make packages or make packageworld. make packagekernel does not yield .pkg files and it's related to traditional distribution sets. Is there any command to package a custom kernel to .pkg files without building the whole base system?
 
Is there any command to package a custom kernel to .pkg files without building the whole base system?
It seems the create-packages-kernel target is doing the job, kernel-toolchain buildkernel required :
Rich (BB code):
/usr/src-15.0 #  make create-packages-kernel KERNCONF=MYKERNEL
===> Creating FreeBSD-kernel-mykernel-15.0

/usr/src-15.0 % find /usr/obj -name 'FreeBSD-kernel-mykernel*'
/usr/obj/usr/src-15.0/repo/FreeBSD:15:amd64/15.0/FreeBSD-kernel-mykernel-15.0.pkg

src/Makefile.inc1
Rich (BB code):
   2141 create-packages-kernel: _pkgbootstrap _repodir .PHONY
   2142         ${_+_}@cd ${.CURDIR}; \
   2143                 ${MAKE} -f Makefile.inc1 \
   2144                         DESTDIR=${KSTAGEDIR} \
   2145                         PKG_VERSION=${PKG_VERSION} DISTDIR=kernel \
   2146                         SOURCE_DATE_EPOCH=${SOURCE_DATE_EPOCH} \
   2147                         create-kernel-packages
 
I installed 15.0-RELEASE on a thinkpad T460. My 8260 card was not detected at all. Not even by the iwm wifi driver.

I entered the shell before the installer, loaded the iwlwifi driver, then it was detected during install.

Post install I had to add some vars to rc.conf to prevent iwm from loading, and iwlwifi then worked fine for me.
 
Hm, can't pkgbase have it's own command so it is distinguishable for users ?

^^ exactly this is my opinion, too. I'd love to have pkg to manage third party packages and something like ospkg or basepkg or fpkg or whatever you call it to manage the operating system. With the current thing we have entered linux land, it feels
 
It seems the create-packages-kernel target is doing the job, kernel-toolchain buildkernel required :
Rich (BB code):
 /usr/src-15.0 # make create-packages-kernel KERNCONF=MYKERNEL ===> Creating FreeBSD-kernel-mykernel-15.0 /usr/src-15.0 % find /usr/obj -name 'FreeBSD-kernel-mykernel*' /usr/obj/usr/src-15.0/repo/FreeBSD:15:amd64/15.0/FreeBSD-kernel-mykernel-15.0.pkg
src/Makefile.inc1
Rich (BB code):
 2141 create-packages-kernel: _pkgbootstrap _repodir .PHONY 2142 ${_+_}@cd ${.CURDIR}; \ 2143 ${MAKE} -f Makefile.inc1 \ 2144 DESTDIR=${KSTAGEDIR} \ 2145 PKG_VERSION=${PKG_VERSION} DISTDIR=kernel \ 2146 SOURCE_DATE_EPOCH=${SOURCE_DATE_EPOCH} \ 2147 create-kernel-packages
Thanks for your hint. However it does not work either:
Code:
/usr/src $ sudo make create-packages-kernel KERNCONF=MYKERNEL
pkg: Unable to determine the ABI, none of the ABI_FILEs can be read.
pkg: Cannot parse configuration file!
make[2]: /usr/src/Makefile.inc1:2008: warning: Command "pkg -o ABI_FILE=/usr/obj/usr/src/amd64.amd64/worldstage/usr/bin/uname config ABI" exited with status 1
===> Creating FreeBSD-kernel-mykernel-15.0
pkg: Unknown OS '' in ABI string
pkg: Cannot parse configuration file!
*** Error code 1

Stop.
make[2]: stopped making "create-kernel-packages" in /usr/src
*** Error code 1

Stop.
make[1]: stopped making "create-packages-kernel" in /usr/src
*** Error code 1

Stop.
make: stopped making "create-packages-kernel" in /usr/src
 
However it does not work either:
After extensive testing, to create custom kernel packages one must build and create with the buildworld, buildkernel KERNCONF=<MYCUSTOMKCONF>, and packages targets on the first run.

After the above first run, subsequent kernel packages can be created with the mentioned method in post # 288:
Code:
# make -j X  buildkernel KERNCONF=<MYCUSTOMKERNCONF>
# make create-packages-kernel KERNCONF=<MYCUSTOMKERNCONF>

It seems it's not possible to create a kernel package from buildkernel only.

I have to apologize for the suggested solution in my post # 288. For testing purposes I create ZFS "src" dataset clones from a parent src dataset, operating on that clone to have separate OBJ dirs, normally (it can be done with normal dirs as well instead of ZFS datasets). In this case, by mistake, when I tested kernel package creation, I did it in a src dataset from which existed a "buildworld", "buildkernel" and "packages" executed targets.

Sorry for the confusion.
 
Last edited:
After extensive testing, to create custom kernel packages one must build and create with the buildworld, buildkernel KERNCONF=<MYCUSTOMKCONF>, and packages targets on the first run.

After the above first run, subsequent kernel packages can be created with the mentioned method in post # 288:
Code:
# make -j X  buildkernel KERNCONF=<MYCUSTOMKERNCONF>
# make create-packages-kernel KERNCONF=<MYCUSTOMKERNCONF>

It's seems it's not possible to create a kernel package from buildkernel only.

I have to apologize for the suggested solution in my post # 288. For testing purposes I create ZFS "src" dataset clones from a parent src dataset, operating on that clone to have separate OBJ dirs, normally (it can be done with normal dirs as well instead of ZFS datasets). In this case, by mistake, when I tested kernel package creation, I did it in a src dataset from which existed a "buildworld", "buildkernel" and "packages" executed targets.

Sorry for the confusion.
Many thanks for your suggestion and the exhaustive testing! So we could confirm that the current pkgbase toolchain needs at least running make buildworld once before building separate kernel .pkg packages. Maybe the author of pkg(8) can resolve this extra dependency (if it is), or IMHO we should send your finding to the mailing list.
 
Many thanks for your suggestion and the exhaustive testing!
No problem.

I was also investigating pkg-create(8) a package from /boot/kernel.custom. For doing so, a MANIFEST file is necessary, but I couldn't find a shell script in the source code which does it automatically (e.g. <shell_script> /boot/kernel.custom > MANIFEST).

For example, a pkgbase kernel MANIFEST file looks like pkg info -R FreeBSD-kernel-generic:
Code:
name: "FreeBSD-kernel-generic"
origin: "base/FreeBSD-kernel-generic"
version: "15.0"
comment: "FreeBSD GENERIC Kernel "
maintainer: "re@FreeBSD.org"
www: "https://www.FreeBSD.org"
abi: "FreeBSD:15:amd64"
arch: "freebsd:15:x86:64"
prefix: "/"
flatsize: 160719006
timestamp: 1765797975
licenselogic: "single"
licenses: [
    "BSD2CLAUSE"
]
desc: "FreeBSD GENERIC Kernel"
categories: [
    "base"
]
annotations: {
    FreeBSD_version: "1500068",
    repo_type: "binary",
    repository: "FreeBSD-base",
    set: "kernels"
}
files: {
    /boot/kernel/aac.ko: {
        sum: "1$42cbac7e229701648e620f420e01126291798be9ba636b4d961b9b3749b139ab",
        uname: "root",
        gname: "wheel",
        perm: "0444",
        fflags: 0,
        mtime: 1764492937
    },    /boot/kernel/aacraid.ko: {
        sum: "1$52c6e21638c3444e506f99fc47ca5eb4634a5c3e5a0fbee34ace6b96ffa0c261",
        uname: "root",
        gname: "wheel",
        perm: "0444",
        fflags: 0,
        mtime: 1764492937
    },
...

Such a kernel MANIFEST file must be created automatically from a script, it's not possible to do it manually (note all those "sum" -> "mtime" in the "files" section for each kernel file).

If there were a MANIFEST file, a package can be created calling: pkg create -M MANIFEST.



All that technical kernel package creation aside,
Maybe the author of pkg(8) can resolve this extra dependency (if it is), or IMHO we should send your finding to the mailing list.
In FreeBSD with pkgbase, running make installkernel DESTDIR=/ overriding existing kernel files breaks pkg check -s (checksum).
Best course of action is to ask on freebsd-pkgbase@ ( all the pkgbase developers are there), and one of the questions should be how to handle custom kernel and pkgbase "base" packages, in particular when there is an security or errata update.

Removing the kernel-generic package would silence pkg-check(8) and, I could imagine it would exclude a kernel package update (which would overwrite the custom kernel), but I'm not sure. There are no updates for 15.0-RELEASE available, yet, and I haven't tested 15.0-STABLE or 16.0-CURRENT, which have regular updates, in particular CURRENT.
 
Code:
> This issue is corrected as of the corresponding Git commit hash in the
> following stable and release branches:
> 
> Branch/path                             Hash                     Revision
> -------------------------------------------------------------------------
> releng/15.0/                            408f5c61821f  releng/15.0-n280998

A quick heads-up here for pkgbase users: If you upgrade to 15.0-RELEASE-p1
and run `uname -v` you will see a different hash from this.
 
Back
Top