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 |
# File lib/boxgrinder-build/plugins/os/rpm-based/rpm-based-os-plugin.rb, line 27 27: def after_init 28: set_default_config_value('format', 'raw') 29: 30: register_deliverable( 31: :disk => "#{@appliance_config.name}-sda.#{@plugin_config['format']}", 32: :descriptor => "#{@appliance_config.name}.xml" 33: ) 34: 35: @linux_helper = LinuxHelper.new(:log => @log) 36: end
# File lib/boxgrinder-build/plugins/os/rpm-based/rpm-based-os-plugin.rb, line 27 27: def after_init 28: set_default_config_value('format', 'raw') 29: 30: register_deliverable( 31: :disk => "#{@appliance_config.name}-sda.#{@plugin_config['format']}", 32: :descriptor => "#{@appliance_config.name}.xml" 33: ) 34: 35: @linux_helper = LinuxHelper.new(:log => @log) 36: end
# File lib/boxgrinder-build/plugins/os/rpm-based/rpm-based-os-plugin.rb, line 269 269: def apply_root_password(guestfs) 270: @log.debug "Applying root password..." 271: guestfs.sh("/usr/bin/passwd -d root") 272: guestfs.sh("/usr/sbin/usermod -p '#{@appliance_config.os.password.crypt((0...8).map { 65.+(rand(25)).chr }.join)}' root") 273: @log.debug "Password applied." 274: end
# File lib/boxgrinder-build/plugins/os/rpm-based/rpm-based-os-plugin.rb, line 269 269: def apply_root_password(guestfs) 270: @log.debug "Applying root password..." 271: guestfs.sh("/usr/bin/passwd -d root") 272: guestfs.sh("/usr/sbin/usermod -p '#{@appliance_config.os.password.crypt((0...8).map { 65.+(rand(25)).chr }.join)}' root") 273: @log.debug "Password applied." 274: end
# File lib/boxgrinder-build/plugins/os/rpm-based/rpm-based-os-plugin.rb, line 91 91: def build_with_appliance_creator(appliance_definition_file, repos = {}) 92: if File.extname(appliance_definition_file).eql?('.ks') 93: kickstart_file = appliance_definition_file 94: else 95: kickstart_file = Kickstart.new(@config, @appliance_config, repos, @dir, :log => @log).create 96: RPMDependencyValidator.new(@config, @appliance_config, @dir, kickstart_file, @options).resolve_packages 97: end 98: 99: @log.info "Building #{@appliance_config.name} appliance..." 100: 101: execute_appliance_creator(kickstart_file) 102: 103: FileUtils.mv(Dir.glob("#{@dir.tmp}/#{@appliance_config.name}/*"), @dir.tmp) 104: FileUtils.rm_rf("#{@dir.tmp}/#{@appliance_config.name}/") 105: 106: @image_helper.customize([@deliverables.disk]) do |guestfs, guestfs_helper| 107: # TODO is this really needed? 108: @log.debug "Uploading '/etc/resolv.conf'..." 109: guestfs.upload("/etc/resolv.conf", "/etc/resolv.conf") 110: @log.debug "'/etc/resolv.conf' uploaded." 111: 112: change_configuration(guestfs_helper) 113: # TODO check if this is still required 114: apply_root_password(guestfs) 115: use_labels_for_partitions(guestfs) 116: disable_firewall(guestfs) 117: set_motd(guestfs) 118: install_repos(guestfs) 119: 120: if @appliance_config.os.name == 'fedora' and @appliance_config.os.version == '15' 121: disable_biosdevname(guestfs) 122: change_runlevel(guestfs) 123: disable_netfs(guestfs) 124: link_mtab(guestfs) 125: end 126: 127: guestfs.sh("chkconfig firstboot off") if guestfs.exists('/etc/init.d/firstboot') != 0 128: 129: @log.info "Executing post operations after build..." 130: 131: unless @appliance_config.post['base'].nil? 132: @appliance_config.post['base'].each do |cmd| 133: guestfs_helper.sh(cmd, :arch => @appliance_config.hardware.arch) 134: end 135: @log.debug "Post commands from appliance definition file executed." 136: else 137: @log.debug "No commands specified, skipping." 138: end 139: 140: yield guestfs, guestfs_helper if block_given? 141: 142: @log.info "Post operations executed." 143: 144: # https://issues.jboss.org/browse/BGBUILD-148 145: recreate_rpm_database(guestfs, guestfs_helper) if @config.os.name != @appliance_config.os.name or @config.os.version != @appliance_config.os.version 146: end 147: 148: @log.info "Base image for #{@appliance_config.name} appliance was built successfully." 149: end
# File lib/boxgrinder-build/plugins/os/rpm-based/rpm-based-os-plugin.rb, line 91 91: def build_with_appliance_creator(appliance_definition_file, repos = {}) 92: if File.extname(appliance_definition_file).eql?('.ks') 93: kickstart_file = appliance_definition_file 94: else 95: kickstart_file = Kickstart.new(@config, @appliance_config, repos, @dir, :log => @log).create 96: RPMDependencyValidator.new(@config, @appliance_config, @dir, kickstart_file, @options).resolve_packages 97: end 98: 99: @log.info "Building #{@appliance_config.name} appliance..." 100: 101: execute_appliance_creator(kickstart_file) 102: 103: FileUtils.mv(Dir.glob("#{@dir.tmp}/#{@appliance_config.name}/*"), @dir.tmp) 104: FileUtils.rm_rf("#{@dir.tmp}/#{@appliance_config.name}/") 105: 106: @image_helper.customize([@deliverables.disk]) do |guestfs, guestfs_helper| 107: # TODO is this really needed? 108: @log.debug "Uploading '/etc/resolv.conf'..." 109: guestfs.upload("/etc/resolv.conf", "/etc/resolv.conf") 110: @log.debug "'/etc/resolv.conf' uploaded." 111: 112: change_configuration(guestfs_helper) 113: # TODO check if this is still required 114: apply_root_password(guestfs) 115: use_labels_for_partitions(guestfs) 116: disable_firewall(guestfs) 117: set_motd(guestfs) 118: install_repos(guestfs) 119: 120: if @appliance_config.os.name == 'fedora' and @appliance_config.os.version == '15' 121: disable_biosdevname(guestfs) 122: change_runlevel(guestfs) 123: disable_netfs(guestfs) 124: link_mtab(guestfs) 125: end 126: 127: guestfs.sh("chkconfig firstboot off") if guestfs.exists('/etc/init.d/firstboot') != 0 128: 129: @log.info "Executing post operations after build..." 130: 131: unless @appliance_config.post['base'].nil? 132: @appliance_config.post['base'].each do |cmd| 133: guestfs_helper.sh(cmd, :arch => @appliance_config.hardware.arch) 134: end 135: @log.debug "Post commands from appliance definition file executed." 136: else 137: @log.debug "No commands specified, skipping." 138: end 139: 140: yield guestfs, guestfs_helper if block_given? 141: 142: @log.info "Post operations executed." 143: 144: # https://issues.jboss.org/browse/BGBUILD-148 145: recreate_rpm_database(guestfs, guestfs_helper) if @config.os.name != @appliance_config.os.name or @config.os.version != @appliance_config.os.version 146: end 147: 148: @log.info "Base image for #{@appliance_config.name} appliance was built successfully." 149: end
# File lib/boxgrinder-build/plugins/os/rpm-based/rpm-based-os-plugin.rb, line 276 276: def change_configuration(guestfs_helper) 277: guestfs_helper.augeas do 278: set('/etc/ssh/sshd_config', 'UseDNS', 'no') 279: set('/etc/sysconfig/selinux', 'SELINUX', 'permissive') 280: end 281: end
# File lib/boxgrinder-build/plugins/os/rpm-based/rpm-based-os-plugin.rb, line 276 276: def change_configuration(guestfs_helper) 277: guestfs_helper.augeas do 278: set('/etc/ssh/sshd_config', 'UseDNS', 'no') 279: set('/etc/sysconfig/selinux', 'SELINUX', 'permissive') 280: end 281: end
issues.jboss.org/browse/BGBUILD-204
# File lib/boxgrinder-build/plugins/os/rpm-based/rpm-based-os-plugin.rb, line 168 168: def change_runlevel(guestfs) 169: @log.debug "Changing runlevel to multi-user non-graphical..." 170: guestfs.rm("/etc/systemd/system/default.target") 171: guestfs.ln_sf("/lib/systemd/system/multi-user.target", "/etc/systemd/system/default.target") 172: @log.debug "Runlevel changed." 173: end
issues.jboss.org/browse/BGBUILD-204
# File lib/boxgrinder-build/plugins/os/rpm-based/rpm-based-os-plugin.rb, line 168 168: def change_runlevel(guestfs) 169: @log.debug "Changing runlevel to multi-user non-graphical..." 170: guestfs.rm("/etc/systemd/system/default.target") 171: guestfs.ln_sf("/lib/systemd/system/multi-user.target", "/etc/systemd/system/default.target") 172: @log.debug "Runlevel changed." 173: end
# File lib/boxgrinder-build/plugins/os/rpm-based/rpm-based-os-plugin.rb, line 203 203: def cleanup_after_appliance_creator(pid) 204: @log.debug "Sending TERM signal to process '#{pid}'..." 205: Process.kill("TERM", pid) 206: 207: @log.debug "Waiting for process to be terminated..." 208: Process.wait(pid) 209: 210: @log.debug "Cleaning appliance-creator mount points..." 211: 212: Dir["#{@dir.tmp}/imgcreate-*"].each do |dir| 213: dev_mapper = @exec_helper.execute "mount | grep #{dir} | awk '{print $1}'" 214: 215: mappings = {} 216: 217: dev_mapper.each do |mapping| 218: if mapping =~ /(loop\d+)p(\d+)/ 219: mappings[$1] = [] if mappings[$1].nil? 220: mappings[$1] << $2 unless mappings[$1].include?($2) 221: end 222: end 223: 224: (['/var/cache/yum', '/dev/shm', '/dev/pts', '/proc', '/sys'] + @appliance_config.hardware.partitions.keys.reverse).each do |mount_point| 225: @log.trace "Unmounting '#{mount_point}'..." 226: @exec_helper.execute "umount -d #{dir}/install_root#{mount_point}" 227: end 228: 229: mappings.each do |loop, partitions| 230: @log.trace "Removing mappings from loop device #{loop}..." 231: @exec_helper.execute "/sbin/kpartx -d /dev/#{loop}" 232: @exec_helper.execute "losetup -d /dev/#{loop}" 233: 234: partitions.each do |part| 235: @log.trace "Removing mapping for partition #{part} from loop device #{loop}..." 236: @exec_helper.execute "rm /dev/#{loop}#{part}" 237: end 238: end 239: end 240: 241: @log.debug "Cleaned up after appliance-creator." 242: end
# File lib/boxgrinder-build/plugins/os/rpm-based/rpm-based-os-plugin.rb, line 203 203: def cleanup_after_appliance_creator(pid) 204: @log.debug "Sending TERM signal to process '#{pid}'..." 205: Process.kill("TERM", pid) 206: 207: @log.debug "Waiting for process to be terminated..." 208: Process.wait(pid) 209: 210: @log.debug "Cleaning appliance-creator mount points..." 211: 212: Dir["#{@dir.tmp}/imgcreate-*"].each do |dir| 213: dev_mapper = @exec_helper.execute "mount | grep #{dir} | awk '{print $1}'" 214: 215: mappings = {} 216: 217: dev_mapper.each do |mapping| 218: if mapping =~ /(loop\d+)p(\d+)/ 219: mappings[$1] = [] if mappings[$1].nil? 220: mappings[$1] << $2 unless mappings[$1].include?($2) 221: end 222: end 223: 224: (['/var/cache/yum', '/dev/shm', '/dev/pts', '/proc', '/sys'] + @appliance_config.hardware.partitions.keys.reverse).each do |mount_point| 225: @log.trace "Unmounting '#{mount_point}'..." 226: @exec_helper.execute "umount -d #{dir}/install_root#{mount_point}" 227: end 228: 229: mappings.each do |loop, partitions| 230: @log.trace "Removing mappings from loop device #{loop}..." 231: @exec_helper.execute "/sbin/kpartx -d /dev/#{loop}" 232: @exec_helper.execute "losetup -d /dev/#{loop}" 233: 234: partitions.each do |part| 235: @log.trace "Removing mapping for partition #{part} from loop device #{loop}..." 236: @exec_helper.execute "rm /dev/#{loop}#{part}" 237: end 238: end 239: end 240: 241: @log.debug "Cleaned up after appliance-creator." 242: end
issues.jboss.org/browse/BGBUILD-204
# File lib/boxgrinder-build/plugins/os/rpm-based/rpm-based-os-plugin.rb, line 161 161: def disable_biosdevname(guestfs) 162: @log.debug "Disabling biosdevname for Fedora 15..." 163: guestfs.sh('sed -i "s/kernel\(.*\)/kernel\1 biosdevname=0/g" /boot/grub/grub.conf') 164: @log.debug "Biosdevname disabled." 165: end
issues.jboss.org/browse/BGBUILD-204
# File lib/boxgrinder-build/plugins/os/rpm-based/rpm-based-os-plugin.rb, line 161 161: def disable_biosdevname(guestfs) 162: @log.debug "Disabling biosdevname for Fedora 15..." 163: guestfs.sh('sed -i "s/kernel\(.*\)/kernel\1 biosdevname=0/g" /boot/grub/grub.conf') 164: @log.debug "Biosdevname disabled." 165: end
issues.jboss.org/browse/BGBUILD-177
# File lib/boxgrinder-build/plugins/os/rpm-based/rpm-based-os-plugin.rb, line 245 245: def disable_firewall(guestfs) 246: @log.debug "Disabling firewall..." 247: guestfs.sh("lokkit -q --disabled") 248: @log.debug "Firewall disabled." 249: end
issues.jboss.org/browse/BGBUILD-177
# File lib/boxgrinder-build/plugins/os/rpm-based/rpm-based-os-plugin.rb, line 245 245: def disable_firewall(guestfs) 246: @log.debug "Disabling firewall..." 247: guestfs.sh("lokkit -q --disabled") 248: @log.debug "Firewall disabled." 249: end
issues.jboss.org/browse/BGBUILD-204
# File lib/boxgrinder-build/plugins/os/rpm-based/rpm-based-os-plugin.rb, line 176 176: def disable_netfs(guestfs) 177: @log.debug "Disabling network filesystem mounting..." 178: guestfs.sh("chkconfig netfs off") 179: @log.debug "Network filesystem mounting disabled." 180: end
issues.jboss.org/browse/BGBUILD-204
# File lib/boxgrinder-build/plugins/os/rpm-based/rpm-based-os-plugin.rb, line 176 176: def disable_netfs(guestfs) 177: @log.debug "Disabling network filesystem mounting..." 178: guestfs.sh("chkconfig netfs off") 179: @log.debug "Network filesystem mounting disabled." 180: end
# File lib/boxgrinder-build/plugins/os/rpm-based/rpm-based-os-plugin.rb, line 151 151: def execute_appliance_creator(kickstart_file) 152: begin 153: @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']}" 154: rescue InterruptionError => e 155: cleanup_after_appliance_creator(e.pid) 156: abort 157: end 158: end
# File lib/boxgrinder-build/plugins/os/rpm-based/rpm-based-os-plugin.rb, line 151 151: def execute_appliance_creator(kickstart_file) 152: begin 153: @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']}" 154: rescue InterruptionError => e 155: cleanup_after_appliance_creator(e.pid) 156: abort 157: end 158: end
# File lib/boxgrinder-build/plugins/os/rpm-based/rpm-based-os-plugin.rb, line 300 300: def install_repos(guestfs) 301: @log.debug "Installing repositories from appliance definition file..." 302: @appliance_config.repos.each do |repo| 303: if repo['ephemeral'] 304: @log.debug "Repository '#{repo['name']}' is an ephemeral repo. It'll not be installed in the appliance." 305: next 306: end 307: 308: @log.debug "Installing #{repo['name']} repo..." 309: repo_file = File.read("#{File.dirname(__FILE__)}/src/base.repo").gsub(/#NAME#/, repo['name']) 310: 311: ['baseurl', 'mirrorlist'].each do |type| 312: repo_file << ("#{type}=#{repo[type]}\n") unless repo[type].nil? 313: end 314: 315: guestfs.write_file("/etc/yum.repos.d/#{repo['name']}.repo", repo_file, 0) 316: end 317: @log.debug "Repositories installed." 318: end
# File lib/boxgrinder-build/plugins/os/rpm-based/rpm-based-os-plugin.rb, line 300 300: def install_repos(guestfs) 301: @log.debug "Installing repositories from appliance definition file..." 302: @appliance_config.repos.each do |repo| 303: if repo['ephemeral'] 304: @log.debug "Repository '#{repo['name']}' is an ephemeral repo. It'll not be installed in the appliance." 305: next 306: end 307: 308: @log.debug "Installing #{repo['name']} repo..." 309: repo_file = File.read("#{File.dirname(__FILE__)}/src/base.repo").gsub(/#NAME#/, repo['name']) 310: 311: ['baseurl', 'mirrorlist'].each do |type| 312: repo_file << ("#{type}=#{repo[type]}\n") unless repo[type].nil? 313: end 314: 315: guestfs.write_file("/etc/yum.repos.d/#{repo['name']}.repo", repo_file, 0) 316: end 317: @log.debug "Repositories installed." 318: end
issues.jboss.org/browse/BGBUILD-209
# File lib/boxgrinder-build/plugins/os/rpm-based/rpm-based-os-plugin.rb, line 183 183: def link_mtab(guestfs) 184: @log.debug "Linking /etc/mtab to /proc/self/mounts for Fedora 15..." 185: guestfs.ln_sf("/proc/self/mounts", "/etc/mtab") 186: @log.debug "/etc/mtab linked." 187: end
issues.jboss.org/browse/BGBUILD-209
# File lib/boxgrinder-build/plugins/os/rpm-based/rpm-based-os-plugin.rb, line 183 183: def link_mtab(guestfs) 184: @log.debug "Linking /etc/mtab to /proc/self/mounts for Fedora 15..." 185: guestfs.ln_sf("/proc/self/mounts", "/etc/mtab") 186: @log.debug "/etc/mtab linked." 187: end
# File lib/boxgrinder-build/plugins/os/rpm-based/rpm-based-os-plugin.rb, line 38 38: def read_file(file) 39: read_kickstart(file) if File.extname(file).eql?('.ks') 40: end
# File lib/boxgrinder-build/plugins/os/rpm-based/rpm-based-os-plugin.rb, line 38 38: def read_file(file) 39: read_kickstart(file) if File.extname(file).eql?('.ks') 40: end
# File lib/boxgrinder-build/plugins/os/rpm-based/rpm-based-os-plugin.rb, line 42 42: def read_kickstart(file) 43: appliance_config = ApplianceConfig.new 44: appliance_config.name = File.basename(file, '.ks') 45: 46: name = nil 47: version = nil 48: 49: kickstart = File.read(file) 50: 51: kickstart.each do |line| 52: n = line.scan(/^# bg_os_name: (.*)/).flatten.first 53: v = line.scan(/^# bg_os_version: (.*)/).flatten.first 54: 55: name = n unless n.nil? 56: version = v unless v.nil? 57: end 58: 59: raise "No operating system name specified, please add comment to you kickstrt file like this: # bg_os_name: fedora" if name.nil? 60: raise "No operating system version specified, please add comment to you kickstrt file like this: # bg_os_version: 14" if version.nil? 61: 62: appliance_config.os.name = name 63: appliance_config.os.version = version 64: 65: partitions = {} 66: 67: kickstart.each do |line| 68: # Parse also the partition scheme 69: if line =~ /^part ([\/\w]+)/ 70: root = $1 71: partitions[root] = {} 72: 73: # size 74: partitions[root]['size'] = $1.to_f / 1024 if line =~ /--size[=\s]*(\d+)/ 75: # fs type 76: partitions[root]['type'] = $1 if line =~ /--fstype[=\s]*(\w+)/ 77: # fs options 78: partitions[root]['options'] = $1 if line =~ /--fsoptions[=\s]*([,\w]+)/ 79: 80: raise "Partition size not specified for #{root} partition in #{file}" if partitions[root]['size'].nil? 81: end 82: end 83: 84: raise "No partitions specified in your kickstart file #{file}" if partitions.empty? 85: 86: appliance_config.hardware.partitions = partitions 87: 88: appliance_config 89: end
# File lib/boxgrinder-build/plugins/os/rpm-based/rpm-based-os-plugin.rb, line 42 42: def read_kickstart(file) 43: appliance_config = ApplianceConfig.new 44: appliance_config.name = File.basename(file, '.ks') 45: 46: name = nil 47: version = nil 48: 49: kickstart = File.read(file) 50: 51: kickstart.each do |line| 52: n = line.scan(/^# bg_os_name: (.*)/).flatten.first 53: v = line.scan(/^# bg_os_version: (.*)/).flatten.first 54: 55: name = n unless n.nil? 56: version = v unless v.nil? 57: end 58: 59: raise "No operating system name specified, please add comment to you kickstrt file like this: # bg_os_name: fedora" if name.nil? 60: raise "No operating system version specified, please add comment to you kickstrt file like this: # bg_os_version: 14" if version.nil? 61: 62: appliance_config.os.name = name 63: appliance_config.os.version = version 64: 65: partitions = {} 66: 67: kickstart.each do |line| 68: # Parse also the partition scheme 69: if line =~ /^part ([\/\w]+)/ 70: root = $1 71: partitions[root] = {} 72: 73: # size 74: partitions[root]['size'] = $1.to_f / 1024 if line =~ /--size[=\s]*(\d+)/ 75: # fs type 76: partitions[root]['type'] = $1 if line =~ /--fstype[=\s]*(\w+)/ 77: # fs options 78: partitions[root]['options'] = $1 if line =~ /--fsoptions[=\s]*([,\w]+)/ 79: 80: raise "Partition size not specified for #{root} partition in #{file}" if partitions[root]['size'].nil? 81: end 82: end 83: 84: raise "No partitions specified in your kickstart file #{file}" if partitions.empty? 85: 86: appliance_config.hardware.partitions = partitions 87: 88: appliance_config 89: end
# File lib/boxgrinder-build/plugins/os/rpm-based/rpm-based-os-plugin.rb, line 265 265: def read_label(guestfs, partition) 266: (guestfs.respond_to?(:vfs_label) ? guestfs.vfs_label(partition) : guestfs.sh("/sbin/e2label #{partition}").chomp.strip).gsub('_', '') 267: end
# File lib/boxgrinder-build/plugins/os/rpm-based/rpm-based-os-plugin.rb, line 265 265: def read_label(guestfs, partition) 266: (guestfs.respond_to?(:vfs_label) ? guestfs.vfs_label(partition) : guestfs.sh("/sbin/e2label #{partition}").chomp.strip).gsub('_', '') 267: end
# File lib/boxgrinder-build/plugins/os/rpm-based/rpm-based-os-plugin.rb, line 296 296: def recreate_kernel_image(guestfs, modules = []) 297: @linux_helper.recreate_kernel_image(guestfs, modules) 298: end
# File lib/boxgrinder-build/plugins/os/rpm-based/rpm-based-os-plugin.rb, line 296 296: def recreate_kernel_image(guestfs, modules = []) 297: @linux_helper.recreate_kernel_image(guestfs, modules) 298: end
issues.jboss.org/browse/BGBUILD-148
# File lib/boxgrinder-build/plugins/os/rpm-based/rpm-based-os-plugin.rb, line 190 190: def recreate_rpm_database(guestfs, guestfs_helper) 191: @log.debug "Recreating RPM database..." 192: 193: guestfs.download("/var/lib/rpm/Packages", "#{@dir.tmp}/Packages") 194: @exec_helper.execute("/usr/lib/rpm/rpmdb_dump #{@dir.tmp}/Packages > #{@dir.tmp}/Packages.dump") 195: guestfs.upload("#{@dir.tmp}/Packages.dump", "/tmp/Packages.dump") 196: guestfs.sh("rm -rf /var/lib/rpm/*") 197: guestfs_helper.sh("cd /var/lib/rpm/ && cat /tmp/Packages.dump | /usr/lib/rpm/rpmdb_load Packages") 198: guestfs_helper.sh("rpm --rebuilddb") 199: 200: @log.debug "RPM database recreated..." 201: end
issues.jboss.org/browse/BGBUILD-148
# File lib/boxgrinder-build/plugins/os/rpm-based/rpm-based-os-plugin.rb, line 190 190: def recreate_rpm_database(guestfs, guestfs_helper) 191: @log.debug "Recreating RPM database..." 192: 193: guestfs.download("/var/lib/rpm/Packages", "#{@dir.tmp}/Packages") 194: @exec_helper.execute("/usr/lib/rpm/rpmdb_dump #{@dir.tmp}/Packages > #{@dir.tmp}/Packages.dump") 195: guestfs.upload("#{@dir.tmp}/Packages.dump", "/tmp/Packages.dump") 196: guestfs.sh("rm -rf /var/lib/rpm/*") 197: guestfs_helper.sh("cd /var/lib/rpm/ && cat /tmp/Packages.dump | /usr/lib/rpm/rpmdb_load Packages") 198: guestfs_helper.sh("rpm --rebuilddb") 199: 200: @log.debug "RPM database recreated..." 201: end
# File lib/boxgrinder-build/plugins/os/rpm-based/rpm-based-os-plugin.rb, line 283 283: def set_motd(guestfs) 284: @log.debug "Setting up '/etc/motd'..." 285: # set nice banner for SSH 286: motd_file = "/etc/init.d/motd" 287: guestfs.upload("#{File.dirname(__FILE__)}/src/motd.init", motd_file) 288: guestfs.sh("sed -i s/#VERSION#/'#{@appliance_config.version}.#{@appliance_config.release}'/ #{motd_file}") 289: guestfs.sh("sed -i s/#APPLIANCE#/'#{@appliance_config.name} appliance'/ #{motd_file}") 290: 291: guestfs.sh("/bin/chmod +x #{motd_file}") 292: guestfs.sh("/sbin/chkconfig --add motd") 293: @log.debug "'/etc/motd' is nice now." 294: end
# File lib/boxgrinder-build/plugins/os/rpm-based/rpm-based-os-plugin.rb, line 283 283: def set_motd(guestfs) 284: @log.debug "Setting up '/etc/motd'..." 285: # set nice banner for SSH 286: motd_file = "/etc/init.d/motd" 287: guestfs.upload("#{File.dirname(__FILE__)}/src/motd.init", motd_file) 288: guestfs.sh("sed -i s/#VERSION#/'#{@appliance_config.version}.#{@appliance_config.release}'/ #{motd_file}") 289: guestfs.sh("sed -i s/#APPLIANCE#/'#{@appliance_config.name} appliance'/ #{motd_file}") 290: 291: guestfs.sh("/bin/chmod +x #{motd_file}") 292: guestfs.sh("/sbin/chkconfig --add motd") 293: @log.debug "'/etc/motd' is nice now." 294: end
# File lib/boxgrinder-build/plugins/os/rpm-based/rpm-based-os-plugin.rb, line 251 251: def use_labels_for_partitions(guestfs) 252: device = guestfs.list_devices.first 253: 254: # /etc/fstab 255: if fstab = guestfs.read_file('/etc/fstab').gsub!(/^(\/dev\/sda.)/) { |path| "LABEL=#{read_label(guestfs, path.gsub('/dev/sda', device))}" } 256: guestfs.write_file('/etc/fstab', fstab, 0) 257: end 258: 259: # /boot/grub/grub.conf 260: if grub = guestfs.read_file('/boot/grub/grub.conf').gsub!(/(\/dev\/sda.)/) { |path| "LABEL=#{read_label(guestfs, path.gsub('/dev/sda', device))}" } 261: guestfs.write_file('/boot/grub/grub.conf', grub, 0) 262: end 263: end
# File lib/boxgrinder-build/plugins/os/rpm-based/rpm-based-os-plugin.rb, line 251 251: def use_labels_for_partitions(guestfs) 252: device = guestfs.list_devices.first 253: 254: # /etc/fstab 255: if fstab = guestfs.read_file('/etc/fstab').gsub!(/^(\/dev\/sda.)/) { |path| "LABEL=#{read_label(guestfs, path.gsub('/dev/sda', device))}" } 256: guestfs.write_file('/etc/fstab', fstab, 0) 257: end 258: 259: # /boot/grub/grub.conf 260: if grub = guestfs.read_file('/boot/grub/grub.conf').gsub!(/(\/dev\/sda.)/) { |path| "LABEL=#{read_label(guestfs, path.gsub('/dev/sda', device))}" } 261: guestfs.write_file('/boot/grub/grub.conf', grub, 0) 262: end 263: end