Class: Dr::BuildRoot

Inherits:
Object
  • Object
show all
Includes:
Logger
Defined in:
lib/dr/buildroot.rb

Instance Method Summary collapse

Methods included from Logger

log, #log, #tag

Constructor Details

#initialize(arch, br_archive = nil) ⇒ BuildRoot

Returns a new instance of BuildRoot.



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/dr/buildroot.rb', line 10

def initialize(arch, br_archive=nil)
  @location = br_archive

  @extra_pkgs = "sudo,vim,ca-certificates,fakeroot,build-essential," +
                "devscripts,debhelper,git,bc,locales,equivs,pkg-config"
  @repo = "http://mirrordirector.raspbian.org/raspbian/"

  if br_archive == nil || !File.exists?(br_archive)
    setup
  end
end

Instance Method Details

#open ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/dr/buildroot.rb', line 22

def open
  Dir.mktmpdir do |tmp|
    log :info, "Preparing the build root"
    ShellCmd.new "sudo tar xz -C #{tmp} -f #{@location}", :tag => "tar"
    begin
      yield tmp
    ensure
      log :info, "Cleaning up the buildroot"
      ShellCmd.new "sudo rm -rf #{tmp}/*", :tag => "rm"
    end
  end
end