[PATCH 1/3] misc-functions.sh: Inline prepinfo code in install_qa_check()

Ulrich Müller <[email protected]> Tue, 4 Apr 2023 23:46:28 +0200
Newsgroups gmane.linux.gentoo.portage.devel
Message-ID <[email protected]>
Add a deprecation warning. Presumably, subdirs of /usr/share/info have
never been used by any package except app-editors/emacs.

Remove duplicate rm statement at the end of the function.

Bug: https://bugs.gentoo.org/899898
Signed-off-by: Ulrich Müller <[email protected]>
---
 bin/misc-functions.sh | 24 +++++++++++++++++++-----
 1 file changed, 19 insertions(+), 5 deletions(-)

diff --git a/bin/misc-functions.sh b/bin/misc-functions.sh
index 55c4afe73..235823afc 100755
--- a/bin/misc-functions.sh
+++ b/bin/misc-functions.sh
@@ -1,5 +1,5 @@
 #!/usr/bin/env bash
-# Copyright 1999-2018 Gentoo Authors
+# Copyright 1999-2023 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 #
 # Miscellaneous shell functions that make use of the ebuild env but don't need
@@ -143,7 +143,24 @@ install_qa_check() {
 		chflags -R nosunlnk,nouunlnk "${ED}" 2>/dev/null
 	fi
 
-	[[ -d ${ED%/}/usr/share/info ]] && prepinfo
+	if [[ -d ${ED%/}/usr/share/info ]]; then
+		# Portage regenerates this on the installed system.
+		rm -f "${ED%/}"/usr/share/info/dir{,.info}{,.Z,.gz,.bz2,.lzma,.lz,.xz,.zst} \
+			|| die "rm failed"
+		# Recurse into subdirs. Remove this code after 2023-12-31. #899898
+		while read -r -d '' x; do
+			( shopt -s failglob; : "${x}"/.keepinfodir* ) 2>/dev/null \
+				&& continue
+			for f in "${x}"/dir{,.info}{,.Z,.gz,.bz2,.lzma,.lz,.xz,.zst}; do
+				if [[ -e ${f} ]]; then
+					eqawarn "QA Notice: Removing Info directory file '${f}'."
+					eqawarn "Relying on this behavior is deprecated and may"
+					eqawarn "cause file collisions in future."
+					rm -f "${f}" || die "rm failed"
+				fi
+			done
+		done < <(find "${ED%/}"/usr/share/info -mindepth 1 -type d -print0)
+	fi
 
 	# If binpkg-docompress is enabled, apply compression before creating
 	# the binary package.
@@ -251,9 +268,6 @@ install_qa_check() {
 			prepallstrip
 		fi
 	fi
-
-	# Portage regenerates this on the installed system.
-	rm -f "${ED%/}"/usr/share/info/dir{,.Z,.gz,.bz2,.lzma,.lz,.xz,.zst} || die "rm failed!"
 }
 
 __dyn_instprep() {
-- 
2.40.0