summaryrefslogtreecommitdiff
path: root/autodeps/linux.prov
blob: b858e6f6fce4db1b9b948d6eb4e40a8d3053bf20 (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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/bin/bash

# This script reads filenames from STDIN and outputs any relevant provides
# information that needs to be included in the package.
IFS=$'\n'
filelist=($(cat))

debuginfolist=($(printf "%s\n" "${filelist[@]}" | grep "/usr/lib/debug/"))
filelist=($(printf "%s\n" "${filelist[@]}" | grep -v "/usr/lib/debug/"))

solist=($(printf "%s\n" "${filelist[@]}" | grep "\\.so" | grep -v "^/lib/ld.so" | \
	  tr '\n' '\0' | xargs -0 -r file -L | grep "ELF.*shared object" | \
	  cut -d: -f1))
pythonlist=($(printf "%s\n" "${filelist[@]}" | egrep '/usr/bin/python.\..$'))
tcllist=
monolist=($(printf "%s\n" "${filelist[@]}" | egrep "\\.(exe|dll)\$"))
firmwarelist=($(printf "%s\n" "${filelist[@]}" | grep "/lib/firmware/"))

#
# --- Alpha does not mark 64bit dependencies
case `uname -m` in
  alpha*)	mark64=false ;;
  *)		mark64=true ;;
esac

#
# --- Library sonames and weak symbol versions (from glibc).
for f in "${solist[@]}"; do
    soname=$(objdump -p "$f" | awk '/SONAME/ {print $2}')
    [ -n "$soname" -a -L "$f" ] && continue
    [ -z "$soname" ] && soname="${f##*/}"

    if $mark64 && file -L "$f" 2>/dev/null | grep "ELF 64-bit" >/dev/null; then
	lib64="()(64bit)" slib64="(64bit)"
    else
	lib64= slib64=
    fi
    echo "$soname$lib64"
    objdump -p "$f" | awk '
	BEGIN { START=0 ; }
	/Version definitions:/ { START=1; }
	/^[0-9]/ && (START==1) { print $4; }
	/^$/ { START=0; }
    ' | \
	while read symbol ; do
	    echo "$soname($symbol)$slib64"
	done
done | sort -u

#
# --- Perl modules.
[ -x /usr/lib/rpm/perl.prov ] &&
    printf "%s\n" "${filelist[@]}" | grep '\.pm$' | /usr/lib/rpm/perl.prov | sort -u

#
# --- Python modules.
[ -x /usr/lib/rpm/pythondeps.sh -a -n "$pythonlist" ] &&
    printf "%s\n" "${pythonlist[@]}" | /usr/lib/rpm/pythondeps.sh -P | sort -u

#
# --- Tcl modules.
[ -x /usr/lib/rpm/tcl.prov -a -n "$tcllist" ] &&
    printf "%s\n" "${tcllist[@]}" | /usr/lib/rpm/tcl.prov | sort -u

#
# --- firmware files
[ -x /usr/lib/rpm/firmware.prov -a -n "$firmwarelist" ] &&
     printf "%s\n" "${firmwarelist[@]}" | /usr/lib/rpm/firmware.prov | sort -u

#
# --- debuginfo files
[ -x /usr/lib/rpm/debuginfo.prov -a -n "$debuginfolist" ] &&
     printf "%s\n" "${debuginfolist[@]}" | /usr/lib/rpm/debuginfo.prov | sort -u

#
# --- Mono exes/dlls
: ${MONO_PREFIX=/usr}
if [ -x $MONO_PREFIX/bin/mono -a -n "$monolist" ] ; then
    printf "%s\n" "${monolist[@]}" | MONO_PATH=$MONO_PREFIX/lib${MONO_PATH:+:$MONO_PATH} prefix=$MONO_PREFIX $MONO_PREFIX/bin/mono-find-provides || echo "WARNING: MONO RPM PROVIDES WERE NOT GENERATED FOR THIS BUILD!!" 1>&2
fi

#
# --- Kernel module exported symbols
[ -x /usr/lib/rpm/find-provides.ksyms ] &&
    printf "%s\n" "${filelist[@]}" | /usr/lib/rpm/find-provides.ksyms "$@"

exit 0