6 OUTPUT=${IMAGE_DEFAULT}.bootable
12 echo "Available images:" 1>&2
14 ls *.img | cut -f1 -d. | tr '\n' ' ' 1>&2
20 echo "Usage: $0 [<options>] <image-name>" 1>&2
23 echo " --no-interactive in the generated media, during boot, do not prompt" 1>&2
24 echo " --output dir directory in which to create the structure" 1>&2
27 echo " <image-name> an image name, default $IMAGE_DEFAULT" 1>&2
38 IMAGE="$IMAGE_DEFAULT"
53 if [ "$#" != "1" ]; then
54 echo "Unknown option $1" 1>&2
58 if [ "${OUTPUT}" == "" ]; then
59 OUTPUT=${IMAGE}.bootable
67 if ! test -f ${IMAGE}.img; then
68 echo "*** No such image ${IMAGE}"
72 if ! test -d ${OUTPUT}; then
76 cp ${IMAGE}.{dat,crc,img} ${OUTPUT}
78 mkdir -p ${OUTPUT}/boot
80 # create essential header required by OpenFirmware
81 cat <<EOF >${OUTPUT}/boot/olpc.fth
85 ." This is a debxo bootable install script." cr
87 ." `md5sum ${IMAGE}.img`" cr
88 ." `md5sum ${IMAGE}.dat`" cr
89 ." `md5sum ${IMAGE}.crc`" cr
93 # create either an interactive or non-interactive section
96 cat <<EOF >>${OUTPUT}/boot/olpc.fth
98 \ --no-interactive was used, so we do not prompt
99 ." Erasing everything here and installing debxo ${IMAGE}" cr
103 cat <<EOF >>${OUTPUT}/boot/olpc.fth
105 \ --interactive was used, so we prompt before erasing
106 ." Power off to abort, or" cr
107 ." press Enter to erase everything here and install debxo ${IMAGE} ?"
115 cat <<EOF >>${OUTPUT}/boot/olpc.fth
120 \ erase the NAND flash and fill it with the image
121 update-nand u:\\${IMAGE}.img
123 \ boot from the NAND flash
124 boot n:\boot\olpc.fth
127 # TODO: avoid reflashing if already flashed