From cc787728a23488f6f5c16519ecd8db44a51fe500 Mon Sep 17 00:00:00 2001 From: Mark Huang Date: Sat, 2 Dec 2006 04:55:53 +0000 Subject: [PATCH] experimental build script for new build system --- newbuild.sh | 153 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 153 insertions(+) create mode 100755 newbuild.sh diff --git a/newbuild.sh b/newbuild.sh new file mode 100755 index 0000000..033d56e --- /dev/null +++ b/newbuild.sh @@ -0,0 +1,153 @@ +#!/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: build.sh,v 1.42 2006/11/22 20:40:48 mef 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 + +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 -- 2.43.0