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 # uncomment this to augment verbosity of boot phase
21 KERNEL_DEBUG_ARGS="$KERNEL_DEBUG_ARGS systemd.log_level=debug"
24 DEFAULT_TYPES="usb iso"
25 # Leave 4 MB of free space
26 GRAPHIC_CONSOLE="graphic"
27 SERIAL_CONSOLE="ttyS0:115200:n:8"
28 CONSOLE_INFO=$GRAPHIC_CONSOLE
29 MKISOFS_OPTS="-R -J -r -f -b isolinux.bin -c boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table"
30 # isolinux-debug.bin is supposedly helpful as well if available,
31 # when things don't work as expected
32 #MKISOFS_OPTS="-R -J -r -f -b isolinux-debug.bin -c boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table"
36 # command-line settable args
37 NODE_CONFIGURATION_FILE=
47 FULL_VERSION_STRING=""
55 console_serial_line=""
58 #################### compute all supported types
59 # removing support for serial in the type
60 # this is because kargs.txt goes in the overlay, that is computed only once
61 # so we cannot handle serial and graphic modes within the same invokation of this script
64 for x in iso usb usb_partition; do for c in "" "_cramfs" ; do
71 ALL_TYPES="$ALL_TYPES $t" ;;
75 #################### cleanup utilities
76 declare -a _CLEANUPS=()
77 function do_cleanup() {
78 cd / ; for i in "${_CLEANUPS[@]}"; do $i ; done
80 function push_cleanup() {
81 _CLEANUPS=( "${_CLEANUPS[@]}" "$*" )
83 function pop_cleanup() {
84 unset _CLEANUPS[$((${#_CLEANUPS[@]} - 1))]
87 #################### initialization
88 function init_and_check () {
90 # Change to our source directory
91 local srcdir=$(cd $DIRNAME && pwd -P)
95 ISOREF=$PWD/${VARIANT}
97 # The reference image is expected to have been built by prep.sh (see .spec)
98 # we disable the initial logic that called prep.sh if that was not the case
99 # this is because prep.sh needs to know pldistro
100 if [ ! -f $ISOREF/isofs/bootcd.img -o ! -f $ISOREF/version.txt ] ; then
101 echo "Could not find isofs and version.txt in $ISOREF"
102 if [ "$VARIANT" == "build" ] ; then
103 echo "You have to run prep.sh prior to calling $COMMAND"
105 echo "You need to create your variant image, see kvariant.sh"
111 # build/version.txt written by prep.sh
112 BOOTCD_VERSION=$(cat ${VARIANT}/version.txt)
114 if [ -f /etc/planetlab/plc_config ] ; then
115 # Source PLC configuration
116 . /etc/planetlab/plc_config
119 # use /var/tmp that should be large enough on both chroot- or vserver-based myplc
122 FULL_VERSION_STRING="${PLC_NAME} BootCD ${BOOTCD_VERSION}"
127 # the custom-dir feature is designed to let a myplc try/ship a patched bootcd
128 # without the need for a full devel environment
129 # for example, you would create /root/custom-bootcd/etc/rc.d/init.d/pl_hwinit
130 # and run this script with -C /root/custom-bootcd
131 # this creates a third .img image of the custom dir, that 'hides' the files from
132 # bootcd.img in the resulting unionfs
133 # it seems that this feature has not been used nor tested in a long time, use with care
136 echo "Usage: $COMMAND [OPTION]..."
137 echo " -f plnode.txt Node to customize CD for (default: none)"
138 echo " -t 'types' Build the specified images (default: $DEFAULT_TYPES)"
139 echo " NOTE: mentioning 'serial' as part of the type is not supported anymore"
140 echo " -a Build all known types as listed below"
141 echo " -s console-info Enable a serial line as console and also bring up getty on that line"
142 echo " console-info: tty:baud-rate:parity:bits"
143 echo " or 'default' shortcut for $SERIAL_CONSOLE"
144 echo " -S equivalent to -s default"
145 echo " -O output-base The prefix of the generated files (default: PLC_NAME-BootCD-VERSION)"
146 echo " useful when multiple types are provided"
147 echo " can be a full path"
148 echo " -o output-name The full name of the generated file"
149 echo " -C custom-dir Custom directory"
150 echo " -V variant Use a variant - see kvariant.sh"
151 echo " -n Dry run - mostly for debug/test purposes"
152 echo " -k Add additional parameters to the kargs.txt file"
153 echo " -h This message"
154 echo "All known types: $ALL_TYPES"
159 function parse_command_line () {
164 while getopts "f:t:as:SO:o:C:V:k:nh" opt ; do
166 f) NODE_CONFIGURATION_FILE=$OPTARG ;;
167 t) TYPES="$TYPES $OPTARG" ;;
168 a) TYPES="$ALL_TYPES" ;;
169 s) CONSOLE_INFO="$OPTARG" ;;
170 S) CONSOLE_INFO=$SERIAL_CONSOLE ;;
171 O) OUTPUT_BASE="$OPTARG" ;;
172 o) OUTPUT_NAME="$OPTARG" ;;
173 C) CUSTOM_DIR="$OPTARG" ;;
174 V) VARIANT="$OPTARG" ;;
175 k) KERNEL_ARGS="$KERNEL_ARGS $OPTARG" ;;
181 # use defaults if not set
182 [ -z "$TYPES" ] && TYPES="$DEFAULT_TYPES"
183 [ -z "$VARIANT" ] && VARIANT="build"
184 [ "$CONSOLE_INFO" == "default" ] && CONSOLE_INFO=$SERIAL_CONSOLE
186 if [ -n "$NODE_CONFIGURATION_FILE" ] ; then
187 # check existence of NODE_CONFIGURATION_FILE and normalize as we will change directory
188 if [ ! -f "$NODE_CONFIGURATION_FILE" ] ; then
189 echo "Node configuration file $NODE_CONFIGURATION_FILE not found - exiting"
192 cf_dir="$(dirname $NODE_CONFIGURATION_FILE)"
193 cf_dir="$(cd $cf_dir; pwd -P)"
194 cf_file="$(basename $NODE_CONFIGURATION_FILE)"
195 NODE_CONFIGURATION_FILE="$cf_dir"/"$cf_file"
199 local matcher="XXX$(echo $ALL_TYPES | sed -e 's,\W,XXX,g')XXX"
201 echo Checking type $t
202 echo $matcher | grep XXX${t}XXX &> /dev/null
203 if [ "$?" != 0 ] ; then
212 function init_serial () {
213 local console=$1; shift
214 if [ "$console" == "$GRAPHIC_CONSOLE" ] ; then
217 echo "Standard, graphic, non-serial mode"
220 console_dev=$(echo "$console" | awk -F: ' {print $1}')
221 console_baud=$(echo "$console" | awk -F: ' {print $2}')
222 [ -z "$console_baud" ] && console_baud="115200"
223 local console_parity=$(echo "$console" | awk -F: ' {print $3}')
224 [ -z "$console_parity" ] && console_parity="n"
225 local console_bits=$(echo "$console" | awk -F: ' {print $4}')
226 [ -z "$console_bits" ] && console_bits="8"
227 console_spec="console=${console_dev},${console_baud}${console_parity}${console_bits}"
228 local tty_nb=$(echo $console_dev | sed -e 's,[a-zA-Z],,g')
229 console_serial_line="SERIAL ${tty_nb} ${console_baud}"
231 echo "console_serial_line=${console_serial_line}"
232 echo "console_spec=${console_spec}"
236 #################### run once : build the overlay image
237 function build_overlay () {
239 BUILDTMP=$(mktemp -d ${BUILDTMP}/bootcd.XXXXXX)
240 push_cleanup rm -fr "${BUILDTMP}"
243 ISOFS="${BUILDTMP}/isofs"
245 for i in "$ISOREF"/isofs/{bootcd.img,kernel}; do
248 # use new location as of fedora 12
249 # used to be in /usr/lib/syslinux/isolinux.bin
250 # removed backward compat in jan. 2015
251 # as of syslinux 6.05 (fedora 21) ldlinux.c32 is required by isolinux.bin
252 # the debug version can come in handy at times, and is 40k as well
253 isolinuxdir="/usr/share/syslinux"
254 isolinuxfiles="isolinux.bin ldlinux.c32 isolinux-debug.bin memdisk"
255 for isolinuxfile in $isolinuxfiles; do
256 [ -f $isolinuxdir/$isolinuxfile ] && cp $isolinuxdir/$isolinuxfile "${BUILDTMP}/isofs"
259 # Root of the ISO and USB images
260 echo "* Populating root filesystem..."
261 OVERLAY="${BUILDTMP}/overlay"
262 install -d -m 755 $OVERLAY
263 push_cleanup rm -fr $OVERLAY
265 # Create version files
266 echo "* Creating version files"
268 # Boot Manager compares pl_version in both places to make sure that
269 # the right CD is mounted. We used to boot from an initrd and mount
270 # the CD on /usr. Now we just run everything out of the initrd.
271 for file in $OVERLAY/pl_version $OVERLAY/usr/isolinux/pl_version ; do
272 mkdir -p $(dirname $file)
273 echo "$FULL_VERSION_STRING" >$file
276 # Install boot server configuration files
277 echo "* Installing boot server configuration files"
279 # We always intended to bring up and support backup boot servers,
280 # but never got around to it. Just install the same parameters for
282 for dir in $OVERLAY/usr/boot $OVERLAY/usr/boot/backup ; do
283 install -D -m 644 $PLC_BOOT_CA_SSL_CRT $dir/cacert.pem
284 install -D -m 644 $PLC_ROOT_GPG_KEY_PUB $dir/pubring.gpg
285 echo "$PLC_BOOT_HOST" >$dir/boot_server
286 echo "$PLC_BOOT_SSL_PORT" >$dir/boot_server_port
287 echo "/boot/" >$dir/boot_server_path
290 # Install old-style boot server configuration files
291 # as opposed to what a former comment suggested,
292 # this is still required, somewhere in the bootmanager apparently
293 install -D -m 644 $PLC_BOOT_CA_SSL_CRT $OVERLAY/usr/bootme/cacert/$PLC_BOOT_HOST/cacert.pem
294 echo "$FULL_VERSION_STRING" >$OVERLAY/usr/bootme/ID
295 echo "$PLC_BOOT_HOST" >$OVERLAY/usr/bootme/BOOTSERVER
296 echo "$PLC_BOOT_HOST" >$OVERLAY/usr/bootme/BOOTSERVER_IP
297 echo "$PLC_BOOT_SSL_PORT" >$OVERLAY/usr/bootme/BOOTPORT
299 # Generate /etc/issue
300 echo "* Generating /etc/issue"
302 if [ "$PLC_WWW_PORT" = "443" ] ; then
303 PLC_WWW_URL="https://$PLC_WWW_HOST/"
304 elif [ "$PLC_WWW_PORT" != "80" ] ; then
305 PLC_WWW_URL="http://$PLC_WWW_HOST:$PLC_WWW_PORT/"
307 PLC_WWW_URL="http://$PLC_WWW_HOST/"
310 mkdir -p $OVERLAY/etc
311 cat >$OVERLAY/etc/issue <<EOF
317 This machine is a node in the $PLC_NAME distributed network. It has
318 not fully booted yet. If you have cancelled the boot process at the
319 request of $PLC_NAME Support, please follow the instructions provided
320 to you. Otherwise, please contact $PLC_MAIL_SUPPORT_ADDRESS.
322 Console login at this point is restricted to root. Provide the root
323 password of the default $PLC_NAME Central administrator account at the
324 time that this CD was created.
329 echo "* Setting root password"
331 if [ -z "$ROOT_PASSWORD" ] ; then
332 # Generate an encrypted password with crypt() if not defined
333 # in a static configuration.
334 ROOT_PASSWORD=$(python <<EOF
335 import crypt, random, string
336 salt = [random.choice(string.letters + string.digits + "./") for i in range(0,8)]
337 print crypt.crypt('$PLC_ROOT_PASSWORD', '\$1\$' + "".join(salt) + '\$')
342 # build/passwd copied out by prep.sh
343 sed -e "s@^root:[^:]*:\(.*\)@root:$ROOT_PASSWORD:\1@" ${VARIANT}/passwd >$OVERLAY/etc/passwd
345 # Install node configuration file (e.g., if node has no floppy disk or USB slot)
346 if [ -f "$NODE_CONFIGURATION_FILE" ] ; then
347 echo "* Installing node configuration file $NODE_CONFIGURATION_FILE -> /usr/boot/plnode.txt of the bootcd image"
348 install -D -m 644 $NODE_CONFIGURATION_FILE $OVERLAY/usr/boot/plnode.txt
349 NODE_ID=$(source $NODE_CONFIGURATION_FILE; echo $NODE_ID)
350 echo "* Building network configuration for $NODE_ID"
351 plnet -- --root $OVERLAY --files-only --program BootCD $NODE_ID
354 [ -n "$IS_SERIAL" ] && KERNEL_ARGS="$KERNEL_ARGS ${console_spec}"
356 # tmp: should be restricted to f15 nodes and above
357 # making sure the network interfaces are still numbered eth0 and above
358 KERNEL_ARGS="$KERNEL_ARGS biosdevname=0"
359 # making sure selinux is turned off - somehow this is needed with lxc/f14
360 KERNEL_ARGS="$KERNEL_ARGS selinux=0"
361 # output systemd-related messages on the serial line so it gets with log.txt
362 KERNEL_ARGS="$KERNEL_ARGS systemd.log_target=console console=ttyS0,115200"
363 # add any debug flag if any (defined in the header of this script)
364 KERNEL_ARGS="$KERNEL_ARGS $KERNEL_DEBUG_ARGS"
365 # propagate kernel args for later boot stages
366 [ -n "$KERNEL_ARGS" ] && echo "$KERNEL_ARGS" > $OVERLAY/kargs.txt
368 # Pack overlay files into a compressed archive
369 echo "* Compressing overlay image"
370 (cd $OVERLAY && find . | cpio --quiet -c -o) | gzip -9 >$ISOFS/overlay.img
375 if [ -n "$CUSTOM_DIR" ]; then
376 echo "* Compressing custom image"
377 (cd "$CUSTOM_DIR" && find . | cpio --quiet -c -o) | gzip -9 >$ISOFS/custom.img
380 # Calculate ramdisk size (total uncompressed size of both archives)
381 ramdisk_size=$(gzip -l $ISOFS/bootcd.img $ISOFS/overlay.img ${CUSTOM_DIR:+$ISOFS/custom.img} | tail -1 | awk '{ print $2; }') # bytes
382 ramdisk_size=$((($ramdisk_size + 1023) / 1024)) # kilobytes
384 echo "$FULL_VERSION_STRING" >$ISOFS/pl_version
389 #################### plain ISO
390 function build_iso() {
391 local iso="$1" ; shift
394 # Write isolinux configuration
395 cat >$ISOFS/isolinux.cfg <<EOF
396 ${console_serial_line}
398 DEFAULT planetlab-bootcd
400 LABEL planetlab-bootcd
403 APPEND ramdisk_size=$ramdisk_size initrd=bootcd.img,overlay.img${custom:+,custom.img} root=/dev/ram0 rw ${KERNEL_ARGS}
407 echo "* Creating ISO image in $(pwd)"
408 mkisofs -o "$iso" $MKISOFS_OPTS $ISOFS
411 #################### USB with partitions
412 function build_usb_partition() {
413 echo -n "* Creating USB image with partitions..."
414 local usb="$1" ; shift
417 local size=$(($(du -Lsk $ISOFS | awk '{ print $1; }') + $FREE_SPACE))
418 size=$(( $size / 1024 ))
422 local cylinders=$(( ($size*1024*2)/($heads*$sectors) ))
423 local offset=$(( $sectors*512 ))
425 if [ -f /usr/lib/syslinux/mkdiskimage ] ; then
426 /usr/lib/syslinux/mkdiskimage -M -4 "$usb" $size $heads $sectors
428 mkdiskimage -M -4 "$usb" $size $heads $sectors
431 cat >${BUILDTMP}/mtools.conf<<EOF
441 # environment variable for mtools
442 export MTOOLSRC="${BUILDTMP}/mtools.conf"
444 ### COPIED FROM build_usb() below!!!!
445 echo -n " populating USB image... "
446 mcopy -bsQ -i "$usb" "$ISOFS"/* z:/
448 # Use syslinux instead of isolinux to make the image bootable
449 tmp="${BUILDTMP}/syslinux.cfg"
451 ${console_serial_line}
453 DEFAULT planetlab-bootcd
455 LABEL planetlab-bootcd
458 APPEND ramdisk_size=$ramdisk_size initrd=bootcd.img,overlay.img${custom:+,custom.img} root=/dev/ram0 rw ${KERNEL_ARGS}
460 mdel -i "$usb" z:/isolinux.cfg 2>/dev/null || :
461 mcopy -i "$usb" "$tmp" z:/syslinux.cfg
466 echo "making USB image bootable."
467 syslinux -o $offset "$usb"
471 #################### plain USB
472 function build_usb() {
473 echo -n "* Creating USB image... "
474 local usb="$1" ; shift
478 mkfs.vfat -C "$usb" $(($(du -Lsk $ISOFS | awk '{ print $1; }') + $FREE_SPACE))
480 cat >${BUILDTMP}/mtools.conf<<EOF
483 # environment variable for mtools
484 export MTOOLSRC="${BUILDTMP}/mtools.conf"
487 echo -n " populating USB image... "
488 mcopy -bsQ -i "$usb" "$ISOFS"/* ::/
490 # Use syslinux instead of isolinux to make the image bootable
491 tmp="${BUILDTMP}/syslinux.cfg"
493 ${console_serial_line}
495 DEFAULT planetlab-bootcd
497 LABEL planetlab-bootcd
500 APPEND ramdisk_size=$ramdisk_size initrd=bootcd.img,overlay.img${custom:+,custom.img} root=/dev/ram0 rw ${KERNEL_ARGS}
502 mdel -i "$usb" ::/isolinux.cfg 2>/dev/null || :
503 mcopy -i "$usb" "$tmp" ::/syslinux.cfg
508 echo "making USB image bootable."
512 #################### utility to setup CRAMFS related support
513 function prepare_cramfs() {
514 [ -n "$CRAMFS_PREPARED" ] && return 0
517 echo "* Setting up CRAMFS-based images"
518 local tmp="${BUILDTMP}/cramfs-tree"
520 push_cleanup rm -rf $tmp
522 gzip -d -c $ISOFS/bootcd.img | cpio -diu
523 gzip -d -c $ISOFS/overlay.img | cpio -diu
524 [ -n "$custom" ] && \
525 gzip -d -c $ISOFS/custom.img | cpio -diu
527 # clean out unnecessary rpm lib
528 echo "* clearing var/lib/rpm/*"
531 # bootcd requires this directory
532 mkdir -p mnt/confdevice
534 # relocate various directory to /tmp
536 ln -fs /tmp/root root
537 ln -fs /sbin/init linuxrc
538 ln -fs /tmp/resolv.conf etc/resolv.conf
539 ln -fs /tmp/etc/mtab etc/mtab
541 # have pl_rsysinit copy over appropriate etc & var directories into /tmp/etc/
543 echo "* renaming dirs in ./etc"
545 for dir in `find * -type d -prune | grep -v rc.d`; do
547 ln -fs /tmp/etc/${dir} ${dir}
551 echo "* renaming dirs in ./var"
552 # rename all top-level directories and put in a symlink to /tmp/var
554 for dir in `find * -type d -prune`; do
556 ln -fs /tmp/var/${dir} ${dir}
560 # overwrite fstab to mount / as cramfs and /tmp as tmpfs
561 echo "* Overwriting etc/fstab to use cramfs and tmpfs"
563 cat >./etc/fstab <<EOF
564 /dev/ram0 / cramfs ro 0 0
565 none /dev/pts devpts gid=5,mode=620 0 0
566 none /proc proc defaults 0 0
567 none /sys sysfs defaults 0 0
573 #for i in 0 1 2 3 4 5 6 7 8; do rm -f ram${i} ; done
574 #for i in 0 1 2 3 4 5 6 7 8; do mknod ram${i} b 1 ${i} ; done
579 # update etc/inittab to start with pl_rsysinit
580 for file in etc/inittab etc/event.d/rcS etc/init/rcS.conf; do
581 [ -f $file ] && sed -i 's,pl_sysinit,pl_rsysinit,' $file
584 # modify inittab to have a serial console
585 # xxx this might well be broken with f12 and above xxx
586 if [ -n "$serial" ] ; then
587 echo "T0:23:respawn:/sbin/agetty -L $console_dev $console_baud vt100" >> etc/inittab
588 # and let root log in
589 echo "$console_dev" >> etc/securetty
592 # calculate the size of /tmp based on the size of /etc & /var + 8MB slack
593 etcsize=$(du -s ./etc | awk '{ print $1 }')
594 varsize=$(du -s ./var | awk '{ print $1 }')
595 let msize=($varsize+$etcsize+8192)/1024
597 # make dhclient happy
598 for i in $(seq 0 9); do ln -fs /tmp/etc/dhclient-eth${i}.conf etc/dhclient-eth${i}.conf ; done
599 ln -fs /tmp/etc/resolv.conf etc/resolv.conf
600 ln -fs /tmp/etc/resolv.conf.predhclient etc/resolv.conf.predhclient
602 # generate pl_rsysinit
603 cat > etc/rc.d/init.d/pl_rsysinit <<EOF
605 # generated by $COMMAND
606 echo -n "pl_rsysinit: preparing /etc and /var for pl_sysinit..."
607 mount -t tmpfs -orw,size=${msize}M,mode=1777 tmpfs /tmp
610 touch /tmp/etc/resolv.conf
615 echo "tmpfs /tmp tmpfs rw,size=${msize}M,mode=1777 1 1" > /tmp/etc/mtab
617 # copy over directory contents of all _o directories from /etc and /var
618 # /tmp/etc and /tmp/var
620 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
623 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
628 # hand over to pl_sysinit
629 echo "pl_rsysinit: handing over to pl_sysinit"
630 /etc/init.d/pl_sysinit
632 chmod +x etc/rc.d/init.d/pl_rsysinit
636 # create the cramfs image
637 echo "* Creating cramfs image"
638 mkfs.cramfs $tmp/ ${BUILDTMP}/cramfs.img
639 cramfs_size=$(($(du -sk ${BUILDTMP}/cramfs.img | awk '{ print $1; }') + 1))
644 #################### Create ISO CRAMFS image
645 function build_iso_cramfs() {
646 local iso="$1" ; shift
649 prepare_cramfs "$custom"
650 echo "* Creating ISO CRAMFS-based image"
652 local tmp="${BUILDTMP}/cramfs-iso"
654 push_cleanup rm -rf $tmp
655 (cd $ISOFS && find . | grep -v "\.img$" | cpio -p -d -u $tmp/)
656 cat >$tmp/isolinux.cfg <<EOF
657 ${console_serial_line}
659 DEFAULT planetlab-bootcd
661 LABEL planetlab-bootcd
664 APPEND ramdisk_size=$ramdisk_size initrd=cramfs.img root=/dev/ram0 rw ${KERNEL_ARGS}
667 cp ${BUILDTMP}/cramfs.img $tmp
676 #################### Create USB CRAMFS based image
677 function build_usb_cramfs() {
678 local usb="$1" ; shift
681 prepare_cramfs "$custom"
682 echo "* Creating USB CRAMFS based image"
684 let vfat_size=${cramfs_size}+$FREE_SPACE
686 # Make VFAT filesystem for USB
687 mkfs.vfat -C "$usb" $vfat_size
690 echo "* Populating USB with overlay images and cramfs"
691 mcopy -bsQ -i "$usb" $ISOFS/kernel $ISOFS/pl_version ::/
692 mcopy -bsQ -i "$usb" ${BUILDTMP}/cramfs.img ::/
694 # Use syslinux instead of isolinux to make the image bootable
695 tmp="${BUILDTMP}/syslinux.cfg"
697 ${console_serial_line}
699 DEFAULT planetlab-bootcd
701 LABEL planetlab-bootcd
704 APPEND ramdisk_size=$ramdisk_size initrd=cramfs.img root=/dev/ram0 rw ${KERNEL_ARGS}
707 mcopy -bsQ -i "$usb" "$tmp" ::/syslinux.cfg
710 echo "* Making USB CRAMFS based image bootable"
714 #################### map on all types provided on the command-line and invoke one of the above functions
715 function build_types () {
717 [ -z "$OUTPUT_BASE" ] && OUTPUT_BASE="$PLC_NAME-BootCD-$BOOTCD_VERSION"
719 # alter output filename to reflect serial settings
720 if [ -n "$IS_SERIAL" ] ; then
721 if [ "$CONSOLE_INFO" == "$SERIAL_CONSOLE" ] ; then
724 serial="-serial-$(echo $CONSOLE_INFO | sed -e 's,:,,g')"
730 function type_to_name() {
733 s/usb_partition$/-partition.usb/;
735 s/usb_cramfs$/-cramfs.usb/;
736 s/iso_cramfs$/-cramfs.iso/;
743 tname=`type_to_name $t`
744 # if -o is specified (as it has no default)
745 if [ -n "$OUTPUT_NAME" ] ; then
748 output="${OUTPUT_BASE}${serial}${tname}"
751 echo "*** Dealing with type=$arg"
752 echo '*' build_$t "$output" "$CUSTOM_DIR"
753 [ -n "$DRY_RUN" ] || build_$t "$output" "$CUSTOM_DIR"
760 parse_command_line "$@"
764 echo "* Building bootcd images for $NODE_CONFIGURATION_FILE ($FULL_VERSION_STRING) - $(date +%H-%M:%S)"
765 # Do not tolerate errors
767 trap "do_cleanup" ERR INT EXIT
769 init_serial $CONSOLE_INFO
773 echo "* Done with bootcd images for $NODE_CONFIGURATION_FILE - $(date +%H-%M:%S)"