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