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
11 COMMAND=$(basename $0)
13 PATH=/sbin:/bin:/usr/sbin:/usr/bin
16 # keep KERNEL_DEBUG_ARGS void for production
18 # and uncomment these to augment verbosity of boot phase
19 # not everything works or is helpful, but well
20 #KERNEL_DEBUG_ARGS="$KERNEL_DEBUG_ARGS debuginitrd showerr"
21 #KERNEL_DEBUG_ARGS="$KERNEL_DEBUG_ARGS earlyprintk=vga loglevel=6"
22 # for systemd - might slow down boot
23 #KERNEL_DEBUG_ARGS="$KERNEL_DEBUG_ARGS systemd.log_level=debug systemd.journald.forward_to_console=1"
27 DEFAULT_TYPES="usb iso"
28 # Leave 4 MB of free space
29 GRAPHIC_CONSOLE="graphic"
30 SERIAL_CONSOLE="ttyS0:115200:n:8"
31 CONSOLE_INFO=$GRAPHIC_CONSOLE
32 MKISOFS_OPTS="-R -J -r -f -b isolinux.bin -c boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table"
33 #isolinux-debug.bin is supposedly helpful as well if available,
34 # when things don't work as expected
35 #MKISOFS_OPTS="-R -J -r -f -b isolinux-debug.bin -c boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table"
38 # command-line settable args
39 NODE_CONFIGURATION_FILE=
49 FULL_VERSION_STRING=""
57 console_serial_line=""
60 #################### compute all supported types
61 # removing support for serial in the type
62 # this is because kargs.txt goes in the overlay, that is computed only once
63 # so we cannot handle serial and graphic modes within the same invokation of this script
66 for x in iso usb usb_partition; do for c in "" "_cramfs" ; do
73 ALL_TYPES="$ALL_TYPES $t" ;;
77 #################### cleanup utilities
78 declare -a _CLEANUPS=()
79 function do_cleanup() {
80 cd / ; for i in "${_CLEANUPS[@]}"; do $i ; done
82 function push_cleanup() {
83 _CLEANUPS=( "${_CLEANUPS[@]}" "$*" )
85 function pop_cleanup() {
86 unset _CLEANUPS[$((${#_CLEANUPS[@]} - 1))]
89 #################### initialization
90 function init_and_check () {
92 # Change to our source directory
93 local srcdir=$(cd $DIRNAME && pwd -P)
97 ISOREF=$PWD/${VARIANT}
99 # The reference image is expected to have been built by prep.sh (see .spec)
100 # we disable the initial logic that called prep.sh if that was not the case
101 # this is because prep.sh needs to know pldistro
102 if [ ! -f $ISOREF/isofs/bootcd.img -o ! -f $ISOREF/version.txt ] ; then
103 echo "Could not find isofs and version.txt in $ISOREF"
104 if [ "$VARIANT" == "build" ] ; then
105 echo "You have to run prep.sh prior to calling $COMMAND"
107 echo "You need to create your variant image, see kvariant.sh"
113 # build/version.txt written by prep.sh
114 BOOTCD_VERSION=$(cat ${VARIANT}/version.txt)
116 if [ -f /etc/planetlab/plc_config ] ; then
117 # Source PLC configuration
118 . /etc/planetlab/plc_config
121 # use /var/tmp that should be large enough on both chroot- or vserver-based myplc
124 FULL_VERSION_STRING="${PLC_NAME} BootCD ${BOOTCD_VERSION}"
129 # the custom-dir feature is designed to let a myplc try/ship a patched bootcd
130 # without the need for a full devel environment
131 # for example, you would create /root/custom-bootcd/etc/rc.d/init.d/pl_hwinit
132 # and run this script with -C /root/custom-bootcd
133 # this creates a third .img image of the custom dir, that 'hides' the files from
134 # bootcd.img in the resulting unionfs
135 # it seems that this feature has not been used nor tested in a long time, use with care
138 echo "Usage: $COMMAND [OPTION]..."
139 echo " -f plnode.txt Node to customize CD for (default: none)"
140 echo " -t 'types' Build the specified images (default: $DEFAULT_TYPES)"
141 echo " NOTE: mentioning 'serial' as part of the type is not supported anymore"
142 echo " -a Build all known types as listed below"
143 echo " -s console-info Enable a serial line as console and also bring up getty on that line"
144 echo " console-info: tty:baud-rate:parity:bits"
145 echo " or 'default' shortcut for $SERIAL_CONSOLE"
146 echo " -S equivalent to -s default"
147 echo " -O output-base The prefix of the generated files (default: PLC_NAME-BootCD-VERSION)"
148 echo " useful when multiple types are provided"
149 echo " can be a full path"
150 echo " -o output-name The full name of the generated file"
151 echo " -C custom-dir Custom directory"
152 echo " -V variant Use a variant - see kvariant.sh"
153 echo " -n Dry run - mostly for debug/test purposes"
154 echo " -k Add additional parameters to the kargs.txt file"
155 echo " -h This message"
156 echo "All known types: $ALL_TYPES"
161 function parse_command_line () {
166 while getopts "f:t:as:SO:o:C:V:k:nh" opt ; do
168 f) NODE_CONFIGURATION_FILE=$OPTARG ;;
169 t) TYPES="$TYPES $OPTARG" ;;
170 a) TYPES="$ALL_TYPES" ;;
171 s) CONSOLE_INFO="$OPTARG" ;;
172 S) CONSOLE_INFO=$SERIAL_CONSOLE ;;
173 O) OUTPUT_BASE="$OPTARG" ;;
174 o) OUTPUT_NAME="$OPTARG" ;;
175 C) CUSTOM_DIR="$OPTARG" ;;
176 V) VARIANT="$OPTARG" ;;
177 k) KERNEL_ARGS="$KERNEL_ARGS $OPTARG" ;;
183 # use defaults if not set
184 [ -z "$TYPES" ] && TYPES="$DEFAULT_TYPES"
185 [ -z "$VARIANT" ] && VARIANT="build"
186 [ "$CONSOLE_INFO" == "default" ] && CONSOLE_INFO=$SERIAL_CONSOLE
188 if [ -n "$NODE_CONFIGURATION_FILE" ] ; then
189 # check existence of NODE_CONFIGURATION_FILE and normalize as we will change directory
190 if [ ! -f "$NODE_CONFIGURATION_FILE" ] ; then
191 echo "Node configuration file $NODE_CONFIGURATION_FILE not found - exiting"
194 cf_dir="$(dirname $NODE_CONFIGURATION_FILE)"
195 cf_dir="$(cd $cf_dir; pwd -P)"
196 cf_file="$(basename $NODE_CONFIGURATION_FILE)"
197 NODE_CONFIGURATION_FILE="$cf_dir"/"$cf_file"
201 local matcher="XXX$(echo $ALL_TYPES | sed -e 's,\W,XXX,g')XXX"
203 echo Checking type $t
204 echo $matcher | grep XXX${t}XXX &> /dev/null
205 if [ "$?" != 0 ] ; then
214 function init_serial () {
215 local console=$1; shift
216 if [ "$console" == "$GRAPHIC_CONSOLE" ] ; then
219 echo "Standard, graphic, non-serial mode"
222 console_dev=$(echo "$console" | awk -F: ' {print $1}')
223 console_baud=$(echo "$console" | awk -F: ' {print $2}')
224 [ -z "$console_baud" ] && console_baud="115200"
225 local console_parity=$(echo "$console" | awk -F: ' {print $3}')
226 [ -z "$console_parity" ] && console_parity="n"
227 local console_bits=$(echo "$console" | awk -F: ' {print $4}')
228 [ -z "$console_bits" ] && console_bits="8"
229 console_spec="console=${console_dev},${console_baud}${console_parity}${console_bits}"
230 local tty_nb=$(echo $console_dev | sed -e 's,[a-zA-Z],,g')
231 console_serial_line="SERIAL ${tty_nb} ${console_baud}"
233 echo "console_serial_line=${console_serial_line}"
234 echo "console_spec=${console_spec}"
238 #################### run once : build the overlay image
239 function build_overlay () {
241 BUILDTMP=$(mktemp -d ${BUILDTMP}/bootcd.XXXXXX)
242 push_cleanup rm -fr "${BUILDTMP}"
245 ISOFS="${BUILDTMP}/isofs"
247 for i in "$ISOREF"/isofs/{bootcd.img,kernel}; do
250 # use new location as of fedora 12
251 # used to be in /usr/lib/syslinux/isolinux.bin
252 # removed backward compat in jan. 2015
253 # as of syslinux 5.0 (fedora 21) ldlinux.c32 is required by isolinux.bin
254 # the debug version can come in handy at times, and is 40k as well
255 isolinuxdir="/usr/share/syslinux"
256 isolinuxfiles="isolinux.bin ldlinux.c32 isolinux-debug.bin memdisk"
257 for isolinuxfile in $isolinuxfiles; do
258 [ -f $isolinuxdir/$isolinuxfile ] && cp $isolinuxdir/$isolinuxfile "${BUILDTMP}/isofs"
261 # Root of the ISO and USB images
262 echo "* Populating root filesystem..."
263 OVERLAY="${BUILDTMP}/overlay"
264 install -d -m 755 $OVERLAY
265 push_cleanup rm -fr $OVERLAY
267 # Create version files
268 echo "* Creating version files"
270 # Boot Manager compares pl_version in both places to make sure that
271 # the right CD is mounted. We used to boot from an initrd and mount
272 # the CD on /usr. Now we just run everything out of the initrd.
273 for file in $OVERLAY/pl_version $OVERLAY/usr/isolinux/pl_version ; do
274 mkdir -p $(dirname $file)
275 echo "$FULL_VERSION_STRING" >$file
278 # Install boot server configuration files
279 echo "* Installing boot server configuration files"
281 # We always intended to bring up and support backup boot servers,
282 # but never got around to it. Just install the same parameters for
284 for dir in $OVERLAY/usr/boot $OVERLAY/usr/boot/backup ; do
285 install -D -m 644 $PLC_BOOT_CA_SSL_CRT $dir/cacert.pem
286 install -D -m 644 $PLC_ROOT_GPG_KEY_PUB $dir/pubring.gpg
287 echo "$PLC_BOOT_HOST" >$dir/boot_server
288 echo "$PLC_BOOT_SSL_PORT" >$dir/boot_server_port
289 echo "/boot/" >$dir/boot_server_path
292 # Install old-style boot server configuration files
293 # as opposed to what a former comment suggested,
294 # this is still required, somewhere in the bootmanager apparently
295 install -D -m 644 $PLC_BOOT_CA_SSL_CRT $OVERLAY/usr/bootme/cacert/$PLC_BOOT_HOST/cacert.pem
296 echo "$FULL_VERSION_STRING" >$OVERLAY/usr/bootme/ID
297 echo "$PLC_BOOT_HOST" >$OVERLAY/usr/bootme/BOOTSERVER
298 echo "$PLC_BOOT_HOST" >$OVERLAY/usr/bootme/BOOTSERVER_IP
299 echo "$PLC_BOOT_SSL_PORT" >$OVERLAY/usr/bootme/BOOTPORT
301 # Generate /etc/issue
302 echo "* Generating /etc/issue"
304 if [ "$PLC_WWW_PORT" = "443" ] ; then
305 PLC_WWW_URL="https://$PLC_WWW_HOST/"
306 elif [ "$PLC_WWW_PORT" != "80" ] ; then
307 PLC_WWW_URL="http://$PLC_WWW_HOST:$PLC_WWW_PORT/"
309 PLC_WWW_URL="http://$PLC_WWW_HOST/"
312 mkdir -p $OVERLAY/etc
313 cat >$OVERLAY/etc/issue <<EOF
319 This machine is a node in the $PLC_NAME distributed network. It has
320 not fully booted yet. If you have cancelled the boot process at the
321 request of $PLC_NAME Support, please follow the instructions provided
322 to you. Otherwise, please contact $PLC_MAIL_SUPPORT_ADDRESS.
324 Console login at this point is restricted to root. Provide the root
325 password of the default $PLC_NAME Central administrator account at the
326 time that this CD was created.
331 echo "* Setting root password"
333 if [ -z "$ROOT_PASSWORD" ] ; then
334 # Generate an encrypted password with crypt() if not defined
335 # in a static configuration.
336 ROOT_PASSWORD=$(python <<EOF
337 import crypt, random, string
338 salt = [random.choice(string.letters + string.digits + "./") for i in range(0,8)]
339 print crypt.crypt('$PLC_ROOT_PASSWORD', '\$1\$' + "".join(salt) + '\$')
344 # build/passwd copied out by prep.sh
345 sed -e "s@^root:[^:]*:\(.*\)@root:$ROOT_PASSWORD:\1@" ${VARIANT}/passwd >$OVERLAY/etc/passwd
347 # Install node configuration file (e.g., if node has no floppy disk or USB slot)
348 if [ -f "$NODE_CONFIGURATION_FILE" ] ; then
349 echo "* Installing node configuration file $NODE_CONFIGURATION_FILE -> /usr/boot/plnode.txt of the bootcd image"
350 install -D -m 644 $NODE_CONFIGURATION_FILE $OVERLAY/usr/boot/plnode.txt
351 NODE_ID=$(source $NODE_CONFIGURATION_FILE; echo $NODE_ID)
352 echo "* Building network configuration for $NODE_ID"
353 plnet -- --root $OVERLAY --files-only --program BootCD $NODE_ID
356 [ -n "$IS_SERIAL" ] && KERNEL_ARGS="$KERNEL_ARGS ${console_spec}"
358 # tmp: should be restricted to f15 nodes and above
359 # making sure the network interfaces are still numbered eth0 and above
360 KERNEL_ARGS="$KERNEL_ARGS biosdevname=0"
361 # making sure selinux is turned off - somehow this is needed with lxc/f14
362 KERNEL_ARGS="$KERNEL_ARGS selinux=0"
363 # cannot use this mecahnism to set systemd default target because this applies to kexec boots as well
364 # # set default target for systemd
365 # KERNEL_ARGS="$KERNEL_ARGS systemd.unit=pl_boot.target"
366 # output more systemd-related messages on the console
367 KERNEL_ARGS="$KERNEL_ARGS systemd.log_target=console"
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 APPEND ramdisk_size=$ramdisk_size initrd=bootcd.img,overlay.img${custom:+,custom.img} root=/dev/ram0 rw ${KERNEL_ARGS}
410 echo "* Creating ISO image in $(pwd)"
411 mkisofs -o "$iso" $MKISOFS_OPTS $ISOFS
414 #################### USB with partitions
415 function build_usb_partition() {
416 echo -n "* Creating USB image with partitions..."
417 local usb="$1" ; shift
420 local size=$(($(du -Lsk $ISOFS | awk '{ print $1; }') + $FREE_SPACE))
421 size=$(( $size / 1024 ))
425 local cylinders=$(( ($size*1024*2)/($heads*$sectors) ))
426 local offset=$(( $sectors*512 ))
428 if [ -f /usr/lib/syslinux/mkdiskimage ] ; then
429 /usr/lib/syslinux/mkdiskimage -M -4 "$usb" $size $heads $sectors
431 mkdiskimage -M -4 "$usb" $size $heads $sectors
434 cat >${BUILDTMP}/mtools.conf<<EOF
444 # environment variable for mtools
445 export MTOOLSRC="${BUILDTMP}/mtools.conf"
447 ### COPIED FROM build_usb() below!!!!
448 echo -n " populating USB image... "
449 mcopy -bsQ -i "$usb" "$ISOFS"/* z:/
451 # Use syslinux instead of isolinux to make the image bootable
452 tmp="${BUILDTMP}/syslinux.cfg"
454 ${console_serial_line}
456 APPEND ramdisk_size=$ramdisk_size initrd=bootcd.img,overlay.img${custom:+,custom.img} root=/dev/ram0 rw ${KERNEL_ARGS}
461 mdel -i "$usb" z:/isolinux.cfg 2>/dev/null || :
462 mcopy -i "$usb" "$tmp" z:/syslinux.cfg
467 echo "making USB image bootable."
468 syslinux -o $offset "$usb"
472 #################### plain USB
473 function build_usb() {
474 echo -n "* Creating USB image... "
475 local usb="$1" ; shift
479 mkfs.vfat -C "$usb" $(($(du -Lsk $ISOFS | awk '{ print $1; }') + $FREE_SPACE))
481 cat >${BUILDTMP}/mtools.conf<<EOF
484 # environment variable for mtools
485 export MTOOLSRC="${BUILDTMP}/mtools.conf"
488 echo -n " populating USB image... "
489 mcopy -bsQ -i "$usb" "$ISOFS"/* ::/
491 # Use syslinux instead of isolinux to make the image bootable
492 tmp="${BUILDTMP}/syslinux.cfg"
494 ${console_serial_line}
496 APPEND ramdisk_size=$ramdisk_size initrd=bootcd.img,overlay.img${custom:+,custom.img} root=/dev/ram0 rw ${KERNEL_ARGS}
501 mdel -i "$usb" ::/isolinux.cfg 2>/dev/null || :
502 mcopy -i "$usb" "$tmp" ::/syslinux.cfg
507 echo "making USB image bootable."
511 #################### utility to setup CRAMFS related support
512 function prepare_cramfs() {
513 [ -n "$CRAMFS_PREPARED" ] && return 0
516 echo "* Setting up CRAMFS-based images"
517 local tmp="${BUILDTMP}/cramfs-tree"
519 push_cleanup rm -rf $tmp
521 gzip -d -c $ISOFS/bootcd.img | cpio -diu
522 gzip -d -c $ISOFS/overlay.img | cpio -diu
523 [ -n "$custom" ] && \
524 gzip -d -c $ISOFS/custom.img | cpio -diu
526 # clean out unnecessary rpm lib
527 echo "* clearing var/lib/rpm/*"
530 # bootcd requires this directory
531 mkdir -p mnt/confdevice
533 # relocate various directory to /tmp
535 ln -fs /tmp/root root
536 ln -fs /sbin/init linuxrc
537 ln -fs /tmp/resolv.conf etc/resolv.conf
538 ln -fs /tmp/etc/mtab etc/mtab
540 # have pl_rsysinit copy over appropriate etc & var directories into /tmp/etc/
542 echo "* renaming dirs in ./etc"
544 for dir in `find * -type d -prune | grep -v rc.d`; do
546 ln -fs /tmp/etc/${dir} ${dir}
550 echo "* renaming dirs in ./var"
551 # rename all top-level directories and put in a symlink to /tmp/var
553 for dir in `find * -type d -prune`; do
555 ln -fs /tmp/var/${dir} ${dir}
559 # overwrite fstab to mount / as cramfs and /tmp as tmpfs
560 echo "* Overwriting etc/fstab to use cramfs and tmpfs"
562 cat >./etc/fstab <<EOF
563 /dev/ram0 / cramfs ro 0 0
564 none /dev/pts devpts gid=5,mode=620 0 0
565 none /proc proc defaults 0 0
566 none /sys sysfs defaults 0 0
572 #for i in 0 1 2 3 4 5 6 7 8; do rm -f ram${i} ; done
573 #for i in 0 1 2 3 4 5 6 7 8; do mknod ram${i} b 1 ${i} ; done
578 # update etc/inittab to start with pl_rsysinit
579 for file in etc/inittab etc/event.d/rcS etc/init/rcS.conf; do
580 [ -f $file ] && sed -i 's,pl_sysinit,pl_rsysinit,' $file
583 # modify inittab to have a serial console
584 # xxx this might well be broken with f12 and above xxx
585 if [ -n "$serial" ] ; then
586 echo "T0:23:respawn:/sbin/agetty -L $console_dev $console_baud vt100" >> etc/inittab
587 # and let root log in
588 echo "$console_dev" >> etc/securetty
591 # calculate the size of /tmp based on the size of /etc & /var + 8MB slack
592 etcsize=$(du -s ./etc | awk '{ print $1 }')
593 varsize=$(du -s ./var | awk '{ print $1 }')
594 let msize=($varsize+$etcsize+8192)/1024
596 # make dhclient happy
597 for i in $(seq 0 9); do ln -fs /tmp/etc/dhclient-eth${i}.conf etc/dhclient-eth${i}.conf ; done
598 ln -fs /tmp/etc/resolv.conf etc/resolv.conf
599 ln -fs /tmp/etc/resolv.conf.predhclient etc/resolv.conf.predhclient
601 # generate pl_rsysinit
602 cat > etc/rc.d/init.d/pl_rsysinit <<EOF
604 # generated by $COMMAND
605 echo -n "pl_rsysinit: preparing /etc and /var for pl_sysinit..."
606 mount -t tmpfs -orw,size=${msize}M,mode=1777 tmpfs /tmp
609 touch /tmp/etc/resolv.conf
614 echo "tmpfs /tmp tmpfs rw,size=${msize}M,mode=1777 1 1" > /tmp/etc/mtab
616 # copy over directory contents of all _o directories from /etc and /var
617 # /tmp/etc and /tmp/var
619 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
622 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
627 # hand over to pl_sysinit
628 echo "pl_rsysinit: handing over to pl_sysinit"
629 /etc/init.d/pl_sysinit
631 chmod +x etc/rc.d/init.d/pl_rsysinit
635 # create the cramfs image
636 echo "* Creating cramfs image"
637 mkfs.cramfs $tmp/ ${BUILDTMP}/cramfs.img
638 cramfs_size=$(($(du -sk ${BUILDTMP}/cramfs.img | awk '{ print $1; }') + 1))
643 #################### Create ISO CRAMFS image
644 function build_iso_cramfs() {
645 local iso="$1" ; shift
648 prepare_cramfs "$custom"
649 echo "* Creating ISO CRAMFS-based image"
651 local tmp="${BUILDTMP}/cramfs-iso"
653 push_cleanup rm -rf $tmp
654 (cd $ISOFS && find . | grep -v "\.img$" | cpio -p -d -u $tmp/)
655 cat >$tmp/isolinux.cfg <<EOF
656 ${console_serial_line}
658 APPEND ramdisk_size=$cramfs_size initrd=cramfs.img root=/dev/ram0 ro ${KERNEL_ARGS}
664 cp ${BUILDTMP}/cramfs.img $tmp
673 #################### Create USB CRAMFS based image
674 function build_usb_cramfs() {
675 local usb="$1" ; shift
678 prepare_cramfs "$custom"
679 echo "* Creating USB CRAMFS based image"
681 let vfat_size=${cramfs_size}+$FREE_SPACE
683 # Make VFAT filesystem for USB
684 mkfs.vfat -C "$usb" $vfat_size
687 echo "* Populating USB with overlay images and cramfs"
688 mcopy -bsQ -i "$usb" $ISOFS/kernel $ISOFS/pl_version ::/
689 mcopy -bsQ -i "$usb" ${BUILDTMP}/cramfs.img ::/
691 # Use syslinux instead of isolinux to make the image bootable
692 tmp="${BUILDTMP}/syslinux.cfg"
694 ${console_serial_line}
696 APPEND ramdisk_size=$cramfs_size initrd=cramfs.img root=/dev/ram0 ro ${KERNEL_ARGS}
702 mcopy -bsQ -i "$usb" "$tmp" ::/syslinux.cfg
705 echo "* Making USB CRAMFS based image bootable"
709 #################### map on all types provided on the command-line and invoke one of the above functions
710 function build_types () {
712 [ -z "$OUTPUT_BASE" ] && OUTPUT_BASE="$PLC_NAME-BootCD-$BOOTCD_VERSION"
714 # alter output filename to reflect serial settings
715 if [ -n "$IS_SERIAL" ] ; then
716 if [ "$CONSOLE_INFO" == "$SERIAL_CONSOLE" ] ; then
719 serial="-serial-$(echo $CONSOLE_INFO | sed -e 's,:,,g')"
725 function type_to_name() {
728 s/usb_partition$/-partition.usb/;
730 s/usb_cramfs$/-cramfs.usb/;
731 s/iso_cramfs$/-cramfs.iso/;
738 tname=`type_to_name $t`
739 # if -o is specified (as it has no default)
740 if [ -n "$OUTPUT_NAME" ] ; then
743 output="${OUTPUT_BASE}${serial}${tname}"
746 echo "*** Dealing with type=$arg"
747 echo '*' build_$t "$output" "$CUSTOM_DIR"
748 [ -n "$DRY_RUN" ] || build_$t "$output" "$CUSTOM_DIR"
755 parse_command_line "$@"
759 echo "* Building images for $FULL_VERSION_STRING"
760 # Do not tolerate errors
762 trap "do_cleanup" ERR INT EXIT
764 init_serial $CONSOLE_INFO