summaryrefslogtreecommitdiffstats
path: root/aports/pkg.lua
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2014-01-24 13:43:51 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2014-01-24 13:44:16 +0000
commit252d3854b375935195d0e94cfc74e17594edf0e9 (patch)
treeb5dbe7a6a9050bd86bab9154d3b0a6e3a6516ff2 /aports/pkg.lua
parentc1ce372185dbbbd4b2e61979f45757e4954ee98a (diff)
downloadlua-aports-252d3854b375935195d0e94cfc74e17594edf0e9.tar.bz2
lua-aports-252d3854b375935195d0e94cfc74e17594edf0e9.tar.xz
pkg: replace all_deps with an each_dependency() iterator
Diffstat (limited to 'aports/pkg.lua')
-rw-r--r--aports/pkg.lua45
1 files changed, 16 insertions, 29 deletions
diff --git a/aports/pkg.lua b/aports/pkg.lua
index 0614ec6..b5218e0 100644
--- a/aports/pkg.lua
+++ b/aports/pkg.lua
@@ -3,26 +3,6 @@ local M = {}
local abuild = require('aports.abuild')
local lfs = require('lfs')
--- return a key list with makedepends and depends
-function M.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 M.is_remote(url)
local _,pref
for _,pref in pairs{ "^http://", "^ftp://", "^https://", ".*::.*" } do
@@ -110,15 +90,22 @@ function M.arch_enabled(pkg)
return pkg.arch.all or pkg.arch.noarch or pkg.arch[abuild.arch]
end
+function M.each_dependency(pkg)
+ return coroutine.wrap(function()
+ for _,dep in pairs(pkg.depends or {}) do
+ coroutine.yield(dep)
+ end
+ for _,dep in pairs(pkg.makedepends or {}) do
+ coroutine.yield(dep)
+ end
+ end)
+end
+
+
function M.init(pkg)
- pkg.all_deps = M.all_deps
- pkg.remote_sources = M.remote_sources
- pkg.get_maintainer = M.get_maintainer
- pkg.get_repo_name = M.get_repo_name
- pkg.get_apk_file_name = M.get_apk_file_name
- pkg.get_apk_file_path = M.get_apk_file_path
- pkg.apk_file_exists = M.apk_file_exists
- pkg.all_apks_exists = M.all_apks_exists
- pkg.arch_enabled = M.arch_enabled
+ for k,v in pairs(M) do
+ pkg[k] = v
+ end
end
+
return M