bliss

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

commit 30aea9a248e3caf62dedfd1db862b43c3a280111
parent a74ad09b9e63e3243bb8888f2e63ea75eea2c82b
Author: phoebos <ben@bvnf.space>
Date:   Tue, 27 Jun 2023 22:05:15 +0100

add archive.tar_create

Diffstat:
Mbliss/archive.lua | 25+++++++++++++++++++++++++
1 file changed, 25 insertions(+), 0 deletions(-)

diff --git a/bliss/archive.lua b/bliss/archive.lua @@ -1,6 +1,7 @@ local utils = require 'bliss.utils' local dirent = require 'posix.dirent' local stdio = require 'posix.stdio' +local unistd = require 'posix.unistd' -- extracts tarball to PWD local function tar_extract(tarball) @@ -24,7 +25,31 @@ local function tar_extract(tarball) end end +-- p is a package table as in bliss.build +local function tar_create(env, p) + utils.log(p.pkg, "Creating tarball") + unistd.chdir(env.pkg_dir .. '/' .. p.pkg) + + local _tar_file = env.bin_dir .. '/' .. p.pkg .. '@' .. p.ver .. '-' .. p.rel .. '.tar.' .. env.COMPRESS + + -- env.COMPRESS is definitely one of the below (checked in utils.setup) + local compress_map = { + bz2 = "bzip2 -z", + gz = "gzip -6", + lzma = "lzma -z", + lz = "lzip -z", + xz = "xz -z", + zst = "zstd -z", + } + if not utils.run("tar cf - . | " .. compress_map[env.COMPRESS] .. " > " .. _tar_file) then os.exit(false) end + + -- TODO: cd $OLDPWD? + + utils.log(p.pkg, "Successfully created tarball") +end + local M = { tar_extract = tar_extract, + tar_create = tar_create, } return M