27 Commits
1.0.2 ... main

Author SHA1 Message Date
LeonMMcoset
51cf60dfc1 Update README.md 2025-09-17 00:28:48 +08:00
LeonMMcoset
a441a62417 Update installer.lua 2025-09-15 01:17:02 +08:00
Leonmmcoset
b1e7f6c8d3 fix(installer): 更新安装器版本至1.0.3 Beta 7
refactor(appgui_demo): 使用安全的事件拉取函数替换os.pullEvent
2025-09-14 22:21:14 +08:00
Leonmmcoset
9f0b5c4156 Merge branch 'main' of https://github.com/CCLeonOS/LeonOS 2025-09-14 21:42:32 +08:00
Leonmmcoset
06458f0283 refactor(installer): 移除冗余的term.at调用
清理了installer.lua中未使用的term.at(1, y).clearLine()调用,该代码在当前上下文中无实际作用且可能引起混淆
2025-09-14 21:42:29 +08:00
LeonMMcoset
b0973e2ad4 Update README.md 2025-09-13 18:00:50 +08:00
LeonMMcoset
5deffe0ef4 Update README.md 2025-09-13 17:55:47 +08:00
LeonMMcoset
770a04eaca Update README.md 2025-09-13 17:54:29 +08:00
LeonMMcoset
93cebf337e Update README.md 2025-09-13 17:52:24 +08:00
LeonMMcoset
03c76ebcd7 Update README.md 2025-09-12 22:29:35 +08:00
LeonMMcoset
13c047c8d4 Delete LICENSE_LEONCORE 2025-09-12 22:26:12 +08:00
LeonMMcoset
b34df6d682 Update LICENSE_BSL 2025-09-12 22:25:28 +08:00
LeonMMcoset
3cb9a007f2 Rename LICENSE_LEONCORE to LICENSE_BSL 2025-09-12 22:25:06 +08:00
LeonMMcoset
ab37382fa8 Create LICENSE_LEONCORE 2025-09-12 22:23:44 +08:00
LeonMMcoset
a5766b5e6a Update README.md 2025-09-12 22:20:56 +08:00
LeonMMcoset
a37d349cd4 Update README.md 2025-09-12 22:20:23 +08:00
LeonMMcoset
16ac26e2bd Update README.md 2025-09-12 22:18:41 +08:00
Leonmmcoset
f9fa18585f refactor(installer): 移除appgui依赖并恢复原生顶部栏实现
- 更新安装器版本至1.0.3 Beta 5
- 移除对appgui模块的依赖
- 恢复使用原生term API实现顶部标题栏
- 清理被注释的冗余代码
2025-09-12 17:33:01 +08:00
Leonmmcoset
1927d1222d refactor(installer): 使用appgui重构顶部栏并更新版本号
移除手动实现的顶部栏代码,改用appgui模块统一处理
更新安装器版本号为1.0.3 Beta 4
2025-09-12 17:27:19 +08:00
Leonmmcoset
bf396ef4ba fix(installer): 更新安装程序版本并添加必要的模块导入
添加了term、colors和rc模块的导入,并将安装程序版本更新至1.0.3 Beta 3
2025-09-12 17:23:10 +08:00
Leonmmcoset
adb57f5ee8 refactor: 移除未使用的appgui模块导入
清理未使用的代码依赖,减少不必要的模块加载以提高性能
2025-09-12 17:20:31 +08:00
Leonmmcoset
81297b724f refactor(installer): 移除appgui.topbar调用并恢复原始标题栏实现
恢复使用原生term API实现标题栏显示,移除对appgui.topbar的依赖,保持界面风格一致性
2025-09-12 17:14:24 +08:00
Leonmmcoset
50f8f989c7 Merge branch 'main' of https://github.com/CCLeonOS/LeonOS 2025-09-12 17:10:47 +08:00
Leonmmcoset
0bb365cadb feat(appgui): 添加应用GUI界面支持及包类型管理
新增appgui API用于绘制顶部和底部状态栏,提供一致的UI界面
在package.json中添加type字段区分应用和API包类型
更新安装程序以使用新的appgui界面
修改pkg程序以支持根据包类型安装到不同目录
添加appgui使用文档和演示程序
2025-09-12 17:10:44 +08:00
LeonMMcoset
98a108f1f6 Update README.md 2025-09-11 17:56:43 +08:00
Leonmmcoset
429b98ab00 fix: 更新仓库地址及版本号至1.0.3
将仓库地址从Leonmmcoset/LeonOS更新为CCLeonOS/LeonOS,并升级系统版本号至1.0.3。同时更新了安装器版本号为1.0.3 Beta 1。
2025-09-09 20:03:32 +08:00
Leonmmcoset
e60b50b9e1 style(lua): 修改REPL提示符从'>>>'变为'#'以简化界面 2025-09-09 19:58:28 +08:00
12 changed files with 390 additions and 24 deletions

15
LICENSE_BSL Normal file
View File

@@ -0,0 +1,15 @@
BLC Certificate
Copyright © LeonOS Organization. All rights reserved.
The full name of the BLC Certificate is "Build with LeonCore".
Permission is hereby granted, free of charge, to any person obtaining a copy of the operating system with the BLC Certificate, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the operating system; when using or modifying the operating system with the BLC Certificate, you may keep the operating system closed-source, but shall indicate this agreement on the system information page; you must indicate "Powered by LeonCore" at startup or in other relevant locations of the operating system; you may use the operating system for commercial profit, but for commercialized versions of the operating system, you shall report the profit situation to LeonCore via GitHub Issues; you may open-source the operating system under any open-source license other than the BLC License; this agreement shall only apply to the open-source projects of LeonCore.
Any contributor who submits code, documents, or other contributions to the LeonCore open-source project hereby grants the LeonOS Organization the right to use, modify, and redistribute such contributions, and the submitted content must comply with the terms of this agreement. The contributor shall ensure that the submitted content is free of copyright disputes and does not infringe the legitimate rights and interests of third parties; otherwise, the contributor shall bear full responsibility for any consequences arising therefrom.
This version of the BLC Agreement is Version 1.0. The LeonOS Organization reserves the right to revise this agreement, and the revised agreement shall be published through the official GitHub repository of the LeonCore project. After the revised agreement takes effect, any act of using or modifying the operating system shall comply with the latest version of the agreement.
THE OPERATING SYSTEM WITH THE BLC CERTIFICATE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE OPERATING SYSTEM OR THE USE OR OTHER DEALINGS IN THE OPERATING SYSTEM.

View File

@@ -1,6 +1,35 @@
![logo](https://socialify.git.ci/ccleonos/leonos/image?description=1&font=JetBrains+Mono&forks=1&issues=1&language=1&name=1&owner=1&pattern=Circuit+Board&pulls=1&stargazers=1&theme=Light)
# LeonOS
Use
```shell
wget run https://gh.catmak.name/https://raw.githubusercontent.com/Leonmmcoset/LeonOS/refs/heads/main/installer.lua
wget run https://gh.catmak.name/https://raw.githubusercontent.com/CCLeonOS/LeonOS/refs/heads/main/installer.lua
```
to install the LeonOS system.
> [!NOTE]
> The CatOS program is moved to `ccleonos/catos-installer`.
## How did LeonOS work?
[![](https://mermaid.ink/img/pako:eNq1WO9T00gY_lc6cfwGTSgUSmfuZrQtZ-dkdE79ctZxQhpoJE06STrKqTMgVMvPogeIiAIHHnhzU_HUo0LR_-Wum5RP_Av3bjZJE1qmMtPrlya77_Pus---u--zuU9xcpKnwtSgKN_lUqyi-a5HE5IPfufP-9DLL9WNHeP9AXo9fVxeqT75o1Kaqo7OVErT-qcxY2caDI7L-etR33e-63KmPSrflY7LkwnJ8aCv76FyARVXKp8nwVIvzKPJWbS5qy_PHZdnjI1i5esrfXJUX52sTj0yHn02Ftb0xbzpA3vgRFZVo_ygT5BUjRVFXvENCqIYPhdlYqG-vjZVU-RhPnyu60IvEwu0cbIoK-FzDMOcgCtZSRPSvAWOMX19McYBd0Z6ujujp4P5exqvSKxooTH2YsBBx7p7YgHv0M7sjYUdPb9X2d-q7D8jjTdUXrmZoEgHDkippOcL6HEObS2hzQ944tStcDhsEbaZCNywCfUlqJSmZdQwTQ8JWio74OfkNM1xIi9LskpbfwOiPECnWUGik6zG0mCSycIUOIUd1Ggxy9IDgqz64SFBucii4mR1M3e0_Lde_EQa43bQgTHpxUu-XwDeznpgNw5rp9XN2_FyVvKeMTBVO4C-9vbvHySo6tf56sbMCasHtfFOTMJGze2hwtJPV_rR3LRRfotmchj0g6Bdyg40RqDHL1DuTVayo_bv6BjA9aUnlYO_0dZneM2w3LA_zaV5zWRwWeZYse-aO7ZbS0fjO_rqLJraqJTmjnKzxmGR9JKRIcLkAWKL5tbQ9nT100RlfxuMjcm8vvqnE2M7Gwk6EgdkJE5HomjvTeVwFbZlIzOyEpH4WZfAT6zou7IyjE8IlVZ4kWdV3j-SFu0luSxIGrCoHGwa62P65qi-9gbPcXNOXy9XtydQ_sXplDD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Bcyt6jA4oA6FpBYvBKR4Xihwh3dTMD0QYXvU_eocHtHR5e_KxDs7O4JMcEepjPY2UaNQHsg5O8JdoQCvcHOXqYrGOoJPGyjfjEHDvgDwVCog-kJhoK9THdvCDySgtZPPkCZ36Ee_gdH7zUU)
Chinese version
---
LeonOS's kernal "The LeonCore Open Source Project" which is LeonCore is open source as BLC Certificate
```
BLC Certificate
Copyright © LeonOS Organization. All rights reserved.
The full name of the BLC Certificate is "Build with LeonCore".
Permission is hereby granted, free of charge, to any person obtaining a copy of the operating system with the BLC Certificate, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the operating system; when using or modifying the operating system with the BLC Certificate, you may keep the operating system closed-source, but shall indicate this agreement on the system information page; you must indicate "Powered by LeonCore" at startup or in other relevant locations of the operating system; you may use the operating system for commercial profit, but for commercialized versions of the operating system, you shall report the profit situation to LeonCore via GitHub Issues; you may open-source the operating system under any open-source license other than the BLC License; this agreement shall only apply to the open-source projects of LeonCore.
Any contributor who submits code, documents, or other contributions to the LeonCore open-source project hereby grants the LeonOS Organization the right to use, modify, and redistribute such contributions, and the submitted content must comply with the terms of this agreement. The contributor shall ensure that the submitted content is free of copyright disputes and does not infringe the legitimate rights and interests of third parties; otherwise, the contributor shall bear full responsibility for any consequences arising therefrom.
This version of the BLC Agreement is Version 1.0. The LeonOS Organization reserves the right to revise this agreement, and the revised agreement shall be published through the official GitHub repository of the LeonCore project. After the revised agreement takes effect, any act of using or modifying the operating system shall comply with the latest version of the agreement.
THE OPERATING SYSTEM WITH THE BLC CERTIFICATE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE OPERATING SYSTEM OR THE USE OR OTHER DEALINGS IN THE OPERATING SYSTEM.
```

View File

@@ -1,4 +1,4 @@
_G._HOST = _G._HOST .. " (LeonOS 1.0.2)"
_G._HOST = _G._HOST .. " (LeonOS 1.0.3)"
local fs = rawget(_G, "fs")
_G._RC_ROM_DIR = _RC_ROM_DIR or (...) and fs.exists("/leonos") and "/leonos" or "/rom"
@@ -32,7 +32,7 @@ local rc = {
_VERSION = {
major = 1,
minor = 0,
patch = 2
patch = 3
},
queueEvent = pull(os, "queueEvent"),
startTimer = pull(os, "startTimer"),

View File

@@ -4,6 +4,7 @@
"description": "An example package for LeonOS",
"author": "LeonMMcoset",
"license": "MIT",
"type": "app",
"dependencies": {},
"files": [
"example.lua"

View File

@@ -0,0 +1,94 @@
-- appgui API for LeonOS
-- Provides simple topbar and downbar drawing functions
local term = require("term")
local colors = require("colors")
local expect = require("cc.expect").expect
local appgui = {}
--- Draws a top bar with the specified text centered
--- @param text string The text to display in the top bar
--- @param fgColor number Optional foreground color (default: white)
--- @param bgColor number Optional background color (default: blue)
function appgui.topbar(text, fgColor, bgColor)
expect(1, text, "string")
expect(2, fgColor, "number", "nil")
expect(3, bgColor, "number", "nil")
-- Default colors
fgColor = fgColor or colors.white
bgColor = bgColor or colors.blue
-- Save current colors
local oldFg = term.getTextColor()
local oldBg = term.getBackgroundColor()
-- Get terminal size
local w, h = term.getSize()
-- Set colors and position
term.setTextColor(fgColor)
term.setBackgroundColor(bgColor)
term.setCursorPos(1, 1)
-- Clear the top line
term.clearLine()
-- Calculate padding for centered text
local padding = math.floor((w - #text) / 2)
-- Draw the top bar with centered text
term.write(string.rep(" ", padding) .. text .. string.rep(" ", padding))
-- Restore original colors
term.setTextColor(oldFg)
term.setBackgroundColor(oldBg)
-- Move cursor below the top bar
term.setCursorPos(1, 2)
end
--- Draws a bottom bar with the specified text centered
--- @param text string The text to display in the bottom bar
--- @param fgColor number Optional foreground color (default: white)
--- @param bgColor number Optional background color (default: blue)
function appgui.downbar(text, fgColor, bgColor)
expect(1, text, "string")
expect(2, fgColor, "number", "nil")
expect(3, bgColor, "number", "nil")
-- Default colors
fgColor = fgColor or colors.white
bgColor = bgColor or colors.blue
-- Save current colors
local oldFg = term.getTextColor()
local oldBg = term.getBackgroundColor()
-- Get terminal size
local w, h = term.getSize()
-- Set colors and position
term.setTextColor(fgColor)
term.setBackgroundColor(bgColor)
term.setCursorPos(1, h)
-- Clear the bottom line
term.clearLine()
-- Calculate padding for centered text
local padding = math.floor((w - #text) / 2)
-- Draw the bottom bar with centered text
term.write(string.rep(" ", padding) .. text .. string.rep(" ", padding))
-- Restore original colors
term.setTextColor(oldFg)
term.setBackgroundColor(oldBg)
-- Move cursor to a safe position
term.setCursorPos(1, 1)
end
return appgui

View File

@@ -0,0 +1,103 @@
=== appgui API ===
The `appgui` API provides simple functions for drawing top bars and bottom bars in LeonOS applications, making it easy to create consistent user interfaces.
== Introduction ==
The appgui API is designed to simplify the process of adding professional-looking UI elements to your applications. It provides two main functions for drawing centered text bars at the top or bottom of the screen.
== Available Functions ==
- **appgui.topbar(text, [fgColor], [bgColor])**: Draws a top bar with centered text
- **appgui.downbar(text, [fgColor], [bgColor])**: Draws a bottom bar with centered text
== Function Parameters ==
Both functions accept the following parameters:
- **text**: (string) The text to display in the bar
- **fgColor**: (number, optional) The foreground color (default: white)
- **bgColor**: (number, optional) The background color (default: blue)
== Usage Examples ==
=== Basic Usage ===
First, you need to import the appgui module:
>>color yellow
local appgui = require("appgui")
>>color white
Then you can use the functions to draw bars:
1. Draw a top bar with default colors (white text on blue background):
>>color yellow
appgui.topbar("My Application Title")
>>color white
2. Draw a bottom bar with default colors:
>>color yellow
appgui.downbar("Status: Ready")
>>color white
=== Custom Colors ===
You can specify custom colors using the `colors` module:
>>color yellow
local colors = require("colors")
-- Red text on yellow background
appgui.topbar("Warning Message", colors.red, colors.yellow)
-- Green text on black background
appgui.downbar("Success", colors.green, colors.black)
>>color white
=== Complete Example ===
Here's a complete example showing how to use both top and bottom bars in an application:
>>color yellow
local appgui = require("appgui")
local term = require("term")
local colors = require("colors")
-- Clear the screen
term.clear()
-- Draw top and bottom bars
appgui.topbar("My Application")
appgui.downbar("Press Q to quit")
-- Add some content
print()
print("Welcome to my application!")
print()
print("This is a demonstration of the appgui API.")
print()
-- Wait for 'Q' key to exit
while true do
local event, key = os.pullEvent("key")
if key == 16 then -- Q key
break
end
end
>>color white
== Notes ==
- The text will be automatically centered in the bar
- The functions will preserve the original terminal colors by saving and restoring them
- After drawing a top bar, the cursor will be positioned below the bar
- After drawing a bottom bar, the cursor will be positioned at the top of the screen
- You can use any colors available in the `colors` module
- If the text is longer than the terminal width, it will be truncated
== See Also ==
- **colors**: For available color values
- **term**: For other terminal manipulation functions
- **appgui_demo**: A demonstration program showing the appgui API in action

View File

@@ -52,10 +52,33 @@ The package.json file contains metadata about your package. Here's an example:
- **version**: The package version (semantic versioning recommended)
- **author**: Your name or username
- **description**: A short description of what the package does
- **type**: The type of your package ("app" for applications, "api" for libraries)
- **main**: The main Lua file to load
- **dependencies**: Other packages your package depends on
- **exports**: Functions or variables to export for other programs to use
== Package Type Field ==
The `type` field in package.json determines where your package files will be installed:
- **app**: Files will be installed in the `/app` directory (default behavior)
- **api**: Files will be installed in the `/leonos/apis` directory
Example of a package.json with type field:
>>color yellow
{
"name": "example-api",
"version": "1.0.0",
"author": "Your Name",
"description": "An example API package",
"type": "api",
"main": "example-api.lua",
"dependencies": {},
"exports": {}
}
>>color white
== Writing Package Code ==
Edit the `<package_name>.lua` file to add your code. Here's a simple example:

View File

@@ -0,0 +1,77 @@
-- appgui_demo.lua
-- Demonstration of the appgui API for drawing top and bottom bars
local appgui = require("appgui")
local term = require("term")
local colors = require("colors")
-- Clear the screen before starting
term.clear()
-- Draw the top bar with default colors (white text on blue background)
appgui.topbar("LeonOS App GUI Demo")
-- Add some content in the middle
print()
print("This is a demonstration of the appgui API.")
print()
print("The top bar shows the application title.")
print("The bottom bar shows the status information.")
print()
print("Press any key to see custom colors...")
-- Wait for a key press using a safe event pulling function
local pullEventFunc = os.pullEvent or os.pullEventRaw
if not pullEventFunc then
error("No valid event pulling function found")
end
local event, key = table.unpack({pullEventFunc("key")})
-- Clear the screen and redraw with custom colors
term.clear()
appgui.topbar("Custom Colored Top Bar", colors.yellow, colors.red)
-- Add some content
print()
print("Now with custom colors!")
print()
print("Top bar: Yellow text on Red background")
print()
print("Press any key to continue...")
-- Wait for a key press using a safe event pulling function
local pullEventFunc = os.pullEvent or os.pullEventRaw
if not pullEventFunc then
error("No valid event pulling function found")
end
local event, key = table.unpack({pullEventFunc("key")})
-- Clear the screen and draw both top and bottom bars
term.clear()
appgui.topbar("Complete GUI Demo")
appgui.downbar("Status: Running - Press Q to quit")
-- Add some content in the middle
print()
print("Now you can see both top and bottom bars.")
print()
print("Try resizing the terminal window to see how the text stays centered.")
print()
print("Press Q to exit this demo.")
-- Main loop to handle key presses
while true do
-- Use a safe event pulling function
local pullEventFunc = os.pullEvent or os.pullEventRaw
if not pullEventFunc then
error("No valid event pulling function found")
end
local event, key = table.unpack({pullEventFunc("key")})
if key == 16 then -- Q key
break
end
end
-- Clear the screen before exiting
term.clear()
print("AppGUI Demo has ended.")

View File

@@ -35,7 +35,7 @@ print("LeonOS Lua REPL.\nCall exit() to exit.")
local history = {}
while run do
term.setTextColor(colors.white)
io.write("$ lua >>> ")
io.write("$ lua # ")
local data = term.read(nil, history, function(text)
return textutils.complete(text, env)
end)

View File

@@ -54,6 +54,7 @@ local function create_package(pkg_name)
description = "A new package for LeonOS",
author = "LeonOS User",
license = "MIT",
type = "app", -- 默认类型为app
dependencies = {},
files = {
pkg_name .. ".lua"
@@ -288,18 +289,25 @@ local function install_github_package(repo_path, options)
meta_file:write(textutils.serializeJSON(meta, false))
meta_file:close()
-- 下载并安装文件
-- 根据package类型确定安装目录
print("Installing version: " .. pkg_version)
local app_dir = "/app"
if not fs.exists(app_dir) then
fs.makeDir(app_dir)
local install_dir
if meta.type and meta.type == "api" then
install_dir = "/leonos/apis"
else
install_dir = "/app" -- 默认安装到app目录
end
-- 确保安装目录存在
if not fs.exists(install_dir) then
fs.makeDir(install_dir)
end
local success_count = 0
local fail_count = 0
for _, file_path in ipairs(meta.files or {}) do
local dest = fs.combine(app_dir, file_path)
local dest = fs.combine(install_dir, file_path)
if download_github_package_file(repo_path, file_path, dest) then
print("Installed: " .. file_path)
@@ -386,17 +394,23 @@ local function install_package(pkg_name, options)
return false
end
-- 安装文件
-- 根据package类型确定安装目录
print("Installing version: " .. latest_version)
-- 确保app目录存在
local app_dir = "/app"
if not fs.exists(app_dir) then
fs.makeDir(app_dir)
local install_dir
if meta.type and meta.type == "api" then
install_dir = "/leonos/apis"
else
install_dir = "/app" -- 默认安装到app目录
end
-- 确保安装目录存在
if not fs.exists(install_dir) then
fs.makeDir(install_dir)
end
for _, file_path in ipairs(meta.files or {}) do
local src = fs.combine(version_path, file_path)
local dest = fs.combine(app_dir, file_path)
local dest = fs.combine(install_dir, file_path)
-- 确保目标目录存在
local dest_dir = fs.getDir(dest)
@@ -508,9 +522,14 @@ local function remove_package(pkg_name)
file:close()
local ok, meta = pcall(textutils.unserializeJSON, meta_content)
if ok and meta then
-- 除包文件
-- 除包文件
for _, file_path in ipairs(meta.files or {}) do
local dest = fs.combine("/rom", file_path)
local dest
if meta.type and meta.type == "api" then
dest = fs.combine("/leonos/apis", file_path)
else
dest = fs.combine("/app", file_path)
end
if fs.exists(dest) then
fs.delete(dest)
print("Removed: " .. file_path)

View File

@@ -40,7 +40,7 @@ textutils.coloredPrint(colors.yellow,
print("Checking for update...")
local http = require("http")
local base = "https://gh.catmak.name/https://raw.githubusercontent.com/Leonmmcoset/LeonOS/refs/heads/main/"
local base = "https://gh.catmak.name/https://raw.githubusercontent.com/CCLeonOS/LeonOS/refs/heads/main/"
local Bhandle, Berr = http.get(base .. "data/computercraft/lua/bios.lua")
if not Bhandle then

View File

@@ -1,5 +1,5 @@
-- LeonOS installer
local INSTALLER_VERSION = "1.0.2"
local INSTALLER_VERSION = "1.0.3 Beta 7"
local DEFAULT_ROM_DIR = "/leonos"
print("Start loading LeonOS installer ("..INSTALLER_VERSION..")...")
@@ -47,7 +47,7 @@ print("[Installer] Loading done.")
print("[Installer] Loading module 7")
local function rcload(f)
return ghload(
"Leonmmcoset/LeonOS/refs/heads/main/data/computercraft/lua/rom/"..f, f)
"CCLeonOS/LeonOS/refs/heads/main/data/computercraft/lua/rom/"..f, f)
end
print("[Installer] Loading done.")
print("[Installer] Loading module 8")
@@ -69,6 +69,7 @@ term.write("[Installer] Loading done.\n")
local term = require("term")
local colors = require("colors")
local rc = require("rc")
-- local appgui = require("appgui")
-- 保存当前颜色设置
local old_fg = term.getTextColor()
local old_bg = term.getBackgroundColor()
@@ -96,10 +97,13 @@ tu.coloredPrint("If you want to keep the existing files, please backup them firs
tu.coloredPrint(colors.yellow, "Are you sure? (y/n)")
local confirm = read()
if confirm ~= "y" then
term.at(1, y).clearLine()
print("Installation cancelled.")
return
end
for y=2, term.getSize() do
term.at(1, y).clearLine()
end
local ROM_DIR
-- tu.coloredPrint("Enter installation directory ", colors.yellow, "[",
-- colors.lightBlue, DEFAULT_ROM_DIR, colors.yellow, "]")
@@ -123,7 +127,7 @@ end
bullet("Getting repository tree...")
local repodata = dl("https://gh.catmak.name/https://api.github.com/repos/Leonmmcoset/LeonOS/git/trees/main?recursive=1")
local repodata = dl("https://gh.catmak.name/https://api.github.com/repos/CCLeonOS/LeonOS/git/trees/main?recursive=1")
repodata = json.decode(repodata)
@@ -179,7 +183,7 @@ for i=1, #to_dl, 1 do
local v = to_dl[i]
if v.type == "blob" then
parallels[#parallels+1] = function()
local data = dl("https://gh.catmak.name/https://raw.githubusercontent.com/Leonmmcoset/LeonOS/refs/heads/main/data/computercraft/lua/"..v.path)
local data = dl("https://gh.catmak.name/https://raw.githubusercontent.com/CCLeonOS/LeonOS/refs/heads/main/data/computercraft/lua/"..v.path)
assert(io.open(v.real_path, "w")):write(data):close()
done = done + 1
progress(pby, done, #to_dl)
@@ -197,9 +201,10 @@ bullet("Downloading startup file...")
assert(io.open(
fs.exists("/startup.lua") and "/unbios-rc.lua" or "/startup.lua", "w"))
:write(dl(
"https://gh.catmak.name/https://raw.githubusercontent.com/Leonmmcoset/LeonOS/refs/heads/main/unbios.lua"
"https://gh.catmak.name/https://raw.githubusercontent.com/CCLeonOS/LeonOS/refs/heads/main/unbios.lua"
)):close()
ok()
os.sleep(0.5)
tu.coloredPrint(colors.yellow, "Your computer will restart in 3 seconds.")
local _, y = term.getCursorPos()