From 672ec5d6743a5c14682550b14cdf972dbea56fa6 Mon Sep 17 00:00:00 2001
From: Alexander Golubev <fatzer2@gmail.com>
Date: Thu, 30 Jul 2026 20:16:23 +0300
Subject: metadata/install-qa-check.d: add 08gentoo-paths

Copy an install-qa-check from Gentoo upstream (with no changes yet) to
override it locally in subsequent commits so it won't be triggered by
/usr/tqt3 and /usr/trinity paths.

Bug: https://mirror.git.trinitydesktop.org/gitea/TDE/tde-packaging-gentoo/issues/262
Bug: https://mirror.git.trinitydesktop.org/gitea/TDE/tde-packaging-gentoo/issues/519
Signed-off-by: Alexander Golubev <fatzer2@gmail.com>
---
 metadata/install-qa-check.d/08gentoo-paths | 84 ++++++++++++++++++++++++++++++
 1 file changed, 84 insertions(+)
 create mode 100644 metadata/install-qa-check.d/08gentoo-paths

diff --git a/metadata/install-qa-check.d/08gentoo-paths b/metadata/install-qa-check.d/08gentoo-paths
new file mode 100644
index 00000000..0b92a7a1
--- /dev/null
+++ b/metadata/install-qa-check.d/08gentoo-paths
@@ -0,0 +1,84 @@
+# Check whether ebuilds are not installing new, non-Gentoo-ey paths.
+
+# QA check: validate Gentoo's filesystem layout policies
+# Maintainer: Portage team <dev-portage@gentoo.org>
+
+gentoo_path_check() {
+	# allowed path definitions
+	# ------------------------
+
+	# directories common to / and /usr
+	local allowed_common_dirs=(
+		bin lib lib32 lib64 libx32 sbin
+	)
+
+	# toplevel directories which can be installed to by ebuilds
+	# /home is not included as no ebuilds should install files there
+	local allowed_paths_toplevel=(
+		"${allowed_common_dirs[@]}"
+		boot dev etc opt srv usr var
+	)
+
+	# directories in /usr which can be installed to by ebuilds
+	# /usr/games is not included as it is banned nowadays
+	local allowed_paths_usr=(
+		"${allowed_common_dirs[@]}"
+		include libexec share src
+		# toolchain stuff
+		"${CHOST}" "${CTARGET}"
+	)
+
+
+	# the logic
+	# ---------
+	local bad_paths=()
+	local x
+
+	local shopt_save=$(shopt -p nullglob)
+	shopt -s nullglob
+
+	# 1. check for unexpected top-level directories
+	local toplevel_dirs=( "${ED%/}"/* )
+	for x in "${toplevel_dirs[@]##*/}"; do
+		if ! has "${x}" "${allowed_paths_toplevel[@]}"; then
+			bad_paths+=( "/${x}" )
+		fi
+	done
+
+	# 2. check for unexpected /usr subdirectories
+	local usr_dirs=( "${ED%/}"/usr/* )
+	for x in "${usr_dirs[@]##*/}"; do
+		if ! has "${x}" "${allowed_paths_usr[@]}"; then
+			bad_paths+=( "/usr/${x}" )
+		fi
+	done
+
+	# 3. check for unexpected subdirectories in bin and sbin
+	local bin_subdirs=( "${ED%/}"{,/usr}/{bin,sbin}/*/ )
+	bad_paths+=( "${bin_subdirs[@]%/}" )
+
+	# 4. check for unexpected /usr/share/doc subdirectories
+	local doc_dirs=( "${ED%/}"/usr/share/doc/* )
+	for x in "${doc_dirs[@]##*/}"; do
+		if [[ ${x} != ${PF} ]]; then
+			bad_paths+=( "/usr/share/doc/${x}" )
+		fi
+	done
+
+	${shopt_save}
+
+	# report
+	# ------
+	if [[ -n ${bad_paths[@]} ]]; then
+		eqawarn "QA Notice: The ebuild is installing to one or more unexpected directories:"
+		eqawarn
+		eqatag -v non-gentoo-paths "${bad_paths[@]#${D%/}}"
+		eqawarn
+		eqawarn "Please fix the ebuild to use correct FHS/Gentoo policy paths."
+	fi
+}
+
+gentoo_path_check
+: # guarantee successful exit
+
+# vim:ft=sh
-- 
cgit v1.2.3

