Skip to content

Instantly share code, notes, and snippets.

@tuxillo
Created April 25, 2013 09:04
Show Gist options
  • Select an option

  • Save tuxillo/5458486 to your computer and use it in GitHub Desktop.

Select an option

Save tuxillo/5458486 to your computer and use it in GitHub Desktop.
#! /bin/sh
#set -x
REPOSITORY=/home/source/dfbsd
ARCH=""
NCPU=`sysctl hw.ncpu | cut -w -f 2`
usage()
{
echo `basename $0`: '[buildkernel|quickkernel|nativekernel]'
echo 'Make sure you set VKDIR environment variable to your VKERNEL path'
exit
}
do_build()
{
local _ret
local buildmode=$1
local arch=$2
cd ${REPOSITORY}
/bin/sh -c "env COPTFLAGS=\"-g -O0\" make -j${NCPU} ${buildmode} -DNO_MODULES KERNCONF=VKERNEL${arch} > /tmp/buildkernel_${ACTION}.log 2>&1"
if [ $? -ne 0 ]; then
echo Failed to build, please check /tmp/buildkernel_${ACTION}.log
exit 1
else
echo " + Installing vkernel into ${VKDIR}"
/usr/pkg/bin/sudo sh -c "make installkernel DESTDIR=${VKDIR} -DNO_MODULES KERNCONF=VKERNEL${arch}" > /tmp/buildkernel_${ACTION}.log2 >&1
fi
}
get_arch()
{
if [ "`uname -m`" = "i386" ]; then
ARCH=""
else
ARCH="64"
fi
}
# ---------------------------------------------------------------
get_arch
ACTION="$1"
if [ $# -ne 1 ]; then
usage
fi
if [ "${VKDIR}" = "" ]; then
usage
fi
if [ ! -d ${VKDIR} ]; then
echo ${VKDIR} directory does not exist.
exit
fi
case $1 in
'buildkernel'|'quickkernel'|'nativekernel')
echo --- Action: ${ACTION} config file: VKERNEL${ARCH}
do_build ${ACTION} ${ARCH}
;;
*)
usage
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment