git: 2a3bd0870869 - main - pkgbase: hide duplicate METALOG directory warnings under verbose

From: Ed Maste <emaste_at_FreeBSD.org>
Date: Mon, 01 May 2023 19:28:46 UTC
The branch main has been updated by emaste:

URL: https://cgit.FreeBSD.org/src/commit/?id=2a3bd0870869819354b5ea65761d13e5e2987697

commit 2a3bd0870869819354b5ea65761d13e5e2987697
Author:     Ed Maste <emaste@FreeBSD.org>
AuthorDate: 2023-05-01 17:25:18 +0000
Commit:     Ed Maste <emaste@FreeBSD.org>
CommitDate: 2023-05-01 19:22:36 +0000

    pkgbase: hide duplicate METALOG directory warnings under verbose
    
    Creating directories multiple times is an inherent side effect of the
    way installation is done.  Hide warnings from duplicate directory
    entries (with identical metadata) under metalog_reader's verbose mode.
    
    Duplicate file entries are always reported.  They currently generate
    warnings but will be switched to errors once the few instances currently
    in the tree are fixed.
    
    PR:             244596, 271178
    Reviewed by:    kevans
    Sponsored By:   The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D39898
---
 tools/pkgbase/metalog_reader.lua | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/tools/pkgbase/metalog_reader.lua b/tools/pkgbase/metalog_reader.lua
index 3e8cf8461914..9cc5fd727923 100644
--- a/tools/pkgbase/metalog_reader.lua
+++ b/tools/pkgbase/metalog_reader.lua
@@ -392,12 +392,18 @@ function Analysis_session(metalog, verbose, w_notagdirs)
 			if #rows == 1 then goto continue end
 			local iseq, offby = metalogrows_all_equal(rows)
 			if iseq then -- repeated line, just a warning
-				warn[#warn+1] = 'warning: '..filename
-					.. ' ' .. rows[1].attrs.type
-					..' repeated with same meta: line '
-					..table.concat(
-						table_map(rows, function(e) return e.linenum end), ',')
-				warn[#warn+1] = '\n'
+				local dupmsg = filename .. ' ' ..
+				    rows[1].attrs.type ..
+				    ' repeated with same meta: line ' ..
+				    table.concat(table_map(rows, function(e) return e.linenum end), ',')
+				if rows[1].attrs.type == "dir" then
+					if verbose then
+						warn[#warn+1] = 'warning: ' .. dupmsg .. '\n'
+					end
+				else
+					-- XXX downgrade to warning until instances in the tree are fixed (PR271178)
+					warn[#warn+1] = 'error: ' .. dupmsg .. '\n'
+				end
 			elseif not metalogrows_all_equal(rows, false, true) then
 			-- same filename (possibly different tags), different metadata, an error
 				errs[#errs+1] = 'error: '..filename