diff options
author | Tails developers <amnesia@boum.org> | 2012-05-16 08:00:41 +0200 |
---|---|---|
committer | Tails developers <amnesia@boum.org> | 2012-05-16 13:30:42 +0200 |
commit | 3dfbc87ebbeeef360f0da0febeb4e5286e9b5b8d (patch) | |
tree | 51e492334bf754afa9e04bcb2f70295c9d3b6005 | |
parent | 3f0858935076122e752653c01fb366d987ee76b5 (diff) |
vagrant: Add defaults for in-memory build settings
When we can know the current amount of usable free memory (read using
GNU/Linux), we default to in-memory builds if enough memory is available.
-rw-r--r-- | Rakefile | 15 |
1 files changed, 15 insertions, 0 deletions
@@ -17,6 +17,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. +require 'rbconfig' require 'rubygems' require 'vagrant' require 'uri' @@ -40,9 +41,23 @@ def current_vm_memory $1.to_i if info =~ /^memory=(\d+)/ end +def enough_free_memory? + return false unless RbConfig::CONFIG['host_os'] =~ /linux/i + + begin + usable_free_mem = `free`.split[16].to_i + usable_free_mem > VM_MEMORY_FOR_RAM_BUILDS * 1024 + rescue + false + end +end + task :parse_build_options do options = '' + # Default to in-memory builds if there is enough RAM available + options += 'ram ' if enough_free_memory? + # Use in-VM proxy unless an external proxy is set options += 'vmproxy ' unless EXTERNAL_HTTP_PROXY |