<commit_before><?xml version="1.0"?>

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:exsl="http://exslt.org/common"
    extension-element-prefixes="exsl"
    version="1.0">

<!-- $Id$ -->

<!-- XSLT stylesheet to create shell scripts from "linear build" BLFS books. -->

  <!-- Build as user (y) or as root (n)? -->
  <xsl:param name="sudo" select="y"/>

  <xsl:template match="/">
    <xsl:apply-templates select="//sect1"/>
  </xsl:template>

<!--=================== Master chunks code ======================-->

  <xsl:template match="sect1">
    <xsl:if test="@id != 'locale-issues' and
                  (count(descendant::screen/userinput) &gt; 0 and
                  count(descendant::screen/userinput) &gt;
                  count(descendant::screen[@role='nodump']))">

        <!-- The file names -->
      <xsl:variable name="pi-file" select="processing-instruction('dbhtml')"/>
      <xsl:variable name="pi-file-value" select="substring-after($pi-file,'filename=')"/>
      <xsl:variable name="filename" select="substring-before(substring($pi-file-value,2),'.html')"/>

        <!-- Package name (use "Download FTP" by default. If empty, use "Download HTTP" -->
      <xsl:param name="package">
        <xsl:choose>
          <xsl:when
            test="string-length(sect2[@role='package']/itemizedlist/listitem[2]/para/ulink/@url)
            &gt; '10'">
            <xsl:call-template name="package_name">
              <xsl:with-param name="url"
                select="sect2[@role='package']/itemizedlist/listitem[2]/para/ulink/@url"/>
            </xsl:call-template>
          </xsl:when>
          <xsl:otherwise>
            <xsl:call-template name="package_name">
              <xsl:with-param name="url"
                select="sect2[@role='package']/itemizedlist/listitem[1]/para/ulink/@url"/>
            </xsl:call-template>
          </xsl:otherwise>
        </xsl:choose>
      </xsl:param>

        <!-- FTP dir name -->
      <xsl:param name="ftpdir">
        <xsl:call-template name="ftp_dir">
          <xsl:with-param name="package" select="$package"/>
        </xsl:call-template>
      </xsl:param>

        <!-- The build order -->
      <xsl:variable name="position" select="position()"/>
      <xsl:variable name="order">
        <xsl:choose>
          <xsl:when test="string-length($position) = 1">
            <xsl:text>00</xsl:text>
            <xsl:value-of select="$position"/>
          </xsl:when>
          <xsl:when test="string-length($position) = 2">
            <xsl:text>0</xsl:text>
            <xsl:value-of select="$position"/>
          </xsl:when>
          <xsl:otherwise>
            <xsl:value-of select="$position"/>
          </xsl:otherwise>
        </xsl:choose>
      </xsl:variable>

      <!-- Depuration code -->
      <xsl:message>
        <xsl:text>SCRIPT is </xsl:text>
        <xsl:value-of select="concat($order,'-',$filename)"/>
        <xsl:text>&#xA;   PACKAGE is </xsl:text>
        <xsl:value-of select="$package"/>
        <xsl:text>&#xA;    FTPDIR is </xsl:text>
        <xsl:value-of select="$ftpdir"/>
        <xsl:text>&#xA;&#xA;</xsl:text>
      </xsl:message>

        <!-- Creating the scripts -->
      <exsl:document href="{$order}-z-{$filename}" method="text">
        <xsl:text>#!/bin/sh&#xA;set -e&#xA;&#xA;</xsl:text>
        <xsl:choose>
          <!-- Package page -->
          <xsl:when test="sect2[@role='package']">
            <!-- Variables -->
            <xsl:text>SRC_ARCHIVE=$SRC_ARCHIVE&#xA;</xsl:text>
            <xsl:text>FTP_SERVER=$FTP_SERVER&#xA;&#xA;PACKAGE=</xsl:text>
            <xsl:value-of select="$package"/>
            <xsl:text>&#xA;PKG_DIR=</xsl:text>
            <xsl:value-of select="$ftpdir"/>
            <xsl:text>&#xA;SRC_DIR=$SRC_DIR&#xA;&#xA;</xsl:text>
            <!-- Download code and build commands -->
            <xsl:apply-templates select="sect2">
              <xsl:with-param name="package" select="$package"/>
              <xsl:with-param name="ftpdir" select="$ftpdir"/>
            </xsl:apply-templates>
            <!-- Clean-up -->
            <xsl:text>cd $SRC_DIR/$PKG_DIR&#xA;</xsl:text>
            <xsl:text>rm -rf $UNPACKDIR unpacked&#xA;&#xA;</xsl:text>
          </xsl:when>
          <!-- Non-package page -->
          <xsl:otherwise>
            <xsl:apply-templates select=".//screen"/>
          </xsl:otherwise>
        </xsl:choose>
        <xsl:text>exit</xsl:text>
      </exsl:document>

    </xsl:if>
  </xsl:template>

<!--======================= Sub-sections code =======================-->

  <xsl:template match="sect2">
    <xsl:param name="package" select="foo"/>
    <xsl:param name="ftpdir" select="foo"/>
    <xsl:choose>
      <xsl:when test="@role = 'package'">
        <xsl:text>mkdir -p $SRC_DIR/$PKG_DIR&#xA;</xsl:text>
        <xsl:text>cd $SRC_DIR/$PKG_DIR&#xA;</xsl:text>
        <xsl:apply-templates select="itemizedlist/listitem/para">
          <xsl:with-param name="package" select="$package"/>
          <xsl:with-param name="ftpdir" select="$ftpdir"/>
        </xsl:apply-templates>
        <xsl:text>&#xA;</xsl:text>
      </xsl:when>
      <xsl:when test="@role = 'installation'">
        <xsl:text>
if [[ -e unpacked ]] ; then
  UNPACKDIR=`head -n1 unpacked | sed 's@^./@@;s@/.*@@'`
  rm -rf $UNPACKDIR
fi
tar -xvf $PACKAGE > unpacked
UNPACKDIR=`head -n1 unpacked | sed 's@^./@@;s@/.*@@'`
cd $UNPACKDIR
          </xsl:text>
        <xsl:apply-templates select=".//screen | .//para/command"/>
        <xsl:text>&#xA;</xsl:text>
      </xsl:when>
      <xsl:when test="@role = 'configuration'">
        <xsl:apply-templates select=".//screen"/>
        <xsl:text>&#xA;</xsl:text>
      </xsl:when>
    </xsl:choose><commit_msg>Run ldconfig after each package installation<commit_after><?xml version="1.0"?>

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:exsl="http://exslt.org/common"
    extension-element-prefixes="exsl"
    version="1.0">

<!-- $Id$ -->

<!-- XSLT stylesheet to create shell scripts from "linear build" BLFS books. -->

  <!-- Build as user (y) or as root (n)? -->
  <xsl:param name="sudo" select="y"/>

  <xsl:template match="/">
    <xsl:apply-templates select="//sect1"/>
  </xsl:template>

<!--=================== Master chunks code ======================-->

  <xsl:template match="sect1">
    <xsl:if test="@id != 'locale-issues' and
                  (count(descendant::screen/userinput) &gt; 0 and
                  count(descendant::screen/userinput) &gt;
                  count(descendant::screen[@role='nodump']))">

        <!-- The file names -->
      <xsl:variable name="pi-file" select="processing-instruction('dbhtml')"/>
      <xsl:variable name="pi-file-value" select="substring-after($pi-file,'filename=')"/>
      <xsl:variable name="filename" select="substring-before(substring($pi-file-value,2),'.html')"/>

        <!-- Package name (use "Download FTP" by default. If empty, use "Download HTTP" -->
      <xsl:param name="package">
        <xsl:choose>
          <xsl:when
            test="string-length(sect2[@role='package']/itemizedlist/listitem[2]/para/ulink/@url)
            &gt; '10'">
            <xsl:call-template name="package_name">
              <xsl:with-param name="url"
                select="sect2[@role='package']/itemizedlist/listitem[2]/para/ulink/@url"/>
            </xsl:call-template>
          </xsl:when>
          <xsl:otherwise>
            <xsl:call-template name="package_name">
              <xsl:with-param name="url"
                select="sect2[@role='package']/itemizedlist/listitem[1]/para/ulink/@url"/>
            </xsl:call-template>
          </xsl:otherwise>
        </xsl:choose>
      </xsl:param>

        <!-- FTP dir name -->
      <xsl:param name="ftpdir">
        <xsl:call-template name="ftp_dir">
          <xsl:with-param name="package" select="$package"/>
        </xsl:call-template>
      </xsl:param>

        <!-- The build order -->
      <xsl:variable name="position" select="position()"/>
      <xsl:variable name="order">
        <xsl:choose>
          <xsl:when test="string-length($position) = 1">
            <xsl:text>00</xsl:text>
            <xsl:value-of select="$position"/>
          </xsl:when>
          <xsl:when test="string-length($position) = 2">
            <xsl:text>0</xsl:text>
            <xsl:value-of select="$position"/>
          </xsl:when>
          <xsl:otherwise>
            <xsl:value-of select="$position"/>
          </xsl:otherwise>
        </xsl:choose>
      </xsl:variable>

      <!-- Depuration code -->
      <xsl:message>
        <xsl:text>SCRIPT is </xsl:text>
        <xsl:value-of select="concat($order,'-',$filename)"/>
        <xsl:text>&#xA;   PACKAGE is </xsl:text>
        <xsl:value-of select="$package"/>
        <xsl:text>&#xA;    FTPDIR is </xsl:text>
        <xsl:value-of select="$ftpdir"/>
        <xsl:text>&#xA;&#xA;</xsl:text>
      </xsl:message>

        <!-- Creating the scripts -->
      <exsl:document href="{$order}-z-{$filename}" method="text">
        <xsl:text>#!/bin/sh&#xA;set -e&#xA;&#xA;</xsl:text>
        <xsl:choose>
          <!-- Package page -->
          <xsl:when test="sect2[@role='package']">
            <!-- Variables -->
            <xsl:text>SRC_ARCHIVE=$SRC_ARCHIVE&#xA;</xsl:text>
            <xsl:text>FTP_SERVER=$FTP_SERVER&#xA;&#xA;PACKAGE=</xsl:text>
            <xsl:value-of select="$package"/>
            <xsl:text>&#xA;PKG_DIR=</xsl:text>
            <xsl:value-of select="$ftpdir"/>
            <xsl:text>&#xA;SRC_DIR=$SRC_DIR&#xA;&#xA;</xsl:text>
            <!-- Download code and build commands -->
            <xsl:apply-templates select="sect2">
              <xsl:with-param name="package" select="$package"/>
              <xsl:with-param name="ftpdir" select="$ftpdir"/>
            </xsl:apply-templates>
            <!-- Clean-up -->
            <xsl:text>cd $SRC_DIR/$PKG_DIR&#xA;</xsl:text>
            <xsl:text>rm -rf $UNPACKDIR unpacked&#xA;&#xA;</xsl:text>
          </xsl:when>
          <!-- Non-package page -->
          <xsl:otherwise>
            <xsl:apply-templates select=".//screen"/>
          </xsl:otherwise>
        </xsl:choose>
        <xsl:text>exit</xsl:text>
      </exsl:document>

    </xsl:if>
  </xsl:template>

<!--======================= Sub-sections code =======================-->

  <xsl:template match="sect2">
    <xsl:param name="package" select="foo"/>
    <xsl:param name="ftpdir" select="foo"/>
    <xsl:choose>
      <xsl:when test="@role = 'package'">
        <xsl:text>mkdir -p $SRC_DIR/$PKG_DIR&#xA;</xsl:text>
        <xsl:text>cd $SRC_DIR/$PKG_DIR&#xA;</xsl:text>
        <xsl:apply-templates select="itemizedlist/listitem/para">
          <xsl:with-param name="package" select="$package"/>
          <xsl:with-param name="ftpdir" select="$ftpdir"/>
        </xsl:apply-templates>
        <xsl:text>&#xA;</xsl:text>
      </xsl:when>
      <xsl:when test="@role = 'installation'">
        <xsl:text>
if [[ -e unpacked ]] ; then
  UNPACKDIR=`head -n1 unpacked | sed 's@^./@@;s@/.*@@'`
  rm -rf $UNPACKDIR
fi
tar -xvf $PACKAGE > unpacked
UNPACKDIR=`head -n1 unpacked | sed 's@^./@@;s@/.*@@'`
cd $UNPACKDIR
          </xsl:text>
        <xsl:apply-templates select=".//screen | .//para/command"/>
        <xsl:if test="$sudo = 'y'">
          <xsl:text>sudo </xsl:text>
        </xsl:if>
        <xsl:text>ldconfig&#xA;&#xA;</xsl:text>
      </xsl:when>
      <xsl:when test="@role = 'configuration'">
        <xsl:apply-templates select=".//screen"/>
        <xsl:text>&#xA;</xsl:text>
      </xsl:when>
    </xsl:choose>
{'fraction_non_alphanumeric': 0.2158025965093285, 'fraction_numerical': 0.005330582065170664, 'mean_word_length': 2.3902652287962693, 'pattern_counts': {'":': 0, '<': 285, '<?xml version=': 2, '>': 287, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 6}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3997672', 'n_tokens_mistral': 4070, 'n_tokens_neox': 3650, 'n_words': 588}