[pacman-dev] [PATCH] Files that contain references to srcdir and pkgdir are listed

Ashley Whetter ashley at awhetter.co.uk
Wed May 25 21:21:01 UTC 2016


Fixes FS#31558

Signed-off-by: Ashley Whetter <ashley at awhetter.co.uk>
---
 .../libmakepkg/lint_package/build_references.sh.in | 22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)

diff --git a/scripts/libmakepkg/lint_package/build_references.sh.in b/scripts/libmakepkg/lint_package/build_references.sh.in
index 67c14e6..dd6b88c 100644
--- a/scripts/libmakepkg/lint_package/build_references.sh.in
+++ b/scripts/libmakepkg/lint_package/build_references.sh.in
@@ -29,10 +29,24 @@ source "$LIBRARY/util/message.sh"
 lint_package_functions+=('warn_build_references')
 
 warn_build_references() {
-	if find "${pkgdir}" -type f -print0 | xargs -0 grep -q -I "${srcdir}" ; then
-		warning "$(gettext "Package contains reference to %s")" "\$srcdir"
+	warn_single_build_references "$srcdir" srcdir
+	warn_single_build_references "$pkgdirbase" pkgdir
+}
+
+warn_single_build_references() {
+	local to_find=$1 ref_name=$2
+
+	mapfile -t refs < <(cd "$pkgdir" && find_files_that_ref "$to_find")
+	if (( ${#refs[*]} )); then
+		warning "$(gettext "Package contains reference to %s")" "\$$ref_name"
+		printf "  %s\n" "${refs[@]}"
 	fi
-	if find "${pkgdir}" -type f -print0 | xargs -0 grep -q -I "${pkgdirbase}" ; then
-		warning "$(gettext "Package contains reference to %s")" "\$pkgdir"
+}
+
+find_files_that_ref() {
+	if [[ -z "$1" ]]; then
+		return 1
 	fi
+
+	find -type f -exec grep -Il "$1" {} +
 }
-- 
2.8.2


More information about the pacman-dev mailing list