]> git.ipfire.org Git - pakfire.git/blame - tools/find-provides
Fix closing archives when extracting a package.
[pakfire.git] / tools / find-provides
CommitLineData
63029754
MT
1#!/bin/bash
2
3# Include functions.
4BASEDIR=$(dirname ${0})
5source ${BASEDIR}/find-common
6
7BUILDROOT=${1}
8FILELIST=${2}
9
10binary_files=
11perl_files=
12pkgconfig_files=
13
14# Walk through all file files and see what we have got here.
15while read file; do
16 case "${file}" in
5d007720
MT
17 */usr/lib/debug/*|*/usr/src/debug/*)
18 # Skip all debuginfo files.
19 continue
20 ;;
610c0849 21 */usr/lib*/python*/*.so*)
5b421683
MT
22 # Do not show python shared objects in provides list.
23 ;;
5d007720
MT
24 */usr/lib*/gconv/*)
25 # Skip gconv files.
26 continue
27 ;;
63029754 28 *.so*)
5d007720
MT
29 # Skip symlinks for performance reasons.
30 [ -L "${file}" ] && continue
31
f77b35e7
MT
32 file_is_elf ${file} >/dev/null 2>&1 && \
33 binary_files="${binary_files} ${file}"
63029754
MT
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
43done < ${FILELIST}
44
45# Search for SONAMEs in all binary files.
46for file in ${binary_files}; do
63029754
MT
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; }' | \
63029754
MT
72 while read symbol ; do
73 echo "${soname}(${symbol})$(${is_64} && echo ${mark64} | sed 's/()//')"
74 done
75done
76
77# Search for perl provides.
78if [ -n "${perl_files}" ] && [ -x /usr/bin/perl ]; then
79 perl ${BASEDIR}/perl.prov ${perl_files} | sort -u
80fi
81
82# pkg-config files.
83pkgconfig=$(which pkg-config)
84
85if [ -n "${pkgconfig}" -a -x "${pkgconfig}" ]; then
86 for file in ${pkgconfig_files}; do
87 # Query the dependencies of the package.
88 ${pkgconfig} --print-provides "${file}" 2> /dev/null | while read n r v ; do
89 # We have a dependency. Make a note that we need the pkgconfig
90 # tool for this package.
91 echo "pkgconfig(${n}) ${r} ${v}"
63029754
MT
92 done
93 done | sort -u
94fi
95
96exit 0