Class: SystemBuilder::DebianBoot::Chroot

Inherits:
Object
  • Object
show all
Defined in:
lib/system_builder/boot.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(image) ⇒ Chroot

Returns a new instance of Chroot.



320
321
322
# File 'lib/system_builder/boot.rb', line 320

def initialize(image)
  @image = image
end

Instance Attribute Details

#imageObject (readonly)

Returns the value of attribute image.



318
319
320
# File 'lib/system_builder/boot.rb', line 318

def image
  @image
end

Instance Method Details

#apt_install(*packages) ⇒ Object



324
325
326
# File 'lib/system_builder/boot.rb', line 324

def apt_install(*packages)
  sudo "apt-get install #{SystemBuilder::DebianBoot.apt_options} --yes --force-yes #{packages.join(' ')}"
end

#cp(*arguments) ⇒ Object



328
329
330
# File 'lib/system_builder/boot.rb', line 328

def cp(*arguments)
  sudo "cp #{arguments.join(' ')}"
end

#execute(&block) ⇒ Object



337
338
339
340
341
342
343
344
# File 'lib/system_builder/boot.rb', line 337

def execute(&block)
  begin
    prepare_run
    yield self
  ensure
    unprepare_run
  end
end

#prepare_runObject



346
347
348
# File 'lib/system_builder/boot.rb', line 346

def prepare_run
  FileUtils::sudo "mount proc #{image.expand_path('/proc')} -t proc"
end

#sh(*arguments) ⇒ Object Also known as: sudo



332
333
334
# File 'lib/system_builder/boot.rb', line 332

def sh(*arguments)
  FileUtils::sudo "chroot #{image.expand_path('/')} sh -c \"export HOME=/root; LC_ALL=C #{arguments.join(' ')}\""
end

#unprepare_runObject



350
351
352
# File 'lib/system_builder/boot.rb', line 350

def unprepare_run
  FileUtils::sudo "umount #{image.expand_path('/proc')}"
end