]>
Commit | Line | Data |
---|---|---|
63029754 MT |
1 | #!/bin/bash |
2 | ||
3 | # Include functions. | |
4 | BASEDIR=$(dirname ${0}) | |
5 | source ${BASEDIR}/find-common | |
6 | ||
7 | # BUILDROOT is the first argument. | |
8 | BUILDROOT=${1} | |
9 | FILELIST=${2} | |
10 | ||
11 | # Determine libdir. | |
12 | if [ "$(uname -m)" = "x86_64" ]; then | |
13 | libdir=/usr/lib64 | |
14 | else | |
15 | libdir=/usr/lib | |
16 | fi | |
17 | ||
18 | binary_files= | |
19 | perl_files= | |
20 | script_files= | |
21 | pkgconfig_files= | |
22 | ||
23 | # Walk through all file files and see what we have got here. | |
24 | while read file; do | |
25 | case "${file}" in | |
3598810e MT |
26 | */usr/lib/debug/*|*/usr/src/debug/*) |
27 | # Skip all debuginfo files. | |
5d007720 MT |
28 | continue |
29 | ;; | |
30 | */usr/lib*/gconv/*) | |
31 | # Skip all gconv files. | |
32 | continue | |
3598810e | 33 | ;; |
7d7953ec MT |
34 | *.ko) |
35 | # Skip all kernel modules because they do not | |
36 | # require anything at all. | |
37 | continue | |
38 | ;; | |
63029754 MT |
39 | *.pc) |
40 | # Find all pkg-config files. | |
41 | pkgconfig_files="${pkgconfig_files} ${file}" | |
42 | continue | |
43 | ;; | |
44 | *.pm) | |
45 | # Find all perl modules. | |
46 | if [ -r "${file}" ]; then | |
47 | perl_files="${perl_files} ${file}" | |
48 | continue | |
49 | fi | |
50 | ;; | |
51 | ||
52 | # Python | |
53 | */usr/lib*/python*/*) | |
54 | # Sort out all python files. | |
5d007720 | 55 | # Directories are processed bewlow. |
63029754 | 56 | ;; |
d16c1569 | 57 | */usr/lib/python*|*/usr/lib64/python*) |
63029754 MT |
58 | # This will only get the python directory. |
59 | file=$(basename ${file}) | |
60 | ||
61 | # Strip the python version from the string. | |
62 | python_version="${file#python}" | |
63 | ||
d16c1569 MT |
64 | if [ -n "${python_version}" ]; then |
65 | echo "python-abi = ${python_version}" | |
66 | fi | |
63029754 MT |
67 | continue |
68 | ;; | |
69 | esac | |
70 | ||
63029754 MT |
71 | # Unresolved symlinks. |
72 | if [ -L "${file}" ]; then | |
73 | # Get destination. | |
74 | link=$(readlink -m ${file}) | |
75 | ||
76 | # If destination does not exist, make | |
77 | # a dependency for it. | |
78 | if ! [ -e "${link}" ]; then | |
79 | echo "${link#${BUILDROOT}}" | |
80 | fi | |
7d7953ec MT |
81 | |
82 | # Don't search for anything else, because | |
83 | # symlinks do not require anything but the target file. | |
84 | continue | |
85 | fi | |
86 | ||
87 | # Search for all binary files. | |
88 | if file_is_elf ${file}; then | |
89 | binary_files="${binary_files} ${file}" | |
90 | continue | |
91 | fi | |
92 | ||
93 | # Search for script files. | |
94 | if file_is_script ${file}; then | |
95 | script_files="${script_files} ${file}" | |
96 | continue | |
63029754 MT |
97 | fi |
98 | done < ${FILELIST} | |
99 | ||
100 | # Process script files. | |
101 | interpreters= | |
102 | for file in ${script_files}; do | |
103 | [ -r ${file} -a -x ${file} ] || continue | |
104 | ||
77099310 | 105 | interp=$(file_get_script_interpreter ${file}) |
63029754 MT |
106 | interpreters="${interpreters} ${interp}" |
107 | ||
108 | # Collect all perl files. | |
8e56dfbf | 109 | case "${interp}" in |
63029754 MT |
110 | */perl) |
111 | perl_files="${perl_files} ${file}" | |
112 | ;; | |
113 | esac | |
114 | done | |
115 | ||
116 | # Output the list of needed interpreters. | |
daef68ff | 117 | [ -n "${interpreters}" ] && { echo ${interpreters} | tr '[:blank:]' \\n | sort -u ; } |
63029754 | 118 | |
1df83d33 MT |
119 | # Search for binary interpreters. |
120 | for file in ${binary_files}; do | |
8d2c4eea MT |
121 | # Get the interpreter. |
122 | interp=$(file_get_elf_interpreter ${file}) | |
123 | ||
124 | # Skip the interpreter if it is provided by this | |
125 | # package. | |
126 | [ -e "${BUILDROOT}${interp}" ] && continue | |
127 | ||
128 | # Print the interpreter. | |
129 | echo "${interp}" | |
1df83d33 MT |
130 | done | sort -u |
131 | ||
63029754 MT |
132 | # Weak symbol versions (from glibc). |
133 | [ -n "${mark64}" ] && mark64="(64bit)" | |
134 | for file in ${binary_files}; do | |
135 | [ -r ${file} ] || continue | |
136 | ||
137 | lib64=$(if file_is_64bit ${file}; then echo "${mark64}"; fi) | |
72cea61c | 138 | objdump -p ${file} 2>/dev/null | awk 'BEGIN { START=0; LIBNAME=""; } |
63029754 MT |
139 | /^$/ { START=0; } |
140 | /^Dynamic Section:$/ { START=1; } | |
141 | (START==1) && /NEEDED/ { | |
142 | if ("'${lib64}'" != "") { | |
143 | sub(/$/, "()'${lib64}'", $2); | |
144 | } | |
145 | print $2; | |
146 | } | |
147 | (START==2) && /^[A-Za-z]/ { START=3; } | |
148 | /^Version References:$/ { START=2; } | |
149 | (START==2) && /required from/ { | |
150 | sub(/:/, "", $3); | |
151 | LIBNAME=$3; | |
152 | } | |
153 | (START==2) && (LIBNAME!="") && ($4!="") { | |
154 | print LIBNAME "(" $4 ")'${lib64}'"; | |
155 | }' | |
156 | done | sort -u | |
157 | ||
158 | # Search for perl requires. | |
159 | if [ -n "${perl_files}" ] && [ -x /usr/bin/perl ]; then | |
160 | perl ${BASEDIR}/perl.req ${perl_files} | sort -u | |
161 | fi | |
162 | ||
163 | # Search for pkg-config requires. | |
164 | pkgconfig=$(which pkg-config) | |
165 | if [ -n "${pkgconfig}" -a -x "${pkgconfig}" ]; then | |
166 | for file in ${pkgconfig_files}; do | |
6230230c MT |
167 | # The dependency for the pkgconfig package itself. |
168 | echo "pkgconfig" | |
169 | ||
63029754 MT |
170 | ${pkgconfig} --print-requires --print-requires-private "${file}" 2> /dev/null | while read n r v ; do |
171 | echo "pkgconfig(${n})" "${r}" "${v}" | |
172 | done | |
173 | done | |
174 | fi | |
175 | ||
176 | exit 0 |