summaryrefslogtreecommitdiffstats
path: root/Rakefile
diff options
context:
space:
mode:
authorTails developers <amnesia@boum.org>2014-05-05 14:09:30 +0200
committerTails developers <amnesia@boum.org>2014-05-06 17:46:00 +0200
commit32fd0f4034183f05f430908f62ed7e2075685fb6 (patch)
tree9844407f3be815d0d8b037f0465f8c3a1030285c /Rakefile
parentea3f6c189117ad7236e3b17609314902cfb8b254 (diff)
Fix buggy memory checks for RAM building.
We have to take into account which state the Vagrant VM is in for determining *where* we check if enough memory is available for a RAM build. If it's off, we check the host; if it's on we check the VM. Previously we always checked the host, which doesn't make sense when the VM is already started.
Diffstat (limited to 'Rakefile')
-rw-r--r--Rakefile32
1 files changed, 21 insertions, 11 deletions
diff --git a/Rakefile b/Rakefile
index ff96cec..3eccff9 100644
--- a/Rakefile
+++ b/Rakefile
@@ -85,11 +85,6 @@ def vm_driver
end
end
-def current_vm_memory
- info = vm_driver.execute 'showvminfo', vm_id, '--machinereadable'
- $1.to_i if info =~ /^memory=(\d+)/
-end
-
def current_vm_cpus
info = vm_driver.execute 'showvminfo', vm_id, '--machinereadable'
$1.to_i if info =~ /^cpus=(\d+)/
@@ -99,7 +94,7 @@ def vm_running?
primary_vm_state == :running
end
-def enough_free_memory?
+def enough_free_host_memory_for_ram_build?
return false unless RbConfig::CONFIG['host_os'] =~ /linux/i
begin
@@ -110,6 +105,24 @@ def enough_free_memory?
end
end
+def free_vm_memory
+ primary_vm_chan.execute("free", :error_check => false) do |fd, data|
+ return data.split[16].to_i
+ end
+end
+
+def enough_free_vm_memory_for_ram_build?
+ free_vm_memory > BUILD_SPACE_REQUIREMENT * 1024
+end
+
+def enough_free_memory_for_ram_build?
+ if vm_running?
+ enough_free_vm_memory_for_ram_build?
+ else
+ enough_free_host_memory_for_ram_build?
+ end
+end
+
def is_release?
branch_name = `git name-rev --name-only HEAD`
tag_name = `git describe --exact-match HEAD 2> /dev/null`
@@ -130,7 +143,7 @@ task :parse_build_options do
options = ''
# Default to in-memory builds if there is enough RAM available
- options += 'ram ' if enough_free_memory?
+ options += 'ram ' if enough_free_memory_for_ram_build?
# Use in-VM proxy unless an external proxy is set
options += 'vmproxy ' unless EXTERNAL_HTTP_PROXY
@@ -150,9 +163,6 @@ task :parse_build_options do
case opt
# Memory build settings
when 'ram'
- unless vm_running? || enough_free_memory?
- abort "Not enough free memory to do an in-memory build. Aborting."
- end
ENV['TAILS_RAM_BUILD'] = '1'
when 'noram'
ENV['TAILS_RAM_BUILD'] = nil
@@ -235,7 +245,7 @@ end
desc 'Build Tails'
task :build => ['parse_build_options', 'ensure_clean_repository', 'validate_http_proxy', 'vm:up'] do
- if ENV['TAILS_RAM_BUILD'] && current_vm_memory < VM_MEMORY_FOR_RAM_BUILDS
+ if ENV['TAILS_RAM_BUILD'] && not(enough_free_memory_for_ram_build?)
$stderr.puts <<-END_OF_MESSAGE.gsub(/^ /, '')
The virtual machine is not currently set with enough memory to