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