Sha256: 7950888569dca1ca33fef49d8a25873c0561237d5e893e9b6183dab14592f2e2

Contents?: true

Size: 1.62 KB

Versions: 1

Compression:

Stored size: 1.62 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"
	required_packages << "squashfs-tools"
        
        FileUtils.sudo "apt-get install #{required_packages.join(' ')}"
      end
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
system-builder-0.0.12 lib/system_builder/task.rb