OCWorkflow/ocbuild.lua

49 lines
1.1 KiB
Lua
Raw Normal View History

local internet = require("internet")
local shell = require("shell")
local arg = {...}
local fs = require("filesystem")
local req = ""
local srcserv = ""
local srcproj = ""
if arg[1] ~= nil or arg[2] ~=nil then
srcserv = arg[1]
srcproj = arg[2]
elseif fs.exists(shell.getWorkingDirectory() .. "/Projfile") then
print("pulling from Projfile...")
projfile = shell.getWorkingDirectory() .. "/Projfile"
file = fs.open(projfile,"r")
if file == nil then
print("Need a project file or supplied project info!")
return
end
srcuncut = file:read(256)
local cut = string.find(srcuncut, ",")
srcserv = string.sub(srcuncut, 0, cut - 1)
srcproj = string.sub(srcuncut, cut + 1)
print(srcserv)
print(srcproj)
else
print("No args and no project file - no idea what to do! Abort.")
return
end
print("Requesting " .. "http://" .. srcserv .."/" .. srcproj .. ".proj")
local handle = internet.request("http://" .. srcserv .. "/" .. srcproj .. ".proj")
files = ""
for chunk in handle do
files = chunk
end
for str in string.gmatch(files, '([^' .. '\n' .. ']+)') do
shell.execute("wget -f http://" .. srcserv .. "/" .. str)
end
shell.execute("main")