1 | #!/bin/sh
|
---|
2 | #
|
---|
3 | BASEDIR=`dirname $0`
|
---|
4 | . ${BASEDIR}/package-build.inc.sh
|
---|
5 |
|
---|
6 | NANOBSD="$NANO_SRC/tools/tools/nanobsd/nanobsd.sh"
|
---|
7 |
|
---|
8 | usage() {
|
---|
9 | cat <<EOF
|
---|
10 | # Usage $0 <arguments>"
|
---|
11 | #
|
---|
12 | # Wrapper around nanobsd.sh with autodetection of already processed steps to
|
---|
13 | # provide some failsafe net, which avoids building world and/or kernel by
|
---|
14 | # default.
|
---|
15 | #
|
---|
16 | # Rick van der Zwet <rick@wirelessleiden.nl>
|
---|
17 | #
|
---|
18 | # Arguments:
|
---|
19 | # build - Build NanoBSD parts which are not build yet
|
---|
20 | # build force kernel - Build NanoBSD and force rebuilding the kernel
|
---|
21 | # build force world - Build NanoBSD and force rebuilding world
|
---|
22 | # rebuild - Rebuild NanoBSD (aka force rebuilding all)
|
---|
23 | EOF
|
---|
24 | }
|
---|
25 |
|
---|
26 | FORCE_KERNEL=${FORCE_KERNEL:-"no"}
|
---|
27 | FORCE_WORLD=${FORCE_WORLD:-"no"}
|
---|
28 |
|
---|
29 | if [ -z "$1" ]; then
|
---|
30 | usage; exit 1
|
---|
31 | elif [ "$1" = "build" ]; then
|
---|
32 | if [ -z "$2" ]; then
|
---|
33 | elif [ "$2" = "force" ]; then
|
---|
34 | if [ "$3" = "kernel" ]; then
|
---|
35 | FORCE_KERNEL="yes"
|
---|
36 | elif [ "$3" = "world" ]; then
|
---|
37 | FORCE_WORLD="yes"
|
---|
38 | else
|
---|
39 | echo "Argument Error - '$3'"; exit 128
|
---|
40 | fi
|
---|
41 | else
|
---|
42 | echo "Argument Error - '$2'"; exit 128
|
---|
43 | fi
|
---|
44 | elif [ "$1" = "rebuild" ]; then
|
---|
45 | FORCE_KERNEL="yes"
|
---|
46 | FORCE_WORLD="yes"
|
---|
47 | else
|
---|
48 | echo "Argument Error - '$1'"; exit 128
|
---|
49 | fi
|
---|
50 |
|
---|
51 | p_info Forcefully building kernel: $FORCE_KERNEL
|
---|
52 | p_info Forcefully building world : $FORCE_WORLD
|
---|
53 |
|
---|
54 | NANOBSD_EXTRA=${NANOBSD_EXTRA:-''}
|
---|
55 |
|
---|
56 | if [ ! -r "${NANOBSD}" ]; then
|
---|
57 | p_err ${NANOBSD} does not exists
|
---|
58 | exit 1
|
---|
59 | fi
|
---|
60 |
|
---|
61 | if [ ! -x "${NANOBSD}" ]; then
|
---|
62 | NANOBSD="sh ${NANOBSD}"
|
---|
63 | fi
|
---|
64 |
|
---|
65 | # Find object directory
|
---|
66 | OBJDIR="/usr/obj/nanobsd.${NANO_NAME}"
|
---|
67 |
|
---|
68 | if [ -d "${OBJDIR}" ]; then
|
---|
69 | NANOBSD_FLAGS=""
|
---|
70 |
|
---|
71 | # Detect succesfull buildworld
|
---|
72 | tail -10 ${OBJDIR}/_.bw | grep 'World build completed'
|
---|
73 | if [ $? -eq 0 -a ${FORCE_WORLD} = "no" ]; then
|
---|
74 | p_info NO building of world
|
---|
75 | NANOBSD_FLAGS="${NANOBSD_FLAGS} -w"
|
---|
76 | fi
|
---|
77 |
|
---|
78 | # Detect succesfull buildkernel
|
---|
79 | tail -10 ${OBJDIR}/_.bk | grep 'Kernel build for .* completed'
|
---|
80 | if [ $? -eq 0 -a ${FORCE_KERNEL} = "no" ]; then
|
---|
81 | p_info NO building of kernel
|
---|
82 | NANOBSD_FLAGS="${NANOBSD_FLAGS} -k"
|
---|
83 | fi
|
---|
84 |
|
---|
85 | else
|
---|
86 | p_warn Nothing yet, starting fresh
|
---|
87 | NANOBSD_FLAGS=""
|
---|
88 | fi
|
---|
89 |
|
---|
90 | # Provide verbose output by default
|
---|
91 | COMMAND="${NANOBSD} ${NANOBSD_FLAGS} -c ${NANO_CFG_FILE} -v ${NANOBSD_EXTRA}"
|
---|
92 | f_time ${COMMAND}
|
---|
93 | RETVAL=$?
|
---|
94 |
|
---|
95 | # Verify on build failures
|
---|
96 | tail -10 ${OBJDIR}/_.bw | grep 'World build completed'
|
---|
97 | if [ $? -eq 1 ]; then
|
---|
98 | p_err Building world FAILED, check ${OBJDIR}/_.bw
|
---|
99 | fi
|
---|
100 | tail -10 ${OBJDIR}/_.bk | grep 'Kernel build for .* completed'
|
---|
101 | if [ $? -eq 1 ]; then
|
---|
102 | p_err Building kernel FAILED, check ${OBJDIR}/_.bk
|
---|
103 | fi
|
---|
104 | if [ $RETVAL -ne 0 ]; then
|
---|
105 | p_err "Errors in building NanoBSD Image ($RETVAL)"
|
---|
106 | fi
|
---|
107 | p_info End time: `date`
|
---|
108 | exit ${RETVAL}
|
---|