1 |
commit: 4e81ea0e963c31b13fe8a6386f6ac90f32606bd5 |
2 |
Author: Maciej Mrozowski <reavertm <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sat Nov 23 01:54:05 2013 +0000 |
4 |
Commit: Maciej Mrozowski <reavertm <AT> gentoo <DOT> org> |
5 |
CommitDate: Sat Nov 23 02:04:43 2013 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/kde.git;a=commit;h=4e81ea0e |
7 |
|
8 |
[Documentation] Fix dynlink-scanner (make scanelf resolve full library paths, detect broken file utility, add some comments for easier maintenace in a future) |
9 |
|
10 |
--- |
11 |
Documentation/maintainers/dynlink-scanner | 28 +++++++++++++++++++++------- |
12 |
1 file changed, 21 insertions(+), 7 deletions(-) |
13 |
|
14 |
diff --git a/Documentation/maintainers/dynlink-scanner b/Documentation/maintainers/dynlink-scanner |
15 |
index 07f4fff..017f929 100755 |
16 |
--- a/Documentation/maintainers/dynlink-scanner |
17 |
+++ b/Documentation/maintainers/dynlink-scanner |
18 |
@@ -1,9 +1,10 @@ |
19 |
#!/bin/bash |
20 |
|
21 |
-run_scanelf() |
22 |
+# Returns colon separated list of linking dependencies |
23 |
+get_link_deps() |
24 |
{ |
25 |
KEY= |
26 |
- for dep in `scanelf -yBF '%f %n' "$1"`; do |
27 |
+ for dep in `scanelf --use-ldpath -yBF '%f %n' "$1"`; do |
28 |
if [[ -z $KEY ]]; then |
29 |
KEY="$dep" |
30 |
continue |
31 |
@@ -12,12 +13,19 @@ run_scanelf() |
32 |
done |
33 |
} |
34 |
|
35 |
-if [[ "$1" = --internal ]]; then |
36 |
+# Print linking deps for given executable or shared object in alphabetical order. |
37 |
+# Also try to dlopen shared objects in order to detect missing/broken dependencies. |
38 |
+if [[ "$1" = --linking-deps ]]; then |
39 |
+ # Sanity check, file-5.12 is broken, bail out early |
40 |
+ if [[ `file --version | grep --color=never file- | cut -d'-' -f2` == '5.12' ]]; then |
41 |
+ echo "file-5.12 is broken, bailing out" |
42 |
+ exit 1 |
43 |
+ fi |
44 |
mime=`file -b --mime-type "$2"` |
45 |
if [[ "$mime" == 'application/x-executable' ]] || [[ "${mime}" == 'application/x-sharedlib' ]]; then |
46 |
- LINK=`run_scanelf "$2"` |
47 |
+ LINK=`get_link_deps "$2"` |
48 |
[[ "$mime" == 'application/x-sharedlib' ]] && /tmp/try_dlopen "$2" |
49 |
- [[ -n $LINK ]] && echo -e ${LINK//,/\\n} |
50 |
+ [[ -n $LINK ]] && echo -e ${LINK//,/\\n} | sort -u |
51 |
exit 0 |
52 |
fi |
53 |
exit 1 |
54 |
@@ -25,17 +33,23 @@ fi |
55 |
|
56 |
[[ -z $* ]] && echo "usage: `basename $0` <package>" && exit 0 |
57 |
|
58 |
+# Check whether package is installed |
59 |
if ! portageq has_version $ROOT/ $1; then |
60 |
echo "$1 is not installed" |
61 |
exit 1 |
62 |
fi |
63 |
|
64 |
-LDLIBS=`/sbin/ldconfig -p` |
65 |
+# Compile dlopen test application, we will use it to check for broken linking dependencies |
66 |
gcc "`dirname $0`/try_dlopen.c" -o /tmp/try_dlopen -ldl |
67 |
|
68 |
+# For each installed slot |
69 |
for cpv in `portageq match $ROOT/ $1`; do |
70 |
echo "Processing $cpv" |
71 |
- qfile -eR $ROOT `portageq contents $ROOT/ $cpv | xargs -r -L 1 "$0" --internal | sort -u` | cut -f1 -d' ' | sort -u |
72 |
+ # For each file that belongs to package |
73 |
+ # run dynlink-scanner --linking-deps <file> to obtain its linking dependencies |
74 |
+ # Assign all linking deps to packages and print package names |
75 |
+ qfile -eR $ROOT `portageq contents $ROOT/ $cpv | xargs -r -L 1 "$0" --linking-deps` | cut -f1 -d' ' | sort -u |
76 |
done |
77 |
|
78 |
+# Cleanup |
79 |
rm -f /tmp/try_dlopen |