libmakepkg/strip: don't re-add the same debug source multiple times

It's either a waste of work, or triggers edge cases in some packages
(like coreutils-8.31) where the source file is readonly and cp gets a
permission denied error trying to overwrite it with an identical copy of
itself.

Also while we are at it, make the variable names be something readable,
because I could barely tell what this was doing while editing it.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
(cherry picked from commit 3674144a74)
This commit is contained in:
Eli Schwartz 2020-05-11 00:16:30 -04:00 committed by Andrew Gregory
parent b3be0ce99b
commit 03cfe9e21c

View file

@ -56,11 +56,14 @@ strip_file() {
fi fi
# copy source files to debug directory # copy source files to debug directory
local f t local file dest t
while IFS= read -r t; do while IFS= read -r t; do
f=${t/${dbgsrcdir}/"$srcdir"} file=${t/${dbgsrcdir}/"$srcdir"}
mkdir -p "${dbgsrc/"$dbgsrcdir"/}${t%/*}" dest="${dbgsrc/"$dbgsrcdir"/}$t"
cp -- "$f" "${dbgsrc/"$dbgsrcdir"/}$t" if ! [[ -f $dest ]]; then
mkdir -p "${dest%/*}"
cp -- "$file" "$dest"
fi
done < <(source_files "$binary") done < <(source_files "$binary")
# copy debug symbols to debug directory # copy debug symbols to debug directory