class Docker::Template::Builder::Rootfs

Private Class Methods

files() click to toggle source

# File lib/docker/template/builder/rootfs.rb, line 102
def files
  %w(
    Rootfs.erb Rootfs rootfs.erb rootfs
  )
end
sub?() click to toggle source
# File lib/docker/template/builder/rootfs.rb, line 96
def sub?
  return true
end

Public Instance Methods

builder_data() click to toggle source

# File lib/docker/template/builder/rootfs.rb, line 39
def builder_data
  Template.get(discover, {
    :meta => @repo.meta
  })
end
data() click to toggle source

# File lib/docker/template/builder/rootfs.rb, line 13
def data
  Template.get(:rootfs, {
    :rootfs_base_img => @repo.meta["rootfs_base_img"]
  })
end
discover() click to toggle source

# File lib/docker/template/builder/rootfs.rb, line 21
def discover
  self.class.files.map do |file|
    file = @repo.root.join(
      file
    )

    if file.file?
      then return file
    end
  end

  "rootfs/#{
    @repo.meta.rootfs_template
  }"
end
simple_cleanup(dir) click to toggle source

– During a simple copy you store all the data (including rootfs) data as a project unit, this helps us clean up data that is known to be for just the rootfs image and remove it so it doesn't impact. –

# File lib/docker/template/builder/rootfs.rb, line 50
def simple_cleanup(dir)
  file = dir.join("usr/local/bin/mkimg")

  if file.exist?
    then file.delete
  end
end
teardown(img: true) click to toggle source

# File lib/docker/template/builder/rootfs.rb, line 60
def teardown(img: true)
  @context.rmtree if @context && @context.directory?
  @img.delete "force" => true if @img && img \
    rescue nil
end

Private Instance Methods

copy_rootfs() click to toggle source

# File lib/docker/template/builder/rootfs.rb, line 83
def copy_rootfs
  dir = @repo.copy_dir(
    "rootfs"
  )

  if dir.exist?
    @repo.copy_dir("rootfs").safe_copy(@copy, {
      :root => Template.root
    })
  end
end
setup_context() click to toggle source

# File lib/docker/template/builder/rootfs.rb, line 69
def setup_context
  @context = @repo.tmpdir("rootfs")
  @copy = @context.join(@repo.meta["copy_dir"])
  @context.join("Dockerfile").write(data)

  @copy.join("usr/local/bin").mkdir_p
  @copy.join("usr/local/bin/mkimg").write(builder_data)
  @copy.join("usr/local/bin/mkimg").chmod(0755)
  copy_rootfs
end