|
@ -1,6 +1,7 @@ |
|
|
--[[ |
|
|
--[[ |
|
|
OpenPrograms package manager, browser and downloader, for easy access to many programs |
|
|
|
|
|
Author: Vexatos |
|
|
|
|
|
|
|
|
Sothr Package Manager, browser and downloader, for easy access to many programs |
|
|
|
|
|
Author: Vexatos, WarrickSothr |
|
|
|
|
|
Forked and modified from: https://github.com/Wuerfel21/OpenComputers/blob/master/src/main/resources/assets/opencomputers/loot/OPPM/oppm.lua |
|
|
]] |
|
|
]] |
|
|
local component = require("component") |
|
|
local component = require("component") |
|
|
local event = require("event") |
|
|
local event = require("event") |
|
@ -20,7 +21,8 @@ if not component.isAvailable("internet") then |
|
|
end |
|
|
end |
|
|
local internet = require("internet") |
|
|
local internet = require("internet") |
|
|
|
|
|
|
|
|
local repoLocationConfig="https://raw.githubusercontent.com/OpenPrograms/openprograms.github.io/master/repos.cfg" |
|
|
|
|
|
|
|
|
--local repoLocationConfig="https://raw.githubusercontent.com/OpenPrograms/openprograms.github.io/master/repos.cfg" |
|
|
|
|
|
local repoLocationConfig = "https://sothr.com/download/oc/releases/repos.cfg" |
|
|
|
|
|
|
|
|
local args, options = shell.parse(...) |
|
|
local args, options = shell.parse(...) |
|
|
|
|
|
|
|
@ -60,7 +62,15 @@ local function getRepos() |
|
|
return serial.unserialize(sRepos) |
|
|
return serial.unserialize(sRepos) |
|
|
end |
|
|
end |
|
|
|
|
|
|
|
|
local function getPackages(repo) |
|
|
|
|
|
|
|
|
local function getPackages(src) |
|
|
|
|
|
local success, sPackages = pcall(getContent, src .. "/programs.cfg") |
|
|
|
|
|
if not success or not sPackages then |
|
|
|
|
|
return -1 |
|
|
|
|
|
end |
|
|
|
|
|
return serial.unserialize(sPackages) |
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
local function getGithubPackages(repo) |
|
|
local success, sPackages = pcall(getContent, "https://raw.githubusercontent.com/" .. repo .. "/master/programs.cfg") |
|
|
local success, sPackages = pcall(getContent, "https://raw.githubusercontent.com/" .. repo .. "/master/programs.cfg") |
|
|
if not success or not sPackages then |
|
|
if not success or not sPackages then |
|
|
return -1 |
|
|
return -1 |
|
@ -91,10 +101,10 @@ local function readFromFile(fNum) |
|
|
if fNum == 1 then |
|
|
if fNum == 1 then |
|
|
path = "/etc/opdata.svd" |
|
|
path = "/etc/opdata.svd" |
|
|
elseif fNum == 2 then |
|
|
elseif fNum == 2 then |
|
|
path = "/etc/oppm.cfg" |
|
|
|
|
|
|
|
|
path = "/etc/spm.cfg" |
|
|
if not fs.exists(path) then |
|
|
if not fs.exists(path) then |
|
|
local tProcess = process.running() |
|
|
local tProcess = process.running() |
|
|
path = fs.concat(fs.path(shell.resolve(tProcess)),"/etc/oppm.cfg") |
|
|
|
|
|
|
|
|
path = fs.concat(fs.path(shell.resolve(tProcess)), "/etc/spm.cfg") |
|
|
end |
|
|
end |
|
|
end |
|
|
end |
|
|
if not fs.exists(fs.path(path)) then |
|
|
if not fs.exists(fs.path(path)) then |
|
@ -141,11 +151,19 @@ local function listPackages(filter) |
|
|
return |
|
|
return |
|
|
end |
|
|
end |
|
|
for _, j in pairs(repos) do |
|
|
for _, j in pairs(repos) do |
|
|
if j.repo then |
|
|
|
|
|
|
|
|
local lPacks |
|
|
|
|
|
local target |
|
|
|
|
|
if j.src then |
|
|
|
|
|
print("Checking Repository " .. j.src) |
|
|
|
|
|
lPacks = getPackages(j.src) |
|
|
|
|
|
target = j.src |
|
|
|
|
|
elseif j.repo then |
|
|
print("Checking Repository " .. j.repo) |
|
|
print("Checking Repository " .. j.repo) |
|
|
local lPacks = getPackages(j.repo) |
|
|
|
|
|
|
|
|
lPacks = getGithubPackages(j.repo) |
|
|
|
|
|
target = j.repo |
|
|
|
|
|
end |
|
|
if lPacks == nil then |
|
|
if lPacks == nil then |
|
|
io.stderr:write("Error while trying to receive package list for " .. j.repo.."\n") |
|
|
|
|
|
|
|
|
io.stderr:write("Error while trying to receive package list for " .. target .. "\n") |
|
|
return |
|
|
return |
|
|
elseif type(lPacks) == "table" then |
|
|
elseif type(lPacks) == "table" then |
|
|
for k in pairs(lPacks) do |
|
|
for k in pairs(lPacks) do |
|
@ -155,7 +173,6 @@ local function listPackages(filter) |
|
|
end |
|
|
end |
|
|
end |
|
|
end |
|
|
end |
|
|
end |
|
|
end |
|
|
|
|
|
local lRepos = readFromFile(2) |
|
|
local lRepos = readFromFile(2) |
|
|
if lRepos then |
|
|
if lRepos then |
|
|
for _, j in pairs(lRepos.repos) do |
|
|
for _, j in pairs(lRepos.repos) do |
|
@ -218,15 +235,21 @@ local function getInformation(pack) |
|
|
return |
|
|
return |
|
|
end |
|
|
end |
|
|
for _, j in pairs(repos) do |
|
|
for _, j in pairs(repos) do |
|
|
if j.repo then |
|
|
|
|
|
local lPacks = getPackages(j.repo) |
|
|
|
|
|
|
|
|
local lPacks |
|
|
|
|
|
local target |
|
|
|
|
|
if j.src then |
|
|
|
|
|
lPacks = getPackages(j.src) |
|
|
|
|
|
target = j.src |
|
|
|
|
|
elseif j.repo then |
|
|
|
|
|
lPacks = getGithubPackages(j.repo) |
|
|
|
|
|
target = "https://raw.githubusercontent.com/" .. j.repo |
|
|
|
|
|
end |
|
|
if lPacks == nil then |
|
|
if lPacks == nil then |
|
|
io.stderr:write("Error while trying to receive package list for "..j.repo.."\n") |
|
|
|
|
|
|
|
|
io.stderr:write("Error while trying to receive package list for " .. target .. "\n") |
|
|
elseif type(lPacks) == "table" then |
|
|
elseif type(lPacks) == "table" then |
|
|
for k in pairs(lPacks) do |
|
|
for k in pairs(lPacks) do |
|
|
if k == pack then |
|
|
if k == pack then |
|
|
return lPacks[k],j.repo |
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
return lPacks[k], target |
|
|
end |
|
|
end |
|
|
end |
|
|
end |
|
|
end |
|
|
end |