mirror of
https://gitlab.alpinelinux.org/alpine/abuild.git
synced 2024-12-23 07:22:53 +00:00
ap/aports.lua: implement recurse_until
will recursively parse all build depends
This commit is contained in:
parent
dee681905f
commit
486959e2db
26
ap.in
26
ap.in
@ -36,28 +36,11 @@ subcmd.recursdeps = {
|
||||
desc = "Recursively print all make dependencies for given packages",
|
||||
usage = "PKG...",
|
||||
run = function (opts)
|
||||
local i
|
||||
local visited = {}
|
||||
local apkdb, rev = aports.init_apkdb(repodirs)
|
||||
function recurs(pn)
|
||||
if pn == nil or visited[pn] or apkdb[pn] == nil then
|
||||
return
|
||||
end
|
||||
visited[pn] = true
|
||||
local i,d, p
|
||||
for i,p in pairs(apkdb[pn]) do
|
||||
local _, d
|
||||
for _, d in pairs(p.depends) do
|
||||
recurs(d)
|
||||
end
|
||||
for _, d in pairs(p.makedepends) do
|
||||
recurs(d)
|
||||
end
|
||||
end
|
||||
print(pn)
|
||||
end
|
||||
local db, rev = aports.init_apkdb(repodirs)
|
||||
for i = 2, #opts do
|
||||
recurs(opts[i])
|
||||
aports.recurs_until(db, opts[i], function(pn)
|
||||
print(pn)
|
||||
end)
|
||||
end
|
||||
end
|
||||
}
|
||||
@ -130,6 +113,7 @@ while i <= #arg do
|
||||
i = i + 1
|
||||
end
|
||||
|
||||
|
||||
cmd = opts[1]
|
||||
|
||||
if cmd == nil then
|
||||
|
42
aports.lua
42
aports.lua
@ -103,3 +103,45 @@ function init_apkdb(repodirs)
|
||||
return pkgdb, revdeps
|
||||
end
|
||||
|
||||
-- return a key list with makedepends and depends
|
||||
function all_deps(p)
|
||||
local m = {}
|
||||
local k,v
|
||||
if p == nil then
|
||||
return m
|
||||
end
|
||||
if type(p.depends) == "table" then
|
||||
for k,v in pairs(p.depends) do
|
||||
m[v] = true
|
||||
end
|
||||
end
|
||||
if type(p.makedepends) == "table" then
|
||||
for k,v in pairs(p.makedepends) do
|
||||
m[v] = true
|
||||
end
|
||||
end
|
||||
return m
|
||||
end
|
||||
|
||||
|
||||
function recurs_until(apkdb, pn, func)
|
||||
local visited={}
|
||||
function recurs(pn)
|
||||
if pn == nil or visited[pn] or apkdb[pn] == nil then
|
||||
return false
|
||||
end
|
||||
visited[pn] = true
|
||||
local _, p
|
||||
for _, p in pairs(apkdb[pn]) do
|
||||
local d
|
||||
for d in pairs(all_deps(p)) do
|
||||
if recurs(d) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
return func(pn)
|
||||
end
|
||||
return recurs(pn)
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user