Update package sources to include develop branch and improve download logic

This commit is contained in:
MayaTheShy
2026-03-22 15:50:46 -04:00
parent 03f00fc2a4
commit a914786116

View File

@@ -1,4 +1,5 @@
local Util = require('opus.util')
local Config = require('opus.config')
local Util = require('opus.util')
local fs = _G.fs
local textutils = _G.textutils
@@ -7,6 +8,21 @@ local PACKAGE_DIR = 'packages'
local Packages = { }
-- Default package sources (upstream GitHub + self-hosted Gitea)
local DEFAULT_SOURCES = {
{
name = 'opus-apps',
branches = {
[ 'develop-1.8' ] = 'https://raw.githubusercontent.com/kepler155c/opus-apps/develop-1.8/packages.list',
[ 'master-1.8' ] = 'https://raw.githubusercontent.com/kepler155c/opus-apps/master-1.8/packages.list',
},
},
{
name = 'spatulaa',
url = 'https://git.spatulaa.com/MayaTheShy/Opus/raw/branch/main/sys/etc/packages.list',
},
}
function Packages:installed()
local list = { }
@@ -55,13 +71,30 @@ function Packages:isInstalled(package)
end
function Packages:downloadList()
local packages = {
[ 'develop-1.8' ] = 'https://raw.githubusercontent.com/kepler155c/opus-apps/develop-1.8/packages.list',
[ 'master-1.8' ] = 'https://raw.githubusercontent.com/kepler155c/opus-apps/master-1.8/packages.list',
}
local sources = Config.load('package').sources or DEFAULT_SOURCES
local packages = { }
if packages[_G.OPUS_BRANCH] then
Util.download(packages[_G.OPUS_BRANCH], 'usr/config/packages')
for _, source in ipairs(sources) do
local url = source.url
if source.branches then
url = source.branches[_G.OPUS_BRANCH]
end
if url then
local content = Util.httpGet(url)
if content then
local list = textutils.unserialize(content)
if list then
for k, v in pairs(list) do
packages[k] = v
end
end
end
end
end
if next(packages) then
Util.writeTable('usr/config/packages', packages)
end
end