summaryrefslogtreecommitdiffstats
path: root/vagrant
diff options
context:
space:
mode:
authorTails developers <amnesia@boum.org>2012-05-14 23:51:37 +0200
committerTails developers <amnesia@boum.org>2012-05-16 13:30:41 +0200
commit1431b891565b2a12eab80c1f52ae52b2e0990b02 (patch)
tree87cad30c5993255507bb05e70bbe08d22c435cf7 /vagrant
parent799f1e8e2d6990273f09087eda65b8ae8cf34ae6 (diff)
vagrant: Add suport for in-memory build settings
Diffstat (limited to 'vagrant')
-rw-r--r--vagrant/Vagrantfile9
-rw-r--r--vagrant/lib/tails_build_settings.rb6
-rwxr-xr-xvagrant/provision/assets/build-tails24
3 files changed, 39 insertions, 0 deletions
diff --git a/vagrant/Vagrantfile b/vagrant/Vagrantfile
index cc035c9..8e9ee6c 100644
--- a/vagrant/Vagrantfile
+++ b/vagrant/Vagrantfile
@@ -20,6 +20,13 @@
# Monkey-patched Vagrant!
$:.unshift File.expand_path('../lib', __FILE__)
require 'vagrant_verified_download'
+require 'tails_build_settings'
+
+if ENV['TAILS_RAM_BUILD']
+ mem_size = VM_MEMORY_FOR_RAM_BUILDS
+else
+ mem_size = VM_MEMORY_FOR_DISK_BUILDS
+end
Vagrant::Config.run do |config|
config.vm.box = 'tails'
@@ -30,4 +37,6 @@ Vagrant::Config.run do |config|
config.vm.provision :shell, :inline => "http_proxy='#{ENV['http_proxy']}' /vagrant/provision/setup-tails-builder"
config.vm.share_folder 'amnesia', '/amnesia.git', '../.git'
+
+ config.vm.customize ['modifyvm', :id, '--memory', mem_size]
end
diff --git a/vagrant/lib/tails_build_settings.rb b/vagrant/lib/tails_build_settings.rb
index 714dfa2..c645ff9 100644
--- a/vagrant/lib/tails_build_settings.rb
+++ b/vagrant/lib/tails_build_settings.rb
@@ -19,3 +19,9 @@
# Hostname of the virtual machine (must be in /etc/hosts)
VIRTUAL_MACHINE_HOSTNAME = 'squeeze.vagrantup.com'
+
+# Virtual machine memory size for in-memory builds
+VM_MEMORY_FOR_RAM_BUILDS = 6 * 1024 + 512 # 6.5 GB
+
+# Virtual machine memory size for on-disk builds
+VM_MEMORY_FOR_DISK_BUILDS = 1024 # 1 GB
diff --git a/vagrant/provision/assets/build-tails b/vagrant/provision/assets/build-tails
index f491b5d..e6d1e8d 100755
--- a/vagrant/provision/assets/build-tails
+++ b/vagrant/provision/assets/build-tails
@@ -2,6 +2,8 @@
set -e
+TMPFS_SIZE=6 # GB
+
as_root_do() {
sudo \
${RSYNC_PROXY:+RSYNC_PROXY="$RSYNC_PROXY"} \
@@ -13,6 +15,17 @@ as_root_do() {
"$@"
}
+usable_memory() {
+ free | awk '/cache:/ { print $4 }'
+}
+
+if [ "$TAILS_RAM_BUILD" ]; then
+ if [ "$(usable_memory)" -lt $(($TMPFS_SIZE * 1024 * 1024)) ]; then
+ echo "Not enough memory available for an in-memory build. Aborting." >&2
+ exit 1
+ fi
+fi
+
REV="${1:-$(git --git-dir=/amnesia.git name-rev --name-only HEAD)}"
COMMIT="$(git --git-dir=/amnesia.git rev-parse --verify "$REV")"
@@ -24,6 +37,17 @@ git fetch origin
as_root_do git checkout --force "$REV"
as_root_do git reset --hard "$COMMIT"
as_root_do lb clean || true
+
+if [ "$TAILS_RAM_BUILD" ]; then
+ BUILD_DIR=$(mktemp -d /home/vagrant/tails-build.XXXXXXXX)
+ trap "cd / ; sudo umount '$BUILD_DIR' ; sudo rmdir '$BUILD_DIR'" EXIT
+ as_root_do mount -t tmpfs -o "noatime,size=${TMPFS_SIZE}G,mode=0770,uid=root,gid=vagrant" tmpfs "$BUILD_DIR"
+
+ as_root_do rsync -a /home/vagrant/amnesia/ "$BUILD_DIR"/
+
+ cd "$BUILD_DIR"
+fi
+
as_root_do lb config
as_root_do lb build