From 00bfba9251a9e1fd71d041e79d9458f733148091 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Georges=20Dup=C3=A9ron?= Date: Mon, 27 Aug 2018 08:42:50 +0200 Subject: [PATCH 1/4] macos: mkisofs includes the path to its input as extra unwanted directories in the iso --- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 862974d..3ac6d2d 100644 --- a/Makefile +++ b/Makefile @@ -206,7 +206,7 @@ ${bld}/os.iso: ${bld}/iso_files/os.zip ${bld}/iso_files/boot/iso_boot.sys ${bld} ! test -d ${bld}/iso_files.tmp cp -a -T -- ${bld}/iso_files ${bld}/iso_files.tmp find ${bld}/iso_files.tmp -depth -exec touch -t ${commit_timestamp} '{}' ';' - faketime -f ${commit_faketime} mkisofs \ + (cd ./${bld}/iso_files.tmp/ && faketime -f ${commit_faketime} mkisofs \ --input-charset utf-8 \ -rock \ -joliet \ @@ -215,8 +215,8 @@ ${bld}/os.iso: ${bld}/iso_files/os.zip ${bld}/iso_files/boot/iso_boot.sys ${bld} -no-emul-boot \ -boot-load-size 4 \ -pad \ - -output $@ \ - ./${bld}/iso_files.tmp/ + -output ../os.iso \ + .) rm -- ${bld}/iso_files.tmp/os.zip \ ${bld}/iso_files.tmp/boot/iso_boot.sys rmdir ${bld}/iso_files.tmp/boot/ From 2e9ce6fc261b275b1be07084f005083e5576f993 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Georges=20Dup=C3=A9ron?= Date: Sun, 23 Sep 2018 17:38:38 +0200 Subject: [PATCH 2/4] macos: date conversion needs different flags than in Linux --- Makefile | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 3ac6d2d..302d46e 100644 --- a/Makefile +++ b/Makefile @@ -17,8 +17,17 @@ tests_emu = test/qemu-system-i386-floppy test/qemu-system-i386-cdrom test/qemu-s tests_requiring_sudo = test/fat12_mount test/iso_mount tests_noemu = test/zip test/os.reasm test/sizes test/fat12_contents test/reproducible_build -commit_timestamp = "$$(date -d "${COMMIT_TIMESTAMP_ISO_8601}" '+%Y%m%d%H%m.%S')" -commit_faketime = "$$(date -d "${COMMIT_TIMESTAMP_ISO_8601}" '+%Y-%m-%d %H:%m:%S')" +# We truncate the timezone, because the Darwin version of date seems to lack +# the %:z format (for ±HH:MM timezone). +define date_command + if test "$$(uname -s)" = Darwin; then \ + date -j -f %Y-%m-%dT%H:%M:%S $$(echo ${1} | cut -c 1-19) ${2}; \ + else \ + date -d ${1} ${2}; \ + fi +endef +commit_timestamp = "$$(${call date_command,"${COMMIT_TIMESTAMP_ISO_8601}",'+%Y%m%d%H%m.%S'})" +commit_faketime = "$$(${call date_command,"${COMMIT_TIMESTAMP_ISO_8601}",'+%Y-%m-%d %H:%m:%S'})" offset_names = bytes_os_size \ bytes_mbr_start \ From 07e12d30628b2f94d15af7f5aea09ae05b347e76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Georges=20Dup=C3=A9ron?= Date: Fri, 31 Aug 2018 09:28:39 +0200 Subject: [PATCH 3/4] cp -T option does not exist on on macos --- Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 302d46e..9da4634 100644 --- a/Makefile +++ b/Makefile @@ -211,9 +211,10 @@ ${more_built_directories}: Makefile ${bld}/os.32k: example-os/os.asm ${bld}/check_makefile nasm -w+macro-params -w+macro-selfref -w+orphan-labels -w+gnu-elf-extensions -o $@ $< +cp_T_option = $$(if test "$$(uname -s)" = Darwin; then echo ''; else echo '-T'; fi) ${bld}/os.iso: ${bld}/iso_files/os.zip ${bld}/iso_files/boot/iso_boot.sys ${bld}/check_makefile ! test -d ${bld}/iso_files.tmp - cp -a -T -- ${bld}/iso_files ${bld}/iso_files.tmp + cp -a ${cp_T_option} -- ${bld}/iso_files ${bld}/iso_files.tmp find ${bld}/iso_files.tmp -depth -exec touch -t ${commit_timestamp} '{}' ';' (cd ./${bld}/iso_files.tmp/ && faketime -f ${commit_faketime} mkisofs \ --input-charset utf-8 \ From 24fe32c3b51c69cc3509cd6a1cd4b2f8a4c01028 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Georges=20Dup=C3=A9ron?= Date: Sat, 22 Sep 2018 00:40:07 +0200 Subject: [PATCH 4/4] Circumvent the fact that faketime does not work on system binaries in macos --- .gitignore | 3 +++ Makefile | 19 +++++++++++++------ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 4eb63e1..d129e9f 100644 --- a/.gitignore +++ b/.gitignore @@ -118,3 +118,6 @@ /deploy-screenshots/virtualbox-anim.gif /deploy-screenshots/virtualbox.png /os.bat +/utils/mcopy +/utils/mformat +/utils/mkisofs diff --git a/Makefile b/Makefile index 9da4634..708dbe8 100644 --- a/Makefile +++ b/Makefile @@ -108,7 +108,8 @@ built_files = ${os_filename} \ ${tests_noemu:test/%=${bld}/test_pass/noemu_%} \ ${tests_requiring_sudo:test/%=${bld}/test_pass/sudo_%} \ ${tests_emu:test/%=${screenshots}/%.png} \ - ${tests_emu:test/%=${screenshots}/%-anim.gif} + ${tests_emu:test/%=${screenshots}/%-anim.gif} \ + utils/mformat utils/mcopy utils/mkisofs # Temporary copies used to adjust timestamps for reproducible builds. # These are normally created and deleted within a single target, but @@ -211,12 +212,17 @@ ${more_built_directories}: Makefile ${bld}/os.32k: example-os/os.asm ${bld}/check_makefile nasm -w+macro-params -w+macro-selfref -w+orphan-labels -w+gnu-elf-extensions -o $@ $< +# Circumvent the fact that faketime does not work on system binaries in macos +./utils/mkisofs ./utils/mformat ./utils/mcopy: Makefile # TODO: depend on the mkisofs binary + cp $$(which $$(basename $@)) $@ + chmod u+x $@ + cp_T_option = $$(if test "$$(uname -s)" = Darwin; then echo ''; else echo '-T'; fi) -${bld}/os.iso: ${bld}/iso_files/os.zip ${bld}/iso_files/boot/iso_boot.sys ${bld}/check_makefile +${bld}/os.iso: ${bld}/iso_files/os.zip ${bld}/iso_files/boot/iso_boot.sys ./utils/mkisofs ${bld}/check_makefile ! test -d ${bld}/iso_files.tmp cp -a ${cp_T_option} -- ${bld}/iso_files ${bld}/iso_files.tmp find ${bld}/iso_files.tmp -depth -exec touch -t ${commit_timestamp} '{}' ';' - (cd ./${bld}/iso_files.tmp/ && faketime -f ${commit_faketime} mkisofs \ + UTILS="$$PWD/utils" (cd ./${bld}/iso_files.tmp/ && faketime -f ${commit_faketime} $$UTILS/mkisofs \ --input-charset utf-8 \ -rock \ -joliet \ @@ -292,14 +298,15 @@ ${eval ${call offset,bytes_gpt_mirror_start, $${bytes_gpt_mirror_end} - $${bytes ${eval ${call offset,bytes_zip_end, $${bytes_os_size}, bytes_os_size,}} os_fat12_partition = "$@@@${bytes_fat12_start}" -${bld}/os.fat12: ${bld}/os.zip ${dep_bytes_fat12_size} ${dep_bytes_fat12_start} ${dep_sectors_os_size} ${bld}/check_makefile +${bld}/os.fat12: ${bld}/os.zip ${dep_bytes_fat12_size} ${dep_bytes_fat12_start} ${dep_sectors_os_size} \ + ./utils/mformat ./utils/mcopy ${bld}/check_makefile set -x; dd if=/dev/zero bs=${sector_size} count=${sectors_os_size} of=$@ - faketime -f ${commit_faketime} mformat -v "Example OS" \ + faketime -f ${commit_faketime} ./utils/mformat -v "Example OS" \ -T ${sectors_fat12_size} \ -h ${os_floppy_chs_h} \ -s ${os_floppy_chs_s} \ -i ${os_fat12_partition} - faketime -f ${commit_faketime} mcopy -i ${os_fat12_partition} $< "::os.zip" + faketime -f ${commit_faketime} ./utils/mcopy -i ${os_fat12_partition} $< "::os.zip" ${bld}/iso_files/os.zip: ${bld}/os.zip ${bld}/check_makefile # TODO: make it so that the various file formats are mutual quines: