1
0
mirror of https://github.com/kepler155c/opus synced 2024-11-17 14:14:50 +00:00
opus/sys/extensions/6.packages.lua

51 lines
1.3 KiB
Lua
Raw Normal View History

2018-10-21 00:35:48 +00:00
local Packages = require('packages')
local Util = require('util')
2018-12-23 03:11:16 +00:00
local fs = _G.fs
local help = _G.help
2018-10-21 00:35:48 +00:00
local shell = _ENV.shell
2019-01-09 11:59:19 +00:00
if not fs.exists('usr/config/packages') then
Packages:downloadList()
end
2018-12-27 08:05:12 +00:00
local appPaths = Util.split(shell.path(), '(.-):')
2018-12-17 03:17:19 +00:00
local luaPaths = Util.split(_G.LUA_PATH, '(.-);')
2018-12-23 22:32:06 +00:00
local helpPaths = Util.split(help.path(), '(.-):')
table.insert(helpPaths, '/sys/help')
2018-10-21 00:35:48 +00:00
2018-12-30 11:50:59 +00:00
local function addEntry(t, e, n)
2018-12-23 22:32:06 +00:00
for _,v in ipairs(t) do
if v == e then
return true
2018-10-21 00:35:48 +00:00
end
end
2018-12-30 11:50:59 +00:00
table.insert(t, n or 1, e)
2018-10-21 00:35:48 +00:00
end
2018-11-04 18:00:37 +00:00
for name in pairs(Packages:installed()) do
2018-11-03 22:13:41 +00:00
local packageDir = fs.combine('packages', name)
if fs.exists(fs.combine(packageDir, '.install')) then
local install = Util.readTable(fs.combine(packageDir, '.install'))
if install and install.mount then
fs.mount(table.unpack(Util.matches(install.mount)))
end
2018-10-21 00:35:48 +00:00
end
2018-12-23 22:32:06 +00:00
addEntry(appPaths, packageDir)
2018-10-21 08:46:40 +00:00
local apiPath = fs.combine(fs.combine('packages', name), 'apis')
if fs.exists(apiPath) then
2019-01-27 03:58:02 +00:00
fs.mount(fs.combine('sys/apis', name), 'linkfs', apiPath)
2018-10-21 08:46:40 +00:00
end
2018-12-23 03:11:16 +00:00
2018-12-23 22:32:06 +00:00
local helpPath = '/' .. fs.combine(fs.combine('packages', name), 'help')
2018-12-23 03:11:16 +00:00
if fs.exists(helpPath) then
table.insert(helpPaths, helpPath)
end
2018-10-21 00:35:48 +00:00
end
2018-12-23 03:11:16 +00:00
help.setPath(table.concat(helpPaths, ':'))
2018-10-21 00:35:48 +00:00
shell.setPath(table.concat(appPaths, ':'))
2018-12-17 03:17:19 +00:00
_G.LUA_PATH = table.concat(luaPaths, ';')