[pacman-dev] [PATCH] Files that contain references to srcdir and pkgdir are listed
Fixes FS#31558
Signed-off-by: Ashley Whetter ashley@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" {} + }
On 26/05/16 07:21, Ashley Whetter wrote:
Fixes FS#31558
Signed-off-by: Ashley Whetter ashley@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"
fiprintf " %s\n" "${refs[@]}"
- 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() {
Why make this a separate function for one line?
- if [[ -z "$1" ]]; then
fireturn 1
- find -type f -exec grep -Il "$1" {} +
}
I don't think a separte "warn_single_build_references" function is needed either. We can loop! What about (totally untested...)
warn_build_references() { for v in "srcdir" "pkgdir"; do mapfile -t refs < <(cd "$pkgdir" && find -type f -exec grep -Il "${!v}" {} + if (( ${#refs[*]} )); then warning "$(gettext "Package contains reference to %s")" "$$v" printf " %s\n" "${refs[@]}" ...
participants (2)
-
Allan McRae
-
Ashley Whetter