summaryrefslogtreecommitdiffstats
path: root/Rakefile
diff options
context:
space:
mode:
authorTails developers <amnesia@boum.org>2012-05-12 17:46:43 +0200
committerTails developers <amnesia@boum.org>2012-05-16 12:50:31 +0200
commit39737699ab82e204a9d821ac0cbab79b98e004ea (patch)
treea0ca9b1982885720021e34c5f9b7b3c54b561f7b /Rakefile
parent475f940a39b321971ecb9bd525ab29f8651e6abf (diff)
vagrant: Start a Rakefile to drive builds
Build based on Vagrant will be drived using `rake`. This has the definite advantage that we can easily isolate Vagrant related files in the `vagrant` subdirectory while providing an easy access to build functions. This will also allow easier local customizations to Vagrant itself, as we will be able to mangle stuff in Rake before handing commands to Vagrant. The Rakefile currently only wraps a few Vagrant commands, it will be extended later on.
Diffstat (limited to 'Rakefile')
-rw-r--r--Rakefile78
1 files changed, 78 insertions, 0 deletions
diff --git a/Rakefile b/Rakefile
new file mode 100644
index 0000000..45b4f05
--- /dev/null
+++ b/Rakefile
@@ -0,0 +1,78 @@
+# -*- 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/>.
+
+require 'rubygems'
+require 'vagrant'
+
+# Path to the directory which holds our Vagrantfile
+VAGRANT_PATH = File.expand_path('../vagrant', __FILE__)
+
+namespace :vm do
+ desc 'Start the build virtual machine'
+ task :up do
+ env = Vagrant::Environment.new(:cwd => VAGRANT_PATH, :ui_class => Vagrant::UI::Basic)
+ case env.primary_vm.state
+ when :not_created
+ $stderr.puts <<-END_OF_MESSAGE.gsub(/^ /, '')
+
+ This is the first time that the Tails builder virtual machine is
+ started. The virtual machine template is about 300 MB to download,
+ so the process might take some time.
+
+ Please remember to shut the virtual machine down once your work on
+ Tails in done:
+
+ $ rake vm:halt
+
+ END_OF_MESSAGE
+ when :poweroff
+ $stderr.puts <<-END_OF_MESSAGE.gsub(/^ /, '')
+
+ Starting Tails builder virtual machine. This might take a short while.
+ Please remember to shut it down once your work on Tails in done:
+
+ $ rake vm:halt
+
+ END_OF_MESSAGE
+ end
+ result = env.cli('up')
+ abort "'vagrant up' failed" unless result
+ end
+
+ desc 'Stop the build virtual machine'
+ task :halt do
+ env = Vagrant::Environment.new(:cwd => VAGRANT_PATH, :ui_class => Vagrant::UI::Basic)
+ result = env.cli('halt')
+ abort "'vagrant halt' failed" unless result
+ end
+
+ desc 'Re-run virtual machine setup'
+ task :provision do
+ env = Vagrant::Environment.new(:cwd => VAGRANT_PATH, :ui_class => Vagrant::UI::Basic)
+ result = env.cli('provision')
+ abort "'vagrant provision' failed" unless result
+ end
+
+ desc 'Destroy build virtual machine (clean up all files)'
+ task :destroy do
+ env = Vagrant::Environment.new(:cwd => VAGRANT_PATH, :ui_class => Vagrant::UI::Basic)
+ result = env.cli('destroy', '--force')
+ abort "'vagrant destroy' failed" unless result
+ end
+end