[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? -->
|
---|
[401f81e] | 20 | <xsl:param name="grsecurity_host" select="n"/>
|
---|
[877cc6a] | 21 |
|
---|
| 22 | <!-- Run test suites?
|
---|
| 23 | 0 = none
|
---|
| 24 | 1 = only chapter06 Glibc, GCC and Binutils testsuites
|
---|
| 25 | 2 = all chapter06 testsuites
|
---|
[28f4756] | 26 | 3 = alias to 2
|
---|
| 27 | -->
|
---|
[877cc6a] | 28 | <xsl:param name="testsuite" select="1"/>
|
---|
| 29 |
|
---|
[28f4756] | 30 | <!-- Bomb on test suites failures?
|
---|
[401f81e] | 31 | n = no, I want to build the full system and review the logs
|
---|
| 32 | y = yes, bomb at the first test suite failure to can review the build dir
|
---|
[28f4756] | 33 | -->
|
---|
[401f81e] | 34 | <xsl:param name="bomb-testsuite" select="n"/>
|
---|
[28f4756] | 35 |
|
---|
[877cc6a] | 36 | <!-- Time zone -->
|
---|
[a229600] | 37 | <xsl:param name="timezone" select="GMT"/>
|
---|
[877cc6a] | 38 |
|
---|
| 39 | <!-- Page size -->
|
---|
| 40 | <xsl:param name="page" select="letter"/>
|
---|
| 41 |
|
---|
| 42 | <!-- Locale settings -->
|
---|
[a229600] | 43 | <xsl:param name="lang" select="C"/>
|
---|
| 44 | <xsl:param name="lc_all" select="C"/>
|
---|
[877cc6a] | 45 |
|
---|
| 46 | <xsl:template match="/">
|
---|
| 47 | <xsl:apply-templates select="//sect1"/>
|
---|
| 48 | </xsl:template>
|
---|
| 49 |
|
---|
| 50 | <xsl:template match="sect1">
|
---|
| 51 | <xsl:if test="(../@id='chapter-temporary-tools' or
|
---|
| 52 | ../@id='chapter-building-system' or
|
---|
| 53 | ../@id='chapter-bootable') and
|
---|
| 54 | ((@condition=$model or not(@condition)) and
|
---|
| 55 | count(descendant::screen/userinput) > 0 and
|
---|
| 56 | count(descendant::screen/userinput) >
|
---|
| 57 | count(descendant::screen[@role='nodump']))">
|
---|
| 58 | <!-- The dirs names -->
|
---|
| 59 | <xsl:variable name="pi-dir" select="../processing-instruction('dbhtml')"/>
|
---|
| 60 | <xsl:variable name="pi-dir-value" select="substring-after($pi-dir,'dir=')"/>
|
---|
| 61 | <xsl:variable name="quote-dir" select="substring($pi-dir-value,1,1)"/>
|
---|
| 62 | <xsl:variable name="dirname" select="substring-before(substring($pi-dir-value,2),$quote-dir)"/>
|
---|
| 63 | <!-- The file names -->
|
---|
| 64 | <xsl:variable name="pi-file" select="processing-instruction('dbhtml')"/>
|
---|
| 65 | <xsl:variable name="pi-file-value" select="substring-after($pi-file,'filename=')"/>
|
---|
| 66 | <xsl:variable name="filename" select="substring-before(substring($pi-file-value,2),'.html')"/>
|
---|
| 67 | <!-- The build order -->
|
---|
| 68 | <xsl:variable name="position" select="position()"/>
|
---|
| 69 | <xsl:variable name="order">
|
---|
| 70 | <xsl:choose>
|
---|
| 71 | <xsl:when test="string-length($position) = 1">
|
---|
| 72 | <xsl:text>00</xsl:text>
|
---|
| 73 | <xsl:value-of select="$position"/>
|
---|
| 74 | </xsl:when>
|
---|
| 75 | <xsl:when test="string-length($position) = 2">
|
---|
| 76 | <xsl:text>0</xsl:text>
|
---|
| 77 | <xsl:value-of select="$position"/>
|
---|
| 78 | </xsl:when>
|
---|
| 79 | <xsl:otherwise>
|
---|
| 80 | <xsl:value-of select="$position"/>
|
---|
| 81 | </xsl:otherwise>
|
---|
| 82 | </xsl:choose>
|
---|
| 83 | </xsl:variable>
|
---|
| 84 | <!-- Creating dirs and files -->
|
---|
| 85 | <exsl:document href="{$dirname}/{$order}-{$filename}" method="text">
|
---|
[1330ebc] | 86 | <xsl:choose>
|
---|
| 87 | <xsl:when test="@id='ch-system-creatingdirs' or
|
---|
[7d6fe10] | 88 | @id='ch-system-createfiles' or
|
---|
| 89 | @id='ch-system-strippingagain'">
|
---|
[1330ebc] | 90 | <xsl:text>#!/tools/bin/bash
set +h
</xsl:text>
|
---|
| 91 | </xsl:when>
|
---|
| 92 | <xsl:otherwise>
|
---|
| 93 | <xsl:text>#!/bin/bash
set +h
</xsl:text>
|
---|
| 94 | </xsl:otherwise>
|
---|
| 95 | </xsl:choose>
|
---|
[5f4982d] | 96 | <xsl:if test="not(@id='ch-tools-stripping') and
|
---|
| 97 | not(@id='ch-system-strippingagain')">
|
---|
| 98 | <xsl:text>set -e
</xsl:text>
|
---|
| 99 | </xsl:if>
|
---|
| 100 | <xsl:text>
</xsl:text>
|
---|
[877cc6a] | 101 | <xsl:if test="(sect2[@role='installation'] and
|
---|
[d81c640] | 102 | not(@id='bootable-kernel'))">
|
---|
[877cc6a] | 103 | <xsl:text>cd $PKGDIR
</xsl:text>
|
---|
[5e83595] | 104 | <xsl:if test="@id='ch-system-uclibc'">
|
---|
[877cc6a] | 105 | <xsl:text>pushd ../; tar -xvf gettext-&gettext-version;.*; popd; 
</xsl:text>
|
---|
| 106 | </xsl:if>
|
---|
[d81c640] | 107 |
|
---|
[4d15d7f] | 108 | <!-- SVN toolchain format, from inside ./sources dir unpack binutils and gcc -->
|
---|
[d81c640] | 109 | <xsl:if test="@id='ch-tools-embryo-toolchain' or
|
---|
| 110 | @id='ch-tools-cocoon-toolchain' or
|
---|
| 111 | @id='ch-system-butterfly-toolchain'">
|
---|
| 112 | <xsl:text>tar -xvf gcc-core-&gcc-version;.*; 
</xsl:text>
|
---|
| 113 | <xsl:text>tar -xvf binutils-&binutils-version;.*; 
</xsl:text>
|
---|
[877cc6a] | 114 | </xsl:if>
|
---|
[30d1215] | 115 | <xsl:if test="@id='ch-tools-cocoon-toolchain' or
|
---|
| 116 | @id='ch-system-butterfly-toolchain'">
|
---|
| 117 | <xsl:text>tar -xvf gcc-g++-&gcc-version;.*; 
</xsl:text>
|
---|
| 118 | </xsl:if>
|
---|
[d81c640] | 119 | <!-- ONLY butterfly has a testsuite -->
|
---|
[b2489fb] | 120 | <xsl:if test="@id='ch-system-butterfly-toolchain' and $testsuite != '0'">
|
---|
[d81c640] | 121 | <xsl:text>tar -xvf gcc-testsuite-&gcc-version;.*; 
</xsl:text>
|
---|
[877cc6a] | 122 | </xsl:if>
|
---|
[4d15d7f] | 123 | <!-- END SVN toolchain format -->
|
---|
| 124 |
|
---|
| 125 | <!-- 2.4-branch toolchain -->
|
---|
| 126 | <xsl:if test="@id='ch-tools-gcc-pass2' or @id='ch-system-gcc'">
|
---|
| 127 | <xsl:text>pushd ../; tar -xvf gcc-g++-&gcc-version;.*; popd; 
</xsl:text>
|
---|
| 128 | </xsl:if>
|
---|
| 129 | <xsl:if test="@id='ch-system-gcc' and $testsuite != '0'">
|
---|
| 130 | <xsl:text>pushd ../; tar -xvf gcc-testsuite-&gcc-version;.*; popd; 
</xsl:text>
|
---|
| 131 | </xsl:if>
|
---|
| 132 | <!-- END 2.4-branch toolchain -->
|
---|
[d81c640] | 133 |
|
---|
[877cc6a] | 134 | <xsl:if test="@id='bootable-bootscripts'">
|
---|
| 135 | <xsl:text>pushd ../; tar -xvf blfs-bootscripts-&blfs-bootscripts-version;.* ; popd; 
</xsl:text>
|
---|
| 136 | </xsl:if>
|
---|
| 137 | </xsl:if>
|
---|
| 138 | <xsl:apply-templates select=".//para/userinput | .//screen"/>
|
---|
| 139 | <xsl:text>exit</xsl:text>
|
---|
| 140 | </exsl:document>
|
---|
| 141 | </xsl:if>
|
---|
| 142 | </xsl:template>
|
---|
| 143 |
|
---|
| 144 | <xsl:template match="screen">
|
---|
| 145 | <xsl:if test="(@condition=$model or not(@condition)) and
|
---|
| 146 | child::* = userinput and not(@role = 'nodump')">
|
---|
| 147 | <xsl:apply-templates select="userinput" mode="screen"/>
|
---|
| 148 | </xsl:if>
|
---|
| 149 | </xsl:template>
|
---|
| 150 |
|
---|
| 151 | <xsl:template match="para/userinput">
|
---|
| 152 | <xsl:if test="(contains(string(),'test') or
|
---|
[d81c640] | 153 | contains(string(),'check')) and
|
---|
| 154 | ($testsuite = '2' or $testsuite = '3')">
|
---|
[28f4756] | 155 | <xsl:choose>
|
---|
[401f81e] | 156 | <xsl:when test="$bomb-testsuite = 'n'">
|
---|
[28f4756] | 157 | <xsl:value-of select="substring-before(string(),'make')"/>
|
---|
| 158 | <xsl:text>make -k</xsl:text>
|
---|
| 159 | <xsl:value-of select="substring-after(string(),'make')"/>
|
---|
| 160 | <xsl:text> >> $TEST_LOG 2>&1 || true
</xsl:text>
|
---|
| 161 | </xsl:when>
|
---|
| 162 | <xsl:otherwise>
|
---|
| 163 | <xsl:apply-templates/>
|
---|
[a1f1969] | 164 | <xsl:text> >> $TEST_LOG 2>&1</xsl:text>
|
---|
| 165 | <xsl:if test="contains(string(),' -k ')">
|
---|
| 166 | <xsl:text> || true</xsl:text>
|
---|
| 167 | </xsl:if>
|
---|
| 168 | <xsl:text>
</xsl:text>
|
---|
[28f4756] | 169 | </xsl:otherwise>
|
---|
| 170 | </xsl:choose>
|
---|
[877cc6a] | 171 | </xsl:if>
|
---|
| 172 | </xsl:template>
|
---|
| 173 |
|
---|
| 174 | <xsl:template match="userinput" mode="screen">
|
---|
| 175 | <xsl:choose>
|
---|
| 176 | <!-- Estandarized package formats -->
|
---|
| 177 | <xsl:when test="contains(string(),'tar.gz')">
|
---|
| 178 | <xsl:value-of select="substring-before(string(),'tar.gz')"/>
|
---|
| 179 | <xsl:text>tar.*</xsl:text>
|
---|
| 180 | <xsl:value-of select="substring-after(string(),'tar.gz')"/>
|
---|
| 181 | <xsl:text>
</xsl:text>
|
---|
| 182 | </xsl:when>
|
---|
| 183 | <!-- grsecurity kernel in the host? -->
|
---|
| 184 | <xsl:when test="ancestor::sect1[@id='ch-system-kernfs'] and
|
---|
| 185 | contains(string(),'sysctl')
|
---|
[401f81e] | 186 | and $grsecurity_host ='n'"/>
|
---|
[37002ae] | 187 | <!-- We need to have /dev/console and /dev/null availables before
|
---|
| 188 | entering to the chroot -->
|
---|
| 189 | <xsl:when test="ancestor::sect1[@id='ch-system-devices'] and
|
---|
| 190 | contains(string(),'600 /dev/console')"/>
|
---|
[4d15d7f] | 191 | <!-- Fix MAKEDEV installation in 2.4-branch -->
|
---|
| 192 | <xsl:when test="ancestor::sect1[@id='ch-system-devices'] and
|
---|
| 193 | contains(string(),'bzcat MAKEDEV')">
|
---|
| 194 | <xsl:text>bzcat /sources/</xsl:text>
|
---|
| 195 | <xsl:value-of select="substring-after(string(),'bzcat ')"/>
|
---|
| 196 | <xsl:text>
</xsl:text>
|
---|
| 197 | </xsl:when>
|
---|
[877cc6a] | 198 | <!-- Setting $LC_ALL and $LANG for /etc/profile -->
|
---|
| 199 | <xsl:when test="ancestor::sect1[@id='bootable-profile'] and
|
---|
| 200 | contains(string(),'export LANG=')">
|
---|
| 201 | <xsl:value-of select="substring-before(string(),'export LC_ALL=')"/>
|
---|
| 202 | <xsl:text>export LC_ALL=</xsl:text>
|
---|
| 203 | <xsl:value-of select="$lc_all"/>
|
---|
| 204 | <xsl:text>
export LANG=</xsl:text>
|
---|
| 205 | <xsl:value-of select="$lang"/>
|
---|
| 206 | <xsl:text>
export INPUTRC</xsl:text>
|
---|
| 207 | <xsl:value-of select="substring-after(string(),'INPUTRC')"/>
|
---|
| 208 | <xsl:text>
</xsl:text>
|
---|
| 209 | </xsl:when>
|
---|
| 210 | <!-- Fixing bootscripts installation -->
|
---|
| 211 | <xsl:when test="ancestor::sect1[@id='bootable-bootscripts'] and
|
---|
| 212 | string() = 'make install'">
|
---|
| 213 | <xsl:text>make install
</xsl:text>
|
---|
| 214 | <xsl:text>cd ../blfs-bootscripts-&blfs-bootscripts-version;
</xsl:text>
|
---|
| 215 | </xsl:when>
|
---|
[f4caf9c] | 216 | <!-- Compile the keymap into the kernel has been dissabled -->
|
---|
| 217 | <xsl:when test="contains(string(),'defkeymap')"/>
|
---|
[877cc6a] | 218 | <!-- Copying the kernel config file -->
|
---|
| 219 | <xsl:when test="string() = 'make mrproper'">
|
---|
| 220 | <xsl:text>make mrproper
</xsl:text>
|
---|
| 221 | <xsl:text>cp -v /sources/kernel-config .config
</xsl:text>
|
---|
| 222 | </xsl:when>
|
---|
| 223 | <!-- No interactive commands are needed if the .config file is the proper one -->
|
---|
| 224 | <xsl:when test="string() = 'make menuconfig'"/>
|
---|
| 225 | <!-- For uClibc we need to cd to the Gettext package -->
|
---|
| 226 | <xsl:when test="contains(string(),'cd gettext-runtime/')">
|
---|
| 227 | <xsl:text>cd ../gettext-*/gettext-runtime</xsl:text>
|
---|
| 228 | <xsl:value-of select="substring-after(string(),'gettext-runtime')"/>
|
---|
| 229 | <xsl:text>
</xsl:text>
|
---|
| 230 | </xsl:when>
|
---|
| 231 | <!-- The Coreutils and Module-Init-Tools test suites are optional -->
|
---|
[a229600] | 232 | <xsl:when test="(ancestor::sect1[@id='ch-system-coreutils'] or
|
---|
[877cc6a] | 233 | ancestor::sect1[@id='ch-system-module-init-tools']) and
|
---|
| 234 | (contains(string(),'check') or
|
---|
| 235 | contains(string(),'distclean') or
|
---|
[a229600] | 236 | contains(string(),'dummy'))">
|
---|
| 237 | <xsl:choose>
|
---|
| 238 | <xsl:when test="$testsuite = '0' or $testsuite = '1'"/>
|
---|
| 239 | <xsl:otherwise>
|
---|
[28f4756] | 240 | <xsl:if test="not(contains(string(),'check'))">
|
---|
| 241 | <xsl:apply-templates/>
|
---|
| 242 | <xsl:text>
</xsl:text>
|
---|
| 243 | </xsl:if>
|
---|
[a229600] | 244 | <xsl:if test="contains(string(),'check')">
|
---|
[28f4756] | 245 | <xsl:choose>
|
---|
[401f81e] | 246 | <xsl:when test="$bomb-testsuite = 'n'">
|
---|
[28f4756] | 247 | <xsl:value-of select="substring-before(string(),'check')"/>
|
---|
| 248 | <xsl:text>-k check</xsl:text>
|
---|
| 249 | <xsl:value-of select="substring-after(string(),'check')"/>
|
---|
| 250 | <xsl:text> >> $TEST_LOG 2>&1 || true
</xsl:text>
|
---|
| 251 | </xsl:when>
|
---|
| 252 | <xsl:otherwise>
|
---|
| 253 | <xsl:apply-templates/>
|
---|
[a1f1969] | 254 | <xsl:text> >> $TEST_LOG 2>&1</xsl:text>
|
---|
| 255 | <xsl:if test="contains(string(),' -k ')">
|
---|
| 256 | <xsl:text> || true</xsl:text>
|
---|
| 257 | </xsl:if>
|
---|
| 258 | <xsl:text>
</xsl:text>
|
---|
[28f4756] | 259 | </xsl:otherwise>
|
---|
| 260 | </xsl:choose>
|
---|
[a229600] | 261 | </xsl:if>
|
---|
| 262 | </xsl:otherwise>
|
---|
| 263 | </xsl:choose>
|
---|
| 264 | </xsl:when>
|
---|
[4d15d7f] | 265 | <!-- Fixing butterfly and 2.4-branch toolchain plus other packages test suites run -->
|
---|
[ff43bb8] | 266 | <xsl:when test="string() = 'make -k check'
|
---|
| 267 | or string() = 'make check'
|
---|
| 268 | or string() = 'make tests'">
|
---|
[877cc6a] | 269 | <xsl:choose>
|
---|
[4d15d7f] | 270 | <xsl:when test="((ancestor::sect1[@id='ch-system-butterfly-toolchain']
|
---|
| 271 | or ancestor::sect1[@id='ch-system-gcc'] or
|
---|
| 272 | ancestor::sect1[@id='ch-system-binutils'])
|
---|
[ff43bb8] | 273 | and $testsuite != '0') or
|
---|
| 274 | $testsuite = '2' or $testsuite = '3'">
|
---|
[28f4756] | 275 | <xsl:choose>
|
---|
[401f81e] | 276 | <xsl:when test="$bomb-testsuite = 'n'">
|
---|
[ff43bb8] | 277 | <xsl:text>make -k check >> $TEST_LOG 2>&1 || true
</xsl:text>
|
---|
[28f4756] | 278 | </xsl:when>
|
---|
| 279 | <xsl:otherwise>
|
---|
[ff43bb8] | 280 | <xsl:apply-templates/>
|
---|
[f98695c] | 281 | <xsl:text> >> $TEST_LOG 2>&1</xsl:text>
|
---|
[a1f1969] | 282 | <xsl:if test="contains(string(),' -k ')">
|
---|
| 283 | <xsl:text> || true</xsl:text>
|
---|
| 284 | </xsl:if>
|
---|
[f98695c] | 285 | <xsl:text>
</xsl:text>
|
---|
[28f4756] | 286 | </xsl:otherwise>
|
---|
| 287 | </xsl:choose>
|
---|
[877cc6a] | 288 | </xsl:when>
|
---|
| 289 | </xsl:choose>
|
---|
| 290 | </xsl:when>
|
---|
[d81c640] | 291 | <!-- Fixing Glbc test suite -->
|
---|
| 292 | <xsl:when test="contains(string(),'glibc-check-log')">
|
---|
[877cc6a] | 293 | <xsl:choose>
|
---|
| 294 | <xsl:when test="$testsuite != '0'">
|
---|
[ff43bb8] | 295 | <xsl:value-of select="substring-before(string(),'2>&1')"/>
|
---|
| 296 | <xsl:text>>> $TEST_LOG 2>&1 || true
</xsl:text>
|
---|
[877cc6a] | 297 | </xsl:when>
|
---|
| 298 | </xsl:choose>
|
---|
| 299 | </xsl:when>
|
---|
[ff43bb8] | 300 | <!-- Don't stop on strip run -->
|
---|
[85077e7] | 301 | <xsl:when test="contains(string(),'strip ')">
|
---|
[877cc6a] | 302 | <xsl:apply-templates/>
|
---|
| 303 | <xsl:text> || true
</xsl:text>
|
---|
| 304 | </xsl:when>
|
---|
| 305 | <!-- The rest of commands -->
|
---|
| 306 | <xsl:otherwise>
|
---|
| 307 | <xsl:apply-templates/>
|
---|
| 308 | <xsl:text>
</xsl:text>
|
---|
| 309 | </xsl:otherwise>
|
---|
| 310 | </xsl:choose>
|
---|
| 311 | </xsl:template>
|
---|
| 312 |
|
---|
[d81c640] | 313 | <xsl:template match="literal">
|
---|
| 314 | <xsl:if test="@condition=$model or not(@condition)">
|
---|
| 315 | <xsl:apply-templates/>
|
---|
| 316 | </xsl:if>
|
---|
| 317 | </xsl:template>
|
---|
| 318 |
|
---|
[877cc6a] | 319 | <xsl:template match="replaceable">
|
---|
| 320 | <xsl:choose>
|
---|
| 321 | <xsl:when test="ancestor::sect1[@id='ch-system-glibc'] or
|
---|
| 322 | ancestor::sect1[@id='ch-system-uclibc']">
|
---|
| 323 | <xsl:value-of select="$timezone"/>
|
---|
| 324 | </xsl:when>
|
---|
| 325 | <xsl:when test="ancestor::sect1[@id='ch-system-groff']">
|
---|
| 326 | <xsl:value-of select="$page"/>
|
---|
| 327 | </xsl:when>
|
---|
| 328 | <xsl:otherwise>
|
---|
| 329 | <xsl:text>**EDITME</xsl:text>
|
---|
| 330 | <xsl:apply-templates/>
|
---|
| 331 | <xsl:text>EDITME**</xsl:text>
|
---|
| 332 | </xsl:otherwise>
|
---|
| 333 | </xsl:choose>
|
---|
| 334 | </xsl:template>
|
---|
| 335 |
|
---|
| 336 | </xsl:stylesheet>
|
---|