OC-misc/repo-installer/instgen.lua

37 lines
902 B
Lua
Raw Normal View History

2018-08-06 19:22:21 +10:00
local serial = require "serialization"
local tArgs = {...}
local src, dest = tArgs[1], tArgs[2].."/"
os.execute("mkdir "..dest.."/master/")
os.execute("wget "..src.." -O "..dest.."/master/programs.cfg")
local pathpre = src:match("(.+/).+/.+")
print(pathpre)
local f = io.open(dest.."/master/programs.cfg","rb")
if not f then
print("Unable to open programs.cfg")
return false
end
local programs = serial.unserialize(f:read("*a"))
f:close()
local dlfiles = {}
for k,v in pairs(programs) do
if v.files then
for l,m in pairs(v.files) do
dlfiles[#dlfiles+1] = l
end
end
end
for k,v in pairs(dlfiles) do
local path,fn = v:match("(.+)/(.+)")
os.execute("mkdir "..dest..path)
os.execute("wget "..pathpre..v.." -O "..dest..v)
print("wget "..pathpre..v.." -O "..dest..v)
end
os.execute("wget https://git.shadowkat.net/izaya/OC-misc/raw/branch/master/repoinstaller.lua "..dest.."/.install")