Sha256: 5d3a361125ff060540e2f22f9cb5ef84b51c9d686c9009a0080f4ca74b1ec3db

Contents?: true

Size: 1.58 KB

Versions: 3

Compression:

Stored size: 1.58 KB

Contents

require 'rake/tasklib'

class SystemBuilder::Task < Rake::TaskLib

  attr_reader :name

  def initialize(name, &block)
    @name = name

    @image =
      if block_given?
        block.call
      else
        SystemBuilder.config(name)
      end

    define
  end

  def define
    namespace name do
      desc "Create image #{name} in #{@image.file}"
      task :dist do
        @image.create
      end
      namespace :dist do
        desc "Create vmware image in #{@image.file}.vdmk"
        task :vmware do
          @image.convert "#{@image.file}.vmdk", :format => "vmdk"
        end

        desc "Create iso image in #{@image.file}.iso"
        task :iso do
          SystemBuilder::IsoImage.new("#{@image.file}.iso").tap do |image|
            image.boot = @image.boot
          end.create_iso
        end
      end
      task "dist:vmware" => "dist"

      namespace :build do
        desc "Configure the image system"
        task :configure do
          @image.boot.configure
          @image.boot.clean
        end

        desc "Clean the image system"
        task :clean do
          @image.boot.clean
        end
      end

      task :setup do
        required_packages = []
        required_packages << "qemu" # to convert image files
        required_packages << "util-linux" # provides sfdisk
        required_packages << "sudo"
        required_packages << "debootstrap"
        required_packages << "rsync"
        required_packages << "dosfstools"
        required_packages << "syslinux"
        
        FileUtils.sudo "apt-get install #{required_packages.join(' ')}"
      end
    end
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
system-builder-0.0.10 lib/system_builder/task.rb
system-builder-0.0.9 lib/system_builder/task.rb
system-builder-0.0.7 lib/system_builder/task.rb