Class: SystemBuilder::DebianBoot::Image
- Defined in:
- lib/system_builder/boot.rb
Instance Method Summary collapse
- #exists?(path) ⇒ Boolean
- #expand_path(path) ⇒ Object (also: #file)
-
#initialize(root) ⇒ Image
constructor
A new instance of Image.
- #install(target, *sources) ⇒ Object
- #mkdir(directory) ⇒ Object
- #open(filename, &block) ⇒ Object
- #rsync(target, *sources) ⇒ Object
Constructor Details
Instance Method Details
#exists?(path) ⇒ Boolean
309 310 311 312 |
# File 'lib/system_builder/boot.rb', line 309 def exists?(path) 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 (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(' ')} #{(target)}" end |
#mkdir(directory) ⇒ Object
279 280 281 |
# File 'lib/system_builder/boot.rb', line 279 def mkdir(directory) FileUtils::sudo "mkdir -p #{(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 = (Hash === sources.last ? sources.pop : {}) = .collect { |k,v| v == true ? "--#{k}" : "--#{k}='#{v}'" } FileUtils::sudo "rsync -a #{.join(' ')} #{sources.join(' ')} #{(target)}" end |