3 # mkbootable.sh, make a bootable file set from a jffs2 image
4 # Copyright © 2008 James Cameron <quozl@laptop.org>
6 # This file is free software; you can redistribute it and/or modify it
7 # under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful, but
12 # WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 # Using an image produced by mkjffs2.sh,
22 # produces a tree of files suitable for erasing and loading an XO,
23 # typical usage is to mount USB storage and then populate the storage,
26 # mount /dev/sdz1 /mnt
27 # ./mkbootable --output /mnt gnome
34 OUTPUT=${IMAGE_DEFAULT}.bootable
40 echo "Available images:" 1>&2
42 ls *.img | cut -f1 -d. | tr '\n' ' ' 1>&2
48 echo "Usage: $0 [<options>] <image-name>" 1>&2
51 echo " --no-interactive in the generated media, during boot, do not prompt" 1>&2
52 echo " --output dir directory in which to create the structure" 1>&2
55 echo " <image-name> an image name, default $IMAGE_DEFAULT" 1>&2
66 IMAGE="$IMAGE_DEFAULT"
81 if [ "$#" != "1" ]; then
82 echo "Unknown option $1" 1>&2
86 if [ "${OUTPUT}" == "" ]; then
87 OUTPUT=${IMAGE}.bootable
95 if ! test -f ${IMAGE}.img; then
96 echo "*** No such image ${IMAGE}"
100 if ! test -d ${OUTPUT}; then
104 cp ${IMAGE}.{dat,crc,img} ${OUTPUT}
106 mkdir -p ${OUTPUT}/boot
108 # create essential header required by OpenFirmware
109 cat <<EOF >${OUTPUT}/boot/olpc.fth
113 ." This is a debxo bootable install script." cr
115 ." `md5sum ${IMAGE}.img`" cr
116 ." `md5sum ${IMAGE}.dat`" cr
117 ." `md5sum ${IMAGE}.crc`" cr
121 # create either an interactive or non-interactive section
124 cat <<EOF >>${OUTPUT}/boot/olpc.fth
126 \ --no-interactive was used, so we do not prompt
127 ." Erasing everything here and installing debxo ${IMAGE}" cr
131 cat <<EOF >>${OUTPUT}/boot/olpc.fth
133 \ --interactive was used, so we prompt before erasing
134 ." Power off to abort, or" cr
135 ." press Enter to erase everything here and install debxo ${IMAGE} ?"
143 cat <<EOF >>${OUTPUT}/boot/olpc.fth
148 \ erase the NAND flash and fill it with the image
149 \ boot from the NAND flash
151 " update-nand u:\\${IMAGE}.img" evaluate
152 " boot n:\boot\olpc.fth" evaluate
158 # TODO: avoid reflashing if already flashed