bliss

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

commit adef629ff2dcf1723fa48fd5f2743b7b968aedfb
parent 70fd772a7a54ffa88d404555d1676a6635ba4128
Author: phoebos <ben@bvnf.space>
Date:   Mon,  3 Jul 2023 18:27:07 +0100

build: etcsums

All the necessary features of build are now implemented!

Diffstat:
MREADME | 2+-
Mbliss/build.lua | 33++++++++++++++++++++++++++++++++-
2 files changed, 33 insertions(+), 2 deletions(-)

diff --git a/README b/README @@ -4,7 +4,7 @@ BLISS An implementation of the kiss package manager in Lua. [ ] alternatives -[ ] build +[x] build [ ] hooks [x] checksum [x] download diff --git a/bliss/build.lua b/bliss/build.lua @@ -5,6 +5,7 @@ local download = require "bliss.download" local checksum = require "bliss.checksum" local glob = require "posix.glob" local libgen = require "posix.libgen" +local sys_stat = require "posix.sys.stat" local unistd = require "posix.unistd" --[[ @@ -109,7 +110,9 @@ local function gen_manifest(env, p) local mani = recurse_find(destdir .. "/*") table.insert(mani, manifest_file) - -- TODO: etcsums + if sys_stat.stat(destdir .. "/etc") then + table.insert(mani, destdir .. "/" .. env.pkg_db .. "/" .. p.pkg .. "/etcsums") + end -- Sort in reverse. table.sort(mani, function (a,b) return b < a end) @@ -125,6 +128,32 @@ local function gen_manifest(env, p) f:close() end +local function gen_etcsums(env, p) + local destdir = env.pkg_dir .. "/" .. p.pkg + if not sys_stat.stat(destdir .. "/etc") then return end + + utils.log(p.pkg, "Generating etcsums") + + local db = destdir .. "/" .. env.pkg_db .. "/" .. p.pkg + local etcsums = assert(io.open(db .. "/etcsums", "w")) + local lines = pkg.read_lines(db .. "/manifest") + for _, line in ipairs(lines) do + -- beware that read_lines splits lines by spaces + line = line[1] + if string.sub(line, 1, 5) == "/etc/" and string.sub(line, -1) ~= "/" then + local f = destdir .. line + local sb = sys_stat.stat(f) + if sys_stat.S_ISLNK(sb.st_mode) ~= 0 then + f = "/dev/null" + end + + local hash = checksum.checksum_file(f) + etcsums:write(hash .. "\n") + end + end + etcsums:close() +end + local function build(env, arg) if #arg == 0 then end -- TODO @@ -190,7 +219,9 @@ local function build(env, arg) build_extract(env, p) build_build(env, p) + -- TODO: strip? fix_deps? gen_manifest(env, p) + gen_etcsums(env, p) archive.tar_create(env, p) if not explicit[p.pkg] then