From 2812dcb4e38e73d8397defe3b86fcc807d60080b Mon Sep 17 00:00:00 2001 From: Natanael Copa Date: Mon, 6 Mar 2017 13:29:25 +0100 Subject: add sanity check of generated yaml --- secfixes.lua | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'secfixes.lua') diff --git a/secfixes.lua b/secfixes.lua index a9fb853..8dbe71d 100644 --- a/secfixes.lua +++ b/secfixes.lua @@ -40,10 +40,29 @@ function arch_list(a) return str end +function verify_yaml(file) + f = io.open(file) + if f == nil then + return 1 + end + print("Verifying "..file) + local data = yaml.load(f:read("*all")) + for _,p in pairs(data.packages) do + assert(type(p.pkg.name) == "string") + for k,v in pairs(p.pkg.secfixes) do + assert(type(k) == "string", file..": "..p.pkg.name..": not a string: "..tostring(k)) + assert(string.match(k, "^[0-9]+")) + end + end + + f:close() +end + opthelp = [[ --repo=REPO set repository --release=VERSION distro release branch + --verify=FILE verify generated yaml ]] archs = { @@ -55,6 +74,10 @@ archs = { opts, args = require('optarg').from_opthelp(opthelp) +if opts.verify then + os.exit(verify_yaml(opts.verify)) +end + repo = (opts.repo or "main") distroversion = (opts.release or "v3.4") -- cgit v1.2.3