source: BLFS/libs/func_dependencies@ 323f805

experimental
Last change on this file since 323f805 was 323f805, checked in by Manuel Canales Esparcia <manuel@…>, 18 years ago

Pre-generating dep files for alsa, kde-koffice, and xorg7.

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