Merge pull request #284487 from alyssais/compressFirmwareXz

compressFirmwareXz: fix symlink type check
This commit is contained in:
K900 2024-01-28 14:17:03 +03:00 committed by GitHub
commit 50071d87c7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -3,7 +3,9 @@
firmware:
let
args = lib.optionalAttrs (firmware ? meta) { inherit (firmware) meta; };
args = {
allowedRequisites = [];
} // lib.optionalAttrs (firmware ? meta) { inherit (firmware) meta; };
in
runCommand "${firmware.name}-xz" args ''
@ -15,10 +17,13 @@ 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")"
if [ -f $target ]; then
if [ -f "${firmware}/$link" ]; then
ln -vs -- "''${target/^${firmware}/$out}.xz" "$out/$link.xz"
else
ln -vs -- "''${target/^${firmware}/$out}" "$out/$link"
fi
done
echo "Checking for broken symlinks:"
find -L $out -type l -print -execdir false -- '{}' '+'
''