[PATCH] makepkg: Handle invalid files in strip

Morten Linderud foxboron at archlinux.org
Sat Jan 1 17:51:53 UTC 2022


From: Morten Linderud <morten at linderud.pw>

makepkg does a fairly naive pass on the DWARF files to generate source
files. If this is done on things like Golang it will give strip a list
of files that are truncated paths or completely invalid virtual paths
for the runtime to interpret.

We also explicitly only allow source files that contains the given debug
source directory. We depend on this for file lookup and it would produce
invalid packages with weird paths if they are not present.

Signed-off-by: Morten Linderud <morten at linderud.pw>
---
 scripts/libmakepkg/tidy/strip.sh.in | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/scripts/libmakepkg/tidy/strip.sh.in b/scripts/libmakepkg/tidy/strip.sh.in
index 92a6fb15..d9eb8a95 100644
--- a/scripts/libmakepkg/tidy/strip.sh.in
+++ b/scripts/libmakepkg/tidy/strip.sh.in
@@ -60,11 +60,11 @@ strip_file() {
 		while IFS= read -r t; do
 			file=${t/${dbgsrcdir}/"$srcdir"}
 			dest="${dbgsrc/"$dbgsrcdir"/}$t"
-			if ! [[ -f $dest ]]; then
+			if [[ -f "$file" ]] && ! [[ -f $dest ]]; then
 				mkdir -p "${dest%/*}"
 				cp -- "$file" "$dest"
 			fi
-		done < <(source_files "$binary")
+		done < <(source_files "$binary" | grep "$dbgsrcdir")
 
 		# copy debug symbols to debug directory
 		mkdir -p "$dbgdir/${binary%/*}"
-- 
2.34.1



More information about the pacman-dev mailing list