#!/bin/sh # # Generate Supplements: lines for the kernel-firmware package, by looking at # the firmware: and alias: fields of kernel modules. Ideally, this script # should be run automatically during each build, the problem is that # kernel-firmware is a noarch package, but the kernel packages differ among # architectures, so the results could change randomly. For now, run this # script manually against the i586 desktop kernel, like this # # $ tar xf linux-firmware-$version.tar.bz2 # $ ./firmware-supplements.sh linux-firmware-$version \ # kernel-desktop-*.i586.rpm >firmware-supplements.txt USAGE="$0 [kernel directory] $0 kernel.rpm" usage() { echo "$USAGE" >&2 exit 1 } fw_dir="$1" kernel="$2" if ! test -d "$fw_dir"; then usage fi trap 'rm -rf "$tmp"' EXIT tmp=$(mktemp -d) get_kernel_dir() { # default if test -z "$kernel"; then kernel="/lib/modules/$(uname -r)/kernel" if ! test -d "$kernel"; then echo "No kernel found below /lib/modules/$(uname -r)" >&2 usage fi return fi # /lib/modules/$version ? if test -d "$kernel/kernel"; then kernel="$_" return fi # just $version ? if test -d "/lib/modules/$kernel/kernel"; then kernel="$_" return fi # a kernel rpm? case "$kernel" in *.rpm) mkdir "$tmp/kernel" rpm2cpio "$kernel" | (cd "$tmp/kernel"; cpio -id) kernel="$tmp/kernel" return esac usage } get_kernel_dir find "$kernel" -name '*.ko' -type f | while read ko; do firmware=$(/sbin/modinfo -F firmware "$ko") for fw in $firmware; do if test -f "$fw_dir/$fw"; then echo "$ko" break fi done done | sort | /usr/lib/rpm/find-supplements.ksyms | \ sed 's/^modalias(kernel-[^:]*:/modalias(/' # strip the kernel-$flavor: prefix