mirror of
https://git.hardenedbsd.org/hardenedbsd/HardenedBSD.git
synced 2024-11-25 10:01:02 +01:00
f8e46fd61e
Rework how ucl manifest are generated leveraging ucl features and flua now the ucl generation is done via a lua script which uses libucl to ingest the template and use variables as defined in its command line. the template will include only if it exist a ucl file named after the package name which will complement the template or overwrite what was defined in the template if defined in this specific ucl file this allows to overwrite license, but add script only to the packages who actually needs them. As a results the post install scripts are now only added to the right package and not also added to the subpackages like -man or -dev Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D44374
36 lines
954 B
Lua
Executable File
36 lines
954 B
Lua
Executable File
#!/usr/libexec/flua
|
|
|
|
--[[ usage:
|
|
generare-ucl.lua [<variablename> <variablevalue>]... <sourceucl> <destucl>
|
|
|
|
In the <destucl> files the variable <variablename> (in the form ${variablename}
|
|
in the <sourceucl>) will be expanded to <variablevalue>.
|
|
|
|
The undefined variables will reamin unmofifier "${variablename}"
|
|
]]--
|
|
|
|
local ucl = require("ucl")
|
|
|
|
if #arg < 2 or #arg % 2 ~= 0 then
|
|
io.stderr:write(arg[0] .. ": expected an even number of arguments, got " .. #arg)
|
|
os.exit(1)
|
|
end
|
|
|
|
local parser = ucl.parser()
|
|
for i = 2, #arg - 2, 2 do
|
|
parser:register_variable(arg[i - 1], arg[i])
|
|
end
|
|
local res,err = parser:parse_file(arg[#arg - 1])
|
|
if not res then
|
|
io.stderr:write(arg[0] .. ": fail to parse("..arg[#arg - 1].."): "..err)
|
|
os.exit(1)
|
|
end
|
|
local f,err = io.open(arg[#arg], "w")
|
|
if not f then
|
|
io.stderr:write(arg[0] .. ": fail to open("..arg[#arg].."): ".. err)
|
|
os.exit(1)
|
|
end
|
|
local obj = parser:get_object()
|
|
f:write(ucl.to_format(obj, 'ucl'))
|
|
f:close()
|