Dag-Erling_Smørgrav <des_at_FreeBSD.org> wrote on Date: Sun, 23 Nov 2025 17:12:08 UTC :
> [email protected] writes: > > what is the correct way to depkgbasify? > > There is no “correct” way. Here's what I would suggest: > > 1. Make sure your system is up-to-date and consistent and you have a > matching source tree installed: > > # pkg upgrade -y > # pkg install -y FreeBSD-set-src > # pkg autoremove -y > > 2. Make a list of non-pkgbase non-automatic packages: > > # pkg query -e '%a == 0 && %o !~ base/*' %n >packages > > 3. Delete your installed package database: > > # rm /var/db/pkg/local.sqlite > > 4. Reinstall non-pkgbase packages: > > # pkg install -fy $(cat packages) > > This will of course also reinstall all dependencies, but we are > deliberately only specifying non-automatic packages so the end result > is the same as what we started out with. If we had made a list of > _all_ installed packages, we would end up with everything now being > marked non-automatic, and `pkg autoremove` would no longer work > properly. > > 5. Populate /var/db/etcupdate so it will work when you later upgrade > from source: > > # etcupdate extract > > 6. Optional but recommended — disable the pkgbase repository: > > # rm /usr/local/etc/pkg/repos/FreeBSD.conf > > (this file will have been created by the installer and should contain > a single line that enables the FreeBSD-base repository; without it, > the repository remains defined in /etc/pkg/FreeBSD.conf but disabled) > > You can also remove cached information about the repository, which > you will no longer need: > > # rm -rf /var/db/pkg/repos/FreeBSD-base > > At this point you can replace /usr/src with a git clone and upgrade as > usual (`make -C /usr/src -j1.5 world kernel && etcupdate -B`). > > There is a shortcut for steps 2-4. I think it is both sufficient and > safe, but I don't know pkg's internals well enough to say for sure; > perhaps bapt@ can weight in. First you need to install the sqlite3 cli: > > # pkg install -Ay sqlite3 > > You can then use it to remove information about base packages from the > package database, leaving the rest intact so you don't have to reinstall > them: > > # sqlite3 /var/db/pkg/local.sqlite \ > "delete from packages where origin like 'base/%';" > > If you choose this route you can also drop the autoremove in step 1, > which I only put in to shorten steps 2 and 4. You still have to perform > step 5 (and optionally 6). At some point after one is no longer dependent on FreeBSD-*.pkg files from pkgbase, one may want to recover the disk space from any: /var/cache/pkg/FreeBSD-*.pkg files. # ls -l /var/cache/pkg/FreeBSD-*.pkg lrwxr-xr-x 1 root wheel 49 Nov 15 15:48 /var/cache/pkg/FreeBSD-acct-16.snap20251112131218.pkg -> FreeBSD-acct-16.snap20251112131218~d117264470.pkg -rw-r--r-- 1 root wheel 48106 Nov 12 15:39 /var/cache/pkg/FreeBSD-acct-16.snap20251112131218~d117264470.pkg . . . (My file ownerships need not match yours.) # ls -1 /var/cache/pkg/FreeBSD-*.pkg | wc -l 1032 (Not that you would get that specific figure. I tend to have all the FreeBSD-*.pkg for the platform installed.) I'm not sure of what well fits with the above steps 1..6 for this. Possibly just as a step 7: # rm -f /var/cache/pkg/FreeBSD-*.pkg ? === Mark Millard marklmi at yahoo.com
