From a9147861163020596bfbf32cd249fcc77888532f Mon Sep 17 00:00:00 2001 From: MayaTheShy Date: Sun, 22 Mar 2026 15:50:46 -0400 Subject: [PATCH] Update package sources to include develop branch and improve download logic --- sys/modules/opus/packages.lua | 47 +++++++++++++++++++++++++++++------ 1 file changed, 40 insertions(+), 7 deletions(-) diff --git a/sys/modules/opus/packages.lua b/sys/modules/opus/packages.lua index 446e1ba..6c2a319 100644 --- a/sys/modules/opus/packages.lua +++ b/sys/modules/opus/packages.lua @@ -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