2006-06-11 12:04:36 +02:00
|
|
|
<?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$ -->
|
|
|
|
|
2006-06-12 22:57:57 +02:00
|
|
|
<!-- XSLT stylesheet to create shell scripts from "linear build" BLFS books. -->
|
2006-06-11 12:04:36 +02:00
|
|
|
|
|
|
|
<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) > 0 and
|
|
|
|
count(descendant::screen/userinput) >
|
|
|
|
count(descendant::screen[@role='nodump']))">
|
2006-06-12 22:57:57 +02:00
|
|
|
|
2006-06-11 12:04:36 +02:00
|
|
|
<!-- 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')"/>
|
2006-06-12 22:57:57 +02:00
|
|
|
|
|
|
|
<!-- Package name (what happens if "Download HTTP" is empty?)-->
|
|
|
|
<xsl:param name="package">
|
|
|
|
<xsl:call-template name="package_name">
|
|
|
|
<xsl:with-param name="url"
|
|
|
|
select="sect2[@role='package']/itemizedlist/listitem/para/ulink/@url"/>
|
|
|
|
</xsl:call-template>
|
|
|
|
</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>
|
|
|
|
|
2006-06-11 12:04:36 +02:00
|
|
|
<!-- 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>
|
2006-06-12 22:57:57 +02:00
|
|
|
|
2006-06-14 22:38:31 +02:00
|
|
|
<!-- Depuration code -->
|
|
|
|
<xsl:message>
|
|
|
|
<xsl:text>SCRIPT is </xsl:text>
|
|
|
|
<xsl:value-of select="concat($order,'-',$filename)"/>
|
|
|
|
<xsl:text>
 PACKAGE is </xsl:text>
|
|
|
|
<xsl:value-of select="$package"/>
|
|
|
|
<xsl:text>
 FTPDIR is </xsl:text>
|
|
|
|
<xsl:value-of select="$ftpdir"/>
|
|
|
|
<xsl:text>

</xsl:text>
|
|
|
|
</xsl:message>
|
|
|
|
|
2006-06-12 22:57:57 +02:00
|
|
|
<!-- Creating the scripts -->
|
2006-06-11 12:04:36 +02:00
|
|
|
<exsl:document href="{$order}-{$filename}" method="text">
|
|
|
|
<xsl:text>#!/bin/sh
set -e

</xsl:text>
|
2006-06-11 12:24:31 +02:00
|
|
|
<xsl:choose>
|
|
|
|
<xsl:when test="sect2[@role='package']">
|
|
|
|
<xsl:apply-templates select="sect2">
|
|
|
|
<xsl:with-param name="package" select="$package"/>
|
|
|
|
<xsl:with-param name="ftpdir" select="$ftpdir"/>
|
|
|
|
</xsl:apply-templates>
|
2006-06-11 12:28:58 +02:00
|
|
|
<xsl:text>cd ~/sources/</xsl:text>
|
|
|
|
<xsl:value-of select="$ftpdir"/>
|
|
|
|
<xsl:text>
rm -rf $UNPACKDIR

</xsl:text>
|
2006-06-11 12:24:31 +02:00
|
|
|
</xsl:when>
|
|
|
|
<xsl:otherwise>
|
|
|
|
<xsl:apply-templates select=".//screen"/>
|
|
|
|
</xsl:otherwise>
|
|
|
|
</xsl:choose>
|
2006-06-11 12:04:36 +02:00
|
|
|
<xsl:text>exit</xsl:text>
|
|
|
|
</exsl:document>
|
2006-06-12 22:57:57 +02:00
|
|
|
|
2006-06-11 12:04:36 +02:00
|
|
|
</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 ~/sources/</xsl:text>
|
|
|
|
<xsl:value-of select="$ftpdir"/>
|
|
|
|
<xsl:text>
cd ~/sources/</xsl:text>
|
|
|
|
<xsl:value-of select="$ftpdir"/>
|
|
|
|
<xsl:text>
</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>
</xsl:text>
|
|
|
|
</xsl:when>
|
|
|
|
<xsl:when test="@role = 'installation'">
|
|
|
|
<xsl:text>tar -xvf </xsl:text>
|
|
|
|
<xsl:value-of select="$package"/>
|
|
|
|
<xsl:text> > /tmp/unpacked
</xsl:text>
|
|
|
|
<xsl:text>UNPACKDIR=`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'`
</xsl:text>
|
|
|
|
<xsl:text>cd $UNPACKDIR
</xsl:text>
|
|
|
|
<xsl:apply-templates select=".//screen | .//para/command"/>
|
|
|
|
<xsl:text>
</xsl:text>
|
|
|
|
</xsl:when>
|
|
|
|
<xsl:when test="@role = 'configuration'">
|
|
|
|
<xsl:apply-templates select=".//screen"/>
|
|
|
|
<xsl:text>
</xsl:text>
|
|
|
|
</xsl:when>
|
|
|
|
<xsl:otherwise/>
|
|
|
|
</xsl:choose>
|
|
|
|
</xsl:template>
|
|
|
|
|
|
|
|
<!--==================== Download code =======================-->
|
|
|
|
|
2006-06-12 22:57:57 +02:00
|
|
|
<xsl:template name="package_name">
|
|
|
|
<xsl:param name="url" select="foo"/>
|
|
|
|
<xsl:param name="sub-url" select="substring-after($url,'/')"/>
|
|
|
|
<xsl:choose>
|
|
|
|
<xsl:when test="contains($sub-url,'/')">
|
|
|
|
<xsl:call-template name="package_name">
|
|
|
|
<xsl:with-param name="url" select="$sub-url"/>
|
|
|
|
</xsl:call-template>
|
|
|
|
</xsl:when>
|
|
|
|
<xsl:otherwise>
|
|
|
|
<xsl:choose>
|
|
|
|
<xsl:when test="contains($sub-url,'?')">
|
|
|
|
<xsl:value-of select="substring-before($sub-url,'?')"/>
|
|
|
|
</xsl:when>
|
|
|
|
<xsl:otherwise>
|
|
|
|
<xsl:value-of select="$sub-url"/>
|
|
|
|
</xsl:otherwise>
|
|
|
|
</xsl:choose>
|
|
|
|
</xsl:otherwise>
|
|
|
|
</xsl:choose>
|
|
|
|
</xsl:template>
|
|
|
|
|
|
|
|
<xsl:template name="ftp_dir">
|
|
|
|
<xsl:param name="package" select="foo"/>
|
2006-06-14 22:38:31 +02:00
|
|
|
<!-- From BLFS patcheslist.xsl. Need be revised and fixed. -->
|
|
|
|
<xsl:choose>
|
|
|
|
<!-- cdparanoia -->
|
|
|
|
<xsl:when test="contains($package, '-III')">
|
|
|
|
<xsl:text>cdparanoia</xsl:text>
|
|
|
|
</xsl:when>
|
|
|
|
<!-- Open Office -->
|
|
|
|
<xsl:when test="contains($package, 'OOo')">
|
|
|
|
<xsl:text>OOo</xsl:text>
|
|
|
|
</xsl:when>
|
|
|
|
<!-- QT -->
|
|
|
|
<xsl:when test="contains($package, 'qt-x')">
|
|
|
|
<xsl:text>qt</xsl:text>
|
|
|
|
</xsl:when>
|
|
|
|
<!-- XOrg -->
|
|
|
|
<xsl:when test="contains($package, 'X11R6')">
|
|
|
|
<xsl:text>xorg</xsl:text>
|
|
|
|
</xsl:when>
|
|
|
|
<!-- General rule -->
|
|
|
|
<xsl:otherwise>
|
|
|
|
<xsl:variable name="cut"
|
|
|
|
select="translate(substring-after($package, '-'), '0123456789', '0000000000')"/>
|
|
|
|
<xsl:variable name="package2">
|
|
|
|
<xsl:value-of select="substring-before($package, '-')"/>
|
|
|
|
<xsl:text>-</xsl:text>
|
|
|
|
<xsl:value-of select="$cut"/>
|
|
|
|
</xsl:variable>
|
|
|
|
<xsl:value-of select="substring-before($package2, '-0')"/>
|
|
|
|
</xsl:otherwise>
|
|
|
|
</xsl:choose>
|
2006-06-12 22:57:57 +02:00
|
|
|
</xsl:template>
|
|
|
|
|
2006-06-11 12:04:36 +02:00
|
|
|
<xsl:template match="itemizedlist/listitem/para">
|
|
|
|
<xsl:param name="package" select="foo"/>
|
|
|
|
<xsl:param name="ftpdir" select="foo"/>
|
|
|
|
<xsl:choose>
|
|
|
|
<xsl:when test="contains(string(),'HTTP')">
|
2006-06-11 12:12:05 +02:00
|
|
|
<!-- SRC_ARCHIVE may have subdirectories or not -->
|
2006-06-11 12:04:36 +02:00
|
|
|
<xsl:text>cp $SRC_ARCHIVE/</xsl:text>
|
|
|
|
<xsl:value-of select="$ftpdir"/>
|
|
|
|
<xsl:text>/</xsl:text>
|
|
|
|
<xsl:value-of select="$package"/>
|
|
|
|
<xsl:text> || \
</xsl:text>
|
|
|
|
<xsl:text>cp $SRC_ARCHIVE/</xsl:text>
|
|
|
|
<xsl:value-of select="$package"/>
|
|
|
|
<xsl:text> || \
</xsl:text>
|
|
|
|
<!-- The FTP_SERVER mirror -->
|
|
|
|
<xsl:text>wget $FTP_SERVER/BLFS/conglomeration/</xsl:text>
|
|
|
|
<xsl:value-of select="$ftpdir"/>
|
|
|
|
<xsl:text>/</xsl:text>
|
|
|
|
<xsl:value-of select="$package"/>
|
|
|
|
<xsl:text> || \
</xsl:text>
|
|
|
|
<!-- Upstream HTTP URL -->
|
|
|
|
<xsl:text>wget </xsl:text>
|
|
|
|
<xsl:value-of select="ulink/@url"/>
|
|
|
|
<xsl:text> || \
</xsl:text>
|
|
|
|
</xsl:when>
|
|
|
|
<xsl:when test="contains(string(),'FTP')">
|
|
|
|
<!-- Upstream FTP URL -->
|
|
|
|
<xsl:text>wget </xsl:text>
|
|
|
|
<xsl:value-of select="ulink/@url"/>
|
|
|
|
<xsl:text>
</xsl:text>
|
|
|
|
</xsl:when>
|
|
|
|
<xsl:when test="contains(string(),'MD5')">
|
|
|
|
<xsl:text>echo "</xsl:text>
|
|
|
|
<xsl:value-of select="substring-after(string(),'sum: ')"/>
|
|
|
|
<xsl:text>  </xsl:text>
|
|
|
|
<xsl:value-of select="$package"/>
|
|
|
|
<xsl:text>" | md5sum -c -
</xsl:text>
|
|
|
|
</xsl:when>
|
|
|
|
<!-- Patches. Need be veryfied -->
|
|
|
|
<xsl:when test="contains(string(),'patch')">
|
|
|
|
<xsl:text>wget </xsl:text>
|
|
|
|
<xsl:value-of select="ulink/@url"/>
|
|
|
|
<xsl:text>
</xsl:text>
|
|
|
|
</xsl:when>
|
|
|
|
<xsl:otherwise/>
|
|
|
|
</xsl:choose>
|
|
|
|
</xsl:template>
|
|
|
|
|
|
|
|
<!--======================== Commands code ==========================-->
|
|
|
|
|
|
|
|
<xsl:template match="screen">
|
|
|
|
<xsl:if test="child::* = userinput">
|
|
|
|
<xsl:choose>
|
|
|
|
<xsl:when test="@role = 'nodump'"/>
|
|
|
|
<xsl:otherwise>
|
|
|
|
<xsl:if test="@role = 'root'">
|
|
|
|
<xsl:text>sudo </xsl:text>
|
|
|
|
</xsl:if>
|
|
|
|
<xsl:apply-templates select="userinput" mode="screen"/>
|
|
|
|
</xsl:otherwise>
|
|
|
|
</xsl:choose>
|
|
|
|
</xsl:if>
|
|
|
|
</xsl:template>
|
|
|
|
|
|
|
|
<xsl:template match="para/command">
|
|
|
|
<xsl:if test="(contains(string(),'test') or
|
|
|
|
contains(string(),'check'))">
|
|
|
|
<xsl:text>#</xsl:text>
|
|
|
|
<xsl:value-of select="substring-before(string(),'make')"/>
|
|
|
|
<xsl:text>make -k</xsl:text>
|
|
|
|
<xsl:value-of select="substring-after(string(),'make')"/>
|
|
|
|
<xsl:text> || true
</xsl:text>
|
|
|
|
</xsl:if>
|
|
|
|
</xsl:template>
|
|
|
|
|
|
|
|
<xsl:template match="userinput" mode="screen">
|
|
|
|
<xsl:apply-templates/>
|
|
|
|
<xsl:text>
</xsl:text>
|
|
|
|
</xsl:template>
|
|
|
|
|
|
|
|
<xsl:template match="replaceable">
|
|
|
|
<xsl:text>**EDITME</xsl:text>
|
|
|
|
<xsl:apply-templates/>
|
|
|
|
<xsl:text>EDITME**</xsl:text>
|
|
|
|
</xsl:template>
|
|
|
|
|
|
|
|
</xsl:stylesheet>
|