Class: DockerTools::Debootstrap

Inherits:
Object
  • Object
show all
Defined in:
lib/docker_tools/debootstrap.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, distro, tmpdir = '/tmp') ⇒ Debootstrap

Returns a new instance of Debootstrap.



5
6
7
8
9
10
# File 'lib/docker_tools/debootstrap.rb', line 5

def initialize(name, distro, tmpdir='/tmp')
  @name = name
  @distro = distro
  @tmpdir = tmpdir
  @archive = "#{@tmpdir}/#{@name}.tar"
end

Instance Attribute Details

#archiveObject

Returns the value of attribute archive.



3
4
5
# File 'lib/docker_tools/debootstrap.rb', line 3

def archive
  @archive
end

Instance Method Details

#cleanupObject



21
22
23
# File 'lib/docker_tools/debootstrap.rb', line 21

def cleanup
  `rm -rf #{@tmpdir}/#{@name}*`
end

#runObject



12
13
14
15
16
17
18
19
# File 'lib/docker_tools/debootstrap.rb', line 12

def run
  output = `debootstrap --download-only #{@distro} #{@tmpdir}/#{@name}`
  unless $?.to_i == 0
    puts output
    throw "Could not run debootstrap"
  end
  `cd #{@tmpdir}/#{@name} && tar -cvf ../#{@name}.tar .`
end