#!/bin/sh # BASEDIR=`dirname $0` . ${BASEDIR}/package-build.inc.sh NANOBSD="$NANO_SRC/tools/tools/nanobsd/nanobsd.sh" usage() { cat <" # # Wrapper around nanobsd.sh with autodetection of already processed steps to # provide some failsafe net, which avoids building world and/or kernel by # default. # # Rick van der Zwet # # Arguments: # build - Build NanoBSD parts which are not build yet # build force kernel - Build NanoBSD and force rebuilding the kernel # build force world - Build NanoBSD and force rebuilding world # rebuild - Rebuild NanoBSD (aka force rebuilding all) EOF } FORCE_KERNEL=${FORCE_KERNEL:-"no"} FORCE_WORLD=${FORCE_WORLD:-"no"} if [ -z "$1" ]; then usage; exit 1 elif [ "$1" = "build" ]; then if [ -z "$2" ]; then elif [ "$2" = "force" ]; then if [ "$3" = "kernel" ]; then FORCE_KERNEL="yes" elif [ "$3" = "world" ]; then FORCE_WORLD="yes" else echo "Argument Error - '$3'"; exit 128 fi else echo "Argument Error - '$2'"; exit 128 fi elif [ "$1" = "rebuild" ]; then FORCE_KERNEL="yes" FORCE_WORLD="yes" else echo "Argument Error - '$1'"; exit 128 fi p_info Forcefully building kernel: $FORCE_KERNEL p_info Forcefully building world : $FORCE_WORLD NANOBSD_EXTRA=${NANOBSD_EXTRA:-''} if [ ! -r "${NANOBSD}" ]; then p_err ${NANOBSD} does not exists exit 1 fi if [ ! -x "${NANOBSD}" ]; then NANOBSD="sh ${NANOBSD}" fi # Find object directory OBJDIR="/usr/obj/nanobsd.${NANO_NAME}" if [ -d "${OBJDIR}" ]; then NANOBSD_FLAGS="" # Detect succesfull buildworld tail -10 ${OBJDIR}/_.bw | grep 'World build completed' if [ $? -eq 0 -a ${FORCE_WORLD} = "no" ]; then p_info NO building of world NANOBSD_FLAGS="${NANOBSD_FLAGS} -w" fi # Detect succesfull buildkernel tail -10 ${OBJDIR}/_.bk | grep 'Kernel build for .* completed' if [ $? -eq 0 -a ${FORCE_KERNEL} = "no" ]; then p_info NO building of kernel NANOBSD_FLAGS="${NANOBSD_FLAGS} -k" fi else p_warn Nothing yet, starting fresh NANOBSD_FLAGS="" fi # Provide verbose output by default COMMAND="${NANOBSD} ${NANOBSD_FLAGS} -c ${NANO_CFG_FILE} -v ${NANOBSD_EXTRA}" f_time ${COMMAND} RETVAL=$? # Verify on build failures tail -10 ${OBJDIR}/_.bw | grep 'World build completed' if [ $? -eq 1 ]; then p_err Building world FAILED, check ${OBJDIR}/_.bw fi tail -10 ${OBJDIR}/_.bk | grep 'Kernel build for .* completed' if [ $? -eq 1 ]; then p_err Building kernel FAILED, check ${OBJDIR}/_.bk fi if [ $RETVAL -ne 0 ]; then p_err "Errors in building NanoBSD Image ($RETVAL)" fi p_info End time: `date` exit ${RETVAL}