Index: BLFS/libs/book.xsl
===================================================================
--- BLFS/libs/book.xsl	(revision 232f5955604a906e4aea6903281d5f6d8885e516)
+++ 	(revision )
@@ -1,105 +1,0 @@
-<?xml version='1.0' encoding='ISO-8859-1'?>
-
-<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
-                xmlns="http://www.w3.org/1999/xhtml"
-                version="1.0">
-
-<!-- $Id$ -->
-
-  <!-- NOTE: the base dir (blfs-xml) is set to the proper dir
-  via a sed in ./blfs -->
-  <xsl:import href="../blfs-xml/stylesheets/blfs-chunked.xsl"/>
-
-  <xsl:param name="mail_server" select="sendmail"/>
-
-  <xsl:param name="xwindow" select="xorg7"/>
-
-     <!-- Template from BLFS_XML/stylesheets/xhtml/lfs-xref.xsl.-->
-  <xsl:template match="xref" name="xref">
-
-    <!-- IDs that need be remaped to the proper file -->
-    <xsl:variable name="linkend">
-      <xsl:choose>
-        <xsl:when test="@linkend = 'alsa'">
-          <xsl:text>alsa-lib</xsl:text>
-        </xsl:when>
-        <xsl:when test="@linkend = 'arts'">
-          <xsl:text>aRts</xsl:text>
-        </xsl:when>
-        <xsl:when test="@linkend = 'kde'">
-          <xsl:text>kdelibs</xsl:text>
-        </xsl:when>
-        <xsl:when test="@linkend = 'server-mail'">
-          <xsl:value-of select="$mail_server"/>
-        </xsl:when>
-        <xsl:when test="@linkend = 'x-window-system'">
-          <xsl:value-of select="$xwindow"/>
-        </xsl:when>
-        <xsl:otherwise>
-          <xsl:value-of select="@linkend"/>
-        </xsl:otherwise>
-      </xsl:choose>
-    </xsl:variable>
-
-    <xsl:variable name="targets" select="key('id',$linkend)"/>
-    <!-- -->
-
-    <xsl:variable name="target" select="$targets[1]"/>
-    <xsl:variable name="refelem" select="local-name($target)"/>
-    <xsl:variable name="role" select="@role"/>
-    <xsl:call-template name="check.id.unique">
-      <xsl:with-param name="linkend" select="$linkend"/>
-    </xsl:call-template>
-    <xsl:call-template name="anchor"/>
-    <xsl:choose>
-
-      <!-- Dead links -->
-      <xsl:when test="count($target) = 0">
-        <b>
-          <xsl:value-of select="@linkend"/>
-        </b>
-        <tt>
-          <xsl:text> (in the full book)</xsl:text>
-        </tt>
-      </xsl:when>
-      <!-- -->
-
-      <xsl:when test="$target/@xreflabel">
-        <a>
-          <xsl:attribute name="href">
-            <xsl:call-template name="href.target">
-              <xsl:with-param name="object" select="$target"/>
-            </xsl:call-template>
-          </xsl:attribute>
-          <xsl:call-template name="xref.xreflabel">
-            <xsl:with-param name="target" select="$target"/>
-          </xsl:call-template>
-        </a>
-      </xsl:when>
-      <xsl:otherwise>
-        <xsl:variable name="href">
-          <xsl:call-template name="href.target">
-            <xsl:with-param name="object" select="$target"/>
-          </xsl:call-template>
-        </xsl:variable>
-        <xsl:apply-templates select="$target" mode="xref-to-prefix"/>
-        <a href="{$href}">
-          <xsl:if test="$target/title or $target/*/title">
-            <xsl:attribute name="title">
-              <xsl:apply-templates select="$target" mode="xref-title"/>
-            </xsl:attribute>
-          </xsl:if>
-          <xsl:apply-templates select="$target" mode="xref-to">
-            <xsl:with-param name="referrer" select="."/>
-            <xsl:with-param name="role" select="$role"/>
-            <xsl:with-param name="xrefstyle">
-              <xsl:value-of select="@xrefstyle"/>
-            </xsl:with-param>
-          </xsl:apply-templates>
-        </a>
-        <xsl:apply-templates select="$target" mode="xref-to-suffix"/>
-      </xsl:otherwise>
-    </xsl:choose>
-  </xsl:template>
-
-</xsl:stylesheet>
Index: BLFS/libs/dependencies.xsl
===================================================================
--- BLFS/libs/dependencies.xsl	(revision 232f5955604a906e4aea6903281d5f6d8885e516)
+++ 	(revision )
@@ -1,47 +1,0 @@
-<?xml version="1.0"?>
-
-<!-- $Id$ -->
-
-<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
-    version="1.0">
-
-  <xsl:output method="text"/>
-
-  <xsl:param name="dependencies" select="2"/>
-
-  <xsl:template match="/">
-    <xsl:apply-templates select="//para[@role='optional']"/>
-    <xsl:apply-templates select="//para[@role='recommended']"/>
-    <xsl:apply-templates select="//para[@role='required']"/>
-  </xsl:template>
-
-  <xsl:template match="//text()"/>
-
-  <xsl:template match="para[@role='required']">
-    <xsl:apply-templates select="xref">
-      <xsl:sort select="position()" data-type="number" order="descending"/>
-    </xsl:apply-templates>
-  </xsl:template>
-
-  <xsl:template match="para[@role='recommended']">
-    <xsl:if test="$dependencies != '1'">
-      <xsl:apply-templates select="xref">
-        <xsl:sort select="position()" data-type="number" order="descending"/>
-      </xsl:apply-templates>
-    </xsl:if>
-  </xsl:template>
-
-  <xsl:template match="para[@role='optional']">
-    <xsl:if test="$dependencies = '3'">
-      <xsl:apply-templates select="xref">
-        <xsl:sort select="position()" data-type="number" order="descending"/>
-      </xsl:apply-templates>
-    </xsl:if>
-  </xsl:template>
-
-  <xsl:template match="xref">
-    <xsl:value-of select="@linkend"/>
-    <xsl:text>&#xA;</xsl:text>
-  </xsl:template>
-
-</xsl:stylesheet>
Index: BLFS/libs/func_dependencies
===================================================================
--- BLFS/libs/func_dependencies	(revision 232f5955604a906e4aea6903281d5f6d8885e516)
+++ BLFS/libs/func_dependencies	(revision 63fc514fa4465531008488ff3e3e148ba03bffc4)
@@ -3,8 +3,16 @@
 # $Id$
 #
-set -e
 
-declare -i cntr=0
+# A string of spaces for indenting:
 declare -a spaceSTR="                                                                   "
+declare -a exchange_triplet
+
+# In case we find a cirdular dependency, it has the form :
+# parent->dependency_0->...->dependency_n->dependency_0
+# If we want to build dependency_n before dependency_0,
+# no problem: we just prune the tree at dependency_n.
+# If we want to build first dependency_0, we need to
+# put dependency_n as a dependency of parent. The triplet
+# above shall contain (parent dependency_0 dependency_n)
 
 #----------------------------#
@@ -12,426 +20,177 @@
 #----------------------------#
 : <<inline_doc
-    function:   Create a dependency tree for the TARGET
-    input vars: none
-    externals:  vars: TARGET
-                      PKGXML
+    function:   Create a subtree of the dependency tree
+                (recursive function)
+    input vars: $1 : file with a list of targets
+		     the first line of the file is an array
+                     of links
+    externals:  vars: BLFS_XML
 		      DEP_LEVEL
-                func: do_dependencies
-    modifies:   vars: PKGXML
-                      BLFS_XML
+    modifies:   vars: none
     returns:    nothing
-    output:     files: $TARGET.dep
-                       $TARGET-index.xml.tmp
-                       depure.txt
+    output:     files: for each pkg with dependencies in $1,
+                       a file pkg.dep and its dependencies
     on error:   nothing
     on success: nothing
 inline_doc
 
-  local ENTRY_START
-  local ENTRY_END
+local DepFile=$1
+local -a rootlink
+local -a otherlink
+local -i depth
+local -i count=0
+local id_of_dep
+local parent
+local lines_to_remove=
+local srootlink
+local dep_level
 
-  #---------------------
-  # Create the working directory and cd into it
-  if [[ -d $TARGET ]] ; then
-    echo -e "\tERROR: Looks like $TARGET has been already processed."
-    echo -e "\tPlease delete or rename the $TARGET directory.\n"
-    exit 1
-  else
-    mkdir $TARGET && cd $TARGET
+{
+# BEWARE : the order of options matters : read -a -u6 rootlink hangs forever
+# (actually, the doc says -a array -u fd)
+# We use fd number 6 for input from DepFile, because we need 0 for user input
+read -u6 -a rootlink
+depth=${#rootlink[*]}
+dep_level=$DEP_LEVEL
+if (( $DEP_LEVEL > 2 )) && (( $depth > 1 )); then dep_level=2; fi
+srootlink="${rootlink[*]} "
+# start of Depfile
+echo -en "\nNode: $depth${spaceSTR:0:$depth}${RED}$DepFile${OFF}"
+
+while read -u6 id_of_dep; do
+# count entries in file
+  (( count++ ))
+# Has this entry already been seen?
+  if [ -f ${id_of_dep}.dep ]; then # found ${id_of_dep}.dep already in tree
+    otherlink=($(head -n 1 ${id_of_dep}.dep))
+    if [ -z "${otherlink[*]}" ] 
+      then echo otherlink empty for $id_of_dep.dep
+      echo This should not happen, but happens to happen...
+      exit 1
+    fi
+# Do not use "${rootlink[*]}" =~ "${otherlink[*]}": case rootlink=(1 11)
+# and otherlink=(1 1)
+    if [[ ${srootlink#"${otherlink[*]} "} != ${srootlink} ]]; then # circular dep
+# First look for the other parent of this dependency.
+# The parent has the same link without the last entry.
+# We do not need otherlink anymore so just destroy the last element
+      unset otherlink[${#otherlink[*]}-1]
+      parent=$(grep ^"${otherlink[*]}"\$ -l *)
+      parent=${parent%.dep}
+      echo -en "\nCirc: $depth${spaceSTR:0:$depth}${BLUE}Circular dependency detected:${OFF}"
+      echo -en "\nCirc: $depth${spaceSTR:0:$depth}${BOLD}${id_of_dep}${OFF} is a dependency \
+of ${BOLD}${parent}${OFF}"
+      echo -en "\nCirc: $depth${spaceSTR:0:$depth}${BOLD}${DepFile%.dep}${OFF} is a dependency \
+of ${BOLD}${id_of_dep}${OFF}"
+      echo -en "\nCirc: $depth${spaceSTR:0:$depth}${BOLD}${id_of_dep}${OFF} is a dependency \
+of ${BOLD}${DepFile%.dep}${OFF}"
+# If idofdep is the parent of DepFile, we can exchange them if required
+#      if grep -q ${DepFile%.dep} ${id_of_dep}.dep; then
+# we propose exchange always
+        echo -en "\nCirc: $depth${spaceSTR:0:$depth}Do you want to build ${id_of_dep} first? yes/no (no):"
+        read ANSWER
+        if [ x$ANSWER = "xyes" ] ; then  # exchange:
+# set triplet and return 1
+          exchange_triplet=($parent $id_of_dep ${DepFile%.dep})
+          return 1
+        else # no exchange: prune
+          lines_to_remove="$lines_to_remove $id_of_dep"
+        fi
+#      else
+#        lines_to_remove="$lines_to_remove $id_of_dep"
+#      fi
+    else # not circular: prune
+      lines_to_remove="$lines_to_remove $id_of_dep"
+    fi
+    continue
   fi
+  flag=true
+  while [ $flag = true ]; do
+    flag=false
+    xsltproc --stringparam dependencies ${dep_level} \
+        --stringparam idofdep $id_of_dep \
+        -o ${id_of_dep}.dep \
+        ../xsl/dependencies.xsl ../packages.xml
 
-  #---------------------
-  # XML file of the target package
-  PKGXML=`grep "^$TARGET[[:space:]]" ../packages | cut -f2`
-
-  #---------------------
-  # The BLFS sources directory.
-  BLFS_XML=`echo $PKGXML | sed -e 's,/.*,,'`
-
-  if [[ ! -d ../$BLFS_XML ]] ; then
-    echo -e "\tThe BLFS book sources directory is missing.\n"
-    echo -e "\tExecution aborted.\n"
-    cd .. && rmdir $TARGET
-    exit 1
-  fi
-
-  #---------------------
-  # XInclude stuff
-  ENTRY_START="<xi:include xmlns:xi=\"http://www.w3.org/2003/XInclude\" href=\"../"
-  ENTRY_END="\"/>"
-
-  echo -e "\tGenerating $TARGET dependencies tree ..."
-
-  mkdir dependencies
-
-  #---------------------
-  # Create target package dependencies list
-  case $TARGET in
-    # Skip the creation when all dependencies are circular.
-    alsa-lib | cracklib | libexif | unixodbc ) ;;
-
-    # Meta-packages at target level
-    alsa )
-      cp ../libs/alsa.dep dependencies/
-      ;;
-    gnome-core )
-      cp ../libs/gnome-core.dep dependencies/
-      ;;
-    gnome-full )
-      cp ../libs/gnome-{core,full}.dep dependencies/
-      ;;
-    kde-core )
-      cp ../libs/kde-core.dep dependencies/
-      ;;
-    kde-full )
-      cp ../libs/kde-{core,full}.dep dependencies/
-      ;;
-    kde-koffice )
-      cp ../libs/kde-{core,full,koffice}.dep dependencies/
-      ;;
-    xorg7 )
-      cp ../libs/xorg7.dep dependencies/
-      ;;
-    * ) # Default
-      xsltproc --stringparam dependencies $DEP_LEVEL \
-               -o dependencies/$TARGET.dep \
-               ../libs/dependencies.xsl ../$PKGXML
-      ;;
-  esac
-
-  #---------------------
-  # Start with a clean $TARGET-index.xml.tmp file
-  > $TARGET-index.xml.tmp
-
-  #---------------------
-  # Write the XInclude
-  case $TARGET in
-    # If there is no usefull XML page, skip it.
-    alsa | gnome-core | gnome-full | kde-core | kde-full | kde-koffice | xorg7) ;;
-    * )
-      echo -e "    $ENTRY_START$PKGXML$ENTRY_END" >> $TARGET-index.xml.tmp
-      ;;
-  esac
-
-  #---------------------
-  # If have dependencies, write its XInclude and find sub-dependencies
-  if [[ -f dependencies/$TARGET.dep ]]; then
-    mkdir xincludes && do_dependencies $TARGET
-  fi
-
-  echo -e "\n\t... done"
+    if [[ -f ${id_of_dep}.dep ]]; then
+      sed -i "1i${rootlink[*]} $count" ${id_of_dep}.dep
+      generate_dependency_tree ${id_of_dep}.dep
+# Test return value, in case we exchange dependencies
+      case $? in
+       0) # Normal return
+         ;;
+       1) # We are backing up to parent
+         if [[ ${exchange_triplet} == ${DepFile%.dep} ]]
+           then tree_erase ${id_of_dep}.dep
+# Just doing a sed -i "s@${id_of_dep}@${exchange_triplet[2]}@" $DepFile
+# is not good if $DepFile contains several times the same line
+# so first find the first line and then sed
+           lineno=$(sed -n /${id_of_dep}/= $DepFile | head -n1)
+           sed -i "${lineno}s@${id_of_dep}@${exchange_triplet[2]}@" $DepFile
+           id_of_dep=${exchange_triplet[2]}
+           flag=true
+         else
+# echo backing up to ${exchange_triplet} at ${DepFile%.dep}
+           return 1
+         fi
+         ;;
+      esac
+    else
+      echo "${rootlink[*]} $count" > ${id_of_dep}.dep
+    fi
+  done
+done
+echo -en "\n End: $depth${spaceSTR:0:$depth}${GREEN}$DepFile${OFF}"
+} 6<$DepFile
+# It may happen that a file is created with several times
+# the same line. Normally, all those lines but one
+# would be flagged to be removed (or all of them if
+# the dependency appeared before). a simple sed /$line/d
+# destroys all the lines. We should instead remove
+# only one for each appearance of it in lines_to_remove.
+# so first get the number of first line and then delete
+# that line
+for line in $lines_to_remove
+  do lineno=$(sed -n /^$line\$/= $DepFile | head -n1)
+  sed -i ${lineno}d $DepFile
+done
+return 0
 }
 
+#---------------#
+tree_browse() { #
+#---------------#
+local file=$1
+local f
 
+#echo file=$file
+for f in $(grep '[^0-9 ]' $file); do
+#  echo f=$f
+  if grep -q '[^0-9 ]' ${f}.dep ; then
+    tree_browse ${f}.dep
+  fi
+  echo $f
+done
+}
 
-#-----------------------#
-do_dependencies()  {    #  Loop to find sub-dependencies  :::WARNING::: THIS IS A RECURVISE FUNCTION
-#-----------------------#
-: <<inline_doc
-    function:   Loop through all the packages and create a sub-dependency tree
-    input vars: $1, package name
-    externals:  vars:  $DEP_LEVEL
-                       $TARGET
-                       $PRINT_SERVER
-                       $KBR5
-                       $GHOSTSCRIPT
-                       $MAILSERVER
-                file:  depure.txt
-                       $TARGET-index.xml.tmp
-                       $PKG.dep
-                       $PKG.inc
-    modifies:   files
-    returns:    nothing
-    output:     file:  $PKG-xinc.tmp
-                       depure.txt
-                       $TARGET-index.xml.tmp
-    on error:   exit
-    on success:
-inline_doc
+#--------------#
+tree_erase() { #
+#--------------#
+local file=$1
+local f
+local -a rootlink
+local -a rootlink2
 
-  set -e
-  local PKG=$1
-  local saveIFS=$IFS
-  local DEP_LV=$DEP_LEVEL
-  local line line2 DEP pkg_ver inst_ver
-
-  #------------------
-  #  If a premade xinclude file exists, use it. If not, create one
-  if [[ -f xincludes/$PKG.xinc ]] ; then
-    IFS=$'\x0A'
-    for line in `cat xincludes/$PKG.xinc` ; do
-      IFS=$saveIFS
-      # Remove the Xinclude entry if found. We want the most newer one.
-      # Using double quotes to let bash expand variables.
-      # Remove also the empty line created. Can not be done in one step
-      # due that d requires the pattner between /, but we have a lot of /
-      # inside the pattner.
-      sed -e "s,^[[:space:]]*$line,," -e '/./!d' -i $TARGET-index.xml.tmp
-      # Write the XInclude
-      echo -e "$line" >> $TARGET-index.xml.tmp
-    done
-    return
+#echo file=$file
+rootlink=($(head -n1 $file))
+for f in $(grep '[^0-9 ]' $file); do
+#  echo "    f"=$f
+  if [ -f ${f}.dep ]; then
+    rootlink2=($(head -n1 ${f}.dep))
+    if [[ "${rootlink2[*]}" =~ "${rootlink[*]}" ]] ; then
+      tree_erase ${f}.dep
+    fi
   fi
-
-  #------------------
-  # Start with a clean $PKG.xinc.tmp file
-  > xincludes/$PKG.xinc.tmp
-  for DEP in `cat dependencies/$PKG.dep`; do
-
-    # Special packages that need be remaped
-    case $DEP in
-
-      db ) continue ;; # The proper version of DB is installed in LFS
-
-        # Don't have their own XML file
-      hal-requirements | hal-runtime-dependencies ) continue ;;
-      perl-* | tk-perl )         DEP=perl-modules ;;
-      dbus-* )                   DEP=dbus-bindings ;;
-      pyxml | pycairo | pygobject | pygtk | pyorbit | \
-      gnome-python | gnome-python-desktop ) DEP=python-modules ;;
-
-        # Orphan links (proper link must be created when generating the book)
-      arts )                     DEP=aRts ;;
-      kde )                      DEP=kde-core ;;
-
-        # Set values for alternative packages
-      LPRng | cups )             DEP=$PRINT_SERVER ;;
-      mitkrb | heimdal )         DEP=$KBR5 ;;
-      gs | espgs )               DEP=$GHOSTSCRIPT ;;
-      server-mail )              DEP=$MAIL_SERVER ;;
-      x-window-system )
-        case $X11 in
-          xorg7 ) DEP=xorg7 ;;
-              * )
-                  pkg_ver=$(grep "^${X11}[[:space:]]" ../packages | cut -f3)
-                  inst_ver=$(grep "^${X11}[[:space:]]" ../packages | cut -f4)
-                  [ -n "${pkg_ver}" ] && [[ "x${pkg_ver}" = "x${inst_ver}" ]] && continue
-                  [ -n "${pkg_ver}" ] && [[ "x${pkg_ver}" < "x${inst_ver}" ]] && continue
-                  ;;
-        esac
-        ;;
-    esac
-
-    # If DEP has been previouly installed, skip it
-    pkg_ver=$(grep "^${DEP}[[:space:]]" ../packages | cut -f3)
-    inst_ver=$(grep "^${DEP}[[:space:]]" ../packages | cut -f4)
-    [ -n "${pkg_ver}" ] && [[ "x${pkg_ver}" = "x${inst_ver}" ]] && continue
-    [ -n "${pkg_ver}" ] && [[ "x${pkg_ver}" < "x${inst_ver}" ]] && continue
-
-    #------------------
-    # Prevent circular dependencies
-    # If all dependencies are circular, the creation of the *.dep file
-    # must be skipped, not placed here, to avoid that the script will bomb
-    # due empty *.xinc files
-    case $DEP in
-      akode )
-        # Both are in the same page
-        [[ "$PKG" = "kdemultimedia" ]] && continue
-        ;;
-      aRts )
-        # esound-->aRts-->esound
-        [[ "$PKG" = "esound" ]] && continue
-        ;;
-      dbus-bindings )
-        # True circular dependecy
-        [[ "$PKG" = "dbus-bindings" ]] && continue
-        ;;
-      DocBook )
-        # Used to rebuild the documentation
-        [[ "$PKG" = "linux-pam" ]] && continue
-        ;;
-      docbook-xsl )
-        # Used to rebuild the documentation
-        [[ "$PKG" = "linux-pam" ]] && continue
-        ;;
-      doxygen )
-        # Used to rebuild the documentation
-        [[ "$PKG" = "dbus" ]] && continue
-        [[ "$PKG" = "libdvdcss" ]] && continue
-        [[ "$PKG" = "libusb" ]] && continue
-        [[ "$PKG" = "libxcb" ]] && continue
-        ;;
-      espgs )
-        # Used to rebuild the documentation
-        [[ "$PKG" = "$MAIL_SERVER" ]] && continue
-        ;;
-      ffmpeg )
-        # alsa-plugins-->ffmpeg-->several-->alsa-plugins
-        [[ "$PKG" = "alsa-plugins" ]] && continue
-        ;;
-      fop )
-        # Used to rebuild the documentation
-        [[ "$PKG" = "linux-pam" ]] && continue
-        ;;
-      graphviz )
-        # Used to build the API documentation
-        [[ "$PKG" = "libusb" ]] && continue
-        ;;
-      GTK )
-        # deprecated GTK version
-        [[ "$PKG" = "alsa-tools" ]] && continue
-        ;;
-      gtk2 )
-        # Testsuite only
-        [[ "$PKG" = "cairo" ]] && continue
-        ;;
-      jadetex )
-        # Runtime only
-        [[ "$PKG" = "docbook-utils" ]] && continue
-        ;;
-      $KBR5 )
-        # cyrus-sasl-->postgresql-->$KBR5-->openldap-->cyrus-sasl
-        [[ "$PKG" = "cyrus-sasl" ]] && continue
-        ;;
-      librsvg )
-        # Testsuite only
-        [[ "$PKG" = "cairo" ]] && continue
-        ;;
-      libxslt )
-        # libxml2-->libxslt-->libxml2
-        [[ "$PKG" = "libxml2" ]] && continue
-        ;;
-      Links )
-        # Runtime only
-        [[ "$PKG" = "docbook-utils" ]] && continue
-        ;;
-      lynx )
-        # Runtime only
-        [[ "$PKG" = "docbook-utils" ]] && continue
-        ;;
-      openldap )
-        # cyrus-sasl-->postgresql-->$KBR5-->openldap-->cyrus-sasl
-        [[ "$PKG" = "cyrus-sasl" ]] && continue
-        ;;
-      poppler )
-        # Testsuite only
-        [[ "$PKG" = "cairo" ]] && continue
-        ;;
-      postgresql )
-        # cyrus-sasl-->postgresql-->$KBR5-->openldap-->cyrus-sasl
-        [[ "$PKG" = "cyrus-sasl" ]] && continue
-        ;;
-      python-modules )
-        # True circular dependecy
-        [[ "$PKG" = "python-modules" ]] && continue
-        # libgsf-->python-modules-->several combinations-->libgsf
-        [[ "$PKG" = "libgsf" ]] && continue
-        # gimp-->python-modules-->several combinations-->gimp
-        [[ "$PKG" = "gimp" ]] && continue
-        # Used to rebuild the documentation
-        [[ "$PKG" = "gstreamer" ]] && continue
-        [[ "$PKG" = "gst-plugins-base" ]] && continue
-        [[ "$PKG" = "gst-plugins-good" ]] && continue
-        ;;
-      tk )
-        # python-->tk-->xorg7-->several combinations-->libxslt-->python
-        [[ "$PKG" = "python" ]] && continue
-        ;;
-      w3m )
-        # Runtime only
-        [[ "$PKG" = "docbook-utils" ]] && continue
-        # Used to rebuild the documentation
-        [[ "$PKG" = "linux-pam" ]] && continue
-        ;;
-    esac
-
-    #------------------
-    # XML file of dependency package
-    DEP_XML=`grep "^$DEP[[:space:]]" ../packages | cut -f2`
-    case $DEP in
-      x-window-system | alsa ) ;; # No page for that (proper link must be created when generating the book)
-      xorg7 ) ;; # This page will be dump in the xorg7.xinc file
-      gnome-core | kde-core | kde-full ) ;; # Invented packages
-      * )
-        # Remove the Xinclude entry if found
-        sed -e "s,^[[:space:]]*$ENTRY_START$DEP_XML$ENTRY_END,," \
-            -e '/./!d' -i xincludes/$PKG.xinc.tmp
-        # Write the XInclude
-        echo -e "    $ENTRY_START$DEP_XML$ENTRY_END" >> xincludes/$PKG.xinc.tmp
-        ;;
-    esac
-
-    #------------------
-    # If not already created, create its dependencies list
-    if [[ ! -f dependencies/$DEP.dep ]] ; then
-      case $DEP in
-        # Skip the creation when all dependencies are circular.
-        alsa-lib | cracklib | libexif | unixodbc ) ;;
-        # Meta-packages at dependency level
-        alsa )
-          cp ../libs/alsa.dep dependencies/
-          ;;
-        kde-core )
-          cp ../libs/kde-core.dep dependencies/
-          ;;
-        x-window-system ) # When X11 is not Xorg7
-          echo -e "x-config\nx-setup\n$X11" > dependencies/x-window-system.dep
-          ;;
-        xorg7 )
-          cp ../libs/xorg7.dep dependencies/
-          ;;
-        * ) xsltproc --stringparam dependencies $DEP_LV \
-               -o dependencies/$DEP.dep ../libs/dependencies.xsl ../$DEP_XML
-          ;;
-      esac
-    fi
-
-    #------------------
-    # If needed, process its dependencies
-    if [[ -f dependencies/$DEP.dep ]] ; then
-      # If a premade xinclude file esist, include it
-      if [[ -f xincludes/$DEP.xinc ]] ; then
-        IFS=$'\x0A'
-        for line2 in `cat xincludes/$DEP.xinc` ; do
-          IFS=$saveIFS
-          # Remove the Xinclude entry if found
-          sed -e "s,^[[:space:]]*$line2,," -e '/./!d' -i xincludes/$PKG.xinc.tmp
-          # Write the XInclude
-          echo -e "$line2" >> xincludes/$PKG.xinc.tmp
-        done
-      #------------------
-      # Create the xinclude file
-      else
-	#
-	# >>>>>> THIS IS A RECURSIVE FUNCTION CALL.. BEWARE OF GREMLINS. <<<<<<
-	#
-	# If the recursion depth is not too great this is an acceptable methodology for a script language
-	# However, uncontrolled recursion will cause a seg-fault due to stack issues with local variables.
-	#
-        set +e
-         [[ "${VERBOSITY}" > 0 ]] && echo -ne "\ncall: $((++cntr))${spaceSTR:0:$cntr}${RED}$DEP${OFF}"
-            do_dependencies $DEP
-         [[ "${VERBOSITY}" > 0 ]] && echo -ne "\n ret: $cntr${spaceSTR:0:$((cntr--))}${GREEN}$DEP${OFF}  Using $DEP Xinc to solve $PKG"
-        set -e
-
-        # Include it when done
-        IFS=$'\x0A'
-        for line2 in `cat xincludes/$DEP.xinc` ; do
-          IFS=$saveIFS
-          # Remove the Xinclude entry if found
-          sed -e "s,^[[:space:]]*$line2,," -e '/./!d' -i xincludes/$PKG.xinc.tmp
-          # Write the XInclude
-          echo -e "$line2" >> xincludes/$PKG.xinc.tmp
-        done
-      fi
-    fi
-  done
-
-  #------------------
-  if [[ "$PKG" = "xorg7" ]] ; then
-    # Add their XInclude
-    PKG_XML=${BLFS_XML}/x/installing/xorg7.xml
-    echo -e "    $ENTRY_START$PKG_XML$ENTRY_END" >> xincludes/$PKG.xinc.tmp
-  fi
-
-  #------------------
-  mv xincludes/$PKG.xinc.tmp xincludes/$PKG.xinc
-  IFS=$'\x0A'
-  for line in `cat xincludes/$PKG.xinc` ; do
-    IFS=$saveIFS
-    # Remove the Xinclude entry if found.
-    sed -e "s,^[[:space:]]*$line,," -e '/./!d' -i $TARGET-index.xml.tmp
-    # Write the XInclude
-    echo -e "$line" >> $TARGET-index.xml.tmp
-  done
+done
+rm -f $file
 }
Index: BLFS/libs/func_packages
===================================================================
--- BLFS/libs/func_packages	(revision 232f5955604a906e4aea6903281d5f6d8885e516)
+++ 	(revision )
@@ -1,231 +1,0 @@
-#!/bin/bash
-#
-# $Id$
-#
-set -e
-
-#-----------------------#
-get_pkg_ver() {         # Find package version for a given package ID
-#-----------------------#
-  local pkg_id=$1
-
-  case ${pkg_id} in
-                  # ALSA packages version
-            alsa* ) pkg_id=alsa ;;
-
-                  # KDE packages version
-          kdevelop ) : ;;
-        kde*config ) : ;;
-              kde* ) pkg_id=kde ;;
-
-                  # Xorg7 packages version
-      xorg7-server ) pkg_id=xorg-server ;;
-            xterm2 ) pkg_id=xterm ;;
-            xorg7* ) pkg_id=xorg7 ;;
-
-                   # Others (ID value don't match entity name)
-    wireless_tools ) pkg_id=wireless-tools ;;
-        bind-utils ) pkg_id=bind ;;
-         html-tidy ) pkg_id=tidy ;;
-          reiserfs ) pkg_id=reiser ;;
-               xfs ) pkg_id=xfsprogs ;;
-  esac
-
-  xmllint --noent ./${BLFS_XML}/book/bookinfo.xml 2>/dev/null | \
-  grep -i " ${pkg_id}-version " | cut -d "\"" -f2 | sed "s/ /_/g"
-
-}
-
-#-----------------------#
-get_installed_ver() {   # Find installed package version for a given package ID
-#-----------------------#
-  local pkg_id=$1
-
-
-  case ${pkg_id} in
-    html-tidy )
-      find $TRACKING_DIR -name "${pkg_id}-cvs_[[:digit:]]*" | sed "s/.*${pkg_id}-//"
-      ;;
-    cdparanoia )
-      find $TRACKING_DIR -name "${pkg_id}-III-[[:digit:]]*" | sed "s/.*${pkg_id}-//"
-      ;;
-    ffmpeg )
-      find $TRACKING_DIR -name "${pkg_id}-svn_[[:digit:]]*" | sed "s/.*${pkg_id}-//"
-      ;;
-    psutils )
-      find $TRACKING_DIR -name "${pkg_id}-p[[:digit:]]*" | sed "s/.*${pkg_id}-//"
-      ;;
-    * )
-      find $TRACKING_DIR -name "${pkg_id}-[[:digit:]]*" | sed "s/.*${pkg_id}-//" | sed "s/ /_/g"
-      ;;
-  esac
-
-}
-
-#-----------------------#
-generate_packages()  {  # Master packages file
-#-----------------------#
-  local pkg_id file pkg_ver
-  local ALSA_VER GNOME_VER GNOME_MINOR_VER KDE_VER KDE_KOFFICE_VER XORG7_VER
-
-  > packages.tmp
-
-  # Extract Id and path for sect1 files
-  for file in `find $BLFS_XML -name "*.xml"` ; do
-    pkg_id=$(grep "sect1 id" $file | sed -e 's/<sect1 id="//;s/".*//')
-    case ${pkg_id} in
-      dbus-bindings | \
-      perl-modules | \
-      python-modules ) pkg_ver=0.no_version ;;
-                   * ) pkg_ver=$(get_pkg_ver $pkg_id) ;;
-    esac
-    installed_ver=$(get_installed_ver $pkg_id)
-    [[ ! -z "$pkg_id" ]] && echo -e "$pkg_id\t$file\t$pkg_ver\t$installed_ver" >> packages.tmp
-  done
-
-  # IDs clean-up (unuseful pages or commented-out packages, could be more)
-  sed -i '/template/d;/ntroduction/d;/preface/d;/alsa.xml/d;/xorg.xml/d' packages.tmp
-  sed -i '/obsolete/d;/ispell\t/d;/postlfs-/d;/-client.xml/d;/xorg7.xml/d' packages.tmp
-  sed -i '/courier.xml/d;/-other\t/d;/others-/d;/other-/d;/^ash\t/d' packages.tmp
-  sed -i '/fw-firewall\t/d;/gcc2\t/d;/cvsserver\t/d;/svnserver\t/d' packages.tmp
-  sed -i '/fam\t/d;/libungif\t/d;/ncpfs\t/d;/slrn\t/d;/konq\t/d;/arts\t/d' packages.tmp
-  sed -i '/gst-plugins\t/d;/gimp-print\t/d;/openquicktime\t/d;/compressdoc\t/d' packages.tmp
-  sed -i '/errata\t/d;/foreword\t/d;/organization\t/d;/whoread\t/d' packages.tmp
-
-  # Meta-packages version
-  ALSA_VER=$(get_pkg_ver alsa)
-  GNOME_VER=$(get_pkg_ver gnome)
-  GNOME_MINOR_VER=$(get_pkg_ver gnome-minor)
-  KDE_VER=$(get_pkg_ver kde)
-  KDE_INST_VER=$(get_installed_ver kde)
-  KDE_KOFFICE_VER=$(get_pkg_ver koffice)
-  XORG7_VER=$(get_pkg_ver xorg7)
-
-  # Meta-packages installed version
-  ALSA_INST_VER=$(get_installed_ver alsa)
-  GNOME_CORE_INST_VER=$(get_installed_ver gnome-core)
-  GNOME_FULL_INST_VER=$(get_installed_ver gnome-full)
-  KDE_CORE_INST_VER=$(get_installed_ver kde-core)
-  KDE_FULL_INST_VER=$(get_installed_ver kde-full)
-  KDE_KOFFICE_INST_VER=$(get_installed_ver kde-koffice)
-  XORG7_INST_VER=$(get_installed_ver xorg7)
-
-  # Add header with meta-packages pseudo Id
-{
-  cat << EOF
-alsa	$BLFS_XML	$ALSA_VER	$ALSA_INST_VER
-gnome-core	$BLFS_XML	$GNOME_VER$GNOME_MINOR_VER	$GNOME_CORE_INST_VER
-gnome-full	$BLFS_XML	$GNOME_VER$GNOME_MINOR_VER	$GNOME_FULL_INST_VER
-kde-core	$BLFS_XML	$KDE_VER	$KDE_CORE_INST_VER
-kde-full	$BLFS_XML	$KDE_VER	$KDE_FULL_INST_VER
-kde-koffice	$BLFS_XML	$KDE_KOFFICE_VER	$KDE_KOFFICE_INST_VER
-xorg7	$BLFS_XML	$XORG7_VER	$XORG7_INST_VER
-EOF
-} >> packages.tmp
-
-  # Dump packages list
-  sort packages.tmp -b --key=2 --field-separator=/ --output=packages
-
-  # Clean up
-  rm packages.tmp
-}
-
-# Pre-made *.dep files for meta-packages
-
-#--------------------------#
-generate_gnome_core()  {   # GNOME core
-#--------------------------#
-  local line base_xml package
-
-  > gnome-core.dep.tmp
-
-  for line in `grep "xi:include" $BLFS_XML/gnome/core/core.xml` ; do
-    base_xml=`echo $line | sed 's/^.*href="//;s/".*//'`
-    package=`grep "gnome/core/$base_xml" packages | cut -f1`
-    [[ -n "$package" ]] && echo $package >> gnome-core.dep.tmp
-  done
-
-  # Replace dummy packages with the proper ones
-  sed -i 's/GNOME-//g' gnome-core.dep.tmp
-
-  tac gnome-core.dep.tmp > libs/gnome-core.dep
-  rm gnome-core.dep.tmp
-}
-
-#--------------------------#
-generate_gnome_full()  {   # GNOME full
-#--------------------------#
-  local line base_xml package
-
-  echo "gnome-core" > gnome-full.dep.tmp
-
-  for line in `grep "xi:include" $BLFS_XML/gnome/add/add.xml` ; do
-    base_xml=`echo $line | sed 's/^.*href="//;s/".*//'`
-    package=`grep "gnome/add/$base_xml" packages | cut -f1`
-    [[ -n "$package" ]] && echo $package >> gnome-full.dep.tmp
-  done
-
-  tac gnome-full.dep.tmp > libs/gnome-full.dep
-  rm gnome-full.dep.tmp
-}
-
-#--------------------------#
-generate_kde_core()  {     # KDE core
-#--------------------------#
-  local line base_xml package
-
-  > kde-core.dep.tmp
-
-  for line in `grep "xi:include" $BLFS_XML/kde/core/core.xml` ; do
-    base_xml=`echo $line | sed 's/^.*href="//;s/".*//'`
-    package=`grep "kde/core/$base_xml" packages | cut -f1`
-    [[ -n "$package" ]] && echo $package >> kde-core.dep.tmp
-  done
-
-  tac kde-core.dep.tmp > libs/kde-core.dep
-  rm kde-core.dep.tmp
-}
-
-#--------------------------#
-generate_kde_full()  {     # KDE full
-#--------------------------#
-  local line base_xml package
-
-  echo "kde-core" > kde-full.dep.tmp
-
-  for line in `grep "xi:include" $BLFS_XML/kde/add/add.xml` ; do
-    base_xml=`echo $line | sed 's/^.*href="//;s/".*//'`
-    package=`grep "kde/add/$base_xml" packages | cut -f1`
-    [[ -n "$package" ]] && echo $package >> kde-full.dep.tmp
-  done
-
-  for line in `grep "xi:include" $BLFS_XML/kde/devel/devel.xml` ; do
-    base_xml=`echo $line | sed 's/^.*href="//;s/".*//'`
-    package=`grep "kde/devel/$base_xml" packages | cut -f1`
-    [[ -n "$package" ]] && echo $package >> kde-full.dep.tmp
-  done
-
-  tac kde-full.dep.tmp > libs/kde-full.dep
-  rm kde-full.dep.tmp
-}
-
-#--------------------------#
-generate_kde_koffice()  {  # KDE full + Koffice
-#--------------------------#
-  echo -e "koffice\nkde-full\nkde-core" > libs/kde-koffice.dep
-}
-
-#--------------------------#
-generate_alsa()  {         # ALSA packages
-#--------------------------#
-  echo -e "alsa-oss\nalsa-firmware\nalsa-tools\nalsa-utils\n\
-alsa-plugins\nalsa-lib" > libs/alsa.dep
-}
-
-#--------------------------#
-generate_xorg7()  {        # Xorg7 packages
-#--------------------------#
-  echo -e "x-config\nx-setup\nrman\nxterm2\nxorg7-driver\nxorg7-server\nluit\n\
-xkeyboard-config\nxorg7-font\nxorg7-data\nxorg7-app\nmesalib\nlibdrm\nxbitmaps\n\
-xorg7-lib\nlibxcb\nxcb-proto\nlibXdmcp\nlibXau\nxorg7-util\nxorg7-proto" > libs/xorg7.dep
-}
Index: BLFS/libs/func_parser
===================================================================
--- BLFS/libs/func_parser	(revision 232f5955604a906e4aea6903281d5f6d8885e516)
+++ 	(revision )
@@ -1,151 +1,0 @@
-#!/bin/bash
-#####
-#
-# Parse the XML documents to create a 'package' book
-#
-# $Id$
-#####
-
-
-#----------------------------#
-generate_TARGET_xml()  {     #
-#----------------------------#
-: <<inline_doc
-    function:   Generate the XML document for the TARGET package
-    input vars: nothing
-    externals:  vars: TARGET
-    modifies:   nothing
-    returns:    nothing
-    output:     file: $TARGET-index.xml
-    on error:   nothing
-    on success: nothing
-inline_doc
-
-  local
-  echo -en "\n\tGenerating $TARGET-index.xml ..."
-
-  #---------------------
-  # Header to $TARGET-index.xml
-{
-cat << EOF
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
-  "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" >
-
-<book>
-
-  <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="../$BLFS_XML/book/bookinfo.xml"/>
-
-  <preface>
-    <?dbhtml filename="preface.html" dir="preface"?>
-
-    <title>Preface</title>
-
-    <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="../$BLFS_XML/introduction/important/locale-issues.xml"/>
-    <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="../$BLFS_XML/introduction/important/bootscripts.xml"/>
-
-  </preface>
-
-  <chapter>
-    <?dbhtml filename="chapter.html" dir="installing"?>
-
-    <title>Installing $TARGET in Dependencies Build Order</title>
-
-EOF
-} > $TARGET-index.xml
-
-  #---------------------
-  # Dump $TARGET-index.xml.tmp in reverse order.
-  tac $TARGET-index.xml.tmp >> $TARGET-index.xml
-  rm $TARGET-index.xml.tmp
-
-  #---------------------
-  # Footer of $TARGET-index.xml
-{
-cat << EOF
-
-  </chapter>
-
-  <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="../$BLFS_XML/appendices/creat-comm.xml"/>
-  <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="../$BLFS_XML/appendices/ac-free-lic.xml"/>
-
-  <index/>
-
-</book>
-
-EOF
-} >> $TARGET-index.xml
-
-  echo "done"
-}
-
-
-#-------------------------#
-generate_target_book() {  #
-#-------------------------#
-: <<inline_doc
-    function:   Create an HTML document of the requested TARGET.
-    input vars: nothing
-    externals:  vars: TARGET
-                      BLFS_XML
-                      MAIL_SERVER
-                      X11
-    modifies:   nothing
-    returns:    nothing
-    output:     file: NUMEROUS FILES
-    on error:   nothing
-    on success: nothing
-inline_doc
-
-  local filename # output filename
-  echo -en  "\n\tGenerating <$TARGET> HTML book from <$BLFS_XML> xml files ..."
-  xsltproc --xinclude --nonet \
-           --stringparam mail_server $MAIL_SERVER \
-           --stringparam xwindow $X11 \
-           --stringparam base.dir HTML/ \
-           ../libs/book.xsl \
-           $TARGET-index.xml > xsltproc.log 2>&1
-  mkdir HTML/{stylesheets,images}
-  cp ../$BLFS_XML/stylesheets/lfs-xsl/*.css HTML/stylesheets
-  cp ../$BLFS_XML/images/*.png HTML/images
-  cd HTML
-  sed -i -e "s@../stylesheets@stylesheets@g" *.html
-  sed -i -e "s@../images@images@g" *.html
-  for filename in `find . -name "*.html"` ; do
-    tidy -config ../../$BLFS_XML/tidy.conf $filename || true
-    sh ../../$BLFS_XML/obfuscate.sh $filename
-    sed -i -e "s@text/html@application/xhtml+xml@g" $filename
-  done
-  cd ..
-  echo "done"
-}
-
-
-#-------------------------#
-create_build_scripts() {  #
-#-------------------------#
-: <<inline_doc
-    function:   Create shell scripts of the requested TARGET.
-    input vars: $1 use sudo n/y
-    externals:  TARGET
-    modifies:   nothing
-    returns:    nothing
-    output:     file: NUMEROUS FILES
-    on error:   nothing
-    on success: nothing
-inline_doc
-
-  # Log separator
-  echo -e "\n\tScripts generation depuration and errors:\n" >> xsltproc.log
-
-  echo -en "\n\tGenerating the build scripts ..."
-  xsltproc --xinclude --nonet \
-           --stringparam sudo $SUDO \
-           -o ./scripts/ ../libs/scripts.xsl \
-           $TARGET-index.xml >> xsltproc.log 2>&1
-    # Make the scripts executable.
-  chmod -R +x scripts
-  cd ..
-  echo -e "done\n"
-
-}
Index: BLFS/libs/scripts.xsl
===================================================================
--- BLFS/libs/scripts.xsl	(revision 232f5955604a906e4aea6903281d5f6d8885e516)
+++ 	(revision )
@@ -1,496 +1,0 @@
-<?xml version="1.0"?>
-
-<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
-    xmlns:exsl="http://exslt.org/common"
-    extension-element-prefixes="exsl"
-    version="1.0">
-
-<!-- $Id$ -->
-
-<!-- XSLT stylesheet to create shell scripts from "linear build" BLFS books. -->
-
-  <!-- Build as user (y) or as root (n)? -->
-  <xsl:param name="sudo" select="y"/>
-
-  <xsl:template match="/">
-    <xsl:apply-templates select="//sect1"/>
-  </xsl:template>
-
-<!--=================== Master chunks code ======================-->
-
-  <xsl:template match="sect1">
-    <xsl:if test="(count(descendant::screen/userinput) &gt; 0 and
-                  count(descendant::screen/userinput) &gt;
-                  count(descendant::screen[@role='nodump'])) and
-                  @id != 'locale-issues' and @id != 'xorg7' and
-                  @id != 'x-setup'">
-
-        <!-- The file names -->
-      <xsl:variable name="filename" select="@id"/>
-
-        <!-- Package name (use "Download FTP" by default. If empty, use "Download HTTP" -->
-      <xsl:variable name="package">
-        <xsl:choose>
-          <xsl:when
-            test="string-length(sect2[@role='package']/itemizedlist/listitem[2]/para/ulink/@url)
-            &gt; '10'">
-            <xsl:call-template name="package_name">
-              <xsl:with-param name="url"
-                select="sect2[@role='package']/itemizedlist/listitem[2]/para/ulink/@url"/>
-            </xsl:call-template>
-          </xsl:when>
-          <xsl:otherwise>
-            <xsl:call-template name="package_name">
-              <xsl:with-param name="url"
-                select="sect2[@role='package']/itemizedlist/listitem[1]/para/ulink/@url"/>
-            </xsl:call-template>
-          </xsl:otherwise>
-        </xsl:choose>
-      </xsl:variable>
-
-        <!-- FTP dir name -->
-      <xsl:variable name="ftpdir">
-        <xsl:call-template name="ftp_dir">
-          <xsl:with-param name="package" select="$package"/>
-        </xsl:call-template>
-      </xsl:variable>
-
-        <!-- The build order -->
-      <xsl:variable name="position" select="position()"/>
-      <xsl:variable name="order">
-        <xsl:choose>
-          <xsl:when test="string-length($position) = 1">
-            <xsl:text>00</xsl:text>
-            <xsl:value-of select="$position"/>
-          </xsl:when>
-          <xsl:when test="string-length($position) = 2">
-            <xsl:text>0</xsl:text>
-            <xsl:value-of select="$position"/>
-          </xsl:when>
-          <xsl:otherwise>
-            <xsl:value-of select="$position"/>
-          </xsl:otherwise>
-        </xsl:choose>
-      </xsl:variable>
-
-      <!-- Depuration code -->
-      <xsl:message>
-        <xsl:text>SCRIPT is </xsl:text>
-        <xsl:value-of select="concat($order,'-',$filename)"/>
-        <xsl:text>&#xA;   PACKAGE is </xsl:text>
-        <xsl:value-of select="$package"/>
-        <xsl:text>&#xA;    FTPDIR is </xsl:text>
-        <xsl:value-of select="$ftpdir"/>
-        <xsl:text>&#xA;&#xA;</xsl:text>
-      </xsl:message>
-
-        <!-- Creating the scripts -->
-      <exsl:document href="{$order}-z-{$filename}" method="text">
-        <xsl:text>#!/bin/bash&#xA;set -e&#xA;&#xA;</xsl:text>
-        <xsl:choose>
-          <!-- Package page -->
-          <xsl:when test="sect2[@role='package'] and not(@id = 'xorg7-app' or
-                          @id = 'xorg7-data' or @id = 'xorg7-driver' or
-                          @id = 'xorg7-font' or @id = 'xorg7-lib' or
-                          @id = 'xorg7-proto' or @id = 'xorg7-util')">
-            <!-- Variables -->
-            <xsl:text>SRC_ARCHIVE=$SRC_ARCHIVE&#xA;</xsl:text>
-            <xsl:text>FTP_SERVER=$FTP_SERVER&#xA;&#xA;PACKAGE=</xsl:text>
-            <xsl:value-of select="$package"/>
-            <xsl:text>&#xA;PKG_DIR=</xsl:text>
-            <xsl:value-of select="$ftpdir"/>
-            <xsl:text>&#xA;SRC_DIR=$SRC_DIR&#xA;&#xA;</xsl:text>
-            <!-- Download code and build commands -->
-            <xsl:apply-templates select="sect2">
-              <xsl:with-param name="package" select="$package"/>
-              <xsl:with-param name="ftpdir" select="$ftpdir"/>
-            </xsl:apply-templates>
-            <!-- Clean-up -->
-            <xsl:if test="not(@id='mesalib')">
-              <xsl:text>cd $SRC_DIR/$PKG_DIR&#xA;</xsl:text>
-              <xsl:text>rm -rf $UNPACKDIR unpacked&#xA;&#xA;</xsl:text>
-            </xsl:if>
-            <xsl:if test="@id='xorg7-server'">
-              <xsl:text>cd $SRC_DIR/MesaLib
-UNPACKDIR=`head -n1 unpacked | sed 's@^./@@;s@/.*@@'`
-rm -rf $UNPACKDIR unpacked&#xA;&#xA;</xsl:text>
-            </xsl:if>
-          </xsl:when>
-          <!-- Xorg7 pseudo-packages -->
-          <xsl:when test="contains(@id,'xorg7') and not(@id = 'xorg7-server')">
-            <xsl:text>SRC_DIR=$SRC_DIR
-
-cd $SRC_DIR
-mkdir -p xc
-cd xc&#xA;</xsl:text>
-            <xsl:apply-templates select="sect2" mode="xorg7"/>
-          </xsl:when>
-          <!-- Non-package page -->
-          <xsl:otherwise>
-            <xsl:apply-templates select=".//screen"/>
-          </xsl:otherwise>
-        </xsl:choose>
-        <xsl:text>exit</xsl:text>
-      </exsl:document>
-
-    </xsl:if>
-  </xsl:template>
-
-<!--======================= Sub-sections code =======================-->
-
-  <xsl:template match="sect2">
-    <xsl:param name="package" select="foo"/>
-    <xsl:param name="ftpdir" select="foo"/>
-    <xsl:choose>
-      <xsl:when test="@role = 'package'">
-        <xsl:text>mkdir -p $SRC_DIR/$PKG_DIR&#xA;</xsl:text>
-        <xsl:text>cd $SRC_DIR/$PKG_DIR&#xA;</xsl:text>
-        <xsl:apply-templates select="itemizedlist/listitem/para">
-          <xsl:with-param name="package" select="$package"/>
-          <xsl:with-param name="ftpdir" select="$ftpdir"/>
-        </xsl:apply-templates>
-        <xsl:text>&#xA;</xsl:text>
-      </xsl:when>
-      <xsl:when test="@role = 'installation'">
-        <xsl:text>
-if [[ -e unpacked ]] ; then
-  UNPACKDIR=`head -n1 unpacked | sed 's@^./@@;s@/.*@@'`
-  [[ -n $UNPACKDIR ]] &amp;&amp; [[ -d $UNPACKDIR ]] &amp;&amp; rm -rf $UNPACKDIR
-fi
-tar -xvf $PACKAGE > unpacked
-UNPACKDIR=`head -n1 unpacked | sed 's@^./@@;s@/.*@@'`
-cd $UNPACKDIR&#xA;</xsl:text>
-        <xsl:apply-templates select=".//screen | .//para/command"/>
-        <xsl:if test="$sudo = 'y'">
-          <xsl:text>sudo /sbin/</xsl:text>
-        </xsl:if>
-        <xsl:text>ldconfig&#xA;&#xA;</xsl:text>
-      </xsl:when>
-      <xsl:when test="@role = 'configuration'">
-        <xsl:apply-templates select=".//screen"/>
-        <xsl:text>&#xA;</xsl:text>
-      </xsl:when>
-    </xsl:choose>
-  </xsl:template>
-
-  <xsl:template match="sect2" mode="xorg7">
-    <xsl:choose>
-      <xsl:when test="@role = 'package'">
-        <xsl:apply-templates select="itemizedlist/listitem/para" mode="xorg7"/>
-      </xsl:when>
-      <xsl:when test="not(@role)">
-        <xsl:text>SRC_ARCHIVE=$SRC_ARCHIVE
-FTP_SERVER=$FTP_SERVER&#xA;</xsl:text>
-        <xsl:apply-templates select=".//screen" mode="sect-ver"/>
-        <xsl:text>mkdir -p ${section}&#xA;cd ${section}&#xA;</xsl:text>
-        <xsl:apply-templates select="../sect2[@role='package']/itemizedlist/listitem/para" mode="xorg7-patch"/>
-        <xsl:text>for line in $(grep -v '^#' ../${sect_ver}.wget) ; do
-  if [[ ! -f ${line} ]] ; then
-    if [[ -f $SRC_ARCHIVE/Xorg/${section}/${line} ]] ; then
-      cp $SRC_ARCHIVE/Xorg/${section}/${line} ${line}
-    elif [[ -f $SRC_ARCHIVE/Xorg/${line} ]] ; then
-      cp $SRC_ARCHIVE/Xorg/${line} ${line}
-    elif [[ -f $SRC_ARCHIVE/${section}/${line} ]] ; then
-      cp $SRC_ARCHIVE/${section}/${line} ${line}
-    elif [[ -f $SRC_ARCHIVE/${line} ]] ; then
-      cp $SRC_ARCHIVE/${line} ${line}
-    else
-      wget ${FTP_SERVER}conglomeration/Xorg/${line} || \
-      wget http://xorg.freedesktop.org/releases/individual/${section}/${line}
-    fi
-  fi
-done
-md5sum -c ../${sect_ver}.md5
-cp ../${sect_ver}.wget ../${sect_ver}.wget.orig
-cp ../${sect_ver}.md5 ../${sect_ver}.md5.orig&#xA;</xsl:text>
-      </xsl:when>
-      <xsl:when test="@role = 'installation'">
-        <xsl:text>for package in $(grep -v '^#' ../${sect_ver}.wget) ; do
-  packagedir=$(echo $package | sed 's/.tar.bz2//')
-  tar -xf ${package}
-  cd ${packagedir}&#xA;</xsl:text>
-        <xsl:apply-templates select=".//screen | .//para/command"/>
-        <xsl:text>  cd ..
-  rm -rf ${packagedir}
-  sed -i "/${package}/d" ../${sect_ver}.wget
-  sed -i "/${package}/d" ../${sect_ver}.md5
-done
-mv ../${sect_ver}.wget.orig ../${sect_ver}.wget
-mv ../${sect_ver}.md5.orig ../${sect_ver}.md5&#xA;</xsl:text>
-        <xsl:if test="$sudo = 'y'">
-          <xsl:text>sudo /sbin/</xsl:text>
-        </xsl:if>
-        <xsl:text>ldconfig&#xA;&#xA;</xsl:text>
-      </xsl:when>
-      <xsl:when test="@role = 'configuration'">
-        <xsl:apply-templates select=".//screen"/>
-        <xsl:text>&#xA;</xsl:text>
-      </xsl:when>
-    </xsl:choose>
-  </xsl:template>
-
-<!--==================== Download code =======================-->
-
-  <xsl:template name="package_name">
-    <xsl:param name="url" select="foo"/>
-    <xsl:param name="sub-url" select="substring-after($url,'/')"/>
-    <xsl:choose>
-      <xsl:when test="contains($sub-url,'/')">
-        <xsl:call-template name="package_name">
-          <xsl:with-param name="url" select="$sub-url"/>
-        </xsl:call-template>
-      </xsl:when>
-      <xsl:otherwise>
-        <xsl:choose>
-          <xsl:when test="contains($sub-url,'?')">
-            <xsl:value-of select="substring-before($sub-url,'?')"/>
-          </xsl:when>
-          <xsl:when test="contains($sub-url,'.patch')"/>
-          <xsl:otherwise>
-            <xsl:value-of select="$sub-url"/>
-          </xsl:otherwise>
-        </xsl:choose>
-      </xsl:otherwise>
-    </xsl:choose>
-  </xsl:template>
-
-  <xsl:template name="ftp_dir">
-    <xsl:param name="package" select="foo"/>
-    <!-- A lot of hardcoded dir names. Not full revised yet. -->
-    <xsl:choose>
-        <!-- cdparanoia -->
-      <xsl:when test="contains($package, '-III')">
-        <xsl:text>cdparanoia</xsl:text>
-      </xsl:when>
-        <!-- DobBook 3.1 -->
-      <xsl:when test="contains($package, 'docbk31')">
-        <xsl:text>docbk</xsl:text>
-      </xsl:when>
-        <!-- gc -->
-      <xsl:when test="contains($package, 'gc6')">
-        <xsl:text>gc</xsl:text>
-      </xsl:when>
-        <!-- ISO-codes -->
-      <xsl:when test="contains($package, 'iso-codes')">
-        <xsl:text>iso-codes</xsl:text>
-      </xsl:when>
-        <!-- JPEG -->
-      <xsl:when test="contains($package, 'jpegsrc')">
-        <xsl:text>jpeg</xsl:text>
-      </xsl:when>
-        <!-- lynx -->
-      <xsl:when test="contains($package, 'lynx')">
-        <xsl:text>lynx</xsl:text>
-      </xsl:when>
-        <!-- ntp -->
-      <xsl:when test="contains($package, 'ntp')">
-        <xsl:text>ntp</xsl:text>
-      </xsl:when>
-        <!-- OpenLDAP -->
-      <xsl:when test="contains($package, 'openldap')">
-        <xsl:text>openldap</xsl:text>
-      </xsl:when>
-        <!-- Open Office -->
-      <xsl:when test="contains($package, 'OOo')">
-        <xsl:text>OOo</xsl:text>
-      </xsl:when>
-        <!-- pine -->
-      <xsl:when test="contains($package, 'pine')">
-        <xsl:text>pine</xsl:text>
-      </xsl:when>
-        <!-- portmap -->
-      <xsl:when test="contains($package, 'portmap')">
-        <xsl:text>portmap</xsl:text>
-      </xsl:when>
-        <!-- psutils -->
-      <xsl:when test="contains($package, 'psutils')">
-        <xsl:text>psutils</xsl:text>
-      </xsl:when>
-        <!-- qpopper -->
-      <xsl:when test="contains($package, 'qpopper')">
-        <xsl:text>qpopper</xsl:text>
-      </xsl:when>
-        <!-- QT -->
-      <xsl:when test="contains($package, 'qt-x')">
-        <xsl:text>qt-x11-free</xsl:text>
-      </xsl:when>
-        <!-- sendmail -->
-      <xsl:when test="contains($package, 'sendmail')">
-        <xsl:text>sendmail</xsl:text>
-      </xsl:when>
-        <!-- Slib -->
-      <xsl:when test="contains($package, 'slib')">
-        <xsl:text>slib</xsl:text>
-      </xsl:when>
-        <!-- TCL -->
-      <xsl:when test="contains($package, 'tcl')">
-        <xsl:text>tcl</xsl:text>
-      </xsl:when>
-        <!-- tcpwrappers -->
-      <xsl:when test="contains($package, 'tcp_wrappers')">
-        <xsl:text>tcp_wrappers</xsl:text>
-      </xsl:when>
-        <!-- TeTeX -->
-      <xsl:when test="contains($package, 'tetex')">
-        <xsl:text>tetex</xsl:text>
-      </xsl:when>
-        <!-- Tidy -->
-      <xsl:when test="contains($package, 'tidy')">
-        <xsl:text>tidy</xsl:text>
-      </xsl:when>
-        <!-- Tk -->
-      <xsl:when test="contains($package, 'tk8')">
-        <xsl:text>tk</xsl:text>
-      </xsl:when>
-        <!-- unzip -->
-      <xsl:when test="contains($package, 'unzip')">
-        <xsl:text>unzip</xsl:text>
-      </xsl:when>
-        <!-- wireless_tools -->
-      <xsl:when test="contains($package, 'wireless_tools')">
-        <xsl:text>wireless_tools</xsl:text>
-      </xsl:when>
-        <!-- whois -->
-      <xsl:when test="contains($package, 'whois')">
-        <xsl:text>whois</xsl:text>
-      </xsl:when>
-        <!-- XOrg -->
-      <xsl:when test="contains($package, 'X11R6')">
-        <xsl:text>Xorg</xsl:text>
-      </xsl:when>
-        <!-- zip -->
-      <xsl:when test="contains($package, 'zip2')">
-        <xsl:text>zip</xsl:text>
-      </xsl:when>
-        <!-- General rule -->
-      <xsl:otherwise>
-        <xsl:variable name="cut"
-          select="translate(substring-after($package, '-'), '0123456789', '0000000000')"/>
-        <xsl:variable name="package2">
-          <xsl:value-of select="substring-before($package, '-')"/>
-          <xsl:text>-</xsl:text>
-          <xsl:value-of select="$cut"/>
-        </xsl:variable>
-        <xsl:value-of select="substring-before($package2, '-0')"/>
-      </xsl:otherwise>
-    </xsl:choose>
-  </xsl:template>
-
-  <xsl:template match="itemizedlist/listitem/para">
-    <xsl:param name="package" select="foo"/>
-    <xsl:param name="ftpdir" select="foo"/>
-    <xsl:choose>
-      <!-- This depend on all package pages having both "Download HTTP" and "Download FTP" lines -->
-      <xsl:when test="contains(string(),'HTTP')">
-        <xsl:text>if [[ ! -f $PACKAGE ]] ; then&#xA;</xsl:text>
-        <!-- SRC_ARCHIVE may have subdirectories or not -->
-        <xsl:text>  if [[ -f $SRC_ARCHIVE/$PKG_DIR/$PACKAGE ]] ; then&#xA;</xsl:text>
-        <xsl:text>    cp $SRC_ARCHIVE/$PKG_DIR/$PACKAGE $PACKAGE&#xA;</xsl:text>
-        <xsl:text>  elif [[ -f $SRC_ARCHIVE/$PACKAGE ]] ; then&#xA;</xsl:text>
-        <xsl:text>    cp $SRC_ARCHIVE/$PACKAGE $PACKAGE&#xA;  else&#xA;</xsl:text>
-        <!-- The FTP_SERVER mirror -->
-        <xsl:text>    wget ${FTP_SERVER}conglomeration/$PKG_DIR/$PACKAGE</xsl:text>
-        <!-- Upstream HTTP URL -->
-        <xsl:if test="string-length(ulink/@url) &gt; '10'">
-          <xsl:text> || \&#xA;    wget </xsl:text>
-          <xsl:choose>
-            <xsl:when test="contains(ulink/@url,'?')">
-              <xsl:value-of select="substring-before(ulink/@url,'?')"/>
-            </xsl:when>
-            <xsl:otherwise>
-              <xsl:value-of select="ulink/@url"/>
-            </xsl:otherwise>
-          </xsl:choose>
-        </xsl:if>
-      </xsl:when>
-      <xsl:when test="contains(string(),'FTP')">
-        <!-- Upstream FTP URL -->
-        <xsl:if test="string-length(ulink/@url) &gt; '10'">
-          <xsl:text> || \&#xA;    wget </xsl:text>
-          <xsl:value-of select="ulink/@url"/>
-        </xsl:if>
-        <xsl:text>&#xA;  fi&#xA;fi&#xA;</xsl:text>
-      </xsl:when>
-      <xsl:when test="contains(string(),'MD5')">
-        <xsl:text>echo "</xsl:text>
-        <xsl:value-of select="substring-after(string(),'sum: ')"/>
-        <xsl:text>&#x20;&#x20;$PACKAGE" | md5sum -c -&#xA;</xsl:text>
-      </xsl:when>
-      <!-- Patches -->
-      <xsl:when test="contains(string(ulink/@url),'.patch')">
-        <xsl:text>wget </xsl:text>
-        <xsl:value-of select="ulink/@url"/>
-        <xsl:text>&#xA;</xsl:text>
-      </xsl:when>
-    </xsl:choose>
-  </xsl:template>
-
-  <xsl:template match="itemizedlist/listitem/para" mode="xorg7">
-    <xsl:if test="contains(string(ulink/@url),'.md5') or
-                  contains(string(ulink/@url),'.wget')">
-      <xsl:text>wget </xsl:text>
-      <xsl:value-of select="ulink/@url"/>
-      <xsl:text>&#xA;</xsl:text>
-    </xsl:if>
-  </xsl:template>
-
-  <xsl:template match="itemizedlist/listitem/para" mode="xorg7-patch">
-    <xsl:if test="contains(string(ulink/@url),'.patch')">
-      <xsl:text>wget </xsl:text>
-      <xsl:value-of select="ulink/@url"/>
-      <xsl:text>&#xA;</xsl:text>
-    </xsl:if>
-  </xsl:template>
-
-<!--======================== Commands code ==========================-->
-
-  <xsl:template match="screen">
-    <xsl:if test="child::* = userinput and not(@role = 'nodump')">
-      <xsl:if test="@role = 'root' and $sudo = 'y'">
-        <xsl:text>sudo sh -c '</xsl:text>
-      </xsl:if>
-      <xsl:apply-templates select="userinput"/>
-      <xsl:if test="@role = 'root' and $sudo = 'y'">
-        <xsl:text>'</xsl:text>
-      </xsl:if>
-      <xsl:text>&#xA;</xsl:text>
-    </xsl:if>
-  </xsl:template>
-
-  <xsl:template match="screen" mode="sect-ver">
-    <xsl:text>section=</xsl:text>
-    <xsl:value-of select="substring-before(substring-after(string(),'mkdir '),' &amp;')"/>
-    <xsl:text>&#xA;sect_ver=</xsl:text>
-    <xsl:value-of select="substring-before(substring-after(string(),'-c ../'),'.md5')"/>
-    <xsl:text>&#xA;</xsl:text>
-  </xsl:template>
-
-  <xsl:template match="para/command">
-    <xsl:if test="(contains(string(),'test') or
-            contains(string(),'check'))">
-      <xsl:text>#</xsl:text>
-      <xsl:value-of select="substring-before(string(),'make')"/>
-      <xsl:text>make -k</xsl:text>
-      <xsl:value-of select="substring-after(string(),'make')"/>
-      <xsl:text> || true&#xA;</xsl:text>
-    </xsl:if>
-  </xsl:template>
-
-  <xsl:template match="userinput">
-    <xsl:apply-templates/>
-  </xsl:template>
-
-  <xsl:template match="replaceable">
-    <xsl:choose>
-      <xsl:when test="ancestor::sect1[@id='xorg7-server']">
-        <xsl:text>$SRC_DIR/MesaLib</xsl:text>
-      </xsl:when>
-      <xsl:otherwise>
-        <xsl:text>**EDITME</xsl:text>
-        <xsl:apply-templates/>
-        <xsl:text>EDITME**</xsl:text>
-      </xsl:otherwise>
-    </xsl:choose>
-  </xsl:template>
-
-</xsl:stylesheet>
