From b09ab4bdff2cd8eef52d85ef564291e6629e601e Mon Sep 17 00:00:00 2001 From: Alessandro Proto Date: Tue, 11 Apr 2023 13:24:11 +0200 Subject: [PATCH] Moved CapyOS to folder /sys --- .../Assets/Lua/CapyOS/boot/autorun/00_package.lua | 3 --- Capy64/Assets/Lua/CapyOS/init.lua | 12 +++++++----- Capy64/Assets/Lua/CapyOS/{ => sys}/bin/cd.lua | 0 Capy64/Assets/Lua/CapyOS/{ => sys}/bin/clear.lua | 0 Capy64/Assets/Lua/CapyOS/{ => sys}/bin/exit.lua | 0 .../Lua/CapyOS/{ => sys}/bin/fun/mandelbrot.lua | 0 Capy64/Assets/Lua/CapyOS/{ => sys}/bin/fun/melt.lua | 0 Capy64/Assets/Lua/CapyOS/{ => sys}/bin/hello.lua | 0 Capy64/Assets/Lua/CapyOS/{ => sys}/bin/ls.lua | 0 Capy64/Assets/Lua/CapyOS/{ => sys}/bin/lua.lua | 0 Capy64/Assets/Lua/CapyOS/{ => sys}/bin/mkdir.lua | 0 Capy64/Assets/Lua/CapyOS/{ => sys}/bin/pwd.lua | 0 Capy64/Assets/Lua/CapyOS/{ => sys}/bin/reboot.lua | 0 Capy64/Assets/Lua/CapyOS/{ => sys}/bin/rm.lua | 0 Capy64/Assets/Lua/CapyOS/{ => sys}/bin/shell.lua | 2 +- Capy64/Assets/Lua/CapyOS/{ => sys}/bin/shutdown.lua | 0 Capy64/Assets/Lua/CapyOS/{ => sys}/bin/version.lua | 0 Capy64/Assets/Lua/CapyOS/{ => sys}/bin/wget.lua | 0 .../Lua/CapyOS/sys/boot/autorun/00_package.lua | 3 +++ .../Lua/CapyOS/{ => sys}/boot/autorun/01_event.lua | 0 .../Lua/CapyOS/{ => sys}/boot/autorun/01_stdio.lua | 0 .../Lua/CapyOS/{ => sys}/boot/autorun/02_http.lua | 0 .../Lua/CapyOS/{ => sys}/boot/autorun/02_timer.lua | 0 .../Lua/CapyOS/{ => sys}/boot/autorun/99_shell.lua | 2 +- Capy64/Assets/Lua/CapyOS/{ => sys}/lib/colors.lua | 0 Capy64/Assets/Lua/CapyOS/{ => sys}/lib/expect.lua | 0 Capy64/Assets/Lua/CapyOS/{ => sys}/lib/io.lua | 0 Capy64/Assets/Lua/CapyOS/{ => sys}/lib/json.lua | 0 Capy64/Assets/Lua/CapyOS/{ => sys}/lib/keys.lua | 0 Capy64/Assets/Lua/CapyOS/{ => sys}/lib/parallel.lua | 0 .../Assets/Lua/CapyOS/{ => sys}/lib/utfstring.lua | 0 Capy64/Assets/Lua/CapyOS/{boot => sys}/vendor.bmp | Bin Capy64/Assets/Lua/bios.lua | 11 ++++++++--- 33 files changed, 20 insertions(+), 13 deletions(-) delete mode 100644 Capy64/Assets/Lua/CapyOS/boot/autorun/00_package.lua rename Capy64/Assets/Lua/CapyOS/{ => sys}/bin/cd.lua (100%) rename Capy64/Assets/Lua/CapyOS/{ => sys}/bin/clear.lua (100%) rename Capy64/Assets/Lua/CapyOS/{ => sys}/bin/exit.lua (100%) rename Capy64/Assets/Lua/CapyOS/{ => sys}/bin/fun/mandelbrot.lua (100%) rename Capy64/Assets/Lua/CapyOS/{ => sys}/bin/fun/melt.lua (100%) rename Capy64/Assets/Lua/CapyOS/{ => sys}/bin/hello.lua (100%) rename Capy64/Assets/Lua/CapyOS/{ => sys}/bin/ls.lua (100%) rename Capy64/Assets/Lua/CapyOS/{ => sys}/bin/lua.lua (100%) rename Capy64/Assets/Lua/CapyOS/{ => sys}/bin/mkdir.lua (100%) rename Capy64/Assets/Lua/CapyOS/{ => sys}/bin/pwd.lua (100%) rename Capy64/Assets/Lua/CapyOS/{ => sys}/bin/reboot.lua (100%) rename Capy64/Assets/Lua/CapyOS/{ => sys}/bin/rm.lua (100%) rename Capy64/Assets/Lua/CapyOS/{ => sys}/bin/shell.lua (98%) rename Capy64/Assets/Lua/CapyOS/{ => sys}/bin/shutdown.lua (100%) rename Capy64/Assets/Lua/CapyOS/{ => sys}/bin/version.lua (100%) rename Capy64/Assets/Lua/CapyOS/{ => sys}/bin/wget.lua (100%) create mode 100644 Capy64/Assets/Lua/CapyOS/sys/boot/autorun/00_package.lua rename Capy64/Assets/Lua/CapyOS/{ => sys}/boot/autorun/01_event.lua (100%) rename Capy64/Assets/Lua/CapyOS/{ => sys}/boot/autorun/01_stdio.lua (100%) rename Capy64/Assets/Lua/CapyOS/{ => sys}/boot/autorun/02_http.lua (100%) rename Capy64/Assets/Lua/CapyOS/{ => sys}/boot/autorun/02_timer.lua (100%) rename Capy64/Assets/Lua/CapyOS/{ => sys}/boot/autorun/99_shell.lua (89%) rename Capy64/Assets/Lua/CapyOS/{ => sys}/lib/colors.lua (100%) rename Capy64/Assets/Lua/CapyOS/{ => sys}/lib/expect.lua (100%) rename Capy64/Assets/Lua/CapyOS/{ => sys}/lib/io.lua (100%) rename Capy64/Assets/Lua/CapyOS/{ => sys}/lib/json.lua (100%) rename Capy64/Assets/Lua/CapyOS/{ => sys}/lib/keys.lua (100%) rename Capy64/Assets/Lua/CapyOS/{ => sys}/lib/parallel.lua (100%) rename Capy64/Assets/Lua/CapyOS/{ => sys}/lib/utfstring.lua (100%) rename Capy64/Assets/Lua/CapyOS/{boot => sys}/vendor.bmp (100%) diff --git a/Capy64/Assets/Lua/CapyOS/boot/autorun/00_package.lua b/Capy64/Assets/Lua/CapyOS/boot/autorun/00_package.lua deleted file mode 100644 index 2cc7dd8..0000000 --- a/Capy64/Assets/Lua/CapyOS/boot/autorun/00_package.lua +++ /dev/null @@ -1,3 +0,0 @@ -package.path = "/lib/?.lua;/lib/?/init.lua;" .. package.path - -_G.io = require("io") diff --git a/Capy64/Assets/Lua/CapyOS/init.lua b/Capy64/Assets/Lua/CapyOS/init.lua index c25bb13..ae90150 100644 --- a/Capy64/Assets/Lua/CapyOS/init.lua +++ b/Capy64/Assets/Lua/CapyOS/init.lua @@ -1,10 +1,11 @@ -local version = "0.0.2" +local version = "0.0.3" +local systemDirectory = "/sys" print("Starting CapyOS") local term = require("term") local fs = require("fs") -local gpu = require("gpu") +local machine = require("machine") local nPrint = print local function showError(err) @@ -26,11 +27,12 @@ function os.version() end term.setPos(1, 1) -term.write(_HOST) +term.write(machine.version()) +term.setPos(1, 3) -local files = fs.list("/boot/autorun") +local files = fs.list(fs.combine(systemDirectory, "boot/autorun")) for i = 1, #files do - local func, err = loadfile("/boot/autorun/" .. files[i]) + local func, err = loadfile(fs.combine(systemDirectory, "boot/autorun", files[i])) if not func then showError(err) break diff --git a/Capy64/Assets/Lua/CapyOS/bin/cd.lua b/Capy64/Assets/Lua/CapyOS/sys/bin/cd.lua similarity index 100% rename from Capy64/Assets/Lua/CapyOS/bin/cd.lua rename to Capy64/Assets/Lua/CapyOS/sys/bin/cd.lua diff --git a/Capy64/Assets/Lua/CapyOS/bin/clear.lua b/Capy64/Assets/Lua/CapyOS/sys/bin/clear.lua similarity index 100% rename from Capy64/Assets/Lua/CapyOS/bin/clear.lua rename to Capy64/Assets/Lua/CapyOS/sys/bin/clear.lua diff --git a/Capy64/Assets/Lua/CapyOS/bin/exit.lua b/Capy64/Assets/Lua/CapyOS/sys/bin/exit.lua similarity index 100% rename from Capy64/Assets/Lua/CapyOS/bin/exit.lua rename to Capy64/Assets/Lua/CapyOS/sys/bin/exit.lua diff --git a/Capy64/Assets/Lua/CapyOS/bin/fun/mandelbrot.lua b/Capy64/Assets/Lua/CapyOS/sys/bin/fun/mandelbrot.lua similarity index 100% rename from Capy64/Assets/Lua/CapyOS/bin/fun/mandelbrot.lua rename to Capy64/Assets/Lua/CapyOS/sys/bin/fun/mandelbrot.lua diff --git a/Capy64/Assets/Lua/CapyOS/bin/fun/melt.lua b/Capy64/Assets/Lua/CapyOS/sys/bin/fun/melt.lua similarity index 100% rename from Capy64/Assets/Lua/CapyOS/bin/fun/melt.lua rename to Capy64/Assets/Lua/CapyOS/sys/bin/fun/melt.lua diff --git a/Capy64/Assets/Lua/CapyOS/bin/hello.lua b/Capy64/Assets/Lua/CapyOS/sys/bin/hello.lua similarity index 100% rename from Capy64/Assets/Lua/CapyOS/bin/hello.lua rename to Capy64/Assets/Lua/CapyOS/sys/bin/hello.lua diff --git a/Capy64/Assets/Lua/CapyOS/bin/ls.lua b/Capy64/Assets/Lua/CapyOS/sys/bin/ls.lua similarity index 100% rename from Capy64/Assets/Lua/CapyOS/bin/ls.lua rename to Capy64/Assets/Lua/CapyOS/sys/bin/ls.lua diff --git a/Capy64/Assets/Lua/CapyOS/bin/lua.lua b/Capy64/Assets/Lua/CapyOS/sys/bin/lua.lua similarity index 100% rename from Capy64/Assets/Lua/CapyOS/bin/lua.lua rename to Capy64/Assets/Lua/CapyOS/sys/bin/lua.lua diff --git a/Capy64/Assets/Lua/CapyOS/bin/mkdir.lua b/Capy64/Assets/Lua/CapyOS/sys/bin/mkdir.lua similarity index 100% rename from Capy64/Assets/Lua/CapyOS/bin/mkdir.lua rename to Capy64/Assets/Lua/CapyOS/sys/bin/mkdir.lua diff --git a/Capy64/Assets/Lua/CapyOS/bin/pwd.lua b/Capy64/Assets/Lua/CapyOS/sys/bin/pwd.lua similarity index 100% rename from Capy64/Assets/Lua/CapyOS/bin/pwd.lua rename to Capy64/Assets/Lua/CapyOS/sys/bin/pwd.lua diff --git a/Capy64/Assets/Lua/CapyOS/bin/reboot.lua b/Capy64/Assets/Lua/CapyOS/sys/bin/reboot.lua similarity index 100% rename from Capy64/Assets/Lua/CapyOS/bin/reboot.lua rename to Capy64/Assets/Lua/CapyOS/sys/bin/reboot.lua diff --git a/Capy64/Assets/Lua/CapyOS/bin/rm.lua b/Capy64/Assets/Lua/CapyOS/sys/bin/rm.lua similarity index 100% rename from Capy64/Assets/Lua/CapyOS/bin/rm.lua rename to Capy64/Assets/Lua/CapyOS/sys/bin/rm.lua diff --git a/Capy64/Assets/Lua/CapyOS/bin/shell.lua b/Capy64/Assets/Lua/CapyOS/sys/bin/shell.lua similarity index 98% rename from Capy64/Assets/Lua/CapyOS/bin/shell.lua rename to Capy64/Assets/Lua/CapyOS/sys/bin/shell.lua index 81d2654..21d840a 100644 --- a/Capy64/Assets/Lua/CapyOS/bin/shell.lua +++ b/Capy64/Assets/Lua/CapyOS/sys/bin/shell.lua @@ -6,7 +6,7 @@ local machine = require("machine") local exit = false local shell = {} -shell.path = "./?;./?.lua;/bin/?.lua" +shell.path = "./?;./?.lua;/bin/?.lua;/sys/bin/?.lua" shell.homePath = "/home" local currentDir = shell.homePath diff --git a/Capy64/Assets/Lua/CapyOS/bin/shutdown.lua b/Capy64/Assets/Lua/CapyOS/sys/bin/shutdown.lua similarity index 100% rename from Capy64/Assets/Lua/CapyOS/bin/shutdown.lua rename to Capy64/Assets/Lua/CapyOS/sys/bin/shutdown.lua diff --git a/Capy64/Assets/Lua/CapyOS/bin/version.lua b/Capy64/Assets/Lua/CapyOS/sys/bin/version.lua similarity index 100% rename from Capy64/Assets/Lua/CapyOS/bin/version.lua rename to Capy64/Assets/Lua/CapyOS/sys/bin/version.lua diff --git a/Capy64/Assets/Lua/CapyOS/bin/wget.lua b/Capy64/Assets/Lua/CapyOS/sys/bin/wget.lua similarity index 100% rename from Capy64/Assets/Lua/CapyOS/bin/wget.lua rename to Capy64/Assets/Lua/CapyOS/sys/bin/wget.lua diff --git a/Capy64/Assets/Lua/CapyOS/sys/boot/autorun/00_package.lua b/Capy64/Assets/Lua/CapyOS/sys/boot/autorun/00_package.lua new file mode 100644 index 0000000..542145b --- /dev/null +++ b/Capy64/Assets/Lua/CapyOS/sys/boot/autorun/00_package.lua @@ -0,0 +1,3 @@ +package.path = "/lib/?.lua;/lib/?/init.lua;/sys/lib/?.lua;/sys/lib/?/init.lua;" .. package.path + +_G.io = require("io") diff --git a/Capy64/Assets/Lua/CapyOS/boot/autorun/01_event.lua b/Capy64/Assets/Lua/CapyOS/sys/boot/autorun/01_event.lua similarity index 100% rename from Capy64/Assets/Lua/CapyOS/boot/autorun/01_event.lua rename to Capy64/Assets/Lua/CapyOS/sys/boot/autorun/01_event.lua diff --git a/Capy64/Assets/Lua/CapyOS/boot/autorun/01_stdio.lua b/Capy64/Assets/Lua/CapyOS/sys/boot/autorun/01_stdio.lua similarity index 100% rename from Capy64/Assets/Lua/CapyOS/boot/autorun/01_stdio.lua rename to Capy64/Assets/Lua/CapyOS/sys/boot/autorun/01_stdio.lua diff --git a/Capy64/Assets/Lua/CapyOS/boot/autorun/02_http.lua b/Capy64/Assets/Lua/CapyOS/sys/boot/autorun/02_http.lua similarity index 100% rename from Capy64/Assets/Lua/CapyOS/boot/autorun/02_http.lua rename to Capy64/Assets/Lua/CapyOS/sys/boot/autorun/02_http.lua diff --git a/Capy64/Assets/Lua/CapyOS/boot/autorun/02_timer.lua b/Capy64/Assets/Lua/CapyOS/sys/boot/autorun/02_timer.lua similarity index 100% rename from Capy64/Assets/Lua/CapyOS/boot/autorun/02_timer.lua rename to Capy64/Assets/Lua/CapyOS/sys/boot/autorun/02_timer.lua diff --git a/Capy64/Assets/Lua/CapyOS/boot/autorun/99_shell.lua b/Capy64/Assets/Lua/CapyOS/sys/boot/autorun/99_shell.lua similarity index 89% rename from Capy64/Assets/Lua/CapyOS/boot/autorun/99_shell.lua rename to Capy64/Assets/Lua/CapyOS/sys/boot/autorun/99_shell.lua index 3c5ef7c..d1619ec 100644 --- a/Capy64/Assets/Lua/CapyOS/boot/autorun/99_shell.lua +++ b/Capy64/Assets/Lua/CapyOS/sys/boot/autorun/99_shell.lua @@ -10,6 +10,6 @@ term.setPos(1, 1) term.write(os.version()) term.setPos(1, 2) -dofile("/bin/shell.lua") +dofile("/sys/bin/shell.lua") machine.shutdown() diff --git a/Capy64/Assets/Lua/CapyOS/lib/colors.lua b/Capy64/Assets/Lua/CapyOS/sys/lib/colors.lua similarity index 100% rename from Capy64/Assets/Lua/CapyOS/lib/colors.lua rename to Capy64/Assets/Lua/CapyOS/sys/lib/colors.lua diff --git a/Capy64/Assets/Lua/CapyOS/lib/expect.lua b/Capy64/Assets/Lua/CapyOS/sys/lib/expect.lua similarity index 100% rename from Capy64/Assets/Lua/CapyOS/lib/expect.lua rename to Capy64/Assets/Lua/CapyOS/sys/lib/expect.lua diff --git a/Capy64/Assets/Lua/CapyOS/lib/io.lua b/Capy64/Assets/Lua/CapyOS/sys/lib/io.lua similarity index 100% rename from Capy64/Assets/Lua/CapyOS/lib/io.lua rename to Capy64/Assets/Lua/CapyOS/sys/lib/io.lua diff --git a/Capy64/Assets/Lua/CapyOS/lib/json.lua b/Capy64/Assets/Lua/CapyOS/sys/lib/json.lua similarity index 100% rename from Capy64/Assets/Lua/CapyOS/lib/json.lua rename to Capy64/Assets/Lua/CapyOS/sys/lib/json.lua diff --git a/Capy64/Assets/Lua/CapyOS/lib/keys.lua b/Capy64/Assets/Lua/CapyOS/sys/lib/keys.lua similarity index 100% rename from Capy64/Assets/Lua/CapyOS/lib/keys.lua rename to Capy64/Assets/Lua/CapyOS/sys/lib/keys.lua diff --git a/Capy64/Assets/Lua/CapyOS/lib/parallel.lua b/Capy64/Assets/Lua/CapyOS/sys/lib/parallel.lua similarity index 100% rename from Capy64/Assets/Lua/CapyOS/lib/parallel.lua rename to Capy64/Assets/Lua/CapyOS/sys/lib/parallel.lua diff --git a/Capy64/Assets/Lua/CapyOS/lib/utfstring.lua b/Capy64/Assets/Lua/CapyOS/sys/lib/utfstring.lua similarity index 100% rename from Capy64/Assets/Lua/CapyOS/lib/utfstring.lua rename to Capy64/Assets/Lua/CapyOS/sys/lib/utfstring.lua diff --git a/Capy64/Assets/Lua/CapyOS/boot/vendor.bmp b/Capy64/Assets/Lua/CapyOS/sys/vendor.bmp similarity index 100% rename from Capy64/Assets/Lua/CapyOS/boot/vendor.bmp rename to Capy64/Assets/Lua/CapyOS/sys/vendor.bmp diff --git a/Capy64/Assets/Lua/bios.lua b/Capy64/Assets/Lua/bios.lua index e1bbcb5..8730e6b 100644 --- a/Capy64/Assets/Lua/bios.lua +++ b/Capy64/Assets/Lua/bios.lua @@ -51,13 +51,13 @@ local function writeCenter(text) end local function drawVendorImage() - if not fs.exists("/boot/vendor.bmp") then + if not fs.exists("/sys/vendor.bmp") then return end local w, h = gpu.getSize() local ok, err = pcall(function() - local task = gpu.loadImageAsync("/boot/vendor.bmp") + local task = gpu.loadImageAsync("/sys/vendor.bmp") local buffer = task:await() local x, y = @@ -95,6 +95,11 @@ local function promptKey() event.pull("key_down") end +local function installDefaultOS() + fs.delete("/sys", true) + installOS() +end + term.setBlink(false) local function setupScreen() @@ -105,7 +110,7 @@ local function setupScreen() }, { "Install default OS", - installOS, + installDefaultOS, }, { "Exit setup",