rev |
line source |
al@932
|
1 #!/bin/sh
|
al@932
|
2 #
|
al@932
|
3 # deps - module of the SliTaz Cook
|
al@932
|
4 # Copyright (C) SliTaz GNU/Linux - GNU GPL v3
|
al@932
|
5 #
|
al@932
|
6
|
al@932
|
7 . /usr/lib/slitaz/libcook.sh
|
al@932
|
8
|
al@932
|
9
|
al@932
|
10 # Maintain databases
|
al@932
|
11
|
al@932
|
12 fl="$cache/tp.files.db" # combined list of all files
|
al@932
|
13 db_so="$cache/tp.so.db" # database with *.so files
|
al@932
|
14 db_a="$cache/tp.a.db" # database with *.a files
|
al@932
|
15 db_la="$cache/tp.la.db" # database with *.la files
|
al@932
|
16 db_pc="$cache/tp.pc.db" # database with *.pc files
|
al@932
|
17
|
al@932
|
18 fl_mirrorz='/var/lib/tazpkg/files.list.lzma' # mirror files list
|
al@932
|
19 fl_local='/home/slitaz/cache/files.list' # local files list
|
al@932
|
20
|
al@994
|
21
|
al@994
|
22 # check "local files list" doesn't contain files from missing/removed packages
|
al@994
|
23
|
al@994
|
24 action 'Updating %s...' "$(basename $fl_local)"
|
al@994
|
25
|
al@994
|
26 splitdb="$CACHE/split.db"
|
al@994
|
27 sed 's|:.*||' $fl_local \
|
al@994
|
28 | sort -u \
|
al@994
|
29 | while read pkg; do
|
al@994
|
30 mainpkg=$(awk -F$'\t' -vpkg=" $pkg " '{
|
al@994
|
31 if (index(" " $2 " ", pkg)) {print 1; exit}
|
al@994
|
32 }' $splitdb)
|
al@994
|
33 [ -n "$mainpkg" ] || sed -i "/^$pkg: /d" $fl_local
|
al@994
|
34 done
|
al@994
|
35 status
|
al@994
|
36
|
al@932
|
37 # recreate "combined list of all files" in the cases:
|
paul@937
|
38 # * if absent
|
al@932
|
39 # * mirror files list has been updated
|
al@932
|
40 # * local files list has been updated
|
al@932
|
41
|
al@938
|
42 case $(hostname) in
|
al@938
|
43 # Do we need to use mirror files list?
|
paul@939
|
44 # It's useful on casual development on local host, but useless on cooker server
|
paul@939
|
45 # (and slows down list creation a lot).
|
al@938
|
46 tank)
|
al@940
|
47 [ ! -s $fl -o $fl_local -nt $fl ] && cp $fl_local $fl
|
al@940
|
48 ;;
|
al@940
|
49 *)
|
al@938
|
50 if [ ! -s $fl -o $fl_mirrorz -nt $fl -o $fl_local -nt $fl ]; then
|
al@940
|
51 action 'Updating %s...' "$(basename $fl)"
|
al@938
|
52 # unpack mirror files list
|
al@938
|
53 fl_mirror="$(mktemp)"
|
al@944
|
54 lzcat $fl_mirrorz | sed '/\.\(so.*\|a\|la\|pc\)$/!d' > $fl_mirror
|
al@932
|
55
|
al@938
|
56 # remove packages that exist in local list
|
al@938
|
57 cut -d: -f1 $fl_local | uniq | \
|
al@938
|
58 while read package; do
|
al@938
|
59 sed -i "/^$package: /d" $fl_mirror
|
al@938
|
60 done
|
al@932
|
61
|
al@938
|
62 # combine lists
|
al@938
|
63 cat $fl_mirror $fl_local > $fl
|
al@932
|
64
|
al@938
|
65 # clean
|
al@938
|
66 rm $fl_mirror
|
al@940
|
67 status
|
al@938
|
68 fi
|
al@938
|
69 ;;
|
al@938
|
70 esac
|
al@932
|
71
|
al@932
|
72 # recreate "database with *.so files" in the cases:
|
paul@937
|
73 # * if absent
|
al@932
|
74 # * combined list of all files has been updated
|
al@932
|
75
|
al@932
|
76 if [ ! -s $db_so -o $fl -nt $db_so ]; then
|
al@940
|
77 action 'Updating %s...' "$(basename $db_so)"
|
al@932
|
78 fgrep '/lib/' $fl | fgrep '.so' | \
|
al@932
|
79 sed 's|^\([^:]*\):.*/\([^/]*\)$|\2\t\1|' | \
|
al@932
|
80 awk -F$'\t' '{if ($2 !~ "uclibc") print}' | \
|
al@932
|
81 sort > $db_so
|
al@940
|
82 status
|
al@932
|
83 fi
|
al@932
|
84
|
al@932
|
85 # recreate "database with *.a files" in the cases:
|
paul@937
|
86 # * if absent
|
al@932
|
87 # * combined list of all files has been updated
|
al@932
|
88
|
al@932
|
89 if [ ! -s $db_a -o $fl -nt $db_a ]; then
|
al@940
|
90 action 'Updating %s...' "$(basename $db_a)"
|
al@932
|
91 fgrep '/usr/lib/lib' $fl | fgrep '.a' | \
|
al@932
|
92 sed 's|^\([^:]*\):.*/\([^/]*\)$|\2\t\1|' | \
|
al@932
|
93 sort > $db_a
|
al@940
|
94 status
|
al@932
|
95 fi
|
al@932
|
96
|
al@932
|
97 # recreate "database with *.la files" in the cases:
|
paul@937
|
98 # * if absent
|
al@932
|
99 # * combined list of all files has been updated
|
al@932
|
100
|
al@932
|
101 if [ ! -s $db_la -o $fl -nt $db_la ]; then
|
al@940
|
102 action 'Updating %s...' "$(basename $db_la)"
|
al@932
|
103 fgrep '/usr/lib/' $fl | fgrep '.la' | \
|
al@932
|
104 sed 's|^\([^:]*\): \(.*\)$|\2\t\1|' | \
|
al@932
|
105 sort > $db_la
|
al@940
|
106 status
|
al@932
|
107 fi
|
al@932
|
108
|
al@932
|
109 # recreate "database with *.pc files" in the cases:
|
paul@937
|
110 # * if absent
|
al@932
|
111 # * combined list of all files has been updated
|
al@932
|
112
|
al@932
|
113 if [ ! -s $db_pc -o $fl -nt $db_pc ]; then
|
al@940
|
114 action 'Updating %s...' "$(basename $db_pc)"
|
al@932
|
115 grep '\.pc$' $fl | \
|
al@932
|
116 sed -e 's|^\([^:]*\):.*/\([^/]*\)$|\2\t\1|' -e '/\tbuildroot$/d' | \
|
al@932
|
117 sort > $db_pc
|
al@940
|
118 status
|
al@932
|
119 fi
|
al@932
|
120
|
al@932
|
121
|
al@932
|
122
|
al@932
|
123
|
paul@937
|
124 # Auxiliary function that deals with "not found" packages as well as with "repeatedly found" packages
|
al@932
|
125
|
al@932
|
126 outpkg() {
|
al@932
|
127 pkgs="$1"
|
al@932
|
128 case $pkgs in
|
al@932
|
129 *ld-linux.so*);;
|
al@932
|
130 *linux-gate.so*);;
|
al@932
|
131 *)
|
al@957
|
132 echo "$pkgs" | awk -vincl="$incl" '
|
al@932
|
133 # if both packages exist in list, return the first one only
|
al@932
|
134 function s(pkg1, pkg2) {
|
al@932
|
135 if (index(" "$0" ", " "pkg1" ") && index(" "$0" ", " " pkg2 " "))
|
al@932
|
136 $0 = pkg1;
|
al@932
|
137 }
|
al@932
|
138 {
|
al@932
|
139 s("wine", "wine-rt");
|
al@932
|
140 s("samba", "samba-pam");
|
al@932
|
141 s("mesa", "mesa-wayland");
|
al@932
|
142 s("mysql", "mariadb");
|
al@932
|
143 s("perl", "perl-thread");
|
al@932
|
144 s("xorg-server", "xorg-server-light");
|
al@932
|
145 s("cairo", "cairo-gl");
|
al@932
|
146 s("freetype", "freetype-infinality");
|
al@932
|
147 s("freetype", "freetype-without-harfbuzz");
|
al@932
|
148 s("harfbuzz", "harfbuzz-icu");
|
al@932
|
149 s("openbox", "openbox-imlib2");
|
al@932
|
150 s("gcc-lib-base", "gcc49-lib-base"); # also gcc54-lib-base and gcc61-lib-base
|
al@932
|
151 s("polkit", "polkit-pam");
|
al@932
|
152 s("libgudev", "eudev"); # also systemd
|
al@932
|
153 s("xz-dev", "liblzma-dev");
|
al@945
|
154 s("xorg-libxcb", "libxcb");
|
al@945
|
155 s("xorg-xcb-util-image", "xcb-util-image");
|
al@945
|
156 s("xorg-xcb-util-keysyms", "xcb-util-keysyms");
|
al@945
|
157 s("xorg-xcb-util-renderutil", "xcb-util-renderutil");
|
al@945
|
158 s("xorg-xcb-util-wm", "xcb-util-wm");
|
al@945
|
159 s("xorg-xcb-util", "xcb-util");
|
al@945
|
160 s("xorg-libxcb", "libxcb");
|
al@945
|
161 s("xorg-libxcb-dev", "libxcb-dev");
|
al@945
|
162 s("xorg-pixman", "pixman");
|
al@945
|
163 s("xorg-pixman-dev", "pixman-dev");
|
al@945
|
164 s("xorg-xcb-util-cursor", "xcb-util-cursor");
|
al@945
|
165 s("xorg-xcb-util-dev", "xcb-util-dev");
|
al@945
|
166 s("xorg-xcb-util-image-dev", "xcb-util-image-dev");
|
al@945
|
167 s("xorg-xcb-util-renderutil-dev", "xcb-util-renderutil-dev");
|
al@945
|
168 s("eudev-dev", "udev-dev");
|
al@1020
|
169 s("util-linux-uuid", "ossp-uuid");
|
al@987
|
170 s("util-linux-uuid-dev", "ossp-uuid-dev");
|
al@988
|
171 s("polkit-pam-dev", "polkit-dev");
|
al@989
|
172 s("nspr", "palemoon"); # I doubt app may depend on Palemoon
|
al@989
|
173 s("nss", "palemoon"); #
|
al@994
|
174 s("xfconf", "libxfconf"); s("xfconf-dev", "libxfconf-dev");
|
al@994
|
175 s("exo", "libexo"); s("exo-dev", "libexo-dev");
|
al@998
|
176 s("gconf", "GConf"); s("gconf-dev", "GConf-dev");
|
al@1003
|
177 s("pulseaudio", "apulse");
|
al@1009
|
178 s("cairo-dev", "cairo-gl-dev");
|
al@1009
|
179 s("freetype-dev", "freetype-infinality-dev");
|
al@932
|
180
|
al@957
|
181 # if called with "--incl": show all deps including glibc-base,
|
al@957
|
182 # gcc-lib-base, glibc-dev and gcc; otherwise hide them
|
al@957
|
183 if (incl == "yes" ||
|
al@957
|
184 ! index($0, "glibc-base") &&
|
al@932
|
185 ! index($0, "gcc-lib-base") &&
|
al@932
|
186 ! index($0, "glibc-dev") &&
|
al@932
|
187 $0 != "gcc")
|
al@932
|
188 print gensub(" ", "|", "g");
|
al@932
|
189 }';;
|
al@1020
|
190 esac
|
al@932
|
191 }
|
al@932
|
192
|
al@932
|
193
|
al@932
|
194 # Search for item $1 in db $2
|
al@932
|
195
|
al@932
|
196 indb() {
|
al@932
|
197 local res="$(awk -vi="$1" '
|
al@932
|
198 {
|
al@932
|
199 if ($1 == i)
|
al@932
|
200 { print $2; found = 1; }
|
al@932
|
201 }
|
al@932
|
202 END {
|
al@932
|
203 if (found != 1) {
|
al@932
|
204 if (index(i, "statically linked"))
|
al@932
|
205 print gensub(" ", "_", "g", i);
|
al@932
|
206 else
|
al@932
|
207 printf("[%s]\n", i);
|
al@932
|
208 }
|
al@932
|
209 }
|
al@1020
|
210 ' $2 | tr '\n' ' ' | sed 's| $||')"
|
al@1020
|
211
|
al@1020
|
212 outpkg "$res"
|
al@932
|
213 }
|
al@932
|
214
|
al@932
|
215
|
al@932
|
216 # Like `ldd` function but returns packages names where dependency exists.
|
al@932
|
217 # Also can process some development files
|
al@932
|
218
|
al@932
|
219 tp_ldd() {
|
al@1020
|
220 local tmptmp libs variables pcs pkg pkgs out
|
al@932
|
221 unset IFS
|
al@932
|
222 tmptmp=$(mktemp)
|
al@932
|
223
|
al@932
|
224 case $1 in
|
al@932
|
225 *.la)
|
al@1020
|
226 if [ -n "$la" ]; then # use with --la
|
al@1020
|
227 # found dependencies in the *.la files
|
al@1020
|
228 libs=$(. $1; echo $dependency_libs)
|
al@1020
|
229 for i in $libs; do
|
al@1020
|
230 case $i in
|
al@1020
|
231 -l*) indb "${i/-l/lib}.so" $db_so >>$tmptmp;; # FIXME: I'm not sure it's about a *.so, but *.a often absent
|
al@1020
|
232 *.la) indb "$i" $db_la >>$tmptmp;;
|
al@1020
|
233 esac
|
al@1020
|
234 done
|
al@1020
|
235 fi
|
al@932
|
236 ;;
|
al@932
|
237 *.pc)
|
al@932
|
238 # found dependencies in the *.pc files
|
al@1020
|
239 variables=$(mktemp)
|
al@1020
|
240 grep '^[a-zA-Z_][a-zA-Z_]*=' $1 > $variables
|
al@1020
|
241 . $variables
|
al@1020
|
242 rm $variables
|
al@932
|
243 # Syntax examples:
|
al@932
|
244 # Requires: glib-2.0 gobject-2.0
|
al@932
|
245 # Requires.private: gmodule-no-export-2.0
|
al@932
|
246 # Requires: gobject-2.0,gio-2.0
|
al@938
|
247 # Requires.private: nspr >= 4.9.2
|
al@932
|
248 pcs=$(grep '^Requires' $1 | cut -d: -f2 | tr ',' ' ' | tr '\n' ' ')
|
al@932
|
249 for i in $pcs; do
|
al@938
|
250 isitlib=$(echo $i | tr -d '<=>0-9.')
|
al@938
|
251 # if it contains only comparisons, numbers, dot - it is not lib, skip
|
al@938
|
252 [ -n "$isitlib" ] || continue
|
al@1020
|
253 indb "$i.pc" $db_pc >>$tmptmp
|
al@932
|
254 done
|
al@932
|
255 # Syntax examples:
|
al@932
|
256 # Libs: -L${libdir} -lgio-2.0
|
al@932
|
257 # Libs.private: -lz -lresolv
|
al@932
|
258 libs=$(grep '^Libs' $1 | cut -d: -f2 | tr '\n' ' ')
|
al@932
|
259 for i in $libs; do
|
al@932
|
260 case $i in
|
al@1020
|
261 -L*) eval LIBDIR="${i#-L}";;
|
al@1020
|
262 -l*)
|
al@1020
|
263 eval i="$i" # substitute variables
|
al@1020
|
264 #echo ">i='$i'" >&2
|
al@1020
|
265 pkg=$(indb "lib${i#-l}.so" $db_so)
|
al@1020
|
266 #echo ">>pkg='$pkg'" >&2
|
al@1020
|
267 pkgs=$(awk -F$'\t' -vpkg="$pkg" '{if (index(" " $2 " ", " " pkg " ")) print $2;}' /home/slitaz/cache/split.db)
|
al@1020
|
268 #echo ">>pkgs='$pkgs'" >&2
|
al@1020
|
269 unset out
|
al@1020
|
270 for j in $pkgs; do
|
al@1020
|
271 # seadrch for <pkg>-dev
|
al@1020
|
272 case $j in $pkg-dev) out=$j; break;;
|
al@1020
|
273 esac
|
al@1020
|
274 done
|
al@1020
|
275 #echo ">>'$out'" >&2
|
al@1020
|
276 [ -z "$out" ] &&
|
al@1020
|
277 for j in $pkgs; do
|
al@1020
|
278 # if not found previously, search for <any>-dev
|
al@1020
|
279 case $j in *-dev) out=$j; break;;
|
al@1020
|
280 esac
|
al@1020
|
281 done
|
al@1020
|
282 #echo ">>'$out'" >&2
|
al@1020
|
283 echo ${out:-$pkg}
|
al@1020
|
284 #echo >&2
|
al@1020
|
285 ;;
|
al@932
|
286 esac
|
al@932
|
287 done
|
al@932
|
288 ;;
|
al@932
|
289 */lib/modules/*)
|
al@932
|
290 echo 'linux'
|
al@932
|
291 ;;
|
al@932
|
292 *.pl|*.pm)
|
al@932
|
293 echo 'perl'
|
al@932
|
294 ;;
|
al@932
|
295 *.py)
|
al@932
|
296 echo 'python'
|
al@932
|
297 ;;
|
al@932
|
298 *)
|
al@1020
|
299 # LD_PRELOAD= LD_TRACE_LOADED_OBJECTS=1 /lib/ld-linux* "$1" 2>/dev/null | \
|
al@1020
|
300 # sed 's| =>.*||; s| (.*||; s|\t||' | \
|
al@1020
|
301 readelf -dW "$1" 2>/dev/null \
|
al@1020
|
302 | sed -n '/NEEDED/ s|.*\[\(.*\)\]|\1|p' \
|
al@1020
|
303 | while read i; do
|
al@1020
|
304 indb "$i" $db_so >>$tmptmp
|
al@932
|
305 done
|
al@932
|
306 ;;
|
al@932
|
307 esac
|
al@932
|
308
|
al@932
|
309 sort -u $tmptmp
|
al@932
|
310 rm $tmptmp
|
al@932
|
311 }
|
al@932
|
312
|
al@932
|
313
|
al@932
|
314 # Return all the names of packages bundled in this receipt
|
al@932
|
315
|
al@932
|
316 all_names() {
|
al@1008
|
317 # Get package names from $SPLIT variable
|
al@1008
|
318 local split=$(echo $SPLIT \
|
al@1008
|
319 | awk '
|
al@1008
|
320 BEGIN { RS = " "; FS = ":"; }
|
al@1008
|
321 { print $1; }' \
|
al@1008
|
322 | tr '\n' ' ')
|
al@1008
|
323 local split_space=" $split "
|
al@1008
|
324 if [ "${split_space/ $PACKAGE /}" != "$split_space" ]; then
|
al@932
|
325 # $PACKAGE included somewhere in $SPLIT (probably in the end).
|
al@932
|
326 # We should build packages in the order defined in the $SPLIT.
|
al@1008
|
327 echo $split
|
al@932
|
328 else
|
al@932
|
329 # We'll build the $PACKAGE, then all defined in the $SPLIT.
|
al@1008
|
330 echo $PACKAGE $split
|
al@932
|
331 fi
|
al@932
|
332 }
|
al@932
|
333
|
al@932
|
334
|
al@932
|
335
|
al@932
|
336
|
al@932
|
337 unset IFS
|
al@932
|
338 . $WOK/$1/receipt
|
al@932
|
339
|
al@932
|
340 for pkg in $(all_names); do
|
al@932
|
341 title 'Dependencies for "%s"' "$pkg"
|
al@932
|
342 IFS=$'\n'
|
al@932
|
343 while read file; do
|
al@932
|
344 tp_ldd "$WOK/$1/taz/$pkg-$VERSION/fs$file"
|
al@1020
|
345 done < $WOK/$1/taz/$pkg-$VERSION/files.list | sort -u | grep -v "^$pkg$" | sed '/^$/d'
|
al@932
|
346 done
|
al@932
|
347
|
al@932
|
348 newline
|