feat(安装系统): 添加应用启动器并更新安装路径

添加新的应用启动器程序(app.lua)用于从/app目录运行应用
将包安装路径从/rom改为/app目录
更新安装器版本号至0.3.6 Beta 2
确保/app目录在安装过程中自动创建
This commit is contained in:
2025-09-02 10:13:01 +08:00
parent a4b55d1fc8
commit e0c295dfd1
3 changed files with 65 additions and 2 deletions

View File

@@ -0,0 +1,51 @@
-- app.lua - Application launcher for LeonOS
local function show_help()
print("Usage: app <program_name> [arguments]")
print("Runs an application from the /app directory")
print("")
print("Options:")
print(" --help, -h Show this help message")
end
local function main(args)
if #args == 0 or args[1] == "--help" or args[1] == "-h" then
show_help()
return
end
local program_name = args[1]
local program_args = {}
-- 提取程序参数
for i=2, #args do
table.insert(program_args, args[i])
end
-- 构建程序路径
local program_path = fs.combine("/app", program_name)
-- 检查程序是否存在
if not fs.exists(program_path) then
-- 尝试添加.lua扩展名
program_path = program_path .. ".lua"
if not fs.exists(program_path) then
print("Error: Application '" .. args[1] .. "' not found in /app directory")
return
end
end
-- 运行程序
print("Running application: " .. program_name)
local success, error_msg = pcall(function()
shell.run(program_path, table.unpack(program_args))
end)
if not success then
print("Error running application: " .. error_msg)
end
end
-- 运行主函数
local args = {...}
main(args)

View File

@@ -134,9 +134,15 @@ local function install_package(pkg_name, options)
-- 安装文件
print("Installing version: " .. latest_version)
-- 确保app目录存在
local app_dir = "/app"
if not fs.exists(app_dir) then
fs.makeDir(app_dir)
end
for _, file_path in ipairs(meta.files or {}) do
local src = fs.combine(version_path, file_path)
local dest = fs.combine("/rom", file_path)
local dest = fs.combine(app_dir, file_path)
-- 确保目标目录存在
local dest_dir = fs.getDir(dest)

View File

@@ -1,5 +1,5 @@
-- LeonOS installer
local INSTALLER_VERSION = "0.3.6 Beta 1"
local INSTALLER_VERSION = "0.3.6 Beta 2"
local DEFAULT_ROM_DIR = "/leonos"
print("Start loading LeonOS installer ("..INSTALLER_VERSION..")...")
@@ -150,6 +150,12 @@ local cache_dir = "/packages/cache"
if not fs.exists(cache_dir) then
fs.makeDir(cache_dir)
end
-- 确保应用目录存在
local app_dir = "/app"
if not fs.exists(app_dir) then
fs.makeDir(app_dir)
end
for i=#to_dl, 1, -1 do
local v = to_dl[i]
if v.type == "tree" then