source: BLFS/func_dependencies@ 2a3e0f0

experimental
Last change on this file since 2a3e0f0 was 2a3e0f0, checked in by Manuel Canales Esparcia <manuel@…>, 19 years ago

Changed circular dependencies handler to skip only the offended dependencies.
But don't look very stable yet (see comments about alsa-lib and jdk).
Not verified yet it all circular dependencies has been tracked.

  • Property mode set to 100644
File size: 11.2 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 mkdir $TARGET && cd $TARGET
36
37 #---------------------
38 # XML file of the target package
39 PKGXML=`grep "^$TARGET[[:space:]]" ../packages | cut -f2`
40
41 #---------------------
42 # The BLFS sources directory.
43 BLFS_XML=`echo $PKGXML | sed -e 's,/.*,,'`
44
45 if [[ ! -d ../$BLFS_XML ]] ; then
46 echo -e "\tThe BLFS book sources directory is missing.\n"
47 echo -e "\tExecution aborted.\n"
48 cd .. && rmdir $TARGET
49 exit 1
50 fi
51
52 #---------------------
53 # XInclude stuff
54 ENTRY_START="<xi:include xmlns:xi=\"http://www.w3.org/2003/XInclude\" href=\"../"
55 ENTRY_END="\"/>"
56
57 echo -en "\tGenerating $TARGET dependencies tree ..."
58
59 #---------------------
60 # Create target package dependencies list
61 case $TARGET in
62 # Meta-packages at target level
63 # KDE and Gnome-{core,full} could be made via packages.sh, but not sure yet how.
64 alsa ) # When target "alsa", use all alsa-* packages
65 echo -e "alsa-oss\nalsa-firmware\nalsa-tools\nalsa-utils\n \
66 alsa-plugins\nalsa-lib" > dependencies/$TARGET.dep
67 ;;
68 * ) # Default
69 xsltproc --stringparam dependencies $DEP_LEVEL \
70 -o dependencies/$TARGET.dep \
71 ../dependencies.xsl ../$PKGXML
72 ;;
73 esac
74
75 #---------------------
76 # Start with a clean $TARGET-index.xml.tmp file
77 > $TARGET-index.xml.tmp
78
79 #---------------------
80 # Write the XInclude
81 echo -e " $ENTRY_START$PKGXML$ENTRY_END" >> $TARGET-index.xml.tmp
82
83 #------------------P---
84 # Start with a clean depure.txt file
85 > depure.txt
86
87 #---------------------
88 # If have dependencies, write its XInclude and find sub-dependencies
89 if [[ -f dependencies/$TARGET.dep ]]; then
90 echo -e "Start loop for PKG $TARGET\n" >> depure.txt
91 mkdir xincludes && do_dependencies $TARGET
92 fi
93
94 echo "done"
95}
96
97
98
99#-----------------------#
100do_dependencies() { # Loop to find sub-dependencies :::WARNING::: THIS IS A RECURVISE FUNCTION
101#-----------------------#
102: <<inline_doc
103 function: Loop through all the packages and create a sub-dependency tree
104 input vars: $1, package name
105 externals: vars: $DEP_LEVEL
106 $TARGET
107 $PRINT_SERVER
108 $KBR5
109 $GHOSTSCRIPT
110 $MAILSERVER
111 file: depure.txt
112 $TARGET-index.xml.tmp
113 $PKG.dep
114 $PKG.inc
115 modifies: files
116 returns: nothing
117 output: file: $PKG-xinc.tmp
118 depure.txt
119 $TARGET-index.xml.tmp
120 on error: exit
121 on success:
122inline_doc
123
124 set -e
125 local PKG=$1
126 local saveIFS=$IFS
127 local DEP_LV=$DEP_LEVEL
128 local line line2 DEP
129 echo -e "\tPKG is $PKG" >> depure.txt
130 echo -e "\tDEP_LEVEL for $PKG is $DEP_LV\n" >> depure.txt
131
132 #------------------
133 # If a premade xinclude file exists, use it. If not, create one
134 if [[ -f xincludes/$PKG.xinc ]] ; then
135 echo -e "\tReusing xinclude file for PKG $PKG" >> depure.txt
136 IFS=$'\x0A'
137 for line in `cat xincludes/$PKG.xinc` ; do
138 IFS=$saveIFS
139 # Remove the Xinclude entry if found. We want the most newer one.
140 # Using double quotes to let bash expand variables.
141 # Remove also the empty line created. Can not be done in one step
142 # due that d requires the pattner between /, but we have a lot of /
143 # inside the pattner.
144 sed -e "s,^[[:space:]]*$line,," -e '/./!d' -i $TARGET-index.xml.tmp
145 # Write the XInclude
146 echo -e "$line" >> $TARGET-index.xml.tmp
147 done
148 return
149 fi
150
151 #------------------
152 # Start with a clean $PKG.xinc.tmp file
153 > xincludes/$PKG.xinc.tmp
154 for DEP in `cat dependencies/$PKG.dep`; do
155 # Special packages (a lot of hacks)
156 case $DEP in
157
158 db ) # The proper version of DB is installed in LFS
159 continue ;;
160 hal-requirements ) # ID value don't have their own XML package file
161 continue ;;
162 perl-* | tk-perl ) DEP=perl-modules ;;
163
164 # Orphan links (proper link must be created when generating the book)
165 arts ) DEP=aRts ;; # That should be fixed in the BLFS book
166 # Set values for alternative packages
167 # X is a meta-package, thus handled in another way.
168 LPRng | cups ) DEP=$PRINT_SERVER ;;
169 mitkrb | heimdal ) DEP=$KBR5 ;;
170 gs | espgs ) DEP=$GHOSTSCRIPT ;;
171 MTA ) DEP=$MAIL_SERVER ;; # The BLFS book need be fixed yet for that
172 esac
173
174 #------------------
175 echo -e "\tDEP for $PKG is $DEP" >> depure.txt
176 # Prevent circular dependencies when level 3
177 case $DEP in
178 python )
179 # cracklib-->python-->tk-->X-->linux-pam-->cracklib
180 [[ "$PKG" = "cracklib" ]] && continue
181 ;;
182 jadetex | perl-* | lynx | Links | w3m )
183 # Optional dependencies are runtime only
184 [[ "$PKG" = "docbook-utils" ]] && continue
185 ;;
186 libxslt )
187 # libxml2-->libxslt-->libxml2
188 [[ "$PKG" = "libxml2" ]] && continue
189 ;;
190 openldap | postgresql | $KBR5 )
191 # cyrus-sasl-->several-->cyrus-sasl
192 [[ "$PKG" = "cyrus-sasl" ]] && continue
193 ;;
194 doxygen )
195 # alsa-lib-->doxygen-->graphviz-->jdk-->alsa-lib
196 # Commented out due that it bomb "jdk 3" Why??
197 #[[ "$PKG" = "alsa-lib" ]] && continue
198 # libexif-->doxygen-->graphviz-->php-->libexif
199 [[ "$PKG" = "libexif" ]] && continue
200 ;;
201 qt )
202 # unixodbc-->qt-->unixodbc
203 [[ "$PKG" = "unixodbc" ]] && continue
204 ;;
205 espgs )
206 # sendmail-->espgs-->cups-->php-->sendmail
207 # We should to use $MAIL_SERVER, when it actually work :-/
208 [[ "$PKG" = "sendmail" ]] && continue
209 ;;
210 graphviz )
211 # libexif-->graphviz-->php-->libexif
212 [[ "$PKG" = "libexif" ]] && continue
213 ;;
214 aRts )
215 # esound-->aRts-->esound
216 [[ "$PKG" = "esound" ]] && continue
217 ;;
218 gimp )
219 # imagemagick-->gimp-->imagemagick
220 [[ "$PKG" = "imagemagick" ]] && continue
221 ;;
222 esac
223
224 #------------------
225 echo -e "\tDEP_LEVEL for $DEP is $DEP_LV" >> depure.txt
226 # XML file of dependency package
227 DEP_XML=`grep "^$DEP[[:space:]]" ../packages | cut -f2`
228 echo -e "\t\tDEP_XML is $DEP_XML\n" >> depure.txt
229 case $DEP in
230 x-window-system ) ;; # No page for that (proper link must be created when generating the book)
231 xorg7 ) ;; # This page will be dump in the xorg7.xinc file
232 * )
233 # Remove the Xinclude entry if found
234 sed -e "s,^[[:space:]]*$ENTRY_START$DEP_XML$ENTRY_END,," \
235 -e '/./!d' -i xincludes/$PKG.xinc.tmp
236 # Write the XInclude
237 echo -e " $ENTRY_START$DEP_XML$ENTRY_END" >> xincludes/$PKG.xinc.tmp
238 ;;
239 esac
240
241 #------------------
242 # If not already created, create its dependencies list
243 if [[ ! -f dependencies/$DEP.dep ]] ; then
244 case $DEP in
245 alsa-lib ) ;; # Only one optional dependency and is recursive.
246 # When placed inside the circular dependencies handler
247 # some packages may bomb. But I don't know yet why
248 # Meta-packages at dependency level (ugly *.dep files, but work for now)
249 alsa ) # When dependency "alsa", use all alsa-* packages
250 echo -e "alsa-oss\nalsa-firmware\nalsa-tools\nalsa-utils\n \
251 alsa-plugins\nalsa-lib" > dependencies/$DEP.dep
252 ;;
253 x-window-system ) # X11 alternatives
254 echo -e "x-config\nx-setup\n$X11" > dependencies/$DEP.dep
255 ;;
256 xorg7 ) # All Xorg7 packages except Xterm (circular dependency)
257 echo -e "rman\nxorg7-driver\nxorg7-server\nluit\nxorg7-font\n \
258 xorg7-data\nxorg7-app\nxbitmaps\nmesalib\nlibdrm\n \
259 xorg7-lib\nxorg7-util\nxorg7-proto" > dependencies/$DEP.dep
260 ;;
261 * ) xsltproc --stringparam dependencies $DEP_LV \
262 -o dependencies/$DEP.dep ../dependencies.xsl ../$DEP_XML
263 ;;
264 esac
265 fi
266
267 #------------------
268 # If needed, process its dependencies
269 if [[ -f dependencies/$DEP.dep ]] ; then
270 # If a premade xinclude file esist, include it
271 if [[ -f xincludes/$DEP.xinc ]] ; then
272 echo -e "\tReusing xinclude file for PKG $DEP (to solve $PKG)\n" >> depure.txt
273 IFS=$'\x0A'
274 for line2 in `cat xincludes/$DEP.xinc` ; do
275 IFS=$saveIFS
276 # Remove the Xinclude entry if found
277 sed -e "s,^[[:space:]]*$line2,," -e '/./!d' -i xincludes/$PKG.xinc.tmp
278 # Write the XInclude
279 echo -e "$line2" >> xincludes/$PKG.xinc.tmp
280 done
281 #------------------
282 # Create the xinclude file
283 else
284 echo -e "\nStart new loop for PKG $DEP (to solve $PKG)\n" >> depure.txt
285 #
286 # >>>>>> THIS IS A RECURSIVE FUNCTION CALL.. BEWARE OF GREMLINS. <<<<<<
287 #
288 # If the recursion depth is not too great this is an acceptable methodology for a script language
289 # However, uncontrolled recursion will cause a seg-fault due to stack issues with local variables.
290 #
291 set +e
292 [[ "${VERBOSITY}" > 0 ]] && echo -ne "\nrecursive call: $((++cntr)) ${spaceSTR:0:$cntr} ${RED}$DEP${OFF}"
293 do_dependencies $DEP
294 [[ "${VERBOSITY}" > 0 ]] && echo -ne "\nrecursive ret: $cntr ${spaceSTR:0:$((cntr--))} ${GREEN}$DEP${OFF}\tUsing the new xinclude file for PKG $DEP (to solve $PKG)"
295 set -e
296
297 # Include it when done
298 echo -e "\tUsing the new xinclude file for PKG $DEP (to solve $PKG)\n" >> depure.txt
299 IFS=$'\x0A'
300 for line2 in `cat xincludes/$DEP.xinc` ; do
301 IFS=$saveIFS
302 # Remove the Xinclude entry if found
303 sed -e "s,^[[:space:]]*$line2,," -e '/./!d' -i xincludes/$PKG.xinc.tmp
304 # Write the XInclude
305 echo -e "$line2" >> xincludes/$PKG.xinc.tmp
306 done
307 fi
308 fi
309 done
310
311 #------------------
312 if [[ "$PKG" = "xorg7" ]] ; then
313 # Add their XInclude
314 PKG_XML=`grep "^$PKG[[:space:]]" ../packages | cut -f2`
315 echo -e " $ENTRY_START$PKG_XML$ENTRY_END" >> xincludes/$PKG.xinc.tmp
316 fi
317
318 #------------------
319 mv xincludes/$PKG.xinc.tmp xincludes/$PKG.xinc
320 echo -e "Using the new xinclude file for PKG $PKG" >> depure.txt
321 IFS=$'\x0A'
322 for line in `cat xincludes/$PKG.xinc` ; do
323 IFS=$saveIFS
324 # Remove the Xinclude entry if found.
325 sed -e "s,^[[:space:]]*$line,," -e '/./!d' -i $TARGET-index.xml.tmp
326 # Write the XInclude
327 echo -e "$line" >> $TARGET-index.xml.tmp
328 done
329
330 echo -e "\nEnd loop for PKG $PKG\n" >> depure.txt
331}
Note: See TracBrowser for help on using the repository browser.