2019-06-28 17:50:02 +00:00
|
|
|
local Packages = require('opus.packages')
|
|
|
|
local Util = require('opus.util')
|
2018-10-21 00:35:48 +00:00
|
|
|
|
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
|
|
|
|
|
2018-12-27 08:05:12 +00:00
|
|
|
local appPaths = Util.split(shell.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-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)
|
2018-10-21 00:35:48 +00:00
|
|
|
|
2020-05-19 23:09:10 +00:00
|
|
|
local fstabPath = fs.combine(packageDir, 'etc/fstab')
|
|
|
|
if fs.exists(fstabPath) then
|
|
|
|
fs.loadTab(fstabPath)
|
|
|
|
end
|
|
|
|
|
2019-07-20 22:23:48 +00:00
|
|
|
table.insert(appPaths, 1, '/' .. packageDir)
|
2020-05-19 23:09:10 +00:00
|
|
|
|
2020-04-27 01:39:58 +00:00
|
|
|
local apiPath = fs.combine(packageDir, 'apis') -- TODO: rename dir to 'modules' (someday)
|
2018-10-21 08:46:40 +00:00
|
|
|
if fs.exists(apiPath) then
|
2019-06-28 17:50:02 +00:00
|
|
|
fs.mount(fs.combine('rom/modules/main', name), 'linkfs', apiPath)
|
2018-10-21 08:46:40 +00:00
|
|
|
end
|
2018-12-23 03:11:16 +00:00
|
|
|
|
2019-03-06 16:48:09 +00:00
|
|
|
local helpPath = '/' .. fs.combine(packageDir, '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, ':'))
|
2020-04-22 04:40:59 +00:00
|
|
|
|
|
|
|
local function runDir(directory)
|
|
|
|
local files = fs.list(directory)
|
|
|
|
table.sort(files)
|
|
|
|
|
|
|
|
for _,file in ipairs(files) do
|
|
|
|
os.sleep(0)
|
|
|
|
local result, err = shell.run(directory .. '/' .. file)
|
|
|
|
if not result and err then
|
|
|
|
_G.printError('\n' .. err)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
for _, package in pairs(Packages:installedSorted()) do
|
|
|
|
local packageDir = 'packages/' .. package.name .. '/init'
|
|
|
|
if fs.exists(packageDir) and fs.isDir(packageDir) then
|
|
|
|
runDir(packageDir)
|
|
|
|
end
|
|
|
|
end
|