summaryrefslogtreecommitdiffstats
path: root/Rakefile
diff options
context:
space:
mode:
authorTails developers <amnesia@boum.org>2012-05-16 08:42:08 +0200
committerTails developers <amnesia@boum.org>2012-05-16 13:30:42 +0200
commit69792d7bdd65279cb8edb43a93d0b9273c955687 (patch)
tree8c866274b90d697ece9d5f8d3d752503d78b51bd /Rakefile
parent3c41c91187940dba63609b60c014ba23c1e88f5d (diff)
vagrant: Add defaults for virtual CPUs build settings
On Linux, we set the number of virtual CPUs to the number of CPUs in host system.
Diffstat (limited to 'Rakefile')
-rw-r--r--Rakefile14
1 files changed, 14 insertions, 0 deletions
diff --git a/Rakefile b/Rakefile
index f6ad2c5..fa66d3b 100644
--- a/Rakefile
+++ b/Rakefile
@@ -59,6 +59,16 @@ def enough_free_memory?
end
end
+def system_cpus
+ return nil unless RbConfig::CONFIG['host_os'] =~ /linux/i
+
+ begin
+ File.read('/proc/cpuinfo').scan(/^processor\s+:/).count
+ rescue
+ nil
+ end
+end
+
task :parse_build_options do
options = ''
@@ -68,6 +78,10 @@ task :parse_build_options do
# Use in-VM proxy unless an external proxy is set
options += 'vmproxy ' unless EXTERNAL_HTTP_PROXY
+ # Default to the number of system CPUs when we can figure it out
+ cpus = system_cpus
+ options += "cpus=#{cpus} " if cpus
+
options += ENV['TAILS_BUILD_OPTIONS'] if ENV['TAILS_BUILD_OPTIONS']
options.split(' ').each do |opt|
case opt