diff options
author | Natanael Copa <ncopa@alpinelinux.org> | 2011-03-30 13:10:06 +0200 |
---|---|---|
committer | Natanael Copa <ncopa@alpinelinux.org> | 2011-03-30 13:11:13 +0200 |
commit | 486959e2dbd516f9d7bce8493a1a55b9d890066e (patch) | |
tree | 0233f3797d8bf79642fb81fea4f9c2b27d49f9d6 /aports.lua | |
parent | dee681905fe6d164f86626fff9021982ab7bb0b1 (diff) | |
download | abuild-486959e2dbd516f9d7bce8493a1a55b9d890066e.tar.gz abuild-486959e2dbd516f9d7bce8493a1a55b9d890066e.tar.bz2 abuild-486959e2dbd516f9d7bce8493a1a55b9d890066e.tar.xz abuild-486959e2dbd516f9d7bce8493a1a55b9d890066e.zip |
ap/aports.lua: implement recurse_until
will recursively parse all build depends
Diffstat (limited to 'aports.lua')
-rwxr-xr-x | aports.lua | 42 |
1 files changed, 42 insertions, 0 deletions
@@ -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 + |