Class BoxGrinder::RPMBasedOSPlugin
In: lib/boxgrinder-build/plugins/os/rpm-based/rpm-based-os-plugin.rb
lib/boxgrinder-build/plugins/os/rpm-based/rpm-based-os-plugin.rb
Parent: BasePlugin

Methods

Public Instance methods

Add default repos (if present) to the list of additional repositories specified in appliance definition.

[Source]

    # File lib/boxgrinder-build/plugins/os/rpm-based/rpm-based-os-plugin.rb, line 40
40:     def add_repos(repos)
41:       return if repos.empty?
42: 
43:       repos[@appliance_config.os.version].each do |name, repo|
44:         r = { 'name' => name, 'ephemeral' => true }
45: 
46:         ['baseurl', 'mirrorlist'].each { |type| r[type] = substitute_vars(repo[type]) unless repo[type].nil? }
47: 
48:         @appliance_config.repos << r
49:       end
50:     end

Add default repos (if present) to the list of additional repositories specified in appliance definition.

[Source]

    # File lib/boxgrinder-build/plugins/os/rpm-based/rpm-based-os-plugin.rb, line 40
40:     def add_repos(repos)
41:       return if repos.empty?
42: 
43:       repos[@appliance_config.os.version].each do |name, repo|
44:         r = { 'name' => name, 'ephemeral' => true }
45: 
46:         ['baseurl', 'mirrorlist'].each { |type| r[type] = substitute_vars(repo[type]) unless repo[type].nil? }
47: 
48:         @appliance_config.repos << r
49:       end
50:     end

[Source]

    # File lib/boxgrinder-build/plugins/os/rpm-based/rpm-based-os-plugin.rb, line 28
28:     def after_init
29:       set_default_config_value('format', 'raw')
30: 
31:       register_deliverable(
32:           :disk => "#{@appliance_config.name}-sda.#{@plugin_config['format']}",
33:           :descriptor => "#{@appliance_config.name}.xml"
34:       )
35: 
36:       @linux_helper = LinuxHelper.new(:log => @log)
37:     end

[Source]

    # File lib/boxgrinder-build/plugins/os/rpm-based/rpm-based-os-plugin.rb, line 28
28:     def after_init
29:       set_default_config_value('format', 'raw')
30: 
31:       register_deliverable(
32:           :disk => "#{@appliance_config.name}-sda.#{@plugin_config['format']}",
33:           :descriptor => "#{@appliance_config.name}.xml"
34:       )
35: 
36:       @linux_helper = LinuxHelper.new(:log => @log)
37:     end

[Source]

     # File lib/boxgrinder-build/plugins/os/rpm-based/rpm-based-os-plugin.rb, line 221
221:     def apply_root_password(guestfs)
222:       @log.debug "Applying root password..."
223:       guestfs.sh("/usr/bin/passwd -d root")
224:       guestfs.sh("/usr/sbin/usermod -p '#{@appliance_config.os.password.crypt((0...8).map { 65.+(rand(25)).chr }.join)}' root")
225:       @log.debug "Password applied."
226:     end

[Source]

     # File lib/boxgrinder-build/plugins/os/rpm-based/rpm-based-os-plugin.rb, line 221
221:     def apply_root_password(guestfs)
222:       @log.debug "Applying root password..."
223:       guestfs.sh("/usr/bin/passwd -d root")
224:       guestfs.sh("/usr/sbin/usermod -p '#{@appliance_config.os.password.crypt((0...8).map { 65.+(rand(25)).chr }.join)}' root")
225:       @log.debug "Password applied."
226:     end

[Source]

     # File lib/boxgrinder-build/plugins/os/rpm-based/rpm-based-os-plugin.rb, line 61
 61:     def build_with_appliance_creator(appliance_definition_file, repos = {})
 62:       @appliance_definition_file = appliance_definition_file
 63: 
 64:       add_repos(repos) if @appliance_config.default_repos
 65: 
 66:       kickstart_file = Kickstart.new(@config, @appliance_config, @dir, :log => @log).create
 67:       RPMDependencyValidator.new(@config, @appliance_config, @dir, :log => @log).resolve_packages
 68: 
 69:       @log.info "Building #{@appliance_config.name} appliance..."
 70: 
 71:       execute_appliance_creator(kickstart_file)
 72: 
 73:       FileUtils.mv(Dir.glob("#{@dir.tmp}/#{@appliance_config.name}/*"), @dir.tmp)
 74:       FileUtils.rm_rf("#{@dir.tmp}/#{@appliance_config.name}/")
 75: 
 76:       @image_helper.customize([@deliverables.disk]) do |guestfs, guestfs_helper|
 77:         # TODO is this really needed?
 78:         @log.debug "Uploading '/etc/resolv.conf'..."
 79:         guestfs.upload("/etc/resolv.conf", "/etc/resolv.conf")
 80:         @log.debug "'/etc/resolv.conf' uploaded."
 81: 
 82:         change_configuration(guestfs_helper)
 83:         # TODO check if this is still required
 84:         apply_root_password(guestfs)
 85:         set_label_for_swap_partitions(guestfs, guestfs_helper)
 86:         use_labels_for_partitions(guestfs)
 87:         disable_firewall(guestfs)
 88:         set_motd(guestfs)
 89:         install_repos(guestfs)
 90:         install_files(guestfs)
 91: 
 92:         guestfs.sh("chkconfig firstboot off") if guestfs.exists('/etc/init.d/firstboot') != 0
 93: 
 94:         # https://issues.jboss.org/browse/BGBUILD-148
 95:         recreate_rpm_database(guestfs, guestfs_helper) if @config.os.name != @appliance_config.os.name or @config.os.version != @appliance_config.os.version
 96: 
 97:         execute_post(guestfs_helper)
 98: 
 99:         yield guestfs, guestfs_helper if block_given?
100:       end
101: 
102:       @log.info "Base image for #{@appliance_config.name} appliance was built successfully."
103:     end

[Source]

     # File lib/boxgrinder-build/plugins/os/rpm-based/rpm-based-os-plugin.rb, line 61
 61:     def build_with_appliance_creator(appliance_definition_file, repos = {})
 62:       @appliance_definition_file = appliance_definition_file
 63: 
 64:       add_repos(repos) if @appliance_config.default_repos
 65: 
 66:       kickstart_file = Kickstart.new(@config, @appliance_config, @dir, :log => @log).create
 67:       RPMDependencyValidator.new(@config, @appliance_config, @dir, :log => @log).resolve_packages
 68: 
 69:       @log.info "Building #{@appliance_config.name} appliance..."
 70: 
 71:       execute_appliance_creator(kickstart_file)
 72: 
 73:       FileUtils.mv(Dir.glob("#{@dir.tmp}/#{@appliance_config.name}/*"), @dir.tmp)
 74:       FileUtils.rm_rf("#{@dir.tmp}/#{@appliance_config.name}/")
 75: 
 76:       @image_helper.customize([@deliverables.disk]) do |guestfs, guestfs_helper|
 77:         # TODO is this really needed?
 78:         @log.debug "Uploading '/etc/resolv.conf'..."
 79:         guestfs.upload("/etc/resolv.conf", "/etc/resolv.conf")
 80:         @log.debug "'/etc/resolv.conf' uploaded."
 81: 
 82:         change_configuration(guestfs_helper)
 83:         # TODO check if this is still required
 84:         apply_root_password(guestfs)
 85:         set_label_for_swap_partitions(guestfs, guestfs_helper)
 86:         use_labels_for_partitions(guestfs)
 87:         disable_firewall(guestfs)
 88:         set_motd(guestfs)
 89:         install_repos(guestfs)
 90:         install_files(guestfs)
 91: 
 92:         guestfs.sh("chkconfig firstboot off") if guestfs.exists('/etc/init.d/firstboot') != 0
 93: 
 94:         # https://issues.jboss.org/browse/BGBUILD-148
 95:         recreate_rpm_database(guestfs, guestfs_helper) if @config.os.name != @appliance_config.os.name or @config.os.version != @appliance_config.os.version
 96: 
 97:         execute_post(guestfs_helper)
 98: 
 99:         yield guestfs, guestfs_helper if block_given?
100:       end
101: 
102:       @log.info "Base image for #{@appliance_config.name} appliance was built successfully."
103:     end

[Source]

     # File lib/boxgrinder-build/plugins/os/rpm-based/rpm-based-os-plugin.rb, line 228
228:     def change_configuration(guestfs_helper)
229:       guestfs_helper.augeas do
230:         set('/etc/ssh/sshd_config', 'UseDNS', 'no')
231:         set('/etc/sysconfig/selinux', 'SELINUX', 'permissive')
232:       end
233:     end

[Source]

     # File lib/boxgrinder-build/plugins/os/rpm-based/rpm-based-os-plugin.rb, line 228
228:     def change_configuration(guestfs_helper)
229:       guestfs_helper.augeas do
230:         set('/etc/ssh/sshd_config', 'UseDNS', 'no')
231:         set('/etc/sysconfig/selinux', 'SELINUX', 'permissive')
232:       end
233:     end

[Source]

     # File lib/boxgrinder-build/plugins/os/rpm-based/rpm-based-os-plugin.rb, line 140
140:     def cleanup_after_appliance_creator(pid)
141:       @log.debug "Sending TERM signal to process '#{pid}'..."
142:       Process.kill("TERM", pid)
143: 
144:       @log.debug "Waiting for process to be terminated..."
145:       Process.wait(pid)
146: 
147:       @log.debug "Cleaning appliance-creator mount points..."
148: 
149:       Dir["#{@dir.tmp}/imgcreate-*"].each do |dir|
150:         dev_mapper = @exec_helper.execute "mount | grep #{dir} | awk '{print $1}'"
151: 
152:         mappings = {}
153: 
154:         dev_mapper.each do |mapping|
155:           if mapping =~ /(loop\d+)p(\d+)/
156:             mappings[$1] = [] if mappings[$1].nil?
157:             mappings[$1] << $2 unless mappings[$1].include?($2)
158:           end
159:         end
160: 
161:         (['/var/cache/yum', '/dev/shm', '/dev/pts', '/proc', '/sys'] + @appliance_config.hardware.partitions.keys.reverse).each do |mount_point|
162:           @log.trace "Unmounting '#{mount_point}'..."
163:           @exec_helper.execute "umount -d #{dir}/install_root#{mount_point}"
164:         end
165: 
166:         mappings.each do |loop, partitions|
167:           @log.trace "Removing mappings from loop device #{loop}..."
168:           @exec_helper.execute "/sbin/kpartx -d /dev/#{loop}"
169:           @exec_helper.execute "losetup -d /dev/#{loop}"
170: 
171:           partitions.each do |part|
172:             @log.trace "Removing mapping for partition #{part} from loop device #{loop}..."
173:             @exec_helper.execute "rm /dev/#{loop}#{part}"
174:           end
175:         end
176:       end
177: 
178:       @log.debug "Cleaned up after appliance-creator."
179:     end

[Source]

     # File lib/boxgrinder-build/plugins/os/rpm-based/rpm-based-os-plugin.rb, line 140
140:     def cleanup_after_appliance_creator(pid)
141:       @log.debug "Sending TERM signal to process '#{pid}'..."
142:       Process.kill("TERM", pid)
143: 
144:       @log.debug "Waiting for process to be terminated..."
145:       Process.wait(pid)
146: 
147:       @log.debug "Cleaning appliance-creator mount points..."
148: 
149:       Dir["#{@dir.tmp}/imgcreate-*"].each do |dir|
150:         dev_mapper = @exec_helper.execute "mount | grep #{dir} | awk '{print $1}'"
151: 
152:         mappings = {}
153: 
154:         dev_mapper.each do |mapping|
155:           if mapping =~ /(loop\d+)p(\d+)/
156:             mappings[$1] = [] if mappings[$1].nil?
157:             mappings[$1] << $2 unless mappings[$1].include?($2)
158:           end
159:         end
160: 
161:         (['/var/cache/yum', '/dev/shm', '/dev/pts', '/proc', '/sys'] + @appliance_config.hardware.partitions.keys.reverse).each do |mount_point|
162:           @log.trace "Unmounting '#{mount_point}'..."
163:           @exec_helper.execute "umount -d #{dir}/install_root#{mount_point}"
164:         end
165: 
166:         mappings.each do |loop, partitions|
167:           @log.trace "Removing mappings from loop device #{loop}..."
168:           @exec_helper.execute "/sbin/kpartx -d /dev/#{loop}"
169:           @exec_helper.execute "losetup -d /dev/#{loop}"
170: 
171:           partitions.each do |part|
172:             @log.trace "Removing mapping for partition #{part} from loop device #{loop}..."
173:             @exec_helper.execute "rm /dev/#{loop}#{part}"
174:           end
175:         end
176:       end
177: 
178:       @log.debug "Cleaned up after appliance-creator."
179:     end

issues.jboss.org/browse/BGBUILD-177

[Source]

     # File lib/boxgrinder-build/plugins/os/rpm-based/rpm-based-os-plugin.rb, line 182
182:     def disable_firewall(guestfs)
183:       @log.debug "Disabling firewall..."
184:       guestfs.sh("lokkit -q --disabled")
185:       @log.debug "Firewall disabled."
186:     end

issues.jboss.org/browse/BGBUILD-177

[Source]

     # File lib/boxgrinder-build/plugins/os/rpm-based/rpm-based-os-plugin.rb, line 182
182:     def disable_firewall(guestfs)
183:       @log.debug "Disabling firewall..."
184:       guestfs.sh("lokkit -q --disabled")
185:       @log.debug "Firewall disabled."
186:     end

[Source]

     # File lib/boxgrinder-build/plugins/os/rpm-based/rpm-based-os-plugin.rb, line 105
105:     def execute_appliance_creator(kickstart_file)
106:       begin
107:         @exec_helper.execute "appliance-creator -d -v -t '#{@dir.tmp}' --cache=#{@config.dir.cache}/rpms-cache/#{@appliance_config.path.main} --config '#{kickstart_file}' -o '#{@dir.tmp}' --name '#{@appliance_config.name}' --vmem #{@appliance_config.hardware.memory} --vcpu #{@appliance_config.hardware.cpus} --format #{@plugin_config['format']}"
108:       rescue InterruptionError => e
109:         cleanup_after_appliance_creator(e.pid)
110:         abort
111:       end
112:     end

[Source]

     # File lib/boxgrinder-build/plugins/os/rpm-based/rpm-based-os-plugin.rb, line 105
105:     def execute_appliance_creator(kickstart_file)
106:       begin
107:         @exec_helper.execute "appliance-creator -d -v -t '#{@dir.tmp}' --cache=#{@config.dir.cache}/rpms-cache/#{@appliance_config.path.main} --config '#{kickstart_file}' -o '#{@dir.tmp}' --name '#{@appliance_config.name}' --vmem #{@appliance_config.hardware.memory} --vcpu #{@appliance_config.hardware.cpus} --format #{@plugin_config['format']}"
108:       rescue InterruptionError => e
109:         cleanup_after_appliance_creator(e.pid)
110:         abort
111:       end
112:     end

[Source]

     # File lib/boxgrinder-build/plugins/os/rpm-based/rpm-based-os-plugin.rb, line 114
114:     def execute_post(guestfs_helper)
115:       @log.info "Executing post operations after build..."
116:       unless @appliance_config.post['base'].nil?
117:         @appliance_config.post['base'].each do |cmd|
118:           guestfs_helper.sh(cmd, :arch => @appliance_config.hardware.arch)
119:         end
120:         @log.debug "Post commands from appliance definition file executed."
121:       else
122:         @log.debug "No commands specified, skipping."
123:       end
124:     end

[Source]

     # File lib/boxgrinder-build/plugins/os/rpm-based/rpm-based-os-plugin.rb, line 114
114:     def execute_post(guestfs_helper)
115:       @log.info "Executing post operations after build..."
116:       unless @appliance_config.post['base'].nil?
117:         @appliance_config.post['base'].each do |cmd|
118:           guestfs_helper.sh(cmd, :arch => @appliance_config.hardware.arch)
119:         end
120:         @log.debug "Post commands from appliance definition file executed."
121:       else
122:         @log.debug "No commands specified, skipping."
123:       end
124:     end

Copies specified files into appliance.

There are two types of paths:

  1. remote - starting with http:// or https:// or ftp://
  2. local - all other.

Please use relative paths. Relative means relative to the appliance definition file. Using absolute paths will cause creating whole directory structure in appliance, which is most probably not exactly what you want.

issues.jboss.org/browse/BGBUILD-276

[Source]

     # File lib/boxgrinder-build/plugins/os/rpm-based/rpm-based-os-plugin.rb, line 283
283:     def install_files(guestfs)
284:       @log.debug "Installing files specified in appliance definition file..."
285: 
286:       @appliance_config.files.each do |dir, files|
287: 
288:         @log.debug "Proceding files for '#{dir}' destination directory..."
289: 
290:         local_files = []
291: 
292:         # Create the directory if it doesn't exists
293:         guestfs.mkdir_p(dir) unless guestfs.exists(dir) != 0
294: 
295:         files.each do |f|
296:           if f.match(/^(http|ftp|https):\/\//)
297:             # Remote url provided
298:             @log.trace "Remote url detected: '#{f}'."
299: 
300:             # We have a remote file, try to download it using curl!
301:             guestfs.sh("cd #{dir} && curl -O -L #{f}")
302:           else
303:             @log.trace "Local path detected: '#{f}'."
304: 
305:             file_path = (f.match(/^\//) ? f : "#{File.dirname(@appliance_definition_file)}/#{f}")
306: 
307:             # TODO validate this earlier
308:             raise ValidationError, "File '#{f}' specified in files section of appliance definition file doesn't exists." unless File.exists?(file_path)
309: 
310:             local_files << f
311:           end
312:         end
313: 
314:         next if local_files.empty?
315: 
316:         @log.trace "Tarring files..."
317:         @exec_helper.execute("cd #{File.dirname(@appliance_definition_file)} && tar -cvf /tmp/bg_install_files.tar --wildcards #{local_files.join(' ')}")
318:         @log.trace "Files tarred."
319: 
320:         @log.trace "Uploading and unpacking..."
321:         guestfs.tar_in("/tmp/bg_install_files.tar", dir)
322:         @log.trace "Files uploaded."
323: 
324:       end
325:       @log.debug "Files installed."
326:     end

Copies specified files into appliance.

There are two types of paths:

  1. remote - starting with http:// or https:// or ftp://
  2. local - all other.

Please use relative paths. Relative means relative to the appliance definition file. Using absolute paths will cause creating whole directory structure in appliance, which is most probably not exactly what you want.

issues.jboss.org/browse/BGBUILD-276

[Source]

     # File lib/boxgrinder-build/plugins/os/rpm-based/rpm-based-os-plugin.rb, line 283
283:     def install_files(guestfs)
284:       @log.debug "Installing files specified in appliance definition file..."
285: 
286:       @appliance_config.files.each do |dir, files|
287: 
288:         @log.debug "Proceding files for '#{dir}' destination directory..."
289: 
290:         local_files = []
291: 
292:         # Create the directory if it doesn't exists
293:         guestfs.mkdir_p(dir) unless guestfs.exists(dir) != 0
294: 
295:         files.each do |f|
296:           if f.match(/^(http|ftp|https):\/\//)
297:             # Remote url provided
298:             @log.trace "Remote url detected: '#{f}'."
299: 
300:             # We have a remote file, try to download it using curl!
301:             guestfs.sh("cd #{dir} && curl -O -L #{f}")
302:           else
303:             @log.trace "Local path detected: '#{f}'."
304: 
305:             file_path = (f.match(/^\//) ? f : "#{File.dirname(@appliance_definition_file)}/#{f}")
306: 
307:             # TODO validate this earlier
308:             raise ValidationError, "File '#{f}' specified in files section of appliance definition file doesn't exists." unless File.exists?(file_path)
309: 
310:             local_files << f
311:           end
312:         end
313: 
314:         next if local_files.empty?
315: 
316:         @log.trace "Tarring files..."
317:         @exec_helper.execute("cd #{File.dirname(@appliance_definition_file)} && tar -cvf /tmp/bg_install_files.tar --wildcards #{local_files.join(' ')}")
318:         @log.trace "Files tarred."
319: 
320:         @log.trace "Uploading and unpacking..."
321:         guestfs.tar_in("/tmp/bg_install_files.tar", dir)
322:         @log.trace "Files uploaded."
323: 
324:       end
325:       @log.debug "Files installed."
326:     end

[Source]

     # File lib/boxgrinder-build/plugins/os/rpm-based/rpm-based-os-plugin.rb, line 252
252:     def install_repos(guestfs)
253:       @log.debug "Installing repositories from appliance definition file..."
254:       @appliance_config.repos.each do |repo|
255:         if repo['ephemeral']
256:           @log.debug "Repository '#{repo['name']}' is an ephemeral repo. It'll not be installed in the appliance."
257:           next
258:         end
259: 
260:         @log.debug "Installing #{repo['name']} repo..."
261:         repo_file = File.read("#{File.dirname(__FILE__)}/src/base.repo").gsub(/#NAME#/, repo['name'])
262: 
263:         ['baseurl', 'mirrorlist'].each do |type|
264:           repo_file << ("#{type}=#{repo[type]}\n") unless repo[type].nil?
265:         end
266: 
267:         guestfs.write_file("/etc/yum.repos.d/#{repo['name']}.repo", repo_file, 0)
268:       end
269:       @log.debug "Repositories installed."
270:     end

[Source]

     # File lib/boxgrinder-build/plugins/os/rpm-based/rpm-based-os-plugin.rb, line 252
252:     def install_repos(guestfs)
253:       @log.debug "Installing repositories from appliance definition file..."
254:       @appliance_config.repos.each do |repo|
255:         if repo['ephemeral']
256:           @log.debug "Repository '#{repo['name']}' is an ephemeral repo. It'll not be installed in the appliance."
257:           next
258:         end
259: 
260:         @log.debug "Installing #{repo['name']} repo..."
261:         repo_file = File.read("#{File.dirname(__FILE__)}/src/base.repo").gsub(/#NAME#/, repo['name'])
262: 
263:         ['baseurl', 'mirrorlist'].each do |type|
264:           repo_file << ("#{type}=#{repo[type]}\n") unless repo[type].nil?
265:         end
266: 
267:         guestfs.write_file("/etc/yum.repos.d/#{repo['name']}.repo", repo_file, 0)
268:       end
269:       @log.debug "Repositories installed."
270:     end

[Source]

     # File lib/boxgrinder-build/plugins/os/rpm-based/rpm-based-os-plugin.rb, line 248
248:     def recreate_kernel_image(guestfs, modules = [])
249:       @linux_helper.recreate_kernel_image(guestfs, modules)
250:     end

[Source]

     # File lib/boxgrinder-build/plugins/os/rpm-based/rpm-based-os-plugin.rb, line 248
248:     def recreate_kernel_image(guestfs, modules = [])
249:       @linux_helper.recreate_kernel_image(guestfs, modules)
250:     end

issues.jboss.org/browse/BGBUILD-148

[Source]

     # File lib/boxgrinder-build/plugins/os/rpm-based/rpm-based-os-plugin.rb, line 127
127:     def recreate_rpm_database(guestfs, guestfs_helper)
128:       @log.debug "Recreating RPM database..."
129: 
130:       guestfs.download("/var/lib/rpm/Packages", "#{@dir.tmp}/Packages")
131:       @exec_helper.execute("/usr/lib/rpm/rpmdb_dump #{@dir.tmp}/Packages > #{@dir.tmp}/Packages.dump")
132:       guestfs.upload("#{@dir.tmp}/Packages.dump", "/tmp/Packages.dump")
133:       guestfs.sh("rm -rf /var/lib/rpm/*")
134:       guestfs_helper.sh("cd /var/lib/rpm/ && cat /tmp/Packages.dump | /usr/lib/rpm/rpmdb_load Packages")
135:       guestfs_helper.sh("rpm --rebuilddb")
136: 
137:       @log.debug "RPM database recreated..."
138:     end

issues.jboss.org/browse/BGBUILD-148

[Source]

     # File lib/boxgrinder-build/plugins/os/rpm-based/rpm-based-os-plugin.rb, line 127
127:     def recreate_rpm_database(guestfs, guestfs_helper)
128:       @log.debug "Recreating RPM database..."
129: 
130:       guestfs.download("/var/lib/rpm/Packages", "#{@dir.tmp}/Packages")
131:       @exec_helper.execute("/usr/lib/rpm/rpmdb_dump #{@dir.tmp}/Packages > #{@dir.tmp}/Packages.dump")
132:       guestfs.upload("#{@dir.tmp}/Packages.dump", "/tmp/Packages.dump")
133:       guestfs.sh("rm -rf /var/lib/rpm/*")
134:       guestfs_helper.sh("cd /var/lib/rpm/ && cat /tmp/Packages.dump | /usr/lib/rpm/rpmdb_load Packages")
135:       guestfs_helper.sh("rpm --rebuilddb")
136: 
137:       @log.debug "RPM database recreated..."
138:     end

issues.jboss.org/browse/BGBUILD-301

[Source]

     # File lib/boxgrinder-build/plugins/os/rpm-based/rpm-based-os-plugin.rb, line 189
189:     def set_label_for_swap_partitions(guestfs, guestfs_helper)
190:       @log.trace "Searching for swap partition to set label..."
191: 
192:       guestfs_helper.mountable_partitions(guestfs.list_devices.first, :list_swap => true).each do |p|
193:         if guestfs.vfs_type(p).eql?('swap')
194:           @log.debug "Setting 'swap' label for partiiton '#{p}'."
195:           guestfs.mkswap_L('swap', p)
196:           @log.debug "Label set."
197:           # We assume here that nobody will want to have two swap partitions
198:           break
199:         end
200:       end
201:     end

issues.jboss.org/browse/BGBUILD-301

[Source]

     # File lib/boxgrinder-build/plugins/os/rpm-based/rpm-based-os-plugin.rb, line 189
189:     def set_label_for_swap_partitions(guestfs, guestfs_helper)
190:       @log.trace "Searching for swap partition to set label..."
191: 
192:       guestfs_helper.mountable_partitions(guestfs.list_devices.first, :list_swap => true).each do |p|
193:         if guestfs.vfs_type(p).eql?('swap')
194:           @log.debug "Setting 'swap' label for partiiton '#{p}'."
195:           guestfs.mkswap_L('swap', p)
196:           @log.debug "Label set."
197:           # We assume here that nobody will want to have two swap partitions
198:           break
199:         end
200:       end
201:     end

[Source]

     # File lib/boxgrinder-build/plugins/os/rpm-based/rpm-based-os-plugin.rb, line 235
235:     def set_motd(guestfs)
236:       @log.debug "Setting up '/etc/motd'..."
237:       # set nice banner for SSH
238:       motd_file = "/etc/init.d/motd"
239:       guestfs.upload("#{File.dirname(__FILE__)}/src/motd.init", motd_file)
240:       guestfs.sh("sed -i s/#VERSION#/'#{@appliance_config.version}.#{@appliance_config.release}'/ #{motd_file}")
241:       guestfs.sh("sed -i s/#APPLIANCE#/'#{@appliance_config.name} appliance'/ #{motd_file}")
242: 
243:       guestfs.sh("/bin/chmod +x #{motd_file}")
244:       guestfs.sh("/sbin/chkconfig --add motd")
245:       @log.debug "'/etc/motd' is nice now."
246:     end

[Source]

     # File lib/boxgrinder-build/plugins/os/rpm-based/rpm-based-os-plugin.rb, line 235
235:     def set_motd(guestfs)
236:       @log.debug "Setting up '/etc/motd'..."
237:       # set nice banner for SSH
238:       motd_file = "/etc/init.d/motd"
239:       guestfs.upload("#{File.dirname(__FILE__)}/src/motd.init", motd_file)
240:       guestfs.sh("sed -i s/#VERSION#/'#{@appliance_config.version}.#{@appliance_config.release}'/ #{motd_file}")
241:       guestfs.sh("sed -i s/#APPLIANCE#/'#{@appliance_config.name} appliance'/ #{motd_file}")
242: 
243:       guestfs.sh("/bin/chmod +x #{motd_file}")
244:       guestfs.sh("/sbin/chkconfig --add motd")
245:       @log.debug "'/etc/motd' is nice now."
246:     end

Substitute variables in selected string.

[Source]

    # File lib/boxgrinder-build/plugins/os/rpm-based/rpm-based-os-plugin.rb, line 53
53:     def substitute_vars(str)
54:       return if str.nil?
55:       @appliance_config.variables.keys.each do |var|
56:         str = str.gsub("##{var}#", @appliance_config.variables[var])
57:       end
58:       str
59:     end

Substitute variables in selected string.

[Source]

    # File lib/boxgrinder-build/plugins/os/rpm-based/rpm-based-os-plugin.rb, line 53
53:     def substitute_vars(str)
54:       return if str.nil?
55:       @appliance_config.variables.keys.each do |var|
56:         str = str.gsub("##{var}#", @appliance_config.variables[var])
57:       end
58:       str
59:     end

[Source]

     # File lib/boxgrinder-build/plugins/os/rpm-based/rpm-based-os-plugin.rb, line 203
203:     def use_labels_for_partitions(guestfs)
204:       @log.debug "Using labels for partitions..."
205:       device = guestfs.list_devices.first
206: 
207:       # /etc/fstab
208:       if fstab = guestfs.read_file('/etc/fstab').gsub!(/^(\/dev\/sda.)/) { |path| "LABEL=#{guestfs.vfs_label(path.gsub('/dev/sda', device))}" }
209:         guestfs.write_file('/etc/fstab', fstab, 0)
210:       end
211: 
212:       # /boot/grub/grub.conf
213:       if guestfs.exists('/boot/grub/grub.conf') != 0
214:         if grub = guestfs.read_file('/boot/grub/grub.conf').gsub!(/(\/dev\/sda.)/) { |path| "LABEL=#{guestfs.vfs_label(path.gsub('/dev/sda', device))}" }
215:           guestfs.write_file('/boot/grub/grub.conf', grub, 0)
216:         end
217:       end
218:       @log.debug "Done."
219:     end

[Source]

     # File lib/boxgrinder-build/plugins/os/rpm-based/rpm-based-os-plugin.rb, line 203
203:     def use_labels_for_partitions(guestfs)
204:       @log.debug "Using labels for partitions..."
205:       device = guestfs.list_devices.first
206: 
207:       # /etc/fstab
208:       if fstab = guestfs.read_file('/etc/fstab').gsub!(/^(\/dev\/sda.)/) { |path| "LABEL=#{guestfs.vfs_label(path.gsub('/dev/sda', device))}" }
209:         guestfs.write_file('/etc/fstab', fstab, 0)
210:       end
211: 
212:       # /boot/grub/grub.conf
213:       if guestfs.exists('/boot/grub/grub.conf') != 0
214:         if grub = guestfs.read_file('/boot/grub/grub.conf').gsub!(/(\/dev\/sda.)/) { |path| "LABEL=#{guestfs.vfs_label(path.gsub('/dev/sda', device))}" }
215:           guestfs.write_file('/boot/grub/grub.conf', grub, 0)
216:         end
217:       end
218:       @log.debug "Done."
219:     end

[Validate]