Unify naming of base,root image settings

This commit is contained in:
Reto Buerki
2013-01-17 16:54:55 +01:00
committed by Tobias Brunner
parent aba43136c2
commit 258cbd40cf
6 changed files with 39 additions and 33 deletions
+7 -7
View File
@@ -23,17 +23,17 @@ APTCACHE=$LOOPDIR/var/cache/apt/archives
mkdir -p $LOOPDIR mkdir -p $LOOPDIR
mkdir -p $BUILDDIR mkdir -p $BUILDDIR
mkdir -p $CACHEDIR mkdir -p $CACHEDIR
rm -f $ROOTFS rm -f $BASEIMG
echo "`date`, building $ROOTFS" >>$LOGFILE echo "`date`, building $BASEIMG" >>$LOGFILE
load_qemu_nbd load_qemu_nbd
log_action "Creating image $ROOTFS" log_action "Creating base image $BASEIMG"
execute "qemu-img create -f qcow2 $ROOTFS ${ROOTFSSIZE}M" execute "qemu-img create -f $IMGEXT $BASEIMG ${BASEIMGSIZE}M"
log_action "Connecting image to NBD device $NBDEV" log_action "Connecting image to NBD device $NBDEV"
execute "qemu-nbd -c $NBDEV $ROOTFS" execute "qemu-nbd -c $NBDEV $BASEIMG"
do_on_exit qemu-nbd -d $NBDEV do_on_exit qemu-nbd -d $NBDEV
log_action "Partitioning disk" log_action "Partitioning disk"
@@ -61,8 +61,8 @@ mkdir -p $APTCACHE
execute "mount -o bind $CACHEDIR $APTCACHE" execute "mount -o bind $CACHEDIR $APTCACHE"
do_on_exit graceful_umount $APTCACHE do_on_exit graceful_umount $APTCACHE
log_action "Running debootstrap ($ROOTFSSUITE, $ROOTFSARCH)" log_action "Running debootstrap ($BASEIMGSUITE, $BASEIMGARCH)"
execute "debootstrap --arch=$ROOTFSARCH --include=$INC --exclude $EXC $ROOTFSSUITE $LOOPDIR $ROOTFSMIRROR" execute "debootstrap --arch=$BASEIMGARCH --include=$INC --exclude $EXC $BASEIMGSUITE $LOOPDIR $BASEIMGMIRROR"
for service in $SERVICES for service in $SERVICES
do do
+4 -4
View File
@@ -20,10 +20,9 @@ echo "Creating guest images"
[ `id -u` -eq 0 ] || die "You must be root to run $0" [ `id -u` -eq 0 ] || die "You must be root to run $0"
BASE=$BUILDDIR/base.qcow2
HOSTSDIR=$PWD/hosts HOSTSDIR=$PWD/hosts
[ -f $BASE ] || die "Base image $BASE not found" [ -f $ROOTIMG ] || die "Root image $ROOTIMG not found"
[ -f $HOSTDIR ] || die "Hosts directory $HOSTSDIR not found" [ -f $HOSTDIR ] || die "Hosts directory $HOSTSDIR not found"
check_commands partprobe qemu-img qemu-nbd check_commands partprobe qemu-img qemu-nbd
@@ -32,6 +31,7 @@ load_qemu_nbd
mkdir -p $BUILDDIR mkdir -p $BUILDDIR
mkdir -p $LOOPDIR mkdir -p $LOOPDIR
mkdir -p $GUESTIMGDIR
if [ "$#" -eq 0 ]; then if [ "$#" -eq 0 ]; then
HOSTS=$STRONGSWANHOSTS HOSTS=$STRONGSWANHOSTS
@@ -46,8 +46,8 @@ do_on_exit umount $LOOPDIR
for host in $HOSTS for host in $HOSTS
do do
log_action "Creating guest image for $host" log_action "Creating guest image for $host"
execute "qemu-img create -b $BASE -f qcow2 $ROOTFSDIR/$host.qcow2" 0 execute "qemu-img create -b $ROOTIMG -f $IMGEXT $GUESTIMGDIR/$host.$IMGEXT" 0
execute "qemu-nbd -c $NBDEV $ROOTFSDIR/$host.qcow2" 0 execute "qemu-nbd -c $NBDEV $GUESTIMGDIR/$host.$IMGEXT" 0
partprobe $NBDEV partprobe $NBDEV
execute "mount $NBDPARTITION $LOOPDIR" 0 execute "mount $NBDPARTITION $LOOPDIR" 0
execute "cp -rf $HOSTSDIR/${host}/etc $LOOPDIR" 0 execute "cp -rf $HOSTSDIR/${host}/etc $LOOPDIR" 0
+8 -11
View File
@@ -20,23 +20,20 @@ echo "Building root image"
[ `id -u` -eq 0 ] || die "You must be root to run $0" [ `id -u` -eq 0 ] || die "You must be root to run $0"
[ -f "$ROOTFS" ] || die "Root image $ROOTFS not found" [ -f "$BASEIMG" ] || die "Base image $BASEIMG not found"
check_commands partprobe qemu-nbd check_commands partprobe qemu-nbd
load_qemu_nbd load_qemu_nbd
mkdir -p $ROOTFSDIR
mkdir -p $LOOPDIR mkdir -p $LOOPDIR
mkdir -p $ROOTFSCOMPILEDIR mkdir -p $ROOTIMGCOMPILEDIR
cd $ROOTFSDIR
BASE=$BUILDDIR/base.qcow2 log_action "Creating root image $ROOTIMG"
log_action "Creating $BASE" execute "cp $BASEIMG $ROOTIMG"
execute "cp $ROOTFS $BASE"
log_action "Connecting base image to NBD device $NBDEV" log_action "Connecting root image to NBD device $NBDEV"
execute "qemu-nbd -c $NBDEV $BASE" execute "qemu-nbd -c $NBDEV $ROOTIMG"
do_on_exit qemu-nbd -d $NBDEV do_on_exit qemu-nbd -d $NBDEV
partprobe $NBDEV partprobe $NBDEV
@@ -49,8 +46,8 @@ execute "mount -t proc none $LOOPDIR/proc"
do_on_exit umount $LOOPDIR/proc do_on_exit umount $LOOPDIR/proc
mkdir -p $LOOPDIR/root/compile mkdir -p $LOOPDIR/root/compile
log_action "Mounting $ROOTFSCOMPILEDIR as /root/compile" log_action "Mounting $ROOTIMGCOMPILEDIR as /root/compile"
execute "mount -o bind $ROOTFSCOMPILEDIR $LOOPDIR/root/compile" execute "mount -o bind $ROOTIMGCOMPILEDIR $LOOPDIR/root/compile"
do_on_exit umount $LOOPDIR/root/compile do_on_exit umount $LOOPDIR/root/compile
echo "Installing software from source" echo "Installing software from source"
+1 -1
View File
@@ -22,7 +22,7 @@ done
for host in $STRONGSWANHOSTS for host in $STRONGSWANHOSTS
do do
ln -fs $ROOTFSDIR/$host.qcow2 $VIRTIMGSTORE/$host.qcow2 ln -fs $GUESTIMGDIR/$host.$IMGEXT $VIRTIMGSTORE/$host.$IMGEXT
log_action "Guest $host" log_action "Guest $host"
execute "virsh create $CONFDIR/$host.xml" execute "virsh create $CONFDIR/$host.xml"
done done
+1 -1
View File
@@ -19,7 +19,7 @@ for host in $STRONGSWANHOSTS
do do
log_action "Guest $host" log_action "Guest $host"
execute "virsh destroy $host" execute "virsh destroy $host"
rm -f $VIRTIMGSTORE/$host.qcow2 rm -f $VIRTIMGSTORE/$host.$IMGEXT
done done
log_action "Removing kernel $KERNEL" log_action "Removing kernel $KERNEL"
+18 -9
View File
@@ -36,16 +36,25 @@ LOGFILE=$BUILDDIR/testing.log
# Directory used for loop-mounts # Directory used for loop-mounts
LOOPDIR=$BUILDDIR/loop LOOPDIR=$BUILDDIR/loop
# Base image settings # Image extension
ROOTFSSIZE=1024 IMGEXT=qcow2
ROOTFSSUITE=wheezy
ROOTFSARCH=amd64
ROOTFS=$BUILDDIR/debian-$ROOTFSSUITE-$ROOTFSARCH.qcow2
ROOTFSMIRROR=http://cdn.debian.net/debian
ROOTFSCOMPILEDIR=$BUILDDIR/compile
# Path to guest images # Base image settings
ROOTFSDIR=$BUILDDIR/root-fs # The base image is a pristine OS installation created using debootstrap.
BASEIMGSIZE=1024
BASEIMGSUITE=wheezy
BASEIMGARCH=amd64
BASEIMG=$BUILDDIR/debian-$BASEIMGSUITE-$BASEIMGARCH.$IMGEXT
BASEIMGMIRROR=http://cdn.debian.net/debian
# Root image settings
# The root image is the origin of all guest images. It contains additional
# test-specific software and patches.
ROOTIMG=$BUILDDIR/root.$IMGEXT
ROOTIMGCOMPILEDIR=$BUILDDIR/compile
# Guest images settings
GUESTIMGDIR=$BUILDDIR/guest-images
# libvirt config # libvirt config
NBDEV=/dev/nbd0 NBDEV=/dev/nbd0