Whamcloud - gitweb
LU-10026 osd-ldiskfs: use preallocation for dense writes
[fs/lustre-release.git] / rpm / find-provides
1 #!/bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3
4 #
5 # This file is part of Lustre, http://www.lustre.org/
6 #
7 # rpm/find-provides
8 #
9 # This script reads filenames from STDIN and outputs any relevant provides
10 # information that needs to be included in the package.
11 #
12
13 if [ "$1" ]
14 then
15     package_name="$1"
16 fi
17
18 filelist=`sed "s/['\"]/\\\&/g"`
19
20 [ -x /usr/lib/rpm/rpmdeps -a -n "$filelist" ] &&
21     echo $filelist | tr '[:blank:]' \\n | /usr/lib/rpm/rpmdeps --provides
22
23 #
24 # --- any other extra find-provides scripts
25 for i in /usr/lib/rpm/redhat/find-provides.d/*.prov
26 do
27     [ -x $i ] &&
28         (echo $filelist | tr '[:blank:]' \\n | $i | sort -u)
29 done
30
31 #
32 # --- Kernel module imported symbols
33 #
34 # Since we don't (yet) get passed the name of the package being built, we
35 # cheat a little here by looking first for a kernel, then for a kmod.
36 #
37
38 is_kmod=1
39 for f in $filelist; do
40     if [ $(echo "$f" | sed -r -ne 's:^.*/lib/modules/(.*)/(.*)\.ko(\.gz|\.bz2|\.xz)?$:\2:p') ]
41     then
42         is_kernel=1;
43     fi
44     if [ $(echo "$f" | sed -r -ne 's:^.*/boot/(.*):\1:p') ]
45     then
46         unset is_kmod;
47     fi
48 done
49 if [ ! "$is_kernel" ] || [ "$package_name" == "kernel" ]
50 then
51     unset is_kmod
52 fi
53
54 FIND_PROVIDES_KSYMS=/usr/lib/rpm/redhat/find-provides.ksyms
55 MODULE_SYMVERS=$RPM_BUILD_ROOT/Module.symvers
56 if [[ -f $MODULE_SYMVERS ]] ; then
57     _sourcedir=$(realpath $(dirname "$0"))
58     FIND_PROVIDES_KSYMS=$_sourcedir/find-provides.ksyms
59 else
60     >&2 echo "*****************************************************************"
61     >&2 echo "$MODULE_SYMVERS not found."
62     >&2 echo "Falling back to redhad find-provides.ksyms"
63     >&2 echo "*****************************************************************"
64 fi
65
66 [ -x $FIND_PROVIDES_KSYMS ] && [ "$is_kmod" ] &&
67     printf "%s\n" "${filelist[@]}" | $FIND_PROVIDES_KSYMS
68
69 exit 0