From f93d92f43d984c1d927c7c12d06ae1497d12deea Mon Sep 17 00:00:00 2001 From: Ed Maste Date: Wed, 23 Nov 2022 16:40:22 -0500 Subject: [PATCH] pkgbase: report errors via metalog reader exit status Reviewed by: kevans Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D37482 --- tools/pkgbase/metalog_reader.lua | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/tools/pkgbase/metalog_reader.lua b/tools/pkgbase/metalog_reader.lua index 72cfcf46c95b..3e8cf8461914 100644 --- a/tools/pkgbase/metalog_reader.lua +++ b/tools/pkgbase/metalog_reader.lua @@ -86,13 +86,14 @@ function main(args) local sess = Analysis_session(filename, verbose, w_notagdirs) + local errors if printall then io.write('--- PACKAGE REPORTS ---\n') io.write(sess.pkg_report_full()) io.write('--- LINTING REPORTS ---\n') - print_lints(sess) + errors = print_lints(sess) elseif checkonly then - print_lints(sess) + errors = print_lints(sess) elseif pkgonly then io.write(sess.pkg_report_simple(dcount, dsize, { fuid and sess.pkg_issetuid or nil, @@ -103,6 +104,10 @@ function main(args) io.stderr:write('This text should not be displayed.') usage() end + + if errors then + return 1 + end end --- @param man boolean @@ -151,6 +156,7 @@ function print_lints(sess) local inodewarn, inodeerr = sess.inode_report() io.write(inodewarn) io.write(inodeerr) + return #duperr > 0 or #inodeerr > 0 end --- @param t table @@ -520,4 +526,4 @@ function Analysis_session(metalog, verbose, w_notagdirs) } end -main(arg) +os.exit(main(arg))