r1185 - in trunk/BOOK: . chapter01

manuel at linuxfromscratch.org manuel at linuxfromscratch.org
Sun Jul 8 04:06:37 PDT 2007


Author: manuel
Date: 2007-07-08 05:06:37 -0600 (Sun, 08 Jul 2007)
New Revision: 1185

Modified:
   trunk/BOOK/Makefile
   trunk/BOOK/chapter01/changelog.xml
   trunk/BOOK/obfuscate.sh
Log:
Updated book sources to use the new LFS-XSL Stylesheets.

Modified: trunk/BOOK/Makefile
===================================================================
--- trunk/BOOK/Makefile	2007-07-08 11:04:18 UTC (rev 1184)
+++ trunk/BOOK/Makefile	2007-07-08 11:06:37 UTC (rev 1185)
@@ -1,17 +1,26 @@
 BASEDIR=~/hlfs-book
-CHUNK_QUIET=0
+RENDERTMP= $(HOME)/tmp
+CHUNK_QUIET=1
+ROOT_ID=""
 
 # This variables don't should be overwritten by command line
 DUMPDIR=$(BASEDIR)/$(LIBC)-$(KERNEL)-commands
 PDF_OUTPUT=HLFS-BOOK-$(LIBC)-$(KERNEL).pdf
 NOCHUNKS_OUTPUT=HLFS-BOOK-$(LIBC)-$(KERNEL).html
 
+ifdef V
+  Q =
+else
+  Q = @
+endif
+
 # By default, generates all chunked books plus top-level files
 all: top-level glibc-26-book glibc-24-book uclibc-26-book uclibc-24-book common-stuff
 
 # Validate the book
 validate:
-	xmllint --noout --nonet --xinclude --postvalid index.xml
+	@echo "Validating the book..."
+	$(Q)xmllint --noout --nonet --xinclude --postvalid index.xml
 
 # PDF books
 pdf: glibc26pdf glibc24pdf uclibc26pdf uclibc24pdf
@@ -26,7 +35,7 @@
 wget-list: wget-glibc26 wget-glibc24 wget-uclibc26 wget-uclibc24
 
 # All-in-one
-world: validate all pdf nochunks dump-commands wget-list
+world: all pdf nochunks dump-commands wget-list
 
 # Targets for individual chunked books with top-level files
 glibc26: top-level glibc-26-book common-stuff
@@ -34,23 +43,38 @@
 uclibc26: top-level uclibc-26-book common-stuff
 uclibc24: top-level uclibc-24-book common-stuff
 
+# Dump the book into a unique XML file with Xincludes and entities solved,
+# then validate it. Useful to improve rendering speed on large tergets.
+validxml: tmpdir
+	@echo "Validating the book..."
+	$(Q)xmllint --nonet --noent --xinclude --postvalid \
+	  -o $(RENDERTMP)/hlfs-full.xml index.xml
 
+# Be sure that RENDERDIR esist and clean it
+tmpdir:
+	@echo "Creating and cleaning $(RENDERTMP)"
+	$(Q)[ -d $(RENDERTMP) ] || mkdir -p $(RENDERTMP)
+	$(Q)rm -f $(RENDERTMP)/hlfs-{full,html,pdf,dump}.xml
+	$(Q)rm -f $(RENDERTMP)/hlfs-pdf.fo
+
+
 # CHUNKED BOOKS SUB-TARGETS #
 
 # top-level index.html
 top-level:
-	xsltproc --nonet --output $(BASEDIR)/index.html \
+	@echo "Generating top-level files..."
+	$(Q)xsltproc --nonet --output $(BASEDIR)/index.html \
 	  stylesheets/top-index.xsl prologue/bookinfo.xml
 
-	xsltproc --xinclude --nonet -stringparam chapter.autolabel 0 \
+	$(Q)xsltproc --xinclude --nonet -stringparam chapter.autolabel 0 \
 	  -stringparam section.autolabel 0 --output $(BASEDIR)/features.html \
-	  stylesheets/lfs-nochunks.xsl features.xml
+	  stylesheets/hlfs-nochunks.xsl features.xml
 
-	if [ ! -e $(BASEDIR)/images ]; then \
+	$(Q)if [ ! -e $(BASEDIR)/images ]; then \
 	  mkdir -p $(BASEDIR)/images; \
 	fi;
-	cp images/*.png $(BASEDIR)/images
-	cp stylesheets/features.js $(BASEDIR)
+	$(Q)cp images/*.png $(BASEDIR)/images
+	$(Q)cp stylesheets/features.js $(BASEDIR)
 
 # Books variables
 glibc-26-book glibc-24-book:   LIBC=glibc
@@ -59,27 +83,34 @@
 glibc-24-book uclibc-24-book:  KERNEL=2.4
 
 # Chunked books targets
-glibc-26-book uclibc-26-book glibc-24-book uclibc-24-book:
-	xsltproc --xinclude --nonet -stringparam profile.condition html,$(LIBC) \
-	  -stringparam profile.vendor $(KERNEL) -stringparam chunk.quietly \
-	  $(CHUNK_QUIET) -stringparam base.dir $(BASEDIR)/$(LIBC)-$(KERNEL)/ \
-	  stylesheets/lfs-chunked.xsl index.xml
+glibc-26-book uclibc-26-book glibc-24-book uclibc-24-book: validxml
+	@echo "Generating profiled XML for XHTML $(LIBC) + $(KERNEL)..."
+	$(Q)xsltproc --nonet --stringparam profile.condition html,$(LIBC) \
+	  -stringparam profile.vendor $(KERNEL) --output $(RENDERTMP)/hlfs-html.xml \
+	  stylesheets/lfs-xsl/profile.xsl $(RENDERTMP)/hlfs-full.xml
 
-	if [ ! -e $(BASEDIR)/$(LIBC)-$(KERNEL)/stylesheets ]; then \
+	@echo "Generating chunked XHTML files..."
+	$(Q)xsltproc --nonet -stringparam chunk.quietly $(CHUNK_QUIET) \
+	  -stringparam rootid $(ROOT_ID) \
+	  -stringparam base.dir $(BASEDIR)/$(LIBC)-$(KERNEL)/ \
+	  stylesheets/hlfs-chunked.xsl $(RENDERTMP)/hlfs-html.xml
+
+	@echo "Copying CSS code and images..."
+	$(Q)if [ ! -e $(BASEDIR)/$(LIBC)-$(KERNEL)/stylesheets ]; then \
 	  mkdir -p $(BASEDIR)/$(LIBC)-$(KERNEL)/stylesheets; \
 	fi;
-	cp stylesheets/*.css $(BASEDIR)/$(LIBC)-$(KERNEL)/stylesheets
-
-	if [ ! -e $(BASEDIR)/$(LIBC)-$(KERNEL)/images ]; then \
+	$(Q)cp stylesheets/lfs-xsl/*.css $(BASEDIR)/$(LIBC)-$(KERNEL)/stylesheets
+	$(Q)if [ ! -e $(BASEDIR)/$(LIBC)-$(KERNEL)/images ]; then \
 	  mkdir -p $(BASEDIR)/$(LIBC)-$(KERNEL)/images; \
 	fi;
-	cp images/*.png $(BASEDIR)/$(LIBC)-$(KERNEL)/images
-	cd $(BASEDIR)/$(LIBC)-$(KERNEL)/; sed -i -e "s at ../stylesheets at stylesheets@g" *.html
-	cd $(BASEDIR)/$(LIBC)-$(KERNEL)/; sed -i -e "s at ../images at images@g" *.html
+	$(Q)cp images/*.png $(BASEDIR)/$(LIBC)-$(KERNEL)/images
+	$(Q)cd $(BASEDIR)/$(LIBC)-$(KERNEL)/; sed -i -e "s at ../stylesheets at stylesheets@g" *.html
+	$(Q)cd $(BASEDIR)/$(LIBC)-$(KERNEL)/; sed -i -e "s at ../images at images@g" *.html
 
 # Common stuff for top-level and chunked books
 common-stuff:
-	for filename in `find $(BASEDIR) -name "*.html"`; do \
+	@echo "Running Tidy and obfuscate.sh..."
+	$(Q)for filename in `find $(BASEDIR) -name "*.html"`; do \
 	  tidy -config tidy.conf $$filename; \
 	  true; \
 	  sh obfuscate.sh $$filename; \
@@ -97,17 +128,21 @@
 glibc26pdf uclibc26pdf:  KERNEL=2.6
 glibc24pdf uclibc24pdf:  KERNEL=2.4
 
-glibc26pdf glibc24pdf uclibc26pdf uclibc24pdf:
-	xsltproc --xinclude --nonet --stringparam profile.condition pdf,$(LIBC) \
-	  -stringparam profile.vendor $(KERNEL) --output $(BASEDIR)/hlfs-pdf.xml \
-	  stylesheets/lfs-profile.xsl index.xml
+glibc26pdf glibc24pdf uclibc26pdf uclibc24pdf: validxml
+	@echo "Generating profiled XML for PDF $(LIBC) + $(KERNEL)..."
+	$(Q)xsltproc --nonet --stringparam profile.condition pdf,$(LIBC) \
+	  -stringparam profile.vendor $(KERNEL) --output $(RENDERTMP)/hlfs-pdf.xml \
+	  stylesheets/lfs-xsl/profile.xsl $(RENDERTMP)/hlfs-full.xml
 
-	xsltproc --nonet --output $(BASEDIR)/hlfs-pdf.fo stylesheets/lfs-pdf.xsl \
-	  $(BASEDIR)/hlfs-pdf.xml
+	@echo "Generating FO file..."
+	$(Q)xsltproc --nonet -stringparam rootid $(ROOT_ID) \
+	  --output $(RENDERTMP)/hlfs-pdf.fo stylesheets/hlfs-pdf.xsl \
+	  $(RENDERTMP)/hlfs-pdf.xml
+	$(Q)sed -i -e 's/span="inherit"/span="all"/' $(RENDERTMP)/hlfs-pdf.fo
 
-	sed -i -e "s/inherit/all/" $(BASEDIR)/hlfs-pdf.fo
-	fop.sh $(BASEDIR)/hlfs-pdf.fo $(BASEDIR)/$(PDF_OUTPUT)
-	rm $(BASEDIR)/hlfs-pdf.xml $(BASEDIR)/hlfs-pdf.fo
+	@echo "Generating PDF file..."
+	$(Q)[ -d $(BASEDIR) ] || mkdir -p $(BASEDIR)
+	$(Q)fop $(RENDERTMP)/hlfs-pdf.fo $(BASEDIR)/$(PDF_OUTPUT)
 
 #-----------------------#
 
@@ -120,16 +155,24 @@
 glibc26nochunk uclibc26nochunk:  KERNEL=2.6
 glibc24nochunk uclibc24nochunk:  KERNEL=2.4
 
-glibc26nochunk glibc24nochunk uclibc26nochunk uclibc24nochunk:
-	xsltproc --xinclude --nonet -stringparam profile.condition html,$(LIBC) \
-	  -stringparam profile.vendor $(KERNEL) --output $(BASEDIR)/$(NOCHUNKS_OUTPUT) \
-	  stylesheets/lfs-nochunks.xsl index.xml
+glibc26nochunk glibc24nochunk uclibc26nochunk uclibc24nochunk: validxml
+	@echo "Generating profiled XML for XHTML $(LIBC) + $(KERNEL)..."
+	$(Q)xsltproc --nonet --stringparam profile.condition html,$(LIBC) \
+	  -stringparam profile.vendor $(KERNEL) --output $(RENDERTMP)/hlfs-html.xml \
+	  stylesheets/lfs-xsl/profile.xsl $(RENDERTMP)/hlfs-full.xml
 
-	tidy -config tidy.conf $(BASEDIR)/$(NOCHUNKS_OUTPUT) || true
+	@echo "Generating non chunked XHTML file..."
+	$(Q)xsltproc --nonet -stringparam rootid $(ROOT_ID) \
+	  --output $(BASEDIR)/$(NOCHUNKS_OUTPUT) \
+	  stylesheets/hlfs-nochunks.xsl $(RENDERTMP)/hlfs-html.xml
 
-	sh obfuscate.sh $(BASEDIR)/$(NOCHUNKS_OUTPUT)
+	@echo "Running Tidy..."
+	$(Q)tidy -config tidy.conf $(BASEDIR)/$(NOCHUNKS_OUTPUT) || true
 
-	sed -i -e "s at text/html at application/xhtml+xml at g"  \
+	@echo "Running obfuscate.sh..."
+	$(Q)sh obfuscate.sh $(BASEDIR)/$(NOCHUNKS_OUTPUT)
+
+	$(Q)sed -i -e "s at text/html at application/xhtml+xml at g"  \
 	  $(BASEDIR)/$(NOCHUNKS_OUTPUT)
 
 #-----------------------#
@@ -143,16 +186,15 @@
 dump-glibc26 dump-uclibc26:  KERNEL=2.6
 dump-glibc24 dump-uclibc24:  KERNEL=2.4
 
-dump-glibc26 dump-glibc24 dump-uclibc26 dump-uclibc24:
-	xsltproc --xinclude --nonet --stringparam profile.condition html,$(LIBC) \
-	  -stringparam profile.vendor $(KERNEL) --output $(DUMPDIR)/hlfs-dump.xml \
-	  stylesheets/lfs-profile.xsl index.xml
+dump-glibc26 dump-glibc24 dump-uclibc26 dump-uclibc24: validxml
+	@echo "Dumping book commands for $(LIBC) + $(KERNEL)..."
+	$(Q)xsltproc --nonet --stringparam profile.condition html,$(LIBC) \
+	  -stringparam profile.vendor $(KERNEL) --output $(RENDERTMP)/hlfs-dump.xml \
+	  stylesheets/lfs-xsl/profile.xsl $(RENDERTMP)/hlfs-full.xml
 
-	xsltproc --xinclude --nonet --output $(DUMPDIR)/ \
-	   stylesheets/dump-commands.xsl $(DUMPDIR)/hlfs-dump.xml
+	$(Q)xsltproc --nonet --output $(DUMPDIR)/ \
+	   stylesheets/dump-commands.xsl $(RENDERTMP)/hlfs-dump.xml
 
-	rm $(DUMPDIR)/hlfs-dump.xml
-
 #-----------------------#
 
 
@@ -165,12 +207,12 @@
 wget-glibc24 wget-uclibc24:  KERNEL=2.4
 
 wget-glibc26 wget-glibc24 wget-uclibc26 wget-uclibc24:
-	mkdir -p $(BASEDIR)
+	@echo "Generating wget list for $(LIBC) + $(KERNEL)..."
+	$(Q)mkdir -p $(BASEDIR)
+	$(Q)xsltproc --xinclude --nonet -stringparam libc $(LIBC) \
+	  -stringparam kernel $(KERNEL) --output $(BASEDIR)/wget-$(LIBC)-$(KERNEL)-list \
+	  stylesheets/wget-list.xsl chapter04/chapter04.xml
 
-	xsltproc --xinclude --nonet -stringparam libc $(LIBC) \
-	  -stringparam kernel $(KERNEL) stylesheets/wget-list.xsl \
-	  chapter04/chapter04.xml > $(BASEDIR)/wget-$(LIBC)-$(KERNEL)-list
-
 #-----------------------#
 
 .PHONY: all common-stuff dump-commands dump-glibc24 dump-glibc26 dump-uclibc24 \
@@ -178,5 +220,5 @@
 	glibc-26-book glibc26nochunk glibc26pdf nochunks pdf top-level uclibc24 \
 	uclibc-24-book uclibc24nochunk uclibc24pdf uclibc26 uclibc-26-book \
 	uclibc26nochunk uclibc26pdf validate wget-glibc24 wget-glibc26 wget-list \
-	wget-uclibc24 wget-uclibc26 world
+	wget-uclibc24 wget-uclibc26 world validxml
 

Modified: trunk/BOOK/chapter01/changelog.xml
===================================================================
--- trunk/BOOK/chapter01/changelog.xml	2007-07-08 11:04:18 UTC (rev 1184)
+++ trunk/BOOK/chapter01/changelog.xml	2007-07-08 11:06:37 UTC (rev 1185)
@@ -49,6 +49,16 @@
 -->
 
     <listitem>
+      <para>July 8th, 2006</para>
+      <itemizedlist>
+        <listitem>
+          <para>[manuel] - Updated the stylesheets and Makefile to use the new
+          XSL code and Fop-0.93.</para>
+        </listitem>
+      </itemizedlist>
+    </listitem>
+
+    <listitem>
       <para>July 5th, 2007</para>
       <itemizedlist>
         <listitem>

Modified: trunk/BOOK/obfuscate.sh
===================================================================
--- trunk/BOOK/obfuscate.sh	2007-07-08 11:04:18 UTC (rev 1184)
+++ trunk/BOOK/obfuscate.sh	2007-07-08 11:06:37 UTC (rev 1185)
@@ -3,6 +3,8 @@
 # obfuscate.sh
 # obfuscate email addresses in XML/HTML
 # Script written (and slight perl modification) by Archaic <archaic AT linuxfromscratch D0T org>
+# Modified from "sed -i" to old style "sed -e" by Manuel Canales <manuel AT linuxfromscratch D0T org>
+# to prevent hangs on very long files, like nonckunked books.
 # Original Perl expression by Anderson Lizardo <lizardo AT linuxfromscratch D0T org>
 # Released under the GNU General Public License
 #
@@ -25,11 +27,13 @@
 # Nothing like a backup plan!
 #cp "$1" "$1".bak
 
-for i in `grep -o '"mailto:.*@.*"' "$1" |sed -e 's|^"mailto:||' -e 's|"$||'`; do
+for i in `grep -o '"mailto:.*@.*"' ${1} |sed -e 's|^"mailto:||' -e 's|"$||'`; do
   link=`echo $i | perl -pe 's/[^\n]/"\\\&#".ord($&)."\;"/ge'`
   plaintext=`echo $i | sed -e 's|@| AT |' -e 's|\.| D0T |g'`
-  sed -i "s|mailto:$i|mailto:$link|" "$1"
-  sed -i "s|$i|$plaintext|" "$1"
+  cp ${1}{,.tmp}
+  sed -e "s|mailto:$i|mailto:$link|" \
+      -e "s|$i|$plaintext|" ${1}.tmp > ${1}
+  rm ${1}.tmp
 done
-
+#rm $FILE.tmp
 #exit 0




More information about the hlfs-book mailing list