Annotation of /trunk/depend-tools/discover_libs.sh
Parent Directory | Revision Log
Revision 379 -
(hide annotations)
(download)
(as text)
Mon Jun 5 09:35:36 2006 UTC (18 years, 5 months ago) by niro
File MIME type: application/x-sh
File size: 1789 byte(s)
Mon Jun 5 09:35:36 2006 UTC (18 years, 5 months ago) by niro
File MIME type: application/x-sh
File size: 1789 byte(s)
added support for reference lists
1 | niro | 331 | #!/bin/bash |
2 | |||
3 | SOURCE="$1" | ||
4 | niro | 379 | if [[ $2 = --references ]] || [[ $2 = -r ]] |
5 | then | ||
6 | shift;shift | ||
7 | for i in $1 | ||
8 | do | ||
9 | REFERENCES="${REFERENCES} $(< ${i})" | ||
10 | done | ||
11 | fi | ||
12 | niro | 331 | |
13 | niro | 379 | COLRED="\033[1;6m\033[31m" |
14 | COLDEFAULT="\033[0m" | ||
15 | |||
16 | niro | 331 | not_in_list() |
17 | { | ||
18 | local deplist="$1" | ||
19 | local dep="$2" | ||
20 | local i | ||
21 | |||
22 | for i in ${deplist} | ||
23 | do | ||
24 | [[ ${i} = ${dep} ]] && return 1 | ||
25 | done | ||
26 | |||
27 | return 0 | ||
28 | } | ||
29 | |||
30 | echo -n "resolving linking lib ... " | ||
31 | |||
32 | # first binaries: | ||
33 | for bin in $(find ${SOURCE} | xargs file | grep "executable" | grep ELF | cut -f 1 -d :) \ | ||
34 | $(find ${SOURCE} | xargs file | grep "shared object" | grep ELF | cut -f 1 -d :) | ||
35 | do | ||
36 | while read lib | ||
37 | do | ||
38 | dep=$(echo "${lib}" | cut -d'>' -f2 | cut -d'(' -f1 | sed "s:\ ::g") | ||
39 | if [[ ${X11HACK} = true ]] | ||
40 | then | ||
41 | dep=$(echo ${dep} | sed "s:/usr/X11R6/:/usr/:g") | ||
42 | fi | ||
43 | if [[ -z $(echo ${dep} | grep "notfound") ]] | ||
44 | then | ||
45 | if not_in_list "${ALL_DEPS}" "${dep}" | ||
46 | then | ||
47 | ALL_DEPS="${ALL_DEPS} ${dep}" | ||
48 | fi | ||
49 | fi | ||
50 | done << EOF | ||
51 | $(ldd ${bin}) | ||
52 | EOF | ||
53 | done | ||
54 | echo "done" | ||
55 | |||
56 | if [[ ${DEBUG} = true ]] | ||
57 | then | ||
58 | echo | ||
59 | for i in $(echo ${ALL_DEPS} | sort ) | ||
60 | do | ||
61 | echo ${i} | ||
62 | done | ||
63 | echo | ||
64 | fi | ||
65 | |||
66 | echo -n "resolving packages ... " | ||
67 | for i in ${ALL_DEPS} | ||
68 | do | ||
69 | pkg=$(/sbin/magequery -f "${i}") | ||
70 | niro | 359 | if [[ -z ${pkg} ]] |
71 | then | ||
72 | NO_PACKAGE_FOUND="${NO_PACKAGE_FOUND}:${i} -> no pkg found." | ||
73 | continue | ||
74 | fi | ||
75 | niro | 331 | for z in ${pkg} |
76 | do | ||
77 | if not_in_list "${ALL_PACKAGES}" "${z}" | ||
78 | then | ||
79 | ALL_PACKAGES="${ALL_PACKAGES} ${z}" | ||
80 | [[ ${DEBUG} = true ]] && echo "DEBUG: ${z} ${i}" | ||
81 | fi | ||
82 | done | ||
83 | done | ||
84 | echo "done" | ||
85 | |||
86 | echo | ||
87 | for i in ${ALL_PACKAGES} | ||
88 | do | ||
89 | niro | 379 | if not_in_list "${REFERENCES}" "${i}" |
90 | then | ||
91 | echo "${i}" | ||
92 | else | ||
93 | echo -e "${COLRED}${i}${COLDEFAULT}" | ||
94 | fi | ||
95 | niro | 331 | done | sort |
96 | echo | ||
97 | niro | 359 | |
98 | if [[ ${PRINT_NOT_FOUND} = true ]] | ||
99 | then | ||
100 | echo | ||
101 | echo "Non resolved libs:" | ||
102 | OLDIFS="${IFS}" | ||
103 | IFS=: | ||
104 | for i in ${NO_PACKAGE_FOUND} | ||
105 | do | ||
106 | echo ${i} | ||
107 | done | sort | ||
108 | IFS="${OLDIFS}" | ||
109 | echo | ||
110 | fi |