From 3b640e997dcd66d1f5b4495cfa1a74f147ac4fa5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Georges=20Dup=C3=A9ron?= Date: Sun, 30 Sep 2018 12:47:57 +0200 Subject: [PATCH 1/4] GUID for gdisk: have Guix inject the hash of the inputs into the source tree --- .gitignore | 3 +++ Makefile | 2 ++ Makefile.example-os | 42 ++++++++++++++++++++++++++++++++++++------ guix.scm | 15 +++++++++++++++ 4 files changed, 56 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index c65b28e..9fb75a2 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,9 @@ /build/check_makefile /build/check_makefile_targets /build/check_makefile_w_arnings +/build/gpt_disk_guid +/build/gpt_partition_guid +/build/input-hash /build/iso_files/boot/iso_boot.sys /build/iso_files/os.zip /build/makefile_built_directories diff --git a/Makefile b/Makefile index d8a6a06..dc038b4 100644 --- a/Makefile +++ b/Makefile @@ -70,6 +70,8 @@ ${bld}/makefile_w_arnings: | $${@D} ${built_files}: | $${@D} ${bld}/makefile_w_arnings: ${Makefiles} + test -e input-hash || printf "\033[1;31mWARNING: input-hash should be created by guix build.\033[m\n" + @unset MAKEFLAGS MAKELEVEL MAKE_TERMERR MFLAGS; \ make -n --warn-undefined-variables \ OS_FILENAME=${OS_FILENAME} \ diff --git a/Makefile.example-os b/Makefile.example-os index da255b5..da2ae2e 100644 --- a/Makefile.example-os +++ b/Makefile.example-os @@ -51,6 +51,9 @@ built_files += ${os_filename} \ ${bld}/os.hex_with_offsets \ ${bld}/iso_files/os.zip \ ${bld}/iso_files/boot/iso_boot.sys \ + ${bld}/input-hash \ + ${bld}/gpt_disk_guid \ + ${bld}/gpt_partition_guid \ ${more_offset_dec} \ ${more_offset_hex} \ @@ -221,12 +224,39 @@ ${bld}/os.zip.adjusted: ${bld}/os.zip ${dep_bytes_zip_start} ${bld}/check_makefi gdisk_pipe_commands_slowly=while read str; do echo "$$str"; printf "\033[1;33m%s\033[m\n" "$$str" >&2; sleep 0.01; done -commit_hash_as_guid=$$((git log -1 --pretty=format:%H || echo 0000000000000000000000000000000000000000) | sed -e 's/^\(.\{8\}\)\(.\{4\}\)\(.\{4\}\)\(.\{4\}\)\(.\{12\}\).*$$/\1-\2-\3-\4-\5/' | tr '[:lower:]' '[:upper:]') -git_dirty=test -n "$$(git diff --shortstat)" -gpt_disk_guid=${commit_hash_as_guid}$$(if $$git_dirty; then printf '0'; else printf '2'; fi) -gpt_partition_guid=${commit_hash_as_guid}$$(if $$git_dirty; then printf '1'; else printf '3'; fi) +.PHONY: force-input-hash +${bld}/input-hash: force-input-hash ${bld}/check_makefile +# input-hash must be a 33 (or more) character-long hexadecimal hash of the +# inputs. It can be used to generate UUIDs for the generated disk image, for +# example. +# +# We use `git log -1 --pretty=format:%H' to obtain the hash of the current +# commit as a fallback, but we do not have access to that information +# within a Guix build environment. + h=$$( cat input-hash \ + || git log -1 --pretty=format:%H \ + || echo 0000000000000000000000000000000000000000 \ + ); \ + if test "$$h" != "$$(cat $@ || echo '')"; then \ + echo "$$h" > "$@"; \ + fi + +# The last digit is 1, to distinguish the disk GUID from the partition GUID +${bld}/gpt_disk_guid: ${bld}/input-hash ${bld}/check_makefile + cat $< \ + | sed -e 's/^\(.\{8\}\)\(.\{4\}\)\(.\{4\}\)\(.\{4\}\)\(.\{11\}\).*$$/\1-\2-\3-\4-\51/' \ + | tr '[:lower:]' '[:upper:]' \ + > $@ + +# The last digit is 2, to distinguish the disk GUID from the partition GUID +${bld}/gpt_partition_guid: ${bld}/input-hash ${bld}/check_makefile + cat $< \ + | sed -e 's/^\(.\{8\}\)\(.\{4\}\)\(.\{4\}\)\(.\{4\}\)\(.\{11\}\).*$$/\1-\2-\3-\4-\52/' \ + | tr '[:lower:]' '[:upper:]' \ + > $@ ${os_filename}: ${bld}/os.32k ${bld}/os.iso ${bld}/os.fat12 ${bld}/os.zip.adjusted \ + ${bld}/gpt_disk_guid ${bld}/gpt_partition_guid \ ${dep_bytes_header_32k_start} \ ${dep_bytes_header_32k_size} \ ${dep_bytes_fat12_start} \ @@ -266,8 +296,8 @@ ${os_filename}: ${bld}/os.32k ${bld}/os.iso ${bld}/os.fat12 ${bld}/os.zip.adjust printf "1\nN\n"; \ printf "01\nY\nN\n"; \ printf "x\n"; \ - printf "g\n${gpt_disk_guid}\n"; \ - printf "c\n${gpt_partition_guid}\n"; \ + printf "g\n$$(cat ${bld}/gpt_disk_guid)\n"; \ + printf "c\n$$(cat ${bld}/gpt_partition_guid)\n"; \ printf "p\no\nw\nY\n") | ${gdisk_pipe_commands_slowly} | gdisk $@ # Inject MS-DOS newlines (CR+LF) and comments (":: ") in the GUID field of unused partition table entries, # so that the part that is to be skipped by MS-DOS does not form a line longer than the MS-DOS maximum diff --git a/guix.scm b/guix.scm index 898b5de..8decc99 100644 --- a/guix.scm +++ b/guix.scm @@ -25,6 +25,8 @@ (ice-9 popen) (ice-9 rdelim) (gnu packages version-control) + (gnu packages vim) + (gnu packages package-management) (gnu packages assembly) (gnu packages base) (gnu packages mtools) @@ -75,6 +77,17 @@ `(#:phases (modify-phases %standard-phases ;; unpack ;; this phase is enabled + (add-after 'unpack 'compute-input-hash + (lambda* (#:key inputs #:allow-other-keys) + (invoke "sh" "-c" + (string-append + " guix hash -rx . --format=base32" + " | tr '[:lower:]' '[:upper:]'" + " | head -c 48" + " | base32 -d" + " | xxd -ps" + " | head -c 60" + " > input-hash")))) ;; patch-source-shebangs ;; this phase is enabled (add-after 'patch-source-shebangs 'make-clean (lambda* (#:key inputs #:allow-other-keys) @@ -99,6 +112,8 @@ (list "in-guix" ,makefile-commit-timestamp))) (native-inputs `(("git" ,git) + ("xxd" ,xxd) + ("guix" ,guix) ("nasm" ,nasm) ("which" ,which) ("mtools" ,mtools) From e8349eb34c043091e6c22d9737a9d9d64bf1714c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Georges=20Dup=C3=A9ron?= Date: Sun, 30 Sep 2018 14:23:17 +0200 Subject: [PATCH 2/4] Compute the disk and partition GUIDs from the disk image itself (with GUIDs initially all-zero) This allows us to have a deterministic build (given a fixed environment) without having to rely on GIT (the .git is not copied in the Guix build environment), and without having to rely on Guix (which previously had to inject the input hash into the source tree). Guix is therefore "only" responsible for ensuring that the build tools and environment are fixed, but is not strictly necessary to have reproducible builds. --- .gitignore | 7 ++-- Makefile | 2 -- Makefile.example-os | 86 ++++++++++++++++++++++----------------------- guix.scm | 17 ++------- 4 files changed, 48 insertions(+), 64 deletions(-) diff --git a/.gitignore b/.gitignore index 9fb75a2..9f762cc 100644 --- a/.gitignore +++ b/.gitignore @@ -5,9 +5,8 @@ /build/check_makefile /build/check_makefile_targets /build/check_makefile_w_arnings -/build/gpt_disk_guid -/build/gpt_partition_guid -/build/input-hash +/build/gpt_guid1 +/build/gpt_guid2 /build/iso_files/boot/iso_boot.sys /build/iso_files/os.zip /build/makefile_built_directories @@ -88,6 +87,8 @@ /build/os.offsets.hex /build/os.reasm /build/os.reasm.asm +/build/os_with_guid_0 +/build/os_with_guid_hash /build/os.zip /build/os.zip.adjusted /build/test_pass/emu_bochs diff --git a/Makefile b/Makefile index dc038b4..d8a6a06 100644 --- a/Makefile +++ b/Makefile @@ -70,8 +70,6 @@ ${bld}/makefile_w_arnings: | $${@D} ${built_files}: | $${@D} ${bld}/makefile_w_arnings: ${Makefiles} - test -e input-hash || printf "\033[1;31mWARNING: input-hash should be created by guix build.\033[m\n" - @unset MAKEFLAGS MAKELEVEL MAKE_TERMERR MFLAGS; \ make -n --warn-undefined-variables \ OS_FILENAME=${OS_FILENAME} \ diff --git a/Makefile.example-os b/Makefile.example-os index da2ae2e..c31ffaf 100644 --- a/Makefile.example-os +++ b/Makefile.example-os @@ -51,9 +51,10 @@ built_files += ${os_filename} \ ${bld}/os.hex_with_offsets \ ${bld}/iso_files/os.zip \ ${bld}/iso_files/boot/iso_boot.sys \ - ${bld}/input-hash \ - ${bld}/gpt_disk_guid \ - ${bld}/gpt_partition_guid \ + ${bld}/gpt_guid1 \ + ${bld}/gpt_guid2 \ + ${bld}/os_with_guid_0 \ + ${bld}/os_with_guid_hash \ ${more_offset_dec} \ ${more_offset_hex} \ @@ -224,49 +225,27 @@ ${bld}/os.zip.adjusted: ${bld}/os.zip ${dep_bytes_zip_start} ${bld}/check_makefi gdisk_pipe_commands_slowly=while read str; do echo "$$str"; printf "\033[1;33m%s\033[m\n" "$$str" >&2; sleep 0.01; done -.PHONY: force-input-hash -${bld}/input-hash: force-input-hash ${bld}/check_makefile -# input-hash must be a 33 (or more) character-long hexadecimal hash of the -# inputs. It can be used to generate UUIDs for the generated disk image, for -# example. -# -# We use `git log -1 --pretty=format:%H' to obtain the hash of the current -# commit as a fallback, but we do not have access to that information -# within a Guix build environment. - h=$$( cat input-hash \ - || git log -1 --pretty=format:%H \ - || echo 0000000000000000000000000000000000000000 \ - ); \ - if test "$$h" != "$$(cat $@ || echo '')"; then \ - echo "$$h" > "$@"; \ - fi - -# The last digit is 1, to distinguish the disk GUID from the partition GUID -${bld}/gpt_disk_guid: ${bld}/input-hash ${bld}/check_makefile - cat $< \ - | sed -e 's/^\(.\{8\}\)\(.\{4\}\)\(.\{4\}\)\(.\{4\}\)\(.\{11\}\).*$$/\1-\2-\3-\4-\51/' \ +# The last digit of guid1 is 1, for guid2 it's 2, and so on. +# This allows us to have a disk GUID which is different from the partition GUID +${bld}/gpt_guid%: ${bld}/os_with_guid_0 ${bld}/check_makefile + sha256sum $< \ + | sed -e 's/^\(.\{8\}\)\(.\{4\}\)\(.\{4\}\)\(.\{4\}\)\(.\{11\}\).*$$/\1-\2-\3-\4-\5$*/' \ | tr '[:lower:]' '[:upper:]' \ > $@ -# The last digit is 2, to distinguish the disk GUID from the partition GUID -${bld}/gpt_partition_guid: ${bld}/input-hash ${bld}/check_makefile - cat $< \ - | sed -e 's/^\(.\{8\}\)\(.\{4\}\)\(.\{4\}\)\(.\{4\}\)\(.\{11\}\).*$$/\1-\2-\3-\4-\52/' \ - | tr '[:lower:]' '[:upper:]' \ - > $@ +gpt_disk_guid=${bld}/gpt_guid1 +gpt_partition_guid=${bld}/gpt_guid2 -${os_filename}: ${bld}/os.32k ${bld}/os.iso ${bld}/os.fat12 ${bld}/os.zip.adjusted \ - ${bld}/gpt_disk_guid ${bld}/gpt_partition_guid \ - ${dep_bytes_header_32k_start} \ - ${dep_bytes_header_32k_size} \ - ${dep_bytes_fat12_start} \ - ${dep_bytes_fat12_size} \ - ${dep_bytes_gpt_mirror_start} \ - ${dep_bytes_gpt_mirror_end} \ - ${dep_sectors_fat12_start} \ - ${dep_sectors_fat12_size} \ - ${dep_bytes_zip_start} \ - ${bld}/check_makefile +${bld}/os_with_guid_0: ${bld}/os.32k ${bld}/os.iso ${bld}/os.fat12 \ + ${dep_bytes_header_32k_start} \ + ${dep_bytes_header_32k_size} \ + ${dep_bytes_fat12_start} \ + ${dep_bytes_fat12_size} \ + ${dep_bytes_gpt_mirror_start} \ + ${dep_bytes_gpt_mirror_end} \ + ${dep_sectors_fat12_start} \ + ${dep_sectors_fat12_size} \ + ${bld}/check_makefile rm -f $@ # start with the .iso cp ${bld}/os.iso $@ @@ -296,8 +275,23 @@ ${os_filename}: ${bld}/os.32k ${bld}/os.iso ${bld}/os.fat12 ${bld}/os.zip.adjust printf "1\nN\n"; \ printf "01\nY\nN\n"; \ printf "x\n"; \ - printf "g\n$$(cat ${bld}/gpt_disk_guid)\n"; \ - printf "c\n$$(cat ${bld}/gpt_partition_guid)\n"; \ + printf "g\n00000000-0000-0000-0000-000000000000\n"; \ + printf "c\n00000000-0000-0000-0000-000000000000\n"; \ + printf "p\no\nw\nY\n") | ${gdisk_pipe_commands_slowly} | gdisk $@ + +${bld}/os_with_guid_hash: ${bld}/os_with_guid_0 \ + ${gpt_disk_guid} ${gpt_partition_guid} \ + ${bld}/check_makefile + cp $< $@ +# gdisk commands: +# * eXpert mode, +# * Change partition GUID, the GUID itself, +# * change disk GUID, the GUID itself, +# * Print GPT, print prOtective MBR, Write, Proceed. + (if test "$$(uname -o)" = "Cygwin"; then printf "Y\n"; fi; \ + printf "x\n"; \ + printf "g\n$$(cat ${gpt_disk_guid})\n"; \ + printf "c\n$$(cat ${gpt_partition_guid})\n"; \ printf "p\no\nw\nY\n") | ${gdisk_pipe_commands_slowly} | gdisk $@ # Inject MS-DOS newlines (CR+LF) and comments (":: ") in the GUID field of unused partition table entries, # so that the part that is to be skipped by MS-DOS does not form a line longer than the MS-DOS maximum @@ -307,6 +301,10 @@ ${os_filename}: ${bld}/os.32k ${bld}/os.iso ${bld}/os.fat12 ${bld}/os.zip.adjust printf "\r\n:: %02x" $$i | dd bs=1 seek=$$(( 1024 + ( ($$i) - 1) * 128 + 16)) count=7 conv=notrunc of=$@; \ printf "\r\n:: %02x" $$i | dd bs=1 seek=$$(( ${bytes_gpt_mirror_start} + ( ($$i) - 1) * 128 + 16)) count=7 conv=notrunc of=$@; \ done +${os_filename}: ${bld}/os_with_guid_hash ${bld}/os.zip.adjusted \ + ${dep_bytes_zip_start} \ + ${bld}/check_makefile + cp -f $< $@ # splice in zip at the end set -x; dd skip=${bytes_zip_start} seek=${bytes_zip_start} bs=1 conv=notrunc if=${bld}/os.zip.adjusted of=$@ chmod a+x-w $@ diff --git a/guix.scm b/guix.scm index 8decc99..8272311 100644 --- a/guix.scm +++ b/guix.scm @@ -25,14 +25,13 @@ (ice-9 popen) (ice-9 rdelim) (gnu packages version-control) - (gnu packages vim) - (gnu packages package-management) (gnu packages assembly) (gnu packages base) (gnu packages mtools) (gnu packages cdrom) (gnu packages compression) (gnu packages disk) + (gnu packages vim) (gnu packages linux)) ;; For faketime @@ -77,17 +76,6 @@ `(#:phases (modify-phases %standard-phases ;; unpack ;; this phase is enabled - (add-after 'unpack 'compute-input-hash - (lambda* (#:key inputs #:allow-other-keys) - (invoke "sh" "-c" - (string-append - " guix hash -rx . --format=base32" - " | tr '[:lower:]' '[:upper:]'" - " | head -c 48" - " | base32 -d" - " | xxd -ps" - " | head -c 60" - " > input-hash")))) ;; patch-source-shebangs ;; this phase is enabled (add-after 'patch-source-shebangs 'make-clean (lambda* (#:key inputs #:allow-other-keys) @@ -112,8 +100,6 @@ (list "in-guix" ,makefile-commit-timestamp))) (native-inputs `(("git" ,git) - ("xxd" ,xxd) - ("guix" ,guix) ("nasm" ,nasm) ("which" ,which) ("mtools" ,mtools) @@ -121,6 +107,7 @@ ("zip" ,zip) ("faketime" ,faketime) ("gdisk" ,gptfdisk) + ("xxd" ,xxd) ("column" ,util-linux))) (description "Test framework to run an OS in multiple emulators, as a guest graphical / text shell on linux, and so on.") (home-page "https://github.com/jsmaniac/os-test-framework") From 38d057464b268c727852b244832c2ae89733aaf4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Georges=20Dup=C3=A9ron?= Date: Sun, 30 Sep 2018 15:31:51 +0200 Subject: [PATCH 3/4] Fixed the GPT CRCs after injecting the MS-DOS comments in the partition array --- .gitignore | 3 +++ Makefile.example-os | 41 ++++++++++++++++++++++++++++++++++++++++- guix.scm | 7 +++++-- 3 files changed, 48 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 9f762cc..357a912 100644 --- a/.gitignore +++ b/.gitignore @@ -89,6 +89,9 @@ /build/os.reasm.asm /build/os_with_guid_0 /build/os_with_guid_hash +/build/os_with_guid_hash.fixed_gpt_crc +/build/os_with_guid_hash.gpt_header_fixed_crc +/build/os_with_guid_hash.partition_array /build/os.zip /build/os.zip.adjusted /build/test_pass/emu_bochs diff --git a/Makefile.example-os b/Makefile.example-os index c31ffaf..efdc3df 100644 --- a/Makefile.example-os +++ b/Makefile.example-os @@ -55,6 +55,9 @@ built_files += ${os_filename} \ ${bld}/gpt_guid2 \ ${bld}/os_with_guid_0 \ ${bld}/os_with_guid_hash \ + ${bld}/os_with_guid_hash.partition_array \ + ${bld}/os_with_guid_hash.gpt_header_fixed_crc \ + ${bld}/os_with_guid_hash.fixed_gpt_crc \ ${more_offset_dec} \ ${more_offset_hex} \ @@ -301,7 +304,43 @@ ${bld}/os_with_guid_hash: ${bld}/os_with_guid_0 \ printf "\r\n:: %02x" $$i | dd bs=1 seek=$$(( 1024 + ( ($$i) - 1) * 128 + 16)) count=7 conv=notrunc of=$@; \ printf "\r\n:: %02x" $$i | dd bs=1 seek=$$(( ${bytes_gpt_mirror_start} + ( ($$i) - 1) * 128 + 16)) count=7 conv=notrunc of=$@; \ done -${os_filename}: ${bld}/os_with_guid_hash ${bld}/os.zip.adjusted \ + +%.partition_array: % ${bld}/check_makefile +# Extract the partition array header + dd if=$< bs=512 skip=2 count=32 of=$@ + +# The GPT header of the given disk image, with its CRC adjusted to the actual +# data. It is used to fix the CRC after injecting MS-DOS comments in ignored +# parts of the partition array. +%.gpt_header_fixed_crc: % %.partition_array % ${bld}/check_makefile +# Extract the GPT header + dd if=$< bs=512 skip=1 count=1 of=$@ +# * Compute the CRC32 of the particion array +# * Convert endianness +# * Convert to binary +# * Inject into the GPT header + crc32 $*.partition_array \ + | sed -e 's/^\(..\)\(..\)\(..\)\(..\)$$/\4\3\2\1/' \ + | xxd -r -ps \ + | dd bs=1 seek=88 count=4 conv=notrunc of=$@ +# Zero-out the CRC of the header itself + printf '00000000' | xxd -r -ps | dd bs=1 seek=16 count=4 conv=notrunc of=$@ +# * Compute the CRC32 of the GPT header (with the CRC field itself zeroed out) +# * Convert endianness +# * Convert to binary +# * Inject into the GPT header + crc32 $@ \ + | sed -e 's/^\(..\)\(..\)\(..\)\(..\)$$/\4\3\2\1/' \ + | xxd -r -ps \ + | dd bs=1 seek=16 count=4 conv=notrunc of=$@ + +%.fixed_gpt_crc: % %.gpt_header_fixed_crc \ + ${bld}/check_makefile + cp $< $@ +# Inject the fixed GPT header + dd if=$*.gpt_header_fixed_crc bs=512 seek=1 count=1 conv=notrunc of=$@ + +${os_filename}: ${bld}/os_with_guid_hash.fixed_gpt_crc ${bld}/os.zip.adjusted \ ${dep_bytes_zip_start} \ ${bld}/check_makefile cp -f $< $@ diff --git a/guix.scm b/guix.scm index 8272311..0625496 100644 --- a/guix.scm +++ b/guix.scm @@ -32,7 +32,8 @@ (gnu packages compression) (gnu packages disk) (gnu packages vim) - (gnu packages linux)) + (gnu packages linux) + (gnu packages perl)) ;; For faketime (use-modules (guix git-download)) @@ -108,7 +109,9 @@ ("faketime" ,faketime) ("gdisk" ,gptfdisk) ("xxd" ,xxd) - ("column" ,util-linux))) + ("column" ,util-linux) + ;; perl is needed as an extra dependency to get crc32 to work. + ("perl" ,perl) ("crc32" ,perl-archive-zip))) (description "Test framework to run an OS in multiple emulators, as a guest graphical / text shell on linux, and so on.") (home-page "https://github.com/jsmaniac/os-test-framework") (license "CC0-1.0") From 796fa239655f9cabf051ce9e32cbf9721fe63c8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Georges=20Dup=C3=A9ron?= Date: Tue, 2 Oct 2018 02:55:45 +0200 Subject: [PATCH 4/4] Fix the CRC in the mirror header too --- Makefile.example-os | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Makefile.example-os b/Makefile.example-os index efdc3df..5f29008 100644 --- a/Makefile.example-os +++ b/Makefile.example-os @@ -1,6 +1,7 @@ offset_names = bytes_os_size \ bytes_mbr_start \ bytes_mbr_end \ + bytes_gpt_header_start \ bytes_header_32k_start \ bytes_header_32k_end \ bytes_iso_start \ @@ -9,6 +10,7 @@ offset_names = bytes_os_size \ bytes_fat12_end \ bytes_gpt_mirror_start \ bytes_gpt_mirror_end \ + bytes_gpt_header_mirror_start \ bytes_zip_start \ bytes_zip_end @@ -148,6 +150,9 @@ ${eval ${call offset,bytes_os_size, $${os_image_size_kb} * 1024,, ${eval ${call offset,sectors_os_size, $${bytes_os_size} / $${sector_size}, bytes_os_size,}} ${eval ${call offset,tracks_os_size, $${sectors_os_size} / $${os_floppy_chs_s}, sectors_os_size,}} +# Primary GPT +${eval ${call offset,bytes_gpt_header_start, $${sector_size},, }} + # round up ${eval ${call offset,bytes_iso_size, $$$$(utils/file-length.sh -c ${bld}/os.iso), ,${bld}/os.iso}} ${eval ${call offset,sectors_iso_size, ${call div_round_up,$${bytes_iso_size},$${sector_size}}, bytes_iso_size,}} @@ -183,6 +188,7 @@ ${eval ${call offset,bytes_fat12_end, $${bytes_fat12_start} + $${bytes_fa # It is probably not necessary to align the GPT mirror end on a track boundary. ${eval ${call offset,bytes_gpt_mirror_size, $${sectors_gpt_mirror_size} * $${sector_size}, sectors_gpt_mirror_size,}} ${eval ${call offset,bytes_gpt_mirror_end, $${bytes_fat12_end} + $${bytes_gpt_mirror_size}, bytes_fat12_end bytes_gpt_mirror_size,}} +${eval ${call offset,bytes_gpt_header_mirror_start, $${bytes_gpt_mirror_end} - $${sector_size}, bytes_gpt_mirror_end,}} ${eval ${call offset,bytes_gpt_mirror_start, $${bytes_gpt_mirror_end} - $${bytes_gpt_mirror_size}, bytes_gpt_mirror_end bytes_gpt_mirror_size,}} ${eval ${call offset,bytes_zip_end, $${bytes_os_size}, bytes_os_size,}} @@ -335,10 +341,13 @@ ${bld}/os_with_guid_hash: ${bld}/os_with_guid_0 \ | dd bs=1 seek=16 count=4 conv=notrunc of=$@ %.fixed_gpt_crc: % %.gpt_header_fixed_crc \ + ${dep_bytes_gpt_header_start} ${dep_bytes_gpt_header_mirror_start} \ ${bld}/check_makefile cp $< $@ -# Inject the fixed GPT header - dd if=$*.gpt_header_fixed_crc bs=512 seek=1 count=1 conv=notrunc of=$@ +# Inject the fixed GPT header + dd if=$*.gpt_header_fixed_crc bs=1 seek=${bytes_gpt_header_start} count=${sector_size} conv=notrunc of=$@ +# Inject the fixed GPT header in the mirror + dd if=$*.gpt_header_fixed_crc bs=1 seek=${bytes_gpt_header_mirror_start} count=${sector_size} conv=notrunc of=$@ ${os_filename}: ${bld}/os_with_guid_hash.fixed_gpt_crc ${bld}/os.zip.adjusted \ ${dep_bytes_zip_start} \