Permalink
Browse files

Added two new fields to the YAML file built by the build_iso_yaml.rb …

…file that contain the sha256 checksums for the vmlinuz and core.gz files contained in the ISO (used to check for integrity of these two files during the iPXE-boot process). Also changed the existing kernel and initrd fields in this file so that they included relative paths (from the root of the ISO) to these two files (boot/vmlinuz and boot/core.gz, respectively). Finally, made changes to the rebuild_iso.sh file so that the new CLI for the build_iso_yaml.rb file is used (now have to pass in 4 arguments, not just two; have added the paths to the kernel and initrd files as inputs to the build_iso_yaml.rb script)
  • Loading branch information...
Tom McSweeney
Tom McSweeney committed Mar 20, 2012
1 parent b0e4480 commit e2c58bc86e4c34bf10d800ad56d7a9950735ebe2
Showing with 47 additions and 8 deletions.
  1. +46 −7 iso-build-files/build_iso_yaml.rb
  2. +1 −1 iso-build-files/rebuild_iso.sh
@@ -10,26 +10,65 @@
# @author Tom McSweeney
require 'yaml'
require 'digest/sha2'
if ARGV.length != 2
puts "USAGE: #{$0} DIR_NAME ISO_VERSION"
puts " (example #{$0} /tmp v0.2.1.0"
def get_file_sha2_hash(path_to_file)
if !File.exist?(path_to_file)
return nil
end
file_h = Digest::SHA2.new
File.open(path_to_file, 'r') do |fh|
while buffer = fh.read(1024)
file_h << buffer
end
end
file_h.to_s
end
if ARGV.length != 4
puts "USAGE: #{$0} dir-name iso-version kernel-path initrd-path"
puts " (example #{$0} tmp v0.2.1.0 boot/vmlinuz boot/core.gz"
end
# take the first argument as the directory to create the YAML file in
dir_name = ARGV[0]
# if the named file doesn't exist or it does and it isn't a directory, then exit
# if the path passed as the directory name doesn't exist ()or it does and
# it isn't a directory), then exit
if !File.exist?(dir_name) || !File.directory?(dir_name)
puts "#{$0} Error: '#{dir_name}' is not a directory"
exit(-1)
end
# second argument is the iso_version
iso_version = ARGV[1]
# third argument is the path to the kernel image (assumed to be under the directory
# passed as the first argument)
kernel_path = ARGV[2]
path_to_file = dir_name + File::SEPARATOR + kernel_path
unless (kernel_sha2 = get_file_sha2_hash(path_to_file))
puts "#{$0} Error: '#{path_to_file}' is not a file"
exit(-2)
end
# and the fourth argument is the path to the initrd image (again, assumed to be under
# the directory passed as the first argument)
initrd_path = ARGV[3]
path_to_file = dir_name + File::SEPARATOR + initrd_path
unless (initrd_sha2 = get_file_sha2_hash(path_to_file))
puts "#{$0} Error: '#{path_to_file}' is not a file"
exit(-3)
end
# build the YAML file
yaml_hash = Hash.new
yaml_hash['iso_version'] = ARGV[1]
yaml_hash['kernel'] = 'vmlinuz'
yaml_hash['initrd'] = 'core.gz'
yaml_hash['iso_version'] = iso_version
yaml_hash['kernel'] = kernel_path
yaml_hash['kernel_sha2'] = kernel_sha2
yaml_hash['initrd'] = initrd_path
yaml_hash['initrd_sha2'] = initrd_sha2
yaml_hash['iso_build_time'] = Time.now.utc
# and save it to the iso-metadata.yaml file in the specified directory
@@ -26,6 +26,6 @@ advdef -z4 core.gz
cp -p core.gz newiso/boot/
# build the YAML file needed for use in Razor, place it into the root of the
# ISO filesystem
./build_iso_yaml.rb newiso ${ISO_VERSION}
./build_iso_yaml.rb newiso ${ISO_VERSION} boot/vmlinuz boot/core.gz
# finally, build the ISO itself (using the contents of the newiso directory as input
mkisofs -l -J -R -V TC-custom -no-emul-boot -boot-load-size 4 -boot-info-table -b boot/isolinux/isolinux.bin -c boot/isolinux/boot.cat -o ${ISO_NAME} newiso

0 comments on commit e2c58bc

Please sign in to comment.