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