aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAdam Harrison <adamdharrison@gmail.com>2024-02-06 18:01:40 -0500
committerAdam Harrison <adamdharrison@gmail.com>2024-02-06 18:01:40 -0500
commit052db5d4be2cde203636e954e8ad9897d3ccc7fc (patch)
tree944705b74d735635da7f26cde9c5b2f7c22f426d /src
parent9189b99792f0e4f2bb4f08da1f46309d8af5fe65 (diff)
downloadlite-xl-plugin-manager-052db5d4be2cde203636e954e8ad9897d3ccc7fc.tar.gz
lite-xl-plugin-manager-052db5d4be2cde203636e954e8ad9897d3ccc7fc.zip
Added in update-checksums.
Diffstat (limited to 'src')
-rw-r--r--src/lpm.lua29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/lpm.lua b/src/lpm.lua
index 5734d88..af2a507 100644
--- a/src/lpm.lua
+++ b/src/lpm.lua
@@ -2208,6 +2208,9 @@ not commonly used publically.
interpreter.
lpm download <url> [target] Downloads the specified URL to stdout,
or to the specified target file.
+ lpm hash [file] Returns the sha256sum of the file.
+ lpm update-checksums [manifest] Pulls all remote files, computes their
+ checksums, and updates them in the file.
lpm extract <file.[tar.gz|zip]> Extracts the specified archive at
[target] target, or the current working directory.
]]
@@ -2371,6 +2374,32 @@ not commonly used publically.
system.extract(ARGS[3], ARGS[4] or ".")
os.exit(0)
end
+ if ARGS[2] == "update-checksums" then
+ local contents = common.read(ARGS[3])
+ local m = json.decode(contents)
+ local computed = {}
+ local filter
+ if #ARGS > 3 then
+ filter = {}
+ for i, arg in ipairs(ARGS) do
+ if i > 3 then filter[arg] = true end
+ end
+ end
+ for _, section in ipairs(common.concat(m.addons or {}, m["lite-xls"] or {})) do
+ for _, file in ipairs(section.files or {}) do
+ if (not filter or (section.id and filter[section.id])) and file.url and file.checksum ~= "SKIP" and type(file.checksum) == "string" then
+ local checksum = system.hash(common.get(file.url))
+ if computed[file.checksum] and computed[file.checksum] ~= checksum then
+ error("can't update manifest; existing checksum " .. file.checksum .. " exists in two separate places that now have disparate checksum values")
+ end
+ computed[file.checksum] = checksum
+ contents = contents:gsub(file.checksum, checksum)
+ end
+ end
+ end
+ common.write(ARGS[3], contents)
+ os.exit(0)
+ end
if ARGS[2] == "manifest" then
local repo = Repository.url(ARGS[3])
repo.branch = "master"