summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pm.lua28
1 files changed, 25 insertions, 3 deletions
diff --git a/pm.lua b/pm.lua
index 72dbdcf..65b56b7 100644
--- a/pm.lua
+++ b/pm.lua
@@ -78,15 +78,37 @@ local function recursive_filesof(pkgname)
return files
end
+local function fmt_set(set)
+ local keys = {}
+ for k in pairs(set) do table.insert(keys,k) end
+ table.sort(keys)
+ return "("..#keys..") " .. table.concat(keys,", ")
+end
+
+local function dl(pkgname)
+ local deps = recursive_depsof(pkgname)
+ local files = recursive_filesof(pkgname)
+ print("all dependencies: "..fmt_set(deps))
+ print("all files: "..fmt_set(files))
+ for file in pairs(files) do
+ dlfile(file)
+ end
+ print"done"
+end
+
+
local function dlfile(filename)
- local file,err=fs.open("/"..filename,"w")
+ local src=rbase..filename
+ local dest="/"..filename
+ print("downloading "..src.." to "..dest)
+ local file,err=fs.open(dest,"w")
if err then error("fs.open "..err) end
- local res,err = http.get("https://g.gh0.pw/ccprogs/plain/"..filename)
+ local res,err = http.get(src)
if err then error("http.get "..err) end
file.write(res.readAll())
file.flush()
file.close()
end
-return {manifest=manifest,rd=recursive_depsof,rf=recursive_filesof}
+return {manifest=manifest,rd=recursive_depsof,rf=recursive_filesof,dl=dl}
--dl(arg[1])