Compiling from Source

Everything’s in the FAQ - 5 Building the System from Source, these are corruptions of those fine notes I maintain for a localised interpretation.

Table of Contents
  1. Grab the Source
  2. Build the Kernel
  3. Build Userland
  4. Build Xenocara

Grab the Source

If you are maintaining multiple releases of OpenBSD, then the question you may need to consider is which version you are going to follow:

Where X_Y is the release version such as 4_2 3_5 or 5_0. In our environment, we use a central cvs, using cvsync and from this local repository distribute to the various build hosts.

for subdir in src ports xenocara; do cd /usr/${subdir}; cvs update -Pd & done

Prepping for Offline Distribution

If we want to release source in a distribution then we can use cvs for a special export such as:

USERNAME=samt HOSTNAME=fw DIRECTORY=/var/cvs SRCDISTRIB=/usr/src-distrib #SRCLIST=“ports src xenocara” SRCLIST=“ports” BUILDVER=“OPENBSD_4_4”

export CVSROOT=${USERNAME}@${HOSTNAME}:${DIRECTORY} mkdir -p ${SRCDISTRIB} cd ${SRCDISTRIB}

for SRC in ${SRCLIST}; do cvs -d${CVSROOT} -q export -r${BUILDVER} -d ${SRC} ${SRC}; done

Building the Kernel

#!/bin/sh ARCH=amd64

cd /usr/src/sys/arch/${ARCH}/conf config GENERIC cd ../compile/GENERIC make clean && make depend && make make install

Building Userland

#!/bin/sh
rm -rf /usr/obj/*
cd /usr/src
make obj
cd /usr/src/etc && env DESTDIR=/ make distrib-dirs
cd /usr/src
make build

Building a Release

For OpenBSD 4.4 and earlier

#!/bin/ksh
cd /usr/src/distrib/crunch && make obj depend all install

Rest of the Build Process

#!/bin/ksh
export DESTDIR=/usr/dest
export RELEASEDIR=/usr/rel

clear DESTDIR

test -d ${DESTDIR} && mv ${DESTDIR} ${DESTDIR}.old && rm -rf ${DESTDIR}.old & mkdir -p ${DESTDIR} ${RELEASEDIR}

make the release

cd /usr/src/etc make release

verify distribution set

cd /usr/src/distrib/sets sh checkflist

Xenocara

Build Userland

cd /usr/xenocara
rm -rf /usr/xobj/*
make bootstrap
make obj
make build

Make Release

export DESTDIR=/usr/xen-dest
export RELEASEDIR=/usr/xen-rel
test -d ${DESTDIR} && mv ${DESTDIR} ${DESTDIR}- && \
     rm -rf ${DESTDIR}- &
mkdir -p ${DESTDIR} ${RELEASEDIR}
make release

$!showsrc(“toolkit/build/mkopenbsd.sh”)!$