summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorubq323 <ubq323@ubq323.website>2022-08-04 00:19:14 +0100
committerubq323 <ubq323@ubq323.website>2022-08-04 00:19:14 +0100
commit1eadba02dc48357e18a729f593c6171e0764bdc0 (patch)
tree8e23cbb1b6add4c79116a05d3c42fcd8f3e72c26
parentf63c137a8adfeacb3e2d727d168cfbfbe86c2919 (diff)
pm
-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])