setup-hooks/separate-debug-info.sh: make deterministic

If multiple files with the same build id were found, we silently randomly
overwrote one with the other.

Change the order to make the output deterministic, and emit a
warning when overwriting.
This commit is contained in:
Arnout Engelen 2023-04-23 11:53:47 +02:00
parent 645bc49f34
commit 9156daa547
No known key found for this signature in database
GPG key ID: 061107B0F74A6DAA

View file

@ -36,10 +36,14 @@ _separateDebugInfo() {
# architecture than we're building for. (This happens with
# firmware blobs in QEMU.)
(
if [ -f "$dst/${id:0:2}/${id:2}.debug" ]
then
echo "separate-debug-info: warning: multiple files with build id $id found, overwriting"
fi
$OBJCOPY --only-keep-debug "$i" "$dst/${id:0:2}/${id:2}.debug"
# Also a create a symlink <original-name>.debug.
ln -sfn ".build-id/${id:0:2}/${id:2}.debug" "$dst/../$(basename "$i")"
) || rmdir -p "$dst/${id:0:2}"
done < <(find "$prefix" -type f -print0)
done < <(find "$prefix" -type f -print0 | sort -z)
}