3 # Builds custom BootCD ISO and USB images in the current
6 # Aaron Klingaman <alk@absarokasoft.com>
7 # Mark Huang <mlhuang@cs.princeton.edu>
8 # Copyright (C) 2004-2007 The Trustees of Princeton University
10 # Jan 2015 - f21 comes with isolinux 6.03 (was 4.05 in f20)
11 # http://www.syslinux.org/wiki/index.php/ISOLINUX
13 COMMAND=$(basename $0)
15 PATH=/sbin:/bin:/usr/sbin:/usr/bin
18 # keep KERNEL_DEBUG_ARGS void for production
20 # and uncomment these to augment verbosity of boot phase
21 # not everything works or is helpful, but well
22 #KERNEL_DEBUG_ARGS="$KERNEL_DEBUG_ARGS debuginitrd showerr"
23 #KERNEL_DEBUG_ARGS="$KERNEL_DEBUG_ARGS earlyprintk=vga loglevel=6"
24 # for systemd - might slow down boot
25 #KERNEL_DEBUG_ARGS="$KERNEL_DEBUG_ARGS systemd.log_level=debug systemd.journald.forward_to_console=1"
29 DEFAULT_TYPES="usb iso"
30 # Leave 4 MB of free space
31 GRAPHIC_CONSOLE="graphic"
32 SERIAL_CONSOLE="ttyS0:115200:n:8"
33 CONSOLE_INFO=$GRAPHIC_CONSOLE
34 MKISOFS_OPTS="-R -J -r -f -b isolinux.bin -c boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table"
35 # isolinux-debug.bin is supposedly helpful as well if available,
36 # when things don't work as expected
37 #MKISOFS_OPTS="-R -J -r -f -b isolinux-debug.bin -c boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table"
41 # command-line settable args
42 NODE_CONFIGURATION_FILE=
52 FULL_VERSION_STRING=""
60 console_serial_line=""
63 #################### compute all supported types
64 # removing support for serial in the type
65 # this is because kargs.txt goes in the overlay, that is computed only once
66 # so we cannot handle serial and graphic modes within the same invokation of this script
69 for x in iso usb usb_partition; do for c in "" "_cramfs" ; do
76 ALL_TYPES="$ALL_TYPES $t" ;;
80 #################### cleanup utilities
81 declare -a _CLEANUPS=()
82 function do_cleanup() {
83 cd / ; for i in "${_CLEANUPS[@]}"; do $i ; done
85 function push_cleanup() {
86 _CLEANUPS=( "${_CLEANUPS[@]}" "$*" )
88 function pop_cleanup() {
89 unset _CLEANUPS[$((${#_CLEANUPS[@]} - 1))]
92 #################### initialization
93 function init_and_check () {
95 # Change to our source directory
96 local srcdir=$(cd $DIRNAME && pwd -P)
100 ISOREF=$PWD/${VARIANT}
102 # The reference image is expected to have been built by prep.sh (see .spec)
103 # we disable the initial logic that called prep.sh if that was not the case
104 # this is because prep.sh needs to know pldistro
105 if [ ! -f $ISOREF/isofs/bootcd.img -o ! -f $ISOREF/version.txt ] ; then
106 echo "Could not find isofs and version.txt in $ISOREF"
107 if [ "$VARIANT" == "build" ] ; then
108 echo "You have to run prep.sh prior to calling $COMMAND"
110 echo "You need to create your variant image, see kvariant.sh"
116 # build/version.txt written by prep.sh
117 BOOTCD_VERSION=$(cat ${VARIANT}/version.txt)
119 if [ -f /etc/planetlab/plc_config ] ; then
120 # Source PLC configuration
121 . /etc/planetlab/plc_config
124 # use /var/tmp that should be large enough on both chroot- or vserver-based myplc
127 FULL_VERSION_STRING="${PLC_NAME} BootCD ${BOOTCD_VERSION}"
132 # the custom-dir feature is designed to let a myplc try/ship a patched bootcd
133 # without the need for a full devel environment
134 # for example, you would create /root/custom-bootcd/etc/rc.d/init.d/pl_hwinit
135 # and run this script with -C /root/custom-bootcd
136 # this creates a third .img image of the custom dir, that 'hides' the files from
137 # bootcd.img in the resulting unionfs
138 # it seems that this feature has not been used nor tested in a long time, use with care
141 echo "Usage: $COMMAND [OPTION]..."
142 echo " -f plnode.txt Node to customize CD for (default: none)"
143 echo " -t 'types' Build the specified images (default: $DEFAULT_TYPES)"
144 echo " NOTE: mentioning 'serial' as part of the type is not supported anymore"
145 echo " -a Build all known types as listed below"
146 echo " -s console-info Enable a serial line as console and also bring up getty on that line"
147 echo " console-info: tty:baud-rate:parity:bits"
148 echo " or 'default' shortcut for $SERIAL_CONSOLE"
149 echo " -S equivalent to -s default"
150 echo " -O output-base The prefix of the generated files (default: PLC_NAME-BootCD-VERSION)"
151 echo " useful when multiple types are provided"
152 echo " can be a full path"
153 echo " -o output-name The full name of the generated file"
154 echo " -C custom-dir Custom directory"
155 echo " -V variant Use a variant - see kvariant.sh"
156 echo " -n Dry run - mostly for debug/test purposes"
157 echo " -k Add additional parameters to the kargs.txt file"
158 echo " -h This message"
159 echo "All known types: $ALL_TYPES"
164 function parse_command_line () {
169 while getopts "f:t:as:SO:o:C:V:k:nh" opt ; do
171 f) NODE_CONFIGURATION_FILE=$OPTARG ;;
172 t) TYPES="$TYPES $OPTARG" ;;
173 a) TYPES="$ALL_TYPES" ;;
174 s) CONSOLE_INFO="$OPTARG" ;;
175 S) CONSOLE_INFO=$SERIAL_CONSOLE ;;
176 O) OUTPUT_BASE="$OPTARG" ;;
177 o) OUTPUT_NAME="$OPTARG" ;;
178 C) CUSTOM_DIR="$OPTARG" ;;
179 V) VARIANT="$OPTARG" ;;
180 k) KERNEL_ARGS="$KERNEL_ARGS $OPTARG" ;;
186 # use defaults if not set
187 [ -z "$TYPES" ] && TYPES="$DEFAULT_TYPES"
188 [ -z "$VARIANT" ] && VARIANT="build"
189 [ "$CONSOLE_INFO" == "default" ] && CONSOLE_INFO=$SERIAL_CONSOLE
191 if [ -n "$NODE_CONFIGURATION_FILE" ] ; then
192 # check existence of NODE_CONFIGURATION_FILE and normalize as we will change directory
193 if [ ! -f "$NODE_CONFIGURATION_FILE" ] ; then
194 echo "Node configuration file $NODE_CONFIGURATION_FILE not found - exiting"
197 cf_dir="$(dirname $NODE_CONFIGURATION_FILE)"
198 cf_dir="$(cd $cf_dir; pwd -P)"
199 cf_file="$(basename $NODE_CONFIGURATION_FILE)"
200 NODE_CONFIGURATION_FILE="$cf_dir"/"$cf_file"
204 local matcher="XXX$(echo $ALL_TYPES | sed -e 's,\W,XXX,g')XXX"
206 echo Checking type $t
207 echo $matcher | grep XXX${t}XXX &> /dev/null
208 if [ "$?" != 0 ] ; then
217 function init_serial () {
218 local console=$1; shift
219 if [ "$console" == "$GRAPHIC_CONSOLE" ] ; then
222 echo "Standard, graphic, non-serial mode"
225 console_dev=$(echo "$console" | awk -F: ' {print $1}')
226 console_baud=$(echo "$console" | awk -F: ' {print $2}')
227 [ -z "$console_baud" ] && console_baud="115200"
228 local console_parity=$(echo "$console" | awk -F: ' {print $3}')
229 [ -z "$console_parity" ] && console_parity="n"
230 local console_bits=$(echo "$console" | awk -F: ' {print $4}')
231 [ -z "$console_bits" ] && console_bits="8"
232 console_spec="console=${console_dev},${console_baud}${console_parity}${console_bits}"
233 local tty_nb=$(echo $console_dev | sed -e 's,[a-zA-Z],,g')
234 console_serial_line="SERIAL ${tty_nb} ${console_baud}"
236 echo "console_serial_line=${console_serial_line}"
237 echo "console_spec=${console_spec}"
241 #################### run once : build the overlay image
242 function build_overlay () {
244 BUILDTMP=$(mktemp -d ${BUILDTMP}/bootcd.XXXXXX)
245 push_cleanup rm -fr "${BUILDTMP}"
248 ISOFS="${BUILDTMP}/isofs"
250 for i in "$ISOREF"/isofs/{bootcd.img,kernel}; do
253 # use new location as of fedora 12
254 # used to be in /usr/lib/syslinux/isolinux.bin
255 # removed backward compat in jan. 2015
256 # as of syslinux 6.05 (fedora 21) ldlinux.c32 is required by isolinux.bin
257 # the debug version can come in handy at times, and is 40k as well
258 isolinuxdir="/usr/share/syslinux"
259 isolinuxfiles="isolinux.bin ldlinux.c32 isolinux-debug.bin memdisk"
260 for isolinuxfile in $isolinuxfiles; do
261 [ -f $isolinuxdir/$isolinuxfile ] && cp $isolinuxdir/$isolinuxfile "${BUILDTMP}/isofs"
264 # Root of the ISO and USB images
265 echo "* Populating root filesystem..."
266 OVERLAY="${BUILDTMP}/overlay"
267 install -d -m 755 $OVERLAY
268 push_cleanup rm -fr $OVERLAY
270 # Create version files
271 echo "* Creating version files"
273 # Boot Manager compares pl_version in both places to make sure that
274 # the right CD is mounted. We used to boot from an initrd and mount
275 # the CD on /usr. Now we just run everything out of the initrd.
276 for file in $OVERLAY/pl_version $OVERLAY/usr/isolinux/pl_version ; do
277 mkdir -p $(dirname $file)
278 echo "$FULL_VERSION_STRING" >$file
281 # Install boot server configuration files
282 echo "* Installing boot server configuration files"
284 # We always intended to bring up and support backup boot servers,
285 # but never got around to it. Just install the same parameters for
287 for dir in $OVERLAY/usr/boot $OVERLAY/usr/boot/backup ; do
288 install -D -m 644 $PLC_BOOT_CA_SSL_CRT $dir/cacert.pem
289 install -D -m 644 $PLC_ROOT_GPG_KEY_PUB $dir/pubring.gpg
290 echo "$PLC_BOOT_HOST" >$dir/boot_server
291 echo "$PLC_BOOT_SSL_PORT" >$dir/boot_server_port
292 echo "/boot/" >$dir/boot_server_path
295 # Install old-style boot server configuration files
296 # as opposed to what a former comment suggested,
297 # this is still required, somewhere in the bootmanager apparently
298 install -D -m 644 $PLC_BOOT_CA_SSL_CRT $OVERLAY/usr/bootme/cacert/$PLC_BOOT_HOST/cacert.pem
299 echo "$FULL_VERSION_STRING" >$OVERLAY/usr/bootme/ID
300 echo "$PLC_BOOT_HOST" >$OVERLAY/usr/bootme/BOOTSERVER
301 echo "$PLC_BOOT_HOST" >$OVERLAY/usr/bootme/BOOTSERVER_IP
302 echo "$PLC_BOOT_SSL_PORT" >$OVERLAY/usr/bootme/BOOTPORT
304 # Generate /etc/issue
305 echo "* Generating /etc/issue"
307 if [ "$PLC_WWW_PORT" = "443" ] ; then
308 PLC_WWW_URL="https://$PLC_WWW_HOST/"
309 elif [ "$PLC_WWW_PORT" != "80" ] ; then
310 PLC_WWW_URL="http://$PLC_WWW_HOST:$PLC_WWW_PORT/"
312 PLC_WWW_URL="http://$PLC_WWW_HOST/"
315 mkdir -p $OVERLAY/etc
316 cat >$OVERLAY/etc/issue <<EOF
322 This machine is a node in the $PLC_NAME distributed network. It has
323 not fully booted yet. If you have cancelled the boot process at the
324 request of $PLC_NAME Support, please follow the instructions provided
325 to you. Otherwise, please contact $PLC_MAIL_SUPPORT_ADDRESS.
327 Console login at this point is restricted to root. Provide the root
328 password of the default $PLC_NAME Central administrator account at the
329 time that this CD was created.
334 echo "* Setting root password"
336 if [ -z "$ROOT_PASSWORD" ] ; then
337 # Generate an encrypted password with crypt() if not defined
338 # in a static configuration.
339 ROOT_PASSWORD=$(python <<EOF
340 import crypt, random, string
341 salt = [random.choice(string.letters + string.digits + "./") for i in range(0,8)]
342 print crypt.crypt('$PLC_ROOT_PASSWORD', '\$1\$' + "".join(salt) + '\$')
347 # build/passwd copied out by prep.sh
348 sed -e "s@^root:[^:]*:\(.*\)@root:$ROOT_PASSWORD:\1@" ${VARIANT}/passwd >$OVERLAY/etc/passwd
350 # Install node configuration file (e.g., if node has no floppy disk or USB slot)
351 if [ -f "$NODE_CONFIGURATION_FILE" ] ; then
352 echo "* Installing node configuration file $NODE_CONFIGURATION_FILE -> /usr/boot/plnode.txt of the bootcd image"
353 install -D -m 644 $NODE_CONFIGURATION_FILE $OVERLAY/usr/boot/plnode.txt
354 NODE_ID=$(source $NODE_CONFIGURATION_FILE; echo $NODE_ID)
355 echo "* Building network configuration for $NODE_ID"
356 plnet -- --root $OVERLAY --files-only --program BootCD $NODE_ID
359 [ -n "$IS_SERIAL" ] && KERNEL_ARGS="$KERNEL_ARGS ${console_spec}"
361 # tmp: should be restricted to f15 nodes and above
362 # making sure the network interfaces are still numbered eth0 and above
363 KERNEL_ARGS="$KERNEL_ARGS biosdevname=0"
364 # making sure selinux is turned off - somehow this is needed with lxc/f14
365 KERNEL_ARGS="$KERNEL_ARGS selinux=0"
366 # output more systemd-related messages on the serial line so it gets with log.txt
367 KERNEL_ARGS="$KERNEL_ARGS systemd.log_target=console systemd.log_level=debug console=ttyS0,115200"
368 # add any debug flag if any (defined in the header of this script)
369 KERNEL_ARGS="$KERNEL_ARGS $KERNEL_DEBUG_ARGS"
370 # propagate kernel args for later boot stages
371 [ -n "$KERNEL_ARGS" ] && echo "$KERNEL_ARGS" > $OVERLAY/kargs.txt
373 # Pack overlay files into a compressed archive
374 echo "* Compressing overlay image"
375 (cd $OVERLAY && find . | cpio --quiet -c -o) | gzip -9 >$ISOFS/overlay.img
380 if [ -n "$CUSTOM_DIR" ]; then
381 echo "* Compressing custom image"
382 (cd "$CUSTOM_DIR" && find . | cpio --quiet -c -o) | gzip -9 >$ISOFS/custom.img
385 # Calculate ramdisk size (total uncompressed size of both archives)
386 ramdisk_size=$(gzip -l $ISOFS/bootcd.img $ISOFS/overlay.img ${CUSTOM_DIR:+$ISOFS/custom.img} | tail -1 | awk '{ print $2; }') # bytes
387 ramdisk_size=$((($ramdisk_size + 1023) / 1024)) # kilobytes
389 echo "$FULL_VERSION_STRING" >$ISOFS/pl_version
394 #################### plain ISO
395 function build_iso() {
396 local iso="$1" ; shift
399 # Write isolinux configuration
400 cat >$ISOFS/isolinux.cfg <<EOF
401 ${console_serial_line}
403 DEFAULT planetlab-bootcd
405 LABEL planetlab-bootcd
408 APPEND ramdisk_size=$ramdisk_size initrd=bootcd.img,overlay.img${custom:+,custom.img} root=/dev/ram0 rw ${KERNEL_ARGS}
412 echo "* Creating ISO image in $(pwd)"
413 mkisofs -o "$iso" $MKISOFS_OPTS $ISOFS
416 #################### USB with partitions
417 function build_usb_partition() {
418 echo -n "* Creating USB image with partitions..."
419 local usb="$1" ; shift
422 local size=$(($(du -Lsk $ISOFS | awk '{ print $1; }') + $FREE_SPACE))
423 size=$(( $size / 1024 ))
427 local cylinders=$(( ($size*1024*2)/($heads*$sectors) ))
428 local offset=$(( $sectors*512 ))
430 if [ -f /usr/lib/syslinux/mkdiskimage ] ; then
431 /usr/lib/syslinux/mkdiskimage -M -4 "$usb" $size $heads $sectors
433 mkdiskimage -M -4 "$usb" $size $heads $sectors
436 cat >${BUILDTMP}/mtools.conf<<EOF
446 # environment variable for mtools
447 export MTOOLSRC="${BUILDTMP}/mtools.conf"
449 ### COPIED FROM build_usb() below!!!!
450 echo -n " populating USB image... "
451 mcopy -bsQ -i "$usb" "$ISOFS"/* z:/
453 # Use syslinux instead of isolinux to make the image bootable
454 tmp="${BUILDTMP}/syslinux.cfg"
456 ${console_serial_line}
458 DEFAULT planetlab-bootcd
460 LABEL planetlab-bootcd
463 APPEND ramdisk_size=$ramdisk_size initrd=bootcd.img,overlay.img${custom:+,custom.img} root=/dev/ram0 rw ${KERNEL_ARGS}
465 mdel -i "$usb" z:/isolinux.cfg 2>/dev/null || :
466 mcopy -i "$usb" "$tmp" z:/syslinux.cfg
471 echo "making USB image bootable."
472 syslinux -o $offset "$usb"
476 #################### plain USB
477 function build_usb() {
478 echo -n "* Creating USB image... "
479 local usb="$1" ; shift
483 mkfs.vfat -C "$usb" $(($(du -Lsk $ISOFS | awk '{ print $1; }') + $FREE_SPACE))
485 cat >${BUILDTMP}/mtools.conf<<EOF
488 # environment variable for mtools
489 export MTOOLSRC="${BUILDTMP}/mtools.conf"
492 echo -n " populating USB image... "
493 mcopy -bsQ -i "$usb" "$ISOFS"/* ::/
495 # Use syslinux instead of isolinux to make the image bootable
496 tmp="${BUILDTMP}/syslinux.cfg"
498 ${console_serial_line}
500 DEFAULT planetlab-bootcd
502 LABEL planetlab-bootcd
505 APPEND ramdisk_size=$ramdisk_size initrd=bootcd.img,overlay.img${custom:+,custom.img} root=/dev/ram0 rw ${KERNEL_ARGS}
507 mdel -i "$usb" ::/isolinux.cfg 2>/dev/null || :
508 mcopy -i "$usb" "$tmp" ::/syslinux.cfg
513 echo "making USB image bootable."
517 #################### utility to setup CRAMFS related support
518 function prepare_cramfs() {
519 [ -n "$CRAMFS_PREPARED" ] && return 0
522 echo "* Setting up CRAMFS-based images"
523 local tmp="${BUILDTMP}/cramfs-tree"
525 push_cleanup rm -rf $tmp
527 gzip -d -c $ISOFS/bootcd.img | cpio -diu
528 gzip -d -c $ISOFS/overlay.img | cpio -diu
529 [ -n "$custom" ] && \
530 gzip -d -c $ISOFS/custom.img | cpio -diu
532 # clean out unnecessary rpm lib
533 echo "* clearing var/lib/rpm/*"
536 # bootcd requires this directory
537 mkdir -p mnt/confdevice
539 # relocate various directory to /tmp
541 ln -fs /tmp/root root
542 ln -fs /sbin/init linuxrc
543 ln -fs /tmp/resolv.conf etc/resolv.conf
544 ln -fs /tmp/etc/mtab etc/mtab
546 # have pl_rsysinit copy over appropriate etc & var directories into /tmp/etc/
548 echo "* renaming dirs in ./etc"
550 for dir in `find * -type d -prune | grep -v rc.d`; do
552 ln -fs /tmp/etc/${dir} ${dir}
556 echo "* renaming dirs in ./var"
557 # rename all top-level directories and put in a symlink to /tmp/var
559 for dir in `find * -type d -prune`; do
561 ln -fs /tmp/var/${dir} ${dir}
565 # overwrite fstab to mount / as cramfs and /tmp as tmpfs
566 echo "* Overwriting etc/fstab to use cramfs and tmpfs"
568 cat >./etc/fstab <<EOF
569 /dev/ram0 / cramfs ro 0 0
570 none /dev/pts devpts gid=5,mode=620 0 0
571 none /proc proc defaults 0 0
572 none /sys sysfs defaults 0 0
578 #for i in 0 1 2 3 4 5 6 7 8; do rm -f ram${i} ; done
579 #for i in 0 1 2 3 4 5 6 7 8; do mknod ram${i} b 1 ${i} ; done
584 # update etc/inittab to start with pl_rsysinit
585 for file in etc/inittab etc/event.d/rcS etc/init/rcS.conf; do
586 [ -f $file ] && sed -i 's,pl_sysinit,pl_rsysinit,' $file
589 # modify inittab to have a serial console
590 # xxx this might well be broken with f12 and above xxx
591 if [ -n "$serial" ] ; then
592 echo "T0:23:respawn:/sbin/agetty -L $console_dev $console_baud vt100" >> etc/inittab
593 # and let root log in
594 echo "$console_dev" >> etc/securetty
597 # calculate the size of /tmp based on the size of /etc & /var + 8MB slack
598 etcsize=$(du -s ./etc | awk '{ print $1 }')
599 varsize=$(du -s ./var | awk '{ print $1 }')
600 let msize=($varsize+$etcsize+8192)/1024
602 # make dhclient happy
603 for i in $(seq 0 9); do ln -fs /tmp/etc/dhclient-eth${i}.conf etc/dhclient-eth${i}.conf ; done
604 ln -fs /tmp/etc/resolv.conf etc/resolv.conf
605 ln -fs /tmp/etc/resolv.conf.predhclient etc/resolv.conf.predhclient
607 # generate pl_rsysinit
608 cat > etc/rc.d/init.d/pl_rsysinit <<EOF
610 # generated by $COMMAND
611 echo -n "pl_rsysinit: preparing /etc and /var for pl_sysinit..."
612 mount -t tmpfs -orw,size=${msize}M,mode=1777 tmpfs /tmp
615 touch /tmp/etc/resolv.conf
620 echo "tmpfs /tmp tmpfs rw,size=${msize}M,mode=1777 1 1" > /tmp/etc/mtab
622 # copy over directory contents of all _o directories from /etc and /var
623 # /tmp/etc and /tmp/var
625 for odir in \$(cd /etc && ls -d *_o); do dir=\$(echo \$odir | sed 's,\_o$,,'); (mkdir -p /tmp/etc/\$dir && cd \$odir && find . | cpio -p -d -u /tmp/etc/\$dir); done
628 for odir in \$(cd /var && ls -d *_o); do dir=\$(echo \$odir | sed 's,\_o$,,'); (mkdir -p /tmp/var/\$dir && cd \$odir && find . | cpio -p -d -u /tmp/var/\$dir); done
633 # hand over to pl_sysinit
634 echo "pl_rsysinit: handing over to pl_sysinit"
635 /etc/init.d/pl_sysinit
637 chmod +x etc/rc.d/init.d/pl_rsysinit
641 # create the cramfs image
642 echo "* Creating cramfs image"
643 mkfs.cramfs $tmp/ ${BUILDTMP}/cramfs.img
644 cramfs_size=$(($(du -sk ${BUILDTMP}/cramfs.img | awk '{ print $1; }') + 1))
649 #################### Create ISO CRAMFS image
650 function build_iso_cramfs() {
651 local iso="$1" ; shift
654 prepare_cramfs "$custom"
655 echo "* Creating ISO CRAMFS-based image"
657 local tmp="${BUILDTMP}/cramfs-iso"
659 push_cleanup rm -rf $tmp
660 (cd $ISOFS && find . | grep -v "\.img$" | cpio -p -d -u $tmp/)
661 cat >$tmp/isolinux.cfg <<EOF
662 ${console_serial_line}
664 DEFAULT planetlab-bootcd
666 LABEL planetlab-bootcd
669 APPEND ramdisk_size=$ramdisk_size initrd=cramfs.img root=/dev/ram0 rw ${KERNEL_ARGS}
672 cp ${BUILDTMP}/cramfs.img $tmp
681 #################### Create USB CRAMFS based image
682 function build_usb_cramfs() {
683 local usb="$1" ; shift
686 prepare_cramfs "$custom"
687 echo "* Creating USB CRAMFS based image"
689 let vfat_size=${cramfs_size}+$FREE_SPACE
691 # Make VFAT filesystem for USB
692 mkfs.vfat -C "$usb" $vfat_size
695 echo "* Populating USB with overlay images and cramfs"
696 mcopy -bsQ -i "$usb" $ISOFS/kernel $ISOFS/pl_version ::/
697 mcopy -bsQ -i "$usb" ${BUILDTMP}/cramfs.img ::/
699 # Use syslinux instead of isolinux to make the image bootable
700 tmp="${BUILDTMP}/syslinux.cfg"
702 ${console_serial_line}
704 DEFAULT planetlab-bootcd
706 LABEL planetlab-bootcd
709 APPEND ramdisk_size=$ramdisk_size initrd=cramfs.img root=/dev/ram0 rw ${KERNEL_ARGS}
712 mcopy -bsQ -i "$usb" "$tmp" ::/syslinux.cfg
715 echo "* Making USB CRAMFS based image bootable"
719 #################### map on all types provided on the command-line and invoke one of the above functions
720 function build_types () {
722 [ -z "$OUTPUT_BASE" ] && OUTPUT_BASE="$PLC_NAME-BootCD-$BOOTCD_VERSION"
724 # alter output filename to reflect serial settings
725 if [ -n "$IS_SERIAL" ] ; then
726 if [ "$CONSOLE_INFO" == "$SERIAL_CONSOLE" ] ; then
729 serial="-serial-$(echo $CONSOLE_INFO | sed -e 's,:,,g')"
735 function type_to_name() {
738 s/usb_partition$/-partition.usb/;
740 s/usb_cramfs$/-cramfs.usb/;
741 s/iso_cramfs$/-cramfs.iso/;
748 tname=`type_to_name $t`
749 # if -o is specified (as it has no default)
750 if [ -n "$OUTPUT_NAME" ] ; then
753 output="${OUTPUT_BASE}${serial}${tname}"
756 echo "*** Dealing with type=$arg"
757 echo '*' build_$t "$output" "$CUSTOM_DIR"
758 [ -n "$DRY_RUN" ] || build_$t "$output" "$CUSTOM_DIR"
765 parse_command_line "$@"
769 echo "* Building bootcd images for $NODE_CONFIGURATION_FILE ($FULL_VERSION_STRING) - $(date +%H-%M:%S)"
770 # Do not tolerate errors
772 trap "do_cleanup" ERR INT EXIT
774 init_serial $CONSOLE_INFO
778 echo "* Done with bootcd images for $NODE_CONFIGURATION_FILE - $(date +%H-%M:%S)"