find-provides fails to find module versions on newer
kernels.
The generated Module.symvers is always generated and
correct. Install it to the well known location BUILDROOT
use it to generate provides and ignore it for installation.
Create a new find-provides and find-provides.ksyms for
lustre based on the one provided by the redhat-rpm-config
package using Module.symvers to supply the symbol versions
instead of extracting symbol versions from the .ko files.
Lustre-change: https://review.whamcloud.com/49302
Lustre-commit:
bb951b90268bb013b55166e1c0bcae1c2a66b165
Test-Parameters: trivial
HPE-bug-id: LUS-11383
Signed-off-by: Shaun Tancheff <shaun.tancheff@hpe.com>
Change-Id: I01c3b3692e6a2a6be86a6930eaead9df75147f90
Reviewed-by: Petros Koutoupis <petros.koutoupis@hpe.com>
Reviewed-by: Jian Yu <yujian@whamcloud.com>
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/49785
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
#
# Top level generated files specific to this top level dir
#
+/find-provides
+/find-provides.ksyms
/.mergeinfo-*
/.pc
/.Xrefs-2.5
# response from them
#%%global _use_internal_dependency_generator 0
+%if 0%{?rhel} > 7 || 0%{?fedora} > 33
+## SUSE uses another tool for provides:
+## https://github.com/openSUSE/kernel-source/blob/master/patches.rpmify/Add-ksym-provides-tool.patch
+%global __find_provides %{_sourcedir}/find-provides
+%endif
+
# Set the package name prefix
%if %{undefined lustre_name}
%if %{with servers}
Source5: kmp-lustre-osd-zfs.preamble
Source6: kmp-lustre-osd-zfs.files
Source7: kmp-lustre-tests.files
+Source8: find-provides
+Source9: find-provides.ksyms
URL: https://wiki.whamcloud.com/
BuildRoot: %{_tmppath}/lustre-%{version}-root
%if %{with lustre_modules}
# Lustre's build system. This is not expected to bother SLES's
# kernel_module_path macro.
basemodpath=$RPM_BUILD_ROOT%{modules_fs_path}/%{name}
+%{__install} -D -m 0644 ${PWD}/Module.symvers %{buildroot}/Module.symvers
%if %{with ldiskfs}
mkdir -p $basemodpath-osd-ldiskfs/fs
mv $basemodpath/fs/osd_ldiskfs.ko $basemodpath-osd-ldiskfs/fs/osd_ldiskfs.ko
%config(noreplace) %{_sysconfdir}/lnet_routes.conf
%endif
%if %{with lustre_modules}
-
+%exclude /Module.symvers
%if %{with shared}
%if %{with ldiskfs}
%if %{with lustre_utils}
--- /dev/null
+#!/bin/bash
+
+# This script reads filenames from STDIN and outputs any relevant provides
+# information that needs to be included in the package.
+
+if [ "$1" ]
+then
+ package_name="$1"
+fi
+
+filelist=`sed "s/['\"]/\\\&/g"`
+
+[ -x /usr/lib/rpm/rpmdeps -a -n "$filelist" ] &&
+ echo $filelist | tr '[:blank:]' \\n | /usr/lib/rpm/rpmdeps --provides
+
+#
+# --- any other extra find-provides scripts
+for i in /usr/lib/rpm/redhat/find-provides.d/*.prov
+do
+ [ -x $i ] &&
+ (echo $filelist | tr '[:blank:]' \\n | $i | sort -u)
+done
+
+#
+# --- Kernel module imported symbols
+#
+# Since we don't (yet) get passed the name of the package being built, we
+# cheat a little here by looking first for a kernel, then for a kmod.
+#
+
+is_kmod=1
+for f in $filelist; do
+ if [ $(echo "$f" | sed -r -ne 's:^.*/lib/modules/(.*)/(.*)\.ko(\.gz|\.bz2|\.xz)?$:\2:p') ]
+ then
+ is_kernel=1;
+ fi
+ if [ $(echo "$f" | sed -r -ne 's:^.*/boot/(.*):\1:p') ]
+ then
+ unset is_kmod;
+ fi
+done
+if [ ! "$is_kernel" ] || [ "$package_name" == "kernel" ]
+then
+ unset is_kmod
+fi
+
+FIND_PROVIDES_KSYMS=/usr/lib/rpm/redhat/find-provides.ksyms
+MODULE_SYMVERS=$RPM_BUILD_ROOT/Module.symvers
+if [[ -f $MODULE_SYMVERS ]] ; then
+ _sourcedir=$(realpath $(dirname "$0"))
+ FIND_PROVIDES_KSYMS=$_sourcedir/find-provides.ksyms
+else
+ >&2 echo "*****************************************************************"
+ >&2 echo "$MODULE_SYMVERS not found."
+ >&2 echo "Falling back to redhad find-provides.ksyms"
+ >&2 echo "*****************************************************************"
+fi
+
+[ -x $FIND_PROVIDES_KSYMS ] && [ "$is_kmod" ] &&
+ printf "%s\n" "${filelist[@]}" | $FIND_PROVIDES_KSYMS
+
+exit 0
--- /dev/null
+#! /bin/bash
+
+IFS=$'\n'
+
+MODULE_SYMVERS=$RPM_BUILD_ROOT/Module.symvers
+
+for module in $(grep -E '/lib/modules/.+\.ko(\.gz|\.bz2|\.xz)?$'); do
+ tmpfile=""
+ if [ "x${module%.ko}" = "x${module}" ]; then
+ tmpfile=$(mktemp -t ${0##*/}.XXXXXX.ko)
+ proc_bin=
+ case "${module##*.}" in
+ xz)
+ proc_bin=xz
+ ;;
+ bz2)
+ proc_bin=bzip2
+ ;;
+ gz)
+ proc_bin=gzip
+ ;;
+ esac
+
+ [ -n "$proc_bin" ] || continue
+
+ "$proc_bin" -d -c - < "$module" > "$tmpfile" || continue
+ module="$tmpfile"
+ fi
+
+ if [[ -f $MODULE_SYMVERS ]] ; then
+ # all symbols prefixed with __rcr_ where the symbol is:
+ # A - symbol is an absolute value
+ # D,d - symbol is in the initialized data section
+ # R,r - symbol is in the read-only data section
+ # T,t - symbol is in the text (code) section
+ for sym in $(nm $module | sed -r -ne 's:^0*([0-9a-f]+) [ADdRr] __crc_(.+):\2:p'); do
+ grep -w $sym $MODULE_SYMVERS | awk '{printf("ksym(%s) = %08s\n", $2, $1)}'
+ done \
+ | LC_ALL=C sort -u
+ else
+ >&2 echo "Module.symvers required for provides."
+ fi
+ [ -z "$tmpfile" ] || rm -f -- "$tmpfile"
+done