mirror of
https://github.com/kepler155c/opus
synced 2025-10-23 03:37:40 +00:00
package management
This commit is contained in:
@@ -1,14 +1,15 @@
|
||||
_G.requireInjector(_ENV)
|
||||
|
||||
local class = require('class')
|
||||
local Config = require('config')
|
||||
local Event = require('event')
|
||||
local FileUI = require('ui.fileui')
|
||||
local NFT = require('nft')
|
||||
local SHA1 = require('sha1')
|
||||
local Tween = require('ui.tween')
|
||||
local UI = require('ui')
|
||||
local Util = require('util')
|
||||
local class = require('class')
|
||||
local Config = require('config')
|
||||
local Event = require('event')
|
||||
local FileUI = require('ui.fileui')
|
||||
local NFT = require('nft')
|
||||
local Packages = require('packages')
|
||||
local SHA1 = require('sha1')
|
||||
local Tween = require('ui.tween')
|
||||
local UI = require('ui')
|
||||
local Util = require('util')
|
||||
|
||||
local colors = _G.colors
|
||||
local fs = _G.fs
|
||||
@@ -46,11 +47,14 @@ local function loadApplications()
|
||||
|
||||
applications = Util.readTable('sys/etc/app.db')
|
||||
|
||||
if fs.exists('usr/etc/apps') then
|
||||
local dbs = fs.list('usr/etc/apps')
|
||||
for _, db in pairs(dbs) do
|
||||
local apps = Util.readTable('usr/etc/apps/' .. db) or { }
|
||||
Util.merge(applications, apps)
|
||||
for dir in pairs(Packages:installed()) do
|
||||
local path = fs.combine('packages/' .. dir, 'etc/apps')
|
||||
if fs.exists(path) then
|
||||
local dbs = fs.list(path)
|
||||
for _, db in pairs(dbs) do
|
||||
local apps = Util.readTable(fs.combine(path, db)) or { }
|
||||
Util.merge(applications, apps)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
36
sys/apps/Package.lua
Normal file
36
sys/apps/Package.lua
Normal file
@@ -0,0 +1,36 @@
|
||||
_G.requireInjector(_ENV)
|
||||
|
||||
local Packages = require('packages')
|
||||
local Util = require('util')
|
||||
|
||||
local fs = _G.fs
|
||||
|
||||
local args = { ... }
|
||||
local action = table.remove(args, 1)
|
||||
|
||||
local function Syntax(msg)
|
||||
error(msg)
|
||||
end
|
||||
|
||||
if action == 'list' then
|
||||
for k in pairs(Packages:list()) do
|
||||
Util.print('[%s] %s', Packages:isInstalled(k) and 'x' or ' ', k)
|
||||
end
|
||||
end
|
||||
|
||||
if action == 'install' then
|
||||
local name = args[1] or Syntax('Invalid package')
|
||||
if Packages:isInstalled(name) then
|
||||
error('Package is already installed')
|
||||
end
|
||||
local manifest = Packages:getManifest(name) or error('Invalid package')
|
||||
local packageDir = 'packages/' .. name
|
||||
local method = args[2] or 'remote'
|
||||
if method == 'remote' then
|
||||
Util.writeTable(packageDir .. '/.install', {
|
||||
mount = string.format('%s gitfs %s', packageDir, manifest.repository),
|
||||
})
|
||||
Util.writeTable(fs.combine(packageDir, '.package'), manifest)
|
||||
print('success')
|
||||
end
|
||||
end
|
@@ -1,13 +0,0 @@
|
||||
_G.requireInjector(_ENV)
|
||||
|
||||
local Packages = require('packages')
|
||||
local Util = require('util')
|
||||
|
||||
local args = { ... }
|
||||
|
||||
if args[1] == 'list' then
|
||||
for k,v in pairs(Packages:list()) do
|
||||
Util.print('[%s] %s', Packages:isInstalled(k) and 'x' or ' ', k)
|
||||
end
|
||||
end
|
||||
|
@@ -568,10 +568,10 @@ local function shellRead(history)
|
||||
local ie = Input:translate(event, p1, p2, p3)
|
||||
if ie then
|
||||
if ie.code == 'scroll_up' then
|
||||
terminal.scrollUp()
|
||||
--terminal.scrollUp()
|
||||
|
||||
elseif ie.code == 'scroll_down' then
|
||||
terminal.scrollDown()
|
||||
--terminal.scrollDown()
|
||||
|
||||
elseif ie.code == 'terminate' then
|
||||
bExit = true
|
||||
|
Reference in New Issue
Block a user