<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: scripts.xsl 34 2012-02-21 16:05:09Z labastie $ -->

<!-- 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 != 'bootscripts'">
        <!-- The file names -->
      <xsl:variable name="filename" select="@id"/>

        <!-- 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,'-z-',$filename)"/>
        <xsl:text>&#xA;    FTPDIR is </xsl:text>
        <xsl:value-of select="$filename"/>
        <xsl:text>&#xA;&#xA;</xsl:text>
      </xsl:message>

        <!-- Creating the scripts -->
      <exsl:document href="{$order}-z-{$filename}" method="text">
        <xsl:text>#!/bin/bash&#xA;set -e&#xA;&#xA;</xsl:text>
        <xsl:choose>
          <!-- Package page -->
          <xsl:when test="sect2[@role='package']">
            <!-- We build in a subdirectory -->
            <xsl:text>PKG_DIR=</xsl:text>
            <xsl:value-of select="$filename"/>
            <xsl:text>&#xA;</xsl:text>
            <!-- Download code and build commands -->
            <xsl:apply-templates select="sect2"/>
            <!-- Clean-up -->
            <xsl:text>cd $SRC_DIR/$PKG_DIR&#xA;</xsl:text>
            <!-- In some case, some files in the build tree are owned
                 by root -->
            <xsl:if test="$sudo='y'">
              <xsl:text>sudo </xsl:text>
            </xsl:if>
            <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: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>
        <!-- Download information is in bridgehead tags -->
        <xsl:apply-templates select="bridgehead[@renderas='sect3']"/>
        <xsl:text>&#xA;</xsl:text>
      </xsl:when>
      <xsl:when test="@role = 'qt4-prefix' or @role = 'qt5-prefix'">
        <xsl:apply-templates select=".//screen"/>
      </xsl:when>
      <xsl:when test="@role = 'installation'">
        <xsl:text>
find . -maxdepth 1 -mindepth 1 -type d | xargs </xsl:text>
        <xsl:if test="$sudo='y'">
          <xsl:text>sudo </xsl:text>
        </xsl:if>
        <xsl:text>rm -rf
case $PACKAGE in
  *.tar.gz|*.tar.bz2|*.tar.xz|*.tgz)
     tar -xvf $PACKAGE &gt; unpacked
     UNPACKDIR=`grep '[^./]\+' unpacked | head -n1 | sed 's@^./@@;s@/.*@@'`
     ;;
  *.zip)
     zipinfo -1 $PACKAGE &gt; unpacked
     UNPACKDIR="$(sed 's@/.*@@' unpacked | uniq )"
     if test $(wc -w &lt;&lt;&lt; $UNPACKDIR) -eq 1; then
       unzip $PACKAGE
     else
       UNPACKDIR=${PACKAGE%.zip}
       unzip -d $UNPACKDIR $PACKAGE
     fi
     ;;
  *)
     UNPACKDIR=$PKG_DIR-build
     mkdir $UNPACKDIR
     cp $PACKAGE $UNPACKDIR
     ;;
esac
cd $UNPACKDIR&#xA;
</xsl:text>
        <xsl:apply-templates select=".//screen | .//para/command"/>
        <xsl:if test="$sudo = 'y'">
          <xsl:text>sudo /sbin/</xsl:text><commit_msg>Add possibility for lzma extension when untarring in BLFS tools<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: scripts.xsl 34 2012-02-21 16:05:09Z labastie $ -->

<!-- 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 != 'bootscripts'">
        <!-- The file names -->
      <xsl:variable name="filename" select="@id"/>

        <!-- 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,'-z-',$filename)"/>
        <xsl:text>&#xA;    FTPDIR is </xsl:text>
        <xsl:value-of select="$filename"/>
        <xsl:text>&#xA;&#xA;</xsl:text>
      </xsl:message>

        <!-- Creating the scripts -->
      <exsl:document href="{$order}-z-{$filename}" method="text">
        <xsl:text>#!/bin/bash&#xA;set -e&#xA;&#xA;</xsl:text>
        <xsl:choose>
          <!-- Package page -->
          <xsl:when test="sect2[@role='package']">
            <!-- We build in a subdirectory -->
            <xsl:text>PKG_DIR=</xsl:text>
            <xsl:value-of select="$filename"/>
            <xsl:text>&#xA;</xsl:text>
            <!-- Download code and build commands -->
            <xsl:apply-templates select="sect2"/>
            <!-- Clean-up -->
            <xsl:text>cd $SRC_DIR/$PKG_DIR&#xA;</xsl:text>
            <!-- In some case, some files in the build tree are owned
                 by root -->
            <xsl:if test="$sudo='y'">
              <xsl:text>sudo </xsl:text>
            </xsl:if>
            <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: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>
        <!-- Download information is in bridgehead tags -->
        <xsl:apply-templates select="bridgehead[@renderas='sect3']"/>
        <xsl:text>&#xA;</xsl:text>
      </xsl:when>
      <xsl:when test="@role = 'qt4-prefix' or @role = 'qt5-prefix'">
        <xsl:apply-templates select=".//screen"/>
      </xsl:when>
      <xsl:when test="@role = 'installation'">
        <xsl:text>
find . -maxdepth 1 -mindepth 1 -type d | xargs </xsl:text>
        <xsl:if test="$sudo='y'">
          <xsl:text>sudo </xsl:text>
        </xsl:if>
        <xsl:text>rm -rf
case $PACKAGE in
  *.tar.gz|*.tar.bz2|*.tar.xz|*.tgz|*.tar.lzma)
     tar -xvf $PACKAGE &gt; unpacked
     UNPACKDIR=`grep '[^./]\+' unpacked | head -n1 | sed 's@^./@@;s@/.*@@'`
     ;;
  *.zip)
     zipinfo -1 $PACKAGE &gt; unpacked
     UNPACKDIR="$(sed 's@/.*@@' unpacked | uniq )"
     if test $(wc -w &lt;&lt;&lt; $UNPACKDIR) -eq 1; then
       unzip $PACKAGE
     else
       UNPACKDIR=${PACKAGE%.zip}
       unzip -d $UNPACKDIR $PACKAGE
     fi
     ;;
  *)
     UNPACKDIR=$PKG_DIR-build
     mkdir $UNPACKDIR
     cp $PACKAGE $UNPACKDIR
     ;;
esac
cd $UNPACKDIR&#xA;
</xsl:text>
        <xsl:apply-templates select=".//screen | .//para/command"/>
        <xsl:if test="$sudo = 'y'">
          <xsl:text>sudo /sbin/</xsl:text>
{'fraction_non_alphanumeric': 0.2204054205398141, 'fraction_numerical': 0.009855526934707134, 'mean_word_length': 2.240203193033382, 'pattern_counts': {'":': 0, '<': 221, '<?xml version=': 2, '>': 221, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 6}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '310582', 'n_tokens_mistral': 3269, 'n_tokens_neox': 2906, 'n_words': 564}