Add VirtualBox support to make-base-vm via Vagrant

lxc
Tom Robinson 10 years ago
parent ac4f77bcd1
commit a6fdc28839

46
Vagrantfile vendored

@ -0,0 +1,46 @@
$script = <<SCRIPT
#!/bin/bash
set -eu
sudo apt-get update -y
sudo apt-get upgrade -y
sudo apt-get install -y autoconf2.13 automake build-essential bsdmainutils faketime g++ g++-mingw-w64 git-core libqt4-dev libtool libz-dev mingw-w64 nsis pciutils pkg-config psmisc subversion unzip zip
echo "ok"
SCRIPT
archs = ["amd64", "i386"]
suites = ["precise", "quantal", "raring", "saucy", "trusty"]
if ARGV[0] == "up" and ARGV.length == 1
puts "Specify a name of the form 'suite-architecture'"
puts " suites: " + suites.join(', ')
puts " architectures: " + archs.join(', ')
Process.exit 1
end
Vagrant.configure("2") do |config|
config.vm.provision "shell", inline: $script
config.vm.network :forwarded_port, id: "ssh", guest: 22, host: 2223
suites.each do |suite|
archs.each do |arch|
name = "#{suite}-#{arch}"
config.vm.define name do |config|
config.vm.box = name
config.vm.box_url = "http://cloud-images.ubuntu.com/vagrant/#{suite}/current/#{suite}-server-cloudimg-#{arch}-vagrant-disk1.box"
config.vm.provider :virtualbox do |vb|
vb.name = "Gitian-#{name}"
end
end
end
end
config.vm.provider :virtualbox do |vb|
vb.memory = 4096
end
end

@ -6,6 +6,7 @@ ARCH=amd64
MIRROR=http://${MIRROR_HOST:-127.0.0.1}:3142/archive.ubuntu.com/ubuntu
SECURITY_MIRROR=http://${MIRROR_HOST:-127.0.0.1}:3142/security.ubuntu.com/ubuntu
LXC=0
VBOX=0
usage() {
echo "Usage: ${0##*/} [OPTION]..."
@ -16,6 +17,7 @@ usage() {
--suite U build suite U instead of lucid
--arch A build architecture A (e.g. i386) instead of amd64
--lxc use lxc instead of kvm
--vbox use VirtualBox instead of kvm
The MIRROR_HOST environment variable can be used to change the
apt-cacher host. It should be something that the target VM can
@ -44,6 +46,10 @@ if [ $# != 0 ] ; then
LXC=1
shift 1
;;
--vbox)
VBOX=1
shift 1
;;
--*)
echo "unrecognized option $1"
exit 1
@ -73,6 +79,26 @@ addpkg=openssh-server,pciutils,build-essential,git-core,subversion
# Remove cron to work around vmbuilder issue when umounting /dev on target
removepkg=cron
if [ $VBOX = "1" ]; then
NAME="$SUITE-$ARCH"
if ! vagrant status | grep "$NAME" | grep "not created" > /dev/null; then
echo "Vagrant machine "$NAME" already exists, please remove it first (vagrant destroy "$NAME")"
exit 1
fi
vagrant up "$NAME"
vagrant ssh "$NAME" -c "sudo mkdir -p /root/.ssh && sudo chmod 700 /root/.ssh"
vagrant ssh "$NAME" -c "sudo sh -c 'cat >> /root/.ssh/authorized_keys'" < var/id_dsa.pub
vagrant ssh "$NAME" -c "sudo -u ubuntu mkdir -p /home/ubuntu/.ssh && sudo -u ubuntu chmod 700 /home/ubuntu/.ssh"
vagrant ssh "$NAME" -c "sudo sh -c 'cat >> /home/ubuntu/.ssh/authorized_keys'" < var/id_dsa.pub
VBoxManage snapshot "Gitian-$NAME" take "Gitian-Clean"
vagrant suspend "$NAME"
exit 0
fi
if [ -e $OUT.qcow2 ]; then
echo $OUT.qcow2 already exists, please remove it first
exit 1

Loading…
Cancel
Save