feat(pkg): 更新包管理系统并升级至LeonOS 0.3.6

- 将包安装目录从/leonos/packages迁移至/packages
- 更新版本号至0.3.6
- 修改installer.lua以正确处理packages目录
- 更新pkg.lua程序适配新的包路径
- 添加示例包文件到新位置
This commit is contained in:
2025-09-02 09:51:29 +08:00
parent 5bf8abf22f
commit 9867d4522c
7 changed files with 16 additions and 10 deletions

View File

@@ -1,10 +0,0 @@
-- example command completion
local shell = require('shell')
local completion = require('completion')
-- Set up completion for example command
shell.setCompletionFunction('example', completion.build({
-- 这里可以添加example命令的补全逻辑
completion.choice{'--help', '-h'}
}))

View File

@@ -1,12 +0,0 @@
{
"name": "example",
"version": "1.0.1",
"description": "An example package for LeonOS",
"author": "LeonMMcoset",
"license": "MIT",
"dependencies": {},
"files": [
"programs/example.lua",
"completions/example.lua"
]
}

View File

@@ -1,25 +0,0 @@
-- Example Package Program
local colors = require('colors')
local term = require('term')
function drawTopBar()
local w, h = term.getSize()
term.setBackgroundColor(colors.cyan)
term.setTextColor(colors.white)
term.setCursorPos(1, 1)
term.clearLine()
local title = "=== Example Package v1.0.0 ==="
local pos = math.floor((w - #title) / 2) + 1
term.setCursorPos(pos, 1)
term.write(title)
term.setBackgroundColor(colors.black)
term.setTextColor(colors.white)
term.setCursorPos(1, 3)
end
drawTopBar()
print("\nThis is an example package that demonstrates the features of LeonOS package manager.")
print("\nUsage:")
print(" pkg install example-pkg - Install this package")
print(" pkg remove example-pkg - Uninstall this package")
print(" pkg list - List installed packages")

View File

@@ -1,3 +0,0 @@
{
"packages": {}
}

View File

@@ -26,9 +26,9 @@ term.at(1, 2)
-- 包管理器配置
local pkg_config = {
repo_url = "https://example.com/leonos/packages", -- 包仓库URL
local_pkg_dir = "/leonos/packages", -- 本地包存储目录
installed_db = "/leonos/packages/installed.json", -- 已安装包数据库
cache_dir = "/leonos/cache" -- 缓存目录
local_pkg_dir = "/packages", -- 本地包存储目录
installed_db = "/packages/installed.json", -- 已安装包数据库
cache_dir = "/rom/cache" -- 缓存目录
}
-- 确保必要的目录存在
@@ -136,7 +136,7 @@ local function install_package(pkg_name, options)
print("Installing version: " .. latest_version)
for _, file_path in ipairs(meta.files or {}) do
local src = fs.combine(version_path, file_path)
local dest = fs.combine("/leonos", file_path)
local dest = fs.combine("/rom", file_path)
-- 确保目标目录存在
local dest_dir = fs.getDir(dest)
@@ -250,7 +250,7 @@ local function remove_package(pkg_name)
if ok and meta then
-- 删除包文件
for _, file_path in ipairs(meta.files or {}) do
local dest = fs.combine("/leonos", file_path)
local dest = fs.combine("/rom", file_path)
if fs.exists(dest) then
fs.delete(dest)
print("Removed: " .. file_path)