[3c10176] | 1 | #!/bin/bash
|
---|
| 2 | #
|
---|
| 3 | # $Id$
|
---|
| 4 | #
|
---|
| 5 | set -e
|
---|
| 6 |
|
---|
| 7 | declare -i cntr=0
|
---|
| 8 | declare -a spaceSTR=" "
|
---|
| 9 |
|
---|
| 10 | #----------------------------#
|
---|
| 11 | generate_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
|
---|
| 28 | inline_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 |
|
---|
[249874a] | 63 | echo -e "\tGenerating $TARGET dependencies tree ..."
|
---|
[3c10176] | 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 )
|
---|
[f4ed135] | 75 | cp ../libs/alsa.dep dependencies/
|
---|
[3c10176] | 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 )
|
---|
[f4ed135] | 90 | cp ../libs/kde-{core,full,koffice}.dep dependencies/
|
---|
[3c10176] | 91 | ;;
|
---|
[f4ed135] | 92 | xorg7 )
|
---|
| 93 | cp ../libs/xorg7.dep dependencies/
|
---|
[3c10176] | 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.
|
---|
[f4ed135] | 110 | alsa | gnome-core | gnome-full | kde-core | kde-full | kde-koffice | xorg7) ;;
|
---|
[3c10176] | 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 |
|
---|
[249874a] | 122 | echo -e "\n\t... done"
|
---|
[3c10176] | 123 | }
|
---|
| 124 |
|
---|
| 125 |
|
---|
| 126 |
|
---|
| 127 | #-----------------------#
|
---|
| 128 | do_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:
|
---|
| 150 | inline_doc
|
---|
| 151 |
|
---|
| 152 | set -e
|
---|
| 153 | local PKG=$1
|
---|
| 154 | local saveIFS=$IFS
|
---|
| 155 | local DEP_LV=$DEP_LEVEL
|
---|
[f4ed135] | 156 | local line line2 DEP pkg_ver inst_ver
|
---|
[3c10176] | 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
|
---|
[f4ed135] | 180 |
|
---|
| 181 | # Special packages that need be remaped
|
---|
[3c10176] | 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 |
|
---|
| 190 | # Orphan links (proper link must be created when generating the book)
|
---|
| 191 | arts ) DEP=aRts ;;
|
---|
| 192 | kde ) DEP=kde-core ;;
|
---|
| 193 |
|
---|
| 194 | # Set values for alternative packages
|
---|
| 195 | LPRng | cups ) DEP=$PRINT_SERVER ;;
|
---|
| 196 | mitkrb | heimdal ) DEP=$KBR5 ;;
|
---|
| 197 | gs | espgs ) DEP=$GHOSTSCRIPT ;;
|
---|
| 198 | server-mail ) DEP=$MAIL_SERVER ;;
|
---|
[f4ed135] | 199 | x-window-system )
|
---|
| 200 | case $X11 in
|
---|
| 201 | xorg7 ) DEP=xorg7 ;;
|
---|
| 202 | * )
|
---|
| 203 | pkg_ver=$(grep "^${X11}[[:space:]]" ../packages | cut -f3)
|
---|
| 204 | inst_ver=$(grep "^${X11}[[:space:]]" ../packages | cut -f4)
|
---|
| 205 | [ -n "${pkg_ver}" ] && [ "x${pkg_ver}" = "x${inst_ver}" ] && continue
|
---|
| 206 | ;;
|
---|
| 207 | esac
|
---|
| 208 | ;;
|
---|
[3c10176] | 209 | esac
|
---|
| 210 |
|
---|
[f4ed135] | 211 | # If DEP has been previouly installed, skip it
|
---|
| 212 | pkg_ver=$(grep "^${DEP}[[:space:]]" ../packages | cut -f3)
|
---|
| 213 | inst_ver=$(grep "^${DEP}[[:space:]]" ../packages | cut -f4)
|
---|
| 214 | [ -n "${pkg_ver}" ] && [ "x${pkg_ver}" = "x${inst_ver}" ] && continue
|
---|
| 215 |
|
---|
[3c10176] | 216 | #------------------
|
---|
| 217 | # Prevent circular dependencies
|
---|
| 218 | # If all dependencies are circular, the creation of the *.dep file
|
---|
| 219 | # must be skipped, not placed here, to avoid that the script will bomb
|
---|
| 220 | # due empty *.xinc files
|
---|
| 221 | case $DEP in
|
---|
| 222 | jadetex | perl-* | lynx | Links | w3m )
|
---|
| 223 | # Optional dependencies are runtime only
|
---|
| 224 | [[ "$PKG" = "docbook-utils" ]] && continue
|
---|
| 225 | ;;
|
---|
| 226 | libxslt )
|
---|
| 227 | # libxml2-->libxslt-->libxml2
|
---|
| 228 | [[ "$PKG" = "libxml2" ]] && continue
|
---|
| 229 | ;;
|
---|
| 230 | openldap | postgresql | $KBR5 )
|
---|
| 231 | # cyrus-sasl-->several-->cyrus-sasl
|
---|
| 232 | [[ "$PKG" = "cyrus-sasl" ]] && continue
|
---|
| 233 | ;;
|
---|
| 234 | espgs )
|
---|
| 235 | # sendmail-->espgs-->cups-->php-->sendmail
|
---|
| 236 | [[ "$PKG" = "$MAIL_SERVER" ]] && continue
|
---|
| 237 | ;;
|
---|
| 238 | aRts )
|
---|
| 239 | # esound-->aRts-->esound
|
---|
| 240 | [[ "$PKG" = "esound" ]] && continue
|
---|
| 241 | ;;
|
---|
| 242 | gimp | sane )
|
---|
| 243 | # imagemagick-->{sane}-->gimp-->imagemagick
|
---|
| 244 | [[ "$PKG" = "imagemagick" ]] && continue
|
---|
| 245 | ;;
|
---|
| 246 | ffmpeg )
|
---|
| 247 | # alsa-plugins-->ffmpeg-->several-->alsa-plugins
|
---|
| 248 | [[ "$PKG" = "alsa-plugins" ]] && continue
|
---|
| 249 | ;;
|
---|
[53e258f] | 250 | GTK )
|
---|
| 251 | # deprecated GTK version
|
---|
| 252 | [[ "$PKG" = "alsa-tools" ]] && continue
|
---|
| 253 | ;;
|
---|
[3c10176] | 254 | akode )
|
---|
| 255 | # Both are in the same page
|
---|
| 256 | [[ "$PKG" = "kdemultimedia" ]] && continue
|
---|
| 257 | ;;
|
---|
[53e258f] | 258 | dbus )
|
---|
| 259 | # cups-->dbus-->several combinations-->cups
|
---|
| 260 | [[ "$PKG" = "cups" ]] && continue
|
---|
| 261 | ;;
|
---|
| 262 | librsvg | poppler | gtk2 )
|
---|
| 263 | # All optinal testsuite dependencies are circular
|
---|
| 264 | [[ "$PKG" = "cairo" ]] && continue
|
---|
| 265 | ;;
|
---|
[3c10176] | 266 | esac
|
---|
| 267 |
|
---|
| 268 | #------------------
|
---|
| 269 | # XML file of dependency package
|
---|
| 270 | DEP_XML=`grep "^$DEP[[:space:]]" ../packages | cut -f2`
|
---|
| 271 | case $DEP in
|
---|
| 272 | x-window-system | alsa ) ;; # No page for that (proper link must be created when generating the book)
|
---|
| 273 | xorg7 ) ;; # This page will be dump in the xorg7.xinc file
|
---|
| 274 | gnome-core | kde-core | kde-full ) ;; # Invented packages
|
---|
| 275 | * )
|
---|
| 276 | # Remove the Xinclude entry if found
|
---|
| 277 | sed -e "s,^[[:space:]]*$ENTRY_START$DEP_XML$ENTRY_END,," \
|
---|
| 278 | -e '/./!d' -i xincludes/$PKG.xinc.tmp
|
---|
| 279 | # Write the XInclude
|
---|
| 280 | echo -e " $ENTRY_START$DEP_XML$ENTRY_END" >> xincludes/$PKG.xinc.tmp
|
---|
| 281 | ;;
|
---|
| 282 | esac
|
---|
| 283 |
|
---|
| 284 | #------------------
|
---|
| 285 | # If not already created, create its dependencies list
|
---|
| 286 | if [[ ! -f dependencies/$DEP.dep ]] ; then
|
---|
| 287 | case $DEP in
|
---|
| 288 | # Skip the creation when all dependencies are circular.
|
---|
| 289 | alsa-lib | cracklib | libexif | unixodbc ) ;;
|
---|
[f4ed135] | 290 | # Meta-packages at dependency level
|
---|
| 291 | alsa )
|
---|
| 292 | cp ../libs/alsa.dep dependencies/
|
---|
[3c10176] | 293 | ;;
|
---|
| 294 | kde-core )
|
---|
| 295 | cp ../libs/kde-core.dep dependencies/
|
---|
| 296 | ;;
|
---|
[f4ed135] | 297 | x-window-system ) # When X11 is not Xorg7
|
---|
[3c10176] | 298 | echo -e "x-config\nx-setup\n$X11" > dependencies/x-window-system.dep
|
---|
| 299 | ;;
|
---|
| 300 | xorg7 )
|
---|
[f4ed135] | 301 | cp ../libs/xorg7.dep dependencies/
|
---|
[3c10176] | 302 | ;;
|
---|
| 303 | * ) xsltproc --stringparam dependencies $DEP_LV \
|
---|
| 304 | -o dependencies/$DEP.dep ../libs/dependencies.xsl ../$DEP_XML
|
---|
| 305 | ;;
|
---|
| 306 | esac
|
---|
| 307 | fi
|
---|
| 308 |
|
---|
| 309 | #------------------
|
---|
| 310 | # If needed, process its dependencies
|
---|
| 311 | if [[ -f dependencies/$DEP.dep ]] ; then
|
---|
| 312 | # If a premade xinclude file esist, include it
|
---|
| 313 | if [[ -f xincludes/$DEP.xinc ]] ; then
|
---|
| 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
|
---|
| 322 | #------------------
|
---|
| 323 | # Create the xinclude file
|
---|
| 324 | else
|
---|
| 325 | #
|
---|
| 326 | # >>>>>> THIS IS A RECURSIVE FUNCTION CALL.. BEWARE OF GREMLINS. <<<<<<
|
---|
| 327 | #
|
---|
| 328 | # If the recursion depth is not too great this is an acceptable methodology for a script language
|
---|
| 329 | # However, uncontrolled recursion will cause a seg-fault due to stack issues with local variables.
|
---|
| 330 | #
|
---|
| 331 | set +e
|
---|
[249874a] | 332 | [[ "${VERBOSITY}" > 0 ]] && echo -ne "\ncall: $((++cntr))${spaceSTR:0:$cntr}${RED}$DEP${OFF}"
|
---|
[3c10176] | 333 | do_dependencies $DEP
|
---|
[249874a] | 334 | [[ "${VERBOSITY}" > 0 ]] && echo -ne "\n ret: $cntr${spaceSTR:0:$((cntr--))}${GREEN}$DEP${OFF} Using $DEP Xinc to solve $PKG"
|
---|
[3c10176] | 335 | set -e
|
---|
| 336 |
|
---|
| 337 | # Include it when done
|
---|
| 338 | IFS=$'\x0A'
|
---|
| 339 | for line2 in `cat xincludes/$DEP.xinc` ; do
|
---|
| 340 | IFS=$saveIFS
|
---|
| 341 | # Remove the Xinclude entry if found
|
---|
| 342 | sed -e "s,^[[:space:]]*$line2,," -e '/./!d' -i xincludes/$PKG.xinc.tmp
|
---|
| 343 | # Write the XInclude
|
---|
| 344 | echo -e "$line2" >> xincludes/$PKG.xinc.tmp
|
---|
| 345 | done
|
---|
| 346 | fi
|
---|
| 347 | fi
|
---|
| 348 | done
|
---|
| 349 |
|
---|
| 350 | #------------------
|
---|
| 351 | if [[ "$PKG" = "xorg7" ]] ; then
|
---|
| 352 | # Add their XInclude
|
---|
[f4ed135] | 353 | PKG_XML=${BLFS_XML}/x/installing/xorg7.xml
|
---|
[3c10176] | 354 | echo -e " $ENTRY_START$PKG_XML$ENTRY_END" >> xincludes/$PKG.xinc.tmp
|
---|
| 355 | fi
|
---|
| 356 |
|
---|
| 357 | #------------------
|
---|
| 358 | mv xincludes/$PKG.xinc.tmp xincludes/$PKG.xinc
|
---|
| 359 | IFS=$'\x0A'
|
---|
| 360 | for line in `cat xincludes/$PKG.xinc` ; do
|
---|
| 361 | IFS=$saveIFS
|
---|
| 362 | # Remove the Xinclude entry if found.
|
---|
| 363 | sed -e "s,^[[:space:]]*$line,," -e '/./!d' -i $TARGET-index.xml.tmp
|
---|
| 364 | # Write the XInclude
|
---|
| 365 | echo -e "$line" >> $TARGET-index.xml.tmp
|
---|
| 366 | done
|
---|
| 367 | }
|
---|