X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=build.sh;h=cfce5e27812ba6544175f337e459a023fc04de62;hb=501b7ec43b05cf01627773c798cee8cf7cb14619;hp=05359624b7751d9f74a2dc7902ae83cc9d52d484;hpb=f4e17d1070752d5fc5450b725a97200047e5057d;p=bootcd.git diff --git a/build.sh b/build.sh index 0535962..cfce5e2 100755 --- a/build.sh +++ b/build.sh @@ -10,6 +10,8 @@ # $Id$ # +COMMAND=$(basename $0) +DIRNAME=$(dirname $0) PATH=/sbin:/bin:/usr/sbin:/usr/bin # defaults @@ -77,41 +79,36 @@ function pop_cleanup() { function init_and_check () { # Change to our source directory - local srcdir=$(cd $(dirname $0) && pwd -P) + local srcdir=$(cd $DIRNAME && pwd -P) pushd $srcdir # Root of the isofs - ISOREF=$PWD/build + ISOREF=$PWD/${VARIANT} # The reference image is expected to have been built by prep.sh (see .spec) # we disable the initial logic that called prep.sh if that was not the case # this is because prep.sh needs to know pldistro if [ ! -f $ISOREF/isofs/bootcd.img -o ! -f $ISOREF/version.txt ] ; then - echo "You have to run prep.sh prior to calling $0 - exiting" + echo "Could not find isofs and version.txt in $ISOREF" + if [ "$VARIANT" == "build" ] ; then + echo "You have to run prep.sh prior to calling $COMMAND" + else + echo "You need to create your variant image, see kvariant.sh" + fi + echo "Exiting .." exit 1 fi # build/version.txt written by prep.sh - BOOTCD_VERSION=$(cat build/version.txt) + BOOTCD_VERSION=$(cat ${VARIANT}/version.txt) if [ -f /etc/planetlab/plc_config ] ; then # Source PLC configuration . /etc/planetlab/plc_config fi - # From within a myplc chroot /usr/tmp is too small - # to build all possible images, whereas /data is part of the host - # filesystem and usually has sufficient space. What we - # should do is check whether the expected amount of space - # is available. - BUILDTMP=/usr/tmp - if [ -d /data/tmp ] ; then - isreadonly=$(mktemp /data/tmp/isreadonly.XXXXXX || /bin/true) - if [ -n "$isreadonly" ] ; then - rm -f "$isreadonly" - BUILDTMP=/data/tmp - fi - fi + # use /var/tmp that should be large enough on both chroot- or vserver-based myplc + BUILDTMP=/var/tmp FULL_VERSION_STRING="${PLC_NAME} BootCD ${BOOTCD_VERSION}" @@ -127,7 +124,7 @@ function init_and_check () { # it seems that this feature has not been used nor tested in a long time, use with care usage() { - echo "Usage: build.sh [OPTION]..." + echo "Usage: $COMMAND [OPTION]..." echo " -f plnode.txt Node to customize CD for (default: none)" echo " -t 'types' Build the specified images (default: $DEFAULT_TYPES)" echo " NOTE: mentioning 'serial' as part of the type is not supported anymore" @@ -141,6 +138,7 @@ usage() { echo " can be a full path" echo " -o output-name The full name of the generated file" echo " -C custom-dir Custom directory" + echo " -V variant Use a variant - see kvariant.sh" echo " -n Dry run - mostly for debug/test purposes" echo " -k Add additional parameters to the kargs.txt file" echo " -h This message" @@ -154,7 +152,7 @@ function parse_command_line () { # init TYPES="" # Get options - while getopts "f:t:as:SO:o:C:k:nh" opt ; do + while getopts "f:t:as:SO:o:C:V:k:nh" opt ; do case $opt in f) NODE_CONFIGURATION_FILE=$OPTARG ;; t) TYPES="$TYPES $OPTARG" ;; @@ -164,7 +162,8 @@ function parse_command_line () { O) OUTPUT_BASE="$OPTARG" ;; o) OUTPUT_NAME="$OPTARG" ;; C) CUSTOM_DIR="$OPTARG" ;; - k) KARGS_STR="$OPTARG" ;; + V) VARIANT="$OPTARG" ;; + k) KARGS_STR="$KARGS_STR $OPTARG" ;; n) DRY_RUN=true ;; h|*) usage ;; esac @@ -172,6 +171,7 @@ function parse_command_line () { # use defaults if not set [ -z "$TYPES" ] && TYPES="$DEFAULT_TYPES" + [ -z "$VARIANT" ] && VARIANT="build" [ "$CONSOLE_INFO" == "default" ] && CONSOLE_INFO=$SERIAL_CONSOLE # check TYPES @@ -308,12 +308,15 @@ EOF fi # build/passwd copied out by prep.sh - sed -e "s@^root:[^:]*:\(.*\)@root:$ROOT_PASSWORD:\1@" build/passwd >$OVERLAY/etc/passwd + sed -e "s@^root:[^:]*:\(.*\)@root:$ROOT_PASSWORD:\1@" ${VARIANT}/passwd >$OVERLAY/etc/passwd # Install node configuration file (e.g., if node has no floppy disk or USB slot) if [ -f "$NODE_CONFIGURATION_FILE" ] ; then echo "* Installing node configuration file $NODE_CONFIGURATION_FILE -> /usr/boot/plnode.txt of the bootcd image" install -D -m 644 $NODE_CONFIGURATION_FILE $OVERLAY/usr/boot/plnode.txt + NODE_ID=$(source $NODE_CONFIGURATION_FILE; echo $NODE_ID) + echo "* Building network configuration for $NODE_ID" + plnet -- --root $OVERLAY --files-only --program BootCD $NODE_ID fi if [ -n "$IS_SERIAL" ] ; then @@ -363,9 +366,7 @@ EOF # Create ISO image echo "* Creating ISO image" - mkisofs -o "$iso" \ - $MKISOFS_OPTS \ - $ISOFS + mkisofs -o "$iso" $MKISOFS_OPTS $ISOFS } #################### USB with partitions @@ -427,6 +428,7 @@ function build_usb() { local usb="$1" ; shift local custom="$1" + rm -f "$usb" mkfs.vfat -C "$usb" $(($(du -Lsk $ISOFS | awk '{ print $1; }') + $FREE_SPACE)) # Populate it @@ -541,7 +543,7 @@ EOF # generate pl_rsysinit cat > etc/rc.d/init.d/pl_rsysinit <