Re: Questions about pkgbase

From: Lexi Winter <ivy_at_freebsd.org>
Date: Thu, 02 Oct 2025 09:17:30 UTC
Yasuhiro Kimura wrote in <20251002.180121.980053125503545103.yasu@FreeBSD.org>:
> 1. Consistency with update using source tree
> 
> Let me assume I made clean install of 16.0-CURRENT system with pkgbase
> and updated it using source tree (make {build,install}{kernel,world}).

you shouldn't use installworld/installkernel to update a pkgbase system
from source.  instead, use make buildworld buildkernel update-packages,
which will build a package repository you can use to update with pkg(8).

> After it has completed, base system itself shoule be updated
> successfully. Then what about things about pkgbase (e.g. version of
> package, list of included files, etc.)? Are they properly updated or
> become inconsistent?
 
this would cause the package database to be inconsistent with the
installed system, which will certainly break things later.

>[...]
> a. Follow the step 1 to step 10 explained in /usr/src/Makefile
> b. Rebuild and reinstall all (non-pkgbase) packages.
> c. Do `make delete-old-libs`.
> 
> On the other hand, it doesn't seems pkgbase keeps obsolete files while
> updating. IIUC `pkg upgrade` uninstall all files included in old
> version of package in question before installing files of new
> version. So obsolete files dissapear after update has finished. Then
> is there any way to prevent situation as above?

pkg(8) has a feature called BACKUP_LIBRARIES which moves deleted shared
libraries into a temporary package.  this allows you to update ports,
then delete the temporary package, which has the same effect as
delete-old-libs.

there is an outstanding issue that means this doesn't work as well as it
should with pkgbase: https://github.com/freebsd/pkg/issues/2501.
re@ is aware of this and it should be fixed for 15.0-RELEASE.

>[...]
> On pkgbase system, however, files under /etc seems to belong to
> packages. So they are updated by `pkg upgrade`. Then how confliction
> is handled if it happnes?

pkg(8) will attempt a 3-way merge when installing a new configuration
file.  if this is successful, no action is required.  if it fails, the
existing file will be left unchanged and pkg will create a <name>.pkgnew
file, which you need to manually merge with the existing version of the
file.

this workflow is much worse than etcupdate or freebsd-update, and i'm
not convinced we should release with pkgbase as the recommended option
without a better solution, but we'll see.

note that this is *not* the same way ports handles new configuration
files; this feature is not used by ports at all, it is specific to the
base system.

> 4. Build pkgbase repository by myself
> 
> I'd like to build pkgbase repository and configure system to use
> it. Is it documented somewhere?

this is what 'make update-packages' does.  it is briefly documented in
build(7), there is (as far as i know) no Handbook documentation yet.

>[...]
> Then is there any way to (re|un)install all installed non-pkgbase
> packages?

this should be possible using 'pkg delete -r FreeBSD-ports', but
currently this option does not exist.  there is a feature request
to add it: https://github.com/freebsd/pkg/issues/2494.