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