bliss

KISS in Lua
git clone git://bvnf.space/bliss.git
Log | Files | Refs | README | LICENSE

commit cf39eb26924ee43da9ecc0987fcffc1a8144e40b
parent 4bb3f9798deefa1057a256b92b4b97faf8b49ada
Author: phoebos <ben@bvnf.space>
Date:   Fri, 16 Jun 2023 15:34:55 +0100

add verify_checksums

Diffstat:
Mbliss/checksum.lua | 14++++++++++++--
Mbliss/pkg.lua | 6++++++
Mtest.lua | 6++++++
3 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/bliss/checksum.lua b/bliss/checksum.lua @@ -46,12 +46,22 @@ local function checksum(env, arg) end end -local function verify_checksums(p, path) - -- TODO +local function verify_checksums(p, repo_dir, caches) + local sums = pkg.find_checksums(p, repo_dir) + for i,v in ipairs(caches) do + local sum = checksum_file(v) + if #sums[i][1] == 64 then + utils.die(p, "Detected sha256 checksums") + end + if sums[i][1] ~= sum and sums[i] ~= "SKIP" then + utils.die(p, "checksum mismatch for file " .. v) + end + end end local M = { checksum = checksum, checksum_file = checksum_file, + verify_checksums = verify_checksums, } return M diff --git a/bliss/pkg.lua b/bliss/pkg.lua @@ -33,6 +33,11 @@ local function find_version(pkg, path) return ver[1] end +local function find_checksums(pkg, repo_dir) + local p = repo_dir .. "/checksums" + return read_lines(p) +end + local function find_sources(pkg, repo_dir) local p = repo_dir .. "/sources" @@ -80,6 +85,7 @@ end local M = { find = find, find_version = find_version, + find_checksums = find_checksums, find_sources = find_sources, resolve = resolve, } diff --git a/test.lua b/test.lua @@ -18,3 +18,9 @@ local obs = bliss.b3sum.finalize(ctx) local exp = bliss.capture("echo test | b3sum") local exp_ = bliss.split(exp[1], ' ')[1] assert(exp_ == obs) + +local p = 'feh' +local repo_dir = bliss.find(p, env.PATH) +local sources = bliss.find_sources(p, repo_dir) +local caches = bliss.resolve(p, sources, env, repo_dir) +bliss.verify_checksums(p, repo_dir, caches)