From e37fa8c44ac95d5d3facdb5c945c11c913b70558 Mon Sep 17 00:00:00 2001 From: Ralf Senderek Date: May 18 2016 18:35:46 +0000 Subject: adding strict mode to the macro (issue #6) --- diff --git a/macros.gpg b/macros.gpg index f76e690..1dd6b28 100644 --- a/macros.gpg +++ b/macros.gpg @@ -110,8 +110,8 @@ \ -- Call the RPM %error macro function rpmerror(str) - echo("gpg_verify: " .. str) - rpm.expand("%{error:gpg_verify: " .. str .. "}") + echo(str) + rpm.expand("%{error:" .. str .. "}") exit(1) end \ @@ -174,7 +174,7 @@ }# # The actual macro -%define gpg_verify(k:) %gpg_macros_init%{lua: +%define gpg_verify(a:k:) %gpg_macros_init%{lua: -- RPM will ignore the first thing we output unless we give it a newline. print('\\n') \ @@ -185,6 +185,7 @@ local signatures = {} local keyring_table = {} local keyrings = {} + local datasources = {} local defkey, match, captures, s \ local function storematch(m, c) @@ -206,10 +207,28 @@ db('Found keyring: ' .. s) else -- Must be a source + table.insert(datasources, s) db('Found source: ' .. s) end end \ + +if getoption("a") then + db('### using STRICT mode ###') + local sigfile + for _,d in pairs(datasources) do + sigfile = string.gsub(d, '$','.sig') + -- db("data: " .. sigfile) + if not sourcefiles[sigfile] then + rpmerror('missing signature for ' .. d) + else + db('Found matching signature for ' .. d) + end + end +end + + +\ if defkeyspec then defkey = check_sources_list({defkeyspec})[1] if not defkey then