Making your own release with FreeBSD

Check out the source you want, eg
cd /usr
cvs -d /home/ncvs co -rRELENG_6_2 src
    
Apply the patches and things.. You will need to apply this patch to teach 'make release' about copying the source files rather than using checkout.

Delete the .orig files generate by the patches..

find /usr/src -name \*.orig -delete
    
Do a buildworld...
/usr/bin/time sh -c 'make -j 2 buildworld' |& tee /tmp/buildworld.log
    
Mount the ports tree you want distributed on /usr/ports, eg
sudo mount -o soft,intr cain:/usr/ports /usr/ports
    
or copy it instead..
mkdir /usr/ports
cd /usr/ports
tar -C /mnt/ports -cf - --exclude ./distfiles/\* . --exclude \*/\*/work | tar xvf -
    
Check out the doc tree (if you don't want it and NODOC= to the make release line). Note the tag is different to the src tag.
cd /usr
cvs -d /usr/home/ncvs co -rRELEASE_6_2 doc
Cook the release!
sudo make release CHROOTDIR=/tmp/6.2-release BUILDNAME=6.2-GENESIS CVSROOT=/home/ncvs HTTP_PROXY=http://proxy:3128 FTP_PROXY=http://proxy:3128 EXTSRCDIR=/usr/src EXTPORTSDIR=/usr/ports WORLD_FLAGS=-j4 KERNEL_FLAGS=-j4 NOPORTS=YES |& tee /tmp/release.log
    
This will take a [long] while. While it is building you can create a chroot to install things into that will later be splatted onto the hard disk.
rm -rf /tmp/6.2-ports
cd /usr/src
make installworld DESTDIR=/tmp/6.2-ports
cd etc
make distribution DESTDIR=/tmp/6.2-ports
cp /etc/resolv.conf /tmp/6.2-ports/etc/resolv.conf

cat << EOF >/tmp/6.2-ports/pkg-root/etc/make.conf
WRKDIRPREFIX=/tmp/work
EOF

mkdir /tmp/6.2-ports/usr/ports
mount_nullfs /usr/ports /tmp/6.2-ports/usr/ports
Now actually enter the chroot and build the ports you require. This method also allows you to modify things just how you need them.
chroot /tmp/6.2-ports /bin/csh
ldconfig /usr/lib
cd /usr/ports
cd x/y ; make install
...
Once that is done you need to tar up the directory, execute the following commands (outside the chroot)
cat >/tmp/exclusions <<EOF
etc/dhclient.conf
etc/rc.conf
etc/ssh/ssh_host_*
etc/fstab
usr/ports/*
var/tmp
usr/tmp
tmp
dev/*
proc/*
compat/linux/proc/*
EOF

tar -X /tmp/exclusions -ycvf - * .??* | split -b1024m - /tmp/image.tar.bz2.
You may also wish to copy the doc distribution off a recent CD if it wasn't built, like so
mount /cdrom
cp /cdrom/doc/* /tmp/6.2-release/release/R/cdrom/disc1/doc/
You will be able to create an iso which is bootable and has all of the packages easily installable. Note that it would be good to make a tar of the ports tree and run and update the md5 checksum in the CD staging area. Finally, to make the iso..
mkisofs -A "Genesis Software OS Installer" -P "Genesis Software +618
82673493" -V "FreeBSD" -b floppies/boot.flp -c floppies/boot.catalog -J -r -T -o /tmp/6.2-GENESIS.iso /tmp/6.2-release/release/R/cdrom/disc1 /tmp/image.tar.bz2.*
A handy thing to have is a sysinstall install script which installs all of your custom packages and picks what distributions you want etc etc.. I have one here which is in the middle of being hacked on.
Daniel O'Connor
Last modified: Mon Apr 2 11:55:28 CST 2007