Sha256: 536abe0076f077a56c1966ef8b8dbda7a689feeb57f0cbb0b1c1c80091b2a602
Contents?: true
Size: 1.92 KB
Versions: 18
Compression:
Stored size: 1.92 KB
Contents
require 'pathname' class Box # :nodoc: attr_reader :definition_path, :definition_dir, :name, :path, :groups def initialize(definition_path) @definition_path = Pathname(definition_path) @definition_dir = @definition_path.dirname @name = @definition_dir.basename.to_s @path = Pathname("#{@name}.box") parts = @name.split('-') @groups = (1...parts.length).map{ |n| parts.take(n).join('-') } end def dependencies postinstall_file_paths = Array(definition[:postinstall_files]).map do |path| definition_dir + path end [definition_path] + postinstall_file_paths end def build sh(*%W[veewee vbox build --auto --checksum --force --nogui #{name}]) sh(*%w[sleep 30]) sh(*%W[veewee vbox export --force #{name}]) sh(*%W[veewee vbox destroy #{name}]) end def add assert_box_created sh(*%W[vagrant box add --force --name boxes/#{path} #{path}]) end private def definition @definition ||= begin eval definition_path.read.sub('Veewee::Session.declare', '{}.merge') end end def assert_box_created abort "#{path} doesn't exist" unless path.size? end def sh(*args) abort unless system(*args) end end Dir['definitions/*/definition.rb'].each do |definition_path| box = Box.new(definition_path) desc "build #{box.name} box" file box.path => box.dependencies do box.build end namespace :add do desc "add #{box.name} box to vagrant" task box.name => box.path do box.add end end box.groups.each do |group| desc "build #{group} boxes" task "build:#{group}" => box.path desc "add #{group} boxes to vagrant" task "add:#{group}" => "add:#{box.name}" end desc 'build all boxes' task :build => box.path desc 'add all boxes to vagrant' task :add => "add:#{box.name}" end desc 'remove *.box and iso dir' task :clean do sh 'rm *.box || true' sh 'rm -r iso || true' end task :default => :build
Version data entries
18 entries across 18 versions & 1 rubygems