1
0
mirror of https://github.com/kepler155c/opus synced 2025-10-16 16:27:39 +00:00

package manager wip

This commit is contained in:
kepler155c@gmail.com
2018-10-20 20:35:48 -04:00
parent 8b50127f21
commit b7176e55ad
4 changed files with 87 additions and 0 deletions

View File

@@ -0,0 +1,38 @@
_G.requireInjector(_ENV)
local Packages = require('packages')
local Util = require('util')
local shell = _ENV.shell
local fs = _G.fs
local appPaths = Util.split(shell.path(), '(.-):')
local luaPaths = Util.split(_G.LUA_PATH, '(.-):')
local function addPath(t, e)
local function hasEntry()
for _,v in ipairs(t) do
if v == e then
return true
end
end
end
if not hasEntry() then
table.insert(t, 1, e)
end
end
-- dependency graph
-- https://github.com/mpeterv/depgraph/blob/master/src/depgraph/init.lua
for name, package in pairs(Packages:installed()) do
if package.mount then
fs.mount(table.unpack(Util.matches(package.mount)))
end
addPath(appPaths, fs.combine(fs.combine('packages', name), 'apps'))
addPath(luaPaths, fs.combine(fs.combine('packages', name), 'apis'))
end
shell.setPath(table.concat(appPaths, ':'))
_G.LUA_PATH = table.concat(luaPaths, ':')