X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=newbuild.sh;fp=newbuild.sh;h=47475826c8b3f5ba148fe0251cf7b737aa000d27;hb=d5019c8cd35d3ec4b5fee35744c8425f12aa7925;hp=0000000000000000000000000000000000000000;hpb=bd0b3cf306759c5aa5e43a88e4f030100dbac496;p=bootcd.git diff --git a/newbuild.sh b/newbuild.sh new file mode 100755 index 0000000..4747582 --- /dev/null +++ b/newbuild.sh @@ -0,0 +1,162 @@ +#!/bin/bash +# +# Builds custom BootCD ISO and USB images in the current +# directory. +# +# Mark Huang +# Copyright (C) 2004-2006 The Trustees of Princeton University +# +# $Id: newbuild.sh,v 1.2 2006/12/04 20:07:18 mlhuang Exp $ +# + +PATH=/sbin:/bin:/usr/sbin:/usr/bin + +BOOTCD_VERSION=4.0 + +if [ -f /etc/planetlab/plc_config ] ; then + # Source PLC configuration + . /etc/planetlab/plc_config +else + echo "Could not find /etc/planetlab/plc_config." + echo "This file defines the configuration of your PlanetLab installation." + exit 1 +fi + +# This support for backwards compatibility can be taken out in the +# future. RC1 based MyPLCs set $PLC_BOOT_SSL_CRT in the plc_config +# file, but >=RC2 based bootcd assumes that $PLC_BOOT_CA_SSL_CRT is +# set. +if [ -z "$PLC_BOOT_CA_SSL_CRT" -a ! -z "$PLC_BOOT_SSL_CRT" ] ; then + PLC_BOOT_CA_SSL_CRT=$PLC_BOOT_SSL_CRT + PLC_API_CA_SSL_CRT=$PLC_API_SSL_CRT +fi + +output="$PLC_NAME-BootCD-$BOOTCD_VERSION.iso" + +usage() +{ + echo "Usage: build.sh [OPTION]..." + eceho " -o file Output file (default: $output)" + echo " -h This message" + exit 1 +} + +# Get options +while getopts "o:h" opt ; do + case $opt in + o) + output=$OPTARG + ;; + h|*) + usage + ;; + esac +done + +FULL_VERSION_STRING="$PLC_NAME BootCD $BOOTCD_VERSION" +echo "* Building image for $FULL_VERSION_STRING" + +# Do not tolerate errors +set -e + +# Change to our source directory +srcdir=$(cd $(dirname $0) && pwd -P) +pushd $srcdir >/dev/null + +# Root of the isofs +isofs=$PWD/isofs + +# Miscellaneous files +misc=$(mktemp -d /tmp/misc.XXXXXX) +trap "rm -rf $misc" ERR INT + +# initramfs requires that /init be present +ln -sf /sbin/init $misc/init + +# Create version file +echo "$FULL_VERSION_STRING" >$misc/.bootcd + +# Install GPG, boot, and API server public keys and certificates +install -D -m 644 $PLC_ROOT_GPG_KEY_PUB $misc/$PLC_ROOT_GPG_KEY_PUB +install -D -m 644 $PLC_BOOT_CA_SSL_CRT $misc/$PLC_BOOT_CA_SSL_CRT +install -D -m 644 $PLC_API_CA_SSL_CRT $misc/$PLC_API_CA_SSL_CRT + +cat > $misc/etc/planetlab/plc_config <$misc/etc/issue <$isofs/misc.img + +rm -rf $misc +trap - ERR INT + +# Calculate ramdisk size (total uncompressed size of all initrds) +ramdisk_size=$(gzip -l $isofs/*.img | tail -1 | awk '{ print $2; }') # bytes +ramdisk_size=$((($ramdisk_size + 1023) / 1024)) # kilobytes + +# Write isolinux configuration +echo "$FULL_VERSION_STRING" >$isofs/version +cat >$isofs/isolinux.cfg </dev/null + +# Create ISO image +echo "* Creating ISO image" +mkisofs -o "$output" \ + -R -allow-leading-dots -J -r \ + -b isolinux.bin -c boot.cat \ + -no-emul-boot -boot-load-size 4 -boot-info-table \ + $isofs + +# XXX Create USB image + +exit 0