Commit 9129a588 authored by Tails developers's avatar Tails developers

Merge remote-tracking branch 'davidiw/bugfix' into stable

parents 08334183 0a3db54f
......@@ -25,6 +25,7 @@ require 'uri'
$:.unshift File.expand_path('../vagrant/lib', __FILE__)
require 'tails_build_settings'
require 'vagrant_version'
# Path to the directory which holds our Vagrantfile
VAGRANT_PATH = File.expand_path('../vagrant', __FILE__)
......@@ -41,23 +42,40 @@ EXTERNAL_HTTP_PROXY = ENV['http_proxy']
# In-VM proxy URL
INTERNEL_HTTP_PROXY = "http://#{VIRTUAL_MACHINE_HOSTNAME}:3142"
def current_vm_memory
def primary_vm
env = Vagrant::Environment.new(:cwd => VAGRANT_PATH, :ui_class => Vagrant::UI::Basic)
uuid = env.primary_vm.uuid
info = env.primary_vm.driver.execute 'showvminfo', uuid, '--machinereadable'
if vagrant_old
return env.primary_vm
else
name = env.primary_machine_name
return env.machine(name, env.default_provider)
end
end
def primary_vm_state
if vagrant_old
return primary_vm.state
else
return primary_vm.state.id
end
end
def current_vm_memory
vm = primary_vm
uuid = vm.uuid
info = vm.driver.execute 'showvminfo', uuid, '--machinereadable'
$1.to_i if info =~ /^memory=(\d+)/
end
def current_vm_cpus
env = Vagrant::Environment.new(:cwd => VAGRANT_PATH, :ui_class => Vagrant::UI::Basic)
uuid = env.primary_vm.uuid
info = env.primary_vm.driver.execute 'showvminfo', uuid, '--machinereadable'
vm = primary_vm
uuid = vm.uuid
info = vm.driver.execute 'showvminfo', uuid, '--machinereadable'
$1.to_i if info =~ /^cpus=(\d+)/
end
def vm_running?
env = Vagrant::Environment.new(:cwd => VAGRANT_PATH, :ui_class => Vagrant::UI::Basic)
env.primary_vm.state == :running
primary_vm_state == :running
end
def enough_free_memory?
......@@ -197,9 +215,12 @@ desc 'Build Tails'
task :build => ['parse_build_options', 'ensure_clean_repository', 'validate_http_proxy', 'vm:up'] do
exported_env = EXPORTED_VARIABLES.select { |k| ENV[k] }.
collect { |k| "#{k}='#{ENV[k]}'" }.join(' ')
env = Vagrant::Environment.new(:cwd => VAGRANT_PATH)
status = env.primary_vm.channel.execute("#{exported_env} build-tails",
if vagrant_old
chan = primary_vm.channel
else
chan = primary_vm.communicate
end
status = chan.execute("#{exported_env} build-tails",
:error_check => false) do |fd, data|
(fd == :stdout ? $stdout : $stderr).write data
end
......@@ -214,8 +235,7 @@ end
namespace :vm do
desc 'Start the build virtual machine'
task :up => ['parse_build_options', 'validate_http_proxy'] do
env = Vagrant::Environment.new(:cwd => VAGRANT_PATH, :ui_class => Vagrant::UI::Basic)
case env.primary_vm.state
case primary_vm_state
when :not_created
# Do not use non-existant in-VM proxy to download the basebox
if ENV['http_proxy'] == INTERNEL_HTTP_PROXY
......@@ -268,6 +288,7 @@ namespace :vm do
abort 'The virtual machine needs to be reloaded to change the number of CPUs. Aborting.'
end
end
env = Vagrant::Environment.new(:cwd => VAGRANT_PATH, :ui_class => Vagrant::UI::Basic)
result = env.cli('up')
abort "'vagrant up' failed" unless result
......
......@@ -2,7 +2,6 @@
# vi: set ft=ruby :
#
# Tails: The Amnesic Incognito Live System
# Copyright © 2012 Tails developers <tails@boum.org>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......@@ -19,6 +18,7 @@
# Monkey-patched Vagrant!
$:.unshift File.expand_path('../lib', __FILE__)
require 'vagrant_version'
require 'vagrant_verified_download'
require 'tails_build_settings'
......@@ -30,16 +30,31 @@ end
cpus = ENV['TAILS_BUILD_CPUS']
Vagrant::Config.run do |config|
config.vm.box = 'tails'
if vagrant_old
Vagrant::Config.run do |config|
config.vm.box = 'tails'
config.vm.box_url = 'http://dl.amnesia.boum.org/tails/project/vagrant/squeeze.box'
config.vm.box_url = 'http://dl.amnesia.boum.org/tails/project/vagrant/squeeze.box'
config.vm.box_checksum = '8951d257fc4751437812477df81d55670ebcc0b57c525c248cf2284a89540ca3'
config.vm.provision :shell, :inline => "http_proxy='#{ENV['http_proxy']}' /vagrant/provision/setup-tails-builder"
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.share_folder 'amnesia', '/amnesia.git', '../.git'
config.vm.customize ['modifyvm', :id, '--memory', mem_size]
config.vm.customize ['modifyvm', :id, '--cpus', cpus] unless cpus.nil?
end
else
Vagrant.configure("2") do |config|
config.vm.box = 'tails'
config.vm.box_url = 'http://dl.amnesia.boum.org/tails/project/vagrant/squeeze.box'
config.vm.provision "shell",
inline: "sudo http_proxy='#{ENV['http_proxy']}' /vagrant/provision/setup-tails-builder"
config.vm.synced_folder '../.git', '/amnesia.git'
config.vm.customize ['modifyvm', :id, '--memory', mem_size]
config.vm.customize ['modifyvm', :id, '--cpus', cpus] unless cpus.nil?
config.vm.provider :virtualbox do |vb|
vb.customize ['modifyvm', :id, '--memory', mem_size]
vb.customize ['modifyvm', :id, '--cpus', cpus] unless cpus.nil?
end
end
end
......@@ -6,9 +6,9 @@ d-i console-keymaps-at/keymap select us
d-i netcfg/choose_interface select auto
d-i netcfg/get_domain string vagrantup.com
# Use cdn.debian.net to select closest mirror
# Use http.debian.net to select closest mirror
d-i mirror/country string manual
d-i mirror/http/hostname string cdn.debian.net
d-i mirror/http/hostname string http.debian.net
d-i mirror/http/directory string /debian
d-i mirror/http/proxy string <%= ENV['http_proxy'] %>
......
# -*- coding: utf-8 -*-
# -*- mode: ruby -*-
# vi: set ft=ruby :
#
# Tails: The Amnesic Incognito Live System
# Copyright © 2012 Tails developers <tails@boum.org>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Hostname of the virtual machine (must be in /etc/hosts)
VIRTUAL_MACHINE_HOSTNAME = 'squeeze.vagrantup.com'
......@@ -26,3 +10,6 @@ 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
# Checksum for BOX
BOX_CHECKSUM = '8951d257fc4751437812477df81d55670ebcc0b57c525c248cf2284a89540ca3'
# Tails: The Amnesic Incognito Live System
# Copyright © 2012 Tails developers <tails@boum.org>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# 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 'digest'
require 'vagrant/util/downloader'
require 'vagrant/errors'
# The following will monkeypatch Vagrant (successfuly tested against Vagrant
# 1.0.2) in order to verify the checksum of a downloaded box.
module Vagrant
class Config::VMConfig
attr_accessor :box_checksum
def check(path)
checksum = Digest::SHA256.new.file(path).hexdigest
if checksum != BOX_CHECKSUM
raise Vagrant::Errors::BoxVerificationFailed.new
end
end
class Action::Box::Download
alias :unverified_download :download
def download
unverified_download
checksum = Digest::SHA256.new.file(@temp_path).hexdigest
if checksum != @env['global_config'].vm.box_checksum
raise Errors::BoxVerificationFailed.new
module Vagrant
if vagrant_old
class Action::Box::Download
alias :unverified_download :download
def download
unverified_download
check(@temp_path)
end
end
else
class Util::Downloader
alias :unverified_download! :download!
def download!
unverified_download!
check(@destination)
end
end
end
......
require 'vagrant/version'
def vagrant_old
version = Vagrant::VERSION.split(".")
return version[1].to_i < 2
end
......@@ -18,7 +18,7 @@ if [ -d /home/vagrant/ikiwiki ]; then
fi
# Add unstable repository for ikiwiki, and pin it low
echo 'deb http://cdn.debian.net/debian unstable main' > /etc/apt/sources.list.d/unstable.list
echo 'deb http://http.debian.net/debian unstable main' > /etc/apt/sources.list.d/unstable.list
sed -e 's/^[[:blank:]]*//' > /etc/apt/preferences.d/unstable <<EOF
Package: *
Pin: release a=unstable
......
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