Starting the move of some features to the XSL code.
First try to manage chapter05.
This commit is contained in:
parent
409488e63e
commit
63b2859f59
2 changed files with 20 additions and 39 deletions
|
@ -4,7 +4,7 @@
|
||||||
extension-element-prefixes="exsl"
|
extension-element-prefixes="exsl"
|
||||||
version="1.0">
|
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:template match="/">
|
||||||
<xsl:apply-templates select="//sect1"/>
|
<xsl:apply-templates select="//sect1"/>
|
||||||
|
@ -39,6 +39,7 @@
|
||||||
</xsl:variable>
|
</xsl:variable>
|
||||||
<!-- Creating dirs and files -->
|
<!-- Creating dirs and files -->
|
||||||
<exsl:document href="{$dirname}/{$order}-{$filename}" method="text">
|
<exsl:document href="{$dirname}/{$order}-{$filename}" method="text">
|
||||||
|
<xsl:text>#!/bin/sh

</xsl:text>
|
||||||
<xsl:apply-templates select=".//screen"/>
|
<xsl:apply-templates select=".//screen"/>
|
||||||
</exsl:document>
|
</exsl:document>
|
||||||
</xsl:template>
|
</xsl:template>
|
||||||
|
@ -47,13 +48,6 @@
|
||||||
<xsl:if test="child::* = userinput">
|
<xsl:if test="child::* = userinput">
|
||||||
<xsl:choose>
|
<xsl:choose>
|
||||||
<xsl:when test="@role = 'nodump'"/>
|
<xsl:when test="@role = 'nodump'"/>
|
||||||
<xsl:when test="@role = 'root'">
|
|
||||||
<xsl:text>
</xsl:text>
|
|
||||||
<xsl:text># Run this as root</xsl:text>
|
|
||||||
<xsl:apply-templates select="userinput"/>
|
|
||||||
<xsl:text># End root commands</xsl:text>
|
|
||||||
<xsl:text>
</xsl:text>
|
|
||||||
</xsl:when>
|
|
||||||
<xsl:otherwise>
|
<xsl:otherwise>
|
||||||
<xsl:apply-templates select="userinput"/>
|
<xsl:apply-templates select="userinput"/>
|
||||||
</xsl:otherwise>
|
</xsl:otherwise>
|
||||||
|
@ -62,17 +56,8 @@
|
||||||
</xsl:template>
|
</xsl:template>
|
||||||
|
|
||||||
<xsl:template match="userinput">
|
<xsl:template match="userinput">
|
||||||
<xsl:text>
</xsl:text>
|
|
||||||
<xsl:if test=".//replaceable">
|
|
||||||
<xsl:text># This block must be edited to suit your needs.</xsl:text>
|
|
||||||
</xsl:if>
|
|
||||||
<xsl:text>
</xsl:text>
|
|
||||||
<xsl:apply-templates/>
|
<xsl:apply-templates/>
|
||||||
<xsl:text>
</xsl:text>
|
<xsl:text> &&
</xsl:text>
|
||||||
<xsl:if test=".//replaceable">
|
|
||||||
<xsl:text># End of editable block.</xsl:text>
|
|
||||||
</xsl:if>
|
|
||||||
<xsl:text>
</xsl:text>
|
|
||||||
</xsl:template>
|
</xsl:template>
|
||||||
|
|
||||||
<xsl:template match="replaceable">
|
<xsl:template match="replaceable">
|
||||||
|
|
38
jhalfs
38
jhalfs
|
@ -1,7 +1,8 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
version="
|
version="
|
||||||
jhalfs 0.2
|
jhalfs development
|
||||||
|
|
||||||
Written by Jeremy Huntwork.
|
Written by Jeremy Huntwork.
|
||||||
Maintained by Manuel Canales Esparcia.
|
Maintained by Manuel Canales Esparcia.
|
||||||
|
|
||||||
|
@ -158,17 +159,6 @@ extract_commands() {
|
||||||
xsltproc --nonet --xinclude -o ./commands/ $XSL \
|
xsltproc --nonet --xinclude -o ./commands/ $XSL \
|
||||||
lfs-$LFSVRS/index.xml >>$JHALFSDIR/$LOG 2>&1
|
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.
|
# Grab the patches and package names.
|
||||||
cd $JHALFSDIR
|
cd $JHALFSDIR
|
||||||
for i in patches packages ; do rm -f $i ; done
|
for i in patches packages ; do rm -f $i ; done
|
||||||
|
@ -263,8 +253,11 @@ build_Makefile() {
|
||||||
# Start with a clean Makefile.tmp file
|
# Start with a clean Makefile.tmp file
|
||||||
>$MKFILE.tmp
|
>$MKFILE.tmp
|
||||||
|
|
||||||
for i in * ; do
|
for file in chapter0{4,5}/* ; do
|
||||||
# First append each name of the command files to a list (this will become
|
# 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
|
# the names of the targets in the Makefile
|
||||||
list="$list $i"
|
list="$list $i"
|
||||||
|
|
||||||
|
@ -293,13 +286,16 @@ build_Makefile() {
|
||||||
echo -e "\tcd \$(SRC)/\$\$ROOT && \\" >> $MKFILE.tmp
|
echo -e "\tcd \$(SRC)/\$\$ROOT && \\" >> $MKFILE.tmp
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Drop in the actual commands that were parsed from the book
|
# # Drop in the actual commands that were parsed from the book
|
||||||
# These seds add an extra $ to each variable so make doesn't break,
|
# # 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
|
# # add tabs to the beginning of each line, and add ' && \' to the end
|
||||||
# of each line except for those that end in '\'.
|
# # of each line except for those that end in '\'.
|
||||||
cat $i | sed -e 's:\$:&&:g' -e 's:^:\t:' -e 's:[^\\]$:& \&\& \\:' >> $MKFILE.tmp
|
# cat $i | sed -e 's:\$:&&:g' -e 's:^:\t:' -e 's:[^\\]$:& \&\& \\:' >> $MKFILE.tmp
|
||||||
# This sed removes the ' && \' from the last command of each target
|
# # This sed removes the ' && \' from the last command of each target
|
||||||
sed -i '$s: \&\& \\::' $MKFILE.tmp
|
# 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.
|
# Include a touch of the target name so make can check if it's already been made.
|
||||||
echo -e "\ttouch \$@" >> $MKFILE.tmp
|
echo -e "\ttouch \$@" >> $MKFILE.tmp
|
||||||
|
|
Reference in a new issue