- Timestamp:
- 04/16/2019 07:30:02 AM (5 years ago)
- Branches:
- ablfs-more, legacy, trunk
- Children:
- 2e2ac74
- Parents:
- bc2f591
- Location:
- BLFS/xsl
- Files:
-
- 1 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
BLFS/xsl/scripts.xsl
rbc2f591 rc048987 10 10 <!-- XSLT stylesheet to create shell scripts from "linear build" BLFS books. --> 11 11 12 <!-- Check whether the book is sysv or systemd --> 12 <!-- parameters and global variables --> 13 <!-- Check whether the book is sysv or systemd --> 13 14 <xsl:variable name="rev"> 14 15 <xsl:choose> … … 81 82 </xsl:variable> 82 83 83 <xsl:variable name="list-stat-norm" 84 select="concat(' ', normalize-space($list-stat),' ')"/> 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 ========================--> 85 96 86 97 <xsl:template match="/"> 87 <xsl:apply-templates select="//sect1"/> 98 <xsl:apply-templates select="//sect1[@id != 'bootscripts' and 99 @id != 'systemd-units']"/> 88 100 </xsl:template> 89 101 … … 92 104 <xsl:template match="sect1"> 93 105 94 <xsl:if test="@id != 'bootscripts' and @id != 'systemd-units'"> 95 <!-- The file names --> 96 <xsl:variable name="filename" select="@id"/> 97 98 <!-- The build order --> 99 <xsl:variable name="position" select="position()"/> 100 <xsl:variable name="order"> 101 <xsl:choose> 102 <xsl:when test="string-length($position) = 1"> 103 <xsl:text>00</xsl:text> 104 <xsl:value-of select="$position"/> 105 </xsl:when> 106 <xsl:when test="string-length($position) = 2"> 107 <xsl:text>0</xsl:text> 108 <xsl:value-of select="$position"/> 109 </xsl:when> 110 <xsl:otherwise> 111 <xsl:value-of select="$position"/> 112 </xsl:otherwise> 113 </xsl:choose> 114 </xsl:variable> 106 <!-- The file names --> 107 <xsl:variable name="filename" select="@id"/> 108 109 <!-- The build order --> 110 <xsl:variable name="position" select="position()"/> 111 <xsl:variable name="order"> 112 <xsl:choose> 113 <xsl:when test="string-length($position) = 1"> 114 <xsl:text>00</xsl:text> 115 <xsl:value-of select="$position"/> 116 </xsl:when> 117 <xsl:when test="string-length($position) = 2"> 118 <xsl:text>0</xsl:text> 119 <xsl:value-of select="$position"/> 120 </xsl:when> 121 <xsl:otherwise> 122 <xsl:value-of select="$position"/> 123 </xsl:otherwise> 124 </xsl:choose> 125 </xsl:variable> 115 126 116 127 <!-- Depuration code --> 117 118 119 120 121 122 123 124 125 126 127 128 <xsl:message> 129 <xsl:text>SCRIPT is </xsl:text> 130 <xsl:value-of select="concat($order,'-z-',$filename)"/> 131 <xsl:text>
 FTPDIR is </xsl:text> 132 <xsl:value-of select="$filename"/> 133 <xsl:text>

</xsl:text> 134 </xsl:message> 135 136 <!-- Creating the scripts --> 137 <exsl:document href="{$order}-z-{$filename}" method="text"> 138 <xsl:text>#!/bin/bash 128 139 set -e 129 140 unset MAKELEVEL 130 131 </xsl:text> 132 133 134 135 136 137 138 139 140 141 <!-- the above is needed for some packages --> 142 </xsl:text> 143 <xsl:choose> 144 <!-- Package page --> 145 <xsl:when test="sect2[@role='package']"> 146 <!-- We build in a subdirectory, whose name may be needed 147 if using package management (see envars.conf), so 148 "export" it --> 149 <xsl:text>export JH_PKG_DIR=</xsl:text> 150 <xsl:value-of select="$filename"/> 151 <xsl:text> 141 152 SRC_DIR=${JH_SRC_ARCHIVE}${JH_SRC_SUBDIRS:+/${JH_PKG_DIR}} 142 153 BUILD_DIR=${JH_BUILD_ROOT}${JH_BUILD_SUBDIRS:+/${JH_PKG_DIR}} … … 147 158 148 159 <!-- If stats are requested, include some definitions and intitializations --> 149 150 160 <xsl:if test="contains($list-stat-norm,concat(' ',@id,' '))"> 161 <xsl:text>INFOLOG=$(pwd)/info-${JH_PKG_DIR} 151 162 TESTLOG=$(pwd)/test-${JH_PKG_DIR} 152 163 unset MAKEFLAGS 153 164 #MAKEFLAGS=-j4 154 165 echo MAKEFLAGS: $MAKEFLAGS > $INFOLOG 155 > $TESTLOG166 : > $TESTLOG 156 167 PKG_DEST=${BUILD_DIR}/dest 157 168 rm -rf $PKG_DEST 158 169 159 170 </xsl:text> 160 161 162 163 164 171 </xsl:if> 172 <!-- Download code and build commands --> 173 <xsl:apply-templates select="sect2"/> 174 <!-- Clean-up --> 175 <xsl:text>cd $BUILD_DIR 165 176 [[ -n "$JH_KEEP_FILES" ]] || </xsl:text> 166 <!-- In some case, some files in the build tree are owned 167 by root --> 168 <xsl:if test="$sudo='y'"> 169 <xsl:text>sudo </xsl:text> 170 </xsl:if> 171 <xsl:text>rm -rf $JH_UNPACKDIR unpacked

</xsl:text> 172 </xsl:when> 173 <!-- Non-package page --> 174 <xsl:otherwise> 175 <xsl:apply-templates select=".//screen" mode="not-pack"/> 176 </xsl:otherwise> 177 </xsl:choose> 178 <xsl:text>exit</xsl:text> 179 </exsl:document> 180 </xsl:if><!-- id!=bootscript or id!=systemd-units --> 177 <!-- In some case, some files in the build tree are owned 178 by root --> 179 <xsl:if test="$sudo='y'"> 180 <xsl:text>sudo </xsl:text> 181 </xsl:if> 182 <xsl:text>rm -rf $JH_UNPACKDIR unpacked

</xsl:text> 183 </xsl:when> 184 <!-- Non-package page --> 185 <xsl:otherwise> 186 <xsl:apply-templates select=".//screen" mode="not-pack"/> 187 </xsl:otherwise> 188 </xsl:choose> 189 <xsl:text>exit</xsl:text> 190 </exsl:document> 181 191 </xsl:template> 182 192 … … 185 195 <xsl:template match="sect2"> 186 196 <xsl:choose> 197 187 198 <xsl:when test="@role = 'package'"> 188 199 <xsl:text>cd $SRC_DIR … … 191 202 <xsl:apply-templates select="bridgehead[@renderas='sect3']"/> 192 203 <xsl:text>
</xsl:text> 193 </xsl:when> 204 </xsl:when><!-- @role="package" --> 205 194 206 <xsl:when test="@role = 'qt4-prefix' or @role = 'qt5-prefix'"> 195 207 <xsl:apply-templates select=".//screen[./userinput]"/> 196 208 </xsl:when> 209 197 210 <xsl:when test="@role = 'installation'"> 198 211 <xsl:text> … … 249 262 250 263 <xsl:apply-templates 264 mode="installation" 251 265 select=".//screen[not(@role = 'nodump') and ./userinput] | 252 .//para/command"/> 266 .//para/command[contains(text(),'check') or 267 contains(text(),'test')]"/> 253 268 <xsl:if test="$sudo = 'y'"> 254 269 <xsl:text>sudo /sbin/</xsl:text> 255 270 </xsl:if> 256 271 <xsl:text>ldconfig

</xsl:text> 257 </xsl:when> 272 </xsl:when><!-- @role="installation" --> 273 258 274 <xsl:when test="@role = 'configuration'"> 259 275 <xsl:apply-templates mode="config" 260 276 select=".//screen[not(@role = 'nodump') and ./userinput]"/> 261 </xsl:when> 277 </xsl:when><!-- @role="configuration" --> 278 262 279 </xsl:choose> 263 280 </xsl:template> … … 518 535 </xsl:template> 519 536 <!--======================== Commands code ==========================--> 537 <!-- Code for installation instructions is in gen-install.xsl --> 520 538 521 539 <xsl:template match="screen"> 522 <xsl:if test="child::* = userinput and not(@role = 'nodump')"> 523 <xsl:choose> 524 <!-- First the case of installation instructions --> 525 <xsl:when test="@role = 'root' and 526 ancestor::sect2[@role='installation'] and 527 not(contains(string(),'useradd')) and 528 not(contains(string(),'usermod')) and 529 not(contains(string(),'icon-cache')) and 530 not(contains(string(),'desktop-database')) and 531 not(contains(string(),'compile-schemas')) and 532 not(contains(string(),'groupadd'))"> 533 <xsl:if test="not(preceding-sibling::screen[1][@role='root'])"> 534 <xsl:if test="contains($list-stat-norm, 535 concat(' ', 536 ancestor::sect1/@id, 537 ' '))"> 538 <xsl:call-template name="output-destdir"/> 539 </xsl:if> 540 <xsl:if test="$sudo = 'y'"> 541 <xsl:text>sudo -E sh << ROOT_EOF
</xsl:text> 542 </xsl:if> 543 <xsl:if test="$wrap-install = 'y'"> 544 <xsl:text>if [ -r "$JH_PACK_INSTALL" ]; then 545 source $JH_PACK_INSTALL 546 export -f wrapInstall 547 export -f packInstall 548 fi 549 wrapInstall ' 550 </xsl:text> 551 </xsl:if> 540 <xsl:choose> 541 <!-- instructions run as root (configuration mainly) --> 542 <xsl:when test="@role = 'root'"> 543 <xsl:if test="not(preceding-sibling::screen[1][@role='root'])"> 544 <xsl:if test="$sudo = 'y'"> 545 <xsl:text>sudo -E sh << ROOT_EOF
</xsl:text> 552 546 </xsl:if> 553 <xsl:apply-templates mode="root"/> 554 <xsl:if test="not(following-sibling::screen[1][@role='root'])"> 555 <xsl:if test="$del-la-files = 'y'"> 556 <xsl:call-template name="output-root"> 557 <xsl:with-param name="out-string" select="$la-files-instr"/> 558 </xsl:call-template> 559 </xsl:if> 560 <xsl:if test="$wrap-install = 'y'"> 561 <xsl:text>'
packInstall</xsl:text> 562 </xsl:if> 563 <xsl:if test="$sudo = 'y'"> 564 <xsl:text>
ROOT_EOF</xsl:text> 565 </xsl:if> 547 </xsl:if> 548 <xsl:apply-templates mode="root"/> 549 <xsl:if test="not(following-sibling::screen[1][@role='root'])"> 550 <xsl:if test="$sudo = 'y'"> 551 <xsl:text>
ROOT_EOF</xsl:text> 566 552 </xsl:if> 567 </xsl:when> 568 <!-- then the case of other instructions run as root (configuration mainly) --> 569 <xsl:when test="@role = 'root'"> 570 <xsl:if test="not(preceding-sibling::screen[1][@role='root'])"> 571 <xsl:if test="$sudo = 'y'"> 572 <xsl:text>sudo -E sh << ROOT_EOF
</xsl:text> 573 </xsl:if> 574 </xsl:if> 575 <xsl:apply-templates mode="root"/> 576 <xsl:if test="not(following-sibling::screen[1][@role='root'])"> 577 <xsl:if test="$sudo = 'y'"> 578 <xsl:text>
ROOT_EOF</xsl:text> 579 </xsl:if> 580 </xsl:if> 581 </xsl:when> 553 </xsl:if> 554 </xsl:when> 582 555 <!-- then all the instructions run as user --> 583 <xsl:otherwise> 584 <xsl:apply-templates select="userinput"/> 585 </xsl:otherwise> 586 </xsl:choose> 587 <xsl:text>
</xsl:text> 588 </xsl:if> 556 <xsl:otherwise> 557 <xsl:apply-templates select="userinput"/> 558 </xsl:otherwise> 559 </xsl:choose> 560 <xsl:text>
</xsl:text> 589 561 </xsl:template> 590 562 … … 653 625 </xsl:template> 654 626 655 <xsl:template match=" para/command">627 <xsl:template match="command" mode="installation"> 656 628 <xsl:variable name="ns" select="normalize-space(string())"/> 657 <xsl:if test="contains($ns,'test') or 658 contains($ns,'check')"> 659 <xsl:choose> 660 <xsl:when test="contains($list-stat-norm, 661 concat(' ',ancestor::sect1/@id,' '))"> 629 <xsl:variable name="first" 630 select="not( 631 boolean( 632 preceding-sibling::command[contains(text(),'check') or 633 contains(text(),'test')]))"/> 634 <xsl:variable name="last" 635 select="not( 636 boolean( 637 following-sibling::command[contains(text(),'check') or 638 contains(text(),'test')]))"/> 639 <xsl:choose> 640 <xsl:when test="contains($list-stat-norm, 641 concat(' ',ancestor::sect1/@id,' '))"> 642 <xsl:if test="$first"> 662 643 <xsl:text> 663 644 echo Time after make: ${SECONDS} >> $INFOLOG 664 645 echo Size after make: $(sudo du -skx --exclude home /) >> $INFOLOG 665 646 echo Time before test: ${SECONDS} >> $INFOLOG 666 </xsl:text> 667 </xsl:when> 668 <xsl:otherwise> 669 <xsl:text>#</xsl:text> 670 </xsl:otherwise> 671 </xsl:choose> 672 <xsl:choose> 673 <xsl:when test="contains($ns,'make')"> 674 <xsl:value-of select="substring-before($ns,'make ')"/> 675 <xsl:text>make </xsl:text> 676 <xsl:if test="not(contains($ns,'-k'))"> 677 <xsl:text>-k </xsl:text> 678 </xsl:if> 679 <xsl:value-of select="substring-after($ns,'make ')"/> 680 </xsl:when> 681 <xsl:otherwise> 682 <xsl:copy-of select="$ns"/> 683 </xsl:otherwise> 684 </xsl:choose> 647 648 </xsl:text> 649 </xsl:if> 650 </xsl:when> 651 <xsl:otherwise> 652 <xsl:text>#</xsl:text> 653 </xsl:otherwise> 654 </xsl:choose> 655 <xsl:choose> 656 <xsl:when test="contains($ns,'make')"> 657 <xsl:value-of select="substring-before($ns,'make ')"/> 658 <xsl:text>make </xsl:text> 659 <xsl:if test="not(contains($ns,'-k'))"> 660 <xsl:text>-k </xsl:text> 661 </xsl:if> 662 <xsl:value-of select="substring-after($ns,'make ')"/> 663 </xsl:when> 664 <xsl:otherwise> 665 <xsl:copy-of select="$ns"/> 666 </xsl:otherwise> 667 </xsl:choose> 668 <xsl:if test="contains($list-stat-norm, 669 concat(' ',ancestor::sect1/@id,' '))"> 670 <xsl:text> >> $TESTLOG 2>&1</xsl:text> 671 </xsl:if> 672 <xsl:text> || true
</xsl:text> 685 673 <xsl:if test="contains($list-stat-norm, 686 concat(' ',ancestor::sect1/@id,' '))"> 687 <xsl:text> >> $TESTLOG 2>&1</xsl:text> 688 </xsl:if> 689 <xsl:text> || true
</xsl:text> 690 </xsl:if> 674 concat(' ',ancestor::sect1/@id,' ')) and $last"> 675 <xsl:text> 676 echo Time after test: ${SECONDS} >> $INFOLOG 677 echo Size after test: $(sudo du -skx --exclude home /) >> $INFOLOG 678 echo Time before install: ${SECONDS} >> $INFOLOG 679 680 </xsl:text> 681 </xsl:if> 691 682 </xsl:template> 692 683 … … 701 692 </xsl:template> 702 693 703 <xsl:variable name="APOS">'</xsl:variable>704 705 694 <xsl:template name="output-root"> 706 695 <xsl:param name="out-string" select="''"/> … … 748 737 <xsl:with-param name="out-string" 749 738 select="substring-after($out-string,'\')"/> 750 </xsl:call-template>751 </xsl:when>752 <xsl:when test="contains($out-string,string($APOS))753 and $wrap-install = 'y'754 and ancestor::sect2[@role='installation']">755 <xsl:call-template name="output-root">756 <xsl:with-param name="out-string"757 select="substring-before($out-string,string($APOS))"/>758 </xsl:call-template>759 <xsl:text>'\''</xsl:text>760 <xsl:call-template name="output-root">761 <xsl:with-param name="out-string"762 select="substring-after($out-string,string($APOS))"/>763 739 </xsl:call-template> 764 740 </xsl:when> … … 830 806 831 807 <xsl:template name="output-destdir"> 832 <!-- Hopefully, the current node is the first screen with role equal to root.833 We first output stats, since we are only called if stats are needed.834 then we output DESTDIR instructions,etc -->835 <xsl:text>836 echo Time after tests: ${SECONDS} >> $INFOLOG837 echo Size after tests: $(sudo du -skx --exclude home /) >> $INFOLOG838 echo Time before install: ${SECONDS} >> $INFOLOG839 </xsl:text>840 808 <xsl:apply-templates 841 809 select="userinput|following-sibling::screen[@role='root']/userinput"
Note:
See TracChangeset
for help on using the changeset viewer.