source: BLFS/gen-special.sh@ 63fc514

ablfs
Last change on this file since 63fc514 was 63fc514, checked in by Pierre Labastie <pierre@…>, 13 years ago

Initial modificaiton of BLFS tools

  • Property mode set to 100755
File size: 4.9 KB
Line 
1#!/bin/bash
2
3# $Id: gen-special.sh 21 2012-02-16 15:06:19Z labastie $
4
5BLFS_XML=$1
6if ! test -f ${BLFS_XML}; then
7 echo ${BLFS_XML} does not exist
8 exit 1
9fi
10SPECIAL_FILE=$2
11if test -z "${SPECIAL_FILE}"; then SPECIAL_FILE=specialCases.xsl;fi
12# Packages whose version does not begin with a number
13EXCEPTIONS=$(grep 'ENTITY.*version[ ]*"[^0-9"&.].*[0-9]' $BLFS_XML |
14 sed 's@^[^"]*"\([^"]*\)".*@\1@')
15# Version for X Window packages without a version in the book
16XVERSION=$(grep 'ENTITY xorg7-release' $BLFS_XML |
17 sed 's@^[^"]*"\([^"]*\)".*@\1@')
18# The case of udev
19# Set PATH to be sure to find udevadm
20SAVPATH=$PATH
21PATH=/bin:/sbin:/usr/bin:/usr/sbin
22UDEVVERSION=$(udevadm --version)
23
24cat >$SPECIAL_FILE << EOF
25<?xml version="1.0" encoding="ISO-8859-1"?>
26
27<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
28 version="1.0">
29
30<xsl:template match='*' mode="special">
31 <xsl:choose>
32 <xsl:when test="@id='udev'">
33 <xsl:text> </xsl:text>
34 <package><xsl:text>&#xA; </xsl:text>
35 <xsl:element name="name"><xsl:value-of select="@id"/></xsl:element>
36 <xsl:text>&#xA; </xsl:text>
37 <xsl:element name="version">$UDEVVERSION</xsl:element>
38 <xsl:if
39 test="document(\$installed-packages)//package[name=current()/@id]">
40 <xsl:text>&#xA; </xsl:text>
41 <xsl:element name="inst-version">
42 <xsl:value-of
43 select="document(\$installed-packages
44 )//package[name=current()/@id]/version"/>
45 </xsl:element>
46 </xsl:if>
47<!-- Dependencies -->
48 <xsl:apply-templates select=".//para[@role='required' or
49 @role='recommended' or
50 @role='optional']"
51 mode="dependency"/>
52<!-- End dependencies -->
53 <xsl:text>&#xA; </xsl:text>
54 </package><xsl:text>&#xA;</xsl:text>
55 </xsl:when>
56 <xsl:when test="@id='xorg7'"/>
57 <xsl:when test="../@id='x-window-system' and
58 not(contains(translate(@xreflabel,
59 '123456789',
60 '000000000'),
61 '-0'))">
62 <xsl:text> </xsl:text>
63 <package><xsl:text>&#xA; </xsl:text>
64 <xsl:element name="name"><xsl:value-of select="@id"/></xsl:element>
65 <xsl:text>&#xA; </xsl:text>
66 <xsl:element name="version">$XVERSION</xsl:element>
67 <xsl:if
68 test="document(\$installed-packages)//package[name=current()/@id]">
69 <xsl:text>&#xA; </xsl:text>
70 <xsl:element name="inst-version">
71 <xsl:value-of
72 select="document(\$installed-packages
73 )//package[name=current()/@id]/version"/>
74 </xsl:element>
75 </xsl:if>
76<!-- Dependencies -->
77 <xsl:apply-templates select=".//para[@role='required' or
78 @role='recommended' or
79 @role='optional']"
80 mode="dependency"/>
81<!-- End dependencies -->
82 <xsl:text>&#xA; </xsl:text>
83 </package><xsl:text>&#xA;</xsl:text>
84 </xsl:when>
85EOF
86
87for ver_ent in $EXCEPTIONS; do
88 id=$(grep 'xreflabel=".*'$ver_ent $BLFS_XML | sed 's@.*id="\([^"]*\)".*@\1@')
89 [[ -z $id ]] && continue
90 cat >>$SPECIAL_FILE << EOF
91 <xsl:when test="@id='$id'">
92 <xsl:text> </xsl:text>
93 <package><xsl:text>&#xA; </xsl:text>
94 <xsl:element name="name">$id</xsl:element>
95 <xsl:text>&#xA; </xsl:text>
96 <xsl:element name="version">$ver_ent</xsl:element>
97 <xsl:if
98 test="document(\$installed-packages)//package[name=current()/@id]">
99 <xsl:text>&#xA; </xsl:text>
100 <xsl:element name="inst-version">
101 <xsl:value-of
102 select="document(\$installed-packages
103 )//package[name=current()/@id]/version"/>
104 </xsl:element>
105 </xsl:if>
106<!-- Dependencies -->
107 <xsl:apply-templates select=".//para[@role='required' or
108 @role='recommended' or
109 @role='optional']"
110 mode="dependency"/>
111<!-- End dependencies -->
112 <xsl:text>&#xA; </xsl:text>
113 </package><xsl:text>&#xA;</xsl:text>
114 </xsl:when>
115EOF
116done
117
118cat >>$SPECIAL_FILE << EOF
119 <xsl:otherwise>
120 <xsl:apply-templates
121 select="self::node()[contains(translate(@xreflabel,
122 '123456789',
123 '000000000'),
124 '-0')
125 ]"
126 mode="normal"/>
127 </xsl:otherwise>
128 </xsl:choose>
129</xsl:template>
130
131</xsl:stylesheet>
132EOF
Note: See TracBrowser for help on using the repository browser.