From 7fc29959e34e7604a4e75d3c28c81e917460175d Mon Sep 17 00:00:00 2001 From: Christian Heusel <christian@heusel.eu> Date: Wed, 2 Aug 2023 12:33:59 +0200 Subject: [PATCH] dbscripts: make createlinks also work if filename contains spaces This addresses the problem that so far the for loop recognizes each filename with a space as different word, i.e.: $ for f in $(find pkg -type f); do echo "$f"; done pkg/usr/bin/Surge XT Effects pkg/usr/bin/Surge XT while the correct output would have been: pkg/usr/bin/Surge XT Effects pkg/usr/bin/Surge XT We fix this by just passing everything directly via xargs to readelf, which also removes the loop overhead. This also results in a significant speedup for packages with a lot of libraries and binaries. fixes https://gitlab.archlinux.org/archlinux/infrastructure/-/issues/524 Signed-off-by: Christian Heusel <christian@heusel.eu> --- roles/dbscripts/files/createlinks | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/roles/dbscripts/files/createlinks b/roles/dbscripts/files/createlinks index cc99f0f0a..861ba8845 100755 --- a/roles/dbscripts/files/createlinks +++ b/roles/dbscripts/files/createlinks @@ -44,9 +44,7 @@ for repo in ${repos[@]}; do echo "$repo/$arch: $pkgname" mkdir -p ${tmppkgdir}/pkg bsdtar -xof $pkg -C ${tmppkgdir}/pkg --include={opt,{,usr/}{lib{,32},{s,}bin}}'/*' 2>/dev/null - for f in $(find ${tmppkgdir}/pkg -type f); do - readelf -d "$f" 2> /dev/null | sed -nr 's/.*Shared library: \[(.*)\].*/\1/p' - done | sort -u > ${tmppkgdir}/links + find "${tmppkgdir}/pkg" -type f -print0 | xargs -0 readelf -d 2> /dev/null | sed -nr 's/.*Shared library: \[(.*)\].*/\1/p' | sort -u > "${tmppkgdir}/links" rm -rf ${tmppkgdir}/pkg fi done -- GitLab