[e576789] | 1 | <?xml version="1.0"?>
|
---|
| 2 |
|
---|
| 3 | <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
---|
| 4 | xmlns:exsl="http://exslt.org/common"
|
---|
| 5 | extension-element-prefixes="exsl"
|
---|
| 6 | version="1.0">
|
---|
| 7 |
|
---|
| 8 | <!-- $Id: scripts.xsl 34 2012-02-21 16:05:09Z labastie $ -->
|
---|
| 9 |
|
---|
| 10 | <!-- XSLT stylesheet to create shell scripts from "linear build" BLFS books. -->
|
---|
| 11 |
|
---|
| 12 | <!-- Build as user (y) or as root (n)? -->
|
---|
| 13 | <xsl:param name="sudo" select="'y'"/>
|
---|
| 14 |
|
---|
| 15 | <xsl:template match="/">
|
---|
| 16 | <xsl:apply-templates select="//sect1"/>
|
---|
| 17 | </xsl:template>
|
---|
| 18 |
|
---|
| 19 | <!--=================== Master chunks code ======================-->
|
---|
| 20 |
|
---|
| 21 | <xsl:template match="sect1">
|
---|
| 22 |
|
---|
| 23 | <xsl:if test="@id != 'bootscripts'">
|
---|
| 24 | <!-- The file names -->
|
---|
| 25 | <xsl:variable name="filename" select="@id"/>
|
---|
| 26 |
|
---|
| 27 | <!-- The build order -->
|
---|
| 28 | <xsl:variable name="position" select="position()"/>
|
---|
| 29 | <xsl:variable name="order">
|
---|
| 30 | <xsl:choose>
|
---|
| 31 | <xsl:when test="string-length($position) = 1">
|
---|
| 32 | <xsl:text>00</xsl:text>
|
---|
| 33 | <xsl:value-of select="$position"/>
|
---|
| 34 | </xsl:when>
|
---|
| 35 | <xsl:when test="string-length($position) = 2">
|
---|
| 36 | <xsl:text>0</xsl:text>
|
---|
| 37 | <xsl:value-of select="$position"/>
|
---|
| 38 | </xsl:when>
|
---|
| 39 | <xsl:otherwise>
|
---|
| 40 | <xsl:value-of select="$position"/>
|
---|
| 41 | </xsl:otherwise>
|
---|
| 42 | </xsl:choose>
|
---|
| 43 | </xsl:variable>
|
---|
| 44 |
|
---|
| 45 | <!-- Depuration code -->
|
---|
| 46 | <xsl:message>
|
---|
| 47 | <xsl:text>SCRIPT is </xsl:text>
|
---|
| 48 | <xsl:value-of select="concat($order,'-z-',$filename)"/>
|
---|
| 49 | <xsl:text>
 FTPDIR is </xsl:text>
|
---|
| 50 | <xsl:value-of select="$filename"/>
|
---|
| 51 | <xsl:text>

</xsl:text>
|
---|
| 52 | </xsl:message>
|
---|
| 53 |
|
---|
| 54 | <!-- Creating the scripts -->
|
---|
| 55 | <exsl:document href="{$order}-z-{$filename}" method="text">
|
---|
| 56 | <xsl:text>#!/bin/bash
set -e

</xsl:text>
|
---|
| 57 | <xsl:choose>
|
---|
| 58 | <!-- Package page -->
|
---|
[642722f] | 59 | <xsl:when test="sect2[@role='package']">
|
---|
| 60 | <!-- We build in a subdirectory -->
|
---|
| 61 | <xsl:text>PKG_DIR=</xsl:text>
|
---|
[e576789] | 62 | <xsl:value-of select="$filename"/>
|
---|
| 63 | <xsl:text>
</xsl:text>
|
---|
| 64 | <!-- Download code and build commands -->
|
---|
| 65 | <xsl:apply-templates select="sect2"/>
|
---|
| 66 | <!-- Clean-up -->
|
---|
[642722f] | 67 | <xsl:text>cd $SRC_DIR/$PKG_DIR
</xsl:text>
|
---|
[e576789] | 68 | <!-- In some case, some files in the build tree are owned
|
---|
| 69 | by root -->
|
---|
[642722f] | 70 | <xsl:if test="$sudo='y'">
|
---|
| 71 | <xsl:text>sudo </xsl:text>
|
---|
[e576789] | 72 | </xsl:if>
|
---|
[642722f] | 73 | <xsl:text>rm -rf $UNPACKDIR unpacked

</xsl:text>
|
---|
[e576789] | 74 | </xsl:when>
|
---|
| 75 | <!-- Non-package page -->
|
---|
| 76 | <xsl:otherwise>
|
---|
| 77 | <xsl:apply-templates select=".//screen"/>
|
---|
| 78 | </xsl:otherwise>
|
---|
| 79 | </xsl:choose>
|
---|
| 80 | <xsl:text>exit</xsl:text>
|
---|
| 81 | </exsl:document>
|
---|
| 82 | </xsl:if>
|
---|
| 83 | </xsl:template>
|
---|
| 84 |
|
---|
| 85 | <!--======================= Sub-sections code =======================-->
|
---|
| 86 |
|
---|
| 87 | <xsl:template match="sect2">
|
---|
| 88 | <xsl:choose>
|
---|
| 89 | <xsl:when test="@role = 'package'">
|
---|
| 90 | <xsl:text>mkdir -p $SRC_DIR/$PKG_DIR
</xsl:text>
|
---|
| 91 | <xsl:text>cd $SRC_DIR/$PKG_DIR
</xsl:text>
|
---|
[642722f] | 92 | <!-- Download information is in bridgehead tags -->
|
---|
[e576789] | 93 | <xsl:apply-templates select="bridgehead[@renderas='sect3']"/>
|
---|
| 94 | <xsl:text>
</xsl:text>
|
---|
| 95 | </xsl:when>
|
---|
[967b819] | 96 | <xsl:when test="@role = 'qt4-prefix' or @role = 'qt5-prefix'">
|
---|
| 97 | <xsl:apply-templates select=".//screen"/>
|
---|
| 98 | </xsl:when>
|
---|
[e576789] | 99 | <xsl:when test="@role = 'installation'">
|
---|
| 100 | <xsl:text>
|
---|
[07f7eff] | 101 | find . -maxdepth 1 -mindepth 1 -type d | xargs </xsl:text>
|
---|
| 102 | <xsl:if test="$sudo='y'">
|
---|
| 103 | <xsl:text>sudo </xsl:text>
|
---|
| 104 | </xsl:if>
|
---|
| 105 | <xsl:text>rm -rf
|
---|
[67992a0] | 106 | case $PACKAGE in
|
---|
[e6967a1] | 107 | *.tar.gz|*.tar.bz2|*.tar.xz|*.tgz|*.tar.lzma)
|
---|
[67992a0] | 108 | tar -xvf $PACKAGE > unpacked
|
---|
| 109 | UNPACKDIR=`grep '[^./]\+' unpacked | head -n1 | sed 's@^./@@;s@/.*@@'`
|
---|
| 110 | ;;
|
---|
| 111 | *.zip)
|
---|
| 112 | zipinfo -1 $PACKAGE > unpacked
|
---|
| 113 | UNPACKDIR="$(sed 's@/.*@@' unpacked | uniq )"
|
---|
| 114 | if test $(wc -w <<< $UNPACKDIR) -eq 1; then
|
---|
| 115 | unzip $PACKAGE
|
---|
| 116 | else
|
---|
| 117 | UNPACKDIR=${PACKAGE%.zip}
|
---|
| 118 | unzip -d $UNPACKDIR $PACKAGE
|
---|
| 119 | fi
|
---|
| 120 | ;;
|
---|
| 121 | *)
|
---|
| 122 | UNPACKDIR=$PKG_DIR-build
|
---|
| 123 | mkdir $UNPACKDIR
|
---|
| 124 | cp $PACKAGE $UNPACKDIR
|
---|
| 125 | ;;
|
---|
| 126 | esac
|
---|
| 127 | cd $UNPACKDIR

|
---|
| 128 | </xsl:text>
|
---|
[e576789] | 129 | <xsl:apply-templates select=".//screen | .//para/command"/>
|
---|
| 130 | <xsl:if test="$sudo = 'y'">
|
---|
| 131 | <xsl:text>sudo /sbin/</xsl:text>
|
---|
| 132 | </xsl:if>
|
---|
| 133 | <xsl:text>ldconfig

</xsl:text>
|
---|
| 134 | </xsl:when>
|
---|
| 135 | <xsl:when test="@role = 'configuration'">
|
---|
| 136 | <xsl:apply-templates select=".//screen" mode="config"/>
|
---|
| 137 | </xsl:when>
|
---|
| 138 | </xsl:choose>
|
---|
| 139 | </xsl:template>
|
---|
| 140 |
|
---|
| 141 | <!--==================== Download code =======================-->
|
---|
| 142 |
|
---|
[642722f] | 143 | <!-- template for extracting the filename from an url in the form:
|
---|
| 144 | proto://internet.name/dir1/.../dirn/filename?condition.
|
---|
| 145 | Needed, because substring-after(...,'/') returns only the
|
---|
| 146 | substring after the first '/'. -->
|
---|
[e576789] | 147 | <xsl:template name="package_name">
|
---|
| 148 | <xsl:param name="url" select="foo"/>
|
---|
| 149 | <xsl:param name="sub-url" select="substring-after($url,'/')"/>
|
---|
| 150 | <xsl:choose>
|
---|
| 151 | <xsl:when test="contains($sub-url,'/')">
|
---|
| 152 | <xsl:call-template name="package_name">
|
---|
| 153 | <xsl:with-param name="url" select="$sub-url"/>
|
---|
| 154 | </xsl:call-template>
|
---|
| 155 | </xsl:when>
|
---|
| 156 | <xsl:otherwise>
|
---|
| 157 | <xsl:choose>
|
---|
| 158 | <xsl:when test="contains($sub-url,'?')">
|
---|
| 159 | <xsl:value-of select="substring-before($sub-url,'?')"/>
|
---|
| 160 | </xsl:when>
|
---|
| 161 | <xsl:otherwise>
|
---|
| 162 | <xsl:value-of select="$sub-url"/>
|
---|
| 163 | </xsl:otherwise>
|
---|
| 164 | </xsl:choose>
|
---|
| 165 | </xsl:otherwise>
|
---|
| 166 | </xsl:choose>
|
---|
| 167 | </xsl:template>
|
---|
| 168 |
|
---|
[642722f] | 169 | <!-- Generates the code to download a package, an additional package or
|
---|
| 170 | a patch. -->
|
---|
| 171 | <xsl:template name="download-file">
|
---|
| 172 | <xsl:param name="httpurl" select="''"/>
|
---|
| 173 | <xsl:param name="ftpurl" select="''"/>
|
---|
| 174 | <xsl:param name="md5" select="''"/>
|
---|
| 175 | <xsl:param name="varname" select="''"/>
|
---|
| 176 | <xsl:variable name="package">
|
---|
| 177 | <xsl:call-template name="package_name">
|
---|
| 178 | <xsl:with-param name="url">
|
---|
[e576789] | 179 | <xsl:choose>
|
---|
[642722f] | 180 | <xsl:when test="string-length($httpurl) > 10">
|
---|
| 181 | <xsl:value-of select="$httpurl"/>
|
---|
[e576789] | 182 | </xsl:when>
|
---|
| 183 | <xsl:otherwise>
|
---|
[642722f] | 184 | <xsl:value-of select="$ftpurl"/>
|
---|
[e576789] | 185 | </xsl:otherwise>
|
---|
| 186 | </xsl:choose>
|
---|
[642722f] | 187 | </xsl:with-param>
|
---|
| 188 | </xsl:call-template>
|
---|
| 189 | </xsl:variable>
|
---|
| 190 | <xsl:variable name="first_letter"
|
---|
| 191 | select="translate(substring($package,1,1),
|
---|
| 192 | 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
|
---|
| 193 | 'abcdefghijklmnopqrstuvwxyz')"/>
|
---|
| 194 | <xsl:text>
</xsl:text>
|
---|
| 195 | <xsl:value-of select="$varname"/>
|
---|
| 196 | <xsl:text>=</xsl:text>
|
---|
| 197 | <xsl:value-of select="$package"/>
|
---|
| 198 | <xsl:text>
if [[ ! -f $</xsl:text>
|
---|
| 199 | <xsl:value-of select="$varname"/>
|
---|
| 200 | <xsl:text> ]] ; then
</xsl:text>
|
---|
| 201 | <!-- SRC_ARCHIVE may have subdirectories or not -->
|
---|
| 202 | <xsl:text> if [[ -f $SRC_ARCHIVE/$PKG_DIR/$</xsl:text>
|
---|
| 203 | <xsl:value-of select="$varname"/>
|
---|
| 204 | <xsl:text> ]] ; then
</xsl:text>
|
---|
| 205 | <xsl:text> cp $SRC_ARCHIVE/$PKG_DIR/$</xsl:text>
|
---|
| 206 | <xsl:value-of select="$varname"/>
|
---|
| 207 | <xsl:text> $</xsl:text>
|
---|
| 208 | <xsl:value-of select="$varname"/>
|
---|
| 209 | <xsl:text>
</xsl:text>
|
---|
| 210 | <xsl:text> elif [[ -f $SRC_ARCHIVE/$</xsl:text>
|
---|
| 211 | <xsl:value-of select="$varname"/>
|
---|
| 212 | <xsl:text> ]] ; then
</xsl:text>
|
---|
| 213 | <xsl:text> cp $SRC_ARCHIVE/$</xsl:text>
|
---|
| 214 | <xsl:value-of select="$varname"/>
|
---|
| 215 | <xsl:text> $</xsl:text>
|
---|
| 216 | <xsl:value-of select="$varname"/>
|
---|
| 217 | <xsl:text>
 else
</xsl:text>
|
---|
[342c862] | 218 | <!-- Download from upstream http -->
|
---|
[642722f] | 219 | <xsl:if test="string-length($httpurl) > 10">
|
---|
[342c862] | 220 | <xsl:text> wget -T 30 -t 5 </xsl:text>
|
---|
[642722f] | 221 | <xsl:value-of select="$httpurl"/>
|
---|
[342c862] | 222 | <xsl:text> ||
</xsl:text>
|
---|
[642722f] | 223 | </xsl:if>
|
---|
[342c862] | 224 | <!-- Download from upstream ftp -->
|
---|
[642722f] | 225 | <xsl:if test="string-length($ftpurl) > 10">
|
---|
[342c862] | 226 | <xsl:text> wget -T 30 -t 5 </xsl:text>
|
---|
[642722f] | 227 | <xsl:value-of select="$ftpurl"/>
|
---|
[342c862] | 228 | <xsl:text> ||
</xsl:text>
|
---|
[642722f] | 229 | </xsl:if>
|
---|
[342c862] | 230 | <!-- The FTP_SERVER mirror as a last resort -->
|
---|
| 231 | <xsl:text> wget -T 30 -t 5 ${FTP_SERVER}svn/</xsl:text>
|
---|
| 232 | <xsl:value-of select="$first_letter"/>
|
---|
| 233 | <xsl:text>/$</xsl:text>
|
---|
| 234 | <xsl:value-of select="$varname"/>
|
---|
[642722f] | 235 | <xsl:text>
|
---|
| 236 | cp $</xsl:text>
|
---|
| 237 | <xsl:value-of select="$varname"/>
|
---|
| 238 | <xsl:text> $SRC_ARCHIVE
|
---|
[e576789] | 239 | fi
|
---|
| 240 | fi
|
---|
| 241 | </xsl:text>
|
---|
[642722f] | 242 | <xsl:if test="string-length($md5) > 10">
|
---|
| 243 | <xsl:text>echo "</xsl:text>
|
---|
| 244 | <xsl:value-of select="$md5"/>
|
---|
| 245 | <xsl:text>  $</xsl:text>
|
---|
| 246 | <xsl:value-of select="$varname"/>
|
---|
| 247 | <xsl:text>" | md5sum -c -
|
---|
[e576789] | 248 | </xsl:text>
|
---|
[642722f] | 249 | </xsl:if>
|
---|
| 250 | </xsl:template>
|
---|
| 251 |
|
---|
| 252 | <!-- Extract the MD5 sum information -->
|
---|
| 253 | <xsl:template match="para" mode="md5">
|
---|
| 254 | <xsl:choose>
|
---|
| 255 | <xsl:when test="contains(substring-after(string(),'sum: '),'
')">
|
---|
| 256 | <xsl:value-of select="substring-before(substring-after(string(),'sum: '),'
')"/>
|
---|
[e576789] | 257 | </xsl:when>
|
---|
[642722f] | 258 | <xsl:otherwise>
|
---|
| 259 | <xsl:value-of select="substring-after(string(),'sum: ')"/>
|
---|
| 260 | </xsl:otherwise>
|
---|
[e576789] | 261 | </xsl:choose>
|
---|
| 262 | </xsl:template>
|
---|
| 263 |
|
---|
[642722f] | 264 | <!-- We have several templates itemizedlist, depending on whether we
|
---|
| 265 | expect the package information, or additional package(s) or patch(es)
|
---|
| 266 | information. Select the appropriate mode here. -->
|
---|
| 267 | <xsl:template match="bridgehead">
|
---|
[e576789] | 268 | <xsl:choose>
|
---|
[642722f] | 269 | <!-- Special case for Openjdk -->
|
---|
| 270 | <xsl:when test="contains(string(),'Source Package Information')">
|
---|
| 271 | <xsl:apply-templates
|
---|
| 272 | select="following-sibling::itemizedlist[1]//simplelist">
|
---|
| 273 | <xsl:with-param name="varname" select="'PACKAGE'"/>
|
---|
| 274 | </xsl:apply-templates>
|
---|
| 275 | <xsl:apply-templates select="following-sibling::itemizedlist
|
---|
| 276 | [preceding-sibling::bridgehead[1]=current()
|
---|
| 277 | and position() >1]//simplelist">
|
---|
| 278 | <xsl:with-param name="varname" select="'PACKAGE1'"/>
|
---|
| 279 | </xsl:apply-templates>
|
---|
[e576789] | 280 | </xsl:when>
|
---|
[642722f] | 281 | <!-- Package information -->
|
---|
| 282 | <xsl:when test="contains(string(),'Package Information')">
|
---|
| 283 | <xsl:apply-templates select="following-sibling::itemizedlist
|
---|
| 284 | [preceding-sibling::bridgehead[1]=current()]"
|
---|
| 285 | mode="package"/>
|
---|
[e576789] | 286 | </xsl:when>
|
---|
[642722f] | 287 | <!-- Additional package information -->
|
---|
[ba57e61] | 288 | <!-- special case for llvm -->
|
---|
| 289 | <xsl:when test="contains(string(),'Optional Download')">
|
---|
| 290 | <xsl:apply-templates select="following-sibling::itemizedlist"
|
---|
| 291 | mode="additional"/>
|
---|
| 292 | </xsl:when>
|
---|
| 293 | <!-- All other additional packages have "Additional" -->
|
---|
[642722f] | 294 | <xsl:when test="contains(string(),'Additional')">
|
---|
| 295 | <xsl:apply-templates select="following-sibling::itemizedlist"
|
---|
| 296 | mode="additional"/>
|
---|
[e576789] | 297 | </xsl:when>
|
---|
[642722f] | 298 | <!-- Do not do anything if the dev has created another type of
|
---|
| 299 | bridgehead. -->
|
---|
| 300 | <xsl:otherwise/>
|
---|
[e576789] | 301 | </xsl:choose>
|
---|
| 302 | </xsl:template>
|
---|
| 303 |
|
---|
[642722f] | 304 | <!-- Call the download code template with appropriate parameters -->
|
---|
| 305 | <xsl:template match="itemizedlist" mode="package">
|
---|
| 306 | <xsl:call-template name="download-file">
|
---|
| 307 | <xsl:with-param name="httpurl">
|
---|
| 308 | <xsl:value-of select="./listitem[1]/para/ulink/@url"/>
|
---|
| 309 | </xsl:with-param>
|
---|
| 310 | <xsl:with-param name="ftpurl">
|
---|
| 311 | <xsl:value-of select="./listitem/para[contains(string(),'FTP')]/ulink/@url"/>
|
---|
| 312 | </xsl:with-param>
|
---|
| 313 | <xsl:with-param name="md5">
|
---|
| 314 | <xsl:apply-templates select="./listitem/para[contains(string(),'MD5')]"
|
---|
| 315 | mode="md5"/>
|
---|
| 316 | </xsl:with-param>
|
---|
| 317 | <xsl:with-param name="varname" select="'PACKAGE'"/>
|
---|
| 318 | </xsl:call-template>
|
---|
[e576789] | 319 | </xsl:template>
|
---|
| 320 |
|
---|
[642722f] | 321 | <xsl:template match="itemizedlist" mode="additional">
|
---|
| 322 | <!-- The normal layout is "one listitem"<->"one url", but some devs
|
---|
| 323 | find amusing to have FTP and/or MD5sum listitems, or to
|
---|
| 324 | enclose the download information inside a simplelist tag... -->
|
---|
| 325 | <xsl:for-each select="listitem[.//ulink]">
|
---|
| 326 | <xsl:choose>
|
---|
| 327 | <!-- hopefully, there was a HTTP line before -->
|
---|
| 328 | <xsl:when test="contains(string(./para),'FTP')"/>
|
---|
| 329 | <xsl:when test=".//simplelist">
|
---|
| 330 | <xsl:apply-templates select=".//simplelist">
|
---|
| 331 | <xsl:with-param name="varname" select="'PACKAGE1'"/>
|
---|
| 332 | </xsl:apply-templates>
|
---|
| 333 | </xsl:when>
|
---|
| 334 | <xsl:otherwise>
|
---|
| 335 | <xsl:call-template name="download-file">
|
---|
| 336 | <xsl:with-param name="httpurl">
|
---|
| 337 | <xsl:value-of select="./para/ulink/@url"/>
|
---|
| 338 | </xsl:with-param>
|
---|
| 339 | <xsl:with-param name="ftpurl">
|
---|
| 340 | <xsl:value-of
|
---|
| 341 | select="following-sibling::listitem[1]/
|
---|
| 342 | para[contains(string(),'FTP')]/ulink/@url"/>
|
---|
| 343 | </xsl:with-param>
|
---|
| 344 | <xsl:with-param name="md5">
|
---|
| 345 | <xsl:apply-templates
|
---|
| 346 | select="following-sibling::listitem[position()<3]/
|
---|
| 347 | para[contains(string(),'MD5')]"
|
---|
| 348 | mode="md5"/>
|
---|
| 349 | </xsl:with-param>
|
---|
| 350 | <xsl:with-param name="varname">
|
---|
| 351 | <xsl:choose>
|
---|
| 352 | <xsl:when test="contains(./para/ulink/@url,'.patch')">
|
---|
| 353 | <xsl:text>PATCH</xsl:text>
|
---|
| 354 | </xsl:when>
|
---|
| 355 | <xsl:otherwise>
|
---|
| 356 | <xsl:text>PACKAGE1</xsl:text>
|
---|
| 357 | </xsl:otherwise>
|
---|
| 358 | </xsl:choose>
|
---|
| 359 | </xsl:with-param>
|
---|
| 360 | </xsl:call-template>
|
---|
| 361 | </xsl:otherwise>
|
---|
| 362 | </xsl:choose>
|
---|
| 363 | </xsl:for-each>
|
---|
[e576789] | 364 | </xsl:template>
|
---|
| 365 |
|
---|
[642722f] | 366 | <!-- the simplelist case. Hopefully, the layout is one member for
|
---|
| 367 | url, one for md5 and others for various information, that we do not
|
---|
| 368 | use -->
|
---|
| 369 | <xsl:template match="simplelist">
|
---|
| 370 | <xsl:param name="varname" select="'PACKAGE1'"/>
|
---|
| 371 | <xsl:call-template name="download-file">
|
---|
| 372 | <xsl:with-param name="httpurl" select=".//ulink/@url"/>
|
---|
| 373 | <xsl:with-param name="md5">
|
---|
| 374 | <xsl:value-of select="substring-after(member[contains(string(),'MD5')],'sum: ')"/>
|
---|
| 375 | </xsl:with-param>
|
---|
| 376 | <xsl:with-param name="varname" select="$varname"/>
|
---|
| 377 | </xsl:call-template>
|
---|
| 378 | </xsl:template>
|
---|
[e576789] | 379 | <!--======================== Commands code ==========================-->
|
---|
| 380 |
|
---|
| 381 | <xsl:template match="screen">
|
---|
| 382 | <xsl:if test="child::* = userinput and not(@role = 'nodump')">
|
---|
| 383 | <xsl:choose>
|
---|
| 384 | <xsl:when test="@role = 'root'">
|
---|
| 385 | <xsl:if test="$sudo = 'y'">
|
---|
| 386 | <xsl:text>sudo -E sh << ROOT_EOF
</xsl:text>
|
---|
| 387 | </xsl:if>
|
---|
| 388 | <xsl:apply-templates mode="root"/>
|
---|
| 389 | <xsl:if test="$sudo = 'y'">
|
---|
| 390 | <xsl:text>
ROOT_EOF</xsl:text>
|
---|
| 391 | </xsl:if>
|
---|
| 392 | </xsl:when>
|
---|
| 393 | <xsl:otherwise>
|
---|
| 394 | <xsl:apply-templates select="userinput"/>
|
---|
| 395 | </xsl:otherwise>
|
---|
| 396 | </xsl:choose>
|
---|
| 397 | <xsl:text>
</xsl:text>
|
---|
| 398 | </xsl:if>
|
---|
| 399 | </xsl:template>
|
---|
| 400 |
|
---|
| 401 | <xsl:template match="screen" mode="config">
|
---|
| 402 | <xsl:if test="preceding-sibling::para[1]/xref[@linkend='bootscripts']">
|
---|
| 403 | <xsl:text>[[ ! -d $SRC_DIR/blfs-bootscripts ]] && mkdir $SRC_DIR/blfs-bootscripts
|
---|
| 404 | pushd $SRC_DIR/blfs-bootscripts
|
---|
| 405 | URL=</xsl:text>
|
---|
| 406 | <xsl:value-of select="id('bootscripts')//itemizedlist//ulink/@url"/><xsl:text>
|
---|
| 407 | BOOTPACKG=$(basename $URL)
|
---|
[bbcdeab] | 408 | if [[ ! -f $BOOTPACKG ]] ; then
|
---|
| 409 | if [[ -f $SRC_ARCHIVE/$PKG_DIR/$BOOTPACKG ]] ; then
|
---|
| 410 | cp $SRC_ARCHIVE/$PKG_DIR/$BOOTPACKG $BOOTPACKG
|
---|
| 411 | elif [[ -f $SRC_ARCHIVE/$BOOTPACKG ]] ; then
|
---|
| 412 | cp $SRC_ARCHIVE/$BOOTPACKG $BOOTPACKG
|
---|
| 413 | else
|
---|
| 414 | wget -T 30 -t 5 $URL
|
---|
| 415 | cp $BOOTPACKG $SRC_ARCHIVE
|
---|
| 416 | fi
|
---|
| 417 | rm -f unpacked
|
---|
| 418 | fi
|
---|
| 419 |
|
---|
[e576789] | 420 | if [[ -e unpacked ]] ; then
|
---|
[f079f8f] | 421 | BOOTUNPACKDIR=`head -n1 unpacked | sed 's@^./@@;s@/.*@@'`
|
---|
| 422 | if ! [[ -d $BOOTUNPACKDIR ]]; then
|
---|
[e576789] | 423 | rm unpacked
|
---|
| 424 | tar -xvf $BOOTPACKG > unpacked
|
---|
[f079f8f] | 425 | BOOTUNPACKDIR=`head -n1 unpacked | sed 's@^./@@;s@/.*@@'`
|
---|
[e576789] | 426 | fi
|
---|
| 427 | else
|
---|
| 428 | tar -xvf $BOOTPACKG > unpacked
|
---|
[f079f8f] | 429 | BOOTUNPACKDIR=`head -n1 unpacked | sed 's@^./@@;s@/.*@@'`
|
---|
[e576789] | 430 | fi
|
---|
[f079f8f] | 431 | cd $BOOTUNPACKDIR
|
---|
[e576789] | 432 | </xsl:text>
|
---|
| 433 | </xsl:if>
|
---|
| 434 | <xsl:apply-templates select='.'/>
|
---|
| 435 | <xsl:if test="preceding-sibling::para[1]/xref[@linkend='bootscripts']">
|
---|
| 436 | <xsl:text>
|
---|
| 437 | popd</xsl:text>
|
---|
| 438 | </xsl:if>
|
---|
| 439 | <xsl:text>
</xsl:text>
|
---|
| 440 | </xsl:template>
|
---|
| 441 |
|
---|
| 442 | <xsl:template match="para/command">
|
---|
[a743e57] | 443 | <xsl:variable name="ns" select="normalize-space(string())"/>
|
---|
| 444 | <xsl:if test="(contains($ns,'test') or
|
---|
| 445 | contains($ns,'check'))">
|
---|
[e576789] | 446 | <xsl:text>#</xsl:text>
|
---|
[a743e57] | 447 | <xsl:value-of select="substring-before($ns,'make ')"/>
|
---|
[9c5ea2f] | 448 | <xsl:text>make </xsl:text>
|
---|
[a743e57] | 449 | <xsl:if test="not(contains($ns,'-k'))">
|
---|
[9c5ea2f] | 450 | <xsl:text>-k </xsl:text>
|
---|
| 451 | </xsl:if>
|
---|
[a743e57] | 452 | <xsl:value-of select="substring-after($ns,'make ')"/>
|
---|
[e576789] | 453 | <xsl:text> || true
</xsl:text>
|
---|
| 454 | </xsl:if>
|
---|
| 455 | </xsl:template>
|
---|
| 456 |
|
---|
| 457 | <xsl:template match="userinput">
|
---|
| 458 | <xsl:apply-templates/>
|
---|
| 459 | </xsl:template>
|
---|
| 460 |
|
---|
| 461 | <xsl:template match="text()" mode="root">
|
---|
| 462 | <xsl:call-template name="output-root">
|
---|
| 463 | <xsl:with-param name="out-string" select="string()"/>
|
---|
| 464 | </xsl:call-template>
|
---|
| 465 | </xsl:template>
|
---|
| 466 |
|
---|
| 467 | <xsl:template name="output-root">
|
---|
| 468 | <xsl:param name="out-string" select="''"/>
|
---|
| 469 | <xsl:choose>
|
---|
[9c5ea2f] | 470 | <xsl:when test="contains($out-string,'make ')">
|
---|
[e576789] | 471 | <xsl:call-template name="output-root">
|
---|
| 472 | <xsl:with-param name="out-string"
|
---|
[9c5ea2f] | 473 | select="substring-before($out-string,'make ')"/>
|
---|
[e576789] | 474 | </xsl:call-template>
|
---|
[9c5ea2f] | 475 | <xsl:text>make -j1 </xsl:text>
|
---|
[e576789] | 476 | <xsl:call-template name="output-root">
|
---|
| 477 | <xsl:with-param name="out-string"
|
---|
[9c5ea2f] | 478 | select="substring-after($out-string,'make ')"/>
|
---|
[e576789] | 479 | </xsl:call-template>
|
---|
| 480 | </xsl:when>
|
---|
| 481 | <xsl:when test="contains($out-string,'$') and $sudo = 'y'">
|
---|
| 482 | <xsl:call-template name="output-root">
|
---|
| 483 | <xsl:with-param name="out-string"
|
---|
| 484 | select="substring-before($out-string,'$')"/>
|
---|
| 485 | </xsl:call-template>
|
---|
| 486 | <xsl:text>\$</xsl:text>
|
---|
| 487 | <xsl:call-template name="output-root">
|
---|
| 488 | <xsl:with-param name="out-string"
|
---|
| 489 | select="substring-after($out-string,'$')"/>
|
---|
| 490 | </xsl:call-template>
|
---|
| 491 | </xsl:when>
|
---|
| 492 | <xsl:when test="contains($out-string,'`') and $sudo = 'y'">
|
---|
| 493 | <xsl:call-template name="output-root">
|
---|
| 494 | <xsl:with-param name="out-string"
|
---|
| 495 | select="substring-before($out-string,'`')"/>
|
---|
| 496 | </xsl:call-template>
|
---|
| 497 | <xsl:text>\`</xsl:text>
|
---|
| 498 | <xsl:call-template name="output-root">
|
---|
| 499 | <xsl:with-param name="out-string"
|
---|
| 500 | select="substring-after($out-string,'`')"/>
|
---|
| 501 | </xsl:call-template>
|
---|
| 502 | </xsl:when>
|
---|
| 503 | <xsl:when test="contains($out-string,'\') and $sudo = 'y'">
|
---|
| 504 | <xsl:call-template name="output-root">
|
---|
| 505 | <xsl:with-param name="out-string"
|
---|
| 506 | select="substring-before($out-string,'\')"/>
|
---|
| 507 | </xsl:call-template>
|
---|
| 508 | <xsl:text>\\</xsl:text>
|
---|
| 509 | <xsl:call-template name="output-root">
|
---|
| 510 | <xsl:with-param name="out-string"
|
---|
| 511 | select="substring-after($out-string,'\')"/>
|
---|
| 512 | </xsl:call-template>
|
---|
| 513 | </xsl:when>
|
---|
| 514 | <xsl:otherwise>
|
---|
| 515 | <xsl:value-of select="$out-string"/>
|
---|
| 516 | </xsl:otherwise>
|
---|
| 517 | </xsl:choose>
|
---|
| 518 | </xsl:template>
|
---|
| 519 |
|
---|
| 520 | <xsl:template match="replaceable">
|
---|
| 521 | <xsl:text>**EDITME</xsl:text>
|
---|
| 522 | <xsl:apply-templates/>
|
---|
| 523 | <xsl:text>EDITME**</xsl:text>
|
---|
| 524 | </xsl:template>
|
---|
| 525 |
|
---|
| 526 | <xsl:template match="replaceable" mode="root">
|
---|
| 527 | <xsl:text>**EDITME</xsl:text>
|
---|
| 528 | <xsl:apply-templates/>
|
---|
| 529 | <xsl:text>EDITME**</xsl:text>
|
---|
| 530 | </xsl:template>
|
---|
| 531 |
|
---|
| 532 | </xsl:stylesheet>
|
---|