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 # add more flags here for debugging
21 # KERNEL_DEBUG_ARGS="$KERNEL_DEBUG_ARGS some_other_kernel_arg"
23 # (*) GetBootMedium that has some provisions for common
24 # kargs, like e.g. for removing the hangcheck feature,
25 # or for turning on debug messages for systemd
26 # these can be turned on with tags on the node
27 # (*) tests default config, that uses this feature so
28 # the tests can benefit these features, without deploying
29 # them by default in production
32 DEFAULT_TYPES="usb iso"
33 # Leave 4 MB of free space
34 GRAPHIC_CONSOLE="graphic"
35 SERIAL_CONSOLE="ttyS0:115200:n:8"
36 CONSOLE_INFO=$GRAPHIC_CONSOLE
37 MKISOFS_OPTS="-R -J -r -f -b isolinux.bin -c boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table"
38 # isolinux-debug.bin is supposedly helpful as well if available,
39 # when things don't work as expected
40 #MKISOFS_OPTS="-R -J -r -f -b isolinux-debug.bin -c boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table"
44 # command-line settable args
45 NODE_CONFIGURATION_FILE=
55 FULL_VERSION_STRING=""
63 console_serial_line=""
66 #################### compute all supported types
67 # removing support for serial in the type
68 # this is because kargs.txt goes in the overlay, that is computed only once
69 # so we cannot handle serial and graphic modes within the same invokation of this script
72 for x in iso usb usb_partition; do for c in "" "_cramfs" ; do
79 ALL_TYPES="$ALL_TYPES $t" ;;
83 #################### cleanup utilities
84 declare -a _CLEANUPS=()
85 function do_cleanup() {
86 cd / ; for i in "${_CLEANUPS[@]}"; do $i ; done
88 function push_cleanup() {
89 _CLEANUPS=( "${_CLEANUPS[@]}" "$*" )
91 function pop_cleanup() {
92 unset _CLEANUPS[$((${#_CLEANUPS[@]} - 1))]
95 #################### initialization
96 function init_and_check () {
98 # Change to our source directory
99 local srcdir=$(cd $DIRNAME && pwd -P)
103 ISOREF=$PWD/${VARIANT}
105 # The reference image is expected to have been built by prep.sh (see .spec)
106 # we disable the initial logic that called prep.sh if that was not the case
107 # this is because prep.sh needs to know pldistro
108 if [ ! -f $ISOREF/isofs/bootcd.img -o ! -f $ISOREF/version.txt ] ; then
109 echo "Could not find isofs and version.txt in $ISOREF"
110 if [ "$VARIANT" == "build" ] ; then
111 echo "You have to run prep.sh prior to calling $COMMAND"
113 echo "You need to create your variant image, see kvariant.sh"
119 # build/version.txt written by prep.sh
120 BOOTCD_VERSION=$(cat ${VARIANT}/version.txt)
122 if [ -f /etc/planetlab/plc_config ] ; then
123 # Source PLC configuration
124 . /etc/planetlab/plc_config
127 # use /var/tmp that should be large enough on both chroot- or vserver-based myplc
130 FULL_VERSION_STRING="${PLC_NAME} BootCD ${BOOTCD_VERSION}"
135 # the custom-dir feature is designed to let a myplc try/ship a patched bootcd
136 # without the need for a full devel environment
137 # for example, you would create /root/custom-bootcd/etc/rc.d/init.d/pl_hwinit
138 # and run this script with -C /root/custom-bootcd
139 # this creates a third .img image of the custom dir, that 'hides' the files from
140 # bootcd.img in the resulting unionfs
141 # it seems that this feature has not been used nor tested in a long time, use with care
144 echo "Usage: $COMMAND [OPTION]..."
145 echo " -f plnode.txt Node to customize CD for (default: none)"
146 echo " -t 'types' Build the specified images (default: $DEFAULT_TYPES)"
147 echo " NOTE: mentioning 'serial' as part of the type is not supported anymore"
148 echo " -a Build all known types as listed below"
149 echo " -s console-info Enable a serial line as console and also bring up getty on that line"
150 echo " console-info: tty:baud-rate:parity:bits"
151 echo " or 'default' shortcut for $SERIAL_CONSOLE"
152 echo " -S equivalent to -s default"
153 echo " -O output-base The prefix of the generated files (default: PLC_NAME-BootCD-VERSION)"
154 echo " useful when multiple types are provided"
155 echo " can be a full path"
156 echo " -o output-name The full name of the generated file"
157 echo " -C custom-dir Custom directory"
158 echo " -V variant Use a variant - see kvariant.sh"
159 echo " -n Dry run - mostly for debug/test purposes"
160 echo " -k Add additional parameters to the kargs.txt file"
161 echo " -h This message"
162 echo "All known types: $ALL_TYPES"
167 function parse_command_line () {
172 while getopts "f:t:as:SO:o:C:V:k:nh" opt ; do
174 f) NODE_CONFIGURATION_FILE=$OPTARG ;;
175 t) TYPES="$TYPES $OPTARG" ;;
176 a) TYPES="$ALL_TYPES" ;;
177 s) CONSOLE_INFO="$OPTARG" ;;
178 S) CONSOLE_INFO=$SERIAL_CONSOLE ;;
179 O) OUTPUT_BASE="$OPTARG" ;;
180 o) OUTPUT_NAME="$OPTARG" ;;
181 C) CUSTOM_DIR="$OPTARG" ;;
182 V) VARIANT="$OPTARG" ;;
183 k) KERNEL_ARGS="$KERNEL_ARGS $OPTARG" ;;
189 # use defaults if not set
190 [ -z "$TYPES" ] && TYPES="$DEFAULT_TYPES"
191 [ -z "$VARIANT" ] && VARIANT="build"
192 [ "$CONSOLE_INFO" == "default" ] && CONSOLE_INFO=$SERIAL_CONSOLE
194 if [ -n "$NODE_CONFIGURATION_FILE" ] ; then
195 # check existence of NODE_CONFIGURATION_FILE and normalize as we will change directory
196 if [ ! -f "$NODE_CONFIGURATION_FILE" ] ; then
197 echo "Node configuration file $NODE_CONFIGURATION_FILE not found - exiting"
200 cf_dir="$(dirname $NODE_CONFIGURATION_FILE)"
201 cf_dir="$(cd $cf_dir; pwd -P)"
202 cf_file="$(basename $NODE_CONFIGURATION_FILE)"
203 NODE_CONFIGURATION_FILE="$cf_dir"/"$cf_file"
207 local matcher="XXX$(echo $ALL_TYPES | sed -e 's,\W,XXX,g')XXX"
209 echo Checking type $t
210 echo $matcher | grep XXX${t}XXX &> /dev/null
211 if [ "$?" != 0 ] ; then
220 function init_serial () {
221 local console=$1; shift
222 if [ "$console" == "$GRAPHIC_CONSOLE" ] ; then
225 echo "Standard, graphic, non-serial mode"
228 console_dev=$(echo "$console" | awk -F: ' {print $1}')
229 console_baud=$(echo "$console" | awk -F: ' {print $2}')
230 [ -z "$console_baud" ] && console_baud="115200"
231 local console_parity=$(echo "$console" | awk -F: ' {print $3}')
232 [ -z "$console_parity" ] && console_parity="n"
233 local console_bits=$(echo "$console" | awk -F: ' {print $4}')
234 [ -z "$console_bits" ] && console_bits="8"
235 console_spec="console=${console_dev},${console_baud}${console_parity}${console_bits}"
236 local tty_nb=$(echo $console_dev | sed -e 's,[a-zA-Z],,g')
237 console_serial_line="SERIAL ${tty_nb} ${console_baud}"
239 echo "console_serial_line=${console_serial_line}"
240 echo "console_spec=${console_spec}"
244 #################### run once : build the overlay image
245 function build_overlay () {
247 BUILDTMP=$(mktemp -d ${BUILDTMP}/bootcd.XXXXXX)
248 push_cleanup rm -fr "${BUILDTMP}"
251 ISOFS="${BUILDTMP}/isofs"
253 for i in "$ISOREF"/isofs/{bootcd.img,kernel}; do
256 # use new location as of fedora 12
257 # used to be in /usr/lib/syslinux/isolinux.bin
258 # removed backward compat in jan. 2015
259 # as of syslinux 6.05 (fedora 21) ldlinux.c32 is required by isolinux.bin
260 # the debug version can come in handy at times, and is 40k as well
261 isolinuxdir="/usr/share/syslinux"
262 # ship only what is mandatory, and forget about
263 # (*) isolinux-debug.bin as its name confuses mkisofs
264 # (*) memdisk that is not useful
265 isolinuxfiles="isolinux.bin ldlinux.c32"
266 for isolinuxfile in $isolinuxfiles; do
267 [ -f $isolinuxdir/$isolinuxfile ] && cp $isolinuxdir/$isolinuxfile "${BUILDTMP}/isofs"
270 # Root of the ISO and USB images
271 echo "* Populating root filesystem..."
272 OVERLAY="${BUILDTMP}/overlay"
273 install -d -m 755 $OVERLAY
274 push_cleanup rm -fr $OVERLAY
276 # Create version files
277 echo "* Creating version files"
279 # Boot Manager compares pl_version in both places to make sure that
280 # the right CD is mounted. We used to boot from an initrd and mount
281 # the CD on /usr. Now we just run everything out of the initrd.
282 for file in $OVERLAY/pl_version $OVERLAY/usr/isolinux/pl_version ; do
283 mkdir -p $(dirname $file)
284 echo "$FULL_VERSION_STRING" >$file
287 # Install boot server configuration files
288 echo "* Installing boot server configuration files"
290 # We always intended to bring up and support backup boot servers,
291 # but never got around to it. Just install the same parameters for
293 for dir in $OVERLAY/usr/boot $OVERLAY/usr/boot/backup ; do
294 install -D -m 644 $PLC_BOOT_CA_SSL_CRT $dir/cacert.pem
295 install -D -m 644 $PLC_ROOT_GPG_KEY_PUB $dir/pubring.gpg
296 echo "$PLC_BOOT_HOST" >$dir/boot_server
297 echo "$PLC_BOOT_SSL_PORT" >$dir/boot_server_port
298 echo "/boot/" >$dir/boot_server_path
301 # Install old-style boot server configuration files
302 # as opposed to what a former comment suggested,
303 # this is still required, somewhere in the bootmanager apparently
304 install -D -m 644 $PLC_BOOT_CA_SSL_CRT $OVERLAY/usr/bootme/cacert/$PLC_BOOT_HOST/cacert.pem
305 echo "$FULL_VERSION_STRING" >$OVERLAY/usr/bootme/ID
306 echo "$PLC_BOOT_HOST" >$OVERLAY/usr/bootme/BOOTSERVER
307 echo "$PLC_BOOT_HOST" >$OVERLAY/usr/bootme/BOOTSERVER_IP
308 echo "$PLC_BOOT_SSL_PORT" >$OVERLAY/usr/bootme/BOOTPORT
310 # Generate /etc/issue
311 echo "* Generating /etc/issue"
313 if [ "$PLC_WWW_PORT" = "443" ] ; then
314 PLC_WWW_URL="https://$PLC_WWW_HOST/"
315 elif [ "$PLC_WWW_PORT" != "80" ] ; then
316 PLC_WWW_URL="http://$PLC_WWW_HOST:$PLC_WWW_PORT/"
318 PLC_WWW_URL="http://$PLC_WWW_HOST/"
321 mkdir -p $OVERLAY/etc
322 cat >$OVERLAY/etc/issue <<EOF
328 This machine is a node in the $PLC_NAME distributed network. It has
329 not fully booted yet. If you have cancelled the boot process at the
330 request of $PLC_NAME Support, please follow the instructions provided
331 to you. Otherwise, please contact $PLC_MAIL_SUPPORT_ADDRESS.
333 Console login at this point is restricted to root. Provide the root
334 password of the default $PLC_NAME Central administrator account at the
335 time that this CD was created.
340 echo "* Setting root password"
342 if [ -z "$ROOT_PASSWORD" ] ; then
343 # Generate an encrypted password with crypt() if not defined
344 # in a static configuration.
345 ROOT_PASSWORD=$(python <<EOF
346 import crypt, random, string
347 salt = [random.choice(string.letters + string.digits + "./") for i in range(0,8)]
348 print crypt.crypt('$PLC_ROOT_PASSWORD', '\$1\$' + "".join(salt) + '\$')
353 # build/passwd copied out by prep.sh
354 sed -e "s@^root:[^:]*:\(.*\)@root:$ROOT_PASSWORD:\1@" ${VARIANT}/passwd >$OVERLAY/etc/passwd
356 # Install node configuration file (e.g., if node has no floppy disk or USB slot)
357 if [ -f "$NODE_CONFIGURATION_FILE" ] ; then
358 echo "* Installing node configuration file $NODE_CONFIGURATION_FILE -> /usr/boot/plnode.txt of the bootcd image"
359 install -D -m 644 $NODE_CONFIGURATION_FILE $OVERLAY/usr/boot/plnode.txt
360 NODE_ID=$(source $NODE_CONFIGURATION_FILE; echo $NODE_ID)
361 echo "* Building network configuration for $NODE_ID"
362 plnet -- --root $OVERLAY --files-only --program BootCD $NODE_ID
365 [ -n "$IS_SERIAL" ] && KERNEL_ARGS="$KERNEL_ARGS ${console_spec}"
367 # tmp: should be restricted to f15 nodes and above
368 # making sure the network interfaces are still numbered eth0 and above
369 KERNEL_ARGS="$KERNEL_ARGS biosdevname=0"
370 # making sure selinux is turned off - somehow this is needed with lxc/f14
371 KERNEL_ARGS="$KERNEL_ARGS selinux=0"
372 # add any debug flag if any (defined in the header of this script)
373 KERNEL_ARGS="$KERNEL_ARGS $KERNEL_DEBUG_ARGS"
374 # propagate kernel args for later boot stages
375 [ -n "$KERNEL_ARGS" ] && echo "$KERNEL_ARGS" > $OVERLAY/kargs.txt
377 # Pack overlay files into a compressed archive
378 echo "* Compressing overlay image"
379 (cd $OVERLAY && find . | cpio --quiet -c -o) | gzip -9 >$ISOFS/overlay.img
384 if [ -n "$CUSTOM_DIR" ]; then
385 echo "* Compressing custom image"
386 (cd "$CUSTOM_DIR" && find . | cpio --quiet -c -o) | gzip -9 >$ISOFS/custom.img
389 # Calculate ramdisk size (total uncompressed size of both archives)
390 ramdisk_size=$(gzip -l $ISOFS/bootcd.img $ISOFS/overlay.img ${CUSTOM_DIR:+$ISOFS/custom.img} | tail -1 | awk '{ print $2; }') # bytes
391 ramdisk_size=$((($ramdisk_size + 1023) / 1024)) # kilobytes
393 echo "$FULL_VERSION_STRING" >$ISOFS/pl_version
398 #################### plain ISO
399 function build_iso() {
400 local iso="$1" ; shift
403 # Write isolinux configuration
404 cat >$ISOFS/isolinux.cfg <<EOF
405 ${console_serial_line}
407 DEFAULT planetlab-bootcd
409 LABEL planetlab-bootcd
412 APPEND ramdisk_size=$ramdisk_size initrd=bootcd.img,overlay.img${custom:+,custom.img} root=/dev/ram0 rw ${KERNEL_ARGS}
416 echo "* Generated isolinux.cfg -------------------- BEG"
417 cat $ISOFS/isolinux.cfg
418 echo "* Generated isolinux.cfg -------------------- END"
419 echo "* Creating ISO image in pwd=$(pwd)"
420 echo "* with command mkisofs -o $iso $MKISOFS_OPTS $ISOFS"
421 mkisofs -o "$iso" $MKISOFS_OPTS $ISOFS
424 #################### USB with partitions
425 function build_usb_partition() {
426 echo -n "* Creating USB image with partitions..."
427 local usb="$1" ; shift
430 local size=$(($(du -Lsk $ISOFS | awk '{ print $1; }') + $FREE_SPACE))
431 size=$(( $size / 1024 ))
435 local cylinders=$(( ($size*1024*2)/($heads*$sectors) ))
436 local offset=$(( $sectors*512 ))
438 if [ -f /usr/lib/syslinux/mkdiskimage ] ; then
439 /usr/lib/syslinux/mkdiskimage -M -4 "$usb" $size $heads $sectors
441 mkdiskimage -M -4 "$usb" $size $heads $sectors
444 cat >${BUILDTMP}/mtools.conf<<EOF
454 # environment variable for mtools
455 export MTOOLSRC="${BUILDTMP}/mtools.conf"
457 ### COPIED FROM build_usb() below!!!!
458 echo -n " populating USB image... "
459 mcopy -bsQ -i "$usb" "$ISOFS"/* z:/
461 # Use syslinux instead of isolinux to make the image bootable
462 tmp="${BUILDTMP}/syslinux.cfg"
464 ${console_serial_line}
466 DEFAULT planetlab-bootcd
468 LABEL planetlab-bootcd
471 APPEND ramdisk_size=$ramdisk_size initrd=bootcd.img,overlay.img${custom:+,custom.img} root=/dev/ram0 rw ${KERNEL_ARGS}
473 mdel -i "$usb" z:/isolinux.cfg 2>/dev/null || :
474 mcopy -i "$usb" "$tmp" z:/syslinux.cfg
479 echo "making USB image bootable."
480 syslinux -o $offset "$usb"
484 #################### plain USB
485 function build_usb() {
486 echo -n "* Creating USB image... "
487 local usb="$1" ; shift
491 mkfs.vfat -C "$usb" $(($(du -Lsk $ISOFS | awk '{ print $1; }') + $FREE_SPACE))
493 cat >${BUILDTMP}/mtools.conf<<EOF
496 # environment variable for mtools
497 export MTOOLSRC="${BUILDTMP}/mtools.conf"
500 echo -n " populating USB image... "
501 mcopy -bsQ -i "$usb" "$ISOFS"/* ::/
503 # Use syslinux instead of isolinux to make the image bootable
504 tmp="${BUILDTMP}/syslinux.cfg"
506 ${console_serial_line}
508 DEFAULT planetlab-bootcd
510 LABEL planetlab-bootcd
513 APPEND ramdisk_size=$ramdisk_size initrd=bootcd.img,overlay.img${custom:+,custom.img} root=/dev/ram0 rw ${KERNEL_ARGS}
515 mdel -i "$usb" ::/isolinux.cfg 2>/dev/null || :
516 mcopy -i "$usb" "$tmp" ::/syslinux.cfg
521 echo "making USB image bootable."
525 #################### utility to setup CRAMFS related support
526 function prepare_cramfs() {
527 [ -n "$CRAMFS_PREPARED" ] && return 0
530 echo "* Setting up CRAMFS-based images"
531 local tmp="${BUILDTMP}/cramfs-tree"
533 push_cleanup rm -rf $tmp
535 gzip -d -c $ISOFS/bootcd.img | cpio -diu
536 gzip -d -c $ISOFS/overlay.img | cpio -diu
537 [ -n "$custom" ] && \
538 gzip -d -c $ISOFS/custom.img | cpio -diu
540 # clean out unnecessary rpm lib
541 echo "* clearing var/lib/rpm/*"
544 # bootcd requires this directory
545 mkdir -p mnt/confdevice
547 # relocate various directory to /tmp
549 ln -fs /tmp/root root
550 ln -fs /sbin/init linuxrc
551 ln -fs /tmp/resolv.conf etc/resolv.conf
552 ln -fs /tmp/etc/mtab etc/mtab
554 # have pl_rsysinit copy over appropriate etc & var directories into /tmp/etc/
556 echo "* renaming dirs in ./etc"
558 for dir in `find * -type d -prune | grep -v rc.d`; do
560 ln -fs /tmp/etc/${dir} ${dir}
564 echo "* renaming dirs in ./var"
565 # rename all top-level directories and put in a symlink to /tmp/var
567 for dir in `find * -type d -prune`; do
569 ln -fs /tmp/var/${dir} ${dir}
573 # overwrite fstab to mount / as cramfs and /tmp as tmpfs
574 echo "* Overwriting etc/fstab to use cramfs and tmpfs"
576 cat >./etc/fstab <<EOF
577 /dev/ram0 / cramfs ro 0 0
578 none /dev/pts devpts gid=5,mode=620 0 0
579 none /proc proc defaults 0 0
580 none /sys sysfs defaults 0 0
586 #for i in 0 1 2 3 4 5 6 7 8; do rm -f ram${i} ; done
587 #for i in 0 1 2 3 4 5 6 7 8; do mknod ram${i} b 1 ${i} ; done
592 # update etc/inittab to start with pl_rsysinit
593 for file in etc/inittab etc/event.d/rcS etc/init/rcS.conf; do
594 [ -f $file ] && sed -i 's,pl_sysinit,pl_rsysinit,' $file
597 # modify inittab to have a serial console
598 # xxx this might well be broken with f12 and above xxx
599 if [ -n "$serial" ] ; then
600 echo "T0:23:respawn:/sbin/agetty -L $console_dev $console_baud vt100" >> etc/inittab
601 # and let root log in
602 echo "$console_dev" >> etc/securetty
605 # calculate the size of /tmp based on the size of /etc & /var + 8MB slack
606 etcsize=$(du -s ./etc | awk '{ print $1 }')
607 varsize=$(du -s ./var | awk '{ print $1 }')
608 let msize=($varsize+$etcsize+8192)/1024
610 # make dhclient happy
611 for i in $(seq 0 9); do ln -fs /tmp/etc/dhclient-eth${i}.conf etc/dhclient-eth${i}.conf ; done
612 ln -fs /tmp/etc/resolv.conf etc/resolv.conf
613 ln -fs /tmp/etc/resolv.conf.predhclient etc/resolv.conf.predhclient
615 # generate pl_rsysinit
616 cat > etc/rc.d/init.d/pl_rsysinit <<EOF
618 # generated by $COMMAND
619 echo -n "pl_rsysinit: preparing /etc and /var for pl_sysinit..."
620 mount -t tmpfs -orw,size=${msize}M,mode=1777 tmpfs /tmp
623 touch /tmp/etc/resolv.conf
628 echo "tmpfs /tmp tmpfs rw,size=${msize}M,mode=1777 1 1" > /tmp/etc/mtab
630 # copy over directory contents of all _o directories from /etc and /var
631 # /tmp/etc and /tmp/var
633 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
636 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
641 # hand over to pl_sysinit
642 echo "pl_rsysinit: handing over to pl_sysinit"
643 /etc/init.d/pl_sysinit
645 chmod +x etc/rc.d/init.d/pl_rsysinit
649 # create the cramfs image
650 echo "* Creating cramfs image"
651 mkfs.cramfs $tmp/ ${BUILDTMP}/cramfs.img
652 cramfs_size=$(($(du -sk ${BUILDTMP}/cramfs.img | awk '{ print $1; }') + 1))
657 #################### Create ISO CRAMFS image
658 function build_iso_cramfs() {
659 local iso="$1" ; shift
662 prepare_cramfs "$custom"
663 echo "* Creating ISO CRAMFS-based image"
665 local tmp="${BUILDTMP}/cramfs-iso"
667 push_cleanup rm -rf $tmp
668 (cd $ISOFS && find . | grep -v "\.img$" | cpio -p -d -u $tmp/)
669 cat >$tmp/isolinux.cfg <<EOF
670 ${console_serial_line}
672 DEFAULT planetlab-bootcd
674 LABEL planetlab-bootcd
677 APPEND ramdisk_size=$ramdisk_size initrd=cramfs.img root=/dev/ram0 rw ${KERNEL_ARGS}
680 cp ${BUILDTMP}/cramfs.img $tmp
689 #################### Create USB CRAMFS based image
690 function build_usb_cramfs() {
691 local usb="$1" ; shift
694 prepare_cramfs "$custom"
695 echo "* Creating USB CRAMFS based image"
697 let vfat_size=${cramfs_size}+$FREE_SPACE
699 # Make VFAT filesystem for USB
700 mkfs.vfat -C "$usb" $vfat_size
703 echo "* Populating USB with overlay images and cramfs"
704 mcopy -bsQ -i "$usb" $ISOFS/kernel $ISOFS/pl_version ::/
705 mcopy -bsQ -i "$usb" ${BUILDTMP}/cramfs.img ::/
707 # Use syslinux instead of isolinux to make the image bootable
708 tmp="${BUILDTMP}/syslinux.cfg"
710 ${console_serial_line}
712 DEFAULT planetlab-bootcd
714 LABEL planetlab-bootcd
717 APPEND ramdisk_size=$ramdisk_size initrd=cramfs.img root=/dev/ram0 rw ${KERNEL_ARGS}
720 mcopy -bsQ -i "$usb" "$tmp" ::/syslinux.cfg
723 echo "* Making USB CRAMFS based image bootable"
727 #################### map on all types provided on the command-line and invoke one of the above functions
728 function build_types () {
730 [ -z "$OUTPUT_BASE" ] && OUTPUT_BASE="$PLC_NAME-BootCD-$BOOTCD_VERSION"
732 # alter output filename to reflect serial settings
733 if [ -n "$IS_SERIAL" ] ; then
734 if [ "$CONSOLE_INFO" == "$SERIAL_CONSOLE" ] ; then
737 serial="-serial-$(echo $CONSOLE_INFO | sed -e 's,:,,g')"
743 function type_to_name() {
746 s/usb_partition$/-partition.usb/;
748 s/usb_cramfs$/-cramfs.usb/;
749 s/iso_cramfs$/-cramfs.iso/;
756 tname=`type_to_name $t`
757 # if -o is specified (as it has no default)
758 if [ -n "$OUTPUT_NAME" ] ; then
761 output="${OUTPUT_BASE}${serial}${tname}"
764 echo "*** Dealing with type=$arg"
765 echo '*' build_$t "$output" "$CUSTOM_DIR"
766 [ -n "$DRY_RUN" ] || build_$t "$output" "$CUSTOM_DIR"
773 parse_command_line "$@"
777 echo "* Building bootcd images for $NODE_CONFIGURATION_FILE ($FULL_VERSION_STRING) - $(date +%H-%M:%S)"
778 # Do not tolerate errors
780 trap "do_cleanup" ERR INT EXIT
782 init_serial $CONSOLE_INFO
786 echo "* Done with bootcd images for $NODE_CONFIGURATION_FILE - $(date +%H-%M:%S)"