- Timestamp:
- Apr 26, 2012, 3:24:04 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/releng-9.0/nanobsd/tools/image
r10592 r10593 8 8 usage() { 9 9 cat <<EOF 10 # Usage $0 <arguments> "10 # Usage $0 <arguments> 11 11 # 12 12 # Wrapper around nanobsd.sh with autodetection of already processed steps to … … 25 25 } 26 26 27 FORCE_KERNEL=${FORCE_KERNEL:-"no"}28 FORCE_WORLD=${FORCE_WORLD:-"no"}29 27 30 if [ -z "$1" ]; then 31 usage; exit 1 32 elif [ "$1" = "build" ]; then 33 if [ -z "$2" ]; then 34 elif [ "$2" = "force" ]; then 35 if [ "$3" = "kernel" ]; then 36 FORCE_KERNEL="yes" 37 elif [ "$3" = "world" ]; then 38 FORCE_WORLD="yes" 39 else 40 echo "Argument Error - '$3'"; exit 128 41 fi 42 else 43 echo "Argument Error - '$2'"; exit 128 44 fi 45 elif [ "$1" = "rebuild" ]; then 46 FORCE_KERNEL="yes" 47 FORCE_WORLD="yes" 48 elif [ "$1" = "deploy" -a "$2" = "on" ]; then 49 if [ -z "$3" ]; then 50 echo "Argument Error - '$3'"; exit 128 51 fi 52 host=$3 53 do_reboot=false 54 if [ -n "$4" -o -n "$5" ]; then 55 if [ "$4" = "and" -a "$5" = "reboot" ]; then 56 do_reboot=true 57 else 58 echo "Argument Error - '$4 $5'"; exit 128 59 fi 60 fi 61 28 deploy_image() { 62 29 # Find object directory 63 30 img=${OBJDIR}/_.disk.image … … 76 43 ssh $host mount || exit 1 77 44 cat $img | ssh $host /tools/update || exit 1 78 if do_reboot; then45 if $do_reboot; then 79 46 ssh $host reboot 80 exit 081 47 fi 48 } 49 50 51 build_image() { 52 p_info Forcefully building kernel: $FORCE_KERNEL 53 p_info Forcefully building world : $FORCE_WORLD 54 55 NANOBSD_EXTRA=${NANOBSD_EXTRA:-''} 56 57 if [ ! -r "${NANOBSD}" ]; then 58 p_err ${NANOBSD} does not exists 59 exit 1 60 fi 61 62 if [ ! -x "${NANOBSD}" ]; then 63 NANOBSD="sh ${NANOBSD}" 64 fi 65 66 # Find object directory 67 OBJDIR="/usr/obj/nanobsd.${NANO_NAME}" 68 69 if [ -d "${OBJDIR}" ]; then 70 NANOBSD_FLAGS="" 71 72 # Detect succesfull buildworld 73 tail -10 ${OBJDIR}/_.bw | grep 'World build completed' 74 if [ $? -eq 0 -a ${FORCE_WORLD} = "no" ]; then 75 p_info NO building of world 76 NANOBSD_FLAGS="${NANOBSD_FLAGS} -w" 77 fi 78 79 # Detect succesfull buildkernel 80 tail -10 ${OBJDIR}/_.bk | grep 'Kernel build for .* completed' 81 if [ $? -eq 0 -a ${FORCE_KERNEL} = "no" ]; then 82 p_info NO building of kernel 83 NANOBSD_FLAGS="${NANOBSD_FLAGS} -k" 84 fi 85 86 else 87 p_warn Nothing yet, starting fresh 88 NANOBSD_FLAGS="" 89 fi 90 91 # Provide verbose output by default 92 COMMAND="${NANOBSD} ${NANOBSD_FLAGS} -c ${NANO_CFG_FILE} -v ${NANOBSD_EXTRA}" 93 f_time ${COMMAND} 94 RETVAL=$? 95 96 # Verify on build failures 97 tail -10 ${OBJDIR}/_.bw | grep 'World build completed' 98 if [ $? -eq 1 ]; then 99 p_err Building world FAILED, check ${OBJDIR}/_.bw 100 fi 101 tail -10 ${OBJDIR}/_.bk | grep 'Kernel build for .* completed' 102 if [ $? -eq 1 ]; then 103 p_err Building kernel FAILED, check ${OBJDIR}/_.bk 104 fi 105 if [ $RETVAL -ne 0 ]; then 106 p_err "Errors in building NanoBSD Image ($RETVAL)" 107 fi 108 p_info End time: `date` 109 exit ${RETVAL} 110 } 111 112 113 # 114 # Argument parsing 115 # 116 FORCE_KERNEL=${FORCE_KERNEL:-"no"} 117 FORCE_WORLD=${FORCE_WORLD:-"no"} 118 if [ -z "$1" ]; then 119 usage; exit 1 120 elif [ "$1" = "build" ]; then 121 if [ -z "$2" ]; then 122 elif [ "$2" = "force" ]; then 123 if [ "$3" = "kernel" ]; then 124 FORCE_KERNEL="yes" 125 elif [ "$3" = "world" ]; then 126 FORCE_WORLD="yes" 127 else 128 echo "Argument Error - '$3'"; exit 128 129 fi 130 else 131 echo "Argument Error - '$2'"; exit 128 132 fi 133 build_image 134 elif [ "$1" = "rebuild" ]; then 135 FORCE_KERNEL="yes" 136 FORCE_WORLD="yes" 137 build_image 138 elif [ "$1" = "deploy" -a "$2" = "on" ]; then 139 if [ -z "$3" ]; then 140 echo "Argument Error - '$3'"; exit 128 141 fi 142 host=$3 143 do_reboot=false 144 if [ -n "$4" -o -n "$5" ]; then 145 if [ "$4" = "and" -a "$5" = "reboot" ]; then 146 do_reboot=true 147 else 148 echo "Argument Error - '$4 $5'"; exit 128 149 fi 150 fi 151 deploy_image 82 152 else 83 153 echo "Argument Error - '$1'"; exit 128 84 154 fi 85 155 86 p_info Forcefully building kernel: $FORCE_KERNEL87 p_info Forcefully building world : $FORCE_WORLD88 89 NANOBSD_EXTRA=${NANOBSD_EXTRA:-''}90 91 if [ ! -r "${NANOBSD}" ]; then92 p_err ${NANOBSD} does not exists93 exit 194 fi95 96 if [ ! -x "${NANOBSD}" ]; then97 NANOBSD="sh ${NANOBSD}"98 fi99 100 # Find object directory101 OBJDIR="/usr/obj/nanobsd.${NANO_NAME}"102 103 if [ -d "${OBJDIR}" ]; then104 NANOBSD_FLAGS=""105 106 # Detect succesfull buildworld107 tail -10 ${OBJDIR}/_.bw | grep 'World build completed'108 if [ $? -eq 0 -a ${FORCE_WORLD} = "no" ]; then109 p_info NO building of world110 NANOBSD_FLAGS="${NANOBSD_FLAGS} -w"111 fi112 113 # Detect succesfull buildkernel114 tail -10 ${OBJDIR}/_.bk | grep 'Kernel build for .* completed'115 if [ $? -eq 0 -a ${FORCE_KERNEL} = "no" ]; then116 p_info NO building of kernel117 NANOBSD_FLAGS="${NANOBSD_FLAGS} -k"118 fi119 120 else121 p_warn Nothing yet, starting fresh122 NANOBSD_FLAGS=""123 fi124 125 # Provide verbose output by default126 COMMAND="${NANOBSD} ${NANOBSD_FLAGS} -c ${NANO_CFG_FILE} -v ${NANOBSD_EXTRA}"127 f_time ${COMMAND}128 RETVAL=$?129 130 # Verify on build failures131 tail -10 ${OBJDIR}/_.bw | grep 'World build completed'132 if [ $? -eq 1 ]; then133 p_err Building world FAILED, check ${OBJDIR}/_.bw134 fi135 tail -10 ${OBJDIR}/_.bk | grep 'Kernel build for .* completed'136 if [ $? -eq 1 ]; then137 p_err Building kernel FAILED, check ${OBJDIR}/_.bk138 fi139 if [ $RETVAL -ne 0 ]; then140 p_err "Errors in building NanoBSD Image ($RETVAL)"141 fi142 p_info End time: `date`143 exit ${RETVAL}
Note:
See TracChangeset
for help on using the changeset viewer.