linux-firmware/debian/scripts/compress-firmware
Ward from fusion-voyager-3 1380bd6e25 add atk override
2024-07-22 02:28:18 +03:00

35 lines
621 B
Bash
Executable File

#!/bin/bash -eu
#
# Compress firmware blobs
#
if [ $# -ne 1 ] ; then
echo "Usage: compress-firmware <dirname>" >&2
exit 2
fi
if ! [ -d "${1}" ] ; then
echo "No such directory: ${1}" >&2
exit 1
fi
echo "Compress firmware files in ${1} ..."
while IFS= read -r f ; do
if [ "${f%.xz}" = "${f}" ] ; then
xz -F xz -C crc32 "${f}"
fi
done < <(find "${1}" -type f)
echo "Recreate symlinks in ${1} ..."
while IFS= read -r l ; do
if [ "${l%.xz}" = "${l}" ] ; then
t=$(readlink "${l}")
if ( cd "${l%/*}" && ! [ -d "${t}" ] ) ; then
ln -s "${t}".xz "${l}".xz
rm "${l}"
fi
fi
done < <(find "${1}" -type l)