kernel-source/find-provides

45 lines
1.1 KiB
Bash

#! /bin/bash
# these are updated by the spec file
sourcedir=${0%/*}
builddir="$sourcedir/../BUILD"
filelist=$(mktemp -t ${0##*/}.XXXXXXXXXX)
trap "rm -f $filelist" EXIT
cat >"$filelist"
flavor=${1##*-}
/usr/lib/rpm/find-provides "$@" <"$filelist"
# HACK: find out what subpackage is this and just print the symsets
# computed in %build. We need to do it this way because the provided
# symsets are computed from the modules AND the reference symsets, which
# we don't see here.
subpack=
samemodules()
{
cmp -s <(sed -rn 's:.*/([^/]*\.ko)$:\1:p' "$1" | sort) \
<(sed -rn 's:.*/([^/]*\.ko)$:\1:p' "$2" | sort)
}
if ! grep -q '\.ko$' "$filelist"; then
# no modules, no symsets
exit 0
fi
if samemodules "$builddir"/base-modules "$filelist"; then
subpack=base
elif samemodules "$builddir"/main-modules "$filelist"; then
subpack=main
elif samemodules "$builddir"/unsupported-modules "$filelist"; then
subpack=extra
else
echo "find-provides: failed to determine which subpackage is this" >&2
exit 1
fi
ls "$builddir/$subpack-symsets" | sed -rn 's/^(.+)\.([a-z0-9]{16})/kernel('$flavor':\1) = \2/p'
exit 0