| 1 | #!/bin/sh
|
---|
| 2 | # Wrapper around nanobsd.sh with autodetection of already processed steps
|
---|
| 3 | # to provide some failsafe net
|
---|
| 4 |
|
---|
| 5 | BASEDIR=`dirname $0`
|
---|
| 6 | . ${BASEDIR}/package-build.inc.sh
|
---|
| 7 |
|
---|
| 8 | NANOBSD="$NANO_SRC/tools/tools/nanobsd/nanobsd.sh"
|
---|
| 9 |
|
---|
| 10 | FORCE_KERNEL=0
|
---|
| 11 | FORCE_WORLD=0
|
---|
| 12 | #XXX: Proper object handling
|
---|
| 13 | if [ "$1" = "-bk" ]; then
|
---|
| 14 | p_warn Forcefully building kernel
|
---|
| 15 | FORCE_KERNEL=1
|
---|
| 16 | elif [ "$1" = "-bw" ]; then
|
---|
| 17 | p_warn Forcefully building world
|
---|
| 18 | FORCE_WORLD=1
|
---|
| 19 | elif [ "$1" = "-f" ]; then
|
---|
| 20 | p_warn Forcefully building world and kernel
|
---|
| 21 | FORCE_KERNEL=1
|
---|
| 22 | FORCE_WORLD=1
|
---|
| 23 | fi
|
---|
| 24 | shift
|
---|
| 25 | NANOBSD_EXTRA=$*
|
---|
| 26 |
|
---|
| 27 | if [ ! -r "${NANOBSD}" ]; then
|
---|
| 28 | p_err ${NANOBSD} does not exists
|
---|
| 29 | exit 1
|
---|
| 30 | fi
|
---|
| 31 |
|
---|
| 32 | if [ ! -x "${NANOBSD}" ]; then
|
---|
| 33 | NANOBSD="sh ${NANOBSD}"
|
---|
| 34 | fi
|
---|
| 35 |
|
---|
| 36 | # Find object directory
|
---|
| 37 | OBJDIR="/usr/obj/nanobsd.${NANO_NAME}"
|
---|
| 38 |
|
---|
| 39 | if [ -d "${OBJDIR}" ]; then
|
---|
| 40 | NANOBSD_FLAGS=""
|
---|
| 41 |
|
---|
| 42 | # Detect succesfull buildworld
|
---|
| 43 | tail -10 ${OBJDIR}/_.bw | grep 'World build completed'
|
---|
| 44 | if [ $? -eq 0 -a ${FORCE_WORLD} -eq 0 ]; then
|
---|
| 45 | p_info NO building of world, use $0 -f to force
|
---|
| 46 | NANOBSD_FLAGS="${NANOBSD_FLAGS} -w"
|
---|
| 47 | fi
|
---|
| 48 |
|
---|
| 49 | # Detect succesfull buildkernel
|
---|
| 50 | tail -10 ${OBJDIR}/_.bk | grep 'Kernel build for .* completed'
|
---|
| 51 | if [ $? -eq 0 -a ${FORCE_KERNEL} -eq 0 ]; then
|
---|
| 52 | p_info NO building of kernel, use $0 -f to force
|
---|
| 53 | NANOBSD_FLAGS="${NANOBSD_FLAGS} -k"
|
---|
| 54 | fi
|
---|
| 55 |
|
---|
| 56 | else
|
---|
| 57 | p_warn Nothing yet, starting fresh
|
---|
| 58 | NANOBSD_FLAGS=""
|
---|
| 59 | fi
|
---|
| 60 |
|
---|
| 61 | # Provide verbose output by default
|
---|
| 62 | COMMAND="${NANOBSD} ${NANOBSD_FLAGS} -c ${NANO_CFG_FILE} -v ${NANOBSD_EXTRA}"
|
---|
| 63 | f_time ${COMMAND}
|
---|
| 64 | RETVAL=$?
|
---|
| 65 |
|
---|
| 66 | # Verify on build failures
|
---|
| 67 | tail -10 ${OBJDIR}/_.bw | grep 'World build completed'
|
---|
| 68 | if [ $? -eq 1 ]; then
|
---|
| 69 | p_err Building world FAILED, check ${OBJDIR}/_.bw
|
---|
| 70 | fi
|
---|
| 71 | tail -10 ${OBJDIR}/_.bk | grep 'Kernel build for .* completed'
|
---|
| 72 | if [ $? -eq 1 ]; then
|
---|
| 73 | p_err Building kernel FAILED, check ${OBJDIR}/_.bk
|
---|
| 74 | fi
|
---|
| 75 | if [ $RETVAL -ne 0 ]; then
|
---|
| 76 | p_err "Errors in building NanoBSD Image ($RETVAL)"
|
---|
| 77 | fi
|
---|
| 78 | p_info End time: `date`
|
---|
| 79 | exit ${RETVAL}
|
---|