From 2d6f2d5ed8b32cb44de85866c2501683fc090f9b Mon Sep 17 00:00:00 2001 From: Jane Roxanne Date: Thu, 12 Sep 2019 17:20:57 -0500 Subject: [PATCH] All kinds of fun stuff. Fun for translations, too. --- .gitignore | 1 + examples/config-example/example.z2c | 39 +++++++++ src/installerdat/base_modules.xml | 16 ++++ src/installerdat/installers_extra/README.md | 4 + src/installerdat/languages.xml | 4 + src/installerdat/runtimes.xml | 8 ++ src/modules/biosemu/init.lua | 93 +++++++++++++++++++++ src/modules/biosemu/lang.xml | 5 ++ src/modules/biosemu/manifest.ini | 0 src/modules/bootmenu/lang.xml | 8 ++ update/install.lua | 5 ++ utils/mkrelease.lua | 12 ++- utils/sign.sh | 16 ++++ utils/signupdate.lua | 10 +++ 14 files changed, 218 insertions(+), 3 deletions(-) create mode 100644 .gitignore create mode 100644 examples/config-example/example.z2c create mode 100644 src/installerdat/base_modules.xml create mode 100644 src/installerdat/installers_extra/README.md create mode 100644 src/installerdat/languages.xml create mode 100644 src/installerdat/runtimes.xml create mode 100644 src/modules/biosemu/init.lua create mode 100644 src/modules/biosemu/lang.xml create mode 100644 src/modules/biosemu/manifest.ini create mode 100644 src/modules/bootmenu/lang.xml create mode 100644 update/install.lua create mode 100755 utils/sign.sh create mode 100644 utils/signupdate.lua diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..91d24c3 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +zbsign.pem \ No newline at end of file diff --git a/examples/config-example/example.z2c b/examples/config-example/example.z2c new file mode 100644 index 0000000..9dcb610 --- /dev/null +++ b/examples/config-example/example.z2c @@ -0,0 +1,39 @@ +-- MineOS launcher +entry "MineOS" + loadmod "biosemu" + biosload ".zy2/biosemu/mineos.lua" + biosdatload ".zy2/biosemu/mineos.bin" + boot + +-- Emulate Zorya v1 +entry "Zorya v1 Emulation" + loadmod "biosemu" + biosload ".zy2/biosemu/zorya13.lua" + biosdatload ".zy2/biosemu/zorya13.bin" + boot + +-- Boot OpenOS +entry "OpenOS" + loadmod "openos" + openos_kload "c2dfc58a-a895-407e-911e-17cc57ff6e17" + boot + +-- Boot OEFIv2.1 application +entry "OEFI2(c2d): OpenOS.efi2" + loadmod "oefi2" + oefiload "c2dfc58a-a895-407e-911e-17cc57ff6e17" "OpenOS.efi2" + boot + +-- Boot Fuchas NT kernel +entry "Fuchas" + loadmod "fuchas" + fuchas_kload "6e621ed7-97cd-478b-a896-bb7fa42ca8e6" + boot + +-- Boot Tsuki kernel +entry "Tsuki Kernel 1.0" + loadmod "tsuki" + load_initramfs "0c6fa9e1-4e4b-44e7-9b80-4d9dff20b6d5" "/boot/tsuki1.0-init.img" "d9e2e89b-5050-47d5-80f0-59914669e37a" + tsuki_karg "initramfs=d9e2e89b-5050-47d5-80f0-59914669e37a init=/sbin/init.lua bootaddr=0c6fa9e1-4e4b-44e7-9b80-4d9dff20b6d5" + tsuki_kload "0c6fa9e1-4e4b-44e7-9b80-4d9dff20b6d5" "/boot/tsuki1.0.tknl" + boot \ No newline at end of file diff --git a/src/installerdat/base_modules.xml b/src/installerdat/base_modules.xml new file mode 100644 index 0000000..aceb369 --- /dev/null +++ b/src/installerdat/base_modules.xml @@ -0,0 +1,16 @@ + + + + Boot Menu + Boot Menu + Classic Zorya 1.x style boot menu. + Classic Zorya 1.x style boot menu. + + + + Load file + Load file + A module that allows for easy loading of files. + A module that allows for easy loading of files. + + \ No newline at end of file diff --git a/src/installerdat/installers_extra/README.md b/src/installerdat/installers_extra/README.md new file mode 100644 index 0000000..719fd92 --- /dev/null +++ b/src/installerdat/installers_extra/README.md @@ -0,0 +1,4 @@ +# What is this? +This is used for loaders that require extra scripts to run durring the install. + +Currently, no loaders need this folder. But it's still nice to have. \ No newline at end of file diff --git a/src/installerdat/languages.xml b/src/installerdat/languages.xml new file mode 100644 index 0000000..ff7aa00 --- /dev/null +++ b/src/installerdat/languages.xml @@ -0,0 +1,4 @@ + + English (US) + English (UK) + \ No newline at end of file diff --git a/src/installerdat/runtimes.xml b/src/installerdat/runtimes.xml new file mode 100644 index 0000000..1869fb6 --- /dev/null +++ b/src/installerdat/runtimes.xml @@ -0,0 +1,8 @@ + + + EEPROM + EEPROM + Basic EEPROM loader. + Basic EEPROM loader. + + \ No newline at end of file diff --git a/src/modules/biosemu/init.lua b/src/modules/biosemu/init.lua new file mode 100644 index 0000000..9351731 --- /dev/null +++ b/src/modules/biosemu/init.lua @@ -0,0 +1,93 @@ +local border_chars = { + "┌", "─", "┐", "│", "└", "┘" +} +local w, h = envs.gpu.getViewport() +envs.gpu.setBackground(envs.cfg.bgcolor) +envs.gpu.setForeground(envs.cfg.fgcolor) +envs.cls() +--Draw some things +envs.gpu.set((w/2)-5, 1, ) +envs.gpu.set(1, 2, border_chars[1]) +envs.gpu.set(2, 2, border_chars[2]:rep(w-2)) +envs.gpu.set(w, 2, border_chars[3]) +for i=1, h-6 do + envs.gpu.set(1, i+2, border_chars[4]) + envs.gpu.set(w, i+2, border_chars[4]) +end +envs.gpu.set(1, h-3, border_chars[5]) +envs.gpu.set(2, h-3, border_chars[2]:rep(w-2)) +envs.gpu.set(w, h-3, border_chars[6]) +envs.gpu.set(1, h-1, "Use ↑ and ↓ keys to select which entry is highlighted.") +envs.gpu.set(1, h, "Use ENTER to boot the selected entry.") +local stime = computer.uptime() +local autosel = true +local ypos = 1 +local sel = 1 +local function redraw() + envs.gpu.setBackground(envs.cfg.bgcolor) + envs.gpu.setForeground(envs.cfg.fgcolor) + envs.gpu.fill(1, h-2, w, 1, " ") + if (autosel) then + envs.gpu.set(1, h-2, "Automatically booting in "..math.floor(envs.cfg.timeout-(computer.uptime()-stime)).."s.") + end + for i=1, h-6 do + local entry = envs.boot[ypos+i-1] + if not entry then break end + local name = entry[1] + if not name then break end + local short = name:sub(1, w-2) + if (short ~= name) then + short = short:sub(1, #sub-3).."..." + end + if (#short < w-2) then + short = short .. string.rep(" ", w-2-#short) + end + if (sel == ypos+i-1) then + envs.gpu.setBackground(envs.cfg.fgcolor) + envs.gpu.setForeground(envs.cfg.bgcolor) + else + envs.gpu.setBackground(envs.cfg.bgcolor) + envs.gpu.setForeground(envs.cfg.fgcolor) + end + envs.gpu.set(2, i+2, short) + end +end +redraw() +sel = envs.cfg.default +while true do + local sig, _, key, code = computer.pullSignal(0.01) + if (sig == "key_down") then + autosel = false + if (key == 0 and code == 200) then + sel = sel - 1 + if (sel < 1) then + sel = 1 + end + if (sel < ypos) then + ypos = ypos - 1 + end + elseif (key == 0 and code == 208) then + sel = sel + 1 + if (sel > #envs.boot) then + sel = #envs.boot + end + if (sel > ypos+h-7) then + ypos = ypos+1 + end + elseif (key == 13 and code == 28) then + envs.gpu.setBackground(0) + envs.gpu.setForeground(0xFFFFFF) + local hand = envs.boot[sel][2] + table.remove(envs.boot[sel], 1) + table.remove(envs.boot[sel], 1) + envs.hand[hand](table.unpack(envs.boot[sel])) + end + end + if (((computer.uptime()-stime) >= envs.cfg.timeout) and autosel) then + local hand = envs.boot[sel][2] + table.remove(envs.boot[sel], 1) + table.remove(envs.boot[sel], 1) + envs.hand[hand](table.unpack(envs.boot[sel])) + end + redraw() +end diff --git a/src/modules/biosemu/lang.xml b/src/modules/biosemu/lang.xml new file mode 100644 index 0000000..a5dd172 --- /dev/null +++ b/src/modules/biosemu/lang.xml @@ -0,0 +1,5 @@ + + + Zorya BIOS Emulator + + \ No newline at end of file diff --git a/src/modules/biosemu/manifest.ini b/src/modules/biosemu/manifest.ini new file mode 100644 index 0000000..e69de29 diff --git a/src/modules/bootmenu/lang.xml b/src/modules/bootmenu/lang.xml new file mode 100644 index 0000000..8951afc --- /dev/null +++ b/src/modules/bootmenu/lang.xml @@ -0,0 +1,8 @@ + + + Zorya NEO BIOS v2.0 (%iK free) + Automatically booting in %is. + Use ↑ and ↓ keys to select which entry is highlighted. + Use ENTER to boot the selected entry. + + \ No newline at end of file diff --git a/update/install.lua b/update/install.lua new file mode 100644 index 0000000..8eb195d --- /dev/null +++ b/update/install.lua @@ -0,0 +1,5 @@ +local component = component or require("component") +local computer = computer or require("computer") + +local inet = component.proxy(component.list("internet")()) +local \ No newline at end of file diff --git a/utils/mkrelease.lua b/utils/mkrelease.lua index ec89808..7d93d03 100755 --- a/utils/mkrelease.lua +++ b/utils/mkrelease.lua @@ -6,6 +6,7 @@ end os.execute("mkdir -p build/modules") os.execute("mkdir -p build/loaders") os.execute("mkdir -p build/microruntime") +os.execute("mkdir -p build/installerdat") local cwd = os.getenv("PWD") @@ -19,7 +20,7 @@ end print("Building modules...") dir("src/modules", function(entry) print("MOD", entry) - os.execute("utils/mkmod.sh src/modules/"..entry.." build/"..entry) + os.execute("utils/mkmod.sh src/modules/"..entry.." build/modules/"..entry) end) print("Building loaders...") @@ -34,6 +35,11 @@ dir("src/microruntime", function(entry) os.execute("cd src/microruntime/"..entry.."; "..cwd.."/utils/luapreproc.lua init.lua "..cwd.."/build/microruntime/"..entry..".urt>/dev/null") end) +print("Copying installer info...") +os.execute("cp -r src/installerdat/* build/installerdat") + print("Packing...") -os.execute("cd build; find * -depth | cpio -o > ../update.zy2 2>/dev/null") -print("Packaging complete. See update.zy2.") \ No newline at end of file +os.execute("cd build; find * -depth | grep -v .git/ |cpio -o > update.zy2 2>/dev/null") +print("Packaging complete. See build/update.zy2.") + +print("Note: Package should probably be signed! Use utils/signupdate.sh...") \ No newline at end of file diff --git a/utils/sign.sh b/utils/sign.sh new file mode 100755 index 0000000..2c304d6 --- /dev/null +++ b/utils/sign.sh @@ -0,0 +1,16 @@ +#!/bin/bash +for f in src/modules/*; do + if [[ -f "$f/init.lua" ]]; then + echo "Siging $f." + printf "init.lua\x00" > ".tmp_1" + openssl dgst -sha256 -sign zbsign.pem "$f/init.lua" > ".tmp_2" + printf "manifest.ini\x00" > ".tmp_3" + openssl dgst -sha256 -sign zbsign.pem "$f/manifest.ini" > ".tmp_4" + if [[ -f "$f/lang.xml" ]]; then + printf "lang.xml\x00" > ".tmp_5" + openssl dgst -sha256 -sign zbsign.pem "$f/lang.xml" > ".tmp_6" + fi + cat .tmp_* > "$f/sig.bin" + rm .tmp_* + fi +done \ No newline at end of file diff --git a/utils/signupdate.lua b/utils/signupdate.lua new file mode 100644 index 0000000..46ac7c5 --- /dev/null +++ b/utils/signupdate.lua @@ -0,0 +1,10 @@ +local h = io.popen("find build -depth -type f | grep -v sig.bin | grep -v update.zy2", "r") +local sigfile = io.open("build/sig.bin", "wb") +for line in h:lines() do + sigfile:write(line:sub(7).."\0") + local s = io.popen("openssl dgst -sha256 -sign zbsign.pem "..line, "r") + sigfile:write(s:read("*a")) + s:close() +end +sigfile:close() +os.execute("cd build; find * -depth | grep -v update.zy2 | cpio -o > update.zy2") \ No newline at end of file