Index: BLFS/Makefile
===================================================================
--- BLFS/Makefile	(revision a3b0e382b5878d7ad5ec8aba6ce8c7738638ebc6)
+++ BLFS/Makefile	(revision a3b0e382b5878d7ad5ec8aba6ce8c7738638ebc6)
@@ -0,0 +1,38 @@
+# From the Build Scripts Written By: Jim Gifford <lfs@jg555.com>
+# Modified By: Joe Ciccone <jciccone@linuxfromscratch.org
+# Additional changes: George Boudreau <georgeb@linuxfromscratch.org>
+
+# $Id$
+
+TOPDIR=$(shell pwd)
+CONFIG_CONFIG_IN = Config.in
+CONFIG = menu
+
+all: 	menuconfig
+
+$(CONFIG)/conf:
+	$(MAKE) -C $(CONFIG) conf
+
+$(CONFIG)/mconf:
+	$(MAKE) -C $(CONFIG) ncurses conf mconf
+
+menuconfig: $(CONFIG)/mconf
+	@./update_book.sh none
+	@./gen_config.sh
+	@$(CONFIG)/mconf $(CONFIG_CONFIG_IN)
+	@./gen_pkg_book.sh
+
+config: $(CONFIG)/conf
+	@$(CONFIG)/conf $(CONFIG_CONFIG_IN)
+
+# Clean up
+
+clean:
+	rm -f configuration configuration.old error
+	- $(MAKE) -C $(CONFIG) clean
+
+clean-target:
+	rm -f error
+	- $(MAKE) -C $(CONFIG) clean
+
+.PHONY: all menuconfig config clean clean-target
Index: BLFS/TODO
===================================================================
--- BLFS/TODO	(revision 5be3651d7f7b42651c1dc9100c665ca90ed30a3a)
+++ BLFS/TODO	(revision a3b0e382b5878d7ad5ec8aba6ce8c7738638ebc6)
@@ -6,22 +6,13 @@
 #####
 
-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:
+--   Review generated scripts for bugs trying to figure out if are due fails
+     in the BLFS book XML tagging (that will implied that the book need be
+     fixed) or are required variations due book layout. If the latter, try
+     to fix it via XSL, documenting in README.BLFS that issues that can't be
+     fixed.
 
---   To review the XSL code needed to create the build scripts.
-     A lot of book-versus-scripts and testing is needed.
-     We need yet to figure out if we can to to handle Perl modules installation
-     and other pages that have commands to install more that one package
-     (e.g., Gnat in GCC Java-bin in Java, sane-backends and sane-frontends
-     in Sane, etc) or not-estandart installations, like Xorg7
-
---   Test the method used to track already installed packages by previous runs.
-     See if the packages version can be watched also.
-
---   Integrate the menuconfig based package selection, trying to make use of the
-     installed packages traking system.
+     This is an on-going and never-end task due that, ideally, each commit to
+     the BLFS book should be revised and validated, but our time is limited.
 
 --   Bugs hunting.
Index: BLFS/alternatives.conf
===================================================================
--- BLFS/alternatives.conf	(revision 5be3651d7f7b42651c1dc9100c665ca90ed30a3a)
+++ 	(revision )
@@ -1,27 +1,0 @@
-#####
-#
-# 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
-
-
-
Index: BLFS/blfs-parser.sh
===================================================================
--- BLFS/blfs-parser.sh	(revision 5be3651d7f7b42651c1dc9100c665ca90ed30a3a)
+++ 	(revision )
@@ -1,119 +1,0 @@
-#!/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  # Package target
-optDEPENDENCY=$2  # Dependencies level, 1/2/3
-         SUDO=$3  # Build as user (y) or as root (n)
-
-[[ -z $SUDO ]] && SUDO=y
-
-
-#---------------------
-# 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
-
-
-
-#-------------------------#
-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 "${SUDO}"
Index: BLFS/gen-makefile.sh
===================================================================
--- BLFS/gen-makefile.sh	(revision 5be3651d7f7b42651c1dc9100c665ca90ed30a3a)
+++ BLFS/gen-makefile.sh	(revision a3b0e382b5878d7ad5ec8aba6ce8c7738638ebc6)
@@ -5,11 +5,9 @@
 set -e
 
-
-
 # TEMPORARY VARIABLES.. development use only
 declare MKFILE=Makefile
 declare PREV_PACKAGE=""
 declare BUILD_SCRIPTS=scripts
-declare TRACKING_DIR=/var/lib/jhalfs/BLFS
+declare TRACKING_DIR=tracking-dir
 
 HEADER="# This file is automatically generated by jhalfs
@@ -51,8 +49,43 @@
   local pkg_name=$1
   local pkg_ver=$2
+  local alsa_ver=$(grep "^alsa[[:space:]]" ../packages | cut -f3)
+  local kde_core_ver=$(grep "^kde-core[[:space:]]" ../packages | cut -f3)
+  local xorg7_ver=$(grep "^xorg7[[:space:]]" ../packages | cut -f3)
+
+  if [[ -n "$pkg_ver" ]] ; then
+(
+cat << EOF
+	@touch \$(TRACKING_DIR)/${pkg_name#*-?-}-${pkg_ver}
+EOF
+) >> $MKFILE.tmp
+  fi
+
+  case $pkg_name in
+    *-alsa-lib ) #this the unique mandatory package for ALSA support.
+(
+cat << EOF
+	@touch \$(TRACKING_DIR)/alsa-${alsa_ver}
+EOF
+) >> $MKFILE.tmp
+      ;;
+    *-kdebase )
+(
+cat << EOF
+	@touch \$(TRACKING_DIR)/kde-core-${kde_core_ver}
+EOF
+) >> $MKFILE.tmp
+      ;;
+    *-xorg7-driver ) # xtrerm2 and rman are optional
+(
+cat << EOF
+	@touch \$(TRACKING_DIR)/xorg7-${xorg7_ver}
+EOF
+) >> $MKFILE.tmp
+      ;;
+  esac
+
 (
 cat << EOF
 	@touch  \$@ && \\
-	touch \$(TRACKING_DIR)/${pkg_name#*-?-}-${pkg_ver} && \\
 	sleep .25 && \\
 	echo -e "\n\n "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
@@ -68,5 +101,5 @@
   local script_name=$1
   local pkg_ver=$2
-  
+
   echo -n "${tab_}${tab_} entry for <$script_name>"
 
@@ -91,4 +124,45 @@
 
 #----------------------------#
+__write_meta_pkg_touch() {   #
+#----------------------------#
+  local meta_pkg=$1
+  local pkg_ver=$(grep "^${meta_pkg}[[:space:]]" ../packages | cut -f3)
+  local gnome_core_ver=$(grep "^gnome-core[[:space:]]" ../packages | cut -f3)
+  local kde_full_ver=$(grep "^kde-full[[:space:]]" ../packages | cut -f3)
+
+(
+cat << EOF
+
+999-z-$meta_pkg:  $PREV_PACKAGE
+	@touch \$(TRACKING_DIR)/${meta_pkg}-${pkg_ver}
+EOF
+) >> $MKFILE.tmp
+
+  case $meta_pkg in
+    gnome-full )
+(
+cat << EOF
+	@touch \$(TRACKING_DIR)/gnome-core-${gnome_core_ver}
+EOF
+) >> $MKFILE.tmp
+      ;;
+    kde-koffice )
+(
+cat << EOF
+	@touch \$(TRACKING_DIR)/kde-full-${kde_full_ver}
+EOF
+) >> $MKFILE.tmp
+      ;;
+  esac
+
+(
+cat << EOF
+	@touch  \$@
+EOF
+) >> $MKFILE.tmp
+
+}
+
+#----------------------------#
 generate_Makefile () {       #
 #----------------------------#
@@ -104,13 +178,22 @@
   for package_script in scripts/* ; do
     this_script=`basename $package_script`
-    script_ver=$(xmllint --noent ../blfs-xml/book/bookinfo.xml 2>/dev/null | \
-    		grep -i " ${this_script#*-?-}-version " | \
-		cut -d "\"" -f2 )
-    if [ ! -e $TRACKING_DIR/${this_script#*-?-}-$script_ver ]; then
-      pkg_list="$pkg_list ${this_script}"
-     __write_entry "${this_script}" "${script_ver}"
-      PREV_PACKAGE=${this_script}
-    fi
+    pkg_ver=$(grep "^${this_script#*-?-}[[:space:]]" ../packages | cut -f3)
+    pkg_list="$pkg_list ${this_script}"
+    __write_entry "${this_script}" "${pkg_ver}"
+    PREV_PACKAGE=${this_script}
   done
+
+  PACKAGE=$(basename $PWD)
+
+   # alsa, kde-core and xorg7 are also available dependencies, thus handled
+   # in another way.
+  case $PACKAGE in
+    gnome-core | \
+    gnome-full | \
+    kde-full | \
+    kde-koffice )  pkg_list="$pkg_list 999-z-${PACKAGE}"
+                  __write_meta_pkg_touch "${PACKAGE}"
+                  ;;
+  esac
 
 
@@ -121,5 +204,5 @@
 $HEADER
 
-PACKAGE= "`basename $PWD`"
+PACKAGE= $PACKAGE
 TRACKING_DIR= $TRACKING_DIR
 
Index: BLFS/gen_config.sh
===================================================================
--- BLFS/gen_config.sh	(revision a3b0e382b5878d7ad5ec8aba6ce8c7738638ebc6)
+++ BLFS/gen_config.sh	(revision a3b0e382b5878d7ad5ec8aba6ce8c7738638ebc6)
@@ -0,0 +1,268 @@
+#!/bin/bash
+#
+# $Id$
+#
+
+export outFile=Config.in	# file for reading and writing to.
+export inFile=packages		# file for reading and writing to.
+
+declare PKG_NAME
+declare PKG_XML_FILE
+declare PKG_DIR
+declare PKG_VER
+declare INST_VER
+declare INST_STRING
+declare SAVE_IFS=${IFS}
+declare -a DIR_TREE
+declare PREV_DIR1="none"
+declare PREV_DIR2="none"
+declare MENU_SET1="n"
+declare MENU_SET2="n"
+
+> $outFile
+
+#---------------------#
+#         MAIN        #
+#---------------------#
+: <<enddoc
+  This script will create a Config.in file from the contents
+  of the file <packages>.
+  Packages previously installed will not be included.
+enddoc
+
+echo -en "\tGenerating Config.in from package data ..."
+while [ 0 ]
+do
+
+#  read -r || break 1
+  read || break 1
+
+  set -- $REPLY
+  PKG_NAME=$1
+  PKG_XML_FILE=$(basename $2)
+  PKG_DIR=$(dirname $2)
+  PKG_VER=$3
+  INST_VER=$4
+    # These are the META packages.
+  if [ $PKG_DIR = "." ]; then
+    SET_COMMENT=y
+      # Do not include previously installed packages
+    if [ -n "${PKG_VER}" ] && [ "x${PKG_VER}" = "x${INST_VER}" ]; then
+      continue
+    fi
+      # Set installed version for updated meta-packages
+    [ -n "${INST_VER}" ] && INST_STRING="[installed ${INST_VER}]"
+
+    META_PKG=$(echo ${PKG_NAME} | tr [a-z] [A-Z])
+(
+cat << EOF
+	config	CONFIG_$META_PKG
+		bool	"$META_PKG $PKG_VER $INST_STRING"
+		default	n
+
+		menu	"$(echo ${PKG_NAME} | tr [a-z] [A-Z]) components"
+			depends	CONFIG_$META_PKG
+
+EOF
+) >> $outFile
+
+    unset INST_STRING
+
+         # Include the dependency data for this meta package
+       while [ 0 ]; do
+         read || break 1
+         PKG_NAME=${REPLY}
+         PKG_VER=$(grep "^${PKG_NAME}[[:space:]]" $inFile | cut -f3)
+         INST_VER=$(grep "^${PKG_NAME}[[:space:]]" $inFile | cut -f4)
+           # Skip installed meta-package components
+         if [ -n "${PKG_VER}" ] && [ "x${PKG_VER}" = "x${INST_VER}" ]; then
+           continue
+         fi
+           # Set installed version for updated meta-packages components
+         [ -n "${INST_VER}" ] && INST_STRING="[installed ${INST_VER}]"
+(
+cat << EOF
+	config	DEP_${META_PKG}_${PKG_NAME}
+		bool	"$PKG_NAME ${PKG_VER} ${INST_STRING}"
+		default	y
+
+EOF
+) >> $outFile
+         unset INST_STRING
+       done <./libs/${PKG_NAME}.dep
+     echo -e "endmenu" >> $outFile
+    continue
+  fi
+  [[ "${SET_COMMENT}" = "y" ]] && echo "comment \"\"" >>$outFile; unset SET_COMMENT
+
+    # Deal with a few unusable (at target level) package names
+  case ${PKG_NAME} in
+     xorg7-* ) continue ;;
+     alsa-* ) continue ;;
+     x-config | x-setup ) continue ;;
+  esac
+
+    # Skip installed packages
+  if [ -n "${PKG_VER}" ] && [ "x${PKG_VER}" = "x${INST_VER}" ]; then
+    continue
+  fi
+    # Set installed version for updated packages
+  [ -n "${INST_VER}" ] && INST_STRING="[installed ${INST_VER}]"
+
+  IFS="/"
+  DIR_TREE=(${PKG_DIR})
+  IFS="$SAVE_IFS"
+
+    # Define a top level menu
+  if [ "$PREV_DIR1" != "${DIR_TREE[1]}" ]; then
+    [[ "${DIR_TREE[1]}" = "kde" ]] && continue
+    [[ "${DIR_TREE[1]}" = "gnome" ]] && continue
+
+    if [ $MENU_SET1 = "y" ]; then
+      # Close out any open secondary menu
+      if [ $MENU_SET2 = "y" ]; then
+        echo -e "\tendmenu" >> $outFile
+        # Reset 'menu open' flag
+        MENU_SET2="n"
+      fi
+      # Close the current top level menu
+      echo -e "endmenu\n" >> $outFile
+    fi
+    # Open a new top level menu
+    echo -e "menu "$(echo ${DIR_TREE[1]:0:1} | tr [a-z] [A-Z])${DIR_TREE[1]:1}"" >> $outFile
+    MENU_SET1="y"
+  fi
+
+    # Define a secondary menu
+  if [ "$PREV_DIR2" != "${DIR_TREE[2]}" ]; then
+      # Close out the previous open menu structure
+    if [ $MENU_SET2 = "y" ]; then
+      echo -e "\tendmenu\n"  >> $outFile
+    fi
+      # Initialize a new 2nd level menu structure.
+    echo -e "\tmenu "$(echo ${DIR_TREE[2]:0:1} | tr [a-z] [A-Z])${DIR_TREE[2]:1}"" >> $outFile
+    MENU_SET2="y"
+  fi
+(
+cat << EOF
+	config CONFIG_$PKG_NAME
+		bool "$PKG_NAME ${PKG_VER} ${INST_STRING}"
+		default n
+EOF
+) >> $outFile
+
+  unset INST_STRING
+
+  PREV_DIR1=${DIR_TREE[1]}
+  PREV_DIR2=${DIR_TREE[2]}
+done <"$inFile"
+
+if [ $MENU_SET2 = "y" ]; then echo -e "\tendmenu" >> $outFile; fi
+if [ $MENU_SET1 = "y" ]; then echo "endmenu" >> $outFile; fi
+
+(
+cat << EOF
+
+comment	""
+
+menu	"Default packages for resolving dependencies"
+
+choice
+	prompt	"Default print server"
+	config	PS_cups
+		bool	"cups"
+	config	PS_LPRng
+		bool	"LPRng"
+endchoice
+config	PRINT_SERVER
+	string
+	default	cups	if PS_cups
+	default	LPRng	if PS_LPRng
+
+choice
+	prompt	"Mail server"
+	config	MS_sendmail
+		bool	"sendmail"
+	config	MS_postfix
+		bool	"postfix"
+	config	MS_exim
+		bool	"exim"
+endchoice
+config	MAIL_SERVER
+	string
+	default	sendmail	if MS_sendmail
+	default	postfix		if MS_postfix
+	default	exim		if MS_exim
+
+choice
+	prompt	"Postscript package"
+	config	GS_espgs
+		bool	"espgs"
+	config	GS_ghostscript
+		bool	"ghostscript"
+endchoice
+config	GHOSTSCRIPT
+	string
+	default	espgs       if GS_espgs
+	default ghostscript if GS_ghostscript
+
+choice
+	prompt	"Kerberos 5"
+	config	KER_mitkrb
+		bool	"mitkrb"
+	config	KER_heimdal
+		bool	"heimdal"
+endchoice
+config	KBR5
+	string
+	default	heimdal	if KER_heimdal
+	default mitkrb	if KER_mitkrb
+
+choice
+	prompt	"Window package"
+	config	WIN_xorg7
+	bool	"Xorg7"
+	config	WIN_xorg
+	bool	"Xorg"
+	config	WIN_xfree86
+	bool	"xfree86"
+endchoice
+config	X11
+	string
+	default	xorg7	if WIN_xorg7
+	default	xorg	if WIN_xorg
+	default xfree86	if WIN_xfree86
+endmenu
+
+choice
+	prompt	"Dependency level"
+	default DEPLVL_2
+
+	config	DEPLVL_1
+	bool	"Required dependencies only"
+
+	config	DEPLVL_2
+	bool	"Required and recommended dependencies"
+
+	config	DEPLVL_3
+	bool	"Required, recommended and optional dependencies"
+
+endchoice
+config	optDependency
+	int
+	default	1	if DEPLVL_1
+	default	2	if DEPLVL_2
+	default	3	if DEPLVL_3
+
+
+config	SUDO
+	bool "Build as User"
+	default	y
+	help
+		Select if sudo will be used (you want build as a normal user)
+		        otherwise sudo is not needed (you want build as root)
+EOF
+) >> $outFile
+echo "done"
+
+
Index: BLFS/gen_pkg_book.sh
===================================================================
--- BLFS/gen_pkg_book.sh	(revision a3b0e382b5878d7ad5ec8aba6ce8c7738638ebc6)
+++ BLFS/gen_pkg_book.sh	(revision a3b0e382b5878d7ad5ec8aba6ce8c7738638ebc6)
@@ -0,0 +1,178 @@
+#!/bin/bash
+#
+# $Id$
+#
+#  Read and parse the configuration parameters..
+#
+set -e
+
+declare -r ConfigFile="configuration"
+declare TARGET
+declare DEP_LEVEL
+declare SUDO
+declare PKGXML
+declare BLFS_XML
+declare VERBOSITY=1
+
+#--------------------------#
+parse_configuration() {    #
+#--------------------------#
+  local	cntr
+  local	optTARGET
+
+  while [ 0 ]; do
+    read || break 1
+
+    # Garbage collection
+    case ${REPLY} in
+      \#* | '') continue ;;
+    esac
+
+    case "${REPLY}" in
+      CONFIG_ALSA=* | \
+      CONFIG_GNOME-CORE=* | \
+      CONFIG_GNOME-FULL=* | \
+      CONFIG_KDE-CORE=* | \
+      CONFIG_KDE-FULL=* | \
+      CONFIG_KDE-KOFFICE=* | \
+      CONFIG_XORG7=* ) REPLY=${REPLY%=*}  # Strip the trailing '=y' test.. unecessary
+                       echo -n "${REPLY}"
+                       if [[ $((++cntr)) > 1 ]]; then
+                         echo "  <<-- ERROR:: SELECT ONLY 1 PACKAGE AT A TIME, META-PACKAGE NOT SELECTED"
+                       else
+                         echo ""
+                         optTARGET=$(echo $REPLY | cut -d "_" -f2 | tr [A-Z] [a-z])
+                       fi
+                       continue ;;
+
+      # Create global variables for these parameters.
+      optDependency=* | \
+      PRINT_SERVER=*  | \
+      MAIL_SERVER=*   | \
+      GHOSTSCRIPT=*   | \
+      KBR5=*  | \
+      X11=*   | \
+      SUDO=*  )  eval ${REPLY} # Define/set a global variable..
+                      continue ;;
+    esac
+
+    if [[ "${REPLY}" =~ "^CONFIG_" ]]; then
+      echo -n "$REPLY"
+      if [[ $((++cntr)) > 1 ]]; then
+        echo "  <<-- ERROR SELECT ONLY 1 PACKAGE AT A TIME, WILL NOT BUILD"
+      else
+        echo ""
+        optTARGET=$( echo $REPLY | sed -e 's@CONFIG_@@' -e 's@=y@@' )
+      fi
+    fi
+  done <$ConfigFile
+
+  if [[ $optTARGET = "" ]]; then
+    echo -e "\n>>> NO TARGET SELECTED.. applicaton terminated"
+    echo -e "    Run <make> again and select a package to build\n"
+    exit 0
+  fi
+
+  TARGET=$optTARGET
+  DEP_LEVEL=$optDependency
+  SUDO=${SUDO:-n}
+}
+
+#--------------------------#
+validate_configuration() { #
+#--------------------------#
+  local -r dotSTR=".................."
+  local -r PARAM_LIST="TARGET DEP_LEVEL SUDO PRINT_SERVER MAIL_SERVER GHOSTSCRIPT KBR5 X11"
+  local -r PARAM_VALS='${config_param}${dotSTR:${#config_param}} ${L_arrow}${BOLD}${!config_param}${OFF}${R_arrow}'
+  local config_param
+
+  for config_param in ${PARAM_LIST}; do
+    echo -e "`eval echo $PARAM_VALS`"
+  done
+}
+
+#
+# Regenerate the META-package dependencies from the configuration file
+#
+#--------------------------#
+regenerate_deps() {        #
+#--------------------------#
+
+  rm -f libs/*.dep-MOD
+  while [ 0 ]; do
+    read || break 1
+    case ${REPLY} in
+      \#* | '') continue ;;
+    esac
+
+    # Drop the "=y"
+    REPLY=${REPLY%=*}
+    if [[ "${REPLY}" =~ "^DEP_" ]]; then
+      META_PACKAGE=$(echo $REPLY | cut -d "_" -f2 | tr [A-Z] [a-z])
+      DEP_FNAME=$(echo $REPLY | cut -d "_" -f3)
+       echo "${DEP_FNAME}" >>libs/${META_PACKAGE}.dep-MOD
+    fi
+
+  done <$ConfigFile
+  #
+  # Replace to 'old' dependency file with a new one.
+  #
+  for dst in `ls ./libs/*.dep-MOD 2>/dev/null`; do
+    cp -vf $dst ${dst%-MOD}
+  done
+}
+
+#
+# Clean configuration file keeping only global default settings.
+# That prevent "trying to assign nonexistent symbol" messages
+# and assures that there is no TARGET selected from a previous run
+#
+#--------------------------#
+clean_configuration() {    #
+#--------------------------#
+
+tail -n 30 configuration > configuration.tmp
+mv configuration.tmp configuration
+
+}
+
+#---------------------
+# Constants
+source libs/constants.inc
+[[ $? > 0 ]] && echo -e "\n\tERROR: constants.inc 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
+
+
+#------- MAIN --------
+if [[ ! -f packages ]] ; then
+  echo -e "\tNo packages file has been found.\n"
+  echo -e "\tExecution aborted.\n"
+  exit 1
+fi
+
+
+parse_configuration
+validate_configuration
+echo "${SD_BORDER}${nl_}"
+echo -n "Are you happy with these settings? yes/no (no): "
+read ANSWER
+if [ x$ANSWER != "xyes" ] ; then
+  echo "${nl_}Rerun make and fix your settings.${nl_}"
+  exit 1
+fi
+echo "${nl_}${SD_BORDER}${nl_}"
+regenerate_deps
+generate_dependency_tree
+generate_TARGET_xml
+generate_target_book
+create_build_scripts "${SUDO}"
+clean_configuration
Index: BLFS/libs/constants.inc
===================================================================
--- BLFS/libs/constants.inc	(revision 5be3651d7f7b42651c1dc9100c665ca90ed30a3a)
+++ BLFS/libs/constants.inc	(revision a3b0e382b5878d7ad5ec8aba6ce8c7738638ebc6)
@@ -3,5 +3,5 @@
 # common constants
 #
-# $Id:
+# $Id$
 #####
 
Index: BLFS/libs/func_dependencies
===================================================================
--- BLFS/libs/func_dependencies	(revision 5be3651d7f7b42651c1dc9100c665ca90ed30a3a)
+++ BLFS/libs/func_dependencies	(revision a3b0e382b5878d7ad5ec8aba6ce8c7738638ebc6)
@@ -47,6 +47,4 @@
   #---------------------
   # 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,/.*,,'`
 
@@ -74,8 +72,6 @@
 
     # 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
+      cp ../libs/alsa.dep dependencies/
       ;;
     gnome-core )
@@ -92,11 +88,8 @@
       ;;
     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
+      cp ../libs/kde-{core,full,koffice}.dep dependencies/
+      ;;
+    xorg7 )
+      cp ../libs/xorg7.dep dependencies/
       ;;
     * ) # Default
@@ -115,5 +108,5 @@
   case $TARGET in
     # If there is no usefull XML page, skip it.
-    alsa | gnome-core | gnome-full | kde-core | kde-full | kde-koffice ) ;;
+    alsa | gnome-core | gnome-full | kde-core | kde-full | kde-koffice | xorg7) ;;
     * )
       echo -e "    $ENTRY_START$PKGXML$ENTRY_END" >> $TARGET-index.xml.tmp
@@ -161,5 +154,5 @@
   local saveIFS=$IFS
   local DEP_LV=$DEP_LEVEL
-  local line line2 DEP
+  local line line2 DEP pkg_ver inst_ver
 
   #------------------
@@ -185,5 +178,6 @@
   > xincludes/$PKG.xinc.tmp
   for DEP in `cat dependencies/$PKG.dep`; do
-    # Special packages (a lot of hacks)
+
+    # Special packages that need be remaped
     case $DEP in
 
@@ -198,15 +192,25 @@
       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 ;;
+      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
+                  ;;
+        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
 
     #------------------
@@ -272,19 +276,16 @@
         # 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
+        # Meta-packages at dependency level
+        alsa )
+          cp ../libs/alsa.dep dependencies/
           ;;
         kde-core )
           cp ../libs/kde-core.dep dependencies/
           ;;
-        x-window-system ) # X11 alternatives
+        x-window-system ) # When X11 is not Xorg7
           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
+          cp ../libs/xorg7.dep dependencies/
           ;;
         * ) xsltproc --stringparam dependencies $DEP_LV \
@@ -338,5 +339,5 @@
   if [[ "$PKG" = "xorg7" ]] ; then
     # Add their XInclude
-    PKG_XML=`grep "^$PKG[[:space:]]" ../packages | cut -f2`
+    PKG_XML=${BLFS_XML}/x/installing/xorg7.xml
     echo -e "    $ENTRY_START$PKG_XML$ENTRY_END" >> xincludes/$PKG.xinc.tmp
   fi
Index: BLFS/libs/func_packages
===================================================================
--- BLFS/libs/func_packages	(revision 5be3651d7f7b42651c1dc9100c665ca90ed30a3a)
+++ BLFS/libs/func_packages	(revision a3b0e382b5878d7ad5ec8aba6ce8c7738638ebc6)
@@ -6,7 +6,50 @@
 
 #-----------------------#
+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 ;;
+               jdk ) pkg_id=jdk-src ;;
+          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
+
+}
+
+#-----------------------#
+get_installed_ver() {   # Find installed package version for a given package ID
+#-----------------------#
+  local pkg_id=$1
+
+  find $TRACKING_DIR -name "${pkg_id}-[[:digit:]]*" | sed "s/.*${pkg_id}-//"
+
+}
+
+#-----------------------#
 generate_packages()  {  # Master packages file
 #-----------------------#
-  local pkg_id file
+  local pkg_id file pkg_ver
+  local ALSA_VER GNOME_VER GNOME_MINOR_VER KDE_VER KDE_KOFFICE_VER XORG7_VER
 
   > packages.tmp
@@ -14,38 +57,51 @@
   # 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
+    pkg_id=$(grep "sect1 id" $file | sed -e 's/<sect1 id="//;s/".*//')
+    pkg_ver=$(get_pkg_ver $pkg_id)
+    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' 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
+  sed -i '/template/d;/ntroduction/d;/preface/d;/alsa.xml/d' packages.tmp
+  sed -i '/obsolete/d;/postlfs-/d;/-client.xml/d;/xorg7.xml/d' packages.tmp
+  sed -i '/courier.xml/d;/-other\t/d;/others-/d;/other-/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' packages.tmp
+  sed -i '/gst-plugins\t/d;/openquicktime\t/d;/compressdoc\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
-
-=== 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 ===
-
+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
+} >> packages.tmp
 
   # Dump packages list
-  sort packages.tmp >> packages
+  sort packages.tmp -b --key=2 --field-separator=/ --output=packages
 
   # Clean up
@@ -68,4 +124,7 @@
   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
@@ -128,2 +187,23 @@
   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\
+xorg7-font\nxorg7-data\nxorg7-app\nxbitmaps\nmesalib\nlibdrm\n\
+xorg7-lib\nxorg7-util\nxorg7-proto" > libs/xorg7.dep
+}
Index: BLFS/libs/func_parser
===================================================================
--- BLFS/libs/func_parser	(revision 5be3651d7f7b42651c1dc9100c665ca90ed30a3a)
+++ BLFS/libs/func_parser	(revision a3b0e382b5878d7ad5ec8aba6ce8c7738638ebc6)
@@ -144,7 +144,8 @@
            -o ./scripts/ ../libs/scripts.xsl \
            $TARGET-index.xml >> xsltproc.log 2>&1
-  echo -e "done\n"
     # Make the scripts executable.
   chmod -R +x scripts
+  cd ..
+  echo -e "done\n"
 
 }
Index: BLFS/libs/scripts.xsl
===================================================================
--- BLFS/libs/scripts.xsl	(revision 5be3651d7f7b42651c1dc9100c665ca90ed30a3a)
+++ BLFS/libs/scripts.xsl	(revision a3b0e382b5878d7ad5ec8aba6ce8c7738638ebc6)
@@ -27,7 +27,5 @@
 
         <!-- 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')"/>
+      <xsl:variable name="filename" select="@id"/>
 
         <!-- Package name (use "Download FTP" by default. If empty, use "Download HTTP" -->
Index: BLFS/update_book.sh
===================================================================
--- BLFS/update_book.sh	(revision 5be3651d7f7b42651c1dc9100c665ca90ed30a3a)
+++ BLFS/update_book.sh	(revision a3b0e382b5878d7ad5ec8aba6ce8c7738638ebc6)
@@ -7,6 +7,6 @@
 declare -r SVN="svn://svn.linuxfromscratch.org"
 
-BLFS_XML=$1  # Book directory
-DOC_MODE=$2  # Action to take, update or get
+DOC_MODE=$1  # Action to take, update, get or none
+BLFS_XML=$2  # Book directory
 TREE=$3      # SVN tree for the BLFS book version
 
@@ -14,4 +14,6 @@
 [[ -z $DOC_MODE ]] && DOC_MODE=update
 [[ -z $TREE ]] && TREE=trunk/BOOK
+
+TRACKING_DIR=tracking-dir
 
 #---------------------
@@ -69,24 +71,38 @@
 }
 
-BOOK_Source
+[ "${DOC_MODE}" != "none" ] && BOOK_Source
 
-echo -en "\n\tGenerating packages file ..."
-generate_packages
-echo "done."
+if [ "${DOC_MODE}" = "none" ] ; then
+  echo -en "\n\tGenerating packages database file ..."
+  generate_packages
+  echo "done."
 
-echo -en "\tGenerating gnome-core dependencies list ..."
-generate_gnome_core
-echo "done."
+  echo -en "\tGenerating alsa dependencies list ..."
+  generate_alsa
+  echo "done."
 
-echo -en "\tGenerating gnome-full dependencies list ..."
-generate_gnome_full
-echo "done."
+  echo -en "\tGenerating gnome-core dependencies list ..."
+  generate_gnome_core
+  echo "done."
 
-echo -en "\tGenerating kde-core dependencies list ..."
-generate_kde_core
-echo "done."
+  echo -en "\tGenerating gnome-full dependencies list ..."
+  generate_gnome_full
+  echo "done."
 
-echo -en "\tGenerating kde-full dependencies list ..."
-generate_kde_full
-echo -e "done.\n"
+  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."
+
+  echo -en "\tGenerating kde-koffice dependencies list ..."
+  generate_kde_koffice
+  echo -e "done."
+
+  echo -en "\tGenerating xorg7 dependencies list ..."
+  generate_xorg7
+  echo "done."
+fi
+
