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@932
|
21 # recreate "combined list of all files" in the cases:
|
al@932
|
22 # * it absent
|
al@932
|
23 # * mirror files list has been updated
|
al@932
|
24 # * local files list has been updated
|
al@932
|
25
|
al@932
|
26 if [ ! -s $fl -o $fl_mirrorz -nt $fl -o $fl_local -nt $fl ]; then
|
al@932
|
27 # unpack mirror files list
|
al@932
|
28 fl_mirror="$(mktemp)"
|
al@932
|
29 lzcat $fl_mirrorz > $fl_mirror
|
al@932
|
30
|
al@932
|
31 # remove packages that exist in local list
|
al@932
|
32 cut -d: -f1 $fl_local | uniq | \
|
al@932
|
33 while read package; do
|
al@932
|
34 sed -i "/^$package: /d" $fl_mirror
|
al@932
|
35 done
|
al@932
|
36
|
al@932
|
37 # combine lists
|
al@932
|
38 cat $fl_mirror $fl_local > $fl
|
al@932
|
39
|
al@932
|
40 # clean
|
al@932
|
41 rm $fl_mirror
|
al@932
|
42 fi
|
al@932
|
43
|
al@932
|
44 # recreate "database with *.so files" in the cases:
|
al@932
|
45 # * it absent
|
al@932
|
46 # * combined list of all files has been updated
|
al@932
|
47
|
al@932
|
48 if [ ! -s $db_so -o $fl -nt $db_so ]; then
|
al@932
|
49 fgrep '/lib/' $fl | fgrep '.so' | \
|
al@932
|
50 sed 's|^\([^:]*\):.*/\([^/]*\)$|\2\t\1|' | \
|
al@932
|
51 awk -F$'\t' '{if ($2 !~ "uclibc") print}' | \
|
al@932
|
52 sort > $db_so
|
al@932
|
53 fi
|
al@932
|
54
|
al@932
|
55 # recreate "database with *.a files" in the cases:
|
al@932
|
56 # * it absent
|
al@932
|
57 # * combined list of all files has been updated
|
al@932
|
58
|
al@932
|
59 if [ ! -s $db_a -o $fl -nt $db_a ]; then
|
al@932
|
60 fgrep '/usr/lib/lib' $fl | fgrep '.a' | \
|
al@932
|
61 sed 's|^\([^:]*\):.*/\([^/]*\)$|\2\t\1|' | \
|
al@932
|
62 sort > $db_a
|
al@932
|
63 fi
|
al@932
|
64
|
al@932
|
65 # recreate "database with *.la files" in the cases:
|
al@932
|
66 # * it absent
|
al@932
|
67 # * combined list of all files has been updated
|
al@932
|
68
|
al@932
|
69 if [ ! -s $db_la -o $fl -nt $db_la ]; then
|
al@932
|
70 fgrep '/usr/lib/' $fl | fgrep '.la' | \
|
al@932
|
71 sed 's|^\([^:]*\): \(.*\)$|\2\t\1|' | \
|
al@932
|
72 sort > $db_la
|
al@932
|
73 fi
|
al@932
|
74
|
al@932
|
75 # recreate "database with *.pc files" in the cases:
|
al@932
|
76 # * it absent
|
al@932
|
77 # * combined list of all files has been updated
|
al@932
|
78
|
al@932
|
79 if [ ! -s $db_pc -o $fl -nt $db_pc ]; then
|
al@932
|
80 grep '\.pc$' $fl | \
|
al@932
|
81 sed -e 's|^\([^:]*\):.*/\([^/]*\)$|\2\t\1|' -e '/\tbuildroot$/d' | \
|
al@932
|
82 sort > $db_pc
|
al@932
|
83 fi
|
al@932
|
84
|
al@932
|
85
|
al@932
|
86
|
al@932
|
87
|
al@932
|
88 # Auxiliary function that deal with "not found" packages as well as with "repeatedly found" packages
|
al@932
|
89
|
al@932
|
90 outpkg() {
|
al@932
|
91 pkgs="$1"
|
al@932
|
92 case $pkgs in
|
al@932
|
93 *ld-linux.so*);;
|
al@932
|
94 *linux-gate.so*);;
|
al@932
|
95 *)
|
al@932
|
96 echo "$pkgs" | awk '
|
al@932
|
97 # if both packages exist in list, return the first one only
|
al@932
|
98 function s(pkg1, pkg2) {
|
al@932
|
99 if (index(" "$0" ", " "pkg1" ") && index(" "$0" ", " " pkg2 " "))
|
al@932
|
100 $0 = pkg1;
|
al@932
|
101 }
|
al@932
|
102 {
|
al@932
|
103 s("wine", "wine-rt");
|
al@932
|
104 s("samba", "samba-pam");
|
al@932
|
105 s("mesa", "mesa-wayland");
|
al@932
|
106 s("mysql", "mariadb");
|
al@932
|
107 s("perl", "perl-thread");
|
al@932
|
108 s("xorg-server", "xorg-server-light");
|
al@932
|
109 s("cairo", "cairo-gl");
|
al@932
|
110 s("freetype", "freetype-infinality");
|
al@932
|
111 s("freetype", "freetype-without-harfbuzz");
|
al@932
|
112 s("harfbuzz", "harfbuzz-icu");
|
al@932
|
113 s("openbox", "openbox-imlib2");
|
al@932
|
114 s("gcc-lib-base", "gcc49-lib-base"); # also gcc54-lib-base and gcc61-lib-base
|
al@932
|
115 s("polkit", "polkit-pam");
|
al@932
|
116 s("libgudev", "eudev"); # also systemd
|
al@932
|
117 s("xz-dev", "liblzma-dev");
|
al@932
|
118
|
al@932
|
119 if (! index($0, "glibc-base") &&
|
al@932
|
120 ! index($0, "gcc-lib-base") &&
|
al@932
|
121 ! index($0, "glibc-dev") &&
|
al@932
|
122 $0 != "gcc")
|
al@932
|
123 print gensub(" ", "|", "g");
|
al@932
|
124 }';;
|
al@932
|
125 esac >>$tmptmp
|
al@932
|
126 }
|
al@932
|
127
|
al@932
|
128
|
al@932
|
129 # Search for item $1 in db $2
|
al@932
|
130
|
al@932
|
131 indb() {
|
al@932
|
132 local res="$(awk -vi="$1" '
|
al@932
|
133 {
|
al@932
|
134 if ($1 == i)
|
al@932
|
135 { print $2; found = 1; }
|
al@932
|
136 }
|
al@932
|
137 END {
|
al@932
|
138 if (found != 1) {
|
al@932
|
139 if (index(i, "statically linked"))
|
al@932
|
140 print gensub(" ", "_", "g", i);
|
al@932
|
141 else
|
al@932
|
142 printf("[%s]\n", i);
|
al@932
|
143 }
|
al@932
|
144 }
|
al@932
|
145 ' $2 | tr '\n' ' ')"
|
al@932
|
146 outpkg "${res% }"
|
al@932
|
147 }
|
al@932
|
148
|
al@932
|
149
|
al@932
|
150 # Like `ldd` function but returns packages names where dependency exists.
|
al@932
|
151 # Also can process some development files
|
al@932
|
152
|
al@932
|
153 tp_ldd() {
|
al@932
|
154 unset IFS
|
al@932
|
155 tmptmp=$(mktemp)
|
al@932
|
156
|
al@932
|
157 case $1 in
|
al@932
|
158 *.la)
|
al@932
|
159 # found dependencies in the *.la files
|
al@932
|
160 libs=$(. $1; echo $dependency_libs)
|
al@932
|
161 for i in $libs; do
|
al@932
|
162 case $i in
|
al@932
|
163 -l*) indb "lib${i#-l}.so" $db_so;; # FIXME: I'm not sure it's about a *.so, but *.a often absent
|
al@932
|
164 *.la) indb "$i" $db_la;;
|
al@932
|
165 esac
|
al@932
|
166 done
|
al@932
|
167 ;;
|
al@932
|
168 *.pc)
|
al@932
|
169 # found dependencies in the *.pc files
|
al@932
|
170 # Syntax examples:
|
al@932
|
171 # Requires: glib-2.0 gobject-2.0
|
al@932
|
172 # Requires.private: gmodule-no-export-2.0
|
al@932
|
173 # Requires: gobject-2.0,gio-2.0
|
al@932
|
174 pcs=$(grep '^Requires' $1 | cut -d: -f2 | tr ',' ' ' | tr '\n' ' ')
|
al@932
|
175 for i in $pcs; do
|
al@932
|
176 indb "$i.pc" $db_pc
|
al@932
|
177 done
|
al@932
|
178 # Syntax examples:
|
al@932
|
179 # Libs: -L${libdir} -lgio-2.0
|
al@932
|
180 # Libs.private: -lz -lresolv
|
al@932
|
181 libs=$(grep '^Libs' $1 | cut -d: -f2 | tr '\n' ' ')
|
al@932
|
182 for i in $libs; do
|
al@932
|
183 case $i in
|
al@932
|
184 -l*) indb "lib${i#-l}.so" $db_so;;
|
al@932
|
185 esac
|
al@932
|
186 done
|
al@932
|
187 ;;
|
al@932
|
188 */lib/modules/*)
|
al@932
|
189 echo 'linux'
|
al@932
|
190 ;;
|
al@932
|
191 *.pl|*.pm)
|
al@932
|
192 echo 'perl'
|
al@932
|
193 ;;
|
al@932
|
194 *.py)
|
al@932
|
195 echo 'python'
|
al@932
|
196 ;;
|
al@932
|
197 *)
|
al@932
|
198 LD_PRELOAD= LD_TRACE_LOADED_OBJECTS=1 /lib/ld-linux* "$1" 2>/dev/null | \
|
al@932
|
199 sed 's| =>.*||; s| (.*||; s|\t||' | \
|
al@932
|
200 while read i; do
|
al@932
|
201 indb "$i" $db_so
|
al@932
|
202 done
|
al@932
|
203 ;;
|
al@932
|
204 esac
|
al@932
|
205
|
al@932
|
206 sort -u $tmptmp
|
al@932
|
207 rm $tmptmp
|
al@932
|
208 }
|
al@932
|
209
|
al@932
|
210
|
al@932
|
211 # Return all the names of packages bundled in this receipt
|
al@932
|
212
|
al@932
|
213 all_names() {
|
al@932
|
214 local split=" $SPLIT "
|
al@932
|
215 if [ "${split/ $PACKAGE /}" != "$split" ]; then
|
al@932
|
216 # $PACKAGE included somewhere in $SPLIT (probably in the end).
|
al@932
|
217 # We should build packages in the order defined in the $SPLIT.
|
al@932
|
218 echo $SPLIT
|
al@932
|
219 else
|
al@932
|
220 # We'll build the $PACKAGE, then all defined in the $SPLIT.
|
al@932
|
221 echo $PACKAGE $SPLIT
|
al@932
|
222 fi
|
al@932
|
223 }
|
al@932
|
224
|
al@932
|
225
|
al@932
|
226
|
al@932
|
227
|
al@932
|
228 unset IFS
|
al@932
|
229 . $WOK/$1/receipt
|
al@932
|
230
|
al@932
|
231 for pkg in $(all_names); do
|
al@932
|
232 title 'Dependencies for "%s"' "$pkg"
|
al@932
|
233 IFS=$'\n'
|
al@932
|
234 while read file; do
|
al@932
|
235 tp_ldd "$WOK/$1/taz/$pkg-$VERSION/fs$file"
|
al@932
|
236 done < $WOK/$1/taz/$pkg-$VERSION/files.list | sort -u | grep -v "^$pkg$"
|
al@932
|
237 done
|
al@932
|
238
|
al@932
|
239 newline
|