r2824 - in jhalfs/trunk/BLFS: . libs

manuel at linuxfromscratch.org manuel at linuxfromscratch.org
Sun Jul 16 03:29:38 PDT 2006


Author: manuel
Date: 2006-07-16 04:29:37 -0600 (Sun, 16 Jul 2006)
New Revision: 2824

Added:
   jhalfs/trunk/BLFS/TODO
   jhalfs/trunk/BLFS/alternatives.conf
   jhalfs/trunk/BLFS/blfs-parser.sh
   jhalfs/trunk/BLFS/libs/
   jhalfs/trunk/BLFS/libs/book.xsl
   jhalfs/trunk/BLFS/libs/constants.inc
   jhalfs/trunk/BLFS/libs/dependencies.xsl
   jhalfs/trunk/BLFS/libs/func_dependencies
   jhalfs/trunk/BLFS/libs/func_makefile
   jhalfs/trunk/BLFS/libs/func_packages
   jhalfs/trunk/BLFS/libs/func_parser
   jhalfs/trunk/BLFS/libs/scripts.xsl
   jhalfs/trunk/BLFS/packages.sh
Log:
Added new BLFS files from the experimental branch.

Added: jhalfs/trunk/BLFS/TODO
===================================================================
--- jhalfs/trunk/BLFS/TODO	                        (rev 0)
+++ jhalfs/trunk/BLFS/TODO	2006-07-16 10:29:37 UTC (rev 2824)
@@ -0,0 +1,32 @@
+#####
+#
+# Project TODO list
+#
+# $Id$
+#####
+
+For now the code is able to do the first step for the new approach: to create
+LFS-like books from BLFS sources, allowing to create linear build scrips and
+Makefiles similars to the current ones for {C,H}LFS.
+
+What remains to do:
+
+1. - To make the top-level blfs script functional. That script should to create
+       the working directory (selected at command line)
+     a. Copy all BLFS/* files to it,
+     b. Fetch the BLFS sources (output directory selected at command line or
+          based on the book version),
+     c. Run the packages.sh script.
+
+2. - To develop the XSL code needed to create the build scripts.
+     Work in progress.
+
+3. - To develop the code to create the Makefile.
+     Should be a separate script to be run manually after the user has
+     review and edited the target build scripts.
+     Must make the build scripts executables and set the SRC_ARCHIVE and
+     FTP_SERVER envars.
+
+4. - To find a way to track already installed packages by previous runs, to can
+       skip them when creating the book/scripts/Makefile for a new target.
+


Property changes on: jhalfs/trunk/BLFS/TODO
___________________________________________________________________
Name: svn:keywords
   + Author Date Revision Id

Added: jhalfs/trunk/BLFS/alternatives.conf
===================================================================
--- jhalfs/trunk/BLFS/alternatives.conf	                        (rev 0)
+++ jhalfs/trunk/BLFS/alternatives.conf	2006-07-16 10:29:37 UTC (rev 2824)
@@ -0,0 +1,27 @@
+#####
+#
+# Configuration file for the BLFS module
+#
+# $Id$
+#
+# Set default package for alternatives when resolving dependencies
+#
+#####
+
+# Print server cups/LPRng
+PRINT_SERVER=cups
+
+# Mail server sendmail/postfix/exim
+MAIL_SERVER=sendmail
+
+# GhostScript  gs/espgs
+GHOSTSCRIPT=espgs
+
+# Kerberos 5 mitkrb/heimdal
+KBR5=heimdal
+
+# X11 implementation xorg7/xorg/xfree86
+X11=xorg7
+
+
+


Property changes on: jhalfs/trunk/BLFS/alternatives.conf
___________________________________________________________________
Name: svn:keywords
   + Author Date Revision Id

Added: jhalfs/trunk/BLFS/blfs-parser.sh
===================================================================
--- jhalfs/trunk/BLFS/blfs-parser.sh	                        (rev 0)
+++ jhalfs/trunk/BLFS/blfs-parser.sh	2006-07-16 10:29:37 UTC (rev 2824)
@@ -0,0 +1,125 @@
+#!/bin/bash
+#
+# $Id$
+#
+set -e
+declare TARGET
+declare DEP_LEVEL
+declare PKGXML
+declare BLFS_XML
+declare VERBOSITY=1
+
+# Grab and name the command line options
+    optTARGET=$1
+optDEPENDENCY=$2
+
+
+#---------------------
+# Constants
+source libs/constants.inc
+[[ $? > 0 ]] && echo -e "\n\tERROR: constants.inc did not load..\n" && exit
+
+#---------------------
+# Configuration file for alternatives
+source alternatives.conf
+[[ $? > 0 ]] && echo -e "\n\tERROR: alternatives.conf did not load..\n" && exit
+
+#---------------------
+# Dependencies module
+source libs/func_dependencies
+[[ $? > 0 ]] && echo -e "\n\tERROR: func_dependencies did not load..\n" && exit
+
+#---------------------
+# parser module
+source libs/func_parser
+[[ $? > 0 ]] && echo -e "\n\tERROR: func_parser did not load..\n" && exit
+
+#---------------------
+# Makefile module
+source libs/func_makefile
+[[ $? > 0 ]] && echo -e "\n\tERROR: func_makefile did not load..\n" && exit
+
+
+
+#-------------------------#
+validate_target() {       # ID of target package (as listed in packages file)
+#-------------------------#
+: <<inline_doc
+    function:   Validate the TARGET parameter.
+    input vars: $1, package/target to validate
+    externals:  file: packages
+    modifies:   TARGET
+    returns:    nothing
+    output:     nothing
+    on error:   exit
+    on success: modifies TARGET
+inline_doc
+
+  if [[ -z "$1" ]] ; then
+    echo -e "\n\tYou must to provide a package ID."
+    echo -e "\tSee packages file for a list of available targets.\n"
+    exit 1
+  fi
+
+  if ! grep  "^$1[[:space:]]" packages > /dev/null ; then
+    echo -e "\n\t$1 is not a valid package ID."
+    echo -e "\tSee packages file for a list of available targets.\n"
+    exit 1
+  fi
+
+  TARGET=$1
+  echo -e "\n\tUsing $TARGET as the target package."
+}
+
+#-------------------------#
+validate_dependency() {   # Dependencies level 1(required)/2(1 + recommended)/3(2+ optional)
+#-------------------------#
+: <<inline_doc
+    function:   Validate the dependency level requested.
+    input vars: $1, requested dependency level
+    externals:  vars: TARGET
+    modifies:   vars: DEP_LEVEL
+    returns:    nothing
+    output:     nothing
+    on error:   nothing
+    on success: modifies DEP_LEVEL, default value = 2
+inline_doc
+
+  if [[ -z "$1" ]] ; then
+    DEP_LEVEL=2
+    echo -e "\n\tNo dependencies level has been defined."
+    echo -e "\tAssuming level $DEP_LEVEL (Required plus Recommended).\n"
+    return
+  fi
+
+  case $1 in
+    1 | 2 | 3 )
+      DEP_LEVEL=$1
+      echo -e "\n\tUsing $DEP_LEVEL as dependencies level.\n"
+      ;;
+    * )
+      DEP_LEVEL=2
+      echo -e "\n\t$1 is not a valid dependencies level."
+      echo -e "\tAssuming level $DEP_LEVEL (Required plus Recommended).\n"
+      ;;
+  esac
+}
+
+
+
+
+
+#------- MAIN --------
+if [[ ! -f packages ]] ; then
+  echo -e "\tNo packages file has been found.\n"
+  echo -e "\tExecution aborted.\n"
+  exit 1
+fi
+
+validate_target     "${optTARGET}"
+validate_dependency "${optDEPENDENCY}"
+generate_dependency_tree
+generate_TARGET_xml
+generate_target_book
+create_build_scripts
+generate_Makefile
\ No newline at end of file


Property changes on: jhalfs/trunk/BLFS/blfs-parser.sh
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:keywords
   + Author Date Revision Id

Added: jhalfs/trunk/BLFS/libs/book.xsl
===================================================================
--- jhalfs/trunk/BLFS/libs/book.xsl	                        (rev 0)
+++ jhalfs/trunk/BLFS/libs/book.xsl	2006-07-16 10:29:37 UTC (rev 2824)
@@ -0,0 +1,105 @@
+<?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) must be changed to FAKEDIR on the
+  final version and set it 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>


Property changes on: jhalfs/trunk/BLFS/libs/book.xsl
___________________________________________________________________
Name: svn:keywords
   + Author Date Revision Id

Added: jhalfs/trunk/BLFS/libs/constants.inc
===================================================================
--- jhalfs/trunk/BLFS/libs/constants.inc	                        (rev 0)
+++ jhalfs/trunk/BLFS/libs/constants.inc	2006-07-16 10:29:37 UTC (rev 2824)
@@ -0,0 +1,40 @@
+#####
+#
+# common constants
+#
+# $Id:
+#####
+
+
+# VT100 colors
+declare -r  BLACK=$'\e[1;30m'
+declare -r  DK_GRAY=$'\e[0;30m'
+
+declare -r  RED=$'\e[31m'
+declare -r  GREEN=$'\e[32m'
+declare -r  YELLOW=$'\e[33m'
+declare -r  BLUE=$'\e[34m'
+declare -r  MAGENTA=$'\e[35m'
+declare -r  CYAN=$'\e[36m'
+declare -r  WHITE=$'\e[37m'
+
+declare -r  OFF=$'\e[0m'
+declare -r  BOLD=$'\e[1m'
+declare -r  REVERSE=$'\e[7m'
+declare -r  HIDDEN=$'\e[8m'
+
+declare -r  tab_=$'\t'
+declare -r  nl_=$'\n'
+
+declare -r   DD_BORDER="${BOLD}==============================================================================${OFF}"
+declare -r   SD_BORDER="${BOLD}------------------------------------------------------------------------------${OFF}"
+declare -r STAR_BORDER="${BOLD}******************************************************************************${OFF}"
+
+# bold yellow > <  pair
+declare -r R_arrow=$'\e[1;33m>\e[0m'
+declare -r L_arrow=$'\e[1;33m<\e[0m'
+
+HEADER="# This file is automatically generated by jhalfs
+# DO NOT EDIT THIS FILE MANUALLY
+#
+# Generated on `date \"+%F %X %Z\"`"


Property changes on: jhalfs/trunk/BLFS/libs/constants.inc
___________________________________________________________________
Name: svn:keywords
   + Author Date Revision Id

Added: jhalfs/trunk/BLFS/libs/dependencies.xsl
===================================================================
--- jhalfs/trunk/BLFS/libs/dependencies.xsl	                        (rev 0)
+++ jhalfs/trunk/BLFS/libs/dependencies.xsl	2006-07-16 10:29:37 UTC (rev 2824)
@@ -0,0 +1,47 @@
+<?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>


Property changes on: jhalfs/trunk/BLFS/libs/dependencies.xsl
___________________________________________________________________
Name: svn:keywords
   + Author Date Revision Id

Added: jhalfs/trunk/BLFS/libs/func_dependencies
===================================================================
--- jhalfs/trunk/BLFS/libs/func_dependencies	                        (rev 0)
+++ jhalfs/trunk/BLFS/libs/func_dependencies	2006-07-16 10:29:37 UTC (rev 2824)
@@ -0,0 +1,371 @@
+#!/bin/bash
+#
+# $Id$
+#
+set -e
+
+declare -i cntr=0
+declare -a spaceSTR="                                                                   "
+
+#----------------------------#
+generate_dependency_tree() { #
+#----------------------------#
+: <<inline_doc
+    function:   Create a dependency tree for the TARGET
+    input vars: none
+    externals:  vars: TARGET
+                      PKGXML
+		      DEP_LEVEL
+                func: do_dependencies
+    modifies:   vars: PKGXML
+                      BLFS_XML
+    returns:    nothing
+    output:     files: $TARGET.dep
+                       $TARGET-index.xml.tmp
+                       depure.txt
+    on error:   nothing
+    on success: nothing
+inline_doc
+
+  local ENTRY_START
+  local ENTRY_END
+
+  #---------------------
+  # 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
+  fi
+
+  #---------------------
+  # XML file of the target package
+  PKGXML=`grep "^$TARGET[[:space:]]" ../packages | cut -f2`
+
+  #---------------------
+  # The BLFS sources directory.
+  # Note: for book.xsl this value must be set via a sed in ./blfs.
+  # For consistency, we should to do the same here.
+  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 -en "\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
+    # KDE and Gnome-{core,full} could be made via packages.sh, but not sure yet how.
+    alsa )
+      echo -e "alsa-oss\nalsa-firmware\nalsa-tools\nalsa-utils\n \
+               alsa-plugins\nalsa-lib" > dependencies/alsa.dep
+      ;;
+    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}.dep dependencies/
+      echo -e "koffice\nkde-full\nkde-core" > dependencies/kde-koffice.dep
+      ;;
+    xorg7 ) # At atarget level, add also x-config and x-setup
+      echo -e "x-config\nx-setup\nrman\nxterm2\nxorg7-driver\nxorg7-server\nluit\n \
+               xorg7-font\nxorg7-data\nxorg7-app\nxbitmaps\nmesalib\nlibdrm\n \
+               xorg7-lib\nxorg7-util\nxorg7-proto" > dependencies/xorg7.dep
+      ;;
+    * ) # 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 ) ;;
+    * )
+      echo -e "    $ENTRY_START$PKGXML$ENTRY_END" >> $TARGET-index.xml.tmp
+      ;;
+  esac
+
+  #------------------P---
+  # Start with a clean depure.txt file
+  > depure.txt
+
+  #---------------------
+  # If have dependencies, write its XInclude and find sub-dependencies
+  if [[ -f dependencies/$TARGET.dep ]]; then
+    echo -e "Start loop for PKG $TARGET\n" >> depure.txt
+    mkdir xincludes && do_dependencies $TARGET
+  fi
+
+  echo "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
+
+  set -e
+  local PKG=$1
+  local saveIFS=$IFS
+  local DEP_LV=$DEP_LEVEL
+  local line line2 DEP
+  echo -e "\tPKG is $PKG" >> depure.txt
+  echo -e "\tDEP_LEVEL for $PKG is $DEP_LV\n" >> depure.txt
+
+  #------------------
+  #  If a premade xinclude file exists, use it. If not, create one
+  if [[ -f xincludes/$PKG.xinc ]] ; then
+    echo -e "\tReusing xinclude file for PKG $PKG" >> depure.txt
+    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
+  fi
+
+  #------------------
+  # Start with a clean $PKG.xinc.tmp file
+  > xincludes/$PKG.xinc.tmp
+  for DEP in `cat dependencies/$PKG.dep`; do
+    # Special packages (a lot of hacks)
+    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 ;;
+
+        # Orphan links (proper link must be created when generating the book)
+      arts )                     DEP=aRts ;;
+      kde )                      DEP=kde-core ;;
+
+       # Dummy gnome-core pages
+      GNOME-desktop-file-utils ) DEP=desktop-file-utils ;;
+      GNOME-shared-mime-info )   DEP=shared-mime-info ;;
+
+        # Set values for alternative packages
+        # X is a meta-package, thus handled in another way.
+      LPRng | cups )             DEP=$PRINT_SERVER ;;
+      mitkrb | heimdal )         DEP=$KBR5 ;;
+      gs | espgs )               DEP=$GHOSTSCRIPT ;;
+      server-mail )              DEP=$MAIL_SERVER ;;
+    esac
+
+    #------------------
+    echo -e "\tDEP for $PKG is $DEP" >> depure.txt
+    # 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
+      jadetex | perl-* | lynx | Links | w3m )
+        # Optional dependencies are runtime only
+        [[ "$PKG" = "docbook-utils" ]] && continue
+        ;;
+      libxslt )
+        # libxml2-->libxslt-->libxml2
+        [[ "$PKG" = "libxml2" ]] && continue
+        ;;
+      openldap | postgresql | $KBR5 )
+        # cyrus-sasl-->several-->cyrus-sasl
+        [[ "$PKG" = "cyrus-sasl" ]] && continue
+        ;;
+      espgs )
+        # sendmail-->espgs-->cups-->php-->sendmail
+        [[ "$PKG" = "$MAIL_SERVER" ]] && continue
+        ;;
+      aRts )
+        # esound-->aRts-->esound
+        [[ "$PKG" = "esound" ]] && continue
+        ;;
+      gimp | sane )
+        # imagemagick-->{sane}-->gimp-->imagemagick
+        [[ "$PKG" = "imagemagick" ]] && continue
+        ;;
+      ffmpeg )
+        # alsa-plugins-->ffmpeg-->several-->alsa-plugins
+        [[ "$PKG" = "alsa-plugins" ]] && continue
+        ;;
+      akode )
+        # Both are in the same page
+        [[ "$PKG" = "kdemultimedia" ]] && continue
+        ;;
+    esac
+
+    #------------------
+    echo -e "\tDEP_LEVEL for $DEP is $DEP_LV" >> depure.txt
+    # XML file of dependency package
+    DEP_XML=`grep "^$DEP[[:space:]]" ../packages | cut -f2`
+    echo -e "\t\tDEP_XML is $DEP_XML\n" >> depure.txt
+    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 (ugly *.dep files, but work for now)
+        alsa ) # When dependency "alsa", use all alsa-* packages
+          echo -e "alsa-oss\nalsa-firmware\nalsa-tools\nalsa-utils\n \
+                   alsa-plugins\nalsa-lib" > dependencies/alsa.dep
+          ;;
+        kde-core )
+          cp ../libs/kde-core.dep dependencies/
+          ;;
+        x-window-system ) # X11 alternatives
+          echo -e "x-config\nx-setup\n$X11" > dependencies/x-window-system.dep
+          ;;
+        xorg7 )
+          echo -e "rman\nxterm2\nxorg7-driver\nxorg7-server\nluit\nxorg7-font\n \
+                   xorg7-data\nxorg7-app\nxbitmaps\nmesalib\nlibdrm\n \
+                   xorg7-lib\nxorg7-util\nxorg7-proto" > dependencies/xorg7.dep
+          ;;
+        * ) 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
+        echo -e "\tReusing xinclude file for PKG $DEP (to solve $PKG)\n" >> depure.txt
+        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
+        echo -e "\nStart new loop for PKG $DEP (to solve $PKG)\n" >> depure.txt
+	#
+	# >>>>>> 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 "\nrecursive call: $((++cntr)) ${spaceSTR:0:$cntr} ${RED}$DEP${OFF}"
+            do_dependencies $DEP
+         [[ "${VERBOSITY}" > 0 ]] && echo -ne  "\n          ret:  $cntr ${spaceSTR:0:$((cntr--))} ${GREEN}$DEP${OFF}\tUsing the new xinclude file for PKG $DEP (to solve $PKG)"
+        set -e
+
+        # Include it when done
+        echo -e "\tUsing the new xinclude file for PKG $DEP (to solve $PKG)\n" >> depure.txt
+        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=`grep "^$PKG[[:space:]]" ../packages | cut -f2`
+    echo -e "    $ENTRY_START$PKG_XML$ENTRY_END" >> xincludes/$PKG.xinc.tmp
+  fi
+
+  #------------------
+  mv xincludes/$PKG.xinc.tmp xincludes/$PKG.xinc
+  echo -e "Using the new xinclude file for PKG $PKG" >> depure.txt
+  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
+
+  echo -e "\nEnd loop for PKG $PKG\n" >> depure.txt
+}


Property changes on: jhalfs/trunk/BLFS/libs/func_dependencies
___________________________________________________________________
Name: svn:keywords
   + Author Date Revision Id

Added: jhalfs/trunk/BLFS/libs/func_makefile
===================================================================
--- jhalfs/trunk/BLFS/libs/func_makefile	                        (rev 0)
+++ jhalfs/trunk/BLFS/libs/func_makefile	2006-07-16 10:29:37 UTC (rev 2824)
@@ -0,0 +1,149 @@
+#####
+#
+#
+#
+# $Id$
+#####
+
+# TEMPORARY VARIABLES.. development use only
+declare MKFILE=devMakefile
+declare PREV_PACKAGE=""
+declare BUILD_SCRIPTS=scripts
+declare TRACKING_DIR=/var/lib/jhalfs/BLFS
+
+
+#----------------------------------#
+__wrt_target() {                   # Create target and initialize log file
+#----------------------------------#
+  local i=$1
+  local PREV=$2
+(
+cat << EOF
+
+$i:  $PREV
+	@\$(call echo_message, Building)
+	@./progress_bar.sh \$@ &
+EOF
+) >> $MKFILE.tmp
+}
+
+
+
+#----------------------------------#
+__write_build_cmd() {              #
+#----------------------------------#
+  local this_script=$1
+  local file=$2
+(
+cat << EOF
+	@( time { ${BUILD_SCRIPTS}/${file} >>logs/${this_script} 2>&1 ; } ) 2>>logs/${this_script}
+EOF
+) >> $MKFILE.tmp
+}
+
+#----------------------------------#
+__wrt_touch() {                    #
+#----------------------------------#
+  local pkg_name=$1
+(
+cat << EOF
+	@touch  \$@ && \\
+	touch \$(TRACKING_DIR)/${pkg_name#*-} && \\
+	sleep .25 && \\
+	echo -e "\n\n "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
+	echo --------------------------------------------------------------------------------\$(WHITE)
+EOF
+) >> $MKFILE.tmp
+}
+
+
+#----------------------------#
+__write_entry() {            #
+#----------------------------#
+  local script_name=$1
+
+  echo -n "${tab_}${tab_} entry for <$script_name>"
+
+  #--------------------------------------------------------------------#
+  #         >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<<          #
+  #--------------------------------------------------------------------#
+  #
+  # Drop in the name of the target on a new line, and the previous target
+  # as a dependency. Also call the echo_message function.
+  __wrt_target "${script_name}" "$PREV_PACKAGE"
+  __write_build_cmd "${script_name}" "${script_name}"
+
+  # Include a touch of the target name so make can check
+  # if it's already been made.
+  __wrt_touch "${script_name}"
+  #
+  #--------------------------------------------------------------------#
+  #              >>>>>>>> END OF Makefile ENTRY <<<<<<<<               #
+  #--------------------------------------------------------------------#
+  echo " .. OK"
+}
+
+#----------------------------#
+generate_Makefile () {       #
+#----------------------------#
+
+
+  echo "${tab_}Creating Makefile... ${BOLD}START${OFF}"
+
+  # Start with a clean files
+  >$MKFILE
+  >$MKFILE.tmp
+
+  
+  for package_script in scripts/* ; do
+    this_script=`basename $package_script`
+    if [ ! -e $TRACKING_DIR/${this_script#*-} ]; then
+      pkg_list="$pkg_list ${this_script}"
+      __write_entry $this_script
+      PREV_PACKAGE=${this_script}
+    fi
+  done
+
+
+  # Add a header, some variables and include the function file
+  # to the top of the real Makefile.
+(
+    cat << EOF
+$HEADER
+
+PACKAGE= "`basename $PKGXML .xml`"
+TRACKING_DIR= $TRACKING_DIR
+
+BOLD= ""
+RED= ""
+GREEN= ""
+ORANGE= ""
+BLUE= ""
+WHITE= ""
+
+define echo_message
+  @echo \$(BOLD)
+  @echo --------------------------------------------------------------------------------
+  @echo \$(BOLD)\$(1) target \$(BLUE)\$@\$(BOLD)
+  @echo \$(WHITE)
+endef
+
+
+define fin_message
+  @echo \$(BOLD)
+  @echo --------------------------------------------------------------------------------
+  @echo \$(BOLD) Build complete for the package \$(BLUE)\$(PACKAGE)\$(BOLD) and its dependencies
+  @echo \$(WHITE)
+endef
+
+all : $pkg_list
+	@\$(call fin_message )
+EOF
+) > $MKFILE
+
+  cat $MKFILE.tmp >> $MKFILE
+  echo "${tab_}Creating Makefile... ${BOLD}DONE${OFF}"
+
+  rm $MKFILE.tmp
+
+}


Property changes on: jhalfs/trunk/BLFS/libs/func_makefile
___________________________________________________________________
Name: svn:keywords
   + Author Date Revision Id

Added: jhalfs/trunk/BLFS/libs/func_packages
===================================================================
--- jhalfs/trunk/BLFS/libs/func_packages	                        (rev 0)
+++ jhalfs/trunk/BLFS/libs/func_packages	2006-07-16 10:29:37 UTC (rev 2824)
@@ -0,0 +1,129 @@
+#!/bin/bash
+#
+# $Id$
+#
+set -e
+
+#-----------------------#
+generate_packages()  {  # Master packages file
+#-----------------------#
+  local pkg_id file
+
+  > 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/".*//'`
+    [[ ! -z "$pkg_id" ]] && echo -e "$pkg_id\t$file" >> packages.tmp
+  done
+
+  # IDs clean-up (unuseful pages or commented-out packages, could be more)
+  sed -i '/template/d;/ntroduction/d;/preface/d' packages.tmp
+  sed -i '/courier.xml/d' packages.tmp
+  sed -i '/nautilus-media.xml/d;/gal.xml/d;/gpdf.xml/d;/gv.xml/d' packages.tmp
+
+  # Add header with meta-packages pseudo Id
+{
+  cat << EOF
+
+=== GNOME META-PACKAGES ===
+# GNOME base packages
+gnome-core	$BLFS_XML
+# All GNOME packages
+gnome-full	$BLFS_XML
+
+=== KDE META-PACKAGES ===
+# KDE base packages
+kde-core	$BLFS_XML
+# All KDE packages
+kde-full	$BLFS_XML
+# All KDE packages plus Koffice
+kde-koffice	$BLFS_XML
+
+=== INDIVIDUAL PACKAGES ===
+
+EOF
+} > packages
+
+  # Dump packages list
+  sort packages.tmp >> 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
+
+  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
+}


Property changes on: jhalfs/trunk/BLFS/libs/func_packages
___________________________________________________________________
Name: svn:keywords
   + Author Date Revision Id

Added: jhalfs/trunk/BLFS/libs/func_parser
===================================================================
--- jhalfs/trunk/BLFS/libs/func_parser	                        (rev 0)
+++ jhalfs/trunk/BLFS/libs/func_parser	2006-07-16 10:29:37 UTC (rev 2824)
@@ -0,0 +1,149 @@
+#!/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 "\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.4//EN"
+  "http://www.oasis-open.org/docbook/xml/4.4/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  "\tGenerating the HTML book for <$TARGET> from the xml files located in <$BLFS_XML>..."
+  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/*.css HTML/stylesheets
+  cp ../$BLFS_XML/images/*.png HTML/images
+  cd HTML
+  sed -i -e "s at ../stylesheets at stylesheets@g" *.html
+  sed -i -e "s at ../images at 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 at text/html at application/xhtml+xml at g" $filename
+  done
+  cd ..
+  echo "done"
+}
+
+
+#-------------------------#
+create_build_scripts() {  #
+#-------------------------#
+: <<inline_doc
+    function:   Create shell scripts of the requested TARGET.
+    input vars: nothing
+    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  "\tGenerating the build scripts ..."
+  xsltproc --xinclude --nonet \
+           -o ./scripts/ ../libs/scripts.xsl \
+           $TARGET-index.xml >> xsltproc.log 2>&1
+  echo "done"
+    # Make the scripts executable.
+  chmod -R +x scripts
+
+}


Property changes on: jhalfs/trunk/BLFS/libs/func_parser
___________________________________________________________________
Name: svn:keywords
   + Author Date Revision Id

Added: jhalfs/trunk/BLFS/libs/scripts.xsl
===================================================================
--- jhalfs/trunk/BLFS/libs/scripts.xsl	                        (rev 0)
+++ jhalfs/trunk/BLFS/libs/scripts.xsl	2006-07-16 10:29:37 UTC (rev 2824)
@@ -0,0 +1,373 @@
+<?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. -->
+
+  <xsl:template match="/">
+    <xsl:apply-templates select="//sect1"/>
+  </xsl:template>
+
+<!--=================== Master chunks code ======================-->
+
+  <xsl:template match="sect1">
+    <xsl:if test="@id != 'locale-issues' and
+                  (count(descendant::screen/userinput) > 0 and
+                  count(descendant::screen/userinput) >
+                  count(descendant::screen[@role='nodump']))">
+
+        <!-- The file names -->
+      <xsl:variable name="pi-file" select="processing-instruction('dbhtml')"/>
+      <xsl:variable name="pi-file-value" select="substring-after($pi-file,'filename=')"/>
+      <xsl:variable name="filename" select="substring-before(substring($pi-file-value,2),'.html')"/>
+
+        <!-- Package name (use "Download FTP" by default. If empty, use "Download HTTP" -->
+      <xsl:param name="package">
+        <xsl:choose>
+          <xsl:when
+            test="string-length(sect2[@role='package']/itemizedlist/listitem[2]/para/ulink/@url)
+            > '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:param>
+
+        <!-- FTP dir name -->
+      <xsl:param name="ftpdir">
+        <xsl:call-template name="ftp_dir">
+          <xsl:with-param name="package" select="$package"/>
+        </xsl:call-template>
+      </xsl:param>
+
+        <!-- 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}-{$filename}" method="text">
+        <xsl:text>#!/bin/sh&#xA;set -e&#xA;&#xA;</xsl:text>
+        <xsl:choose>
+          <!-- Package page -->
+          <xsl:when test="sect2[@role='package']">
+            <!-- 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;&#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:text>cd ~/sources/$PKG_DIR&#xA;</xsl:text>
+            <xsl:text>rm -rf $UNPACKDIR&#xA;&#xA;</xsl:text>
+          </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 ~/sources/$PKG_DIR&#xA;</xsl:text>
+        <xsl:text>cd ~/sources/$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>tar -xvf $PACKAGE > unpacked&#xA;</xsl:text>
+        <xsl:text>UNPACKDIR=`head -n1 unpacked | sed 's@^./@@;s@/.*@@'`&#xA;</xsl:text>
+        <xsl:text>cd $UNPACKDIR&#xA;</xsl:text>
+        <xsl:apply-templates select=".//screen | .//para/command"/>
+        <xsl:text>&#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/BLFS/conglomeration/$PKG_DIR/$PACKAGE</xsl:text>
+        <!-- Upstream HTTP URL -->
+        <xsl:if test="string-length(ulink/@url) > '10' and
+                      not(contains(string(ulink/@url),'sourceforge'))">
+          <xsl:text> || \&#xA;    wget </xsl:text>
+          <xsl:value-of select="ulink/@url"/>
+        </xsl:if>
+      </xsl:when>
+      <xsl:when test="contains(string(),'FTP')">
+        <!-- Upstream FTP URL -->
+        <xsl:if test="string-length(ulink/@url) > '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>
+
+<!--======================== Commands code ==========================-->
+
+  <xsl:template match="screen">
+    <xsl:if test="child::* = userinput and not(@role = 'nodump')">
+      <xsl:if test="@role = 'root'">
+        <xsl:text>sudo sh -c "</xsl:text>
+      </xsl:if>
+      <xsl:apply-templates select="userinput"/>
+      <xsl:if test="@role = 'root'">
+        <xsl:text>"</xsl:text>
+      </xsl:if>
+      <xsl:text>&#xA;</xsl:text>
+    </xsl:if>
+  </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:text>**EDITME</xsl:text>
+    <xsl:apply-templates/>
+    <xsl:text>EDITME**</xsl:text>
+  </xsl:template>
+
+</xsl:stylesheet>


Property changes on: jhalfs/trunk/BLFS/libs/scripts.xsl
___________________________________________________________________
Name: svn:keywords
   + Author Date Revision Id

Added: jhalfs/trunk/BLFS/packages.sh
===================================================================
--- jhalfs/trunk/BLFS/packages.sh	                        (rev 0)
+++ jhalfs/trunk/BLFS/packages.sh	2006-07-16 10:29:37 UTC (rev 2824)
@@ -0,0 +1,97 @@
+#!/bin/bash
+#
+# $Id$
+#
+set -e
+
+declare -r SVN="svn://svn.linuxfromscratch.org"
+
+BLFS_XML=$1  # Book directory
+DOC_MODE=$2  # Action to take, only update at the moment
+
+#---------------------
+# packages module
+source libs/func_packages
+[[ $? > 0 ]] && echo -e "\n\tERROR: func_packages did not load..\n" && exit
+
+#----------------------------#
+BOOK_Source() {              #
+#----------------------------#
+: <<inline_doc
+    function:   Retrieve a fresh copy or upate an existing copy of the BLFS svn tree
+    input vars: $1 BLFS_XML directory
+                $2 DOC_MODE action get/update
+    externals:  none
+    modifies:   $BLFS_XML directory tree
+    returns:    nothing
+    output:     
+    on error:   exit
+    on success: text messages
+inline_doc
+
+    # Redundant definitions but this function may be reused
+  local BLFS_XML=$1
+  local DOC_MODE=$2
+  
+  if [[ -z "$BLFS_XML" ]] ; then
+    echo -e "\n\tYou must to provide the name of the BLFS book sources directory.\n"
+    exit 1
+  fi
+
+  if [[ -n "$DOC_MODE" ]] ; then
+    case $DOC_MODE in
+      update )
+        if [[ ! -d $BLFS_XML ]] ; then
+          echo -e "\n\t$BLFS_XML is not a directory\n"
+          exit 1
+        fi
+        if [[ ! -f $BLFS_XML/use-unzip.xml ]] ; then
+          echo -e "\n\tLooks like $BLFS_XML is not a BLFS book sources directory\n"
+          exit 1
+        fi
+
+        if [[ -d $BLFS_XML/.svn ]] ; then
+          echo -e "\n\tUpdating the $BLFS_XML book sources ...\n"
+          pushd $BLFS_XML 1> /dev/null
+            svn up
+          popd 1> /dev/null
+          echo -e "\n\tBook sources updated."
+        else
+          echo -e "\n\tLooks like $BLFS_XML is not a svn working copy."
+          echo -e "\tSkipping BLFS sources update.\n"
+        fi
+        ;;
+      
+      get )
+        [[ ! -d $BLFS_XML ]] && mkdir -pv $BLFS_XML
+        svn co $SVN/BLFS/trunk/BOOK $BLFS_XML 2>&1
+       ;;
+      * )
+         echo -e "\n\tUnknown option ${DOC_MODE} ignored.\n"
+      ;;
+    esac
+  fi
+}
+
+BOOK_Source $BLFS_XML $DOC_MODE
+
+echo -en "\n\tGenerating packages file ..."
+generate_packages
+echo "done."
+
+echo -en "\tGenerating gnome-core dependencies list ..."
+generate_gnome_core
+echo "done."
+
+echo -en "\tGenerating gnome-full dependencies list ..."
+generate_gnome_full
+echo "done."
+
+echo -en "\tGenerating kde-core dependencies list ..."
+generate_kde_core
+echo "done."
+
+echo -en "\tGenerating kde-full dependencies list ..."
+generate_kde_full
+echo -e "done.\n"
+


Property changes on: jhalfs/trunk/BLFS/packages.sh
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:keywords
   + Author Date Revision Id




More information about the alfs-log mailing list