Skip to content

Instantly share code, notes, and snippets.

@grahamperrin
Last active November 1, 2025 11:38
Show Gist options
  • Select an option

  • Save grahamperrin/a58edbb8587af513a154ac01d922f611 to your computer and use it in GitHub Desktop.

Select an option

Save grahamperrin/a58edbb8587af513a154ac01d922f611 to your computer and use it in GitHub Desktop.
FreeBSD: pkgbase: major upgrades

FreeBSD: pkgbase: major upgrades

A rough guide, for alpha testing on AMD64:

  • tested with FreeBSD 15.0-ALPHA2 and ALPHA3
  • things might be less rough with ALPHA4, with or without the next release of ports-mgmt/pkg.

Not intended to be comprehensive.

Preamble

It's conventional to upgrade the userland part of base before upgrading non-base packages.

The numbered steps below break from convention. The disorderly approach is a workaround to pkg issue #2414. Proceed with caution.

Also, please note:

14.3-RELEASE-p3 to 15.0-ALPHA3

  1. su -
  2. pkg install devel/uclcmd
  3. /bin/tcsh
  4. pkg prime-origins | sort -u > /var/tmp/pkg-prime-origins.txt
  5. /usr/local/etc/periodic/daily/411.pkg-backup
  6. pkg upgrade
  7. uclcmd set --file /usr/local/etc/pkg/repos/FreeBSD-base.conf FreeBSD-base.url 'pkg+https://pkg.freebsd.org/${ABI}/base_latest'
  8. pkg -v
  9. note the version
  10. pkg lock -y pkg
  11. touch /usr/local/etc/pkg/repos/FreeBSD.conf
  12. cat /usr/local/etc/pkg/repos/FreeBSD.conf
  13. if the file is empty, run an echo command
  14. echo "FreeBSD {url = example} FreeBSD-kmods {url = example}" > /usr/local/etc/pkg/repos/FreeBSD.conf
  15. uclcmd set --file /usr/local/etc/pkg/repos/FreeBSD.conf FreeBSD.url 'pkg+https://pkg.freebsd.org/${ABI}/latest'
  16. uclcmd set --file /usr/local/etc/pkg/repos/FreeBSD.conf FreeBSD-kmods.url 'pkg+https://pkg.freebsd.org/${ABI}/kmods_latest'
  17. env ABI=FreeBSD:15:amd64 pkg update -f
  18. ignore all on-screen suggestions to run pkg bootstrap -f
  19. sysctl vm.pageout_oom_seq=120
  20. env ABI=FreeBSD:15:amd64 pkg upgrade --fetch-only --yes
  21. conflicts may be observed as a result of the fetch, another iteration (run of the command) may be required
  22. bectl create fourteen-fifteen-ready
  23. env ABI=FreeBSD:15:amd64 pkg upgrade -U FreeBSD-kernel-generic
  24. history -S
  25. exit
  26. shutdown -r now
  27. login as root at ttyv1
  28. /bin/tcsh
  29. service cron stop
  30. /usr/local/etc/periodic/daily/411.pkg-backup
  31. sysctl vm.pageout_oom_seq=120
  32. env ABI=FreeBSD:15:amd64 pkg-static upgrade -fU --repository FreeBSD
  33. env ABI=FreeBSD:15:amd64 pkg-static upgrade
  34. if the upgrades were successful, history -S then exit and shutdown -r now
  35. ee /usr/local/etc/pkg/repos/FreeBSD.conf
  36. modernise the repository names – FreeBSD-ports and FreeBSD-ports-kmods
  37. pkg install -nU -r FreeBSD-base --glob 'FreeBSD-set-*'
  38. decide whether you want any base meta package (for a FreeBSD Project-defined set of packages)
  39. pkg install -nU -r FreeBSD-base --glob 'FreeBSD-*'
  40. decide whether you want any additional base package
  41. when you're certain that bootstrap will not result in a downgrade, pkg-static unlock -y pkg && pkg bootstrap -fy
@grahamperrin
Copy link
Author

grahamperrin commented Sep 19, 2025

A question:

uclcmd usage after creating /usr/local/etc/pkg/repos/FreeBSD.conf

… (I do want to use uclcmd with a file that is initially empty.)

Usage (copy): https://pastebin.com/raw/r8gNNDQ5

@grahamperrin
Copy link
Author

sysctl vm.pageout_oom_seq=120

The use case for an increased value such as 120 should be documented.

With the default – 12 – memory-related killings may occur. In Reddit:

The pinned comment refers to a documentation bug report (closed) and subsequent discussion.

@grahamperrin
Copy link
Author

grahamperrin commented Sep 25, 2025

Dry runs of a major upgrade from RELEASE to CURRENT, preceded by a fetch of packages:

env ABI=FreeBSD:16:amd64 pkg upgrade -Fqy
root@freebsd-conf:~ # env ABI=FreeBSD:16:amd64 pkg upgrade -Fqy
pkg: Setting ABI requires setting OSVERSION, guessing the OSVERSION as: 1600000
pkg: Warning: Major OS version upgrade detected.  Running "pkg bootstrap -f" recommended
pkg: Cannot solve problem using SAT solver
root@freebsd-conf:~ # env ABI=FreeBSD:16:amd64 pkg-static upgrade -fnU --repository FreeBSD | grep 'to be removed'
pkg-static: Setting ABI requires setting OSVERSION, guessing the OSVERSION as: 1600000
pkg-static: Warning: Major OS version upgrade detected.  Running "pkg bootstrap -f" recommended
root@freebsd-conf:~ # env ABI=FreeBSD:16:amd64 pkg-static upgrade -fnU --repository FreeBSD-base | grep 'to be removed'
pkg-static: Setting ABI requires setting OSVERSION, guessing the OSVERSION as: 1600000
pkg-static: Warning: Major OS version upgrade detected.  Running "pkg bootstrap -f" recommended
Number of packages to be removed: 904
root@freebsd-conf:~ # env ABI=FreeBSD:16:amd64 pkg-static upgrade -fnU | grep 'to be removed'pkg-static: Setting ABI requires setting OSVERSION, guessing the OSVERSION as: 1600000
pkg-static: Warning: Major OS version upgrade detected.  Running "pkg bootstrap -f" recommended
Number of packages to be removed: 6
root@freebsd-conf:~ # pkg lock -l
Currently locked packages:
pkg-2.3.1
root@freebsd-conf:~ # file /usr/sbin/pkg /usr/local/bin/konsole
/usr/sbin/pkg:          ELF 64-bit LSB pie executable, x86-64, version 1 (FreeBSD), dynamically linked, interpreter /libexec/ld-elf.so.1, for FreeBSD 14.3, FreeBSD-style, stripped
/usr/local/bin/konsole: ELF 64-bit LSB executable, x86-64, version 1 (FreeBSD), dynamically linked, interpreter /libexec/ld-elf.so.1, for FreeBSD 14.2, FreeBSD-style, stripped
root@freebsd-conf:~ # freebsd-version -kru ; uname -mvKU
16.0-CURRENT
16.0-CURRENT
14.3-RELEASE-p3
FreeBSD 16.0-CURRENT main-n280598-57d5a8feda3f GENERIC amd64 1600000 1403000
root@freebsd-conf:~ # pkg repos -el | sort -f
FreeBSD
FreeBSD-base
FreeBSD-kmods
root@freebsd-conf:~ # pkg repos -e | grep -B 1 url
FreeBSD: { 
    url             : "pkg+https://pkg.FreeBSD.org/FreeBSD:14:amd64/latest",
--
FreeBSD-kmods: { 
    url             : "pkg+https://pkg.FreeBSD.org/FreeBSD:14:amd64/kmods_latest",
--
FreeBSD-base: { 
    url             : "pkg+https://pkg.FreeBSD.org/FreeBSD:14:amd64/base_latest",
root@freebsd-conf:~ # 
  • 0 (zero) removals with --repository FreeBSD (FreeBSD-ports)
  • 906 removals with --repository FreeBSD-base
  • 6 removals without specifying a repository.

A non-dry run of the third option does fetch additional packages.

The fetch-after-fetch effect was noted a few days ago:

Now, it's nice that I can avoid hundreds of unwanted removals by not specifying a repository.

Previously, with a major upgrade to 15.0-ALPHA3, it was necessary to specify the FreeBSD (ports) repository for a disorderly upgrade (port packages before userland).

@grahamperrin
Copy link
Author

Now, it's nice that I can avoid hundreds of unwanted removals by not specifying a repository.

False!

See https://gist.github.com/grahamperrin/cd67326a3339ca5278cf48d183188e25?permalink_comment_id=5773482#gistcomment-5773482

@grahamperrin
Copy link
Author

grahamperrin commented Sep 26, 2025

I completed a major upgrade from 14.3-RELEASE-p3 to (unannounced) 15.0-ALPHA4:

  • with pkg 2.2.2 locked prior to the upgrade
  • without an sqlite error πŸ‘
  • in a single step, without specifying a repo (not recommended, but I'm pleased that it worked).

Around a week later, sqlite-related issue 2522 recurred – not involving pkgbase, as far as I can tell.

The issue has been reproduced and diagnosed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment