From 8feed4d2bbe7a9a8765d18ae10a79b2292784cc3 Mon Sep 17 00:00:00 2001 From: Björn Persson Date: Jul 14 2016 08:56:55 +0000 Subject: Fixed the error reporting about invalid parameters. --- diff --git a/macros.gpg b/macros.gpg index fab8861..9fa6714 100644 --- a/macros.gpg +++ b/macros.gpg @@ -28,6 +28,9 @@ # Some utility functions to the global namespace # Most of these should come from the utility macros in the other repo. %define gpg_macros_init %{lua: +\ + errors = false +\ function db(str) io.stderr:write(tostring(str) .. '\\n') end @@ -122,6 +125,7 @@ echo("gpg_verify: " .. str) rpm.expand("%{error:gpg_verify: " .. str .. "}") exit(1) + errors = true end \ -- XXX How to we get just a flag and no option? @@ -168,10 +172,10 @@ else fpath = get_named_source(src) end - if not src then - err = 'Not a valid source: ' .. src + if not fpath then + err = src .. ' is not a valid source number or filename.' if src == '1' then - err = err .. '. Note that "Source:" is the 0th source file, not the 1st.' + err = err .. ' Note that "Source:" is the 0th source file, not the 1st.' end rpmerror(err) end @@ -219,9 +223,6 @@ \ if defkeyspec then defkey = check_sources_list({defkeyspec})[1] - if not defkey then - rpmerror('The provided keyring ' .. defkeyspec .. ' is not a valid source number or filename.') - end end \ if defkey then @@ -291,23 +292,25 @@ end end \ - -- Now actually check things - for _,arg in ipairs(arglist) do - local gpgfile = '$GPGHOME/' .. basename(arg.keyfile) .. '.gpg' - echo('Checking signature: file ' .. arg.srcfile .. ' sig ' .. arg.sigfile .. ' key ' .. arg.keyfile) + if not errors then -- Avoid printing confusing error messages when arglist is incomplete because of errors. + -- Now actually check things + for _,arg in ipairs(arglist) do + local gpgfile = '$GPGHOME/' .. basename(arg.keyfile) .. '.gpg' + echo('Checking signature: file ' .. arg.srcfile .. ' sig ' .. arg.sigfile .. ' key ' .. arg.keyfile) \ - -- We need a secure temp directorry - print('GPGHOME=$(mktemp -qd)\\n') + -- We need a secure temp directorry + print('GPGHOME=$(mktemp -qd)\\n') \ - -- Call gpg2 to generate the dearmored key - print('gpg2 --homedir $GPGHOME --no-default-keyring --quiet --yes ') - print('--output '.. gpgfile .. ' --dearmor ' .. arg.keyfile .. "\\n") + -- Call gpg2 to generate the dearmored key + print('gpg2 --homedir $GPGHOME --no-default-keyring --quiet --yes ') + print('--output '.. gpgfile .. ' --dearmor ' .. arg.keyfile .. "\\n") \ - -- Call gpgv2 to verify the signature against the source file with the dearmored key - print('gpgv2 --homedir $GPGHOME --keyring ' .. gpgfile .. ' ' .. arg.sigfile .. ' ' .. arg.srcfile .. '\\n') + -- Call gpgv2 to verify the signature against the source file with the dearmored key + print('gpgv2 --homedir $GPGHOME --keyring ' .. gpgfile .. ' ' .. arg.sigfile .. ' ' .. arg.srcfile .. '\\n') \ - print('rm -rf $GPGHOME\\n') - echo('') + print('rm -rf $GPGHOME\\n') + echo('') + end end \ db('------------')