aboutsummaryrefslogtreecommitdiffstats
path: root/find-provides.in
blob: b03c952233096b9e1a20a25b415fe5a943232fab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/bin/bash

# This script reads filenames from STDIN and outputs any relevant provides
# information that needs to be included in the package.

filelist=`sed "s/['\"]/\\\&/g"`

# fix parsing output of objdump when localized (mga#7883):
export LC_ALL=C

#
# --- If libperl.so is found in buildroot, we provide perlapi-<version>
if [ -n "`echo $filelist | grep -e '/CORE/libperl\.so'`" ]; then
    for i in $filelist; do
        if [ -n "`echo $i | grep -e '/CORE/libperl\.so\$'`" ]; then
            perlpath=$i
            version=${i/CORE*/}
            version=$(echo $version| sed -e 's!/$!!' -e 's!/[^/]*$!!' -e 's!.*/!!')
            minor=$(echo $version| sed -e 's!^.*\.!!')
            major=$(echo $version| sed -e 's!\.[0-9]*$!!')
            if [ -n "$version" ] && [ -n "$minor" ]; then
               for i in $(seq 0 $minor); do echo "perlapi-$major.$i"; done
            fi
        fi
    done
fi

#
# --- Kernel modules.
[ -x @RPMVENDORDIR@/kmod.prov ] &&
    echo "$filelist" | tr '[:blank:]' \\n | @RPMVENDORDIR@/kmod.prov | sort -u \
    	&& test ${PIPESTATUS[2]} -ne 0 && echo 'error: @RPMVENDORDIR@/kmod.prov failed' >&2 && exit 1

#
# --- .so files.
for i in `echo $filelist | tr '[:blank:]' "\n" | egrep '(/usr(/X11R6)?)?/lib(|64)(/gcc(-lib)?/.+)?/[^/]+\.so$'`; do
    objd=`objdump -p ${i} | grep SONAME`
    [ -h ${i} -a -n "${objd}" ] && \
    lib64=`if file -L $i 2>/dev/null | grep "ELF 64-bit" >/dev/null; then echo "(64bit)"; fi` && \
    echo ${objd} | perl -p -e "s/.*SONAME\s+(\S+)\.so.*/devel(\1$lib64)/g"
done | sort -u

exit 0