Sha256: 32510b372ed16fb36033f6fe2e911add8c43fe6d1f2e5f67b7c3a61f2987dadf
Contents?: true
Size: 1.92 KB
Versions: 6
Compression:
Stored size: 1.92 KB
Contents
# frozen_string_literal: true 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 ||= eval definition_path.read.sub('Veewee::Session.declare', '{}.merge') 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
6 entries across 6 versions & 1 rubygems