Re: [pacman-dev] [PATCH v3] makepkg: print files with refs to $srcdir/$pkgdir

2016-10-17 Thread Allan McRae
On 16/10/16 09:34, ivy.fos...@gmail.com wrote:
> From: Ivy Foster 
> 
> Since rewriting build_references() anyway, tweaked quoting.
> Implements FS#31558.
> 
> Signed-off-by: Ivy Foster 
> ---
>  scripts/libmakepkg/lint_package/build_references.sh.in | 16 +---
>  1 file changed, 9 insertions(+), 7 deletions(-)
> 
> diff --git a/scripts/libmakepkg/lint_package/build_references.sh.in 
> b/scripts/libmakepkg/lint_package/build_references.sh.in
> index 67c14e6..b9958c8 100644
> --- a/scripts/libmakepkg/lint_package/build_references.sh.in
> +++ b/scripts/libmakepkg/lint_package/build_references.sh.in
> @@ -25,14 +25,16 @@ LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
>  
>  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"
> - fi
> - if find "${pkgdir}" -type f -print0 | xargs -0 grep -q -I 
> "${pkgdirbase}" ; then
> - warning "$(gettext "Package contains reference to %s")" 
> "\$pkgdir"
> - fi
> + local refs
> +
> + for var in srcdir pkgdir; do
> + mapfile -t refs < <(find "$pkgdir" -type f -exec grep -l 
> "${!var}" {} +)
> + if  [[ ${#refs} -gt 0 ]]; then

Our style used (( )) style tests for number tests.  So this will become

if (( ${#refs} > 0 )); then

I will make this change when I apply.

Thanks,
Allan


[pacman-dev] [PATCH v3] makepkg: print files with refs to $srcdir/$pkgdir

2016-10-15 Thread ivy . foster
From: Ivy Foster 

Since rewriting build_references() anyway, tweaked quoting.
Implements FS#31558.

Signed-off-by: Ivy Foster 
---
 scripts/libmakepkg/lint_package/build_references.sh.in | 16 +---
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/scripts/libmakepkg/lint_package/build_references.sh.in 
b/scripts/libmakepkg/lint_package/build_references.sh.in
index 67c14e6..b9958c8 100644
--- a/scripts/libmakepkg/lint_package/build_references.sh.in
+++ b/scripts/libmakepkg/lint_package/build_references.sh.in
@@ -25,14 +25,16 @@ LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
 
 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"
-   fi
-   if find "${pkgdir}" -type f -print0 | xargs -0 grep -q -I 
"${pkgdirbase}" ; then
-   warning "$(gettext "Package contains reference to %s")" 
"\$pkgdir"
-   fi
+   local refs
+
+   for var in srcdir pkgdir; do
+   mapfile -t refs < <(find "$pkgdir" -type f -exec grep -l 
"${!var}" {} +)
+   if  [[ ${#refs} -gt 0 ]]; then
+   warning "$(gettext 'Package contains reference to %s')" 
"\$$var"
+   printf '%s\n' "${refs[@]}" >&2
+   fi
+   done
 }
-- 
2.10.0