hopefully correctly implement including external files as a dependency
This commit is contained in:
parent
518cb39d66
commit
efd83d6b8e
@ -2,6 +2,10 @@ local serial = require "serialization"
|
||||
|
||||
local tArgs = {...}
|
||||
local src, dest = tArgs[1], tArgs[2].."/"
|
||||
local filter = {}
|
||||
for k,v in ipairs({table.unpack(tArgs,3)}) do
|
||||
filter[v] = true
|
||||
end
|
||||
|
||||
local _OSVERSION = _OSVERSION or ""
|
||||
|
||||
@ -67,21 +71,25 @@ os.execute("rm '"..pcfgname.."'")
|
||||
|
||||
local dlfiles = {}
|
||||
for k,v in pairs(programs) do
|
||||
if v.files then
|
||||
for l,m in pairs(v.files) do
|
||||
for l,m in pairs(v.files or {}) do
|
||||
dlfiles[#dlfiles+1] = l
|
||||
end
|
||||
for l,m in pairs(v.dependencies or {}) do
|
||||
if l:match("^https?://") then
|
||||
dlfiles[#dlfiles+1] = l
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
for k,v in pairs(dlfiles) do
|
||||
local path,fn = v:match("(.+)/(.+)")
|
||||
if v:sub(1,4) ~= "http" then
|
||||
local path = v:match("^(.+)/[^/]+$") or v
|
||||
if v:match("^https?://") then
|
||||
local fp = v:match("^https?://(.+)$")
|
||||
mkdir(dest.."/external/"..fp:match("^(.+)/[^/]+$"))
|
||||
wget(v,dest.."/external/"..fp)
|
||||
else
|
||||
mkdir(dest..path)
|
||||
wget(pathpre..v,dest..v)
|
||||
else
|
||||
mkdir(dest.."/external")
|
||||
wget(v,dest.."/external/"..fn)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -106,6 +106,11 @@ local function drawmenu() -- draw the menu display - nothing but text and VT100
|
||||
end
|
||||
for k = start, math.min(#pkgmap,start+workingSpace) do
|
||||
local v = pkgmap[k]
|
||||
print(string.format("%s %s %s\27[0m",
|
||||
k == selected and "\27[30;47m" or "",
|
||||
unicode.char(packages[v].selected and 0x25A0 or 0x25A1),
|
||||
v))
|
||||
--[[
|
||||
if k == selected then
|
||||
io.write("\27[30;47m")
|
||||
end
|
||||
@ -116,6 +121,7 @@ local function drawmenu() -- draw the menu display - nothing but text and VT100
|
||||
end
|
||||
io.write(v)
|
||||
print("\27[0m")
|
||||
]]
|
||||
end
|
||||
end
|
||||
|
||||
@ -171,7 +177,7 @@ for k,v in pairs(packages) do
|
||||
toinstall[k] = true
|
||||
if v.dependencies then
|
||||
for l,m in pairs(v.dependencies) do -- including dependencies
|
||||
if not toinstall[l] then
|
||||
if not toinstall[l] and not l:match("^https?://") then
|
||||
print("Package "..k.." depends on "..l)
|
||||
toinstall[l] = m
|
||||
end
|
||||
@ -191,6 +197,10 @@ if co ~= 21 then -- confirm they want the packages installed
|
||||
return
|
||||
end
|
||||
|
||||
local function prepareDir(path)
|
||||
return fs.isDirectory(fs.path(path)) or fs.makeDirectory(fs.path(path))
|
||||
end
|
||||
|
||||
local function install(pkg,where) -- installs a package, pkg, to where
|
||||
where = where or tpath
|
||||
if type(where) ~= string then where = tpath end
|
||||
@ -198,28 +208,20 @@ local function install(pkg,where) -- installs a package, pkg, to where
|
||||
if packages[pkg] then
|
||||
ipackages[pkg] = {}
|
||||
print("Copying files...")
|
||||
for l,m in pairs(packages[pkg].files) do
|
||||
local lseg = fs.segments(l)
|
||||
if m:sub(1,2) ~= "//" then
|
||||
if not fs.exists(fs.canonical(where.."/"..m)) then
|
||||
os.execute("mkdir "..fs.canonical(where.."/"..m))
|
||||
for l,m in pairs(packages[pkg].files or {}) do
|
||||
local dest = fs.canonical(string.format("%s/%s/%s", m:sub(1,2) ~= "//" and where or "", m, fs.name(l)))
|
||||
prepareDir(dest)
|
||||
os.execute(string.format("cp -v '%s/%s' '%s'", rpath, l, dest))
|
||||
ipackages[pkg][l] = dest
|
||||
end
|
||||
if l:sub(1,4) == "http" then
|
||||
os.execute("cp -v "..rpath.."/external/"..l:match(".+/(.+)").." "..fs.canonical(where.."/"..m))
|
||||
else
|
||||
os.execute("cp -v "..rpath.."/"..l.." "..fs.canonical(where.."/"..m))
|
||||
end
|
||||
ipackages[pkg][l] = fs.canonical(where.."/"..m).."/"..lseg[#lseg]
|
||||
else
|
||||
if not fs.exists(fs.canonical(m:sub(2))) then
|
||||
os.execute("mkdir "..fs.canonical(m:sub(2)))
|
||||
end
|
||||
if l:sub(1,4) == "http" then
|
||||
os.execute("cp -v "..rpath.."/external/"..l:match(".+/(.+)").." "..fs.canonical(m))
|
||||
else
|
||||
os.execute("cp -v "..rpath.."/"..l.." "..fs.canonical(m))
|
||||
end
|
||||
ipackages[pkg][l] = fs.canonical(m:sub(2)).."/"..lseg[#lseg]
|
||||
for l,m in pairs(packages[pkg].dependencies or {}) do
|
||||
if l:match("^https?://") then
|
||||
local dest = fs.canonical(string.format("%s/%s/%s", m:sub(1,2) ~= "//" and where or "", m, fs.name(l)))
|
||||
print(l)
|
||||
print(l:match("^https?://(.+)$"))
|
||||
print(dest)
|
||||
os.execute(string.format("cp -v '%s/external/%s' '%s'", rpath, l:match("^https?://(.+)$"), dest))
|
||||
ipackages[pkg][l] = dest
|
||||
end
|
||||
end
|
||||
if packages[pkg].postinstall then
|
||||
|
Loading…
Reference in New Issue
Block a user