diff --git a/vm/README.txt b/vm/README.txt index 1138f8bd..e6ff7df3 100644 --- a/vm/README.txt +++ b/vm/README.txt @@ -2,10 +2,10 @@ Create virtual disk of pan.do/ra == Preparations == -Pan.do/ra VM scripts use python-vm-builder, -its available in ubuntu 12.04 and later +Pan.do/ra VM scripts use vmdebootstrap 0.9 or later +You also need qemu to run the vm and virtualbox to convert the image - apt-get install python-vm-builder + apt-get install vmdebootstrap virtualbox qemu == Building == @@ -14,7 +14,12 @@ You can configure some of the arguments in build.sh once done run: ./build.sh -this will create a vdi image in pandora/ +this will create a vdi image in pandora-r{REVISON}.vdi + +If you have a local apt-cacher instance export MIRROR: + +export MIRROR="--mirror http://:3142/archive.ubuntu.com/ubuntu/ --configure-apt" +./build.sh == VirtualBox Usage == diff --git a/vm/build.sh b/vm/build.sh index eb18bb8f..4ce9c7d6 100755 --- a/vm/build.sh +++ b/vm/build.sh @@ -1,30 +1,46 @@ -#!/bin/sh -size=1048576 #in MB -arch=amd64 #i368 or amd64 -password=pandora +#!/bin/bash +cd "`dirname "$0"`" +BASE=`pwd` +VERSION=`cd ..;git rev-list HEAD --count` +TARGET=${BASE}/pandora-r${VERSION}.vdi +SIZE=1T +RELEASE=trusty -hypervisor=vbox #vbox or kvm +if [ "$MIRROR" = "" ]; then + MIRROR="--mirror http://archive.ubuntu.com/ubuntu/" +fi -extra="" +if [ $(id -u) -ne 0 ]; then + echo "you need to run $0 as root" + exit 1 +fi -#make available as pandora.local -extra="--addpkg avahi-daemon" +# make sure ubuntu-archive-keyring is installed +test -e /usr/share/keyrings/ubuntu-archive-keyring.gpg || apt-get install ubuntu-archive-keyring -#to create and include in libvirt: -#hypervisor=kvm -#extra="--libvirt qemu:///system" - -base=$(pwd) -sudo vmbuilder $hypervisor ubuntu --suite=trusty \ - --verbose --debug \ - --arch $arch \ - --dest $base/pandora \ +vmdebootstrap \ + --image ${TARGET}.img \ + --size ${SIZE} \ + --sparse \ + --distribution=${RELEASE} \ + $MIRROR \ + --enable-dhcp \ + --no-serial-console \ + --no-kernel \ + --package "linux-image-generic" \ + --package "avahi-daemon" \ + --package "ssh" \ + --mbr \ + --grub \ + --sudo \ + --lock-root-password \ + --user pandora/pandora \ --hostname pandora \ - --swapsize 512 \ - --rootsize $size \ - --user pandora \ - --pass $password \ - --addpkg linux-image-generic \ - --components main,universe,multiverse \ - --firstboot=$base/firstboot.sh \ - $extra + --customize "${BASE}/prepare.sh" \ + --log ${TARGET}.log --log-level debug --verbose + +echo "Installing pan.do/ra in VM" +qemu-system-x86_64 -enable-kvm -name pandora -m 1024 -drive "format=raw,file=${TARGET}.img" -vnc :2 +rm -rf "${TARGET}" +/usr/bin/VBoxManage convertfromraw -format VDI "${TARGET}.img" "${TARGET}" +rm "${TARGET}.img" diff --git a/vm/firstboot.sh b/vm/firstboot.sh deleted file mode 100755 index 53af4739..00000000 --- a/vm/firstboot.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh -apt-get update -q -apt-get install -y curl -curl -L https://pan.do/ra-install > /root/pandora_install.sh -chmod 755 /root/pandora_install.sh -/root/pandora_install.sh >/root/pandora_install.log 2>&1 -rm /root/pandora_install.sh diff --git a/vm/prepare.sh b/vm/prepare.sh new file mode 100755 index 00000000..a25388de --- /dev/null +++ b/vm/prepare.sh @@ -0,0 +1,47 @@ +#!/bin/sh +set -e + +rootdir=$1 +base=$(dirname $0) +RELEASE=trusty + +cat > "$rootdir/root/pandora_install" << EOF +#!/bin/bash +DEBIAN_FRONTEND=noninteractive +sed -i "s/main/main restricted universe multiverse/g" /etc/apt/sources.list.d/base.list +apt-get update +apt-get -y --force-yes dist-upgrade + +EOF +cat "$base/pandora_install.sh" >> "$rootdir/root/pandora_install" + +#reset install proxy settings +cat >> "$rootdir/root/pandora_install" < /etc/apt/sources.list.d/base.list < "$rootdir/etc/rc.local" <&1 | tee /root/pandora_install.log || true + mv /root/pandora_install /root/pandora_installed + shutdown -h now +fi + +exit 0 +EOF +chmod +x "$rootdir/etc/rc.local" +