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