source: hybrid/branches/releng-9.0/nanobsd/tools/image@ 10591

Last change on this file since 10591 was 10591, checked in by rick, 13 years ago

I constantly type ./tools/image build force kernel so I guess this should be an more logical name.

  • Property svn:eol-style set to LF
  • Property svn:executable set to *
File size: 2.6 KB
Line 
1#!/bin/sh
2#
3BASEDIR=`dirname $0`
4. ${BASEDIR}/package-build.inc.sh
5
6NANOBSD="$NANO_SRC/tools/tools/nanobsd/nanobsd.sh"
7
8usage() {
9cat <<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)
23EOF
24}
25
26FORCE_KERNEL=${FORCE_KERNEL:-"no"}
27FORCE_WORLD=${FORCE_WORLD:-"no"}
28
29if [ -z "$1" ]; then
30 usage; exit 1
31elif [ "$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
44elif [ "$1" = "rebuild" ]; then
45 FORCE_KERNEL="yes"
46 FORCE_WORLD="yes"
47else
48 echo "Argument Error - '$1'"; exit 128
49fi
50
51p_info Forcefully building kernel: $FORCE_KERNEL
52p_info Forcefully building world : $FORCE_WORLD
53
54NANOBSD_EXTRA=${NANOBSD_EXTRA:-''}
55
56if [ ! -r "${NANOBSD}" ]; then
57 p_err ${NANOBSD} does not exists
58 exit 1
59fi
60
61if [ ! -x "${NANOBSD}" ]; then
62 NANOBSD="sh ${NANOBSD}"
63fi
64
65# Find object directory
66OBJDIR="/usr/obj/nanobsd.${NANO_NAME}"
67
68if [ -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
85else
86 p_warn Nothing yet, starting fresh
87 NANOBSD_FLAGS=""
88fi
89
90# Provide verbose output by default
91COMMAND="${NANOBSD} ${NANOBSD_FLAGS} -c ${NANO_CFG_FILE} -v ${NANOBSD_EXTRA}"
92f_time ${COMMAND}
93RETVAL=$?
94
95# Verify on build failures
96tail -10 ${OBJDIR}/_.bw | grep 'World build completed'
97if [ $? -eq 1 ]; then
98 p_err Building world FAILED, check ${OBJDIR}/_.bw
99fi
100tail -10 ${OBJDIR}/_.bk | grep 'Kernel build for .* completed'
101if [ $? -eq 1 ]; then
102 p_err Building kernel FAILED, check ${OBJDIR}/_.bk
103fi
104if [ $RETVAL -ne 0 ]; then
105 p_err "Errors in building NanoBSD Image ($RETVAL)"
106fi
107p_info End time: `date`
108exit ${RETVAL}
Note: See TracBrowser for help on using the repository browser.