diff --git a/sys/apis/injector.lua b/sys/apis/injector.lua index d7ddfec..12792f6 100644 --- a/sys/apis/injector.lua +++ b/sys/apis/injector.lua @@ -15,12 +15,12 @@ for i = 1, #luaPaths do end end -table.insert(luaPaths, 1, '?') -table.insert(luaPaths, 2, '?.lua') -table.insert(luaPaths, 3, '/usr/apis/?') -table.insert(luaPaths, 4, '/usr/apis/?.lua') -table.insert(luaPaths, 5, '/sys/apis/?') -table.insert(luaPaths, 6, '/sys/apis/?.lua') +table.insert(luaPaths, 1, '?.lua') +table.insert(luaPaths, 2, '?/init.lua') +table.insert(luaPaths, 3, '/usr/apis/?.lua') +table.insert(luaPaths, 4, '/usr/apis/?/init.lua') +table.insert(luaPaths, 5, '/sys/apis/?.lua') +table.insert(luaPaths, 6, '/sys/apis/?/init.lua') local DEFAULT_PATH = table.concat(luaPaths, ';') local DEFAULT_BRANCH = _ENV.OPUS_BRANCH or _G.OPUS_BRANCH or 'develop-1.8' @@ -82,30 +82,18 @@ end -- Add require and package to the environment return function(env) - local function standardSearcher(modname) - -- Should this be 2 diff searchers ? if yes, installer would need an update + local function preloadSearcher(modname) if env.package.preload[modname] then return function() return env.package.preload[modname](modname, env) end end - if env.package.loaded[modname] then - return function() - return env.package.loaded[modname] - end - end end - local function shellSearcher(modname) - local fname = modname:gsub('%.', '/') .. '.lua' - - if env.shell and type(env.shell.getRunningProgram) == 'function' then - local running = env.shell.getRunningProgram() - if running then - local path = fs.combine(fs.getDir(running), fname) - if fs.exists(path) and not fs.isDir(path) then - return loadfile(path, env) - end + local function loadedSearcher(modname) + if env.package.loaded[modname] then + return function() + return env.package.loaded[modname] end end end @@ -115,21 +103,15 @@ return function(env) for pattern in string.gmatch(env.package.path, "[^;]+") do local sPath = string.gsub(pattern, "%?", fname) - if env.shell and env.shell.dir and sPath:sub(1, 1) ~= "/" then - sPath = fs.combine(env.shell.dir(), sPath) + -- TODO: if there's no shell, we should not be checking relative paths below + -- as they will resolve to root directory + if env.shell and type(env.shell.getRunningProgram) == 'function' and sPath:sub(1, 1) ~= "/" then + sPath = fs.combine(fs.getDir(env.shell.getRunningProgram()), sPath) end if fs.exists(sPath) and not fs.isDir(sPath) then return loadfile(sPath, env) end end - --[[ - for dir in string.gmatch(env.package.path, "[^:]+") do - local path = fs.combine(dir, fname) - if fs.exists(path) and not fs.isDir(path) then - return loadfile(path, env) - end - end - ]] end -- require('BniCQPVf') @@ -185,8 +167,8 @@ return function(env) table = table, }, loaders = { - standardSearcher, - shellSearcher, + preloadSearcher, + loadedSearcher, pathSearcher, pastebinSearcher, gitSearcher, diff --git a/sys/apps/Network.lua b/sys/apps/Network.lua index 85f6502..70f77c2 100644 --- a/sys/apps/Network.lua +++ b/sys/apps/Network.lua @@ -41,9 +41,10 @@ local page = UI.Page { --{ text = 'Chat', event = 'chat' }, { text = 'Trust', dropdown = { { text = 'Establish', event = 'trust' }, - { text = 'Remove', event = 'untrust' }, +-- { text = 'Remove', event = 'untrust' }, } }, { text = 'Help', event = 'help', noCheck = true }, +--[[ { text = '\187', x = -3, @@ -53,6 +54,7 @@ local page = UI.Page { { text = 'Show trusted', event = 'show_trusted', noCheck = true }, }, }, +]] }, }, grid = UI.ScrollingGrid { diff --git a/sys/extensions/4.user.lua b/sys/extensions/4.user.lua index 89a7000..722ec9a 100644 --- a/sys/extensions/4.user.lua +++ b/sys/extensions/4.user.lua @@ -44,6 +44,8 @@ for _, v in pairs(Util.split(shell.path(), '(.-):')) do end shell.setPath(table.concat(path, ':')) -_G.LUA_PATH = config.lua_path +-- TODO: replace when stable (old lua path is now incorrect) +-- _G.LUA_PATH = config.lua_path +_G.LUA_PATH = package.path fs.loadTab('usr/config/fstab') diff --git a/sys/extensions/6.packages.lua b/sys/extensions/6.packages.lua index c7203b3..9510e35 100644 --- a/sys/extensions/6.packages.lua +++ b/sys/extensions/6.packages.lua @@ -24,12 +24,6 @@ local function addEntry(t, e, n) table.insert(t, n or 1, e) end -local function addRequirePath(t, path) - addEntry(t, string.format('/%s/?/init.lua', path), 7) - addEntry(t, string.format('/%s/?.lua', path), 7) - addEntry(t, string.format('/%s/?', path), 7) -end - for name in pairs(Packages:installed()) do local packageDir = fs.combine('packages', name) if fs.exists(fs.combine(packageDir, '.install')) then @@ -42,7 +36,7 @@ for name in pairs(Packages:installed()) do addEntry(appPaths, packageDir) local apiPath = fs.combine(fs.combine('packages', name), 'apis') if fs.exists(apiPath) then - addRequirePath(luaPaths, apiPath) + fs.mount(fs.combine('sys/apis', name), 'linkfs', apiPath) end local helpPath = '/' .. fs.combine(fs.combine('packages', name), 'help')