summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pm.lua33
1 files changed, 21 insertions, 12 deletions
diff --git a/pm.lua b/pm.lua
index 12ef864..5864d25 100644
--- a/pm.lua
+++ b/pm.lua
@@ -73,9 +73,9 @@ local function manifest(pkgname)
return man
end
-local function recursive_depsof(pkgname)
+local function recursive_depsof(pkgname, out)
local lookedat = {}
- local deps = {}
+ local deps = out or {}
local function F(pkgname)
if not lookedat[pkgname] then
lookedat[pkgname] = true
@@ -90,10 +90,9 @@ local function recursive_depsof(pkgname)
return deps
end
-local function recursive_filesof(pkgname)
- local deps = recursive_depsof(pkgname)
+local function filesof(dep_set)
local files = {}
- for dep in pairs(deps) do
+ for dep in pairs(dep_list) do
for file in pairs(manifest(dep).files) do files[file] = true end
end
return files
@@ -125,9 +124,12 @@ local function dlfile(filename)
file.close()
end
-local function dl(pkgname)
- local deps = recursive_depsof(pkgname)
- local files = recursive_filesof(pkgname)
+local function dl_many(pkgnames)
+ local dep_set = {}
+ for _,pkname in ipairs(pkgnames) do
+ recursive_depsof(pkgname, dep_set)
+ end
+ local files = filesof(dep_set)
print("all dependencies: "..fmt_set(deps))
print("all files: "..fmt_set(files))
for file in pairs(files) do
@@ -135,11 +137,18 @@ local function dl(pkgname)
end
print"done"
end
+
+local function dl(pkgname)
+ dl_many({pkgname})
+end
if is_required() then
- return {manifest=manifest,rd=recursive_depsof,rf=recursive_filesof,dl=dl,cc=clear_cache}
+ return {manifest=manifest,
+ rd=recursive_depsof,
+ rf=recursive_filesof,
+ dl=dl,
+ dl_many=dl_many,
+ cc=clear_cache}
else
- for i=1,#arg do
- dl(arg[i])
- end
+ dl_many(arg)
end