[pacman-dev] [PATCH] makepkg: list files containing $srcdir (FS#31558)
Attached is a patch to resolve FS#31558 [1] Submitted it to the list at Allan's request :) Cheers, ~p [1] https://bugs.archlinux.org/task/31558
On 15/05/13 11:08, Phillip Smith wrote:
From 2730cfde03792ad847343d7339b7a8cacc6ff81e Mon Sep 17 00:00:00 2001 From: Phillip Smith <phillip.smith@naturesorganics.com.au> Date: Wed, 15 May 2013 11:04:03 +1000 Subject: [PATCH] makepkg: list files containing $srcdir (FS#31558)
when checking for files in a built package that contain references to $srcdir or $pkgdir_base, show the files that match to assist in debugging. ---
Much easier to review if the patch is sent inline....
scripts/makepkg.sh.in | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 75ddfe5..70d39b7 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -1606,11 +1606,15 @@ tidy_install() { done
# check for references to the build and package directory - 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" + srcdir_refs=$(cd "${pkgdir}" && find -type f -print0 | xargs -0 grep -I -l "${srcdir}") + if [[ -n $srcdir_refs ]] ; then + warning "$(gettext "The following files within the package reference %s")" "\$srcdir" + echo $srcdir_refs # quotes are important to maintain line breaks
The lack of quotes indicates that they are not that important! Also, are there issues with files with spaces? I think it should look like this (falconindy will correct me if not...) srcdir_refs=($(cd ...)) if [[ -n $s... warning... printf " %s\n" "${srcdir_refs[@]}"
+ fi + pkgdir_refs=$(cd "${pkgdir}" && find -type f -print0 | xargs -0 grep -I -l "${pkgdirbase}") + if [[ -n $pkgdir_refs ]] ; then + warning "$(gettext "The following files within the package reference %s")" "\$pkgdir" + echo "$pkgdir_refs" # quotes are important to maintain line breaks fi
if check_option "zipman" "y" && [[ -n ${MAN_DIRS[*]} ]]; then
On Sat, May 18, 2013 at 11:23:10AM +1000, Allan McRae wrote:
On 15/05/13 11:08, Phillip Smith wrote:
From 2730cfde03792ad847343d7339b7a8cacc6ff81e Mon Sep 17 00:00:00 2001 From: Phillip Smith <phillip.smith@naturesorganics.com.au> Date: Wed, 15 May 2013 11:04:03 +1000 Subject: [PATCH] makepkg: list files containing $srcdir (FS#31558)
when checking for files in a built package that contain references to $srcdir or $pkgdir_base, show the files that match to assist in debugging. ---
Much easier to review if the patch is sent inline....
scripts/makepkg.sh.in | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 75ddfe5..70d39b7 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -1606,11 +1606,15 @@ tidy_install() { done
# check for references to the build and package directory - 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" + srcdir_refs=$(cd "${pkgdir}" && find -type f -print0 | xargs -0 grep -I -l "${srcdir}") + if [[ -n $srcdir_refs ]] ; then
While it's equivalent, we've generally checked for array length by using something like: if (( ${#array[*]} )); then
+ warning "$(gettext "The following files within the package reference %s")" "\$srcdir" + echo $srcdir_refs # quotes are important to maintain line breaks
The lack of quotes indicates that they are not that important! Also, are there issues with files with spaces?
Allan is correct here -- there's problems with files containing spaces because of how the array is created
I think it should look like this (falconindy will correct me if not...)
srcdir_refs=($(cd ...)) if [[ -n $s... warning... printf " %s\n" "${srcdir_refs[@]}"
Close, but there's still word splitting issues here. I'd suggest something like: mapfile -t srcdir_refs < \ <(cd "$pkgdir" && find -type f -exec grep -Il "$srcdir" {} +)) d
+ fi + pkgdir_refs=$(cd "${pkgdir}" && find -type f -print0 | xargs -0 grep -I -l "${pkgdirbase}") + if [[ -n $pkgdir_refs ]] ; then + warning "$(gettext "The following files within the package reference %s")" "\$pkgdir" + echo "$pkgdir_refs" # quotes are important to maintain line breaks fi
if check_option "zipman" "y" && [[ -n ${MAN_DIRS[*]} ]]; then
Much easier to review if the patch is sent inline....
My apologies, I will do that from now on.
Close, but there's still word splitting issues here. I'd suggest something like:
mapfile -t srcdir_refs < \ <(cd "$pkgdir" && find -type f -exec grep -Il "$srcdir" {} +))
Thanks for the feedback guys; I've amended as below.
From 4882226a88927af791979729a1ac47c029b3844d Mon Sep 17 00:00:00 2001 From: Phillip Smith <fukawi2@gmail.com> Date: Mon, 20 May 2013 16:06:39 +1000 Subject: [PATCH] makepkg: list files containing $srcdir (FS#31558)
when checking for files in a built package that contain references to $srcdir or $pkgdir_base, show the files that match to assist in debugging. --- scripts/makepkg.sh.in | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 75ddfe5..1b3cc5a 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -1606,11 +1606,19 @@ tidy_install() { done # check for references to the build and package directory - if find "${pkgdir}" -type f -print0 | xargs -0 grep -q -I "${srcdir}" ; then - warning "$(gettext "Package contains reference to %s")" "\$srcdir" + mapfile -t srcdir_refs <<< $(cd "${pkgdir}" && find -type f -exec grep -I -l "$srcdir" {} \;) + if [[ -n ${srcdir_refs[*]} ]] ; then + warning "$(gettext "The following files within the package reference %s")" "\$srcdir" + for fname in ${srcdir_refs[*]} ; do + printf " %s\n" "$fname" + done fi - if find "${pkgdir}" -type f -print0 | xargs -0 grep -q -I "${pkgdirbase}" ; then - warning "$(gettext "Package contains reference to %s")" "\$pkgdir" + mapfile -t pkgdir_refs <<< $(cd "${pkgdir}" && find -type f -exec grep -I -l "${pkgdirbase}" {} \;) + if [[ -n ${pkgdir_refs[*]} ]] ; then + warning "$(gettext "The following files within the package reference %s")" "\$pkgdir" + for fname in ${pkgdir_refs[*]} ; do + printf " %s\n" "$fname" + done fi if check_option "zipman" "y" && [[ -n ${MAN_DIRS[*]} ]]; then -- 1.8.2.3
On Mon, May 20, 2013 at 04:07:57PM +1000, Phillip Smith wrote:
Much easier to review if the patch is sent inline....
My apologies, I will do that from now on.
Close, but there's still word splitting issues here. I'd suggest something like:
mapfile -t srcdir_refs < \ <(cd "$pkgdir" && find -type f -exec grep -Il "$srcdir" {} +))
Thanks for the feedback guys; I've amended as below.
Please use `git send-email`, do not just copy and paste. gmail really messes with the spaces when you do.
From 4882226a88927af791979729a1ac47c029b3844d Mon Sep 17 00:00:00 2001 From: Phillip Smith <fukawi2@gmail.com> Date: Mon, 20 May 2013 16:06:39 +1000 Subject: [PATCH] makepkg: list files containing $srcdir (FS#31558)
when checking for files in a built package that contain references to $srcdir or $pkgdir_base, show the files that match to assist in debugging. --- scripts/makepkg.sh.in | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 75ddfe5..1b3cc5a 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -1606,11 +1606,19 @@ tidy_install() { done
# check for references to the build and package directory - if find "${pkgdir}" -type f -print0 | xargs -0 grep -q -I "${srcdir}" ; then - warning "$(gettext "Package contains reference to %s")" "\$srcdir" + mapfile -t srcdir_refs <<< $(cd "${pkgdir}" && find -type f -exec grep -I -l "$srcdir" {} \;) + if [[ -n ${srcdir_refs[*]} ]] ; then + warning "$(gettext "The following files within the package reference %s")" "\$srcdir" + for fname in ${srcdir_refs[*]} ; do + printf " %s\n" "$fname" + done fi - if find "${pkgdir}" -type f -print0 | xargs -0 grep -q -I "${pkgdirbase}" ; then - warning "$(gettext "Package contains reference to %s")" "\$pkgdir" + mapfile -t pkgdir_refs <<< $(cd "${pkgdir}" && find -type f -exec grep -I -l "${pkgdirbase}" {} \;) + if [[ -n ${pkgdir_refs[*]} ]] ; then + warning "$(gettext "The following files within the package reference %s")" "\$pkgdir" + for fname in ${pkgdir_refs[*]} ; do + printf " %s\n" "$fname" + done fi
if check_option "zipman" "y" && [[ -n ${MAN_DIRS[*]} ]]; then -- 1.8.2.3
-- William Giokas | KaiSforza GnuPG Key: 0x73CD09CF Fingerprint: F73F 50EF BBE2 9846 8306 E6B8 6902 06D8 73CD 09CF
On 20 May 2013 16:21, William Giokas <1007380@gmail.com> wrote:
Please use `git send-email`, do not just copy and paste. gmail really messes with the spaces when you do.
I can't win. I think that's done, with any luck.
participants (4)
-
Allan McRae
-
Dave Reisner
-
Phillip Smith
-
William Giokas