2017-09-20 20:56:00 +00:00
|
|
|
source [genode_dir]/tool/run/grub2.inc
|
2024-05-17 13:12:00 +00:00
|
|
|
source [genode_dir]/tool/run/shim.inc
|
2017-09-20 20:56:00 +00:00
|
|
|
|
2017-06-12 20:12:11 +00:00
|
|
|
##
|
|
|
|
# Create GPT disk image with UEFI boot loaders and content of the run directory
|
|
|
|
#
|
2024-05-17 13:12:00 +00:00
|
|
|
# \param --image-uefi_size disk size in MiB
|
|
|
|
# \param --image-disk_shim nickname of certificate to use to sign GRUB2
|
2017-06-12 20:12:11 +00:00
|
|
|
#
|
|
|
|
|
|
|
|
proc image_uefi_size { } { return [get_cmd_arg --image-uefi_size 0] }
|
2024-05-17 13:12:00 +00:00
|
|
|
proc image_uefi_shim { } { return [get_cmd_arg --image-uefi_shim ""] }
|
2017-06-12 20:12:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
##
|
|
|
|
# Create uefi image
|
|
|
|
#
|
2023-01-18 15:56:28 +00:00
|
|
|
proc run_image { } {
|
2017-06-12 20:12:11 +00:00
|
|
|
|
2017-10-20 12:11:44 +00:00
|
|
|
set run_size [expr [regsub {\s.*} [exec du -smL [run_dir]] {}]]
|
2017-06-12 20:12:11 +00:00
|
|
|
|
|
|
|
if {[image_uefi_size] > 0} {
|
|
|
|
set disk_size [image_uefi_size]
|
|
|
|
} else {
|
|
|
|
set disk_size [expr $run_size + 1]
|
|
|
|
}
|
|
|
|
|
|
|
|
# generate head space designated for the partition table
|
|
|
|
exec dd if=/dev/zero of=[run_dir].header count=34 bs=512 2>/dev/null
|
|
|
|
|
|
|
|
exec dd if=/dev/zero of=[run_dir].partition bs=1M count=$disk_size 2>/dev/null
|
2018-06-19 17:55:04 +00:00
|
|
|
exec [installed_command mkfs.vfat] -n GENODE [run_dir].partition
|
2017-06-12 20:12:11 +00:00
|
|
|
|
|
|
|
# copy content to disk image
|
|
|
|
foreach file [exec ls [run_dir]] {
|
2018-06-19 17:55:04 +00:00
|
|
|
exec [installed_command mcopy] -i [run_dir].partition -s [run_dir]/$file ::
|
2017-06-12 20:12:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
exec cat [run_dir].header [run_dir].partition > [run_dir].img
|
|
|
|
|
2023-11-10 15:15:11 +00:00
|
|
|
exec [installed_command sgdisk] --set-alignment=1 --largest-new=1 --typecode=1:EF00 [run_dir].img 2> /dev/null
|
2017-06-12 20:12:11 +00:00
|
|
|
|
|
|
|
exec rm -f [run_dir].header [run_dir].partition
|
|
|
|
}
|
2023-01-27 06:57:52 +00:00
|
|
|
|
|
|
|
|
|
|
|
proc install_uefi_bootloader_to_run_dir { } {
|
|
|
|
exec mkdir -p [run_dir]/efi/boot
|
|
|
|
exec cp [get_grub2_dir]/boot/grub2/grub2_32.efi [run_dir]/efi/boot/bootia32.efi
|
|
|
|
exec cp [get_grub2_dir]/boot/grub2/grub2_64.efi [run_dir]/efi/boot/bootx64.efi
|
2024-05-17 13:12:00 +00:00
|
|
|
|
|
|
|
if {[image_uefi_shim] != ""} {
|
|
|
|
setup_shim_and_sign_grub2 [image_uefi_shim] [run_dir]/efi/boot
|
|
|
|
}
|
|
|
|
|
2023-01-27 06:57:52 +00:00
|
|
|
exec mkdir -p [run_dir]/boot/grub
|
|
|
|
exec cp [genode_dir]/tool/boot/bender [run_dir]/boot/bender
|
|
|
|
|
|
|
|
exec cp [genode_dir]/tool/boot/boot.png [run_dir]/boot/boot.png
|
|
|
|
exec cp [get_grub2_dir]/boot/font.pf2 [run_dir]/boot/font.pf2
|
|
|
|
}
|