Commit 3dfbc87e authored by Tails developers's avatar Tails developers
Browse files

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.
parent 3f085893
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment