Ignore:
Timestamp:
Apr 22, 2012, 12:54:37 PM (13 years ago)
Author:
rick
Message:

New style arguments, properly going to merge all image related actions in this
single script.

File:
1 copied

Legend:

Unmodified
Added
Removed
  • branches/releng-9.0/nanobsd/tools/image.sh

    r10532 r10548  
    11#!/bin/sh
    2 # Wrapper around nanobsd.sh with autodetection of already processed steps
    3 # to provide some failsafe net
    4 
     2#
    53BASEDIR=`dirname $0`
    64. ${BASEDIR}/package-build.inc.sh
     
    86NANOBSD="$NANO_SRC/tools/tools/nanobsd/nanobsd.sh"
    97
    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
     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
    2349fi
    24 shift
    25 NANOBSD_EXTRA=$*
     50
     51p_info Forcefully building kernel: $FORCE_KERNEL
     52p_info Forcefully building world : $FORCE_WORLD
     53
     54NANOBSD_EXTRA=${NANOBSD_EXTRA:-''}
    2655
    2756if [ ! -r "${NANOBSD}" ]; then
     
    4271  # Detect succesfull buildworld
    4372  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
     73  if [ $? -eq 0 -a ${FORCE_WORLD} = "no" ]; then
     74     p_info NO building of world
    4675     NANOBSD_FLAGS="${NANOBSD_FLAGS} -w"
    4776  fi 
     
    4978  # Detect succesfull buildkernel
    5079  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
     80  if [ $? -eq 0 -a ${FORCE_KERNEL} = "no" ]; then
     81     p_info NO building of kernel
    5382     NANOBSD_FLAGS="${NANOBSD_FLAGS} -k"
    5483  fi 
Note: See TracChangeset for help on using the changeset viewer.