Class: SystemBuilder::DebianBoot::Image

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

Instance Method Summary collapse

Constructor Details

#initialize(root) ⇒ Image

Returns a new instance of Image.



275
276
277
# File 'lib/system_builder/boot.rb', line 275

def initialize(root)
  @root = root
end

Instance Method Details

#exists?(path) ⇒ Boolean

Returns:

  • (Boolean)


309
310
311
312
# File 'lib/system_builder/boot.rb', line 309

def exists?(path)
  path = expand_path(path)
  File.exists?(path) or File.symlink?(path)
end

#expand_path(path) ⇒ Object Also known as: file



304
305
306
# File 'lib/system_builder/boot.rb', line 304

def expand_path(path)
  File.join(@root,path)
end

#install(target, *sources) ⇒ Object



283
284
285
# File 'lib/system_builder/boot.rb', line 283

def install(target, *sources)
  FileUtils::sudo "cp --preserve=mode,timestamps #{sources.join(' ')} #{expand_path(target)}"
end

#mkdir(directory) ⇒ Object



279
280
281
# File 'lib/system_builder/boot.rb', line 279

def mkdir(directory)
  FileUtils::sudo "mkdir -p #{expand_path(directory)}"
end

#open(filename, &block) ⇒ Object



294
295
296
297
298
299
300
301
302
# File 'lib/system_builder/boot.rb', line 294

def open(filename, &block) 
  Tempfile.open(File.basename(filename)) do |f|
    yield f
    f.close
    
    File.chmod 0644, f.path
    install filename, f.path
  end
end

#rsync(target, *sources) ⇒ Object



287
288
289
290
291
292
# File 'lib/system_builder/boot.rb', line 287

def rsync(target, *sources)
  sources = sources.flatten
  options = (Hash === sources.last ? sources.pop : {})
  rsync_options = options.collect { |k,v| v == true ? "--#{k}" : "--#{k}='#{v}'" }
  FileUtils::sudo "rsync -a #{rsync_options.join(' ')} #{sources.join(' ')} #{expand_path(target)}"
end