]> git.ipfire.org Git - people/ms/pakfire.git/blob - tools/find-provides
Speed up dependency detection.
[people/ms/pakfire.git] / tools / find-provides
1 #!/bin/bash
2
3 # Include functions.
4 BASEDIR=$(dirname ${0})
5 source ${BASEDIR}/find-common
6
7 BUILDROOT=${1}
8 FILELIST=${2}
9
10 binary_files=
11 perl_files=
12 pkgconfig_files=
13
14 # Walk through all file files and see what we have got here.
15 while read file; do
16 case "${file}" in
17 */usr/lib/debug/*|*/usr/src/debug/*)
18 # Skip all debuginfo files.
19 continue
20 ;;
21 */usr/lib*/python*/*.so*)
22 # Do not show python shared objects in provides list.
23 ;;
24 */usr/lib*/gconv/*)
25 # Skip gconv files.
26 continue
27 ;;
28 *.so*)
29 # Skip symlinks for performance reasons.
30 [ -L "${file}" ] && continue
31
32 file_is_elf ${file} >/dev/null 2>&1 && \
33 binary_files="${binary_files} ${file}"
34 ;;
35 *.pm)
36 # This file is a perl module. We check them later.
37 perl_files="${perl_files} ${file}"
38 ;;
39 *.pc)
40 pkgconfig_files="${pkgconfig_files} ${file}"
41 ;;
42 esac
43 done < ${FILELIST}
44
45 # Search for SONAMEs in all binary files.
46 for file in ${binary_files}; do
47 soname=$(file_get_soname ${file})
48
49 # If the files does not have a SONAME, we will
50 # simply use the basename.
51 if [ -z "${soname}" ]; then
52 if [ -L ${file} ]; then
53 continue
54 fi
55 soname=$(basename ${file})
56 fi
57
58 if file_is_64bit ${file}; then
59 is_64=true
60 echo "${soname}${mark64}"
61 else
62 is_64=false
63 echo "${soname}"
64 fi
65
66 # Find weak symbol provides.
67 objdump -p ${file} 2>/dev/null | awk '
68 BEGIN { START=0 ; }
69 /Version definitions:/ { START=1; }
70 /^[0-9]/ && (START==1) { print $4; }
71 /^$/ { START=0; }' | \
72 grep -v ${soname} | \
73 while read symbol ; do
74 echo "${soname}(${symbol})$(${is_64} && echo ${mark64} | sed 's/()//')"
75 done
76 done
77
78 # Search for perl provides.
79 if [ -n "${perl_files}" ] && [ -x /usr/bin/perl ]; then
80 perl ${BASEDIR}/perl.prov ${perl_files} | sort -u
81 fi
82
83 # pkg-config files.
84 pkgconfig=$(which pkg-config)
85
86 if [ -n "${pkgconfig}" -a -x "${pkgconfig}" ]; then
87 for file in ${pkgconfig_files}; do
88 # Query the dependencies of the package.
89 ${pkgconfig} --print-provides "${file}" 2> /dev/null | while read n r v ; do
90 # We have a dependency. Make a note that we need the pkgconfig
91 # tool for this package.
92 echo "pkgconfig(${n}) ${r} ${v}"
93 done
94 done | sort -u
95 fi
96
97 exit 0