source: BLFS/libs/func_dependencies@ e557f50

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

Using the proper desktop-file-utils and shared-mime-info package files from the begining.

  • Property mode set to 100644
File size: 10.6 KB
RevLine 
[1d2f9d4]1#!/bin/bash
2#
3# $Id$
4#
5set -e
6
[41d4c11]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
[2a3e0f0]20 modifies: vars: PKGXML
[41d4c11]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
[2a3e0f0]32
[41d4c11]33 #---------------------
34 # Create the working directory and cd into it
[6f0f0ed]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
[41d4c11]42
43 #---------------------
44 # XML file of the target package
45 PKGXML=`grep "^$TARGET[[:space:]]" ../packages | cut -f2`
46
47 #---------------------
48 # The BLFS sources directory.
[4761b5a]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.
[41d4c11]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
[d0d9e90]65 echo -e "\tGenerating $TARGET dependencies tree ..."
[41d4c11]66
[ad3bf2c]67 mkdir dependencies
68
[41d4c11]69 #---------------------
70 # Create target package dependencies list
71 case $TARGET in
[f1fadeb]72 # Skip the creation when all dependencies are circular.
73 alsa-lib | cracklib | libexif | unixodbc ) ;;
[ad3bf2c]74
[41d4c11]75 # Meta-packages at target level
[ad3bf2c]76 alsa )
[323f805]77 cp ../libs/alsa.dep dependencies/
[ad3bf2c]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 )
[323f805]92 cp ../libs/kde-{core,full,koffice}.dep dependencies/
[41d4c11]93 ;;
[f2a45d9]94 xorg7 )
[323f805]95 cp ../libs/xorg7.dep dependencies/
[6f0f0ed]96 ;;
[41d4c11]97 * ) # Default
98 xsltproc --stringparam dependencies $DEP_LEVEL \
99 -o dependencies/$TARGET.dep \
[2ca2992]100 ../libs/dependencies.xsl ../$PKGXML
[41d4c11]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
[f1fadeb]110 case $TARGET in
111 # If there is no usefull XML page, skip it.
[ad3bf2c]112 alsa | gnome-core | gnome-full | kde-core | kde-full | kde-koffice ) ;;
[f1fadeb]113 * )
114 echo -e " $ENTRY_START$PKGXML$ENTRY_END" >> $TARGET-index.xml.tmp
115 ;;
116 esac
[41d4c11]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
[d0d9e90]124 echo -e "\n\t... done"
[41d4c11]125}
126
127
128
[1d2f9d4]129#-----------------------#
[41d4c11]130do_dependencies() { # Loop to find sub-dependencies :::WARNING::: THIS IS A RECURVISE FUNCTION
[1d2f9d4]131#-----------------------#
[41d4c11]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
[2a3e0f0]144 $PKG.inc
[41d4c11]145 modifies: files
146 returns: nothing
147 output: file: $PKG-xinc.tmp
148 depure.txt
149 $TARGET-index.xml.tmp
150 on error: exit
[2a3e0f0]151 on success:
[41d4c11]152inline_doc
153
[1d2f9d4]154 set -e
155 local PKG=$1
156 local saveIFS=$IFS
157 local DEP_LV=$DEP_LEVEL
158 local line line2 DEP
159
[41d4c11]160 #------------------
161 # If a premade xinclude file exists, use it. If not, create one
[1d2f9d4]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
[41d4c11]175 return
176 fi
[2a3e0f0]177
[41d4c11]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
[2a3e0f0]184
[4fe29a2]185 db ) continue ;; # The proper version of DB is installed in LFS
[4761b5a]186
187 # Don't have their own XML file
[4fe29a2]188 hal-requirements | hal-runtime-dependencies ) continue ;;
189 perl-* | tk-perl ) DEP=perl-modules ;;
[41d4c11]190
[1d2f9d4]191 # Orphan links (proper link must be created when generating the book)
[4761b5a]192 arts ) DEP=aRts ;;
193 kde ) DEP=kde-core ;;
[4fe29a2]194
[1d2f9d4]195 # Set values for alternative packages
196 # X is a meta-package, thus handled in another way.
[4fe29a2]197 LPRng | cups ) DEP=$PRINT_SERVER ;;
198 mitkrb | heimdal ) DEP=$KBR5 ;;
199 gs | espgs ) DEP=$GHOSTSCRIPT ;;
200 server-mail ) DEP=$MAIL_SERVER ;;
[41d4c11]201 esac
202
203 #------------------
[f1fadeb]204 # Prevent circular dependencies
205 # If all dependencies are circular, the creation of the *.dep file
206 # must be skipped, not placed here, to avoid that the script will bomb
207 # due empty *.xinc files
[41d4c11]208 case $DEP in
[2a3e0f0]209 jadetex | perl-* | lynx | Links | w3m )
210 # Optional dependencies are runtime only
211 [[ "$PKG" = "docbook-utils" ]] && continue
212 ;;
213 libxslt )
214 # libxml2-->libxslt-->libxml2
215 [[ "$PKG" = "libxml2" ]] && continue
216 ;;
217 openldap | postgresql | $KBR5 )
218 # cyrus-sasl-->several-->cyrus-sasl
219 [[ "$PKG" = "cyrus-sasl" ]] && continue
220 ;;
221 espgs )
222 # sendmail-->espgs-->cups-->php-->sendmail
[da8017e]223 [[ "$PKG" = "$MAIL_SERVER" ]] && continue
[2a3e0f0]224 ;;
225 aRts )
226 # esound-->aRts-->esound
227 [[ "$PKG" = "esound" ]] && continue
228 ;;
[f1fadeb]229 gimp | sane )
230 # imagemagick-->{sane}-->gimp-->imagemagick
[2a3e0f0]231 [[ "$PKG" = "imagemagick" ]] && continue
[41d4c11]232 ;;
[f1fadeb]233 ffmpeg )
234 # alsa-plugins-->ffmpeg-->several-->alsa-plugins
235 [[ "$PKG" = "alsa-plugins" ]] && continue
236 ;;
[ad3bf2c]237 akode )
238 # Both are in the same page
239 [[ "$PKG" = "kdemultimedia" ]] && continue
240 ;;
[41d4c11]241 esac
242
243 #------------------
244 # XML file of dependency package
245 DEP_XML=`grep "^$DEP[[:space:]]" ../packages | cut -f2`
246 case $DEP in
[f1fadeb]247 x-window-system | alsa ) ;; # No page for that (proper link must be created when generating the book)
[41d4c11]248 xorg7 ) ;; # This page will be dump in the xorg7.xinc file
[ad3bf2c]249 gnome-core | kde-core | kde-full ) ;; # Invented packages
[41d4c11]250 * )
251 # Remove the Xinclude entry if found
252 sed -e "s,^[[:space:]]*$ENTRY_START$DEP_XML$ENTRY_END,," \
253 -e '/./!d' -i xincludes/$PKG.xinc.tmp
254 # Write the XInclude
255 echo -e " $ENTRY_START$DEP_XML$ENTRY_END" >> xincludes/$PKG.xinc.tmp
256 ;;
257 esac
258
259 #------------------
260 # If not already created, create its dependencies list
261 if [[ ! -f dependencies/$DEP.dep ]] ; then
[1d2f9d4]262 case $DEP in
[f1fadeb]263 # Skip the creation when all dependencies are circular.
264 alsa-lib | cracklib | libexif | unixodbc ) ;;
[addb529]265 # Meta-packages at dependency level
[323f805]266 alsa )
267 cp ../libs/alsa.dep dependencies/
[41d4c11]268 ;;
[6a49a38]269 kde-core )
270 cp ../libs/kde-core.dep dependencies/
271 ;;
[41d4c11]272 x-window-system ) # X11 alternatives
[ad3bf2c]273 echo -e "x-config\nx-setup\n$X11" > dependencies/x-window-system.dep
[41d4c11]274 ;;
[323f805]275 xorg7 ) # At dependencies level, remove x-config and x-setup
276 cp ../libs/xorg7.dep dependencies/
277 sed -i '/x-config/d;/x-setup/d' dependencies/xorg7.dep
[41d4c11]278 ;;
279 * ) xsltproc --stringparam dependencies $DEP_LV \
[2ca2992]280 -o dependencies/$DEP.dep ../libs/dependencies.xsl ../$DEP_XML
[1d2f9d4]281 ;;
282 esac
[41d4c11]283 fi
284
285 #------------------
286 # If needed, process its dependencies
287 if [[ -f dependencies/$DEP.dep ]] ; then
288 # If a premade xinclude file esist, include it
289 if [[ -f xincludes/$DEP.xinc ]] ; then
290 IFS=$'\x0A'
291 for line2 in `cat xincludes/$DEP.xinc` ; do
292 IFS=$saveIFS
[1d2f9d4]293 # Remove the Xinclude entry if found
[41d4c11]294 sed -e "s,^[[:space:]]*$line2,," -e '/./!d' -i xincludes/$PKG.xinc.tmp
[1d2f9d4]295 # Write the XInclude
[41d4c11]296 echo -e "$line2" >> xincludes/$PKG.xinc.tmp
297 done
298 #------------------
299 # Create the xinclude file
300 else
301 #
302 # >>>>>> THIS IS A RECURSIVE FUNCTION CALL.. BEWARE OF GREMLINS. <<<<<<
303 #
304 # If the recursion depth is not too great this is an acceptable methodology for a script language
305 # However, uncontrolled recursion will cause a seg-fault due to stack issues with local variables.
[2a3e0f0]306 #
[41d4c11]307 set +e
[d0d9e90]308 [[ "${VERBOSITY}" > 0 ]] && echo -ne "\ncall: $((++cntr))${spaceSTR:0:$cntr}${RED}$DEP${OFF}"
[41d4c11]309 do_dependencies $DEP
[d0d9e90]310 [[ "${VERBOSITY}" > 0 ]] && echo -ne "\n ret: $cntr${spaceSTR:0:$((cntr--))}${GREEN}$DEP${OFF} Using $DEP Xinc to solve $PKG"
[41d4c11]311 set -e
[2a3e0f0]312
[41d4c11]313 # Include it when done
314 IFS=$'\x0A'
315 for line2 in `cat xincludes/$DEP.xinc` ; do
316 IFS=$saveIFS
317 # Remove the Xinclude entry if found
318 sed -e "s,^[[:space:]]*$line2,," -e '/./!d' -i xincludes/$PKG.xinc.tmp
319 # Write the XInclude
320 echo -e "$line2" >> xincludes/$PKG.xinc.tmp
321 done
[1d2f9d4]322 fi
323 fi
[41d4c11]324 done
325
326 #------------------
327 if [[ "$PKG" = "xorg7" ]] ; then
328 # Add their XInclude
[addb529]329 PKG_XML=${BLFS_XML}/x/installing/xorg7.xml
[41d4c11]330 echo -e " $ENTRY_START$PKG_XML$ENTRY_END" >> xincludes/$PKG.xinc.tmp
[1d2f9d4]331 fi
332
[41d4c11]333 #------------------
334 mv xincludes/$PKG.xinc.tmp xincludes/$PKG.xinc
335 IFS=$'\x0A'
336 for line in `cat xincludes/$PKG.xinc` ; do
337 IFS=$saveIFS
338 # Remove the Xinclude entry if found.
339 sed -e "s,^[[:space:]]*$line,," -e '/./!d' -i $TARGET-index.xml.tmp
340 # Write the XInclude
341 echo -e "$line" >> $TARGET-index.xml.tmp
342 done
[1d2f9d4]343}
Note: See TracBrowser for help on using the repository browser.