source: BLFS/libs/func_dependencies@ 5e091a2

2.3 2.4 ablfs ablfs-more legacy new_features trunk
Last change on this file since 5e091a2 was 5e091a2, checked in by Manuel Canales Esparcia <manuel@…>, 17 years ago

BLFS: Skip installed packages newer than the book ones.

  • Property mode set to 100644
File size: 13.0 KB
Line 
1#!/bin/bash
2#
3# $Id$
4#
5set -e
6
7declare -i cntr=0
8declare -a spaceSTR=" "
9
10#----------------------------#
11generate_dependency_tree() { #
12#----------------------------#
13: <<inline_doc
14 function: Create a dependency tree for the TARGET
15 input vars: none
16 externals: vars: TARGET
17 PKGXML
18 DEP_LEVEL
19 func: do_dependencies
20 modifies: vars: PKGXML
21 BLFS_XML
22 returns: nothing
23 output: files: $TARGET.dep
24 $TARGET-index.xml.tmp
25 depure.txt
26 on error: nothing
27 on success: nothing
28inline_doc
29
30 local ENTRY_START
31 local ENTRY_END
32
33 #---------------------
34 # Create the working directory and cd into it
35 if [[ -d $TARGET ]] ; then
36 echo -e "\tERROR: Looks like $TARGET has been already processed."
37 echo -e "\tPlease delete or rename the $TARGET directory.\n"
38 exit 1
39 else
40 mkdir $TARGET && cd $TARGET
41 fi
42
43 #---------------------
44 # XML file of the target package
45 PKGXML=`grep "^$TARGET[[:space:]]" ../packages | cut -f2`
46
47 #---------------------
48 # The BLFS sources directory.
49 BLFS_XML=`echo $PKGXML | sed -e 's,/.*,,'`
50
51 if [[ ! -d ../$BLFS_XML ]] ; then
52 echo -e "\tThe BLFS book sources directory is missing.\n"
53 echo -e "\tExecution aborted.\n"
54 cd .. && rmdir $TARGET
55 exit 1
56 fi
57
58 #---------------------
59 # XInclude stuff
60 ENTRY_START="<xi:include xmlns:xi=\"http://www.w3.org/2003/XInclude\" href=\"../"
61 ENTRY_END="\"/>"
62
63 echo -e "\tGenerating $TARGET dependencies tree ..."
64
65 mkdir dependencies
66
67 #---------------------
68 # Create target package dependencies list
69 case $TARGET in
70 # Skip the creation when all dependencies are circular.
71 alsa-lib | cracklib | libexif | unixodbc ) ;;
72
73 # Meta-packages at target level
74 alsa )
75 cp ../libs/alsa.dep dependencies/
76 ;;
77 gnome-core )
78 cp ../libs/gnome-core.dep dependencies/
79 ;;
80 gnome-full )
81 cp ../libs/gnome-{core,full}.dep dependencies/
82 ;;
83 kde-core )
84 cp ../libs/kde-core.dep dependencies/
85 ;;
86 kde-full )
87 cp ../libs/kde-{core,full}.dep dependencies/
88 ;;
89 kde-koffice )
90 cp ../libs/kde-{core,full,koffice}.dep dependencies/
91 ;;
92 xorg7 )
93 cp ../libs/xorg7.dep dependencies/
94 ;;
95 * ) # Default
96 xsltproc --stringparam dependencies $DEP_LEVEL \
97 -o dependencies/$TARGET.dep \
98 ../libs/dependencies.xsl ../$PKGXML
99 ;;
100 esac
101
102 #---------------------
103 # Start with a clean $TARGET-index.xml.tmp file
104 > $TARGET-index.xml.tmp
105
106 #---------------------
107 # Write the XInclude
108 case $TARGET in
109 # If there is no usefull XML page, skip it.
110 alsa | gnome-core | gnome-full | kde-core | kde-full | kde-koffice | xorg7) ;;
111 * )
112 echo -e " $ENTRY_START$PKGXML$ENTRY_END" >> $TARGET-index.xml.tmp
113 ;;
114 esac
115
116 #---------------------
117 # If have dependencies, write its XInclude and find sub-dependencies
118 if [[ -f dependencies/$TARGET.dep ]]; then
119 mkdir xincludes && do_dependencies $TARGET
120 fi
121
122 echo -e "\n\t... done"
123}
124
125
126
127#-----------------------#
128do_dependencies() { # Loop to find sub-dependencies :::WARNING::: THIS IS A RECURVISE FUNCTION
129#-----------------------#
130: <<inline_doc
131 function: Loop through all the packages and create a sub-dependency tree
132 input vars: $1, package name
133 externals: vars: $DEP_LEVEL
134 $TARGET
135 $PRINT_SERVER
136 $KBR5
137 $GHOSTSCRIPT
138 $MAILSERVER
139 file: depure.txt
140 $TARGET-index.xml.tmp
141 $PKG.dep
142 $PKG.inc
143 modifies: files
144 returns: nothing
145 output: file: $PKG-xinc.tmp
146 depure.txt
147 $TARGET-index.xml.tmp
148 on error: exit
149 on success:
150inline_doc
151
152 set -e
153 local PKG=$1
154 local saveIFS=$IFS
155 local DEP_LV=$DEP_LEVEL
156 local line line2 DEP pkg_ver inst_ver
157
158 #------------------
159 # If a premade xinclude file exists, use it. If not, create one
160 if [[ -f xincludes/$PKG.xinc ]] ; then
161 IFS=$'\x0A'
162 for line in `cat xincludes/$PKG.xinc` ; do
163 IFS=$saveIFS
164 # Remove the Xinclude entry if found. We want the most newer one.
165 # Using double quotes to let bash expand variables.
166 # Remove also the empty line created. Can not be done in one step
167 # due that d requires the pattner between /, but we have a lot of /
168 # inside the pattner.
169 sed -e "s,^[[:space:]]*$line,," -e '/./!d' -i $TARGET-index.xml.tmp
170 # Write the XInclude
171 echo -e "$line" >> $TARGET-index.xml.tmp
172 done
173 return
174 fi
175
176 #------------------
177 # Start with a clean $PKG.xinc.tmp file
178 > xincludes/$PKG.xinc.tmp
179 for DEP in `cat dependencies/$PKG.dep`; do
180
181 # Special packages that need be remaped
182 case $DEP in
183
184 db ) continue ;; # The proper version of DB is installed in LFS
185
186 # Don't have their own XML file
187 hal-requirements | hal-runtime-dependencies ) continue ;;
188 perl-* | tk-perl ) DEP=perl-modules ;;
189 dbus-* ) DEP=dbus-bindings ;;
190
191 # Orphan links (proper link must be created when generating the book)
192 arts ) DEP=aRts ;;
193 kde ) DEP=kde-core ;;
194
195 # Set values for alternative packages
196 LPRng | cups ) DEP=$PRINT_SERVER ;;
197 mitkrb | heimdal ) DEP=$KBR5 ;;
198 gs | espgs ) DEP=$GHOSTSCRIPT ;;
199 server-mail ) DEP=$MAIL_SERVER ;;
200 x-window-system )
201 case $X11 in
202 xorg7 ) DEP=xorg7 ;;
203 * )
204 pkg_ver=$(grep "^${X11}[[:space:]]" ../packages | cut -f3)
205 inst_ver=$(grep "^${X11}[[:space:]]" ../packages | cut -f4)
206 [ -n "${pkg_ver}" ] && [[ "x${pkg_ver}" = "x${inst_ver}" ]] && continue
207 [ -n "${pkg_ver}" ] && [[ "x${pkg_ver}" < "x${inst_ver}" ]] && continue
208 ;;
209 esac
210 ;;
211 esac
212
213 # If DEP has been previouly installed, skip it
214 pkg_ver=$(grep "^${DEP}[[:space:]]" ../packages | cut -f3)
215 inst_ver=$(grep "^${DEP}[[:space:]]" ../packages | cut -f4)
216 [ -n "${pkg_ver}" ] && [[ "x${pkg_ver}" = "x${inst_ver}" ]] && continue
217 [ -n "${pkg_ver}" ] && [[ "x${pkg_ver}" < "x${inst_ver}" ]] && continue
218
219 #------------------
220 # Prevent circular dependencies
221 # If all dependencies are circular, the creation of the *.dep file
222 # must be skipped, not placed here, to avoid that the script will bomb
223 # due empty *.xinc files
224 case $DEP in
225 akode )
226 # Both are in the same page
227 [[ "$PKG" = "kdemultimedia" ]] && continue
228 ;;
229 aRts )
230 # esound-->aRts-->esound
231 [[ "$PKG" = "esound" ]] && continue
232 ;;
233 dbus-bindings )
234 # True circular dependecy
235 [[ "$PKG" = "dbus-bindings" ]] && continue
236 ;;
237 DocBook )
238 # Used to rebuild the documentation
239 [[ "$PKG" = "linux-pam" ]] && continue
240 ;;
241 docbook-xsl )
242 # Used to rebuild the documentation
243 [[ "$PKG" = "linux-pam" ]] && continue
244 ;;
245 doxygen )
246 # Used to rebuild the documentation
247 [[ "$PKG" = "dbus" ]] && continue
248 [[ "$PKG" = "libdvdcss" ]] && continue
249 [[ "$PKG" = "libusb" ]] && continue
250 [[ "$PKG" = "libxcb" ]] && continue
251 ;;
252 espgs )
253 # Used to rebuild the documentation
254 [[ "$PKG" = "$MAIL_SERVER" ]] && continue
255 ;;
256 ffmpeg )
257 # alsa-plugins-->ffmpeg-->several-->alsa-plugins
258 [[ "$PKG" = "alsa-plugins" ]] && continue
259 ;;
260 fop )
261 # Used to rebuild the documentation
262 [[ "$PKG" = "linux-pam" ]] && continue
263 ;;
264 graphviz )
265 # Used to build the API documentation
266 [[ "$PKG" = "libusb" ]] && continue
267 ;;
268 GTK )
269 # deprecated GTK version
270 [[ "$PKG" = "alsa-tools" ]] && continue
271 ;;
272 gtk2 )
273 # Testsuite only
274 [[ "$PKG" = "cairo" ]] && continue
275 ;;
276 jadetex )
277 # Runtime only
278 [[ "$PKG" = "docbook-utils" ]] && continue
279 ;;
280 $KBR5 )
281 # cyrus-sasl-->postgresql-->$KBR5-->openldap-->cyrus-sasl
282 [[ "$PKG" = "cyrus-sasl" ]] && continue
283 ;;
284 librsvg )
285 # Testsuite only
286 [[ "$PKG" = "cairo" ]] && continue
287 ;;
288 libxslt )
289 # libxml2-->libxslt-->libxml2
290 [[ "$PKG" = "libxml2" ]] && continue
291 ;;
292 Links )
293 # Runtime only
294 [[ "$PKG" = "docbook-utils" ]] && continue
295 ;;
296 lynx )
297 # Runtime only
298 [[ "$PKG" = "docbook-utils" ]] && continue
299 ;;
300 openldap )
301 # cyrus-sasl-->postgresql-->$KBR5-->openldap-->cyrus-sasl
302 [[ "$PKG" = "cyrus-sasl" ]] && continue
303 ;;
304 poppler )
305 # Testsuite only
306 [[ "$PKG" = "cairo" ]] && continue
307 ;;
308 postgresql )
309 # cyrus-sasl-->postgresql-->$KBR5-->openldap-->cyrus-sasl
310 [[ "$PKG" = "cyrus-sasl" ]] && continue
311 ;;
312 tk )
313 # python-->tk-->xorg7-->several combinations-->libxslt-->python
314 [[ "$PKG" = "python" ]] && continue
315 ;;
316 w3m )
317 # Runtime only
318 [[ "$PKG" = "docbook-utils" ]] && continue
319 # Used to rebuild the documentation
320 [[ "$PKG" = "linux-pam" ]] && continue
321 ;;
322 esac
323
324 #------------------
325 # XML file of dependency package
326 DEP_XML=`grep "^$DEP[[:space:]]" ../packages | cut -f2`
327 case $DEP in
328 x-window-system | alsa ) ;; # No page for that (proper link must be created when generating the book)
329 xorg7 ) ;; # This page will be dump in the xorg7.xinc file
330 gnome-core | kde-core | kde-full ) ;; # Invented packages
331 * )
332 # Remove the Xinclude entry if found
333 sed -e "s,^[[:space:]]*$ENTRY_START$DEP_XML$ENTRY_END,," \
334 -e '/./!d' -i xincludes/$PKG.xinc.tmp
335 # Write the XInclude
336 echo -e " $ENTRY_START$DEP_XML$ENTRY_END" >> xincludes/$PKG.xinc.tmp
337 ;;
338 esac
339
340 #------------------
341 # If not already created, create its dependencies list
342 if [[ ! -f dependencies/$DEP.dep ]] ; then
343 case $DEP in
344 # Skip the creation when all dependencies are circular.
345 alsa-lib | cracklib | libexif | unixodbc ) ;;
346 # Meta-packages at dependency level
347 alsa )
348 cp ../libs/alsa.dep dependencies/
349 ;;
350 kde-core )
351 cp ../libs/kde-core.dep dependencies/
352 ;;
353 x-window-system ) # When X11 is not Xorg7
354 echo -e "x-config\nx-setup\n$X11" > dependencies/x-window-system.dep
355 ;;
356 xorg7 )
357 cp ../libs/xorg7.dep dependencies/
358 ;;
359 * ) xsltproc --stringparam dependencies $DEP_LV \
360 -o dependencies/$DEP.dep ../libs/dependencies.xsl ../$DEP_XML
361 ;;
362 esac
363 fi
364
365 #------------------
366 # If needed, process its dependencies
367 if [[ -f dependencies/$DEP.dep ]] ; then
368 # If a premade xinclude file esist, include it
369 if [[ -f xincludes/$DEP.xinc ]] ; then
370 IFS=$'\x0A'
371 for line2 in `cat xincludes/$DEP.xinc` ; do
372 IFS=$saveIFS
373 # Remove the Xinclude entry if found
374 sed -e "s,^[[:space:]]*$line2,," -e '/./!d' -i xincludes/$PKG.xinc.tmp
375 # Write the XInclude
376 echo -e "$line2" >> xincludes/$PKG.xinc.tmp
377 done
378 #------------------
379 # Create the xinclude file
380 else
381 #
382 # >>>>>> THIS IS A RECURSIVE FUNCTION CALL.. BEWARE OF GREMLINS. <<<<<<
383 #
384 # If the recursion depth is not too great this is an acceptable methodology for a script language
385 # However, uncontrolled recursion will cause a seg-fault due to stack issues with local variables.
386 #
387 set +e
388 [[ "${VERBOSITY}" > 0 ]] && echo -ne "\ncall: $((++cntr))${spaceSTR:0:$cntr}${RED}$DEP${OFF}"
389 do_dependencies $DEP
390 [[ "${VERBOSITY}" > 0 ]] && echo -ne "\n ret: $cntr${spaceSTR:0:$((cntr--))}${GREEN}$DEP${OFF} Using $DEP Xinc to solve $PKG"
391 set -e
392
393 # Include it when done
394 IFS=$'\x0A'
395 for line2 in `cat xincludes/$DEP.xinc` ; do
396 IFS=$saveIFS
397 # Remove the Xinclude entry if found
398 sed -e "s,^[[:space:]]*$line2,," -e '/./!d' -i xincludes/$PKG.xinc.tmp
399 # Write the XInclude
400 echo -e "$line2" >> xincludes/$PKG.xinc.tmp
401 done
402 fi
403 fi
404 done
405
406 #------------------
407 if [[ "$PKG" = "xorg7" ]] ; then
408 # Add their XInclude
409 PKG_XML=${BLFS_XML}/x/installing/xorg7.xml
410 echo -e " $ENTRY_START$PKG_XML$ENTRY_END" >> xincludes/$PKG.xinc.tmp
411 fi
412
413 #------------------
414 mv xincludes/$PKG.xinc.tmp xincludes/$PKG.xinc
415 IFS=$'\x0A'
416 for line in `cat xincludes/$PKG.xinc` ; do
417 IFS=$saveIFS
418 # Remove the Xinclude entry if found.
419 sed -e "s,^[[:space:]]*$line,," -e '/./!d' -i $TARGET-index.xml.tmp
420 # Write the XInclude
421 echo -e "$line" >> $TARGET-index.xml.tmp
422 done
423}
Note: See TracBrowser for help on using the repository browser.