Update package sources to include develop branch and improve download logic
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
local Util = require('opus.util')
|
local Config = require('opus.config')
|
||||||
|
local Util = require('opus.util')
|
||||||
|
|
||||||
local fs = _G.fs
|
local fs = _G.fs
|
||||||
local textutils = _G.textutils
|
local textutils = _G.textutils
|
||||||
@@ -7,6 +8,21 @@ local PACKAGE_DIR = 'packages'
|
|||||||
|
|
||||||
local 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()
|
function Packages:installed()
|
||||||
local list = { }
|
local list = { }
|
||||||
|
|
||||||
@@ -55,13 +71,30 @@ function Packages:isInstalled(package)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function Packages:downloadList()
|
function Packages:downloadList()
|
||||||
local packages = {
|
local sources = Config.load('package').sources or DEFAULT_SOURCES
|
||||||
[ 'develop-1.8' ] = 'https://raw.githubusercontent.com/kepler155c/opus-apps/develop-1.8/packages.list',
|
local packages = { }
|
||||||
[ 'master-1.8' ] = 'https://raw.githubusercontent.com/kepler155c/opus-apps/master-1.8/packages.list',
|
|
||||||
}
|
|
||||||
|
|
||||||
if packages[_G.OPUS_BRANCH] then
|
for _, source in ipairs(sources) do
|
||||||
Util.download(packages[_G.OPUS_BRANCH], 'usr/config/packages')
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user