compressFirmwareXz: fix links to directories

Only add the `.xz` suffix to links if link target is a regular file.
This breaks if the target is a directory.

Fixes #283005.
This commit is contained in:
Franz Pletz 2024-01-23 07:16:59 +01:00
parent 379bf3e0e6
commit 14f83d5c6f
No known key found for this signature in database
GPG Key ID: 846FDED7792617B4

View File

@ -15,6 +15,10 @@ runCommand "${firmware.name}-xz" args ''
sh -c 'xz -9c -T1 -C crc32 --lzma2=dict=2MiB "${firmware}/$1" > "$1.xz"' --)
(cd ${firmware} && find lib/firmware -type l) | while read link; do
target="$(readlink "${firmware}/$link")"
ln -vs -- "''${target/^${firmware}/$out}.xz" "$out/$link.xz"
if [ -f $target ]; then
ln -vs -- "''${target/^${firmware}/$out}.xz" "$out/$link.xz"
else
ln -vs -- "''${target/^${firmware}/$out}" "$out/$link"
fi
done
''