kernel-firmware/install-split.sh
Takashi Iwai 21af979ee5 Accepting request 1007671 from home:tiwai:branches:Kernel:HEAD
- Update to version 20220930 (git commit fdf1a6525852):
  * linux-firmware: Update AMD cpu microcode
  * mediatek: mt8195: Update scp.img to v2.0.11956
  * mediatek: Add new mt8195 SOF firmware
  * mediatek: Update mt8186 SOF firmware to v0.2.1
  * linux-firmware: update firmware for mediatek bluetooth chip (MT7922)
  * rtl_bt: Update RTL8852A BT USB firmware to 0xD9B8_8207
  * linux-firmware: update firmware for mediatek bluetooth chip (MT7921)
  * linux-firmware: update firmware for MT7922 WiFi device
  * linux-firmware: update firmware for MT7921 WiFi device
  * cxgb4: Update firmware to revision 1.27.0.0
  * i915: Add versionless HuC files for current platforms
  * i915: Add GuC v70.5.1 for DG1, DG2, TGL and ADL-P
  * qca: Update firmware files for BT chip WCN3991.
  * Removing crnv32
  * amdgpu: update yellow carp DMCUB firmware
  * amdgpu: add firmware for VCN 3.1.2 IP block
  * amdgpu: add firmware for SDMA 5.2.6 IP block
  * amdgpu: add firmware for PSP 13.0.5 IP block
  * amdgpu: add firmware for GC 10.3.6 IP block
  * amdgpu: add firmware for DCN 3.1.5 IP block
  * qcom: rename Lenovo ThinkPad X13s firmware paths
  * rtw89: 8852c: update fw to v0.27.42.0
  * rtw89: 8852c: update fw to v0.27.36.0
- Fix install-split.sh for dealing with a symlink of directory

OBS-URL: https://build.opensuse.org/request/show/1007671
OBS-URL: https://build.opensuse.org/package/show/Kernel:HEAD/kernel-firmware?expand=0&rev=388
2022-10-03 11:46:36 +00:00

136 lines
2.8 KiB
Bash

#!/bin/sh
#
# Read WHENCE from stdin and install the compressed firmware files into DESTDIR.
# The file list for each topic is created as files-xxx under the current dir.
#
# usage: install-split.sh [-v] topics.list DESTDIR < WHENCE
#
verbose=:
if [ x"$1" = x"-v" ]; then
verbose=echo
shift
fi
topics="$1"
DESTDIR="$2"
fwdir=${3:-/lib/firmware}
dest=$DESTDIR/$fwdir
do_compress=1
if [ -n "$do_compress" ]; then
cext=".xz"
else
cext=""
fi
make_dirs () {
local f="$1"
mkdir -p $(dirname "$dest/$f")
local d=$(dirname "$f")
if [ "$d" != "." ]; then
while true; do
if ! grep -q '%dir '"$fwdir/$d"'$' files-$topic; then
echo "%dir $fwdir/$d" >> files-$topic
fi
case "$d" in
*/*) d=${d%/*};;
*) break;;
esac
done
fi
}
copy_link () {
local f="$1"
local lf="$2"
local src
test -f "$dest/$f$cext" && return
if [ -z "$lf" ]; then
lf=$(readlink "$f")
src="$lf"
else
src="${f%/*}"
if [ "$src" = "$f" ]; then
src="$lf"
else
src="$src/$lf"
fi
fi
make_dirs "$f"
if [ -d "$dest/$src" ]; then
ln -sf "$lf" "$dest/$f"
echo "\"$fwdir/$f\"" >> files-$topic
$verbose "Link: $lf -> $f (directory) for topic $topic"
else
ln -sf "$lf$cext" "$dest/$f$cext"
echo "\"$fwdir/$f$cext\"" >> files-$topic
$verbose "Link: $lf$cext -> $f$cext for topic $topic"
fi
}
copy_file () {
local f="$1"
test -f "$dest/$f$cext" && return
make_dirs "$f"
install -c -m 0644 "$f" $(dirname "$dest/$f")
test -n "$do_compress" && xz -f -C crc32 --lzma2=dict=2MiB "$dest/$f"
echo "\"$fwdir/$f$cext\"" >> files-$topic
$verbose "Copy: $f$cext for topic $topic"
}
sub="xxx"
while read l; do
test -z "$l" && continue
case "$l" in
----*)
sub=""
topic=""
;;
Driver:*)
test -n "$sub" && continue
sub=$(echo "$l" | sed -e's/Driver: *//' -e's/[ :].*$//')
m=$(grep -m1 "^$sub": "$topics" | sed -e's/^.*:[[:space:]]*//')
test -z "$m" && continue
set -- $m
topic="$1"
if [ "$topic" = "SKIP" ]; then
continue
fi
$verbose "Switching to topic $topic"
if [ -n "$topic" ]; then
if [ ! -s files-$topic ]; then
echo "%dir $fwdir" > files-$topic
fi
fi
;;
File:*)
test "$topic" = "SKIP" && continue
if [ -z "$topic" ]; then
echo "ERROR: no topic found for $l"
exit 1
fi
f=$(echo "$l" | sed -e's/^File: *//' -e's/"//g' -e's/\\//g')
if [ -L "$f" ]; then
copy_link "$f"
else
copy_file "$f"
fi
;;
Link:*)
test "$topic" = "SKIP" && continue
if [ -z "$topic" ]; then
echo "ERROR: no topic found for $l"
exit 1
fi
f=$(echo "$l" | sed -e's/^Link: *//' -e's/ *->.*$//' -es'/\\//g')
d=$(echo "$l" | sed -e's/^.*-> *//' -e's/\\//g')
copy_link "$f" "$d"
;;
esac
done
exit 0