[0170229] | 1 | <?xml version="1.0"?>
|
---|
| 2 | <!DOCTYPE xsl:stylesheet [
|
---|
| 3 | <!ENTITY % general-entities SYSTEM "FAKEDIR/general.ent">
|
---|
| 4 | %general-entities;
|
---|
| 5 | ]>
|
---|
| 6 |
|
---|
[174a8e9] | 7 | <!-- $Id$ -->
|
---|
| 8 |
|
---|
[0170229] | 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 |
|
---|
[174a8e9] | 14 | <!-- XSLT stylesheet to create shell scripts from HLFS books. -->
|
---|
[0170229] | 15 |
|
---|
[174a8e9] | 16 | <!-- What libc implentation must be used? -->
|
---|
| 17 | <xsl:param name="model" select="glibc"/>
|
---|
[0170229] | 18 |
|
---|
[d540567] | 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 |
|
---|
[174a8e9] | 25 | <!-- Run test suites?
|
---|
| 26 | 0 = none
|
---|
| 27 | 1 = only chapter06 Glibc, GCC and Binutils testsuites
|
---|
| 28 | 2 = all chapter06 testsuites
|
---|
| 29 | 3 = all chapter05 and chapter06 testsuites-->
|
---|
| 30 | <xsl:param name="testsuite" select="1"/>
|
---|
[0170229] | 31 |
|
---|
| 32 | <xsl:template match="/">
|
---|
| 33 | <xsl:apply-templates select="//sect1"/>
|
---|
| 34 | </xsl:template>
|
---|
| 35 |
|
---|
| 36 | <xsl:template match="sect1">
|
---|
[174a8e9] | 37 | <xsl:if test="(../@id='chapter-temporary-tools' or
|
---|
| 38 | ../@id='chapter-building-system' or
|
---|
| 39 | ../@id='chapter-bootable') and
|
---|
| 40 | ((@condition=$model or not(@condition)) and
|
---|
| 41 | count(descendant::screen/userinput) > 0 and
|
---|
| 42 | count(descendant::screen/userinput) >
|
---|
| 43 | count(descendant::screen[@role='nodump']))">
|
---|
[0170229] | 44 | <!-- The dirs names -->
|
---|
| 45 | <xsl:variable name="pi-dir" select="../processing-instruction('dbhtml')"/>
|
---|
| 46 | <xsl:variable name="pi-dir-value" select="substring-after($pi-dir,'dir=')"/>
|
---|
| 47 | <xsl:variable name="quote-dir" select="substring($pi-dir-value,1,1)"/>
|
---|
| 48 | <xsl:variable name="dirname" select="substring-before(substring($pi-dir-value,2),$quote-dir)"/>
|
---|
| 49 | <!-- The file names -->
|
---|
| 50 | <xsl:variable name="pi-file" select="processing-instruction('dbhtml')"/>
|
---|
| 51 | <xsl:variable name="pi-file-value" select="substring-after($pi-file,'filename=')"/>
|
---|
| 52 | <xsl:variable name="filename" select="substring-before(substring($pi-file-value,2),'.html')"/>
|
---|
| 53 | <!-- The build order -->
|
---|
| 54 | <xsl:variable name="position" select="position()"/>
|
---|
| 55 | <xsl:variable name="order">
|
---|
| 56 | <xsl:choose>
|
---|
| 57 | <xsl:when test="string-length($position) = 1">
|
---|
| 58 | <xsl:text>00</xsl:text>
|
---|
| 59 | <xsl:value-of select="$position"/>
|
---|
| 60 | </xsl:when>
|
---|
| 61 | <xsl:when test="string-length($position) = 2">
|
---|
| 62 | <xsl:text>0</xsl:text>
|
---|
| 63 | <xsl:value-of select="$position"/>
|
---|
| 64 | </xsl:when>
|
---|
| 65 | <xsl:otherwise>
|
---|
| 66 | <xsl:value-of select="$position"/>
|
---|
| 67 | </xsl:otherwise>
|
---|
| 68 | </xsl:choose>
|
---|
| 69 | </xsl:variable>
|
---|
| 70 | <!-- Creating dirs and files -->
|
---|
| 71 | <exsl:document href="{$dirname}/{$order}-{$filename}" method="text">
|
---|
| 72 | <xsl:choose>
|
---|
| 73 | <xsl:when test="@id='ch-system-changingowner' or
|
---|
[174a8e9] | 74 | @id='ch-system-creatingdirs' or
|
---|
| 75 | @id='ch-system-createfiles'">
|
---|
[0170229] | 76 | <xsl:text>#!/tools/bin/bash
set -e

</xsl:text>
|
---|
| 77 | </xsl:when>
|
---|
| 78 | <xsl:when test="@id='ch-tools-stripping' or
|
---|
[174a8e9] | 79 | @id='ch-system-strippingagain'">
|
---|
[0170229] | 80 | <xsl:text>#!/bin/sh
</xsl:text>
|
---|
| 81 | </xsl:when>
|
---|
| 82 | <xsl:otherwise>
|
---|
| 83 | <xsl:text>#!/bin/sh
set -e

</xsl:text>
|
---|
| 84 | </xsl:otherwise>
|
---|
| 85 | </xsl:choose>
|
---|
[d540567] | 86 | <xsl:if test="(sect2[@role='installation'] and
|
---|
| 87 | not(@id='bootable-kernel')) or
|
---|
[0170229] | 88 | @id='ch-tools-adjusting' or
|
---|
| 89 | @id='ch-system-readjusting'">
|
---|
| 90 | <xsl:text>cd $PKGDIR
</xsl:text>
|
---|
[174a8e9] | 91 | <xsl:if test="@id='ch-tools-uclibc' or @id='ch-system-uclibc'">
|
---|
[0170229] | 92 | <xsl:text>pushd ../; tar -xvf gettext-&gettext-version;.*; popd; 
</xsl:text>
|
---|
| 93 | </xsl:if>
|
---|
[174a8e9] | 94 | <xsl:if test="@id='ch-tools-glibc' or @id='ch-system-glibc'">
|
---|
[0170229] | 95 | <xsl:text>tar -xvf ../glibc-libidn-&glibc-version;.*
</xsl:text>
|
---|
| 96 | </xsl:if>
|
---|
[174a8e9] | 97 | <xsl:if test="@id='ch-tools-gcc' or @id='ch-system-gcc'">
|
---|
[0170229] | 98 | <xsl:text>pushd ../; tar -xvf gcc-g++-&gcc-version;.*; popd; 
</xsl:text>
|
---|
| 99 | </xsl:if>
|
---|
[174a8e9] | 100 | <xsl:if test="@id='ch-tools-gcc' and $testsuite = '3'">
|
---|
| 101 | <xsl:text>pushd ../; tar -xvf gcc-testsuite-&gcc-version;.*; popd; 
</xsl:text>
|
---|
| 102 | </xsl:if>
|
---|
| 103 | <xsl:if test="@id='ch-system-gcc' and $testsuite != '0'">
|
---|
| 104 | <xsl:text>pushd ../; tar -xvf gcc-testsuite-&gcc-version;.*; popd; 
</xsl:text>
|
---|
[0170229] | 105 | </xsl:if>
|
---|
| 106 | <xsl:if test="@id='bootable-bootscripts'">
|
---|
| 107 | <xsl:text>pushd ../; tar -xvf blfs-bootscripts-&blfs-bootscripts-version;.* ; popd; 
</xsl:text>
|
---|
| 108 | </xsl:if>
|
---|
| 109 | </xsl:if>
|
---|
| 110 | <xsl:apply-templates select=".//para/userinput | .//screen"/>
|
---|
| 111 | <xsl:text>exit</xsl:text>
|
---|
| 112 | </exsl:document>
|
---|
| 113 | </xsl:if>
|
---|
| 114 | </xsl:template>
|
---|
| 115 |
|
---|
| 116 | <xsl:template match="screen">
|
---|
[174a8e9] | 117 | <xsl:if test="(@condition=$model or not(@condition)) and
|
---|
| 118 | child::* = userinput and not(@role = 'nodump')">
|
---|
| 119 | <xsl:apply-templates select="userinput" mode="screen"/>
|
---|
[0170229] | 120 | </xsl:if>
|
---|
| 121 | </xsl:template>
|
---|
| 122 |
|
---|
| 123 | <xsl:template match="para/userinput">
|
---|
[174a8e9] | 124 | <xsl:if test="(contains(string(),'test') or
|
---|
| 125 | contains(string(),'check')) and
|
---|
| 126 | (($testsuite = '1' and
|
---|
| 127 | (ancestor::sect1[@id='ch-system-gcc'] or
|
---|
| 128 | ancestor::sect1[@id='ch-system-glibc'])) or
|
---|
| 129 | ($testsuite = '2' and
|
---|
| 130 | ancestor::chapter[@id='chapter-building-system']) or
|
---|
| 131 | $testsuite = '3')">
|
---|
[1f89002] | 132 | <xsl:choose>
|
---|
| 133 | <xsl:when test="ancestor::sect1[@id='ch-system-gcc']">
|
---|
| 134 | <xsl:text>make -k check || true
</xsl:text>
|
---|
| 135 | </xsl:when>
|
---|
| 136 | <xsl:otherwise>
|
---|
| 137 | <xsl:value-of select="substring-before(string(),'make')"/>
|
---|
| 138 | <xsl:text>make -k</xsl:text>
|
---|
| 139 | <xsl:value-of select="substring-after(string(),'make')"/>
|
---|
| 140 | <xsl:text> || true
</xsl:text>
|
---|
| 141 | </xsl:otherwise>
|
---|
| 142 | </xsl:choose>
|
---|
[0170229] | 143 | </xsl:if>
|
---|
| 144 | </xsl:template>
|
---|
| 145 |
|
---|
| 146 | <xsl:template match="userinput" mode="screen">
|
---|
| 147 | <xsl:choose>
|
---|
| 148 | <!-- Estandarized package formats -->
|
---|
| 149 | <xsl:when test="contains(string(),'tar.gz')">
|
---|
| 150 | <xsl:value-of select="substring-before(string(),'tar.gz')"/>
|
---|
| 151 | <xsl:text>tar.*</xsl:text>
|
---|
| 152 | <xsl:value-of select="substring-after(string(),'tar.gz')"/>
|
---|
| 153 | <xsl:text>
</xsl:text>
|
---|
| 154 | </xsl:when>
|
---|
| 155 | <!-- Avoiding a race condition in a patch -->
|
---|
| 156 | <xsl:when test="contains(string(),'debian_fixes')">
|
---|
| 157 | <xsl:value-of select="substring-before(string(),'patch')"/>
|
---|
| 158 | <xsl:text>patch -Z</xsl:text>
|
---|
| 159 | <xsl:value-of select="substring-after(string(),'patch')"/>
|
---|
| 160 | <xsl:text>
</xsl:text>
|
---|
| 161 | </xsl:when>
|
---|
[d540567] | 162 | <!-- grsecurity kernel in the host? -->
|
---|
| 163 | <xsl:when test="ancestor::sect1[@id='ch-system-kernfs'] and
|
---|
| 164 | contains(string(),'sysctl')
|
---|
| 165 | and $grsecurity_host ='0'"/>
|
---|
[174a8e9] | 166 | <!-- Setting $LC_ALL and $LANG for /etc/profile -->
|
---|
| 167 | <xsl:when test="ancestor::sect1[@id='bootable-profile'] and
|
---|
| 168 | contains(string(),'export LANG=')">
|
---|
| 169 | <xsl:value-of select="substring-before(string(),'export LC_ALL=')"/>
|
---|
| 170 | <xsl:text>export LC_ALL=$LC_ALL
export LANG=$LANG
</xsl:text>
|
---|
| 171 | <xsl:text>export INPUTRC</xsl:text>
|
---|
| 172 | <xsl:value-of select="substring-after(string(),'INPUTRC')"/>
|
---|
| 173 | <xsl:text>
</xsl:text>
|
---|
| 174 | </xsl:when>
|
---|
[d540567] | 175 | <!-- Fixing bootscripts installation -->
|
---|
| 176 | <xsl:when test="ancestor::sect1[@id='bootable-bootscripts'] and
|
---|
| 177 | string() = 'make install'">
|
---|
| 178 | <xsl:text>make install
</xsl:text>
|
---|
| 179 | <xsl:text>cd ../blfs-bootscripts-&blfs-bootscripts-version;
</xsl:text>
|
---|
| 180 | </xsl:when>
|
---|
| 181 | <!-- Compile the keymap into the kernel? -->
|
---|
| 182 | <xsl:when test="contains(string(),'defkeymap') and
|
---|
| 183 | $keymap = 'none'"/>
|
---|
[0170229] | 184 | <!-- Copying the kernel config file -->
|
---|
| 185 | <xsl:when test="string() = 'make mrproper'">
|
---|
| 186 | <xsl:text>make mrproper
</xsl:text>
|
---|
| 187 | <xsl:text>cp -v /sources/kernel-config .config
</xsl:text>
|
---|
| 188 | </xsl:when>
|
---|
| 189 | <!-- The Coreutils and Module-Init-Tools test suites are optional -->
|
---|
[174a8e9] | 190 | <xsl:when test="($testsuite = '0' or $testsuite = '1') and
|
---|
[0170229] | 191 | (ancestor::sect1[@id='ch-system-coreutils'] or
|
---|
[174a8e9] | 192 | ancestor::sect1[@id='ch-system-module-init-tools']) and
|
---|
[0170229] | 193 | (contains(string(),'check') or
|
---|
[174a8e9] | 194 | contains(string(),'distclean') or
|
---|
| 195 | contains(string(),'dummy'))"/>
|
---|
[0170229] | 196 | <!-- Fixing toolchain test suites run -->
|
---|
| 197 | <xsl:when test="string() = 'make check' or
|
---|
[174a8e9] | 198 | string() = 'make -k check'">
|
---|
[0170229] | 199 | <xsl:choose>
|
---|
[174a8e9] | 200 | <xsl:when test="(($testsuite = '1' or $testsuite = '2') and
|
---|
| 201 | ancestor::chapter[@id='chapter-building-system']) or
|
---|
| 202 | $testsuite = '3'">
|
---|
[0170229] | 203 | <xsl:text>make -k check || true</xsl:text>
|
---|
| 204 | <xsl:text>
</xsl:text>
|
---|
[174a8e9] | 205 | </xsl:when>
|
---|
[0170229] | 206 | </xsl:choose>
|
---|
| 207 | </xsl:when>
|
---|
[174a8e9] | 208 | <xsl:when test="contains(string(),'make check') and
|
---|
| 209 | ancestor::sect1[@id='ch-system-binutils']">
|
---|
[0170229] | 210 | <xsl:choose>
|
---|
[174a8e9] | 211 | <xsl:when test="$testsuite != '0'">
|
---|
| 212 | <xsl:value-of select="substring-before(string(),'make check')"/>
|
---|
| 213 | <xsl:text>make -k check || true
</xsl:text>
|
---|
| 214 | </xsl:when>
|
---|
[0170229] | 215 | </xsl:choose>
|
---|
| 216 | </xsl:when>
|
---|
[1f89002] | 217 | <xsl:when test="contains(string(),'hardened-specs') and
|
---|
| 218 | ancestor::sect1[@id='ch-system-binutils']
|
---|
| 219 | and $testsuite = '0'"/>
|
---|
[d540567] | 220 | <!-- Don't stop on strip run and chapter05 GCC installation test-->
|
---|
| 221 | <xsl:when test="contains(string(),'strip ') or
|
---|
| 222 | ancestor::sect2[@id='testing-gcc']">
|
---|
[0170229] | 223 | <xsl:apply-templates/>
|
---|
| 224 | <xsl:text> || true
</xsl:text>
|
---|
| 225 | </xsl:when>
|
---|
| 226 | <!-- The rest of commands -->
|
---|
| 227 | <xsl:otherwise>
|
---|
| 228 | <xsl:apply-templates/>
|
---|
| 229 | <xsl:text>
</xsl:text>
|
---|
| 230 | </xsl:otherwise>
|
---|
| 231 | </xsl:choose>
|
---|
| 232 | </xsl:template>
|
---|
| 233 |
|
---|
| 234 | <xsl:template match="replaceable">
|
---|
| 235 | <xsl:choose>
|
---|
[174a8e9] | 236 | <xsl:when test="ancestor::sect1[@id='ch-system-glibc'] or
|
---|
| 237 | ancestor::sect1[@id='ch-system-uclibc']">
|
---|
[0170229] | 238 | <xsl:text>$TIMEZONE</xsl:text>
|
---|
| 239 | </xsl:when>
|
---|
| 240 | <xsl:when test="ancestor::sect1[@id='ch-system-groff']">
|
---|
| 241 | <xsl:text>$PAGE</xsl:text>
|
---|
| 242 | </xsl:when>
|
---|
[d540567] | 243 | <xsl:when test="ancestor::sect1[@id='bootable-kernel']">
|
---|
| 244 | <xsl:value-of select="$keymap"/>
|
---|
| 245 | </xsl:when>
|
---|
[0170229] | 246 | <xsl:otherwise>
|
---|
| 247 | <xsl:text>**EDITME</xsl:text>
|
---|
| 248 | <xsl:apply-templates/>
|
---|
| 249 | <xsl:text>EDITME**</xsl:text>
|
---|
| 250 | </xsl:otherwise>
|
---|
| 251 | </xsl:choose>
|
---|
| 252 | </xsl:template>
|
---|
| 253 |
|
---|
| 254 | </xsl:stylesheet>
|
---|