Source updates on FreeBSD

best way to update freebsd is to grab source, build and install - bsd makes this task rather simple.

First you wanna grab the source - i recommend stable, which newest stable at this point is 12, stable on freebsd is almost bleeding edge, current is active dev.

Ive run current as a main driver for long chunks of time, it rarely breaks to an extreme, but expect some breaks if you are going that route.

Freebsd uses svn:

$svnlite co https://svn.FreeBSD.org/stable/12 /usr/src

default kernel it will build has debugging and such enabled, you probably dont want this - you can use. Also you should edit your /etc/src.conf

add this to /etc/src.conf

MALLOC_PRODUCTION=YES

replace amd64 with your own architecture

$cp /usr/src/sys/amd64/conf/GENERIC-NODEBUG /usr/src/sys/amd64/conf/CUSTOM
$echo "options LOCK_PROFILING" >> /usr/src/amd64/conf/CUSTOM

also optional open up and edit and change IDENT string in custom

then its as simple as

$cd /usr/src
$make -DMALLOC_PRODUCTION -j4 buildworld
$make -DMALLOC_PRODUCTION -j4 buildkernel KERNCONF=CUSTOM
$make -j4 installkernel KERNCONF=CUSTOM
$shutdown -r now

boot into single user mode(this assumes you are using zfs):

$zfs mount -a
$zfs set readonly=off zroot/ROOT/default
$cd /usr/src
$mergemaster -Fp
$make -j4 installworld
$mergemaster -Fi
$make check-old
$make delete-old
$make check-old-libs
$make delete-old-libs
$shutdown -r now

and thats it -

here are the scripts i use to stay upto date

mouse@mousestep ~ % cat /bin/update_build_base
#!/bin/sh
cd /usr/src
make cleanworld && make clean
svnlite up /usr/src

printf "check updating?"
read chkupdating
if [ $chkupdating == "y" ]; then
pico /usr/src/UPDATING
fi

printf "build world?"
read bworld
if [ $bworld == "y" ]; then
make -j4 -DMALLOC_PRODUCTION buildworld
fi

printf "build kernel?"
read bkernel
if [ $bkernel == "y" ]; then
make -j4 -DMALLOC_PRODUCTION buildkernel KERNCONF=CUSTOM
fi

printf "install kernel?"
read ikernel
if [ $ikernel == "y" ]; then
make -j4 installkernel KERNCONF=CUSTOM
fi
mouse@mousestep ~ % cat /bin/singlefix 
#!/bin/sh
zfs mount -a
zfs set readonly=off mouser/ROOT/default
mouse@mousestep ~ % cat /bin/finish 
#!/bin/sh
singlefix
cd /usr/src
mergemaster -Fp
make -j4 installworld
printf "install world succeded?"
read isuccess
if [ $isuccess == "y" ]; then
mergemaster -Fi
make check-old
make delete-old
make check-old-libs
make delete-old-libs
fi
printf "Reboot?"
read reboot
if [ $reboot == "y" ]; then
echo "ok bye bye. time for smoke test!"
shutdown -r now
fi