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.



155
156
157
# File 'lib/system_builder/boot.rb', line 155

def initialize(image)
  @image = image
end

Instance Attribute Details

#imageObject (readonly)

Returns the value of attribute image.



153
154
155
# File 'lib/system_builder/boot.rb', line 153

def image
  @image
end

Instance Method Details

#apt_install(*packages) ⇒ Object



159
160
161
# File 'lib/system_builder/boot.rb', line 159

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

#cp(*arguments) ⇒ Object



163
164
165
# File 'lib/system_builder/boot.rb', line 163

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

#execute(&block) ⇒ Object



172
173
174
175
176
177
178
179
# File 'lib/system_builder/boot.rb', line 172

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

#prepare_runObject



181
182
183
# File 'lib/system_builder/boot.rb', line 181

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

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



167
168
169
# File 'lib/system_builder/boot.rb', line 167

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

#unprepare_runObject



185
186
187
# File 'lib/system_builder/boot.rb', line 185

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