]> git.ipfire.org Git - people/ms/pakfire.git/blob - tools/find-provides
Merge branch 'signatures'
[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*/python*/*.so*)
18 # Do not show python shared objects in provides list.
19 ;;
20 *.so*)
21 file_is_elf ${file} >/dev/null 2>&1 && \
22 binary_files="${binary_files} ${file}"
23 ;;
24 *.pm)
25 # This file is a perl module. We check them later.
26 perl_files="${perl_files} ${file}"
27 ;;
28 *.pc)
29 pkgconfig_files="${pkgconfig_files} ${file}"
30 ;;
31 esac
32 done < ${FILELIST}
33
34 # Search for SONAMEs in all binary files.
35 for file in ${binary_files}; do
36 [ -L ${file} ] && continue
37
38 soname=$(file_get_soname ${file})
39
40 # If the files does not have a SONAME, we will
41 # simply use the basename.
42 if [ -z "${soname}" ]; then
43 if [ -L ${file} ]; then
44 continue
45 fi
46 soname=$(basename ${file})
47 fi
48
49 if file_is_64bit ${file}; then
50 is_64=true
51 echo "${soname}${mark64}"
52 else
53 is_64=false
54 echo "${soname}"
55 fi
56
57 # Find weak symbol provides.
58 objdump -p ${file} 2>/dev/null | awk '
59 BEGIN { START=0 ; }
60 /Version definitions:/ { START=1; }
61 /^[0-9]/ && (START==1) { print $4; }
62 /^$/ { START=0; }' | \
63 grep -v ${soname} | \
64 while read symbol ; do
65 echo "${soname}(${symbol})$(${is_64} && echo ${mark64} | sed 's/()//')"
66 done
67 done
68
69 # Search for perl provides.
70 if [ -n "${perl_files}" ] && [ -x /usr/bin/perl ]; then
71 perl ${BASEDIR}/perl.prov ${perl_files} | sort -u
72 fi
73
74 # pkg-config files.
75 pkgconfig=$(which pkg-config)
76
77 if [ -n "${pkgconfig}" -a -x "${pkgconfig}" ]; then
78 for file in ${pkgconfig_files}; do
79 # Query the dependencies of the package.
80 ${pkgconfig} --print-provides "${file}" 2> /dev/null | while read n r v ; do
81 # We have a dependency. Make a note that we need the pkgconfig
82 # tool for this package.
83 echo "pkgconfig(${n}) ${r} ${v}"
84 done
85 done | sort -u
86 fi
87
88 exit 0