Starting the move of some features to the XSL code.

First try to manage chapter05.
This commit is contained in:
Manuel Canales Esparcia 2005-09-26 22:36:40 +00:00
parent 409488e63e
commit 63b2859f59
2 changed files with 20 additions and 39 deletions

View file

@ -4,7 +4,7 @@
extension-element-prefixes="exsl"
version="1.0">
<!-- XSLT stylesheet to extract commands from [B,H]LFS books. -->
<!-- XSLT stylesheet to create shell scripts from LFS books. -->
<xsl:template match="/">
<xsl:apply-templates select="//sect1"/>
@ -39,6 +39,7 @@
</xsl:variable>
<!-- Creating dirs and files -->
<exsl:document href="{$dirname}/{$order}-{$filename}" method="text">
<xsl:text>#!/bin/sh&#xA;&#xA;</xsl:text>
<xsl:apply-templates select=".//screen"/>
</exsl:document>
</xsl:template>
@ -47,13 +48,6 @@
<xsl:if test="child::* = userinput">
<xsl:choose>
<xsl:when test="@role = 'nodump'"/>
<xsl:when test="@role = 'root'">
<xsl:text>&#xA;</xsl:text>
<xsl:text># Run this as root</xsl:text>
<xsl:apply-templates select="userinput"/>
<xsl:text># End root commands</xsl:text>
<xsl:text>&#xA;</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="userinput"/>
</xsl:otherwise>
@ -62,17 +56,8 @@
</xsl:template>
<xsl:template match="userinput">
<xsl:text>&#xA;</xsl:text>
<xsl:if test=".//replaceable">
<xsl:text># This block must be edited to suit your needs.</xsl:text>
</xsl:if>
<xsl:text>&#xA;</xsl:text>
<xsl:apply-templates/>
<xsl:text>&#xA;</xsl:text>
<xsl:if test=".//replaceable">
<xsl:text># End of editable block.</xsl:text>
</xsl:if>
<xsl:text>&#xA;</xsl:text>
<xsl:text> &amp;&amp;&#xA;</xsl:text>
</xsl:template>
<xsl:template match="replaceable">

38
jhalfs
View file

@ -1,7 +1,8 @@
#!/bin/sh
version="
jhalfs 0.2
jhalfs development
Written by Jeremy Huntwork.
Maintained by Manuel Canales Esparcia.
@ -158,17 +159,6 @@ extract_commands() {
xsltproc --nonet --xinclude -o ./commands/ $XSL \
lfs-$LFSVRS/index.xml >>$JHALFSDIR/$LOG 2>&1
# Move the text files out from the chapter directories, and dump them
# all into the 'commands' directory.
cd commands
find ./* -xtype f -exec mv '{}' . \;
find ./* -maxdepth 0 -xtype d -exec rm -rf '{}' \;
# Remove all the blank lines from the commands
for i in $JHALFSDIR/commands/* ; do
sed -i '/^$/d' $i
done
# Grab the patches and package names.
cd $JHALFSDIR
for i in patches packages ; do rm -f $i ; done
@ -263,8 +253,11 @@ build_Makefile() {
# Start with a clean Makefile.tmp file
>$MKFILE.tmp
for i in * ; do
# First append each name of the command files to a list (this will become
for file in chapter0{4,5}/* ; do
# Keep the script file name
i=`basename $file`
# First append each name of the script files to a list (this will become
# the names of the targets in the Makefile
list="$list $i"
@ -293,13 +286,16 @@ build_Makefile() {
echo -e "\tcd \$(SRC)/\$\$ROOT && \\" >> $MKFILE.tmp
fi
# Drop in the actual commands that were parsed from the book
# These seds add an extra $ to each variable so make doesn't break,
# add tabs to the beginning of each line, and add ' && \' to the end
# of each line except for those that end in '\'.
cat $i | sed -e 's:\$:&&:g' -e 's:^:\t:' -e 's:[^\\]$:& \&\& \\:' >> $MKFILE.tmp
# This sed removes the ' && \' from the last command of each target
sed -i '$s: \&\& \\::' $MKFILE.tmp
# # Drop in the actual commands that were parsed from the book
# # These seds add an extra $ to each variable so make doesn't break,
# # add tabs to the beginning of each line, and add ' && \' to the end
# # of each line except for those that end in '\'.
# cat $i | sed -e 's:\$:&&:g' -e 's:^:\t:' -e 's:[^\\]$:& \&\& \\:' >> $MKFILE.tmp
# # This sed removes the ' && \' from the last command of each target
# sed -i '$s: \&\& \\::' $MKFILE.tmp
# Run the script
echo -e "\tsu - lfs -c \"/bin/bash $file\"" >> $MKFILE.tmp
# Include a touch of the target name so make can check if it's already been made.
echo -e "\ttouch \$@" >> $MKFILE.tmp