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