cookutils view modules/deps @ rev 954

cook: remove package in taz/ is package not needed; modules/compressor: recompress *.zip files (for LibreOffice).
author Aleksej Bobylev <al.bobylev@gmail.com>
date Wed Aug 02 18:44:51 2017 +0300 (2017-08-02)
parents 6e892f321f46
children 11e28a8b9e5a
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 '
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 (! index($0, "glibc-base") &&
155 ! index($0, "gcc-lib-base") &&
156 ! index($0, "glibc-dev") &&
157 $0 != "gcc")
158 print gensub(" ", "|", "g");
159 }';;
160 esac >>$tmptmp
161 }
164 # Search for item $1 in db $2
166 indb() {
167 local res="$(awk -vi="$1" '
168 {
169 if ($1 == i)
170 { print $2; found = 1; }
171 }
172 END {
173 if (found != 1) {
174 if (index(i, "statically linked"))
175 print gensub(" ", "_", "g", i);
176 else
177 printf("[%s]\n", i);
178 }
179 }
180 ' $2 | tr '\n' ' ')"
181 outpkg "${res% }"
182 }
185 # Like `ldd` function but returns packages names where dependency exists.
186 # Also can process some development files
188 tp_ldd() {
189 unset IFS
190 tmptmp=$(mktemp)
192 case $1 in
193 *.la)
194 # found dependencies in the *.la files
195 libs=$(. $1; echo $dependency_libs)
196 for i in $libs; do
197 case $i in
198 -l*) indb "lib${i#-l}.so" $db_so;; # FIXME: I'm not sure it's about a *.so, but *.a often absent
199 *.la) indb "$i" $db_la;;
200 esac
201 done
202 ;;
203 *.pc)
204 # found dependencies in the *.pc files
205 # Syntax examples:
206 # Requires: glib-2.0 gobject-2.0
207 # Requires.private: gmodule-no-export-2.0
208 # Requires: gobject-2.0,gio-2.0
209 # Requires.private: nspr >= 4.9.2
210 pcs=$(grep '^Requires' $1 | cut -d: -f2 | tr ',' ' ' | tr '\n' ' ')
211 for i in $pcs; do
212 isitlib=$(echo $i | tr -d '<=>0-9.')
213 # if it contains only comparisons, numbers, dot - it is not lib, skip
214 [ -n "$isitlib" ] || continue
215 indb "$i.pc" $db_pc
216 done
217 # Syntax examples:
218 # Libs: -L${libdir} -lgio-2.0
219 # Libs.private: -lz -lresolv
220 libs=$(grep '^Libs' $1 | cut -d: -f2 | tr '\n' ' ')
221 for i in $libs; do
222 case $i in
223 -l*) indb "lib${i#-l}.so" $db_so;;
224 esac
225 done
226 ;;
227 */lib/modules/*)
228 echo 'linux'
229 ;;
230 *.pl|*.pm)
231 echo 'perl'
232 ;;
233 *.py)
234 echo 'python'
235 ;;
236 *)
237 LD_PRELOAD= LD_TRACE_LOADED_OBJECTS=1 /lib/ld-linux* "$1" 2>/dev/null | \
238 sed 's| =>.*||; s| (.*||; s|\t||' | \
239 while read i; do
240 indb "$i" $db_so
241 done
242 ;;
243 esac
245 sort -u $tmptmp
246 rm $tmptmp
247 }
250 # Return all the names of packages bundled in this receipt
252 all_names() {
253 local split=" $SPLIT "
254 if [ "${split/ $PACKAGE /}" != "$split" ]; then
255 # $PACKAGE included somewhere in $SPLIT (probably in the end).
256 # We should build packages in the order defined in the $SPLIT.
257 echo $SPLIT
258 else
259 # We'll build the $PACKAGE, then all defined in the $SPLIT.
260 echo $PACKAGE $SPLIT
261 fi
262 }
267 unset IFS
268 . $WOK/$1/receipt
270 for pkg in $(all_names); do
271 title 'Dependencies for "%s"' "$pkg"
272 IFS=$'\n'
273 while read file; do
274 tp_ldd "$WOK/$1/taz/$pkg-$VERSION/fs$file"
275 done < $WOK/$1/taz/$pkg-$VERSION/files.list | sort -u | grep -v "^$pkg$"
276 done
278 newline