Compare commits

...

43 Commits

Author SHA1 Message Date
Georges Dupéron
9b89af06c4 Travis: install guix, which needs sudo 2018-10-15 00:29:57 +02:00
Georges Dupéron
0792640e43 more debug offsets 2018-10-15 00:29:57 +02:00
Georges Dupéron
dbadffd09d Store the GPT mirror at the end of the file, inside the ZIP comment (fixes #10) 2018-10-15 00:29:57 +02:00
Georges Dupéron
95216b8439 The name of the OS is configurable via a Makefile variable 2018-10-15 00:29:57 +02:00
Georges Dupéron
3126558a4f Merge branch 'dev-guid-gdisk' 2018-10-15 00:29:57 +02:00
Georges Dupéron
77b33ac0e1 Inject the commit timestamp from the Guix build recipe 2018-10-15 00:29:57 +02:00
Georges Dupéron
796fa23965 Fix the CRC in the mirror header too 2018-10-15 00:29:57 +02:00
Georges Dupéron
292dd908ba Merge branch 'dev-guix-build-environment' (dummy timestamp, dummy hash for GUIDs) 2018-10-15 00:29:57 +02:00
Georges Dupéron
38d057464b Fixed the GPT CRCs after injecting the MS-DOS comments in the partition array 2018-10-15 00:29:57 +02:00
Georges Dupéron
76def29a7f make [all] now uses the guix build environment (but other targets don't) 2018-10-15 00:29:57 +02:00
Georges Dupéron
e8349eb34c 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.
2018-10-15 00:29:57 +02:00
Georges Dupéron
3913845ca9 Added dependencies to guix.scm 2018-10-15 00:29:57 +02:00
Georges Dupéron
3b640e997d GUID for gdisk: have Guix inject the hash of the inputs into the source tree 2018-10-15 00:29:57 +02:00
Georges Dupéron
178e75902a Started describing a Guix build environment 2018-10-15 00:29:54 +02:00
Georges Dupéron
d5f1c26226
Added another safety option to bash, moved bash invocation to a separate file 2018-10-02 03:19:02 +02:00
Georges Dupéron
24d1285603
Merge branch 'dev-split-makefile' 2018-10-02 03:19:01 +02:00
Georges Dupéron
239f050a4b
Split the clean target into clean and clean_reproducible 2018-10-02 03:19:01 +02:00
Georges Dupéron
017b038ac4
Split the Makefile into three parts (build framework, os-specific build recipes, tests)
Closes #1
2018-10-02 03:19:00 +02:00
Georges Dupéron
4fb06d5865
Merge branch 'misc-cleanup-and-debug' into master 2018-10-02 03:18:08 +02:00
Georges Dupéron
3669ba800e
Tests should fail if the OS filename argument is missing. 2018-10-02 03:18:08 +02:00
Georges Dupéron
584a8541c0
Fixed dependency in Makefile 2018-10-02 03:18:08 +02:00
Georges Dupéron
0e59aa2cc2
make -j 10 sometimes fails to mount the resulting ISO9660 filesystem, added more information and a dump of the OS binary to help debug the issue 2018-10-02 03:18:08 +02:00
Georges Dupéron
f98acb7662
debug sikuli installation error 2018-10-02 03:18:08 +02:00
Georges Dupéron
ba6f2b39a9
Fixed typo (+ instead of *) 2018-10-02 03:18:06 +02:00
Georges Dupéron
6b0082dd68
Display warning: reproducible builds do not work on Windows or macos 2018-10-01 21:08:38 +02:00
Georges Dupéron
1b36f8e98b
Merge branch 'reproducible-build-windows' (unfinished) 2018-10-01 21:08:38 +02:00
Georges Dupéron
b8941befe8
Merge branch 'reproducible-build-macos' (does not work) 2018-10-01 21:08:37 +02:00
Georges Dupéron
76ef64b5be
Use faketime or datefudge if the former is not installed 2018-10-01 21:08:37 +02:00
Georges Dupéron
24fe32c3b5
Circumvent the fact that faketime does not work on system binaries in macos 2018-10-01 21:08:37 +02:00
Georges Dupéron
6f5522bdcb
Installed datefudge on Appveyor via Cygwin 2018-10-01 21:08:37 +02:00
Georges Dupéron
60a7f054b3
appveyor: clone_depth is unnecessary if shallow_clone is used 2018-10-01 21:08:37 +02:00
Georges Dupéron
fce3b9b6b3
Merge branch 'reproducible-build-linux' 2018-10-01 21:08:36 +02:00
Georges Dupéron
07e12d3062
cp -T option does not exist on on macos 2018-10-01 21:08:36 +02:00
Georges Dupéron
08901554b0
Screenshots directory is now an option, to avoid conflicts with the reproducible build's make clean 2018-10-01 21:08:36 +02:00
Georges Dupéron
2e9ce6fc26
macos: date conversion needs different flags than in Linux 2018-10-01 21:08:36 +02:00
Georges Dupéron
00bfba9251
macos: mkisofs includes the path to its input as extra unwanted directories in the iso 2018-10-01 21:08:36 +02:00
Georges Dupéron
634a4a0ff3
Omit the build directory path from os.offsets.hex
The build directory is not the same for the normal build and the build made to check for reproducibility.
2018-10-01 21:08:35 +02:00
Georges Dupéron
94deee14b0
Avoid copying iso_files as a subfolder of an existing iso_files.tmp if the latter was not cleaned correctly 2018-10-01 21:08:35 +02:00
Georges Dupéron
01ea5827b2
Added COMMIT_TIMESTAMP_ISO_8601 as a Makefile parameter 2018-10-01 21:08:35 +02:00
Georges Dupéron
7dcdca9649
Check that the build is reproducible 2018-10-01 21:08:35 +02:00
Georges Dupéron
01d3ae7544
Made the build directory configurable 2018-10-01 21:08:35 +02:00
Georges Dupéron
cd866fb6e7
Closes #42: Reproducible builds
232 initial number of different lines in the hexadecimal dump.
160 (recursive touch in iso_files)
108 (touch os.32k)
46  (faketime on mkisofs)
38  (faketime on mformat)
32  (faketime on mcopy)
0   (explicit partition and disk GUIDs)
2018-10-01 21:08:34 +02:00
Georges Dupéron
282f241459
Missing dependency in offsets calculation (could cause race condition when building with -j) 2018-10-01 21:08:30 +02:00
19 changed files with 1610 additions and 431 deletions

12
.gitignore vendored
View File

@ -5,6 +5,8 @@
/build/check_makefile
/build/check_makefile_targets
/build/check_makefile_w_arnings
/build/gpt_guid1
/build/gpt_guid2
/build/iso_files/boot/iso_boot.sys
/build/iso_files/os.zip
/build/makefile_built_directories
@ -85,6 +87,11 @@
/build/os.offsets.hex
/build/os.reasm
/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
@ -96,12 +103,14 @@
/build/test_pass/emu_virtualbox
/build/test_pass/noemu_fat12_contents
/build/test_pass/noemu_os.reasm
/build/test_pass/noemu_reproducible_build
/build/test_pass/noemu_sizes
/build/test_pass/noemu_zip
/build/test_pass/sudo_fat12_mount
/build/test_pass/sudo_iso_mount
/build/twm_cfg
/build/virtualbox.img
/COMMIT_TIMESTAMP
/deploy-screenshots/bochs-anim.gif
/deploy-screenshots/bochs.png
/deploy-screenshots/dosbox-anim.gif
@ -117,3 +126,6 @@
/deploy-screenshots/virtualbox-anim.gif
/deploy-screenshots/virtualbox.png
/os.bat
/utils/mcopy
/utils/mformat
/utils/mkisofs

View File

@ -22,6 +22,26 @@ addons:
- nasm
- mtools
- genisoimage
- faketime
before_install:
- gpg --keyserver pgp.mit.edu --recv-keys 3CE464558A84FDC69DB40CFB090B11993D9AEBB5 || gpg --keyserver keys.gnupg.net --recv-keys 3CE464558A84FDC69DB40CFB090B11993D9AEBB5
- wget https://alpha.gnu.org/gnu/guix/guix-binary-0.15.0.x86_64-linux.tar.xz.sig
- wget https://alpha.gnu.org/gnu/guix/guix-binary-0.15.0.x86_64-linux.tar.xz
- gpg --verify guix-binary-0.15.0.x86_64-linux.tar.xz.sig
- sudo tar -Jxf guix-binary-0.15.0.x86_64-linux.tar.xz && sudo mv var/guix /var && sudo mv gnu /
- ln --no-dereference --symbolic /var/guix/profiles/per-user/root/guix-profile "$PWD/guix-profile"
- GUIX_PROFILE="$PWD/guix-profile"
- source "$GUIX_PROFILE/etc/profile"; echo $PATH
- echo; echo $PATH
- sudo groupadd --system guixbuild
# --groups kvm
- for i in 01 02 03 04 05 06 07 08 09 10; do sudo useradd "guixbuilder$i" --gid guixbuild --groups guixbuild --home-dir /dev/null/nowhere --comment "Guix build user $i" --shell $(which nologin) --system; done
- sudo "$GUIX_PROFILE/bin/guix-daemon" --build-users-group=guixbuild --max-jobs=10 &
- sleep 5 # TODO…
- echo; echo $PATH
- cat "$GUIX_PROFILE/share/guix/hydra.gnu.org.pub" | sudo su -c "source '$GUIX_PROFILE/etc/profile'; guix archive --authorize"
- guix package -i hello
matrix:
include:
@ -40,14 +60,14 @@ matrix:
- dosbox
- os: linux
env: MODE=gui-sh
sudo: false
sudo: true # false
addons:
apt:
packages:
- *common_apt_packages
- os: linux
env: MODE=dosbox
sudo: false
sudo: true # false
addons:
apt:
packages:
@ -60,10 +80,11 @@ matrix:
- brew install mtools
- brew cask install gdisk
- brew install imagemagick # --with-x11
- brew install libfaketime
script: make all test/noemu test/macos
- os: linux
env: MODE=qemu-system-i386-floppy
sudo: false
sudo: true # false
addons:
apt:
packages:
@ -72,7 +93,7 @@ matrix:
- qemu-system-x86
- os: linux
env: MODE=qemu-system-i386-cdrom
sudo: false
sudo: true # false
addons:
apt:
packages:
@ -81,7 +102,7 @@ matrix:
- qemu-system-x86
- os: linux
env: MODE=qemu-system-arm
sudo: false
sudo: true # false
addons:
apt:
packages:
@ -99,7 +120,7 @@ matrix:
#- virtualbox
- os: linux
env: MODE=bochs
sudo: false
sudo: true # false
addons:
apt:
packages:
@ -119,6 +140,7 @@ install:
- import --version || test "$MODE" = osx-test # import --version has a non-zero exit code on the Travis installation
- Xvfb -help
- ssh -V
- faketime --version
- ./utils/install-sikulix.sh
- export PATH="$HOME/sikulix/:$PATH"
- if test "$MODE" = virtualbox -o "$MODE" = self-test; then ./utils/install-virtualbox.sh; fi

577
Makefile
View File

@ -1,462 +1,199 @@
####################################
# Makefile configuration variables #
OS_FILENAME = os.bat
BUILD_DIR = build
SCREENSHOTS_DIR = deploy-screenshots
COMMIT_TIMESTAMP_ISO_8601 = $$(git log -1 --pretty=format:%ad --date=iso8601-strict)
####################################
MAKEFLAGS = --warn-undefined-variables
SHELL = bash -euET -o pipefail -c
SHELL = ${CURDIR}/utils/safe-bash.sh
# utils/safe-bash.sh
.SECONDEXPANSION:
os_filename = os.bat
Makefiles = Makefile Makefile.example-os Makefile.test-example-os
# Avoid hardcoding the name of the OS. A name change is frequent (during early
# development, and when the project is forked), and is often costly.
os_name = Example OS
os_filename = ${OS_FILENAME}
bld = ${BUILD_DIR}
screenshots = ${SCREENSHOTS_DIR}
tests_emu = test/qemu-system-i386-floppy test/qemu-system-i386-cdrom test/qemu-system-arm test/virtualbox test/bochs test/gui-sh test/dosbox
tests_requiring_sudo = test/fat12_mount test/iso_mount
tests_noemu = test/zip test/os.reasm test/sizes test/fat12_contents
offset_names = bytes_os_size \
bytes_mbr_start \
bytes_mbr_end \
bytes_header_32k_start \
bytes_header_32k_end \
bytes_iso_start \
bytes_iso_end \
bytes_fat12_start \
bytes_fat12_end \
bytes_gpt_mirror_start \
bytes_gpt_mirror_end \
bytes_zip_start \
bytes_zip_end
more_offset_names = ${offset_names} \
bytes_fat12_size \
bytes_gpt_mirror_size \
bytes_header_32k_size \
bytes_iso_size \
bytes_zip_size \
sectors_fat12_size \
sectors_fat12_start \
sectors_gpt_mirror_size \
sectors_iso_size \
sectors_os_size \
sectors_zip_size \
tracks_fat12_size \
tracks_gpt_mirror_size \
tracks_iso_size \
tracks_os_size \
tracks_zip_size
more_offset_dec = ${more_offset_names:%=build/offsets/%.dec}
more_offset_hex = ${more_offset_names:%=build/offsets/%.hex}
# + os.arm.disasm
# + os.reasm.disasm
built_files = ${os_filename} \
build/check_makefile \
build/check_makefile_targets \
build/check_makefile_w_arnings \
build/checkerboard_800x600.xbm \
build/checkerboard_1024x768.png \
build/makefile_built_directories \
build/makefile_built_files \
build/makefile_database \
build/makefile_database_files \
build/makefile_file_targets \
build/makefile_non_file_targets \
build/makefile_phony \
build/makefile_targets \
build/makefile_w_arnings \
build/os.ndisasm.disasm \
build/os.reasm.asm \
build/os.reasm \
build/os.file \
build/os.gdisk \
build/os.zip \
build/os.zip.adjusted \
build/os.iso \
build/os.32k \
build/os.fat12 \
build/os.offsets.hex \
build/os.offsets.dec \
build/os.hex_with_offsets \
build/iso_files/os.zip \
build/iso_files/boot/iso_boot.sys \
build/bochsrc \
build/bochscontinue \
build/twm_cfg \
build/virtualbox.img \
${more_offset_dec} \
${more_offset_hex} \
${tests_emu:test/%=build/test_pass/emu_%} \
${tests_noemu:test/%=build/test_pass/noemu_%} \
${tests_requiring_sudo:test/%=build/test_pass/sudo_%} \
${tests_emu:test/%=deploy-screenshots/%.png} \
${tests_emu:test/%=deploy-screenshots/%-anim.gif}
built_directories = build/iso_files/boot build/iso_files build/offsets build/mnt_fat12 build/mnt_iso build/test_pass deploy-screenshots
more_built_directories = ${built_directories} build
os_image_size_kb = 1440
os_partition_start_sectors = 3
os_partition_size_sectors = 717 # 720 - start
# CHS parameters for 1.44 MB floppy disk
os_floppy_chs_h = 2
os_floppy_chs_s = 9
tests_noemu = test/zip test/os.reasm test/sizes test/fat12_contents test/reproducible_build
.DEFAULT_GOAL := all
.PHONY: all
# all: os.arm.disasm
all: ${os_filename} build/os.ndisasm.disasm build/os.reasm.asm build/os.file build/os.gdisk build/os.offsets.hex build/os.offsets.dec build/os.hex_with_offsets .gitignore build/check_makefile ${more_offset_dec} ${more_offset_hex}
all:
cp -f "$$(guix build --check -f guix.scm)/bin/$$(basename "${os_filename}")" "${os_filename}"
build/makefile_w_arnings: | $${@D}
# 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
real_commit_timestamp_iso_8601 = $$(if test "${COMMIT_TIMESTAMP_ISO_8601}" = "FILE"; then cat COMMIT_TIMESTAMP; else echo "${COMMIT_TIMESTAMP_ISO_8601}"; fi)
commit_timestamp = "$$(${call date_command,"${real_commit_timestamp_iso_8601}",'+%Y%m%d%H%m.%S'})"
reproducible_os_filename="${bld}/reproduced_$$(basename "${os_filename}")"
built_files += ${bld}/check_makefile \
${bld}/check_makefile_targets \
${bld}/check_makefile_w_arnings \
${bld}/makefile_built_directories \
${bld}/makefile_built_files \
${bld}/makefile_database \
${bld}/makefile_database_files \
${bld}/makefile_file_targets \
${bld}/makefile_non_file_targets \
${bld}/makefile_phony \
${bld}/makefile_targets \
${bld}/makefile_w_arnings \
COMMIT_TIMESTAMP
include Makefile.example-os
include Makefile.test-example-os
more_built_directories = ${built_directories} ${bld}
.PHONY: in-guix
# in-guix: os.arm.disasm
in-guix: .gitignore \
${bld}/check_makefile
COMMIT_TIMESTAMP:
echo "This file is injected by the Guix build recipe."
${bld}/makefile_w_arnings: | $${@D}
${built_files}: | $${@D}
build/makefile_w_arnings: Makefile
@unset MAKEFLAGS MAKELEVEL MAKE_TERMERR MFLAGS; make -n --warn-undefined-variables test 2>$@ 1>/dev/null || make -n --warn-undefined-variables test
${bld}/makefile_w_arnings: ${Makefiles}
@unset MAKEFLAGS MAKELEVEL MAKE_TERMERR MFLAGS; \
make -n --warn-undefined-variables \
OS_FILENAME=${OS_FILENAME} \
BUILD_DIR=${BUILD_DIR} \
SCREENSHOTS_DIR=${SCREENSHOTS_DIR} \
COMMIT_TIMESTAMP_ISO_8601=${real_commit_timestamp_iso_8601} \
test 2>$@ 1>/dev/null \
|| cat $@
# Check that the file build/makefile_w_arnings is present, and that it does not contain the string "warn".
build/check_makefile_w_arnings: build/makefile_w_arnings
@cat build/makefile_w_arnings > /dev/null && (! grep -i warn $<) && touch $@
# Check that the file ${bld}/makefile_w_arnings is present, and that it does not contain the string "warn".
${bld}/check_makefile_w_arnings: ${bld}/makefile_w_arnings
@cat ${bld}/makefile_w_arnings > /dev/null && (! grep -i warn $<) && touch $@
# Check that the declared list of built files matches the list of targets extracted from the Makefile.
build/check_makefile_targets: build/makefile_built_files build/makefile_file_targets build/check_makefile_w_arnings
@diff build/makefile_built_files build/makefile_file_targets && touch $@
${bld}/check_makefile_targets: ${bld}/makefile_built_files ${bld}/makefile_file_targets ${bld}/check_makefile_w_arnings
@diff ${bld}/makefile_built_files ${bld}/makefile_file_targets && touch $@
build/check_makefile: build/check_makefile_w_arnings build/check_makefile_targets
${bld}/check_makefile: ${bld}/check_makefile_w_arnings ${bld}/check_makefile_targets
@touch $@
build/makefile_database: Makefile build/check_makefile_w_arnings
@unset MAKEFLAGS MAKELEVEL MAKE_TERMERR MFLAGS; make -rpn | sed -n -e '/^# Make data base,/,$$p' > $@
${bld}/makefile_database: ${Makefiles} ${bld}/check_makefile_w_arnings
@unset MAKEFLAGS MAKELEVEL MAKE_TERMERR MFLAGS; \
make -rpn \
OS_FILENAME=${OS_FILENAME} \
BUILD_DIR=${BUILD_DIR} \
SCREENSHOTS_DIR=${SCREENSHOTS_DIR} \
COMMIT_TIMESTAMP_ISO_8601=${real_commit_timestamp_iso_8601} \
| sed -n -e '/^# Make data base,/,$$p' > $@
build/makefile_database_files: build/makefile_database build/check_makefile_w_arnings
${bld}/makefile_database_files: ${bld}/makefile_database ${bld}/check_makefile_w_arnings
@sed -n -e '/^# Files$$/,/^# files hash-table stats:$$/p' $< > $@
build/makefile_built_directories: build/check_makefile_w_arnings
${bld}/makefile_built_directories: ${bld}/check_makefile_w_arnings
@echo ${more_built_directories} | tr ' ' '\n' | grep -v '^[[:space:]]*$$' | sort > $@
build/makefile_built_files: build/check_makefile_w_arnings
${bld}/makefile_built_files: ${bld}/check_makefile_w_arnings
@echo ${built_files} | tr ' ' '\n' | grep -v '^[[:space:]]*$$' | sort > $@
build/makefile_phony: build/makefile_database_files build/check_makefile_w_arnings
${bld}/makefile_phony: ${bld}/makefile_database_files ${bld}/check_makefile_w_arnings
@sed -n -e 's/^\.PHONY: \(.*\)$$/\1/p' $< | tr ' ' '\n' | grep -v '^[[:space:]]*$$' | sort > $@
build/makefile_targets: build/makefile_database_files build/check_makefile_w_arnings
${bld}/makefile_targets: ${bld}/makefile_database_files ${bld}/check_makefile_w_arnings
@grep -E -v '^([[:space:]]|#|\.|$$|^[^:]*:$$)' $< | grep '^[^ :]*:' | sed -e 's|^\([^:]*\):.*$$|\1|' | sort > $@
build/makefile_non_file_targets: build/makefile_phony build/makefile_built_directories build/check_makefile_w_arnings
@cat build/makefile_phony build/makefile_built_directories | sort > $@
${bld}/makefile_non_file_targets: ${bld}/makefile_phony ${bld}/makefile_built_directories ${bld}/check_makefile_w_arnings
@cat ${bld}/makefile_phony ${bld}/makefile_built_directories | sort > $@
build/makefile_file_targets: build/makefile_non_file_targets build/makefile_targets build/check_makefile_w_arnings
@comm -23 build/makefile_targets build/makefile_non_file_targets > $@
${bld}/makefile_file_targets: ${bld}/makefile_non_file_targets ${bld}/makefile_targets ${bld}/check_makefile_w_arnings
@comm -23 ${bld}/makefile_targets ${bld}/makefile_non_file_targets > $@
${built_directories}: build/check_makefile
${more_built_directories}: Makefile
${built_directories}: ${bld}/check_makefile
${more_built_directories}: ${Makefiles}
mkdir -p $@ && touch $@
# 32k header of the ISO9660 image
build/os.32k: example-os/os.asm build/check_makefile
nasm -w+macro-params -w+macro-selfref -w+orphan-labels -w+gnu-elf-extensions -o $@ $<
build/os.iso: build/iso_files/os.zip build/iso_files/boot/iso_boot.sys build/check_makefile
mkisofs \
--input-charset utf-8 \
-rock \
-joliet \
-eltorito-catalog boot/boot.cat \
-eltorito-boot boot/iso_boot.sys \
-no-emul-boot \
-boot-load-size 4 \
-pad \
-output $@ \
./build/iso_files/
# Layout:
# MBR; GPT; UNIX sh & MS-DOS batch scripts; ISO9660; FAT12; GPT mirror; ZIP
define offset
tmp_${1} = ${3}
build/offsets/${1}.dec: $${tmp_${1}:%=build/offsets/%.dec} ${4} build/check_makefile
echo $$$$(( ${2} )) | tee $$@
${1} = $$$$(cat build/offsets/${1}.dec)
dep_${1} = build/offsets/${1}.dec
endef
define div_round_up
( ( ( ${1} ) + ( ${2} ) - 1 ) / ( ${2} ) )
endef
sector_size = 512
# should be exact (TODO: make a check)
${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,}}
# round up
${eval ${call offset,bytes_iso_size, $$$$(utils/file-length.sh -c build/os.iso), ,build/os.iso}}
${eval ${call offset,sectors_iso_size, ${call div_round_up,$${bytes_iso_size},$${sector_size}}, bytes_iso_size,}}
${eval ${call offset,tracks_iso_size, ${call div_round_up,$${sectors_iso_size},$${os_floppy_chs_s}}, sectors_iso_size,}}
# round up
${eval ${call offset,bytes_zip_size, $$$$(utils/file-length.sh -c build/os.zip), ,build/os.zip}}
${eval ${call offset,sectors_zip_size, ${call div_round_up,$${bytes_zip_size},$${sector_size}}, bytes_zip_size,}}
${eval ${call offset,tracks_zip_size, ${call div_round_up,$${sectors_zip_size},$${os_floppy_chs_s}}, sectors_zip_size,}}
# round up
${eval ${call offset,sectors_gpt_mirror_size, 33,, }}
${eval ${call offset,tracks_gpt_mirror_size, ${call div_round_up,$${sectors_gpt_mirror_size},$${os_floppy_chs_s}}, sectors_gpt_mirror_size,}}
# allocate the remaining sectors to the FAT, aligned on tracks
${eval ${call offset,tracks_fat12_size, $${tracks_os_size} - $${tracks_iso_size} - $${tracks_gpt_mirror_size} - $${tracks_zip_size}, tracks_os_size tracks_iso_size tracks_gpt_mirror_size tracks_zip_size,}}
${eval ${call offset,sectors_fat12_size,$${tracks_fat12_size} * $${os_floppy_chs_s}, tracks_fat12_size,}}
# zip should probably have its end aligned, not its start
${eval ${call offset,bytes_zip_start, $${bytes_os_size} - $${bytes_zip_size}, bytes_os_size bytes_zip_size,}}
${eval ${call offset,bytes_mbr_start, 0,,}}
${eval ${call offset,bytes_mbr_end, 512,,}}
${eval ${call offset,bytes_header_32k_start, 0,,}}
${eval ${call offset,bytes_header_32k_end, 32 * 1024,,}}
${eval ${call offset,bytes_header_32k_size, $${bytes_header_32k_end} - $${bytes_header_32k_start}, bytes_header_32k_end bytes_header_32k_start,}}
${eval ${call offset,bytes_iso_start, 32 * 1024,,}}
${eval ${call offset,bytes_iso_end, $${sectors_iso_size} * $${sector_size}, sectors_iso_size,}}
${eval ${call offset,bytes_fat12_start, $${tracks_iso_size} * $${os_floppy_chs_s} * $${sector_size}, tracks_iso_size,}}
${eval ${call offset,sectors_fat12_start, $${bytes_fat12_start} / $${sector_size}, bytes_fat12_start,}}
${eval ${call offset,bytes_fat12_size, $${sectors_fat12_size} * $${sector_size}, sectors_fat12_size,}}
${eval ${call offset,bytes_fat12_end, $${bytes_fat12_start} + $${bytes_fat12_size}, bytes_fat12_start bytes_fat12_size,}}
# 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_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},, }}
os_fat12_partition = "$@@@${bytes_fat12_start}"
build/os.fat12: build/os.zip ${dep_bytes_fat12_size} ${dep_bytes_fat12_start} ${dep_sectors_os_size} build/check_makefile
set -x; dd if=/dev/zero bs=${sector_size} count=${sectors_os_size} of=$@
set -x; mformat -v "Example OS" \
-T ${sectors_fat12_size} \
-h ${os_floppy_chs_h} \
-s ${os_floppy_chs_s} \
-i ${os_fat12_partition}
set -x; mcopy -i ${os_fat12_partition} build/os.zip "::os.zip"
build/iso_files/os.zip: build/os.zip build/check_makefile
# TODO: make it so that the various file formats are mutual quines:
# * the ISO should contain the original file
# * the ZIP should contain the original file
# * the FAT12 should contain the original file
cp $< $@
# 4 sectors loaded when booting from optical media (CD-ROM, …):
build/iso_files/boot/iso_boot.sys: build/os.32k build/check_makefile
# TODO: this copy of the (or alternate) bootsector should contain a Boot Information Table,
# see https://wiki.osdev.org/El-Torito#A_BareBones_Boot_Image_with_Boot_Information_Table
dd if=$< bs=512 count=4 of=$@
build/os.zip: build/os.32k build/check_makefile
zip $@ $<
build/os.zip.adjusted: build/os.zip ${dep_bytes_zip_start} build/check_makefile
# TODO: the ZIP file can end with a variable-length comment, this would allow us to hide the GPT mirrors.
set -x; dd if=/dev/zero bs=1 count=${bytes_zip_start} of=$@
cat $< >> $@
zip --adjust-sfx $@
${os_filename}: build/os.32k build/os.iso build/os.fat12 build/os.zip.adjusted \
${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} \
build/check_makefile
rm -f $@
# start with the .iso
cp build/os.iso $@
# splice in the first 32k (bootsector and partition table)
set -x; dd skip=${bytes_header_32k_start} seek=${bytes_header_32k_start} bs=1 count=${bytes_header_32k_size} conv=notrunc if=build/os.32k of=$@
# splice in fat12
set -x; dd skip=${bytes_fat12_start} seek=${bytes_fat12_start} bs=1 count=${bytes_fat12_size} conv=notrunc if=build/os.fat12 of=$@
# pad with zeroes to prepare for GPT table
set -x; dd if=/dev/zero seek=$$((${bytes_gpt_mirror_end} - 1 )) bs=1 count=1 conv=notrunc of=$@
# patch the partition table
# Thanks to https://wiki.gentoo.org/wiki/Hybrid_partition_table for showing that gdisk can be used to make a hybrid MBR / GPT.
# gdisk commands:
# * Delete (the only) partition, eXpert mode, sector aLignment = 1, back to Main menu,
# * New partition (number = 1, start sector, end sector, type 0700)
# * Recovery and transformation options, make Hybrid,
# * add GPT partition #1 to the hybrid MBR, do Not put the EFI partition first,
# * MBR partition type=0x01, bootable=Yes, do Not add extra partitions,
# * Print GPT, print MBR, Write, Proceed.
(if test "$$(uname -o)" = "Cygwin"; then printf "Y\n"; fi; \
printf "d\nx\nl\n1\nm\nn\n1\n${sectors_fat12_start}\n${sectors_fat12_size}\n0700\n"; \
printf "r\nh\n"; \
printf "1\nN\n"; \
printf "01\nY\nN\n"; \
printf "p\no\nw\nY\n") | while read str; do echo "$$str"; printf "\033[1;33m%s\033[m\n" "$$str" >&2; sleep 0.01; done | 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
# line length (8192 excluding CR+LF). $i below is the partition entry number, starting from 1
# The numbers 55 and 118 are arbitrarily chosen so that the space between two CR+LF is less than 8192.
for i in 55 118; do \
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
# splice in zip at the end
set -x; dd skip=${bytes_zip_start} seek=${bytes_zip_start} bs=1 conv=notrunc if=build/os.zip.adjusted of=$@
chmod a+x-w $@
build/os.file: ${os_filename} build/check_makefile
file -kr $< > $@
build/os.gdisk: ${os_filename} build/check_makefile
# gdisk commands:
# * Print partition table
# * Recovery and transformation options
# * print prOtective MBR table
# * Quit
printf 'p\nr\no\nq\n' | gdisk $< | tee $@
build/os.offsets.hex: ${offset_names:%=build/offsets/%.hex} build/check_makefile
grep '^' ${offset_names:%=build/offsets/%.hex} | sed -e 's/:/: 0x/' | column -t > $@
build/os.offsets.dec: ${offset_names:%=build/offsets/%.dec} build/check_makefile
grep '^' ${offset_names:%=build/offsets/%.dec} | sed -e 's/:/: /' | column -t > $@
build/offsets/%.hex: build/offsets/%.dec
printf '%x\n' $$(cat $<) > $@
build/os.hex_with_offsets: ${os_filename} build/os.offsets.hex
hexdump -C $< \
| grep -E -e "($$(cat build/os.offsets.hex | cut -d '=' -f 2 | sed -e 's/^[[:space:]]*0x\(.*\).$$/^\10/' | tr '\n' '|')^)" --color=yes > $@
build/os.ndisasm.disasm: ${os_filename} utils/compact-ndisasm.sh build/check_makefile
./utils/compact-ndisasm.sh $< $@
build/os.reasm.asm: build/os.ndisasm.disasm build/check_makefile
sed -e 's/^[^ ]\+ \+[^ ]\+ \+//' $< > $@
build/test_pass/noemu_%.reasm build/%.reasm: build/%.reasm.asm ${os_filename} utils/compact-ndisasm.sh build/check_makefile
# For now ignore this test, since we cannot have a reliable re-assembly of arbitrary data.
touch build/test_pass/noemu_$*.reasm build/$*.reasm
# nasm $< -o $@
# @echo "diff $@ ${os_filename}"
# @diff $@ ${os_filename} \
# && echo "Re-assembled file is identical to ${os_filename}" \
# || (./utils/compact-ndisasm.sh $@ build/os.reasm.disasm; \
# echo "Re-assembled file is different from ${os_filename}. Use meld build/os.ndisasm.disasm build/os.reasm.disasm to see differences."; \
# exit 0)
#os.arm.disasm: ${os_filename} build/check_makefile
# arm-none-eabi-objdump --endian=little -marm -b binary -D --adjust-vma=0x8000 $< > $@
.PHONY: clean
clean: build/check_makefile
rm -f ${built_files}
for d in $$(echo ${more_built_directories} | tr ' ' '\n' | sort --reverse); do \
clean: clean_reproducible ${bld}/check_makefile
rm -f ${built_files} ${temp_files}
for d in $$(echo ${more_built_directories} ${temp_directories} | tr ' ' '\n' | sort --reverse); do \
if test -e "$$d"; then \
rmdir "$$d"; \
fi; \
done
.gitignore: build/check_makefile
.PHONY: clean_reproducible
clean_reproducible: ${bld}/check_makefile
# Calling make unconditionally would cause infinite recursion, so we
# first check whether there is anything to remove.
if test -d ${bld}/reproducible -o -f ${bld}/${reproducible_os_filename}; then \
unset MAKEFLAGS MAKELEVEL MAKE_TERMERR MFLAGS; \
make OS_FILENAME=${reproducible_os_filename} \
BUILD_DIR=${bld}/reproducible \
SCREENSHOTS_DIR=${bld}/reproducible/screenshots \
COMMIT_TIMESTAMP_ISO_8601=${real_commit_timestamp_iso_8601} \
clean; \
fi
.gitignore: ${bld}/check_makefile
for f in ${built_files}; do echo "/$$f"; done | sort > $@
.PHONY: test
test: ${tests_emu:test/%=build/test_pass/emu_%} \
${tests_noemu:test/%=build/test_pass/noemu_%} \
${tests_requiring_sudo:test/%=build/test_pass/sudo_%} \
all \
build/check_makefile
test: all \
${bld}/check_makefile
.PHONY: ${tests_emu}
${tests_emu}: build/test_pass/emu_$$(@F)
build/test_pass/emu_% deploy-screenshots/%.png deploy-screenshots/%-anim.gif: \
${os_filename} \
build/checkerboard_800x600.xbm \
utils/gui-wrapper.sh utils/ansi-screenshots/ansi_screenshot.sh utils/ansi-screenshots/to_ansi.sh \
test/%.sh \
build/check_makefile \
| build/test_pass deploy-screenshots
./utils/gui-wrapper.sh 800x600x24 ./test/$*.sh $<
touch build/test_pass/emu_$*
.PHONY: test/noemu
test/noemu: ${tests_noemu:test/%=build/test_pass/noemu_%} build/check_makefile
build/test_pass/noemu_zip: ${os_filename} build/check_makefile
unzip -t ${os_filename}
touch $@
build/test_pass/noemu_sizes: build/os.32k ${os_filename} build/check_makefile
test "$$(utils/file-length.sh -c build/os.32k)" = "$$((32*1024))"
test "$$(utils/file-length.sh -c ${os_filename})" = "$$((1440*1024))"
touch $@
# check that the fat filesystem has the correct contents
build/test_pass/noemu_fat12_contents: ${os_filename} ${dep_bytes_fat12_start} build/check_makefile
mdir -i "$<@@${bytes_fat12_start}" :: | grep -E "^os[[:space:]]+zip[[:space:]]+"
touch $@
.PHONY: test/requiring_sudo
test/requiring_sudo: ${tests_requiring_sudo:test/%=build/test_pass/sudo_%} build/check_makefile
# check that the fat filesystem can be mounted and has the correct contents
build/test_pass/sudo_fat12_mount: ${os_filename} ${dep_bytes_fat12_start} build/check_makefile | build/mnt_fat12
sudo umount build/mnt_fat12 || true
sudo mount -o loop,ro,offset=${bytes_fat12_start} $< build/mnt_fat12
ls -l build/mnt_fat12 | grep os.zip
sudo umount build/mnt_fat12
touch $@
build/test_pass/sudo_iso_mount: ${os_filename} build/check_makefile | build/mnt_iso
sudo umount build/mnt_iso || true
grep '^' build/offsets/* # debug failure to mount the ISO9660 filesystem
(sudo mount -o loop,ro $< build/mnt_iso) || true
dmesg | tail # debug failure to mount the ISO9660 filesystem
hexdump -C os.bat
ls -l build/mnt_iso | grep os.zip
sudo umount build/mnt_iso
sudo mount -o loop,ro $< build/mnt_iso
sudo umount build/mnt_iso
touch $@
.PHONY: test/macos
test/macos: all test/noemu test/macos-sh test/macos-sh-x11
.PHONY: test/macos-sh-x11
test/macos-sh-x11:
sudo mkdir -p /tmp/.X11-unix
sudo chmod a+rwxt /tmp/.X11-unix
xvfb :42 & \
sleep 5; \
DISPLAY=:42 xterm -e ./os.bat & \
sleep 5; \
# DISPLAY=:42 import -window root deploy-screenshots/macos-sh-x11.png
screencapture deploy-screenshots/macos-sh-x11-screencapture.png
.PHONY: test/macos-sh
test/macos-sh: build/check_makefile \
build/checkerboard_1024x768.png \
| deploy-screenshots
osascript -e 'tell app "Terminal" to do script "'"$$PWD"'/os.bat"'
sleep 2
osascript -e 'tell app "Terminal" to activate'
# DEBUG: ${bld}/os.hex_with_offsets ${bld}/os.offsets.hex
${bld}/test_pass/noemu_reproducible_build: ${os_filename} ${bld}/os.hex_with_offsets ${bld}/check_makefile
# Let some time pass so that any timestamp that may affect the result changes.
sleep 5
(date +%n && sleep 0.2 && date +%n) || true
screencapture deploy-screenshots/screencapture-os-bat.png
./utils/gui-wrapper-mac.sh 1024x768x24 ./test/gui-sh-mac.sh ${os_filename}
# See https://wiki.osdev.org/EFI#Emulation to emulate an UEFI system with qemu, to test the EFI boot from hdd / cd / fd (?).
# Create checkerboard background
build/checkerboard_%.png: build/check_makefile
convert -size "$*" \
tile:pattern:checkerboard \
-auto-level +level-colors 'gray(192),gray(128)' \
$@
build/checkerboard_%.xbm: build/check_makefile
convert -size "$*" \
tile:pattern:checkerboard \
-auto-level \
$@
# Temporary files
build/bochsrc build/bochscontinue build/twm_cfg build/virtualbox.img:
# TODO: try to see if we can re-enable some of these variables without
# causing problems on macos.
unset MAKEFLAGS MAKELEVEL MAKE_TERMERR MFLAGS; \
make OS_FILENAME=${reproducible_os_filename} \
BUILD_DIR=${bld}/reproducible \
SCREENSHOTS_DIR=${bld}/reproducible/screenshots \
COMMIT_TIMESTAMP_ISO_8601=${real_commit_timestamp_iso_8601} \
clean
unset MAKEFLAGS MAKELEVEL MAKE_TERMERR MFLAGS; \
make OS_FILENAME=${reproducible_os_filename} \
BUILD_DIR=${bld}/reproducible \
SCREENSHOTS_DIR=${bld}/reproducible/screenshots \
COMMIT_TIMESTAMP_ISO_8601=${real_commit_timestamp_iso_8601} \
${reproducible_os_filename} \
${bld}/reproducible/os.hex_with_offsets
# Check that the second build produced the same file.
if ! diff ${os_filename} ${reproducible_os_filename}; then \
diff ${bld}/os.hex_with_offsets ${bld}/reproducible/os.hex_with_offsets || true; \
if test "$$(uname -s)" = Darwin -o "$$(uname -o)" = "Cygwin"; then \
for i in `seq 5`; do \
printf '\033[1;31m########################################################\033[m'; \
done; \
echo "REPRODUCIBLE BUILDS ARE UNSUPPORTED ON MACOS AND WINDOWS"; \
for i in `seq 5`; do \
printf '\033[1;31m########################################################\033[m'; \
done; \
else \
exit 1; \
fi; \
fi
unset MAKEFLAGS MAKELEVEL MAKE_TERMERR MFLAGS; \
make OS_FILENAME=${reproducible_os_filename} \
BUILD_DIR=${bld}/reproducible \
SCREENSHOTS_DIR=${bld}/reproducible/screenshots \
COMMIT_TIMESTAMP_ISO_8601=${real_commit_timestamp_iso_8601} \
clean
touch $@

411
Makefile.example-os Normal file
View File

@ -0,0 +1,411 @@
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 \
bytes_iso_end \
bytes_fat12_start \
bytes_fat12_end \
bytes_zip_size \
bytes_zip_start \
bytes_zip_end \
zip_byte_before_gpt \
bytes_gpt_mirror_size \
bytes_gpt_mirror_start \
bytes_gpt_header_mirror_start \
bytes_gpt_mirror_end
more_offset_names = ${offset_names} \
bytes_fat12_size \
bytes_header_32k_size \
bytes_iso_size \
sectors_fat12_size \
sectors_fat12_start \
sectors_gpt_mirror_size \
sectors_iso_size \
sectors_os_size \
sectors_zip_size \
tracks_fat12_size \
tracks_gpt_mirror_size \
tracks_iso_size \
tracks_os_size \
tracks_zip_size
more_offset_dec = ${more_offset_names:%=${bld}/offsets/%.dec}
more_offset_hex = ${more_offset_names:%=${bld}/offsets/%.hex}
# + os.arm.disasm
# + os.reasm.disasm
built_files += ${os_filename} \
${bld}/os.ndisasm.disasm \
${bld}/os.reasm.asm \
${bld}/os.reasm \
${bld}/os.file \
${bld}/os.gdisk \
${bld}/os.zip \
${bld}/os.zip.adjusted \
${bld}/os.iso \
${bld}/os.32k \
${bld}/os.fat12 \
${bld}/os.offsets.hex \
${bld}/os.offsets.dec \
${bld}/os.hex_with_offsets \
${bld}/iso_files/os.zip \
${bld}/iso_files/boot/iso_boot.sys \
${bld}/gpt_guid1 \
${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 \
${bld}/zip_comment \
${more_offset_dec} \
${more_offset_hex} \
# Temporary copies used to adjust timestamps for reproducible builds.
# These are normally created and deleted within a single target, but
# could remain if make is interrupted during the build.
temp_files = ${bld}/iso_files.tmp/os.zip \
${bld}/iso_files.tmp/boot/iso_boot.sys
temp_directories = ${bld}/iso_files.tmp \
${bld}/iso_files.tmp/boot/
built_directories += ${bld}/iso_files/boot \
${bld}/iso_files \
${bld}/offsets
os_image_size_kb = 1440
os_partition_start_sectors = 3
os_partition_size_sectors = 717 # 720 - start
# CHS parameters for 1.44 MB floppy disk
os_floppy_chs_h = 2
os_floppy_chs_s = 9
in-guix: ${os_filename} \
${bld}/os.ndisasm.disasm \
${bld}/os.reasm.asm \
${bld}/os.file \
${bld}/os.gdisk \
${bld}/os.offsets.hex \
${bld}/os.offsets.dec \
${bld}/os.hex_with_offsets \
${more_offset_dec} \
${more_offset_hex} \
${bld}/check_makefile
# 32k header of the ISO9660 image
${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/mformat ./utils/mcopy: ${bld}/check_makefile # TODO: depend on the relevant binary
cp $$(which $$(basename $@)) $@
chmod u+x $@
./utils/mkisofs: ${bld}/check_makefile # TODO: depend on the mkisofs binary
cp $$(which $$(basename $@) || which xorriso) $@
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 ./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} '{}' ';'
UTILS="$$PWD/utils" ./utils/faketime.sh ${real_commit_timestamp_iso_8601} \
sh -c '(cd ./${bld}/iso_files.tmp/ && "$$UTILS/mkisofs" \
--input-charset utf-8 \
-rock \
-joliet \
-eltorito-catalog boot/boot.cat \
-eltorito-boot boot/iso_boot.sys \
-no-emul-boot \
-boot-load-size 4 \
-pad \
-output ../os.iso \
.)'
rm -- ${bld}/iso_files.tmp/os.zip \
${bld}/iso_files.tmp/boot/iso_boot.sys
rmdir ${bld}/iso_files.tmp/boot/
rmdir ${bld}/iso_files.tmp/
# Layout:
# MBR; GPT; UNIX sh & MS-DOS batch scripts; ISO9660; FAT12; GPT mirror; ZIP
define offset
tmp_${1} = ${3}
${bld}/offsets/${1}.dec: $${tmp_${1}:%=${bld}/offsets/%.dec} ${4} ${bld}/check_makefile
echo $$$$(( ${2} )) | tee $$@
${1} = $$$$(cat ${bld}/offsets/${1}.dec)
dep_${1} = ${bld}/offsets/${1}.dec
endef
define div_round_up
( ( ( ${1} ) + ( ${2} ) - 1 ) / ( ${2} ) )
endef
sector_size = 512
# should be exact (TODO: make a check)
${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,}}
${eval ${call offset,tracks_iso_size, ${call div_round_up,$${sectors_iso_size},$${os_floppy_chs_s}}, sectors_iso_size,}}
# round up
${eval ${call offset,bytes_zip_size, $$$$(utils/file-length.sh -c ${bld}/os.zip), ,${bld}/os.zip}}
${eval ${call offset,sectors_zip_size, ${call div_round_up,$${bytes_zip_size},$${sector_size}}, bytes_zip_size,}}
${eval ${call offset,tracks_zip_size, ${call div_round_up,$${sectors_zip_size},$${os_floppy_chs_s}}, sectors_zip_size,}}
# round up
${eval ${call offset,sectors_gpt_mirror_size, 33,, }}
${eval ${call offset,tracks_gpt_mirror_size, ${call div_round_up,$${sectors_gpt_mirror_size},$${os_floppy_chs_s}}, sectors_gpt_mirror_size,}}
# allocate the remaining sectors to the FAT, aligned on tracks
${eval ${call offset,tracks_fat12_size, $${tracks_os_size} - $${tracks_iso_size} - $${tracks_gpt_mirror_size} - $${tracks_zip_size}, tracks_os_size tracks_iso_size tracks_gpt_mirror_size tracks_zip_size,}}
${eval ${call offset,sectors_fat12_size,$${tracks_fat12_size} * $${os_floppy_chs_s}, tracks_fat12_size,}}
# zip should probably have its end aligned, not its start
${eval ${call offset,bytes_zip_start, $${bytes_os_size} - $${bytes_zip_size}, bytes_os_size bytes_zip_size,}}
${eval ${call offset,bytes_mbr_start, 0,,}}
${eval ${call offset,bytes_mbr_end, 512,,}}
${eval ${call offset,bytes_header_32k_start, 0,,}}
${eval ${call offset,bytes_header_32k_end, 32 * 1024,,}}
${eval ${call offset,bytes_header_32k_size, $${bytes_header_32k_end} - $${bytes_header_32k_start}, bytes_header_32k_end bytes_header_32k_start,}}
${eval ${call offset,bytes_iso_start, 32 * 1024,,}}
${eval ${call offset,bytes_iso_end, $${sectors_iso_size} * $${sector_size}, sectors_iso_size,}}
${eval ${call offset,bytes_fat12_start, $${tracks_iso_size} * $${os_floppy_chs_s} * $${sector_size}, tracks_iso_size,}}
${eval ${call offset,sectors_fat12_start, $${bytes_fat12_start} / $${sector_size}, bytes_fat12_start,}}
${eval ${call offset,bytes_fat12_size, $${sectors_fat12_size} * $${sector_size}, sectors_fat12_size,}}
${eval ${call offset,bytes_fat12_end, $${bytes_fat12_start} + $${bytes_fat12_size}, bytes_fat12_start bytes_fat12_size,}}
# 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_os_size}, bytes_os_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,}}
${eval ${call offset,zip_byte_before_gpt, $${bytes_gpt_mirror_start} - 1, bytes_gpt_mirror_start,}}
os_fat12_partition = "$@@@${bytes_fat12_start}"
${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=$@
./utils/faketime.sh ${real_commit_timestamp_iso_8601} ./utils/mformat -v "Example OS" \
-T ${sectors_fat12_size} \
-h ${os_floppy_chs_h} \
-s ${os_floppy_chs_s} \
-i ${os_fat12_partition}
./utils/faketime.sh ${real_commit_timestamp_iso_8601} ./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:
# * the ISO should contain the original file
# * the ZIP should contain the original file
# * the FAT12 should contain the original file
cp $< $@
# 4 sectors loaded when booting from optical media (CD-ROM, …):
${bld}/iso_files/boot/iso_boot.sys: ${bld}/os.32k ${bld}/check_makefile
# TODO: this copy of the (or alternate) bootsector should contain a Boot Information Table,
# see https://wiki.osdev.org/El-Torito#A_BareBones_Boot_Image_with_Boot_Information_Table
dd if=$< bs=512 count=4 of=$@
${bld}/zip_comment: ${dep_bytes_gpt_mirror_size} ${bld}/check_makefile
# Reserve enough space for the secondary GPT.
#
# The X will be replaced by a 0x00 byte after the zip is created and
# adjusted, because the zip utility otherwise truncates the archive
# comment.
#
# It seems that the zip utility injects extra '\r\n' line endings after
# every 256 characters, which changes the total length of the
# comment. We therefore insert a \n directly (zip seems to convert line
# endings from Unix \n to DOS \r\n), and aim for the exact desired size.
(printf "%sX\n" '${os_name}'; \
for i in $$(seq $$((${sectors_gpt_mirror_size} * 2))); do \
printf "%254s\n" ''; \
done) > $@
${bld}/os.zip: ${bld}/os.32k ${bld}/zip_comment ${bld}/check_makefile
# We copy os.32k and alter its timestamp to ensure reproducible
# builds.
mkdir -p ${bld}/os.32k.tmp
cp -a $< ${bld}/os.32k.tmp/os.32k
touch -t ${commit_timestamp} ${bld}/os.32k.tmp/os.32k
# If there is already an archive present from a previous build, zip
# risks trying to update it, so we have to delete it if it exists.
rm -f $@
(cd ${bld}/os.32k.tmp/ && zip -X --archive-comment ../os.zip os.32k < ../zip_comment)
rm ${bld}/os.32k.tmp/os.32k
rmdir ${bld}/os.32k.tmp
${bld}/os.zip.adjusted: ${bld}/os.zip ${dep_bytes_zip_start} ${dep_zip_byte_before_gpt} ${bld}/check_makefile
set -x; dd if=/dev/zero bs=1 count=${bytes_zip_start} of=$@
cat $< >> $@
zip --adjust-sfx $@
# Mark the end of the real ZIP comment, so that the rest is not printed.
# The rest of the comment contains the GPT mirror.
set -x; dd if=/dev/zero bs=1 count=1 conv=notrunc seek=${zip_byte_before_gpt} of=$@
gdisk_pipe_commands_slowly=while read str; do echo "$$str"; printf "\033[1;33m%s\033[m\n" "$$str" >&2; sleep 0.01; done
# 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:]' \
> $@
gpt_disk_guid=${bld}/gpt_guid1
gpt_partition_guid=${bld}/gpt_guid2
${bld}/os_with_guid_0: ${bld}/os.32k ${bld}/os.iso ${bld}/os.fat12 ${bld}/os.zip.adjusted \
${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
rm -f $@
# start with the .iso
cp ${bld}/os.iso $@
# splice in the first 32k (bootsector and partition table)
set -x; dd skip=${bytes_header_32k_start} seek=${bytes_header_32k_start} bs=1 count=${bytes_header_32k_size} conv=notrunc if=${bld}/os.32k of=$@
# splice in fat12
set -x; dd skip=${bytes_fat12_start} seek=${bytes_fat12_start} bs=1 count=${bytes_fat12_size} conv=notrunc if=${bld}/os.fat12 of=$@
# 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=$@
# patch the partition table
# Thanks to https://wiki.gentoo.org/wiki/Hybrid_partition_table for showing that gdisk can be used to make a hybrid MBR / GPT.
# gdisk commands:
# * Delete (the only) partition, eXpert mode, sector aLignment = 1, back to Main menu,
# * New partition (number = 1, start sector, end sector, type 0700)
# * Recovery and transformation options, make Hybrid,
# * add GPT partition #1 to the hybrid MBR, do Not put the EFI partition first,
# * MBR partition type=0x01, bootable=Yes, do Not add extra partitions,
# * back to Main menu,
# * 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 "d\nx\nl\n1\nm\n"; \
printf "n\n1\n${sectors_fat12_start}\n${sectors_fat12_size}\n0700\n"; \
printf "r\nh\n"; \
printf "1\nN\n"; \
printf "01\nY\nN\n"; \
printf "x\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
# line length (8192 excluding CR+LF). $i below is the partition entry number, starting from 1
# The numbers 55 and 118 are arbitrarily chosen so that the space between two CR+LF is less than 8192.
for i in 55 118; do \
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
%.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 \
${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=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}/check_makefile
cp -f $< $@
chmod a+x-w $@
${bld}/os.file: ${os_filename} ${bld}/check_makefile
file -kr $< > $@
${bld}/os.gdisk: ${os_filename} ${bld}/check_makefile
# gdisk commands:
# * eXpert mode
# * Print partition table
#  * print detailed Information about the (only) partition
# * print prOtective MBR table
# * Quit
printf '2\nx\np\ni\nr\no\nq\n' | ${gdisk_pipe_commands_slowly} | gdisk $< | tee $@
${bld}/os.offsets.hex: ${offset_names:%=${bld}/offsets/%.hex} ${bld}/check_makefile
grep '^' ${offset_names:%=${bld}/offsets/%.hex} | sed -e 's|^.*/||' -e 's/:/: 0x/' | column -t > $@
${bld}/os.offsets.dec: ${offset_names:%=${bld}/offsets/%.dec} ${bld}/check_makefile
grep '^' ${offset_names:%=${bld}/offsets/%.dec} | sed -e 's|^.*/||' -e 's/:/: /' | column -t > $@
${bld}/offsets/%.hex: ${bld}/offsets/%.dec
printf '%x\n' $$(cat $<) > $@
${bld}/os.hex_with_offsets: ${os_filename} ${bld}/os.offsets.hex
hexdump -C $< \
| grep -E -e "($$(cat ${bld}/os.offsets.hex | cut -d '=' -f 2 | sed -e 's/^[[:space:]]*0x\(.*\).$$/^\10/' | tr '\n' '|')^)" --color=yes > $@
${bld}/os.ndisasm.disasm: ${os_filename} utils/compact-ndisasm.sh ${bld}/check_makefile
./utils/compact-ndisasm.sh $< $@
${bld}/os.reasm.asm: ${bld}/os.ndisasm.disasm ${bld}/check_makefile
sed -e 's/^[^ ]\+ \+[^ ]\+ \+//' $< > $@

159
Makefile.test-example-os Normal file
View File

@ -0,0 +1,159 @@
built_files += ${bld}/checkerboard_800x600.xbm \
${bld}/checkerboard_1024x768.png \
${bld}/bochsrc \
${bld}/bochscontinue \
${bld}/twm_cfg \
${bld}/virtualbox.img \
${tests_emu:test/%=${bld}/test_pass/emu_%} \
${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} \
utils/mformat utils/mcopy utils/mkisofs
built_directories += ${bld}/mnt_fat12 \
${bld}/mnt_iso \
${bld}/test_pass \
${screenshots}
${bld}/test_pass/noemu_%.reasm ${bld}/%.reasm: ${bld}/%.reasm.asm ${os_filename} utils/compact-ndisasm.sh ${bld}/check_makefile
# For now ignore this test, since we cannot have a reliable re-assembly of arbitrary data.
touch ${bld}/test_pass/noemu_$*.reasm ${bld}/$*.reasm
# nasm $< -o $@
# @echo "diff $@ ${os_filename}"
# @diff $@ ${os_filename} \
# && echo "Re-assembled file is identical to ${os_filename}" \
# || (./utils/compact-ndisasm.sh $@ ${bld}/os.reasm.disasm; \
# echo "Re-assembled file is different from ${os_filename}. Use meld ${bld}/os.ndisasm.disasm ${bld}/os.reasm.disasm to see differences."; \
# exit 0)
#os.arm.disasm: ${os_filename} ${bld}/check_makefile
# arm-none-eabi-objdump --endian=little -marm -b binary -D --adjust-vma=0x8000 $< > $@
.PHONY: test
test: ${tests_emu:test/%=${bld}/test_pass/emu_%} \
${tests_noemu:test/%=${bld}/test_pass/noemu_%} \
${tests_requiring_sudo:test/%=${bld}/test_pass/sudo_%} \
${bld}/check_makefile
.PHONY: test/emu test/noemu test/requiring_sudo
test/emu: ${tests_emu} ${bld}/check_makefile
test/requiring_sudo: ${tests_requiring_sudo} ${bld}/check_makefile
test/noemu: ${tests_noemu} ${bld}/check_makefile
.PHONY: ${tests_emu} ${tests_noemu} ${tests_requiring_sudo}
${tests_emu}: ${bld}/test_pass/emu_$$(@F) ${bld}/check_makefile
${tests_noemu}: ${bld}/test_pass/noemu_$$(@F) ${bld}/check_makefile
${tests_requiring_sudo}: ${bld}/test_pass/sudo_$$(@F) ${bld}/check_makefile
${bld}/test_pass/emu_% ${screenshots}/%.png ${screenshots}/%-anim.gif: \
${os_filename} \
${bld}/checkerboard_800x600.xbm \
utils/gui-wrapper.sh utils/ansi-screenshots/ansi_screenshot.sh utils/ansi-screenshots/to_ansi.sh \
test/%.sh \
${bld}/check_makefile \
| ${bld}/test_pass ${screenshots}
./utils/gui-wrapper.sh 800x600x24 ./test/$*.sh $<
touch ${bld}/test_pass/emu_$*
${bld}/test_pass/noemu_zip: ${os_filename} ${bld}/check_makefile
unzip -t ${os_filename}
touch $@
${bld}/test_pass/noemu_sizes: ${bld}/os.32k ${os_filename} ${bld}/check_makefile
test "$$(utils/file-length.sh -c ${bld}/os.32k)" = "$$((32*1024))"
test "$$(utils/file-length.sh -c ${os_filename})" = "$$((1440*1024))"
touch $@
# check that the fat filesystem has the correct contents
${bld}/test_pass/noemu_fat12_contents: ${os_filename} ${dep_bytes_fat12_start} ${bld}/check_makefile
mdir -i "$<@@${bytes_fat12_start}" :: | grep -E "^os[[:space:]]+zip[[:space:]]+"
touch $@
.PHONY: test/requiring_sudo
test/requiring_sudo: ${tests_requiring_sudo:test/%=${bld}/test_pass/sudo_%} ${bld}/check_makefile
# check that the fat filesystem can be mounted and has the correct contents
${bld}/test_pass/sudo_fat12_mount: ${os_filename} ${dep_bytes_fat12_start} ${bld}/check_makefile | ${bld}/mnt_fat12
sudo umount ${bld}/mnt_fat12 || true
# debug failure to mount the FAT12 filesystem
(set -x ;\
grep '^' ${bld}/offsets/* ;\
(sudo mount -o loop,ro,offset=${bytes_fat12_start} $< ${bld}/mnt_fat12) || true ;\
dmesg | tail ;\
ls -l ${bld}/mnt_fat12 | (grep os.zip || true) ;\
sudo umount ${bld}/mnt_fat12 || true ;\
sleep 10 ;\
cat ${os_filename} | xz | base64 ;\
(sudo mount -o loop,ro,offset=${bytes_fat12_start} $< ${bld}/mnt_fat12) || true ;\
sudo umount ${bld}/mnt_fat12 || true ;\
) > debug-fat12.log 2>&1
cat debug-fat12.log
sudo mount -o loop,ro,offset=${bytes_fat12_start} $< ${bld}/mnt_fat12
ls -l ${bld}/mnt_fat12 | grep os.zip
sudo umount ${bld}/mnt_fat12
touch $@
${bld}/test_pass/sudo_iso_mount: ${os_filename} ${bld}/check_makefile | ${bld}/mnt_iso
sudo umount ${bld}/mnt_iso || true
# debug failure to mount the ISO9660 filesystem
(set -x ;\
grep '^' ${bld}/offsets/* ;\
(sudo mount -o loop,ro $< ${bld}/mnt_iso) || true ;\
dmesg | tail ;\
cat ${os_filename} | xz | base64 ;\
ls -l ${bld}/mnt_iso | grep os.zip ;\
sudo umount ${bld}/mnt_iso || true ;\
sleep 11 ;\
(sudo mount -o loop,ro $< ${bld}/mnt_iso) || true ;\
sudo umount ${bld}/mnt_iso || true ;\
) > debug-iso.log 2>&1
cat debug-iso.log
sudo mount -o loop,ro $< ${bld}/mnt_iso
sudo umount ${bld}/mnt_iso
touch $@
.PHONY: test/macos
test/macos: all test/noemu test/macos-sh test/macos-sh-x11
.PHONY: test/macos-sh-x11
test/macos-sh-x11:
sudo mkdir -p /tmp/.X11-unix
sudo chmod a+rwxt /tmp/.X11-unix
xvfb :42 & \
sleep 5; \
DISPLAY=:42 xterm -e ./${os_filename} & \
sleep 5; \
# DISPLAY=:42 import -window root ${screenshots}/macos-sh-x11.png
screencapture ${screenshots}/macos-sh-x11-screencapture.png
.PHONY: test/macos-sh
test/macos-sh: ${bld}/check_makefile \
${bld}/checkerboard_1024x768.png \
| ${screenshots}
osascript -e 'tell app "Terminal" to do script "'"$$PWD"'/${os_filename}"'
sleep 2
osascript -e 'tell app "Terminal" to activate'
sleep 5
(date +%n && sleep 0.2 && date +%n) || true
screencapture ${screenshots}/screencapture-os-bat.png
./utils/gui-wrapper-mac.sh 1024x768x24 ./test/gui-sh-mac.sh ${os_filename}
# See https://wiki.osdev.org/EFI#Emulation to emulate an UEFI system with qemu, to test the EFI boot from hdd / cd / fd (?).
# Create checkerboard background
${bld}/checkerboard_%.png: ${bld}/check_makefile
convert -size "$*" \
tile:pattern:checkerboard \
-auto-level +level-colors 'gray(192),gray(128)' \
$@
${bld}/checkerboard_%.xbm: ${bld}/check_makefile
convert -size "$*" \
tile:pattern:checkerboard \
-auto-level \
$@
# Temporary files
${bld}/bochsrc ${bld}/bochscontinue ${bld}/twm_cfg ${bld}/virtualbox.img: ${bld}/check_makefile
touch $@

View File

@ -1,5 +1,7 @@
# Travis test harness for hobby operating systems
The guix.scm file is a build recipe for os-test-framework, for the Guix package manager. This file is released under the GNU GPL version 3 or later, because it calls other recipies and library functions which are under the GPL. Other files (with the exception of `guix.scm-gpl-license` and `LICENSE.txt`) are released using the CC0 public domain dedication.
This Travis configuration runs an operating system in various emulators. It can execute a SikuliX test script to ensure that some elements are visible on-screen, send keystrokes and mouse events, and interact with the OS GUI in an automated way. Finally, it will take screenshots of the operating system, and upload them to a separate repository hosting these artifacts.
Below are screenshots of an example operating system. This example merely displays a gradient and does not process any user input.

View File

@ -1,7 +1,5 @@
max_jobs: 1
# Are both necessary?
shallow_clone: true
clone_depth: 1
image: Visual Studio 2015
@ -24,7 +22,7 @@ install:
- cmd: cd ..
- cmd: set PATH=%cd%\gdisk\;%PATH%
# mkisofs,zip,ImageMagick
- cmd: C:\cygwin\setup-x86.exe --no-replaceonreboot --no-shortcuts --quiet-mode --root c:\cygwin --packages mkisofs,genisoimage,zip,ImageMagick,xorg-server-extra
- cmd: C:\cygwin\setup-x86.exe --no-replaceonreboot --no-shortcuts --quiet-mode --root c:\cygwin --packages mkisofs,genisoimage,zip,ImageMagick,xorg-server-extra,datefudge
- cmd: C:\cygwin\bin\find C:\cygwin -iname "import*"
- cmd: C:\cygwin\bin\find C:\cygwin -iname "convert*"
# mtools
@ -57,7 +55,7 @@ install:
- cmd: echo TODO install gnu make and dependencies
build_script:
- cmd: make all
- cmd: make COMMIT_TIMESTAMP_ISO_8601="%APPVEYOR_REPO_COMMIT_TIMESTAMP%" all
test_script:
- cmd: cmd /C os.bat exit

128
guix.scm Normal file
View File

@ -0,0 +1,128 @@
;;; This file is a recipie for building os-test-framework as a Guix package.
;;;
;;; This recipe is free software; you can redistribute it and/or
;;; modify it under the terms of the GNU General Public License as
;;; published by the Free Software Foundation; either version 3 of the
;;; License, or (at your option) any later version.
;;;
;;; This recipe is distributed in the hope that it will be useful, but
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;;; General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with this recipe. If not, see <http://www.gnu.org/licenses/>.
;;;
;;; The copy of the GNU General Public License is stored in the
;;; guix.scm-gpl-license file.
(use-modules (guix packages)
;; (guix build gnu-build-system) ;; for the phases?
(guix build-system gnu)
(guix gexp)
(guix)
(guix build utils)
(ice-9 popen)
(ice-9 rdelim)
(gnu packages version-control)
(gnu packages assembly)
(gnu packages base)
(gnu packages mtools)
(gnu packages cdrom)
(gnu packages compression)
(gnu packages disk)
(gnu packages vim)
(gnu packages linux)
(gnu packages perl))
;; For faketime
(use-modules (guix git-download))
(define-public faketime
(package
(name "faketime")
(version "0.9.7")
(build-system gnu-build-system)
(arguments
`(#:phases (modify-phases %standard-phases
(delete 'configure)
(delete 'check))
#:make-flags `("CC=gcc"
,(string-append "PREFIX=" %output))))
(description "LD_PRELOAD hack which allows changing and freezing the system time")
(home-page "https://github.com/wolfcw/libfaketime")
(license "CC0-1.0")
(source
(origin (uri (git-reference
(url "https://github.com/wolfcw/libfaketime.git")
(commit "5c6518c597160109fbe599fb4db9ca91e4a6769c")))
(method git-fetch)
(sha256 (base32 "1cisgkw0c7c9psi1g4ji9y2gqans0mm223rs1xhj1bjah95kgkp9"))))
(synopsis "")))
(define-public os-test-framework
(let ((makefile-commit-timestamp
'(string-append
"COMMIT_TIMESTAMP_ISO_8601="
;; (let* ((pipe (open-input-pipe "git log -1 --pretty=format:%ad --date=iso8601-strict"))
;; (timestamp (read-line pipe)))
;; (close-pipe pipe)
;; timestamp)
"FILE")))
(package
(name "os-test-framework")
(version "0.0")
(build-system gnu-build-system)
(arguments
`(#:phases
(modify-phases %standard-phases
;; unpack ;; this phase is enabled
;; patch-source-shebangs ;; this phase is enabled
(add-after 'patch-source-shebangs 'make-clean
(lambda* (#:key inputs #:allow-other-keys)
(invoke "cp" "COMMIT_TIMESTAMP" "COMMIT_TIMESTAMP.bak")
(invoke "make" "clean" ,makefile-commit-timestamp)
(invoke "cp" "COMMIT_TIMESTAMP.bak" "COMMIT_TIMESTAMP")))
(delete 'configure)
(add-before 'build 'make-.gitignore-writable
(lambda* (#:key inputs #:allow-other-keys)
(invoke "chmod" "+w" ".gitignore")))
;; build ;; this phase is enabled
(delete 'check) ;; disabled for now, will enable it later.
(replace 'install
(lambda* (#:key outputs #:allow-other-keys)
(let ((out (lambda (f) (string-append (assoc-ref outputs "out") f)))) ;; TODO: use path-append or something similar
(invoke "mkdir" "-p" (out "/bin"))
(invoke "cp" "os.bat" (out "/bin/os.bat")))))
(delete 'patch-shebangs)
(delete 'strip))
#:parallel-build? #t
#:make-flags
(list "in-guix" ,makefile-commit-timestamp)))
(native-inputs
`(("git" ,git)
("nasm" ,nasm)
("which" ,which)
("mtools" ,mtools)
("mkisofs" ,xorriso)
("zip" ,zip)
("faketime" ,faketime)
("gdisk" ,gptfdisk)
("xxd" ,xxd)
("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")
(source (let ()
(invoke "sh" "-c"
"git log -1 --pretty=format:%ad --date=iso8601-strict > COMMIT_TIMESTAMP")
(local-file
(current-source-directory)
#:recursive? #t
#:select? (lambda (file stat)
(not (equal? (basename file) ".git"))))))
(synopsis ""))))
os-test-framework

674
guix.scm-gpl-license Normal file
View File

@ -0,0 +1,674 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<http://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<http://www.gnu.org/philosophy/why-not-lgpl.html>.

View File

@ -3,6 +3,7 @@ set -e
if test $# -ne 1 || test "$1" = '-h' -o "$1" = '--help'; then
echo "Usage: $0 operating_system_file"
exit 1
fi
os_filename="$1"

View File

@ -3,6 +3,7 @@ set -e
if test $# -ne 1 || test "$1" = '-h' -o "$1" = '--help'; then
echo "Usage: $0 operating_system_file"
exit 1
fi
os_filename="$1"

View File

@ -3,6 +3,7 @@ set -e
if test $# -ne 1 || test "$1" = '-h' -o "$1" = '--help'; then
echo "Usage: $0 operating_system_file"
exit 1
fi
# Force the path to be relative or absolute, but with at least one /
# Otherwise, the command will be searched in the $PATH, instead of using the

View File

@ -3,6 +3,7 @@ set -e
if test $# -ne 1 || test "$1" = '-h' -o "$1" = '--help'; then
echo "Usage: $0 operating_system_file"
exit 1
fi
# Force the path to be relative or absolute, but with at least one /
# Otherwise, the command will be searched in the $PATH, instead of using the

View File

@ -3,6 +3,7 @@ set -e
if test $# -ne 1 || test "$1" = '-h' -o "$1" = '--help'; then
echo "Usage: $0 operating_system_file"
exit 1
fi
os_filename="$1"

View File

@ -3,6 +3,7 @@ set -e
if test $# -ne 1 || test "$1" = '-h' -o "$1" = '--help'; then
echo "Usage: $0 operating_system_file"
exit 1
fi
os_filename="$1"

View File

@ -3,6 +3,7 @@ set -e
if test $# -ne 1 || test "$1" = '-h' -o "$1" = '--help'; then
echo "Usage: $0 operating_system_file"
exit 1
fi
os_filename="$1"

24
utils/faketime.sh Executable file
View File

@ -0,0 +1,24 @@
#!/bin/bash
set -euET -o pipefail
timestamp_iso_8601="$1"
shift
date_command() {
# TODO: substring or case … in Darwin*)
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
}
if which faketime >/dev/null; then
( set -x; faketime -f "$(date_command "${timestamp_iso_8601}" '+%Y-%m-%d %H:%m:%S')" "$@"; )
elif which datefudge >/dev/null; then
( set -x; datefudge --static "${timestamp_iso_8601}" "$@"; )
else
echo "ERROR: command faketime or datefudge not found. Please install either command."
exit 1
fi

View File

@ -5,5 +5,5 @@ set -e
# The sikuli-ide packaged with ubuntu 16.04 does not seem to work correctly: missing dependencies, some dependencies are too recent, …
mkdir ~/sikulix/
wget https://launchpad.net/sikuli/sikulix/1.1.3/+download/sikulixsetup-1.1.3.jar -O ~/sikulix/sikulixsetup-1.1.3.jar
(cd ~/sikulix && java -jar sikulixsetup-1.1.3.jar options 1 1.1)
(cd ~/sikulix && java -jar sikulixsetup-1.1.3.jar options 1 1.1) || (cat ~/sikulix/SikuliX-1.1.3-SetupLog.txt; exit 1)
echo 'export PATH="$HOME/sikulix/:$PATH"'

5
utils/safe-bash.sh Executable file
View File

@ -0,0 +1,5 @@
#!/bin/sh
if test "$#" -gt 1 -a "$1" = "-c"; then shift; fi
bash -euET -o pipefail -c 'trap "kill $$" ERR; '"$1"
exit $?