[877cc6a] | 1 | <?xml version="1.0"?>
|
---|
| 2 | <!DOCTYPE xsl:stylesheet [
|
---|
| 3 | <!ENTITY % general-entities SYSTEM "FAKEDIR/general.ent">
|
---|
| 4 | %general-entities;
|
---|
| 5 | ]>
|
---|
| 6 |
|
---|
| 7 | <!-- $Id$ -->
|
---|
| 8 |
|
---|
| 9 | <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
---|
| 10 | xmlns:exsl="http://exslt.org/common"
|
---|
| 11 | extension-element-prefixes="exsl"
|
---|
| 12 | version="1.0">
|
---|
| 13 |
|
---|
| 14 | <!-- XSLT stylesheet to create shell scripts from HLFS books. -->
|
---|
| 15 |
|
---|
| 16 | <!-- What libc implentation must be used? -->
|
---|
| 17 | <xsl:param name="model" select="glibc"/>
|
---|
| 18 |
|
---|
| 19 | <!-- Is the host kernel using grsecurity? -->
|
---|
| 20 | <xsl:param name="grsecurity_host" select="0"/>
|
---|
| 21 |
|
---|
| 22 | <!-- Compile the keymap into the kernel? -->
|
---|
| 23 | <xsl:param name="keymap" select="none"/>
|
---|
| 24 |
|
---|
| 25 | <!-- Run test suites?
|
---|
| 26 | 0 = none
|
---|
| 27 | 1 = only chapter06 Glibc, GCC and Binutils testsuites
|
---|
| 28 | 2 = all chapter06 testsuites
|
---|
[d81c640] | 29 | 3 = alias to 2 -->
|
---|
[877cc6a] | 30 | <xsl:param name="testsuite" select="1"/>
|
---|
| 31 |
|
---|
| 32 | <!-- Time zone -->
|
---|
[a229600] | 33 | <xsl:param name="timezone" select="GMT"/>
|
---|
[877cc6a] | 34 |
|
---|
| 35 | <!-- Page size -->
|
---|
| 36 | <xsl:param name="page" select="letter"/>
|
---|
| 37 |
|
---|
| 38 | <!-- Locale settings -->
|
---|
[a229600] | 39 | <xsl:param name="lang" select="C"/>
|
---|
| 40 | <xsl:param name="lc_all" select="C"/>
|
---|
[877cc6a] | 41 |
|
---|
| 42 | <xsl:template match="/">
|
---|
| 43 | <xsl:apply-templates select="//sect1"/>
|
---|
| 44 | </xsl:template>
|
---|
| 45 |
|
---|
| 46 | <xsl:template match="sect1">
|
---|
| 47 | <xsl:if test="(../@id='chapter-temporary-tools' or
|
---|
| 48 | ../@id='chapter-building-system' or
|
---|
| 49 | ../@id='chapter-bootable') and
|
---|
| 50 | ((@condition=$model or not(@condition)) and
|
---|
| 51 | count(descendant::screen/userinput) > 0 and
|
---|
| 52 | count(descendant::screen/userinput) >
|
---|
| 53 | count(descendant::screen[@role='nodump']))">
|
---|
| 54 | <!-- The dirs names -->
|
---|
| 55 | <xsl:variable name="pi-dir" select="../processing-instruction('dbhtml')"/>
|
---|
| 56 | <xsl:variable name="pi-dir-value" select="substring-after($pi-dir,'dir=')"/>
|
---|
| 57 | <xsl:variable name="quote-dir" select="substring($pi-dir-value,1,1)"/>
|
---|
| 58 | <xsl:variable name="dirname" select="substring-before(substring($pi-dir-value,2),$quote-dir)"/>
|
---|
| 59 | <!-- The file names -->
|
---|
| 60 | <xsl:variable name="pi-file" select="processing-instruction('dbhtml')"/>
|
---|
| 61 | <xsl:variable name="pi-file-value" select="substring-after($pi-file,'filename=')"/>
|
---|
| 62 | <xsl:variable name="filename" select="substring-before(substring($pi-file-value,2),'.html')"/>
|
---|
| 63 | <!-- The build order -->
|
---|
| 64 | <xsl:variable name="position" select="position()"/>
|
---|
| 65 | <xsl:variable name="order">
|
---|
| 66 | <xsl:choose>
|
---|
| 67 | <xsl:when test="string-length($position) = 1">
|
---|
| 68 | <xsl:text>00</xsl:text>
|
---|
| 69 | <xsl:value-of select="$position"/>
|
---|
| 70 | </xsl:when>
|
---|
| 71 | <xsl:when test="string-length($position) = 2">
|
---|
| 72 | <xsl:text>0</xsl:text>
|
---|
| 73 | <xsl:value-of select="$position"/>
|
---|
| 74 | </xsl:when>
|
---|
| 75 | <xsl:otherwise>
|
---|
| 76 | <xsl:value-of select="$position"/>
|
---|
| 77 | </xsl:otherwise>
|
---|
| 78 | </xsl:choose>
|
---|
| 79 | </xsl:variable>
|
---|
| 80 | <!-- Creating dirs and files -->
|
---|
| 81 | <exsl:document href="{$dirname}/{$order}-{$filename}" method="text">
|
---|
| 82 | <xsl:choose>
|
---|
| 83 | <xsl:when test="@id='ch-system-changingowner' or
|
---|
| 84 | @id='ch-system-creatingdirs' or
|
---|
| 85 | @id='ch-system-createfiles'">
|
---|
| 86 | <xsl:text>#!/tools/bin/bash
set -e

</xsl:text>
|
---|
| 87 | </xsl:when>
|
---|
| 88 | <xsl:when test="@id='ch-tools-stripping' or
|
---|
| 89 | @id='ch-system-strippingagain'">
|
---|
| 90 | <xsl:text>#!/bin/sh
</xsl:text>
|
---|
| 91 | </xsl:when>
|
---|
| 92 | <xsl:otherwise>
|
---|
| 93 | <xsl:text>#!/bin/sh
set -e

</xsl:text>
|
---|
| 94 | </xsl:otherwise>
|
---|
| 95 | </xsl:choose>
|
---|
| 96 | <xsl:if test="(sect2[@role='installation'] and
|
---|
[d81c640] | 97 | not(@id='bootable-kernel'))">
|
---|
[877cc6a] | 98 | <xsl:text>cd $PKGDIR
</xsl:text>
|
---|
| 99 | <xsl:if test="@id='ch-tools-uclibc' or @id='ch-system-uclibc'">
|
---|
| 100 | <xsl:text>pushd ../; tar -xvf gettext-&gettext-version;.*; popd; 
</xsl:text>
|
---|
| 101 | </xsl:if>
|
---|
[d81c640] | 102 |
|
---|
| 103 | <!-- NEW toolchain format, from inside ./sources dir unpack binutils and gcc -->
|
---|
| 104 | <xsl:if test="@id='ch-tools-embryo-toolchain' or
|
---|
| 105 | @id='ch-tools-cocoon-toolchain' or
|
---|
| 106 | @id='ch-system-butterfly-toolchain'">
|
---|
| 107 | <xsl:text>tar -xvf gcc-core-&gcc-version;.*; 
</xsl:text>
|
---|
| 108 | <xsl:text>tar -xvf gcc-g++-&gcc-version;.*; 
</xsl:text>
|
---|
| 109 | <xsl:text>tar -xvf binutils-&binutils-version;.*; 
</xsl:text>
|
---|
[877cc6a] | 110 | </xsl:if>
|
---|
[d81c640] | 111 | <!-- ONLY butterfly has a testsuite -->
|
---|
[b2489fb] | 112 | <xsl:if test="@id='ch-system-butterfly-toolchain' and $testsuite != '0'">
|
---|
[d81c640] | 113 | <xsl:text>tar -xvf gcc-testsuite-&gcc-version;.*; 
</xsl:text>
|
---|
[877cc6a] | 114 | </xsl:if>
|
---|
[d81c640] | 115 | <!-- END new toolchain format -->
|
---|
| 116 |
|
---|
[877cc6a] | 117 | <xsl:if test="@id='bootable-bootscripts'">
|
---|
| 118 | <xsl:text>pushd ../; tar -xvf blfs-bootscripts-&blfs-bootscripts-version;.* ; popd; 
</xsl:text>
|
---|
| 119 | </xsl:if>
|
---|
| 120 | </xsl:if>
|
---|
| 121 | <xsl:apply-templates select=".//para/userinput | .//screen"/>
|
---|
| 122 | <xsl:text>exit</xsl:text>
|
---|
| 123 | </exsl:document>
|
---|
| 124 | </xsl:if>
|
---|
| 125 | </xsl:template>
|
---|
| 126 |
|
---|
| 127 | <xsl:template match="screen">
|
---|
| 128 | <xsl:if test="(@condition=$model or not(@condition)) and
|
---|
| 129 | child::* = userinput and not(@role = 'nodump')">
|
---|
| 130 | <xsl:apply-templates select="userinput" mode="screen"/>
|
---|
| 131 | </xsl:if>
|
---|
| 132 | </xsl:template>
|
---|
| 133 |
|
---|
| 134 | <xsl:template match="para/userinput">
|
---|
| 135 | <xsl:if test="(contains(string(),'test') or
|
---|
[d81c640] | 136 | contains(string(),'check')) and
|
---|
| 137 | ($testsuite = '2' or $testsuite = '3')">
|
---|
| 138 | <xsl:value-of select="substring-before(string(),'make')"/>
|
---|
| 139 | <xsl:text>make -k</xsl:text>
|
---|
| 140 | <xsl:value-of select="substring-after(string(),'make')"/>
|
---|
| 141 | <xsl:text> >> $TEST_LOG 2>&1 || true
</xsl:text>
|
---|
[877cc6a] | 142 | </xsl:if>
|
---|
| 143 | </xsl:template>
|
---|
| 144 |
|
---|
| 145 | <xsl:template match="userinput" mode="screen">
|
---|
| 146 | <xsl:choose>
|
---|
| 147 | <!-- Estandarized package formats -->
|
---|
| 148 | <xsl:when test="contains(string(),'tar.gz')">
|
---|
| 149 | <xsl:value-of select="substring-before(string(),'tar.gz')"/>
|
---|
| 150 | <xsl:text>tar.*</xsl:text>
|
---|
| 151 | <xsl:value-of select="substring-after(string(),'tar.gz')"/>
|
---|
| 152 | <xsl:text>
</xsl:text>
|
---|
| 153 | </xsl:when>
|
---|
| 154 | <!-- Avoiding a race condition in a patch -->
|
---|
| 155 | <xsl:when test="contains(string(),'debian_fixes')">
|
---|
| 156 | <xsl:value-of select="substring-before(string(),'patch')"/>
|
---|
| 157 | <xsl:text>patch -Z</xsl:text>
|
---|
| 158 | <xsl:value-of select="substring-after(string(),'patch')"/>
|
---|
| 159 | <xsl:text>
</xsl:text>
|
---|
| 160 | </xsl:when>
|
---|
| 161 | <!-- grsecurity kernel in the host? -->
|
---|
| 162 | <xsl:when test="ancestor::sect1[@id='ch-system-kernfs'] and
|
---|
| 163 | contains(string(),'sysctl')
|
---|
| 164 | and $grsecurity_host ='0'"/>
|
---|
| 165 | <!-- Setting $LC_ALL and $LANG for /etc/profile -->
|
---|
| 166 | <xsl:when test="ancestor::sect1[@id='bootable-profile'] and
|
---|
| 167 | contains(string(),'export LANG=')">
|
---|
| 168 | <xsl:value-of select="substring-before(string(),'export LC_ALL=')"/>
|
---|
| 169 | <xsl:text>export LC_ALL=</xsl:text>
|
---|
| 170 | <xsl:value-of select="$lc_all"/>
|
---|
| 171 | <xsl:text>
export LANG=</xsl:text>
|
---|
| 172 | <xsl:value-of select="$lang"/>
|
---|
| 173 | <xsl:text>
export INPUTRC</xsl:text>
|
---|
| 174 | <xsl:value-of select="substring-after(string(),'INPUTRC')"/>
|
---|
| 175 | <xsl:text>
</xsl:text>
|
---|
| 176 | </xsl:when>
|
---|
| 177 | <!-- Fixing bootscripts installation -->
|
---|
| 178 | <xsl:when test="ancestor::sect1[@id='bootable-bootscripts'] and
|
---|
| 179 | string() = 'make install'">
|
---|
| 180 | <xsl:text>make install
</xsl:text>
|
---|
| 181 | <xsl:text>cd ../blfs-bootscripts-&blfs-bootscripts-version;
</xsl:text>
|
---|
| 182 | </xsl:when>
|
---|
| 183 | <!-- Compile the keymap into the kernel? -->
|
---|
| 184 | <xsl:when test="contains(string(),'defkeymap') and
|
---|
| 185 | $keymap = 'none'"/>
|
---|
| 186 | <!-- Copying the kernel config file -->
|
---|
| 187 | <xsl:when test="string() = 'make mrproper'">
|
---|
| 188 | <xsl:text>make mrproper
</xsl:text>
|
---|
| 189 | <xsl:text>cp -v /sources/kernel-config .config
</xsl:text>
|
---|
| 190 | </xsl:when>
|
---|
| 191 | <!-- No interactive commands are needed if the .config file is the proper one -->
|
---|
| 192 | <xsl:when test="string() = 'make menuconfig'"/>
|
---|
| 193 | <!-- For uClibc we need to cd to the Gettext package -->
|
---|
| 194 | <xsl:when test="contains(string(),'cd gettext-runtime/')">
|
---|
| 195 | <xsl:text>cd ../gettext-*/gettext-runtime</xsl:text>
|
---|
| 196 | <xsl:value-of select="substring-after(string(),'gettext-runtime')"/>
|
---|
| 197 | <xsl:text>
</xsl:text>
|
---|
| 198 | </xsl:when>
|
---|
| 199 | <!-- The Coreutils and Module-Init-Tools test suites are optional -->
|
---|
[a229600] | 200 | <xsl:when test="(ancestor::sect1[@id='ch-system-coreutils'] or
|
---|
[877cc6a] | 201 | ancestor::sect1[@id='ch-system-module-init-tools']) and
|
---|
| 202 | (contains(string(),'check') or
|
---|
| 203 | contains(string(),'distclean') or
|
---|
[a229600] | 204 | contains(string(),'dummy'))">
|
---|
| 205 | <xsl:choose>
|
---|
| 206 | <xsl:when test="$testsuite = '0' or $testsuite = '1'"/>
|
---|
| 207 | <xsl:otherwise>
|
---|
| 208 | <xsl:apply-templates/>
|
---|
| 209 | <xsl:if test="contains(string(),'check')">
|
---|
| 210 | <xsl:text> >> $TEST_LOG 2>&1 || true</xsl:text>
|
---|
| 211 | </xsl:if>
|
---|
| 212 | <xsl:text>
</xsl:text>
|
---|
| 213 | </xsl:otherwise>
|
---|
| 214 | </xsl:choose>
|
---|
| 215 | </xsl:when>
|
---|
[d81c640] | 216 | <!-- Fixing butterfly toolchain test suites run -->
|
---|
| 217 | <xsl:when test="string() = 'make -k check'">
|
---|
[877cc6a] | 218 | <xsl:choose>
|
---|
[d81c640] | 219 | <xsl:when test="$testsuite != '0'">
|
---|
[a229600] | 220 | <xsl:text>make -k check >> $TEST_LOG 2>&1 || true
</xsl:text>
|
---|
[877cc6a] | 221 | </xsl:when>
|
---|
| 222 | </xsl:choose>
|
---|
| 223 | </xsl:when>
|
---|
[d81c640] | 224 | <!-- Fixing Glbc test suite -->
|
---|
| 225 | <xsl:when test="contains(string(),'glibc-check-log')">
|
---|
[877cc6a] | 226 | <xsl:choose>
|
---|
| 227 | <xsl:when test="$testsuite != '0'">
|
---|
[d81c640] | 228 | <xsl:value-of select="substring-before(string(),'> glibc-')"/>
|
---|
| 229 | <xsl:text>>> $TEST_LOG 2>&1 || true
</xsl:text>
|
---|
[877cc6a] | 230 | </xsl:when>
|
---|
| 231 | </xsl:choose>
|
---|
| 232 | </xsl:when>
|
---|
| 233 | <!-- Don't stop on strip run and chapter05 GCC installation test-->
|
---|
| 234 | <xsl:when test="contains(string(),'strip ') or
|
---|
| 235 | ancestor::sect2[@id='testing-gcc'] and
|
---|
| 236 | not(contains(string(),'EOF'))">
|
---|
| 237 | <xsl:apply-templates/>
|
---|
| 238 | <xsl:text> || true
</xsl:text>
|
---|
| 239 | </xsl:when>
|
---|
| 240 | <!-- The rest of commands -->
|
---|
| 241 | <xsl:otherwise>
|
---|
| 242 | <xsl:apply-templates/>
|
---|
| 243 | <xsl:text>
</xsl:text>
|
---|
| 244 | </xsl:otherwise>
|
---|
| 245 | </xsl:choose>
|
---|
| 246 | </xsl:template>
|
---|
| 247 |
|
---|
[d81c640] | 248 | <xsl:template match="literal">
|
---|
| 249 | <xsl:if test="@condition=$model or not(@condition)">
|
---|
| 250 | <xsl:apply-templates/>
|
---|
| 251 | </xsl:if>
|
---|
| 252 | </xsl:template>
|
---|
| 253 |
|
---|
[877cc6a] | 254 | <xsl:template match="replaceable">
|
---|
| 255 | <xsl:choose>
|
---|
| 256 | <xsl:when test="ancestor::sect1[@id='ch-system-glibc'] or
|
---|
| 257 | ancestor::sect1[@id='ch-system-uclibc']">
|
---|
| 258 | <xsl:value-of select="$timezone"/>
|
---|
| 259 | </xsl:when>
|
---|
| 260 | <xsl:when test="ancestor::sect1[@id='ch-system-groff']">
|
---|
| 261 | <xsl:value-of select="$page"/>
|
---|
| 262 | </xsl:when>
|
---|
| 263 | <xsl:when test="ancestor::sect1[@id='bootable-kernel']">
|
---|
| 264 | <xsl:value-of select="$keymap"/>
|
---|
| 265 | </xsl:when>
|
---|
| 266 | <xsl:otherwise>
|
---|
| 267 | <xsl:text>**EDITME</xsl:text>
|
---|
| 268 | <xsl:apply-templates/>
|
---|
| 269 | <xsl:text>EDITME**</xsl:text>
|
---|
| 270 | </xsl:otherwise>
|
---|
| 271 | </xsl:choose>
|
---|
| 272 | </xsl:template>
|
---|
| 273 |
|
---|
| 274 | </xsl:stylesheet>
|
---|