Magellan Linux

Annotation of /trunk/depend-tools/discover_direct_libs.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1539 - (hide annotations) (download) (as text)
Mon Dec 5 19:49:36 2011 UTC (12 years, 5 months ago) by niro
File MIME type: application/x-sh
File size: 1748 byte(s)
-added direct -lib script
1 niro 1539 #!/bin/bash
2    
3     SOURCE="$1"
4     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    
13     COLRED="\033[1;6m\033[31m"
14     COLDEFAULT="\033[0m"
15    
16     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 libs ... "
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     for dep in $(ldd -u ${bin} | sed -e '/^Unused.*/d;' -e '/^[\t]$/d;')
37     do
38     if [[ ${X11HACK} = true ]]
39     then
40     dep=$(echo ${dep} | sed "s:/usr/X11R6/:/usr/:g")
41     fi
42     if [[ -z $(echo ${dep} | grep "notfound") ]]
43     then
44     if not_in_list "${ALL_DEPS}" "${dep}"
45     then
46     ALL_DEPS="${ALL_DEPS} ${dep}"
47     fi
48     fi
49     done
50     done
51     echo "done"
52    
53     if [[ ${DEBUG} = true ]]
54     then
55     echo
56     for i in $(echo ${ALL_DEPS} | sort )
57     do
58     echo ${i}
59     done
60     echo
61     fi
62    
63     echo -n "resolving packages ... "
64     for i in ${ALL_DEPS}
65     do
66     pkg=$(/sbin/magequery -f "${i}")
67     if [[ -z ${pkg} ]]
68     then
69     NO_PACKAGE_FOUND="${NO_PACKAGE_FOUND}:${i} -> no pkg found."
70     continue
71     fi
72     for z in ${pkg}
73     do
74     if not_in_list "${ALL_PACKAGES}" "${z}"
75     then
76     ALL_PACKAGES="${ALL_PACKAGES} ${z}"
77     [[ ${DEBUG} = true ]] && echo "DEBUG: ${z} ${i}"
78     fi
79     done
80     done
81     echo "done"
82    
83     echo
84     for i in ${ALL_PACKAGES}
85     do
86     if not_in_list "${REFERENCES}" "${i}"
87     then
88     echo "${i}"
89     else
90     echo -e "${COLRED}${i}${COLDEFAULT}"
91     fi
92     done | sort
93     echo
94    
95     if [[ ${PRINT_NOT_FOUND} = true ]]
96     then
97     echo
98     echo "Non resolved libs:"
99     OLDIFS="${IFS}"
100     IFS=:
101     for i in ${NO_PACKAGE_FOUND}
102     do
103     echo ${i}
104     done | sort
105     IFS="${OLDIFS}"
106     echo
107     fi