mirror of
https://github.com/kepler155c/opus
synced 2025-10-12 14:27:41 +00:00
fix lua path, mwm, cleanup injector
This commit is contained in:
@@ -10,11 +10,9 @@ if not fs.exists('usr/autorun') then
|
||||
fs.makeDir('usr/autorun')
|
||||
end
|
||||
|
||||
local lua_path = package.path
|
||||
|
||||
-- TODO: Temporary
|
||||
local upgrade = Util.readTable('usr/config/shell')
|
||||
if upgrade and not upgrade.upgraded then
|
||||
if upgrade and not upgrade.upgraded or upgrade.upgraded ~= 1 then
|
||||
fs.delete('usr/config/shell')
|
||||
end
|
||||
|
||||
@@ -22,8 +20,8 @@ if not fs.exists('usr/config/shell') then
|
||||
Util.writeTable('usr/config/shell', {
|
||||
aliases = shell.aliases(),
|
||||
path = 'usr/apps',
|
||||
lua_path = lua_path,
|
||||
upgraded = true,
|
||||
lua_path = package.path,
|
||||
upgraded = 1,
|
||||
})
|
||||
end
|
||||
|
||||
@@ -44,8 +42,7 @@ for _, v in pairs(Util.split(shell.path(), '(.-):')) do
|
||||
end
|
||||
|
||||
shell.setPath(table.concat(path, ':'))
|
||||
-- TODO: replace when stable (old lua path is now incorrect)
|
||||
-- _G.LUA_PATH = config.lua_path
|
||||
_G.LUA_PATH = package.path
|
||||
|
||||
_G.LUA_PATH = config.lua_path
|
||||
|
||||
fs.loadTab('usr/config/fstab')
|
||||
|
@@ -10,30 +10,14 @@ if not fs.exists('usr/config/packages') then
|
||||
end
|
||||
|
||||
local appPaths = Util.split(shell.path(), '(.-):')
|
||||
local luaPaths = Util.split(_G.LUA_PATH, '(.-);')
|
||||
local helpPaths = Util.split(help.path(), '(.-):')
|
||||
|
||||
table.insert(helpPaths, '/sys/help')
|
||||
|
||||
local function addEntry(t, e, n)
|
||||
for _,v in ipairs(t) do
|
||||
if v == e then
|
||||
return true
|
||||
end
|
||||
end
|
||||
table.insert(t, n or 1, e)
|
||||
end
|
||||
|
||||
for name in pairs(Packages:installed()) do
|
||||
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
|
||||
end
|
||||
|
||||
addEntry(appPaths, packageDir)
|
||||
table.insert(appPaths, 1, packageDir)
|
||||
local apiPath = fs.combine(fs.combine('packages', name), 'apis')
|
||||
if fs.exists(apiPath) then
|
||||
fs.mount(fs.combine('sys/apis', name), 'linkfs', apiPath)
|
||||
@@ -47,4 +31,3 @@ end
|
||||
|
||||
help.setPath(table.concat(helpPaths, ':'))
|
||||
shell.setPath(table.concat(appPaths, ':'))
|
||||
_G.LUA_PATH = table.concat(luaPaths, ';')
|
||||
|
@@ -2,6 +2,7 @@ _G.requireInjector(_ENV)
|
||||
|
||||
local Config = require('config')
|
||||
local Packages = require('packages')
|
||||
local trace = require('trace')
|
||||
local Util = require('util')
|
||||
|
||||
local colors = _G.colors
|
||||
@@ -104,6 +105,15 @@ function multishell.launch( tProgramEnv, sProgramPath, ... )
|
||||
})
|
||||
end
|
||||
|
||||
local function xprun(env, path, ...)
|
||||
setmetatable(env, { __index = _G })
|
||||
local fn, m = loadfile(path, env)
|
||||
if fn then
|
||||
return trace(fn, ...)
|
||||
end
|
||||
return fn, m
|
||||
end
|
||||
|
||||
function multishell.openTab(tab)
|
||||
if not tab.title and tab.path then
|
||||
tab.title = fs.getName(tab.path):match('([^%.]+)')
|
||||
@@ -120,7 +130,7 @@ function multishell.openTab(tab)
|
||||
if tab.fn then
|
||||
result, err = Util.runFunction(routine.env, tab.fn, table.unpack(tab.args or { } ))
|
||||
elseif tab.path then
|
||||
result, err = Util.run(routine.env, tab.path, table.unpack(tab.args or { } ))
|
||||
result, err = xprun(routine.env, tab.path, table.unpack(tab.args or { } ))
|
||||
else
|
||||
err = 'multishell: invalid tab'
|
||||
end
|
||||
|
Reference in New Issue
Block a user