Annotation of embedaddon/strongswan/testing/scripts/build-rootimage, revision 1.1

1.1     ! misho       1: #!/bin/bash
        !             2: # Create guest root image
        !             3: #
        !             4: # Copyright (C) 2004  Eric Marchionni, Patrik Rayo
        !             5: # Zuercher Hochschule Winterthur
        !             6: #
        !             7: # This program is free software; you can redistribute it and/or modify it
        !             8: # under the terms of the GNU General Public License as published by the
        !             9: # Free Software Foundation; either version 2 of the License, or (at your
        !            10: # option) any later version.  See <http://www.fsf.org/copyleft/gpl.txt>.
        !            11: #
        !            12: # This program is distributed in the hope that it will be useful, but
        !            13: # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
        !            14: # or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
        !            15: # for more details.
        !            16: 
        !            17: echo "Building root image"
        !            18: 
        !            19: DIR=$(dirname `readlink -f $0`)
        !            20: . $DIR/../testing.conf
        !            21: . $DIR/function.sh
        !            22: 
        !            23: [ `id -u` -eq 0 ] || die "You must be root to run $0"
        !            24: [ -f "$BASEIMG" ] || die "Base image $BASEIMG not found"
        !            25: running_any $STRONGSWANHOSTS && die "Please stop test environment before running $0"
        !            26: 
        !            27: check_commands partprobe qemu-img qemu-nbd
        !            28: 
        !            29: load_qemu_nbd
        !            30: 
        !            31: mkdir -p $LOOPDIR
        !            32: mkdir -p $SHAREDDIR/compile
        !            33: mkdir -p $IMGDIR
        !            34: 
        !            35: log_action "Creating root image $ROOTIMG"
        !            36: execute "qemu-img create -b $BASEIMG -f $IMGEXT $ROOTIMG"
        !            37: 
        !            38: log_action "Connecting root image to NBD device $NBDEV"
        !            39: execute "qemu-nbd -c $NBDEV $ROOTIMG"
        !            40: do_on_exit qemu-nbd -d $NBDEV
        !            41: partprobe $NBDEV
        !            42: 
        !            43: log_action "Mounting $NBDPARTITION to $LOOPDIR"
        !            44: execute "mount $NBDPARTITION $LOOPDIR"
        !            45: do_on_exit umount $LOOPDIR
        !            46: 
        !            47: log_action "Mounting proc filesystem to $LOOPDIR/proc"
        !            48: execute "mount -t proc none $LOOPDIR/proc"
        !            49: do_on_exit umount $LOOPDIR/proc
        !            50: 
        !            51: mkdir -p $LOOPDIR/root/shared
        !            52: log_action "Mounting $SHAREDDIR as /root/shared"
        !            53: execute "mount -o bind $SHAREDDIR $LOOPDIR/root/shared"
        !            54: do_on_exit umount $LOOPDIR/root/shared
        !            55: 
        !            56: echo "Installing software from source"
        !            57: RECPDIR=$DIR/recipes
        !            58: if [ -d "$RECPDIR/patches" ]
        !            59: then
        !            60:        execute "cp -r $RECPDIR/patches $LOOPDIR/root/shared/compile" 0
        !            61: fi
        !            62: RECIPES=`ls $RECPDIR/*.mk | xargs -n1 basename`
        !            63: for r in $RECIPES
        !            64: do
        !            65:        cp $RECPDIR/$r ${LOOPDIR}/root/shared/compile
        !            66:        log_action "Installing from recipe $r"
        !            67:        execute_chroot "make SWANVERSION=$SWANVERSION -C /root/shared/compile -f $r"
        !            68: done
        !            69: 
        !            70: log_action "Removing /etc/resolv.conf"
        !            71: execute "rm -f $LOOPDIR/etc/resolv.conf"

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>