[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 |
|
---|
[56178ba] | 8 | <!-- $Id$ -->
|
---|
[e576789] | 9 |
|
---|
| 10 | <!-- XSLT stylesheet to create shell scripts from "linear build" BLFS books. -->
|
---|
| 11 |
|
---|
[c048987] | 12 | <!-- parameters and global variables -->
|
---|
| 13 | <!-- Check whether the book is sysv or systemd -->
|
---|
[70d73d1] | 14 | <xsl:variable name="rev">
|
---|
| 15 | <xsl:choose>
|
---|
| 16 | <xsl:when test="//bookinfo/title/phrase[@revision='systemd']">
|
---|
| 17 | systemd
|
---|
| 18 | </xsl:when>
|
---|
| 19 | <xsl:otherwise>
|
---|
| 20 | sysv
|
---|
| 21 | </xsl:otherwise>
|
---|
| 22 | </xsl:choose>
|
---|
| 23 | </xsl:variable>
|
---|
| 24 |
|
---|
[945ccaa] | 25 | <!-- Wrap "root" commands inside a wrapper function, allowing
|
---|
| 26 | "porg style" package management -->
|
---|
| 27 | <xsl:param name="wrap-install" select="'n'"/>
|
---|
| 28 |
|
---|
[67c3df4] | 29 | <!-- list of packages needing stats -->
|
---|
| 30 | <xsl:param name="list-stat" select="''"/>
|
---|
| 31 |
|
---|
[dc7fd7b] | 32 | <!-- Remove libtool .la files -->
|
---|
| 33 | <xsl:param name="del-la-files" select="'y'"/>
|
---|
| 34 |
|
---|
[e576789] | 35 | <!-- Build as user (y) or as root (n)? -->
|
---|
| 36 | <xsl:param name="sudo" select="'y'"/>
|
---|
| 37 |
|
---|
[625cb14] | 38 | <!-- Localization in the form ll_CC.charmap@modifier (to be used in
|
---|
| 39 | bash shell startup scripts). ll, CC, and charmap must be present:
|
---|
| 40 | no way to use "C" or "POSIX". -->
|
---|
| 41 | <xsl:param name="language" select="'en_US.UTF-8'"/>
|
---|
| 42 |
|
---|
| 43 | <!-- Break it in pieces -->
|
---|
| 44 | <xsl:variable name="lang-ll">
|
---|
| 45 | <xsl:copy-of select="substring-before($language,'_')"/>
|
---|
| 46 | </xsl:variable>
|
---|
| 47 | <xsl:variable name="lang-CC">
|
---|
| 48 | <xsl:copy-of
|
---|
| 49 | select="substring-before(substring-after($language,'_'),'.')"/>
|
---|
| 50 | </xsl:variable>
|
---|
| 51 | <xsl:variable name="lang-charmap">
|
---|
| 52 | <xsl:choose>
|
---|
| 53 | <xsl:when test="contains($language,'@')">
|
---|
| 54 | <xsl:copy-of
|
---|
| 55 | select="substring-before(substring-after($language,'.'),'@')"/>
|
---|
| 56 | </xsl:when>
|
---|
| 57 | <xsl:otherwise>
|
---|
| 58 | <xsl:copy-of select="substring-after($language,'.')"/>
|
---|
| 59 | </xsl:otherwise>
|
---|
| 60 | </xsl:choose>
|
---|
| 61 | </xsl:variable>
|
---|
| 62 | <xsl:variable name="lang-modifier">
|
---|
| 63 | <xsl:choose>
|
---|
| 64 | <xsl:when test="contains($language,'@')">
|
---|
| 65 | <xsl:copy-of select="concat('@',substring-after($language,'@'))"/>
|
---|
| 66 | </xsl:when>
|
---|
| 67 | <xsl:otherwise>
|
---|
| 68 | <xsl:copy-of select="''"/>
|
---|
| 69 | </xsl:otherwise>
|
---|
| 70 | </xsl:choose>
|
---|
| 71 | </xsl:variable>
|
---|
| 72 |
|
---|
[dc7fd7b] | 73 | <!-- simple instructions for removing .la files. -->
|
---|
[619b313] | 74 | <!-- We'll use the rule that any text output begins with a linefeed if needed
|
---|
| 75 | so that we do not need to output one at the end-->
|
---|
[dc7fd7b] | 76 | <xsl:variable name="la-files-instr">
|
---|
| 77 |
|
---|
| 78 | for libdir in /lib /usr/lib $(find /opt -name lib); do
|
---|
[2969cdf] | 79 | find $libdir -name \*.la \
|
---|
| 80 | ! -path \*ImageMagick\* \
|
---|
| 81 | -delete
|
---|
[619b313] | 82 | done</xsl:variable>
|
---|
[67c3df4] | 83 |
|
---|
[c048987] | 84 | <xsl:variable name="list-stat-norm"
|
---|
| 85 | select="concat(' ', normalize-space($list-stat),' ')"/>
|
---|
| 86 |
|
---|
| 87 | <!-- To be able to use the single quote in tests -->
|
---|
| 88 | <xsl:variable name="APOS">'</xsl:variable>
|
---|
| 89 |
|
---|
| 90 | <!-- end parameters and global variables -->
|
---|
| 91 |
|
---|
| 92 | <!-- include the templates for the screen children of role="install" sect2 -->
|
---|
| 93 | <xsl:include href="gen-install.xsl"/>
|
---|
| 94 |
|
---|
| 95 | <!--=================== Begin processing ========================-->
|
---|
[67c3df4] | 96 |
|
---|
[e576789] | 97 | <xsl:template match="/">
|
---|
[c048987] | 98 | <xsl:apply-templates select="//sect1[@id != 'bootscripts' and
|
---|
| 99 | @id != 'systemd-units']"/>
|
---|
[e576789] | 100 | </xsl:template>
|
---|
| 101 |
|
---|
| 102 | <!--=================== Master chunks code ======================-->
|
---|
| 103 |
|
---|
| 104 | <xsl:template match="sect1">
|
---|
| 105 |
|
---|
[619b313] | 106 | <!-- Are stat requested for this page? -->
|
---|
| 107 | <xsl:variable name="want-stats"
|
---|
| 108 | select="contains($list-stat-norm,
|
---|
| 109 | concat(' ',@id,' '))"/>
|
---|
| 110 |
|
---|
[c048987] | 111 | <!-- The file names -->
|
---|
| 112 | <xsl:variable name="filename" select="@id"/>
|
---|
[e576789] | 113 |
|
---|
[c048987] | 114 | <!-- The build order -->
|
---|
| 115 | <xsl:variable name="position" select="position()"/>
|
---|
| 116 | <xsl:variable name="order">
|
---|
| 117 | <xsl:choose>
|
---|
| 118 | <xsl:when test="string-length($position) = 1">
|
---|
| 119 | <xsl:text>00</xsl:text>
|
---|
| 120 | <xsl:value-of select="$position"/>
|
---|
| 121 | </xsl:when>
|
---|
| 122 | <xsl:when test="string-length($position) = 2">
|
---|
| 123 | <xsl:text>0</xsl:text>
|
---|
| 124 | <xsl:value-of select="$position"/>
|
---|
| 125 | </xsl:when>
|
---|
| 126 | <xsl:otherwise>
|
---|
| 127 | <xsl:value-of select="$position"/>
|
---|
| 128 | </xsl:otherwise>
|
---|
| 129 | </xsl:choose>
|
---|
| 130 | </xsl:variable>
|
---|
[e576789] | 131 |
|
---|
| 132 | <!-- Depuration code -->
|
---|
[c048987] | 133 | <xsl:message>
|
---|
| 134 | <xsl:text>SCRIPT is </xsl:text>
|
---|
| 135 | <xsl:value-of select="concat($order,'-z-',$filename)"/>
|
---|
| 136 | <xsl:text>
 FTPDIR is </xsl:text>
|
---|
| 137 | <xsl:value-of select="$filename"/>
|
---|
| 138 | <xsl:text>

</xsl:text>
|
---|
| 139 | </xsl:message>
|
---|
| 140 |
|
---|
| 141 | <!-- Creating the scripts -->
|
---|
| 142 | <exsl:document href="{$order}-z-{$filename}" method="text">
|
---|
| 143 | <xsl:text>#!/bin/bash
|
---|
[eabfc59] | 144 | set -e
|
---|
| 145 | unset MAKELEVEL
|
---|
| 146 | </xsl:text>
|
---|
[619b313] | 147 | <!-- the above is needed for some packages -->
|
---|
[c048987] | 148 | <xsl:choose>
|
---|
| 149 | <!-- Package page -->
|
---|
| 150 | <xsl:when test="sect2[@role='package']">
|
---|
| 151 | <!-- We build in a subdirectory, whose name may be needed
|
---|
| 152 | if using package management (see envars.conf), so
|
---|
| 153 | "export" it -->
|
---|
[619b313] | 154 | <xsl:text>
|
---|
| 155 | export JH_PKG_DIR=</xsl:text>
|
---|
[c048987] | 156 | <xsl:value-of select="$filename"/>
|
---|
| 157 | <xsl:text>
|
---|
[1fa0dee] | 158 | SRC_DIR=${JH_SRC_ARCHIVE}${JH_SRC_SUBDIRS:+/${JH_PKG_DIR}}
|
---|
| 159 | BUILD_DIR=${JH_BUILD_ROOT}${JH_BUILD_SUBDIRS:+/${JH_PKG_DIR}}
|
---|
[39dc04a] | 160 | mkdir -p $SRC_DIR
|
---|
| 161 | mkdir -p $BUILD_DIR
|
---|
| 162 | </xsl:text>
|
---|
[67c3df4] | 163 |
|
---|
| 164 | <!-- If stats are requested, include some definitions and intitializations -->
|
---|
[619b313] | 165 | <xsl:if test="$want-stats">
|
---|
| 166 | <xsl:text>
|
---|
| 167 | INFOLOG=$(pwd)/info-${JH_PKG_DIR}
|
---|
[9e0c4b6] | 168 | TESTLOG=$(pwd)/test-${JH_PKG_DIR}
|
---|
[67c3df4] | 169 | unset MAKEFLAGS
|
---|
| 170 | #MAKEFLAGS=-j4
|
---|
| 171 | echo MAKEFLAGS: $MAKEFLAGS > $INFOLOG
|
---|
[c048987] | 172 | : > $TESTLOG
|
---|
[67c3df4] | 173 | PKG_DEST=${BUILD_DIR}/dest
|
---|
| 174 | rm -rf $PKG_DEST
|
---|
| 175 | </xsl:text>
|
---|
[c048987] | 176 | </xsl:if>
|
---|
| 177 | <!-- Download code and build commands -->
|
---|
[619b313] | 178 | <xsl:apply-templates select="sect2">
|
---|
| 179 | <xsl:with-param name="want-stats" select="$want-stats"/>
|
---|
| 180 | </xsl:apply-templates>
|
---|
[c048987] | 181 | <!-- Clean-up -->
|
---|
[619b313] | 182 | <xsl:text>
|
---|
| 183 |
|
---|
| 184 | cd $BUILD_DIR
|
---|
[1fa0dee] | 185 | [[ -n "$JH_KEEP_FILES" ]] || </xsl:text>
|
---|
[c048987] | 186 | <!-- In some case, some files in the build tree are owned
|
---|
| 187 | by root -->
|
---|
| 188 | <xsl:if test="$sudo='y'">
|
---|
| 189 | <xsl:text>sudo </xsl:text>
|
---|
| 190 | </xsl:if>
|
---|
[619b313] | 191 | <xsl:text>rm -rf $JH_UNPACKDIR unpacked
|
---|
| 192 | </xsl:text>
|
---|
[c048987] | 193 | </xsl:when>
|
---|
| 194 | <!-- Non-package page -->
|
---|
| 195 | <xsl:otherwise>
|
---|
| 196 | <xsl:apply-templates select=".//screen" mode="not-pack"/>
|
---|
| 197 | </xsl:otherwise>
|
---|
| 198 | </xsl:choose>
|
---|
[619b313] | 199 | <xsl:text>
|
---|
| 200 | exit
|
---|
| 201 | </xsl:text><!-- include a \n at the end of document-->
|
---|
[c048987] | 202 | </exsl:document>
|
---|
[e576789] | 203 | </xsl:template>
|
---|
| 204 |
|
---|
| 205 | <!--======================= Sub-sections code =======================-->
|
---|
| 206 |
|
---|
| 207 | <xsl:template match="sect2">
|
---|
[619b313] | 208 | <xsl:param name="want-stats" select="false"/>
|
---|
[e576789] | 209 | <xsl:choose>
|
---|
[c048987] | 210 |
|
---|
[e576789] | 211 | <xsl:when test="@role = 'package'">
|
---|
[619b313] | 212 | <xsl:text>
|
---|
| 213 | cd $SRC_DIR</xsl:text>
|
---|
[642722f] | 214 | <!-- Download information is in bridgehead tags -->
|
---|
[e576789] | 215 | <xsl:apply-templates select="bridgehead[@renderas='sect3']"/>
|
---|
[c048987] | 216 | </xsl:when><!-- @role="package" -->
|
---|
| 217 |
|
---|
[967b819] | 218 | <xsl:when test="@role = 'qt4-prefix' or @role = 'qt5-prefix'">
|
---|
[625cb14] | 219 | <xsl:apply-templates select=".//screen[./userinput]"/>
|
---|
[967b819] | 220 | </xsl:when>
|
---|
[c048987] | 221 |
|
---|
[e576789] | 222 | <xsl:when test="@role = 'installation'">
|
---|
| 223 | <xsl:text>
|
---|
[39dc04a] | 224 | cd $BUILD_DIR
|
---|
[07f7eff] | 225 | find . -maxdepth 1 -mindepth 1 -type d | xargs </xsl:text>
|
---|
| 226 | <xsl:if test="$sudo='y'">
|
---|
| 227 | <xsl:text>sudo </xsl:text>
|
---|
| 228 | </xsl:if>
|
---|
| 229 | <xsl:text>rm -rf
|
---|
[67c3df4] | 230 | </xsl:text>
|
---|
[619b313] | 231 | <!-- If stats are requested, insert the start size -->
|
---|
| 232 | <xsl:if test="$want-stats">
|
---|
| 233 | <xsl:text>
|
---|
| 234 | echo Start Size: $(sudo du -skx --exclude home /) >> $INFOLOG
|
---|
[67c3df4] | 235 | </xsl:text>
|
---|
| 236 | </xsl:if>
|
---|
| 237 |
|
---|
[619b313] | 238 | <xsl:text>
|
---|
| 239 | case $PACKAGE in
|
---|
[e6967a1] | 240 | *.tar.gz|*.tar.bz2|*.tar.xz|*.tgz|*.tar.lzma)
|
---|
[39dc04a] | 241 | tar -xvf $SRC_DIR/$PACKAGE > unpacked
|
---|
[1fa0dee] | 242 | JH_UNPACKDIR=`grep '[^./]\+' unpacked | head -n1 | sed 's@^\./@@;s@/.*@@'`
|
---|
[6eaae5e] | 243 | ;;
|
---|
| 244 | *.tar.lz)
|
---|
[39dc04a] | 245 | bsdtar -xvf $SRC_DIR/$PACKAGE 2> unpacked
|
---|
[1fa0dee] | 246 | JH_UNPACKDIR=`head -n1 unpacked | cut -d" " -f2 | sed 's@^\./@@;s@/.*@@'`
|
---|
[67992a0] | 247 | ;;
|
---|
| 248 | *.zip)
|
---|
[39dc04a] | 249 | zipinfo -1 $SRC_DIR/$PACKAGE > unpacked
|
---|
[1fa0dee] | 250 | JH_UNPACKDIR="$(sed 's@/.*@@' unpacked | uniq )"
|
---|
| 251 | if test $(wc -w <<< $JH_UNPACKDIR) -eq 1; then
|
---|
[39dc04a] | 252 | unzip $SRC_DIR/$PACKAGE
|
---|
[67992a0] | 253 | else
|
---|
[1fa0dee] | 254 | JH_UNPACKDIR=${PACKAGE%.zip}
|
---|
| 255 | unzip -d $JH_UNPACKDIR $SRC_DIR/$PACKAGE
|
---|
[67992a0] | 256 | fi
|
---|
| 257 | ;;
|
---|
| 258 | *)
|
---|
[1fa0dee] | 259 | JH_UNPACKDIR=$JH_PKG_DIR-build
|
---|
| 260 | mkdir $JH_UNPACKDIR
|
---|
| 261 | cp $SRC_DIR/$PACKAGE $JH_UNPACKDIR
|
---|
[619b313] | 262 | ADDITIONAL="$(find . -mindepth 1 -maxdepth 1 -type l)"
|
---|
| 263 | if [ -n "$ADDITIONAL" ]; then
|
---|
| 264 | cp $ADDITIONAL $JH_UNPACKDIR
|
---|
| 265 | fi
|
---|
[67992a0] | 266 | ;;
|
---|
| 267 | esac
|
---|
[1fa0dee] | 268 | export JH_UNPACKDIR
|
---|
[619b313] | 269 | cd $JH_UNPACKDIR
|
---|
[67992a0] | 270 | </xsl:text>
|
---|
[619b313] | 271 | <!-- If stats are requested, insert the start time -->
|
---|
| 272 | <xsl:if test="$want-stats">
|
---|
| 273 | <xsl:text>
|
---|
| 274 | echo Start Time: ${SECONDS} >> $INFOLOG
|
---|
[67c3df4] | 275 | </xsl:text>
|
---|
| 276 | </xsl:if>
|
---|
| 277 |
|
---|
[625cb14] | 278 | <xsl:apply-templates
|
---|
[c048987] | 279 | mode="installation"
|
---|
[625cb14] | 280 | select=".//screen[not(@role = 'nodump') and ./userinput] |
|
---|
[c048987] | 281 | .//para/command[contains(text(),'check') or
|
---|
[619b313] | 282 | contains(text(),'test')]">
|
---|
| 283 | <xsl:with-param name="want-stats" select="$want-stats"/>
|
---|
| 284 | </xsl:apply-templates>
|
---|
| 285 | <xsl:text>
|
---|
| 286 | </xsl:text>
|
---|
[e576789] | 287 | <xsl:if test="$sudo = 'y'">
|
---|
| 288 | <xsl:text>sudo /sbin/</xsl:text>
|
---|
| 289 | </xsl:if>
|
---|
[619b313] | 290 | <xsl:text>ldconfig</xsl:text>
|
---|
[c048987] | 291 | </xsl:when><!-- @role="installation" -->
|
---|
| 292 |
|
---|
[e576789] | 293 | <xsl:when test="@role = 'configuration'">
|
---|
[619b313] | 294 | <xsl:text>
</xsl:text>
|
---|
[625cb14] | 295 | <xsl:apply-templates mode="config"
|
---|
| 296 | select=".//screen[not(@role = 'nodump') and ./userinput]"/>
|
---|
[c048987] | 297 | </xsl:when><!-- @role="configuration" -->
|
---|
| 298 |
|
---|
[e576789] | 299 | </xsl:choose>
|
---|
| 300 | </xsl:template>
|
---|
| 301 |
|
---|
| 302 | <!--==================== Download code =======================-->
|
---|
| 303 |
|
---|
[642722f] | 304 | <!-- template for extracting the filename from an url in the form:
|
---|
| 305 | proto://internet.name/dir1/.../dirn/filename?condition.
|
---|
| 306 | Needed, because substring-after(...,'/') returns only the
|
---|
| 307 | substring after the first '/'. -->
|
---|
[e576789] | 308 | <xsl:template name="package_name">
|
---|
| 309 | <xsl:param name="url" select="foo"/>
|
---|
| 310 | <xsl:param name="sub-url" select="substring-after($url,'/')"/>
|
---|
| 311 | <xsl:choose>
|
---|
| 312 | <xsl:when test="contains($sub-url,'/')">
|
---|
| 313 | <xsl:call-template name="package_name">
|
---|
| 314 | <xsl:with-param name="url" select="$sub-url"/>
|
---|
| 315 | </xsl:call-template>
|
---|
| 316 | </xsl:when>
|
---|
| 317 | <xsl:otherwise>
|
---|
| 318 | <xsl:choose>
|
---|
| 319 | <xsl:when test="contains($sub-url,'?')">
|
---|
| 320 | <xsl:value-of select="substring-before($sub-url,'?')"/>
|
---|
| 321 | </xsl:when>
|
---|
| 322 | <xsl:otherwise>
|
---|
| 323 | <xsl:value-of select="$sub-url"/>
|
---|
| 324 | </xsl:otherwise>
|
---|
| 325 | </xsl:choose>
|
---|
| 326 | </xsl:otherwise>
|
---|
| 327 | </xsl:choose>
|
---|
| 328 | </xsl:template>
|
---|
| 329 |
|
---|
[642722f] | 330 | <!-- Generates the code to download a package, an additional package or
|
---|
| 331 | a patch. -->
|
---|
| 332 | <xsl:template name="download-file">
|
---|
| 333 | <xsl:param name="httpurl" select="''"/>
|
---|
| 334 | <xsl:param name="ftpurl" select="''"/>
|
---|
| 335 | <xsl:param name="md5" select="''"/>
|
---|
| 336 | <xsl:param name="varname" select="''"/>
|
---|
| 337 | <xsl:variable name="package">
|
---|
| 338 | <xsl:call-template name="package_name">
|
---|
| 339 | <xsl:with-param name="url">
|
---|
[e576789] | 340 | <xsl:choose>
|
---|
[642722f] | 341 | <xsl:when test="string-length($httpurl) > 10">
|
---|
| 342 | <xsl:value-of select="$httpurl"/>
|
---|
[e576789] | 343 | </xsl:when>
|
---|
| 344 | <xsl:otherwise>
|
---|
[642722f] | 345 | <xsl:value-of select="$ftpurl"/>
|
---|
[e576789] | 346 | </xsl:otherwise>
|
---|
| 347 | </xsl:choose>
|
---|
[642722f] | 348 | </xsl:with-param>
|
---|
| 349 | </xsl:call-template>
|
---|
| 350 | </xsl:variable>
|
---|
| 351 | <xsl:variable name="first_letter"
|
---|
| 352 | select="translate(substring($package,1,1),
|
---|
| 353 | 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
|
---|
| 354 | 'abcdefghijklmnopqrstuvwxyz')"/>
|
---|
| 355 | <xsl:text>
</xsl:text>
|
---|
| 356 | <xsl:value-of select="$varname"/>
|
---|
| 357 | <xsl:text>=</xsl:text>
|
---|
| 358 | <xsl:value-of select="$package"/>
|
---|
| 359 | <xsl:text>
if [[ ! -f $</xsl:text>
|
---|
| 360 | <xsl:value-of select="$varname"/>
|
---|
[8dc4646] | 361 | <xsl:text> ]] ; then
|
---|
[1fa0dee] | 362 | if [[ -f $JH_SRC_ARCHIVE/$</xsl:text>
|
---|
[642722f] | 363 | <xsl:value-of select="$varname"/>
|
---|
| 364 | <xsl:text> ]] ; then
</xsl:text>
|
---|
[1fa0dee] | 365 | <xsl:text> cp $JH_SRC_ARCHIVE/$</xsl:text>
|
---|
[642722f] | 366 | <xsl:value-of select="$varname"/>
|
---|
| 367 | <xsl:text> $</xsl:text>
|
---|
| 368 | <xsl:value-of select="$varname"/>
|
---|
[8dc4646] | 369 | <xsl:text>
|
---|
| 370 | else
</xsl:text>
|
---|
[342c862] | 371 | <!-- Download from upstream http -->
|
---|
[642722f] | 372 | <xsl:if test="string-length($httpurl) > 10">
|
---|
[8dc4646] | 373 | <xsl:text> wget -T 30 -t 5 </xsl:text>
|
---|
[642722f] | 374 | <xsl:value-of select="$httpurl"/>
|
---|
[342c862] | 375 | <xsl:text> ||
</xsl:text>
|
---|
[642722f] | 376 | </xsl:if>
|
---|
[342c862] | 377 | <!-- Download from upstream ftp -->
|
---|
[642722f] | 378 | <xsl:if test="string-length($ftpurl) > 10">
|
---|
[8dc4646] | 379 | <xsl:text> wget -T 30 -t 5 </xsl:text>
|
---|
[642722f] | 380 | <xsl:value-of select="$ftpurl"/>
|
---|
[342c862] | 381 | <xsl:text> ||
</xsl:text>
|
---|
[642722f] | 382 | </xsl:if>
|
---|
[342c862] | 383 | <!-- The FTP_SERVER mirror as a last resort -->
|
---|
[1fa0dee] | 384 | <xsl:text> wget -T 30 -t 5 ${JH_FTP_SERVER}svn/</xsl:text>
|
---|
[342c862] | 385 | <xsl:value-of select="$first_letter"/>
|
---|
| 386 | <xsl:text>/$</xsl:text>
|
---|
| 387 | <xsl:value-of select="$varname"/>
|
---|
[1fa0dee] | 388 | <xsl:text>
|
---|
[8dc4646] | 389 | fi
|
---|
[619b313] | 390 | fi</xsl:text>
|
---|
[642722f] | 391 | <xsl:if test="string-length($md5) > 10">
|
---|
[619b313] | 392 | <xsl:text>
|
---|
| 393 | echo "</xsl:text>
|
---|
[642722f] | 394 | <xsl:value-of select="$md5"/>
|
---|
| 395 | <xsl:text>  $</xsl:text>
|
---|
| 396 | <xsl:value-of select="$varname"/>
|
---|
[619b313] | 397 | <xsl:text>" | md5sum -c -</xsl:text>
|
---|
[39dc04a] | 398 | </xsl:if>
|
---|
| 399 | <!-- link additional packages into $BUILD_DIR, because they are supposed to
|
---|
| 400 | be there-->
|
---|
| 401 | <xsl:if test="string($varname) != 'PACKAGE'">
|
---|
[619b313] | 402 | <xsl:text>
|
---|
| 403 | [[ "$SRC_DIR" != "$BUILD_DIR" ]] && ln -sf $SRC_DIR/$</xsl:text>
|
---|
[39dc04a] | 404 | <xsl:value-of select="$varname"/>
|
---|
[619b313] | 405 | <xsl:text> $BUILD_DIR</xsl:text>
|
---|
[642722f] | 406 | </xsl:if>
|
---|
[619b313] | 407 | <xsl:text>
</xsl:text>
|
---|
[642722f] | 408 | </xsl:template>
|
---|
| 409 |
|
---|
| 410 | <!-- Extract the MD5 sum information -->
|
---|
| 411 | <xsl:template match="para" mode="md5">
|
---|
| 412 | <xsl:choose>
|
---|
| 413 | <xsl:when test="contains(substring-after(string(),'sum: '),'
')">
|
---|
| 414 | <xsl:value-of select="substring-before(substring-after(string(),'sum: '),'
')"/>
|
---|
[e576789] | 415 | </xsl:when>
|
---|
[642722f] | 416 | <xsl:otherwise>
|
---|
| 417 | <xsl:value-of select="substring-after(string(),'sum: ')"/>
|
---|
| 418 | </xsl:otherwise>
|
---|
[e576789] | 419 | </xsl:choose>
|
---|
| 420 | </xsl:template>
|
---|
| 421 |
|
---|
[642722f] | 422 | <!-- We have several templates itemizedlist, depending on whether we
|
---|
| 423 | expect the package information, or additional package(s) or patch(es)
|
---|
| 424 | information. Select the appropriate mode here. -->
|
---|
| 425 | <xsl:template match="bridgehead">
|
---|
[e576789] | 426 | <xsl:choose>
|
---|
[642722f] | 427 | <!-- Special case for Openjdk -->
|
---|
| 428 | <xsl:when test="contains(string(),'Source Package Information')">
|
---|
| 429 | <xsl:apply-templates
|
---|
| 430 | select="following-sibling::itemizedlist[1]//simplelist">
|
---|
| 431 | <xsl:with-param name="varname" select="'PACKAGE'"/>
|
---|
| 432 | </xsl:apply-templates>
|
---|
| 433 | <xsl:apply-templates select="following-sibling::itemizedlist
|
---|
| 434 | [preceding-sibling::bridgehead[1]=current()
|
---|
| 435 | and position() >1]//simplelist">
|
---|
| 436 | <xsl:with-param name="varname" select="'PACKAGE1'"/>
|
---|
| 437 | </xsl:apply-templates>
|
---|
[e576789] | 438 | </xsl:when>
|
---|
[642722f] | 439 | <!-- Package information -->
|
---|
| 440 | <xsl:when test="contains(string(),'Package Information')">
|
---|
| 441 | <xsl:apply-templates select="following-sibling::itemizedlist
|
---|
| 442 | [preceding-sibling::bridgehead[1]=current()]"
|
---|
| 443 | mode="package"/>
|
---|
[e576789] | 444 | </xsl:when>
|
---|
[642722f] | 445 | <!-- Additional package information -->
|
---|
[ba57e61] | 446 | <!-- special case for llvm -->
|
---|
| 447 | <xsl:when test="contains(string(),'Optional Download')">
|
---|
| 448 | <xsl:apply-templates select="following-sibling::itemizedlist"
|
---|
| 449 | mode="additional"/>
|
---|
| 450 | </xsl:when>
|
---|
| 451 | <!-- All other additional packages have "Additional" -->
|
---|
[642722f] | 452 | <xsl:when test="contains(string(),'Additional')">
|
---|
| 453 | <xsl:apply-templates select="following-sibling::itemizedlist"
|
---|
| 454 | mode="additional"/>
|
---|
[e576789] | 455 | </xsl:when>
|
---|
[642722f] | 456 | <!-- Do not do anything if the dev has created another type of
|
---|
| 457 | bridgehead. -->
|
---|
| 458 | <xsl:otherwise/>
|
---|
[e576789] | 459 | </xsl:choose>
|
---|
| 460 | </xsl:template>
|
---|
| 461 |
|
---|
[642722f] | 462 | <!-- Call the download code template with appropriate parameters -->
|
---|
| 463 | <xsl:template match="itemizedlist" mode="package">
|
---|
| 464 | <xsl:call-template name="download-file">
|
---|
| 465 | <xsl:with-param name="httpurl">
|
---|
| 466 | <xsl:value-of select="./listitem[1]/para/ulink/@url"/>
|
---|
| 467 | </xsl:with-param>
|
---|
| 468 | <xsl:with-param name="ftpurl">
|
---|
| 469 | <xsl:value-of select="./listitem/para[contains(string(),'FTP')]/ulink/@url"/>
|
---|
| 470 | </xsl:with-param>
|
---|
| 471 | <xsl:with-param name="md5">
|
---|
| 472 | <xsl:apply-templates select="./listitem/para[contains(string(),'MD5')]"
|
---|
| 473 | mode="md5"/>
|
---|
| 474 | </xsl:with-param>
|
---|
| 475 | <xsl:with-param name="varname" select="'PACKAGE'"/>
|
---|
| 476 | </xsl:call-template>
|
---|
[e576789] | 477 | </xsl:template>
|
---|
| 478 |
|
---|
[642722f] | 479 | <xsl:template match="itemizedlist" mode="additional">
|
---|
| 480 | <!-- The normal layout is "one listitem"<->"one url", but some devs
|
---|
| 481 | find amusing to have FTP and/or MD5sum listitems, or to
|
---|
| 482 | enclose the download information inside a simplelist tag... -->
|
---|
| 483 | <xsl:for-each select="listitem[.//ulink]">
|
---|
| 484 | <xsl:choose>
|
---|
| 485 | <!-- hopefully, there was a HTTP line before -->
|
---|
| 486 | <xsl:when test="contains(string(./para),'FTP')"/>
|
---|
| 487 | <xsl:when test=".//simplelist">
|
---|
| 488 | <xsl:apply-templates select=".//simplelist">
|
---|
| 489 | <xsl:with-param name="varname" select="'PACKAGE1'"/>
|
---|
| 490 | </xsl:apply-templates>
|
---|
| 491 | </xsl:when>
|
---|
| 492 | <xsl:otherwise>
|
---|
| 493 | <xsl:call-template name="download-file">
|
---|
| 494 | <xsl:with-param name="httpurl">
|
---|
| 495 | <xsl:value-of select="./para/ulink/@url"/>
|
---|
| 496 | </xsl:with-param>
|
---|
| 497 | <xsl:with-param name="ftpurl">
|
---|
| 498 | <xsl:value-of
|
---|
| 499 | select="following-sibling::listitem[1]/
|
---|
| 500 | para[contains(string(),'FTP')]/ulink/@url"/>
|
---|
| 501 | </xsl:with-param>
|
---|
| 502 | <xsl:with-param name="md5">
|
---|
| 503 | <xsl:apply-templates
|
---|
| 504 | select="following-sibling::listitem[position()<3]/
|
---|
| 505 | para[contains(string(),'MD5')]"
|
---|
| 506 | mode="md5"/>
|
---|
| 507 | </xsl:with-param>
|
---|
| 508 | <xsl:with-param name="varname">
|
---|
| 509 | <xsl:choose>
|
---|
| 510 | <xsl:when test="contains(./para/ulink/@url,'.patch')">
|
---|
| 511 | <xsl:text>PATCH</xsl:text>
|
---|
| 512 | </xsl:when>
|
---|
| 513 | <xsl:otherwise>
|
---|
| 514 | <xsl:text>PACKAGE1</xsl:text>
|
---|
| 515 | </xsl:otherwise>
|
---|
| 516 | </xsl:choose>
|
---|
| 517 | </xsl:with-param>
|
---|
| 518 | </xsl:call-template>
|
---|
| 519 | </xsl:otherwise>
|
---|
| 520 | </xsl:choose>
|
---|
| 521 | </xsl:for-each>
|
---|
[e576789] | 522 | </xsl:template>
|
---|
| 523 |
|
---|
[642722f] | 524 | <!-- the simplelist case. Hopefully, the layout is one member for
|
---|
| 525 | url, one for md5 and others for various information, that we do not
|
---|
| 526 | use -->
|
---|
| 527 | <xsl:template match="simplelist">
|
---|
| 528 | <xsl:param name="varname" select="'PACKAGE1'"/>
|
---|
| 529 | <xsl:call-template name="download-file">
|
---|
| 530 | <xsl:with-param name="httpurl" select=".//ulink/@url"/>
|
---|
| 531 | <xsl:with-param name="md5">
|
---|
| 532 | <xsl:value-of select="substring-after(member[contains(string(),'MD5')],'sum: ')"/>
|
---|
| 533 | </xsl:with-param>
|
---|
| 534 | <xsl:with-param name="varname" select="$varname"/>
|
---|
| 535 | </xsl:call-template>
|
---|
| 536 | </xsl:template>
|
---|
[625cb14] | 537 |
|
---|
| 538 | <!--====================== Non package code =========================-->
|
---|
| 539 |
|
---|
| 540 | <xsl:template match="screen" mode="not-pack">
|
---|
| 541 | <xsl:choose>
|
---|
| 542 | <xsl:when test="ancestor::sect1[@id='postlfs-config-vimrc']">
|
---|
| 543 | <xsl:text>
|
---|
| 544 | cat > ~/.vimrc <<EOF
|
---|
| 545 | </xsl:text>
|
---|
| 546 | <xsl:apply-templates/>
|
---|
| 547 | <xsl:text>
|
---|
| 548 | EOF
|
---|
| 549 | </xsl:text>
|
---|
| 550 | </xsl:when>
|
---|
| 551 | <xsl:otherwise>
|
---|
| 552 | <xsl:apply-templates select="." mode="config"/>
|
---|
| 553 | </xsl:otherwise>
|
---|
| 554 | </xsl:choose>
|
---|
| 555 | </xsl:template>
|
---|
[e576789] | 556 | <!--======================== Commands code ==========================-->
|
---|
[c048987] | 557 | <!-- Code for installation instructions is in gen-install.xsl -->
|
---|
[e576789] | 558 |
|
---|
| 559 | <xsl:template match="screen">
|
---|
[c048987] | 560 | <xsl:choose>
|
---|
| 561 | <!-- instructions run as root (configuration mainly) -->
|
---|
| 562 | <xsl:when test="@role = 'root'">
|
---|
[aeb8539] | 563 | <!-- templates begin/end-root are in gen-install.xsl -->
|
---|
[c048987] | 564 | <xsl:if test="not(preceding-sibling::screen[1][@role='root'])">
|
---|
[aeb8539] | 565 | <xsl:call-template name="begin-root"/>
|
---|
[c048987] | 566 | </xsl:if>
|
---|
| 567 | <xsl:apply-templates mode="root"/>
|
---|
| 568 | <xsl:if test="not(following-sibling::screen[1][@role='root'])">
|
---|
[aeb8539] | 569 | <xsl:call-template name="end-root"/>
|
---|
[c048987] | 570 | </xsl:if>
|
---|
| 571 | </xsl:when>
|
---|
[67c3df4] | 572 | <!-- then all the instructions run as user -->
|
---|
[c048987] | 573 | <xsl:otherwise>
|
---|
| 574 | <xsl:apply-templates select="userinput"/>
|
---|
| 575 | </xsl:otherwise>
|
---|
| 576 | </xsl:choose>
|
---|
[e576789] | 577 | </xsl:template>
|
---|
| 578 |
|
---|
[70d73d1] | 579 | <xsl:template name="set-bootpkg-dir">
|
---|
| 580 | <xsl:param name="bootpkg" select="'bootscripts'"/>
|
---|
| 581 | <xsl:param name="url" select="''"/>
|
---|
[619b313] | 582 | <xsl:text>
|
---|
| 583 | BOOTPKG_DIR=blfs-</xsl:text>
|
---|
[70d73d1] | 584 | <xsl:copy-of select="$bootpkg"/>
|
---|
| 585 | <xsl:text>
|
---|
[619b313] | 586 |
|
---|
[1fa0dee] | 587 | BOOTSRC_DIR=${JH_SRC_ARCHIVE}${JH_SRC_SUBDIRS:+/${BOOTPKG_DIR}}
|
---|
| 588 | BOOTBUILD_DIR=${JH_BUILD_ROOT}${JH_BUILD_SUBDIRS:+/${BOOTPKG_DIR}}
|
---|
[973c767] | 589 | mkdir -p $BOOTSRC_DIR
|
---|
| 590 | mkdir -p $BOOTBUILD_DIR
|
---|
| 591 |
|
---|
| 592 | pushd $BOOTSRC_DIR
|
---|
[e576789] | 593 | URL=</xsl:text>
|
---|
[70d73d1] | 594 | <xsl:value-of select="$url"/>
|
---|
| 595 | <xsl:text>
|
---|
[e576789] | 596 | BOOTPACKG=$(basename $URL)
|
---|
[bbcdeab] | 597 | if [[ ! -f $BOOTPACKG ]] ; then
|
---|
[1fa0dee] | 598 | if [[ -f $JH_SRC_ARCHIVE/$BOOTPACKG ]] ; then
|
---|
| 599 | cp $JH_SRC_ARCHIVE/$BOOTPACKG $BOOTPACKG
|
---|
[bbcdeab] | 600 | else
|
---|
| 601 | wget -T 30 -t 5 $URL
|
---|
| 602 | fi
|
---|
[973c767] | 603 | rm -f $BOOTBUILD_DIR/unpacked
|
---|
[bbcdeab] | 604 | fi
|
---|
| 605 |
|
---|
[973c767] | 606 | cd $BOOTBUILD_DIR
|
---|
[e576789] | 607 | if [[ -e unpacked ]] ; then
|
---|
[f079f8f] | 608 | BOOTUNPACKDIR=`head -n1 unpacked | sed 's@^./@@;s@/.*@@'`
|
---|
| 609 | if ! [[ -d $BOOTUNPACKDIR ]]; then
|
---|
[973c767] | 610 | tar -xvf $BOOTSRC_DIR/$BOOTPACKG > unpacked
|
---|
[f079f8f] | 611 | BOOTUNPACKDIR=`head -n1 unpacked | sed 's@^./@@;s@/.*@@'`
|
---|
[e576789] | 612 | fi
|
---|
| 613 | else
|
---|
[973c767] | 614 | tar -xvf $BOOTSRC_DIR/$BOOTPACKG > unpacked
|
---|
[f079f8f] | 615 | BOOTUNPACKDIR=`head -n1 unpacked | sed 's@^./@@;s@/.*@@'`
|
---|
[e576789] | 616 | fi
|
---|
[619b313] | 617 | cd $BOOTUNPACKDIR</xsl:text>
|
---|
[70d73d1] | 618 | </xsl:template>
|
---|
| 619 |
|
---|
| 620 | <xsl:template match="screen" mode="config">
|
---|
| 621 | <xsl:if test="preceding-sibling::para[1]/xref[@linkend='bootscripts']">
|
---|
[aeb8539] | 622 | <!-- if the preceding "screen" tag is role="root", and we are role="root"
|
---|
| 623 | the end-root has not been called. So do it -->
|
---|
[619b313] | 624 | <xsl:if
|
---|
| 625 | test="preceding-sibling::screen[1][@role='root'] and @role='root'">
|
---|
[aeb8539] | 626 | <xsl:call-template name="end-root"/>
|
---|
| 627 | </xsl:if>
|
---|
[70d73d1] | 628 | <xsl:call-template name="set-bootpkg-dir">
|
---|
| 629 | <xsl:with-param name="bootpkg" select="'bootscripts'"/>
|
---|
| 630 | <xsl:with-param name="url"
|
---|
| 631 | select="id('bootscripts')//itemizedlist//ulink/@url"/>
|
---|
| 632 | </xsl:call-template>
|
---|
[aeb8539] | 633 | <!-- if the preceding "screen" tag is role="root", and we are role="root"
|
---|
| 634 | the begin-root will not be called. So do it -->
|
---|
[619b313] | 635 | <xsl:if
|
---|
| 636 | test="preceding-sibling::screen[1][@role='root'] and @role='root'">
|
---|
[aeb8539] | 637 | <xsl:call-template name="begin-root"/>
|
---|
| 638 | </xsl:if>
|
---|
[70d73d1] | 639 | </xsl:if>
|
---|
| 640 | <xsl:if test="preceding-sibling::para[1]/xref[@linkend='systemd-units']">
|
---|
[aeb8539] | 641 | <!-- if the preceding "screen" tag is role="root", and we are role="root"
|
---|
| 642 | the end-root has not been called. So do it -->
|
---|
[619b313] | 643 | <xsl:if
|
---|
| 644 | test="preceding-sibling::screen[1][@role='root'] and @role='root'">
|
---|
[aeb8539] | 645 | <xsl:call-template name="end-root"/>
|
---|
| 646 | </xsl:if>
|
---|
[70d73d1] | 647 | <xsl:call-template name="set-bootpkg-dir">
|
---|
| 648 | <xsl:with-param name="bootpkg" select="'systemd-units'"/>
|
---|
| 649 | <xsl:with-param name="url"
|
---|
| 650 | select="id('systemd-units')//itemizedlist//ulink/@url"/>
|
---|
| 651 | </xsl:call-template>
|
---|
[aeb8539] | 652 | <!-- if the preceding "screen" tag is role="root", and we are role="root"
|
---|
| 653 | the begin-root will not be called. So do it -->
|
---|
[619b313] | 654 | <xsl:if
|
---|
| 655 | test="preceding-sibling::screen[1][@role='root'] and @role='root'">
|
---|
[aeb8539] | 656 | <xsl:call-template name="begin-root"/>
|
---|
| 657 | </xsl:if>
|
---|
[e576789] | 658 | </xsl:if>
|
---|
| 659 | <xsl:apply-templates select='.'/>
|
---|
[70d73d1] | 660 | <xsl:if test="preceding-sibling::para[1]/xref[@linkend='bootscripts' or
|
---|
| 661 | @linkend='systemd-units']">
|
---|
[aeb8539] | 662 | <!-- if the next "screen" tag is role="root", and we are role="root"
|
---|
| 663 | the end-root has not been called. So do it -->
|
---|
[619b313] | 664 | <xsl:if
|
---|
| 665 | test="following-sibling::screen[1][@role='root'] and @role='root'">
|
---|
[aeb8539] | 666 | <xsl:call-template name="end-root"/>
|
---|
| 667 | </xsl:if>
|
---|
[619b313] | 668 | <xsl:text>
|
---|
| 669 | popd</xsl:text>
|
---|
[aeb8539] | 670 | <!-- if the next "screen" tag is role="root", and we are role="root"
|
---|
| 671 | the begin-root will not be called. So do it -->
|
---|
[619b313] | 672 | <xsl:if
|
---|
| 673 | test="following-sibling::screen[1][@role='root'] and @role='root'">
|
---|
[aeb8539] | 674 | <xsl:call-template name="begin-root"/>
|
---|
| 675 | </xsl:if>
|
---|
[e576789] | 676 | </xsl:if>
|
---|
| 677 | </xsl:template>
|
---|
| 678 |
|
---|
[c048987] | 679 | <xsl:template match="command" mode="installation">
|
---|
[619b313] | 680 | <xsl:param name="want-stats" select="false"/>
|
---|
[a743e57] | 681 | <xsl:variable name="ns" select="normalize-space(string())"/>
|
---|
[c048987] | 682 | <xsl:variable name="first"
|
---|
| 683 | select="not(
|
---|
| 684 | boolean(
|
---|
| 685 | preceding-sibling::command[contains(text(),'check') or
|
---|
| 686 | contains(text(),'test')]))"/>
|
---|
| 687 | <xsl:variable name="last"
|
---|
| 688 | select="not(
|
---|
| 689 | boolean(
|
---|
| 690 | following-sibling::command[contains(text(),'check') or
|
---|
| 691 | contains(text(),'test')]))"/>
|
---|
| 692 | <xsl:choose>
|
---|
[619b313] | 693 | <xsl:when test="$want-stats">
|
---|
[c048987] | 694 | <xsl:if test="$first">
|
---|
[67c3df4] | 695 | <xsl:text>
|
---|
[619b313] | 696 |
|
---|
[67c3df4] | 697 | echo Time after make: ${SECONDS} >> $INFOLOG
|
---|
| 698 | echo Size after make: $(sudo du -skx --exclude home /) >> $INFOLOG
|
---|
| 699 | echo Time before test: ${SECONDS} >> $INFOLOG
|
---|
[c048987] | 700 |
|
---|
[67c3df4] | 701 | </xsl:text>
|
---|
[c048987] | 702 | </xsl:if>
|
---|
| 703 | </xsl:when>
|
---|
| 704 | <xsl:otherwise>
|
---|
[619b313] | 705 | <xsl:text>
|
---|
| 706 | #</xsl:text>
|
---|
[c048987] | 707 | </xsl:otherwise>
|
---|
| 708 | </xsl:choose>
|
---|
| 709 | <xsl:choose>
|
---|
| 710 | <xsl:when test="contains($ns,'make')">
|
---|
| 711 | <xsl:value-of select="substring-before($ns,'make ')"/>
|
---|
| 712 | <xsl:text>make </xsl:text>
|
---|
| 713 | <xsl:if test="not(contains($ns,'-k'))">
|
---|
| 714 | <xsl:text>-k </xsl:text>
|
---|
| 715 | </xsl:if>
|
---|
| 716 | <xsl:value-of select="substring-after($ns,'make ')"/>
|
---|
| 717 | </xsl:when>
|
---|
| 718 | <xsl:otherwise>
|
---|
| 719 | <xsl:copy-of select="$ns"/>
|
---|
| 720 | </xsl:otherwise>
|
---|
| 721 | </xsl:choose>
|
---|
[619b313] | 722 | <xsl:if test="$want-stats">
|
---|
[c048987] | 723 | <xsl:text> >> $TESTLOG 2>&1</xsl:text>
|
---|
[e576789] | 724 | </xsl:if>
|
---|
[619b313] | 725 | <xsl:text> || true</xsl:text>
|
---|
| 726 | <xsl:if test="$want-stats">
|
---|
[c048987] | 727 | <xsl:text>
|
---|
[619b313] | 728 |
|
---|
[c048987] | 729 | echo Time after test: ${SECONDS} >> $INFOLOG
|
---|
| 730 | echo Size after test: $(sudo du -skx --exclude home /) >> $INFOLOG
|
---|
| 731 | echo Time before install: ${SECONDS} >> $INFOLOG
|
---|
| 732 | </xsl:text>
|
---|
| 733 | </xsl:if>
|
---|
[e576789] | 734 | </xsl:template>
|
---|
| 735 |
|
---|
| 736 | <xsl:template match="userinput">
|
---|
[619b313] | 737 | <xsl:text>
|
---|
| 738 | </xsl:text>
|
---|
[e576789] | 739 | <xsl:apply-templates/>
|
---|
| 740 | </xsl:template>
|
---|
| 741 |
|
---|
[619b313] | 742 | <xsl:template match="userinput" mode="root">
|
---|
| 743 | <xsl:text>
|
---|
| 744 | </xsl:text>
|
---|
| 745 | <xsl:apply-templates mode="root"/>
|
---|
| 746 | </xsl:template>
|
---|
| 747 |
|
---|
[aeb8539] | 748 | <xsl:template match="text()">
|
---|
| 749 | <xsl:call-template name="remove-ampersand">
|
---|
| 750 | <xsl:with-param name="out-string" select="string()"/>
|
---|
| 751 | </xsl:call-template>
|
---|
| 752 | </xsl:template>
|
---|
| 753 |
|
---|
[e576789] | 754 | <xsl:template match="text()" mode="root">
|
---|
| 755 | <xsl:call-template name="output-root">
|
---|
| 756 | <xsl:with-param name="out-string" select="string()"/>
|
---|
| 757 | </xsl:call-template>
|
---|
| 758 | </xsl:template>
|
---|
| 759 |
|
---|
| 760 | <xsl:template name="output-root">
|
---|
| 761 | <xsl:param name="out-string" select="''"/>
|
---|
| 762 | <xsl:choose>
|
---|
| 763 | <xsl:when test="contains($out-string,'$') and $sudo = 'y'">
|
---|
| 764 | <xsl:call-template name="output-root">
|
---|
| 765 | <xsl:with-param name="out-string"
|
---|
| 766 | select="substring-before($out-string,'$')"/>
|
---|
| 767 | </xsl:call-template>
|
---|
| 768 | <xsl:text>\$</xsl:text>
|
---|
| 769 | <xsl:call-template name="output-root">
|
---|
| 770 | <xsl:with-param name="out-string"
|
---|
| 771 | select="substring-after($out-string,'$')"/>
|
---|
| 772 | </xsl:call-template>
|
---|
| 773 | </xsl:when>
|
---|
| 774 | <xsl:when test="contains($out-string,'`') and $sudo = 'y'">
|
---|
| 775 | <xsl:call-template name="output-root">
|
---|
| 776 | <xsl:with-param name="out-string"
|
---|
| 777 | select="substring-before($out-string,'`')"/>
|
---|
| 778 | </xsl:call-template>
|
---|
| 779 | <xsl:text>\`</xsl:text>
|
---|
| 780 | <xsl:call-template name="output-root">
|
---|
| 781 | <xsl:with-param name="out-string"
|
---|
| 782 | select="substring-after($out-string,'`')"/>
|
---|
| 783 | </xsl:call-template>
|
---|
| 784 | </xsl:when>
|
---|
| 785 | <xsl:when test="contains($out-string,'\') and $sudo = 'y'">
|
---|
| 786 | <xsl:call-template name="output-root">
|
---|
| 787 | <xsl:with-param name="out-string"
|
---|
| 788 | select="substring-before($out-string,'\')"/>
|
---|
| 789 | </xsl:call-template>
|
---|
| 790 | <xsl:text>\\</xsl:text>
|
---|
| 791 | <xsl:call-template name="output-root">
|
---|
| 792 | <xsl:with-param name="out-string"
|
---|
| 793 | select="substring-after($out-string,'\')"/>
|
---|
| 794 | </xsl:call-template>
|
---|
| 795 | </xsl:when>
|
---|
| 796 | <xsl:otherwise>
|
---|
[aeb8539] | 797 | <xsl:call-template name="remove-ampersand">
|
---|
| 798 | <xsl:with-param name="out-string" select="$out-string"/>
|
---|
| 799 | </xsl:call-template>
|
---|
| 800 | <!-- <xsl:value-of select="$out-string"/> -->
|
---|
[e576789] | 801 | </xsl:otherwise>
|
---|
| 802 | </xsl:choose>
|
---|
| 803 | </xsl:template>
|
---|
| 804 |
|
---|
| 805 | <xsl:template match="replaceable">
|
---|
[625cb14] | 806 | <xsl:choose>
|
---|
| 807 | <!-- When adding a user to a group, the book uses "username" in a replaceable
|
---|
| 808 | tag. Replace by the user name only if not running as root -->
|
---|
| 809 | <xsl:when test="contains(string(),'username') and $sudo='y'">
|
---|
| 810 | <xsl:text>$USER</xsl:text>
|
---|
| 811 | </xsl:when>
|
---|
| 812 | <!-- The next three entries are for gpm. I guess those settings are OK
|
---|
| 813 | for a laptop or desktop. -->
|
---|
| 814 | <xsl:when test="contains(string(),'yourprotocol')">
|
---|
| 815 | <xsl:text>imps2</xsl:text>
|
---|
| 816 | </xsl:when>
|
---|
| 817 | <xsl:when test="contains(string(),'yourdevice')">
|
---|
| 818 | <xsl:text>/dev/input/mice</xsl:text>
|
---|
| 819 | </xsl:when>
|
---|
| 820 | <xsl:when test="contains(string(),'additional options')"/>
|
---|
| 821 | <!-- the book has four fields for language. The language param is
|
---|
| 822 | broken into four pieces above. We use the results here. -->
|
---|
| 823 | <xsl:when test="contains(string(),'<ll>')">
|
---|
| 824 | <xsl:copy-of select="$lang-ll"/>
|
---|
| 825 | </xsl:when>
|
---|
| 826 | <xsl:when test="contains(string(),'<CC>')">
|
---|
| 827 | <xsl:copy-of select="$lang-CC"/>
|
---|
| 828 | </xsl:when>
|
---|
| 829 | <xsl:when test="contains(string(),'<charmap>')">
|
---|
| 830 | <xsl:copy-of select="$lang-charmap"/>
|
---|
| 831 | </xsl:when>
|
---|
| 832 | <xsl:when test="contains(string(),'@modifier')">
|
---|
| 833 | <xsl:copy-of select="$lang-modifier"/>
|
---|
| 834 | </xsl:when>
|
---|
| 835 | <!-- At several places, the number of jobs is given as "N" in a replaceable
|
---|
| 836 | tag. We either detect "N" alone or <N> Replace N with 4. -->
|
---|
| 837 | <xsl:when test="contains(string(),'<N>') or string()='N'">
|
---|
| 838 | <xsl:text>4</xsl:text>
|
---|
| 839 | </xsl:when>
|
---|
| 840 | <!-- Mercurial config file uses user_name. Replace only if non root.
|
---|
| 841 | Add a bogus mail field. That works for the proposed tests anyway. -->
|
---|
| 842 | <xsl:when test="contains(string(),'user_name') and $sudo='y'">
|
---|
| 843 | <xsl:text>$USER ${USER}@mail.bogus</xsl:text>
|
---|
| 844 | </xsl:when>
|
---|
| 845 | <!-- Use the config for Gtk+3 as is -->
|
---|
| 846 | <xsl:when test="ancestor::sect1[@id='gtk3']">
|
---|
| 847 | <xsl:copy-of select="string()"/>
|
---|
| 848 | </xsl:when>
|
---|
| 849 | <!-- Give 1Gb to fop. Hopefully, nobody has less RAM nowadays. -->
|
---|
| 850 | <xsl:when test="contains(string(),'RAM_Installed')">
|
---|
| 851 | <xsl:text>1024</xsl:text>
|
---|
| 852 | </xsl:when>
|
---|
| 853 | <xsl:otherwise>
|
---|
[e576789] | 854 | <xsl:text>**EDITME</xsl:text>
|
---|
| 855 | <xsl:apply-templates/>
|
---|
| 856 | <xsl:text>EDITME**</xsl:text>
|
---|
[625cb14] | 857 | </xsl:otherwise>
|
---|
| 858 | </xsl:choose>
|
---|
[e576789] | 859 | </xsl:template>
|
---|
| 860 |
|
---|
| 861 | <xsl:template match="replaceable" mode="root">
|
---|
[625cb14] | 862 | <xsl:apply-templates select="."/>
|
---|
[e576789] | 863 | </xsl:template>
|
---|
| 864 |
|
---|
[67c3df4] | 865 | <xsl:template name="output-destdir">
|
---|
| 866 | <xsl:apply-templates
|
---|
| 867 | select="userinput|following-sibling::screen[@role='root']/userinput"
|
---|
| 868 | mode="destdir"/>
|
---|
| 869 | <xsl:text>
|
---|
[619b313] | 870 |
|
---|
[67c3df4] | 871 | echo Time after install: ${SECONDS} >> $INFOLOG
|
---|
| 872 | echo Size after install: $(sudo du -skx --exclude home /) >> $INFOLOG
|
---|
| 873 | </xsl:text>
|
---|
| 874 | </xsl:template>
|
---|
| 875 |
|
---|
| 876 | <xsl:template match="userinput" mode="destdir">
|
---|
| 877 | <xsl:choose>
|
---|
| 878 | <xsl:when test="./literal">
|
---|
| 879 | <xsl:call-template name="outputpkgdest">
|
---|
| 880 | <xsl:with-param name="outputstring" select="text()[1]"/>
|
---|
| 881 | </xsl:call-template>
|
---|
| 882 | <xsl:apply-templates select="literal"/>
|
---|
| 883 | <xsl:call-template name="outputpkgdest">
|
---|
| 884 | <xsl:with-param name="outputstring" select="text()[2]"/>
|
---|
| 885 | </xsl:call-template>
|
---|
| 886 | </xsl:when>
|
---|
| 887 | <xsl:otherwise>
|
---|
| 888 | <xsl:call-template name="outputpkgdest">
|
---|
| 889 | <xsl:with-param name="outputstring" select="string()"/>
|
---|
| 890 | </xsl:call-template>
|
---|
| 891 | </xsl:otherwise>
|
---|
| 892 | </xsl:choose>
|
---|
| 893 | </xsl:template>
|
---|
| 894 |
|
---|
| 895 | <xsl:template name="outputpkgdest">
|
---|
| 896 | <xsl:param name="outputstring" select="'foo'"/>
|
---|
| 897 | <xsl:choose>
|
---|
| 898 | <xsl:when test="contains($outputstring,'make ')">
|
---|
| 899 | <xsl:choose>
|
---|
| 900 | <xsl:when test="not(starts-with($outputstring,'make'))">
|
---|
| 901 | <xsl:call-template name="outputpkgdest">
|
---|
| 902 | <xsl:with-param name="outputstring"
|
---|
| 903 | select="substring-before($outputstring,'make')"/>
|
---|
| 904 | </xsl:call-template>
|
---|
| 905 | <xsl:call-template name="outputpkgdest">
|
---|
| 906 | <xsl:with-param
|
---|
| 907 | name="outputstring"
|
---|
| 908 | select="substring-after($outputstring,
|
---|
| 909 | substring-before($outputstring,'make'))"/>
|
---|
| 910 | </xsl:call-template>
|
---|
| 911 | </xsl:when>
|
---|
| 912 | <xsl:otherwise>
|
---|
[619b313] | 913 | <xsl:text>
|
---|
| 914 | make DESTDIR=$PKG_DEST</xsl:text>
|
---|
[67c3df4] | 915 | <xsl:call-template name="outputpkgdest">
|
---|
| 916 | <xsl:with-param
|
---|
| 917 | name="outputstring"
|
---|
| 918 | select="substring-after($outputstring,'make')"/>
|
---|
| 919 | </xsl:call-template>
|
---|
| 920 | </xsl:otherwise>
|
---|
| 921 | </xsl:choose>
|
---|
| 922 | </xsl:when>
|
---|
| 923 | <xsl:when test="contains($outputstring,'ninja install')">
|
---|
| 924 | <xsl:choose>
|
---|
| 925 | <xsl:when test="not(starts-with($outputstring,'ninja install'))">
|
---|
| 926 | <xsl:call-template name="outputpkgdest">
|
---|
| 927 | <xsl:with-param name="outputstring"
|
---|
| 928 | select="substring-before($outputstring,'ninja install')"/>
|
---|
| 929 | </xsl:call-template>
|
---|
| 930 | <xsl:call-template name="outputpkgdest">
|
---|
| 931 | <xsl:with-param
|
---|
| 932 | name="outputstring"
|
---|
| 933 | select="substring-after($outputstring,
|
---|
| 934 | substring-before($outputstring,'ninja install'))"/>
|
---|
| 935 | </xsl:call-template>
|
---|
| 936 | </xsl:when>
|
---|
| 937 | <xsl:otherwise>
|
---|
[619b313] | 938 | <xsl:text>
|
---|
| 939 | DESTDIR=$PKG_DEST ninja</xsl:text>
|
---|
[67c3df4] | 940 | <xsl:call-template name="outputpkgdest">
|
---|
| 941 | <xsl:with-param
|
---|
| 942 | name="outputstring"
|
---|
| 943 | select="substring-after($outputstring,'ninja')"/>
|
---|
| 944 | </xsl:call-template>
|
---|
| 945 | </xsl:otherwise>
|
---|
| 946 | </xsl:choose>
|
---|
| 947 | </xsl:when>
|
---|
| 948 | <xsl:otherwise> <!-- no make nor ninja in this string -->
|
---|
| 949 | <xsl:choose>
|
---|
| 950 | <xsl:when test="contains($outputstring,'>/') and
|
---|
| 951 | not(contains(substring-before($outputstring,'>/'),' /'))">
|
---|
[aeb8539] | 952 | <xsl:call-template name="remove-ampersand">
|
---|
| 953 | <xsl:with-param name="out-string"
|
---|
| 954 | select="substring-before($outputstring,'>/')"/>
|
---|
| 955 | </xsl:call-template>
|
---|
| 956 | <!-- <xsl:value-of select="substring-before($outputstring,'>/')"/>-->
|
---|
[67c3df4] | 957 | <xsl:text>>$PKG_DEST/</xsl:text>
|
---|
| 958 | <xsl:call-template name="outputpkgdest">
|
---|
| 959 | <xsl:with-param name="outputstring" select="substring-after($outputstring,'>/')"/>
|
---|
| 960 | </xsl:call-template>
|
---|
| 961 | </xsl:when>
|
---|
| 962 | <xsl:when test="contains($outputstring,' /')">
|
---|
[aeb8539] | 963 | <xsl:call-template name="remove-ampersand">
|
---|
| 964 | <xsl:with-param name="out-string"
|
---|
| 965 | select="substring-before($outputstring,' /')"/>
|
---|
| 966 | </xsl:call-template>
|
---|
| 967 | <!-- <xsl:value-of select="substring-before($outputstring,' /')"/>-->
|
---|
[67c3df4] | 968 | <xsl:text> $PKG_DEST/</xsl:text>
|
---|
| 969 | <xsl:call-template name="outputpkgdest">
|
---|
| 970 | <xsl:with-param name="outputstring" select="substring-after($outputstring,' /')"/>
|
---|
| 971 | </xsl:call-template>
|
---|
| 972 | </xsl:when>
|
---|
| 973 | <xsl:otherwise>
|
---|
[aeb8539] | 974 | <xsl:call-template name="remove-ampersand">
|
---|
| 975 | <xsl:with-param name="out-string" select="$outputstring"/>
|
---|
| 976 | </xsl:call-template>
|
---|
| 977 | <!-- <xsl:value-of select="$outputstring"/>-->
|
---|
[67c3df4] | 978 | </xsl:otherwise>
|
---|
| 979 | </xsl:choose>
|
---|
| 980 | </xsl:otherwise>
|
---|
| 981 | </xsl:choose>
|
---|
| 982 | </xsl:template>
|
---|
| 983 |
|
---|
[aeb8539] | 984 | <xsl:template name="remove-ampersand">
|
---|
| 985 | <xsl:param name="out-string" select="''"/>
|
---|
| 986 | <xsl:choose>
|
---|
| 987 | <xsl:when test="contains($out-string,'&&
')">
|
---|
| 988 | <xsl:variable name="instruction-before">
|
---|
| 989 | <xsl:call-template name="last-line">
|
---|
| 990 | <xsl:with-param
|
---|
| 991 | name="instructions"
|
---|
| 992 | select="substring-before($out-string,'&&
')"/>
|
---|
| 993 | </xsl:call-template>
|
---|
| 994 | </xsl:variable>
|
---|
| 995 | <xsl:call-template name="remove-end-space">
|
---|
| 996 | <xsl:with-param
|
---|
| 997 | name="instructions"
|
---|
| 998 | select="substring-before($out-string,'&&
')"/>
|
---|
| 999 | </xsl:call-template>
|
---|
| 1000 | <xsl:if test="contains($instruction-before,' ]') or
|
---|
| 1001 | contains($instruction-before,'test ') or
|
---|
| 1002 | contains($instruction-before,'pgrep -l')">
|
---|
| 1003 | <xsl:text> &&</xsl:text>
|
---|
| 1004 | </xsl:if>
|
---|
[619b313] | 1005 | <xsl:text>
|
---|
| 1006 | </xsl:text>
|
---|
[aeb8539] | 1007 | <xsl:call-template name="remove-ampersand">
|
---|
| 1008 | <xsl:with-param name="out-string"
|
---|
| 1009 | select="substring-after($out-string,
|
---|
| 1010 | '&&
')"/>
|
---|
| 1011 | </xsl:call-template>
|
---|
| 1012 | </xsl:when>
|
---|
| 1013 | <xsl:otherwise>
|
---|
| 1014 | <xsl:copy-of select="$out-string"/>
|
---|
| 1015 | </xsl:otherwise>
|
---|
| 1016 | </xsl:choose>
|
---|
| 1017 | </xsl:template>
|
---|
| 1018 |
|
---|
| 1019 | <xsl:template name="last-line">
|
---|
| 1020 | <xsl:param name="instructions" select="''"/>
|
---|
| 1021 | <xsl:choose>
|
---|
| 1022 | <xsl:when test="contains($instructions,'
')">
|
---|
| 1023 | <xsl:call-template name="last-line">
|
---|
| 1024 | <xsl:with-param
|
---|
| 1025 | name="instructions"
|
---|
| 1026 | select="substring-after($instructions,'
')"/>
|
---|
| 1027 | </xsl:call-template>
|
---|
| 1028 | </xsl:when>
|
---|
| 1029 | <xsl:otherwise>
|
---|
| 1030 | <xsl:copy-of select="normalize-space($instructions)"/>
|
---|
| 1031 | </xsl:otherwise>
|
---|
| 1032 | </xsl:choose>
|
---|
| 1033 | </xsl:template>
|
---|
| 1034 |
|
---|
| 1035 | <xsl:template name="remove-end-space">
|
---|
| 1036 | <xsl:param name="instructions" select="''"/>
|
---|
| 1037 | <xsl:choose>
|
---|
[619b313] | 1038 | <xsl:when
|
---|
| 1039 | test="substring($instructions,string-length($instructions))=' '">
|
---|
[aeb8539] | 1040 | <xsl:call-template name="remove-end-space">
|
---|
| 1041 | <xsl:with-param
|
---|
| 1042 | name="instructions"
|
---|
[619b313] | 1043 | select="substring($instructions,
|
---|
| 1044 | 1,
|
---|
| 1045 | string-length($instructions)-1)"/>
|
---|
[aeb8539] | 1046 | </xsl:call-template>
|
---|
| 1047 | </xsl:when>
|
---|
| 1048 | <xsl:otherwise>
|
---|
[619b313] | 1049 | <xsl:copy-of select="$instructions"/>
|
---|
[aeb8539] | 1050 | </xsl:otherwise>
|
---|
| 1051 | </xsl:choose>
|
---|
| 1052 | </xsl:template>
|
---|
| 1053 |
|
---|
[e576789] | 1054 | </xsl:stylesheet>
|
---|