Changeset 67c3df4 for BLFS


Ignore:
Timestamp:
02/05/2018 06:12:17 PM (6 years ago)
Author:
Pierre Labastie <pierre@…>
Branches:
ablfs-more, legacy, trunk
Children:
7bc70cd
Parents:
ad747ed
Message:

Add stats to jhalfs-blfs. NB: due to book layout, far from perfect...

Location:
BLFS
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • BLFS/gen_pkg_book.sh

    rad747ed r67c3df4  
    5252      WRAP_INSTALL=*  | \
    5353      DEL_LA_FILES=*  | \
     54      STATS=*         | \
    5455      SUDO=*  )  eval ${REPLY} # Define/set a global variable..
    5556                      continue ;;
     
    7273  WRAP_INSTALL=${WRAP_INSTALL:-n}
    7374  DEL_LA_FILES=${DEL_LA_FILES:-n}
     75  STATS=${STATS:-n}
    7476}
    7577
     
    9597#
    9698#--------------------------#
    97 generate_deps() {        #
     99generate_deps() {          #
    98100#--------------------------#
    99101
     
    200202echo -en "\n\tGenerating the build scripts ...\n"
    201203rm -rf scripts
     204if test $STATS = y; then
     205  LIST_STAT="${TARGET[*]}"
     206else
     207  LIST_STAT=""
     208fi
    202209xsltproc --xinclude --nonet \
    203210         --stringparam sudo "$SUDO" \
    204211         --stringparam wrap-install "$WRAP_INSTALL" \
    205212         --stringparam del-la-files "$DEL_LA_FILES" \
     213         --stringparam list-stat "$LIST_STAT" \
    206214         -o ./scripts/ ${MakeScripts} \
    207215         ${BookXml}
  • BLFS/xsl/gen_config.xsl

    rad747ed r67c3df4  
    8080                This option should be active on any system mixing libtool
    8181                and meson build systems. ImageMagick .la files are preserved.
     82
     83config  STATS
     84        bool "Generate statistics for the requested package(s)"
     85        default n
     86        help
     87                If you want timing and memory footprint statistics to be
     88                generated for the packages you build (not their dependencies),
     89                set this option to y.
    8290</xsl:text>
    8391  </xsl:template>
  • BLFS/xsl/scripts.xsl

    rad747ed r67c3df4  
    2626  <xsl:param name="wrap-install" select="'n'"/>
    2727
     28  <!-- list of packages needing stats -->
     29  <xsl:param name="list-stat" select="''"/>
     30
    2831  <!-- Remove libtool .la files -->
    2932  <xsl:param name="del-la-files" select="'y'"/>
     
    4043
    4144</xsl:variable>
     45
     46<xsl:variable name="list-stat-norm"
     47              select="concat(' ', normalize-space($list-stat),' ')"/>
     48
    4249  <xsl:template match="/">
    4350    <xsl:apply-templates select="//sect1"/>
     
    97104
    98105</xsl:text>
     106
     107<!-- If stats are requested, include some definitions and intitializations -->
     108            <xsl:if test="contains($list-stat-norm,concat(' ',@id,' '))">
     109              <xsl:text>INFOLOG=$(pwd)/info-${PKG_DIR}
     110TESTLOG=$(pwd)/test-${PKG_DIR}
     111unset MAKEFLAGS
     112#MAKEFLAGS=-j4
     113echo MAKEFLAGS: $MAKEFLAGS > $INFOLOG
     114> $TESTLOG
     115PKG_DEST=${BUILD_DIR}/dest
     116rm -rf $PKG_DEST
     117
     118</xsl:text>
     119            </xsl:if>
    99120            <!-- Download code and build commands -->
    100121            <xsl:apply-templates select="sect2"/>
     
    141162        </xsl:if>
    142163        <xsl:text>rm -rf
    143 case $PACKAGE in
     164
     165</xsl:text>
     166<!-- If stats are requested, insert the start size -->
     167        <xsl:if test="contains($list-stat-norm,concat(' ',../@id,' '))">
     168          <xsl:text>echo Start Size: $(sudo du -skx --exclude home /) >> $INFOLOG
     169
     170</xsl:text>
     171        </xsl:if>
     172
     173        <xsl:text>case $PACKAGE in
    144174  *.tar.gz|*.tar.bz2|*.tar.xz|*.tgz|*.tar.lzma)
    145175     tar -xvf $SRC_DIR/$PACKAGE &gt; unpacked
     
    170200cd $JH_UNPACKDIR&#xA;
    171201</xsl:text>
     202<!-- If stats are requested, insert the start time -->
     203        <xsl:if test="contains($list-stat-norm,concat(' ',../@id,' '))">
     204          <xsl:text>echo Start Time: ${SECONDS} >> $INFOLOG
     205
     206</xsl:text>
     207        </xsl:if>
     208
    172209        <xsl:apply-templates select=".//screen | .//para/command"/>
    173210        <xsl:if test="$sudo = 'y'">
     
    422459    <xsl:if test="child::* = userinput and not(@role = 'nodump')">
    423460      <xsl:choose>
    424         <xsl:when test="@role = 'root'">
    425           <xsl:if test="not(preceding-sibling::screen[1][@role='root'])">
    426             <xsl:if test="$sudo = 'y'">
    427               <xsl:text>sudo -E sh &lt;&lt; ROOT_EOF&#xA;</xsl:text>
    428             </xsl:if>
    429             <xsl:if test="$wrap-install = 'y' and
     461<!-- First the case of installation instructions -->
     462        <xsl:when test="@role = 'root' and
    430463                          ancestor::sect2[@role='installation'] and
    431464                          not(contains(string(),'useradd')) and
    432465                          not(contains(string(),'groupadd'))">
     466          <xsl:if test="not(preceding-sibling::screen[1][@role='root'])">
     467            <xsl:if test="contains($list-stat-norm,
     468                                   concat(' ',
     469                                          ancestor::sect1/@id,
     470                                          ' '))">
     471              <xsl:call-template name="output-destdir"/>
     472            </xsl:if>
     473            <xsl:if test="$sudo = 'y'">
     474              <xsl:text>sudo -E sh &lt;&lt; ROOT_EOF&#xA;</xsl:text>
     475            </xsl:if>
     476            <xsl:if test="$wrap-install = 'y'">
    433477              <xsl:text>if [ -r "$JH_PACK_INSTALL" ]; then
    434478  source $JH_PACK_INSTALL
     
    442486          <xsl:apply-templates mode="root"/>
    443487          <xsl:if test="not(following-sibling::screen[1][@role='root'])">
    444             <xsl:if test="$del-la-files = 'y' and
    445                           ancestor::sect2[@role='installation'] and
    446                           not(contains(string(),'useradd')) and
    447                           not(contains(string(),'groupadd'))">
     488            <xsl:if test="$del-la-files = 'y'">
    448489              <xsl:call-template name="output-root">
    449490                <xsl:with-param name="out-string" select="$la-files-instr"/>
    450491              </xsl:call-template>
    451492            </xsl:if>
    452             <xsl:if test="$wrap-install = 'y' and
    453                           ancestor::sect2[@role='installation'] and
    454                           not(contains(string(),'useradd')) and
    455                           not(contains(string(),'groupadd'))">
     493            <xsl:if test="$wrap-install = 'y'">
    456494              <xsl:text>'&#xA;packInstall</xsl:text>
    457495            </xsl:if>
     
    461499          </xsl:if>
    462500        </xsl:when>
     501<!-- then the case of other instructions run as root (configuration mainly) -->
     502        <xsl:when test="@role = 'root'">
     503          <xsl:if test="not(preceding-sibling::screen[1][@role='root'])">
     504            <xsl:if test="$sudo = 'y'">
     505              <xsl:text>sudo -E sh &lt;&lt; ROOT_EOF&#xA;</xsl:text>
     506            </xsl:if>
     507          </xsl:if>
     508          <xsl:apply-templates mode="root"/>
     509          <xsl:if test="not(following-sibling::screen[1][@role='root'])">
     510            <xsl:if test="$sudo = 'y'">
     511              <xsl:text>&#xA;ROOT_EOF</xsl:text>
     512            </xsl:if>
     513          </xsl:if>
     514        </xsl:when>
     515<!-- then all the instructions run as user -->
    463516        <xsl:otherwise>
    464517          <xsl:apply-templates select="userinput"/>
     
    535588  <xsl:template match="para/command">
    536589    <xsl:variable name="ns" select="normalize-space(string())"/>
    537     <xsl:if test="(contains($ns,'test') or
    538             contains($ns,'check'))">
    539       <xsl:text>#</xsl:text>
    540       <xsl:value-of select="substring-before($ns,'make ')"/>
    541       <xsl:text>make </xsl:text>
    542       <xsl:if test="not(contains($ns,'-k'))">
    543         <xsl:text>-k </xsl:text>
     590    <xsl:if test="contains($ns,'test') or
     591                  contains($ns,'check')">
     592      <xsl:choose>
     593        <xsl:when test="contains($list-stat-norm,
     594                                 concat(' ',ancestor::sect1/@id,' '))">
     595          <xsl:text>
     596echo Time after make: ${SECONDS} >> $INFOLOG
     597echo Size after make: $(sudo du -skx --exclude home /) >> $INFOLOG
     598echo Time before test: ${SECONDS} >> $INFOLOG
     599</xsl:text>
     600        </xsl:when>
     601        <xsl:otherwise>
     602          <xsl:text>#</xsl:text>
     603        </xsl:otherwise>
     604      </xsl:choose>
     605      <xsl:choose>
     606        <xsl:when test="contains($ns,'make')">
     607          <xsl:value-of select="substring-before($ns,'make ')"/>
     608          <xsl:text>make </xsl:text>
     609          <xsl:if test="not(contains($ns,'-k'))">
     610            <xsl:text>-k </xsl:text>
     611          </xsl:if>
     612          <xsl:value-of select="substring-after($ns,'make ')"/>
     613        </xsl:when>
     614        <xsl:otherwise>
     615          <xsl:copy-of select="$ns"/>
     616        </xsl:otherwise>
     617      </xsl:choose>
     618      <xsl:if test="contains($list-stat-norm,
     619                             concat(' ',ancestor::sect1/@id,' '))">
     620        <xsl:text> &gt;&gt; $TESTLOG 2&gt;&amp;1</xsl:text>
    544621      </xsl:if>
    545       <xsl:value-of select="substring-after($ns,'make ')"/>
    546622      <xsl:text> || true&#xA;</xsl:text>
    547623    </xsl:if>
     
    638714  </xsl:template>
    639715
     716  <xsl:template name="output-destdir">
     717<!-- Hopefully, the current node is the first screen with role equal to root.
     718     We first output stats, since we are only called if stats are needed.
     719     then we output DESTDIR instructions,etc -->
     720    <xsl:text>
     721echo Time after tests: ${SECONDS} >> $INFOLOG
     722echo Size after tests: $(sudo du -skx --exclude home /) >> $INFOLOG
     723echo Time before install: ${SECONDS} >> $INFOLOG
     724</xsl:text>
     725    <xsl:apply-templates
     726       select="userinput|following-sibling::screen[@role='root']/userinput"
     727       mode="destdir"/>
     728    <xsl:text>
     729echo Time after install: ${SECONDS} >> $INFOLOG
     730echo Size after install: $(sudo du -skx --exclude home /) >> $INFOLOG
     731</xsl:text>
     732  </xsl:template>
     733
     734  <xsl:template match="userinput" mode="destdir">
     735    <xsl:choose>
     736      <xsl:when test="./literal">
     737        <xsl:call-template name="outputpkgdest">
     738          <xsl:with-param name="outputstring" select="text()[1]"/>
     739        </xsl:call-template>
     740        <xsl:apply-templates select="literal"/>
     741        <xsl:call-template name="outputpkgdest">
     742          <xsl:with-param name="outputstring" select="text()[2]"/>
     743        </xsl:call-template>
     744      </xsl:when>
     745      <xsl:otherwise>
     746        <xsl:call-template name="outputpkgdest">
     747          <xsl:with-param name="outputstring" select="string()"/>
     748        </xsl:call-template>
     749      </xsl:otherwise>
     750    </xsl:choose>
     751    <xsl:text>&#xA;</xsl:text>
     752  </xsl:template>
     753
     754  <xsl:template name="outputpkgdest">
     755    <xsl:param name="outputstring" select="'foo'"/>
     756    <xsl:choose>
     757      <xsl:when test="contains($outputstring,'make ')">
     758        <xsl:choose>
     759          <xsl:when test="not(starts-with($outputstring,'make'))">
     760            <xsl:call-template name="outputpkgdest">
     761              <xsl:with-param name="outputstring"
     762                              select="substring-before($outputstring,'make')"/>
     763            </xsl:call-template>
     764            <xsl:call-template name="outputpkgdest">
     765              <xsl:with-param
     766                 name="outputstring"
     767                 select="substring-after($outputstring,
     768                                      substring-before($outputstring,'make'))"/>
     769            </xsl:call-template>
     770          </xsl:when>
     771          <xsl:otherwise>
     772            <xsl:text>make DESTDIR=$PKG_DEST</xsl:text>
     773              <xsl:call-template name="outputpkgdest">
     774                <xsl:with-param
     775                    name="outputstring"
     776                    select="substring-after($outputstring,'make')"/>
     777              </xsl:call-template>
     778          </xsl:otherwise>
     779        </xsl:choose>
     780      </xsl:when>
     781      <xsl:when test="contains($outputstring,'ninja install')">
     782        <xsl:choose>
     783          <xsl:when test="not(starts-with($outputstring,'ninja install'))">
     784            <xsl:call-template name="outputpkgdest">
     785              <xsl:with-param name="outputstring"
     786                              select="substring-before($outputstring,'ninja install')"/>
     787            </xsl:call-template>
     788            <xsl:call-template name="outputpkgdest">
     789              <xsl:with-param
     790                 name="outputstring"
     791                 select="substring-after($outputstring,
     792                                      substring-before($outputstring,'ninja install'))"/>
     793            </xsl:call-template>
     794          </xsl:when>
     795          <xsl:otherwise>
     796            <xsl:text>DESTDIR=$PKG_DEST ninja</xsl:text>
     797              <xsl:call-template name="outputpkgdest">
     798                <xsl:with-param
     799                    name="outputstring"
     800                    select="substring-after($outputstring,'ninja')"/>
     801              </xsl:call-template>
     802          </xsl:otherwise>
     803        </xsl:choose>
     804      </xsl:when>
     805      <xsl:otherwise> <!-- no make nor ninja in this string -->
     806        <xsl:choose>
     807          <xsl:when test="contains($outputstring,'&gt;/') and
     808                                 not(contains(substring-before($outputstring,'&gt;/'),' /'))">
     809            <xsl:value-of select="substring-before($outputstring,'&gt;/')"/>
     810            <xsl:text>&gt;$PKG_DEST/</xsl:text>
     811            <xsl:call-template name="outputpkgdest">
     812              <xsl:with-param name="outputstring" select="substring-after($outputstring,'&gt;/')"/>
     813            </xsl:call-template>
     814          </xsl:when>
     815          <xsl:when test="contains($outputstring,' /')">
     816            <xsl:value-of select="substring-before($outputstring,' /')"/>
     817            <xsl:text> $PKG_DEST/</xsl:text>
     818            <xsl:call-template name="outputpkgdest">
     819              <xsl:with-param name="outputstring" select="substring-after($outputstring,' /')"/>
     820            </xsl:call-template>
     821          </xsl:when>
     822          <xsl:otherwise>
     823            <xsl:value-of select="$outputstring"/>
     824          </xsl:otherwise>
     825        </xsl:choose>
     826      </xsl:otherwise>
     827    </xsl:choose>
     828  </xsl:template>
     829
    640830</xsl:stylesheet>
Note: See TracChangeset for help on using the changeset viewer.