BLFS tools:

- Separates the groups of xorg package into individual builds
This commit is contained in:
Pierre Labastie 2013-03-31 17:25:21 +00:00
parent d0c94a3a6e
commit d236bbdf03
4 changed files with 325 additions and 52 deletions

View file

@ -2,20 +2,38 @@
# $Id: gen-special.sh 21 2012-02-16 15:06:19Z labastie $ # $Id: gen-special.sh 21 2012-02-16 15:06:19Z labastie $
#-------------------------------------------------------------------------
# generates an xsl stylesheet containing a template for special
# cases in the book:
# - If the version does not begin with a number, it is impossible to know
# where the package name ends and where the version begins. We therefore
# use the ENTITY at the beginning of the validated full-xml.
# - If a package is part of a group of xorg packages (proto, fonts, etc)
# there is no easy way to extract it from the xml. We use the ENTITY at
# the top of each file x7*.xml
# - If a pacakge is versioned but the version is not mentioned in the book
# (currently only udev), we retrieve the version by other means
#-------------------------------------------------------------------------
# Arguments:
# $1 contains the name of the validated xml book
# $2 contains the name of the ouput xsl file
# $3 contains the name of the book sources directory
#-------------------------------------------------------------------------
BLFS_XML=$1 BLFS_XML=$1
if ! test -f ${BLFS_XML}; then if ! test -f ${BLFS_XML}; then
echo ${BLFS_XML} does not exist echo File \`${BLFS_XML}\' does not exist
exit 1 exit 1
fi fi
SPECIAL_FILE=$2 SPECIAL_FILE=$2
if test -z "${SPECIAL_FILE}"; then SPECIAL_FILE=specialCases.xsl;fi if test -z "${SPECIAL_FILE}"; then SPECIAL_FILE=specialCases.xsl;fi
BLFS_DIR=$3
if test -z "${BLFS_DIR}"; then BLFS_DIR=$(cd $(dirname ${BLFS_XML})/.. ; pwd);fi
# Packages whose version does not begin with a number # Packages whose version does not begin with a number
EXCEPTIONS=$(grep 'ENTITY.*version[ ]*"[^0-9"&.].*[0-9]' $BLFS_XML | EXCEPTIONS=$(grep 'ENTITY.*version[ ]*"[^0-9"&.].*[0-9]' $BLFS_XML |
sed 's@^[^"]*"\([^"]*\)".*@\1@') sed 's@^[^"]*"\([^"]*\)".*@\1@')
# Version for X Window packages without a version in the book
XVERSION=$(grep 'ENTITY xorg-version' $BLFS_XML |
sed 's@^[^"]*"\([^"]*\)".*@\1@')
# The case of udev
# Set PATH to be sure to find udevadm # Set PATH to be sure to find udevadm
SAVPATH=$PATH SAVPATH=$PATH
PATH=/bin:/sbin:/usr/bin:/usr/sbin PATH=/bin:/sbin:/usr/bin:/usr/sbin
@ -29,7 +47,7 @@ cat >$SPECIAL_FILE << EOF
<xsl:template match='*' mode="special"> <xsl:template match='*' mode="special">
<xsl:choose> <xsl:choose>
<xsl:when test="@id='udev'"> <xsl:when test="contains(@id,'udev')">
<xsl:text> </xsl:text> <xsl:text> </xsl:text>
<package><xsl:text>&#xA; </xsl:text> <package><xsl:text>&#xA; </xsl:text>
<xsl:element name="name"><xsl:value-of select="@id"/></xsl:element> <xsl:element name="name"><xsl:value-of select="@id"/></xsl:element>
@ -53,46 +71,94 @@ cat >$SPECIAL_FILE << EOF
<xsl:text>&#xA; </xsl:text> <xsl:text>&#xA; </xsl:text>
</package><xsl:text>&#xA;</xsl:text> </package><xsl:text>&#xA;</xsl:text>
</xsl:when> </xsl:when>
<!-- Although versioned, this page is not a package -->
<xsl:when test="@id='xorg7'"/> <xsl:when test="@id='xorg7'"/>
<xsl:when test="../@id='x-window-system' and EOF
not(contains(translate(@xreflabel,
'123456789', # Taking packages inside x7proto etc, as versionned modules.
'000000000'), # We also write a dependency expansion when a dep is of the form
'-0'))"> # xorg7-something. Since that is another template, we need
# a temporary file, which we shall concatenate at the end
cat >tmpfile << EOF
<xsl:template name="expand-deps">
<xsl:param name="section"/>
<xsl:param name="status"/>
<xsl:choose>
EOF
for file in $(ls ${BLFS_DIR}/x/installing/x7* | grep -v x7driver); do
id=$(grep xreflabel $file | sed 's@.*id="\([^"]*\).*@\1@')
cat >>$SPECIAL_FILE << EOF
<xsl:when test="@id='$id'">
<xsl:text> </xsl:text> <xsl:text> </xsl:text>
<package><xsl:text>&#xA; </xsl:text> <package><xsl:text>&#xA; </xsl:text>
<xsl:element name="name"><xsl:value-of select="@id"/></xsl:element> <xsl:element name="name">$id</xsl:element>
<xsl:text>&#xA; </xsl:text> <xsl:text>&#xA; </xsl:text>
<xsl:element name="version">$XVERSION</xsl:element> EOF
<xsl:if cat >> tmpfile << EOF
test="document(\$installed-packages)//package[name=current()/@id]"> <xsl:when test="\$section='$id'">
<xsl:text>&#xA; </xsl:text> EOF
<xsl:element name="inst-version"> # In the list, the preceding package is a dependency of the following,
<xsl:value-of # except the first:
select="document(\$installed-packages precpack=NONE
)//package[name=current()/@id]/version"/> # Rationale for the sed below: the following for breaks words at spaces (unless
</xsl:element> # we tweak IFS). So replace spaces with commas in lines so that only newlines
</xsl:if> # are separators.
for pack in \
$(grep 'ENTITY.*version' $file | sed 's/[ ]\+/,/g'); do
packname=$(echo $pack | sed s'@.*ENTITY,\(.*\)-version.*@\1@')
packversion=$(echo $pack | sed 's@[^"]*"\([^"]*\).*@\1@')
cat >>$SPECIAL_FILE << EOF
<module><xsl:text>&#xA; </xsl:text>
<xsl:element name="name">$packname</xsl:element>
<xsl:element name="version">$packversion</xsl:element>
<xsl:if test="document(\$installed-packages)//package[name='$packname']">
<xsl:element name="inst-version">
<xsl:value-of
select="document(\$installed-packages
)//package[name='$packname']/version"/>
</xsl:element>
</xsl:if>
<!-- Dependencies --> <!-- Dependencies -->
<xsl:text> EOF
</xsl:text> if test $precpack != NONE; then
cat >>$SPECIAL_FILE << EOF
<xsl:element name="dependency">
<xsl:attribute name="status">required</xsl:attribute>
<xsl:attribute name="name">$precpack</xsl:attribute>
<xsl:attribute name="type">ref</xsl:attribute>
</xsl:element>
EOF
else
cat >>$SPECIAL_FILE << EOF
<xsl:apply-templates select=".//para[@role='required' or
@role='recommended' or
@role='optional']"
mode="dependency"/>
EOF
fi
cat >>$SPECIAL_FILE << EOF
<!-- End dependencies -->
</module>
EOF
cat >> tmpfile << EOF
<xsl:element name="dependency"> <xsl:element name="dependency">
<xsl:attribute name="status">required</xsl:attribute> <xsl:attribute name="status">
<xsl:attribute name="name"> <xsl:value-of select="\$status"/>
<xsl:value-of
select="preceding-sibling::sect1[1]/@id"/>
</xsl:attribute> </xsl:attribute>
<xsl:attribute name="name">$packname</xsl:attribute>
<xsl:attribute name="type">ref</xsl:attribute> <xsl:attribute name="type">ref</xsl:attribute>
</xsl:element> </xsl:element>
<xsl:apply-templates select=".//para[@role='required' or
@role='recommended' or
@role='optional']"
mode="dependency"/>
<!-- End dependencies -->
<xsl:text>&#xA; </xsl:text>
</package><xsl:text>&#xA;</xsl:text>
</xsl:when>
EOF EOF
precpack=$packname
done
cat >>$SPECIAL_FILE << EOF
</package>
</xsl:when>
EOF
cat >> tmpfile << EOF
</xsl:when>
EOF
done
for ver_ent in $EXCEPTIONS; do for ver_ent in $EXCEPTIONS; do
id=$(grep 'xreflabel=".*'$ver_ent $BLFS_XML | sed 's@.*id="\([^"]*\)".*@\1@') id=$(grep 'xreflabel=".*'$ver_ent $BLFS_XML | sed 's@.*id="\([^"]*\)".*@\1@')
@ -137,6 +203,17 @@ cat >>$SPECIAL_FILE << EOF
</xsl:otherwise> </xsl:otherwise>
</xsl:choose> </xsl:choose>
</xsl:template> </xsl:template>
EOF
cat $SPECIAL_FILE tmpfile > tmpfile1
mv tmpfile1 $SPECIAL_FILE
rm tmpfile
cat >> $SPECIAL_FILE << EOF
<xsl:otherwise>
<xsl:message>
<xsl:text>You should not be seeing this</xsl:text>
</xsl:message>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet> </xsl:stylesheet>
EOF EOF

View file

@ -181,9 +181,19 @@ depends MENU_</xsl:text>
<xsl:text>]</xsl:text> <xsl:text>]</xsl:text>
</xsl:if> </xsl:if>
<xsl:text>" <xsl:text>"
&#9;&#9;&#9;default&#9;n &#9;&#9;&#9;default&#9;</xsl:text>
<xsl:choose>
<xsl:when test="contains(../name,'xorg')">
<xsl:text>y
</xsl:text> </xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>n
</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:if> </xsl:if>
</xsl:template> </xsl:template>

View file

@ -256,17 +256,31 @@
<xsl:variable name="status" select="./@role"/> <xsl:variable name="status" select="./@role"/>
<!-- No ulink for now (see special case for Perl modules) --> <!-- No ulink for now (see special case for Perl modules) -->
<xsl:for-each select="./xref"> <xsl:for-each select="./xref">
<xsl:text> <xsl:choose>
<xsl:when test="contains(@linkend,'xorg7-')">
<xsl:call-template name="expand-deps">
<xsl:with-param name="section">
<xsl:value-of select="@linkend"/>
</xsl:with-param>
<xsl:with-param name="status">
<xsl:value-of select="$status"/>
</xsl:with-param>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:text>
</xsl:text> </xsl:text>
<xsl:element name="dependency"> <xsl:element name="dependency">
<xsl:attribute name="status"> <xsl:attribute name="status">
<xsl:value-of select="$status"/> <xsl:value-of select="$status"/>
</xsl:attribute> </xsl:attribute>
<xsl:attribute name="name"> <xsl:attribute name="name">
<xsl:value-of select="@linkend"/> <xsl:value-of select="@linkend"/>
</xsl:attribute> </xsl:attribute>
<xsl:attribute name="type">ref</xsl:attribute> <xsl:attribute name="type">ref</xsl:attribute>
</xsl:element> </xsl:element>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each> </xsl:for-each>
</xsl:template> </xsl:template>

View file

@ -34,25 +34,45 @@
</book> </book>
</xsl:template> </xsl:template>
<!-- apply-templates for each id in the list. <!-- apply-templates for each item in the list.
Normally, those items are id of nodes.
Those nodes can be sect1 (normal case), Those nodes can be sect1 (normal case),
sect2 (python modules or DBus bindings) sect2 (python modules or DBus bindings)
bridgehead (perl modules) bridgehead (perl modules)
para (dependency of perl modules). para (dependency of perl modules).
The templates after this one treat each of those cases--> The templates after this one treat each of those cases.
However, some items are xorg package names, and not id.
We need special instructions in that case.
The difficulty is that some of those names *are* id's,
because they are referenced in the index.
Hopefully, none of those id's are sect{1,2}, bridgehead or para...-->
<xsl:template name="apply-list"> <xsl:template name="apply-list">
<xsl:param name="list" select="''"/> <xsl:param name="list" select="''"/>
<xsl:if test="string-length($list) &gt; 0"> <xsl:if test="string-length($list) &gt; 0">
<xsl:choose> <xsl:choose>
<xsl:when test="contains($list,' ')"> <xsl:when test="contains($list,' ')">
<xsl:apply-templates select="id(substring-before($list,' '))"/> <xsl:call-template name="apply-list">
<xsl:with-param name="list"
select="substring-before($list,' ')"/>
</xsl:call-template>
<xsl:call-template name="apply-list"> <xsl:call-template name="apply-list">
<xsl:with-param name="list" <xsl:with-param name="list"
select="substring-after($list,' ')"/> select="substring-after($list,' ')"/>
</xsl:call-template> </xsl:call-template>
</xsl:when> </xsl:when>
<xsl:otherwise> <xsl:otherwise>
<xsl:apply-templates select="id($list)"/> <xsl:choose>
<xsl:when test="not(id($list)/self::sect1|sect2|para|bridgehead)">
<xsl:apply-templates
select="//sect1[contains(string(.//userinput),$list)]"
mode="xorg">
<xsl:with-param name="package" select="$list"/>
</xsl:apply-templates>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="id($list)"/>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise> </xsl:otherwise>
</xsl:choose> </xsl:choose>
</xsl:if> </xsl:if>
@ -265,4 +285,156 @@
</xsl:for-each> </xsl:for-each>
</sect2> </sect2>
</xsl:template> </xsl:template>
<!-- we have got an xorg package. We are at the installation page
but now we need to make an autonomous page from the global
one -->
<xsl:template match="sect1" mode="xorg">
<xsl:param name="package"/>
<xsl:variable name="tarball">
<xsl:call-template name="tarball">
<xsl:with-param name="package" select="$package"/>
<xsl:with-param name="cat-md5"
select="string(.//userinput[starts-with(string(),'cat')])"/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="md5sum">
<xsl:call-template name="md5sum">
<xsl:with-param name="package" select="$package"/>
<xsl:with-param name="cat-md5"
select=".//userinput[starts-with(string(),'cat')]"/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="install-instructions">
<xsl:call-template name="inst-instr">
<xsl:with-param name="inst-instr"
select=".//userinput[starts-with(string(),'for')]"/>
</xsl:call-template>
</xsl:variable>
<xsl:element name="sect1">
<xsl:attribute name="id"><xsl:value-of select="$package"/></xsl:attribute>
<xsl:processing-instruction name="dbhtml">
filename="<xsl:value-of select='$package'/>.html"
</xsl:processing-instruction>
<title><xsl:value-of select="$package"/></title>
<sect2 role="package">
<title>Introduction to <xsl:value-of select="$package"/></title>
<bridgehead renderas="sect3">Package Information</bridgehead>
<itemizedlist spacing="compact">
<listitem>
<para>Download (HTTP): <xsl:element name="ulink">
<xsl:attribute name="url">
<xsl:value-of
select=".//para[contains(string(),'(HTTP)')]/ulink/@url"/>
<xsl:value-of select="$tarball"/>
</xsl:attribute>
</xsl:element>
</para>
</listitem>
<listitem>
<para>Download (FTP): <xsl:element name="ulink">
<xsl:attribute name="url">
<xsl:value-of
select=".//para[contains(string(),'(FTP)')]/ulink/@url"/>
<xsl:value-of select="$tarball"/>
</xsl:attribute>
</xsl:element>
</para>
</listitem>
<listitem>
<para>
Download MD5 sum: <xsl:value-of select="$md5sum"/>
</para>
</listitem>
</itemizedlist>
</sect2>
<sect2 role="installation">
<title>Installation of <xsl:value-of select="$package"/></title>
<para>
Install <application><xsl:value-of select="$package"/></application>
by running the following commands:
</para>
<screen><userinput>packagedir=<xsl:value-of
select="substring-before($tarball,'.tar.bz2')"/>
<xsl:text>&#xA;</xsl:text>
<xsl:value-of select="substring-before($install-instructions,
'as_root')"/>
</userinput></screen>
<para>
Now as the <systemitem class="username">root</systemitem> user:
</para>
<screen role='root'>
<userinput><xsl:value-of select="substring-after(
$install-instructions,
'as_root')"/>
</userinput>
</screen>
</sect2>
</xsl:element><!-- sect1 -->
</xsl:template>
<!-- get the tarball name from the text that comes from the .md5 file -->
<xsl:template name="tarball">
<xsl:param name="package"/>
<xsl:param name="cat-md5"/>
<!-- DEBUG
<xsl:message><xsl:text>Entering "tarball" template:
package is: </xsl:text>
<xsl:value-of select="$package"/><xsl:text>
cat-md5 is: </xsl:text>
<xsl:value-of select="$cat-md5"/>
</xsl:message>
END DEBUG -->
<xsl:choose>
<xsl:when test="contains(substring-before($cat-md5,$package),'&#xA;')">
<xsl:call-template name="tarball">
<xsl:with-param name="package" select="$package"/>
<xsl:with-param name="cat-md5"
select="substring-after($cat-md5,'&#xA;')"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="substring-after(
substring-before($cat-md5,'&#xA;'),' ')"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- same for md5sum -->
<xsl:template name="md5sum">
<xsl:param name="package"/>
<xsl:param name="cat-md5"/>
<xsl:choose>
<xsl:when test="contains(substring-before($cat-md5,$package),'&#xA;')">
<xsl:call-template name="md5sum">
<xsl:with-param name="package" select="$package"/>
<xsl:with-param name="cat-md5"
select="substring-after($cat-md5,'&#xA;')"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="substring-before($cat-md5,' ')"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="inst-instr">
<xsl:param name="inst-instr"/>
<xsl:choose>
<xsl:when test="contains($inst-instr,'pushd')">
<xsl:call-template name="inst-instr">
<xsl:with-param name="inst-instr"
select="substring-after(
substring-after($inst-instr,'pushd'),
'&#xA;')"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="substring-before($inst-instr,'popd')"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet> </xsl:stylesheet>