From 987fa5b8ed35860370cf57627be90af58bb561d5 Mon Sep 17 00:00:00 2001 From: ubq323 Date: Mon, 1 Apr 2024 20:38:00 +0100 Subject: launch --- pm.lua | 33 +++++++++++++++++++++------------ 1 file 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 -- cgit v1.2.3