1
0
kernel-firmware/install-split.sh
Takashi Iwai 6d5f1a9f23 Accepting request 723804 from home:tiwai:fw-compress3
- Move documents and license texts into the proper section
- Remove spurious non-firmware files
- Restructure the packaging for reducing the storage footprint
  (bsc#1143959):
  the firmware files are split into several subpackages, so that user
  doesn't need to install unnecessary files.  Each package has
  supplements entries that are generated from the static list (that
  was created from the current and old TW kernel binaries).
  There is a catch-all package, kernel-firmware-all, and this
  provides/obsoletes the former kernel-firmware package.  And each
  firmware file is compressed in XZ format for the new kernel (5.3 or
  later).
  For the systems with older kernels, we still provide the old'n'good
  kernel-firmware.rpm, containing everything in the raw format, too.
  This kernel-firmware.rpm will be obsoleted once when
  kernel-firmware-all above is installed.
  The build of both flavors are done in the multibuild.  Without the
  flavor, the raw kernel-firmware.rpm and ucode-amd.rpm are built,
  while the new kernel firmware packages are built in "compressed"
  flavor (-M compressed).

OBS-URL: https://build.opensuse.org/request/show/723804
OBS-URL: https://build.opensuse.org/package/show/Kernel:HEAD/kernel-firmware?expand=0&rev=266
2019-08-15 17:52:36 +00:00

105 lines
2.1 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 well.
#
# usage: install-split.sh topics.list DESTDIR < WHENCE
#
topics="$1"
DESTDIR="$2"
fwdir=/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"
test -f "$dest/$f$cext" && return
local lf=$(readlink "$f")
make_dirs "$f"
ln -sf "$lf$cext" "$dest/$f$cext"
echo "\"$fwdir/$f$cext\"" >> files-$topic
}
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 "$dest/$f"
echo "\"$fwdir/$f$cext\"" >> files-$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
if [ -n "$topic" ]; then
if [ ! -s files-$topic ]; then
echo "%dir /lib/firmware" > 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')
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/ ->.*$//')
copy_link "$f"
;;
esac
done