aboutsummaryrefslogtreecommitdiffstats
path: root/testing/scripts/build-baseimage
diff options
context:
space:
mode:
authorTobias Brunner <tobias@strongswan.org>2013-01-17 17:00:05 +0100
committerTobias Brunner <tobias@strongswan.org>2013-01-17 17:00:05 +0100
commit0c006341f3789477c429cdfb547ad5ec59819bbf (patch)
treeb11eda6dc752549be59cc5406887ae4b404e4aa8 /testing/scripts/build-baseimage
parent1449e6dd55892c92e502a14dbfc3ede094aaa806 (diff)
parent737912239f625dcfa1c26924430d8ceb033184dd (diff)
downloadstrongswan-0c006341f3789477c429cdfb547ad5ec59819bbf.tar.bz2
strongswan-0c006341f3789477c429cdfb547ad5ec59819bbf.tar.xz
Merge branch 'debian-testing'
These changes update the integration test system. It previously was based on a pretty much unmaintainable Gentoo root image and the dated UML virtualization technology. Among many other changes the test environment is now based on KVM and uses reproducible Debian-based guest images. Conflicts: NEWS
Diffstat (limited to 'testing/scripts/build-baseimage')
-rwxr-xr-xtesting/scripts/build-baseimage79
1 files changed, 79 insertions, 0 deletions
diff --git a/testing/scripts/build-baseimage b/testing/scripts/build-baseimage
new file mode 100755
index 000000000..1355d7a05
--- /dev/null
+++ b/testing/scripts/build-baseimage
@@ -0,0 +1,79 @@
+#!/bin/bash
+
+echo "Building base image"
+
+DIR=$(dirname `readlink -f $0`)
+. $DIR/../testing.conf
+. $DIR/function.sh
+
+[ `id -u` -eq 0 ] || die "You must be root to run $0"
+
+check_commands debootstrap mkfs.ext3 partprobe qemu-img qemu-nbd sfdisk
+
+# package includes/excludes
+INC=build-essential,gperf,libgmp-dev,libldap2-dev,libcurl4-openssl-dev,ethtool
+INC=$INC,libxml2-dev,libtspi-dev,libsqlite3-dev,openssh-server,tcpdump,psmisc
+INC=$INC,openssl,vim,sqlite3,conntrack,gdb,cmake,libxerces-c2-dev,libltdl-dev
+INC=$INC,liblog4cxx10-dev,libboost-thread-dev,libboost-system-dev,git-core
+INC=$INC,less,acpid,acpi-support-base
+SERVICES="apache2 dbus isc-dhcp-server slapd"
+INC=$INC,${SERVICES// /,}
+EXC=iptables
+
+CACHEDIR=$BUILDDIR/cache
+APTCACHE=$LOOPDIR/var/cache/apt/archives
+
+mkdir -p $LOOPDIR
+mkdir -p $CACHEDIR
+mkdir -p $IMGDIR
+rm -f $BASEIMG
+
+echo "`date`, building $BASEIMG" >>$LOGFILE
+
+load_qemu_nbd
+
+log_action "Creating base image $BASEIMG"
+execute "qemu-img create -f $IMGEXT $BASEIMG ${BASEIMGSIZE}M"
+
+log_action "Connecting image to NBD device $NBDEV"
+execute "qemu-nbd -c $NBDEV $BASEIMG"
+do_on_exit qemu-nbd -d $NBDEV
+
+log_action "Partitioning disk"
+sfdisk /dev/nbd0 -D -uM >>$LOGFILE 2>&1 << EOF
+;
+EOF
+if [ $? != 0 ]
+then
+ log_status 1
+ exit 1
+else
+ log_status 0
+fi
+partprobe $NBDEV
+
+log_action "Creating ext3 filesystem"
+execute "mkfs.ext3 $NBDPARTITION"
+
+log_action "Mounting $NBDPARTITION to $LOOPDIR"
+execute "mount $NBDPARTITION $LOOPDIR"
+do_on_exit graceful_umount $LOOPDIR
+
+log_action "Using $CACHEDIR as archive for apt"
+mkdir -p $APTCACHE
+execute "mount -o bind $CACHEDIR $APTCACHE"
+do_on_exit graceful_umount $APTCACHE
+
+log_action "Running debootstrap ($BASEIMGSUITE, $BASEIMGARCH)"
+execute "debootstrap --arch=$BASEIMGARCH --include=$INC --exclude $EXC $BASEIMGSUITE $LOOPDIR $BASEIMGMIRROR"
+
+for service in $SERVICES
+do
+ log_action "Stopping service $service"
+ execute_chroot "/etc/init.d/$service stop"
+ log_action "Disabling service $service"
+ execute_chroot "update-rc.d -f $service remove"
+done
+
+log_action "Disabling root password"
+execute_chroot "passwd -d root"