cookutils view modules/deps @ rev 978

modules/compressor: process png images with the spaces in the path.
author Aleksej Bobylev <al.bobylev@gmail.com>
date Fri Oct 13 14:01:28 2017 +0300 (2017-10-13)
parents 79b65c3a4e40
children 556429e78e83
line source
1 #!/bin/sh
2 #
3 # deps - module of the SliTaz Cook
4 # Copyright (C) SliTaz GNU/Linux - GNU GPL v3
5 #
7 . /usr/lib/slitaz/libcook.sh
10 # Maintain databases
12 fl="$cache/tp.files.db" # combined list of all files
13 db_so="$cache/tp.so.db" # database with *.so files
14 db_a="$cache/tp.a.db" # database with *.a files
15 db_la="$cache/tp.la.db" # database with *.la files
16 db_pc="$cache/tp.pc.db" # database with *.pc files
18 fl_mirrorz='/var/lib/tazpkg/files.list.lzma' # mirror files list
19 fl_local='/home/slitaz/cache/files.list' # local files list
21 # recreate "combined list of all files" in the cases:
22 # * if absent
23 # * mirror files list has been updated
24 # * local files list has been updated
26 case $(hostname) in
27 # Do we need to use mirror files list?
28 # It's useful on casual development on local host, but useless on cooker server
29 # (and slows down list creation a lot).
30 tank)
31 [ ! -s $fl -o $fl_local -nt $fl ] && cp $fl_local $fl
32 ;;
33 *)
34 if [ ! -s $fl -o $fl_mirrorz -nt $fl -o $fl_local -nt $fl ]; then
35 action 'Updating %s...' "$(basename $fl)"
36 # unpack mirror files list
37 fl_mirror="$(mktemp)"
38 lzcat $fl_mirrorz | sed '/\.\(so.*\|a\|la\|pc\)$/!d' > $fl_mirror
40 # remove packages that exist in local list
41 cut -d: -f1 $fl_local | uniq | \
42 while read package; do
43 sed -i "/^$package: /d" $fl_mirror
44 done
46 # combine lists
47 cat $fl_mirror $fl_local > $fl
49 # clean
50 rm $fl_mirror
51 status
52 fi
53 ;;
54 esac
56 # recreate "database with *.so files" in the cases:
57 # * if absent
58 # * combined list of all files has been updated
60 if [ ! -s $db_so -o $fl -nt $db_so ]; then
61 action 'Updating %s...' "$(basename $db_so)"
62 fgrep '/lib/' $fl | fgrep '.so' | \
63 sed 's|^\([^:]*\):.*/\([^/]*\)$|\2\t\1|' | \
64 awk -F$'\t' '{if ($2 !~ "uclibc") print}' | \
65 sort > $db_so
66 status
67 fi
69 # recreate "database with *.a files" in the cases:
70 # * if absent
71 # * combined list of all files has been updated
73 if [ ! -s $db_a -o $fl -nt $db_a ]; then
74 action 'Updating %s...' "$(basename $db_a)"
75 fgrep '/usr/lib/lib' $fl | fgrep '.a' | \
76 sed 's|^\([^:]*\):.*/\([^/]*\)$|\2\t\1|' | \
77 sort > $db_a
78 status
79 fi
81 # recreate "database with *.la files" in the cases:
82 # * if absent
83 # * combined list of all files has been updated
85 if [ ! -s $db_la -o $fl -nt $db_la ]; then
86 action 'Updating %s...' "$(basename $db_la)"
87 fgrep '/usr/lib/' $fl | fgrep '.la' | \
88 sed 's|^\([^:]*\): \(.*\)$|\2\t\1|' | \
89 sort > $db_la
90 status
91 fi
93 # recreate "database with *.pc files" in the cases:
94 # * if absent
95 # * combined list of all files has been updated
97 if [ ! -s $db_pc -o $fl -nt $db_pc ]; then
98 action 'Updating %s...' "$(basename $db_pc)"
99 grep '\.pc$' $fl | \
100 sed -e 's|^\([^:]*\):.*/\([^/]*\)$|\2\t\1|' -e '/\tbuildroot$/d' | \
101 sort > $db_pc
102 status
103 fi
108 # Auxiliary function that deals with "not found" packages as well as with "repeatedly found" packages
110 outpkg() {
111 pkgs="$1"
112 case $pkgs in
113 *ld-linux.so*);;
114 *linux-gate.so*);;
115 *)
116 echo "$pkgs" | awk -vincl="$incl" '
117 # if both packages exist in list, return the first one only
118 function s(pkg1, pkg2) {
119 if (index(" "$0" ", " "pkg1" ") && index(" "$0" ", " " pkg2 " "))
120 $0 = pkg1;
121 }
122 {
123 s("wine", "wine-rt");
124 s("samba", "samba-pam");
125 s("mesa", "mesa-wayland");
126 s("mysql", "mariadb");
127 s("perl", "perl-thread");
128 s("xorg-server", "xorg-server-light");
129 s("cairo", "cairo-gl");
130 s("freetype", "freetype-infinality");
131 s("freetype", "freetype-without-harfbuzz");
132 s("harfbuzz", "harfbuzz-icu");
133 s("openbox", "openbox-imlib2");
134 s("gcc-lib-base", "gcc49-lib-base"); # also gcc54-lib-base and gcc61-lib-base
135 s("polkit", "polkit-pam");
136 s("libgudev", "eudev"); # also systemd
137 s("xz-dev", "liblzma-dev");
138 s("xorg-libxcb", "libxcb");
139 s("xorg-xcb-util-image", "xcb-util-image");
140 s("xorg-xcb-util-keysyms", "xcb-util-keysyms");
141 s("xorg-xcb-util-renderutil", "xcb-util-renderutil");
142 s("xorg-xcb-util-wm", "xcb-util-wm");
143 s("xorg-xcb-util", "xcb-util");
144 s("xorg-libxcb", "libxcb");
145 s("xorg-libxcb-dev", "libxcb-dev");
146 s("xorg-pixman", "pixman");
147 s("xorg-pixman-dev", "pixman-dev");
148 s("xorg-xcb-util-cursor", "xcb-util-cursor");
149 s("xorg-xcb-util-dev", "xcb-util-dev");
150 s("xorg-xcb-util-image-dev", "xcb-util-image-dev");
151 s("xorg-xcb-util-renderutil-dev", "xcb-util-renderutil-dev");
152 s("eudev-dev", "udev-dev");
154 # if called with "--incl": show all deps including glibc-base,
155 # gcc-lib-base, glibc-dev and gcc; otherwise hide them
156 if (incl == "yes" ||
157 ! index($0, "glibc-base") &&
158 ! index($0, "gcc-lib-base") &&
159 ! index($0, "glibc-dev") &&
160 $0 != "gcc")
161 print gensub(" ", "|", "g");
162 }';;
163 esac >>$tmptmp
164 }
167 # Search for item $1 in db $2
169 indb() {
170 local res="$(awk -vi="$1" '
171 {
172 if ($1 == i)
173 { print $2; found = 1; }
174 }
175 END {
176 if (found != 1) {
177 if (index(i, "statically linked"))
178 print gensub(" ", "_", "g", i);
179 else
180 printf("[%s]\n", i);
181 }
182 }
183 ' $2 | tr '\n' ' ')"
184 outpkg "${res% }"
185 }
188 # Like `ldd` function but returns packages names where dependency exists.
189 # Also can process some development files
191 tp_ldd() {
192 unset IFS
193 tmptmp=$(mktemp)
195 case $1 in
196 *.la)
197 # found dependencies in the *.la files
198 libs=$(. $1; echo $dependency_libs)
199 for i in $libs; do
200 case $i in
201 -l*) indb "lib${i#-l}.so" $db_so;; # FIXME: I'm not sure it's about a *.so, but *.a often absent
202 *.la) indb "$i" $db_la;;
203 esac
204 done
205 ;;
206 *.pc)
207 # found dependencies in the *.pc files
208 # Syntax examples:
209 # Requires: glib-2.0 gobject-2.0
210 # Requires.private: gmodule-no-export-2.0
211 # Requires: gobject-2.0,gio-2.0
212 # Requires.private: nspr >= 4.9.2
213 pcs=$(grep '^Requires' $1 | cut -d: -f2 | tr ',' ' ' | tr '\n' ' ')
214 for i in $pcs; do
215 isitlib=$(echo $i | tr -d '<=>0-9.')
216 # if it contains only comparisons, numbers, dot - it is not lib, skip
217 [ -n "$isitlib" ] || continue
218 indb "$i.pc" $db_pc
219 done
220 # Syntax examples:
221 # Libs: -L${libdir} -lgio-2.0
222 # Libs.private: -lz -lresolv
223 libs=$(grep '^Libs' $1 | cut -d: -f2 | tr '\n' ' ')
224 for i in $libs; do
225 case $i in
226 -l*) indb "lib${i#-l}.so" $db_so;;
227 esac
228 done
229 ;;
230 */lib/modules/*)
231 echo 'linux'
232 ;;
233 *.pl|*.pm)
234 echo 'perl'
235 ;;
236 *.py)
237 echo 'python'
238 ;;
239 *)
240 LD_PRELOAD= LD_TRACE_LOADED_OBJECTS=1 /lib/ld-linux* "$1" 2>/dev/null | \
241 sed 's| =>.*||; s| (.*||; s|\t||' | \
242 while read i; do
243 indb "$i" $db_so
244 done
245 ;;
246 esac
248 sort -u $tmptmp
249 rm $tmptmp
250 }
253 # Return all the names of packages bundled in this receipt
255 all_names() {
256 local split=" $SPLIT "
257 if [ "${split/ $PACKAGE /}" != "$split" ]; then
258 # $PACKAGE included somewhere in $SPLIT (probably in the end).
259 # We should build packages in the order defined in the $SPLIT.
260 echo $SPLIT
261 else
262 # We'll build the $PACKAGE, then all defined in the $SPLIT.
263 echo $PACKAGE $SPLIT
264 fi
265 }
270 unset IFS
271 . $WOK/$1/receipt
273 for pkg in $(all_names); do
274 title 'Dependencies for "%s"' "$pkg"
275 IFS=$'\n'
276 while read file; do
277 tp_ldd "$WOK/$1/taz/$pkg-$VERSION/fs$file"
278 done < $WOK/$1/taz/$pkg-$VERSION/files.list | sort -u | grep -v "^$pkg$"
279 done
281 newline