File find-provides of Package kernel-source

#! /bin/bash

sourcedir=${0%/*}
builddir=$1
shift

trap 'rm -f "$filelist"' EXIT
filelist=$(mktemp -t ${0##*/}.XXXXXXXXXX)
cat >"$filelist"
shopt -s nullglob

# HACK: do not provide anything in the -base package (it's unlikely to be
# used together with KMPs
# HACK2: the base package is defined as a package with less that 200 modules
if grep -q '/boot/System\.map\>' "$filelist" &&
	test 0$(grep -c '\.ko$' "$filelist") -lt 200; then
	exit 0
fi

# HACK3: do not provide any symbols for the vanilla kernel (only keep the 
# debuginfo provides)
if test "$1" = "kernel-vanilla"; then
	sed -ni '\:/usr/lib/debug/:p' "$filelist"
fi

# HACK4: kill firmware(...) provides, nobody needs them
sed -i '\:/lib/firmware:d' "$filelist"

# pretend that /boot/vmlinux-* is in the -base/main package and not in -devel
if grep -q '/boot/System\.map\>' "$filelist"; then
	prefix=$(sed -rn 's:(.*)/boot/System\.map\>.*:\1:p; T; q' "$filelist")
	for f in "$prefix"/boot/vmlinux*; do
		echo "$f" >>"$filelist"
	done
else
	perl -ni -e 'next if /\/boot\/vmlinux/ && !/\.debug$/; print' "$filelist"
fi

/usr/lib/rpm/find-provides "$@" <"$filelist" | \
	"$sourcedir"/kabi.pl --filter-symbols \
	--rules="$builddir"/kabi/severities \
	"$builddir"/linux-obj/Module.symvers.split
openSUSE Build Service is sponsored by