Skip to content

Instantly share code, notes, and snippets.

@grahamperrin
Last active December 13, 2023 10:40
Show Gist options
  • Save grahamperrin/e7a266154793d0e039f9a7d52396f8d7 to your computer and use it in GitHub Desktop.
Save grahamperrin/e7a266154793d0e039f9a7d52396f8d7 to your computer and use it in GitHub Desktop.
Updating FreeBSD -CURRENT from source, and more

Notes:

  • the routine is personalised – things such as SDDM and graphics/x11/nvidia-driver-470 in the mix, and the longhand helps me to not make mistakes after being distracted (or falling asleep at the keyboard, or whatever)
  • /bin/csh for all commands below, some no longer require root since I changed ownership of /usr/doc, /usr/obj, /usr/ports, and /usr/src.

Routine

  1. su -
  2. pkg lock -l
  3. pkg unlock emulators/virtualbox-ose-kmod graphics/drm-510-kmod graphics/drm-515-kmod
  4. chown -vR grahamperrin /usr/obj/usr/src/amd64.amd64/sys/GENERIC-NODEBUG/usr/ports/ ; chown -vR grahamperrin /usr/obj/usr/src/amd64.amd64/sys/GENERIC/usr/ports/
  5. exit
  6. git -C /usr/doc branch -vv | grep \* && git -C /usr/ports branch -vv | grep \* && git -C /usr/src branch -vv | grep \*
  7. if necessary, switch /usr/ports and /usr/src/ to main
  8. git -C /usr/src reset --hard HEAD
  9. git -C /usr/ports pull --ff-only freebsd main && git -C /usr/src pull --ff-only freebsd main
  10. repeat step 9 until no changes are found
  11. glance at https://cgit.freebsd.org/src/log/, https://cgit.freebsd.org/src/tree/UPDATING#n29, and https://cgit.freebsd.org/ports/tree/UPDATING#n5 to estimate whether it's a good time to update
echo "" ; date ; uname -sr ; echo "shell: $SHELL" ; echo "" ; set freebsdmaingitcommitcount="`git -C /usr/src rev-list --first-parent --count HEAD`" && echo "freebsd/main (FreeBSD-CURRENT) Git commit count: $freebsdmaingitcommitcount" && set freebsdmaingithash="`git -C /usr/src rev-list --max-count=1 HEAD`" && echo "freebsd/main Git hash: $freebsdmaingithash" && echo "<https://cgit.freebsd.org/src/commit/?id=$freebsdmaingithash>" && echo "– in context: <https://cgit.freebsd.org/src/log/?qt=range&q=$freebsdmaingithash>"
  1. git -C /usr/src stash apply 0
  2. cd /usr/src && time make -j 16 buildworld | tee /var/log/buildworld.log > /dev/null && time make DISABLE_VULNERABILITIES=yes -j 16 buildkernel | tee /var/log/buildkernel.log > /dev/null && grep -C 2 completed\ on /var/log/buildworld.log && grep -C 2 completed\ on /var/log/buildkernel.log
  3. continue using the desktop environment until completion of the builds
  4. sudo bectl create n"$freebsdmaingitcommitcount"-"$freebsdmaingithash"-a && sudo bectl activate n"$freebsdmaingitcommitcount"-"$freebsdmaingithash"-a && sudo bectl mount n"$freebsdmaingitcommitcount"-"$freebsdmaingithash"-a /tmp/up
  5. sudo sysrc -R /tmp/up sddm_enable="NO"
  6. sudo bectl umount n"$freebsdmaingitcommitcount"-"$freebsdmaingithash"-a && bectl list -c creation
  7. use bectl(8) to shorten the name of the boot environment – remove twenty-eight characters from the tail of the git hash, leave twelve
  8. restart the computer
  9. key Alt-F2 for ttyv1
  10. login
  11. nextboot -o "-s"
  12. cd /usr/src && time make -j 200 installkernel | tee /var/log/installkernel.log > /dev/null && history -S && shutdown -r now
  13. /bin/csh
  14. mount -uw /
  15. zfs mount -a
  16. kldload nvidia-modeset
  17. setenv EDITOR /usr/local/bin/nano
  18. grep -C 1 completed\ on /var/log/installkernel.log
  19. etcupdate -p
  20. cd /usr/src && time make -j 200 installworld | tee /var/log/installworld.log > /dev/null && etcupdate -B
  21. grep -C 2 everything\ completed\ on /var/log/installworld.log
  22. make -DBATCH_DELETE_OLD_FILES delete-old && exit
  23. pkg search nvidia-driver-470 ; pkg search drm-510-kmod ; pkg search drm-515-kmod
  24. pkg lock -l
  25. pkg lock emulators/virtualbox-ose-kmod x11/nvidia-driver-470
  26. pkg upgrade --yes && pkg clean -a && pkg autoremove
  27. sysrc sddm_enable="YES" && history -S && reboot -r
  28. sign in to the desktop environment.

Additionally

For an existing poudriere jail named main with method src=/usr/src to gain an update equal to its host:

  • sudo poudriere jail -u -j main

Then, have readily-available packages of ports that are special to you. For example:

  • sudo poudriere ports -u && sudo poudriere bulk -j main -b latest -Ct x11/nvidia-driver-470 sysutils/sysctlinfo-kmod sysutils/sysctlbyname-improved-kmod emulators/virtualbox-ose-kmod graphics/drm-510-kmod graphics/drm-515-kmod graphics/gpu-firmware-radeon-kmod@btc graphics/gpu-firmware-radeon-kmod@sumo graphics/gpu-firmware-radeon-kmod@turks

Retrospective

Originally

git -C /usr clone -o freebsd -b main --depth 1 https://git.freebsd.org/src.git src

https://old.reddit.com/r/freebsd/comments/keme3b/heads_up_freebsd_changing_from_subversion_to_git/ghxggjm/

One-off, 2021-03-02

git -C /usr/src pull --ff-only --unshallow

https://lists.freebsd.org/pipermail/freebsd-current/2021-March/078985.html

One-off, 2021-03-10

After removing all source files:

git -C /usr clone -o freebsd -b main https://git.freebsd.org/src.git src

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