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