mirror of
https://github.com/genodelabs/genode.git
synced 2024-12-20 06:07:59 +00:00
parent
90fcba79c6
commit
4067cc7962
@ -9,26 +9,20 @@ source [genode_dir]/tool/run/grub2.inc
|
||||
|
||||
proc image_disk_size { } { return [get_cmd_arg --image-disk-size 0] }
|
||||
|
||||
#
|
||||
# Disable parted heuristics for Apple to prevent error messages
|
||||
#
|
||||
set ::env(PARTED_GPT_APPLE) 0
|
||||
|
||||
|
||||
##
|
||||
# Create disk image with the content of the run directory
|
||||
#
|
||||
proc run_image { {unused ""} } {
|
||||
|
||||
requires_installation_of gdisk
|
||||
requires_installation_of parted
|
||||
requires_installation_of sgdisk
|
||||
requires_installation_of e2cp
|
||||
|
||||
# make copy of template grub2 header image
|
||||
exec cp [get_grub2_dir]/boot/grub2-head.img [run_dir].header
|
||||
|
||||
# remove template partition
|
||||
exec -ignorestderr parted -a none -s [run_dir].header -- rm 3
|
||||
exec sgdisk --delete=3 [run_dir].header
|
||||
|
||||
# calculate size of grub2 header and the size of Genode scenario
|
||||
set size_header [expr [regsub {\s.*} [exec du -b [run_dir].header] {}]]
|
||||
@ -63,10 +57,9 @@ proc run_image { {unused ""} } {
|
||||
set last_sector [expr ((($size_header + ($disk_size_kb * 1024)) / 512) - 1)]
|
||||
|
||||
# add free space for the backup gpt at the end of disk
|
||||
set sector_backup [exec -ignorestderr parted -s [run_dir].header 'unit s print']
|
||||
set sector_backup [regexp -all -inline { 1 .*BIOSBOOT} $sector_backup]
|
||||
set sector_backup [regexp -all -inline {([0-9]+)} $sector_backup]
|
||||
set sector_backup [lindex $sector_backup 2]
|
||||
set sector_backup [exec sgdisk --info=1 [run_dir].header]
|
||||
set sector_backup [regexp -all -line -inline {First sector: ([0-9]+)} $sector_backup]
|
||||
set sector_backup [lindex $sector_backup 1]
|
||||
|
||||
exec dd if=/dev/zero of=[run_dir].empty bs=512 count=$sector_backup 2>/dev/null
|
||||
|
||||
@ -78,12 +71,15 @@ proc run_image { {unused ""} } {
|
||||
exec rm [run_dir].header
|
||||
exec rm [run_dir].partition
|
||||
|
||||
# move backup GPT to the end of the disk
|
||||
exec sgdisk --move-second-header [run_dir].img
|
||||
|
||||
# create partition table entry pointing to the content
|
||||
catch { exec -ignorestderr parted -a none [run_dir].img -- mkpart Fix GENODE ext2 [expr $first_sector]s ${last_sector}s }
|
||||
exec -ignorestderr parted [run_dir].img -s 'name 3 GENODE'
|
||||
exec sgdisk --new=3:$first_sector:$last_sector [run_dir].img
|
||||
exec sgdisk --change-name=3:GENODE [run_dir].img
|
||||
|
||||
# create hybrid MBR
|
||||
exec echo -e "r\no\nh\n1\nn\n\ny\nn\no\nw\ny\n" | gdisk [run_dir].img
|
||||
exec sgdisk --hybrid [run_dir].img
|
||||
|
||||
set size_image [expr [regsub {\s.*} [exec du -sk [run_dir].img] {}]]
|
||||
puts "Created image file [run_dir].img (${size_image}kiB)"
|
||||
|
Loading…
Reference in New Issue
Block a user