source: BLFS/gen-special.sh@ 6d9bd8e

ablfs-more trunk
Last change on this file since 6d9bd8e was 9eb3dbe, checked in by Pierre Labastie <pierre.labastie@…>, 15 months ago

Don't build Xorg components that are commented out

gen-special.sh uses the list of files and md5 from the
cat instructions to generate an xml page for each of
the individual components. Until now, there were no commented
out component, so gen-special.sh was not prepared to handle
comments. Now, it removes lines containing comments.

  • Property mode set to 100755
File size: 10.7 KB
Line 
1#!/bin/bash
2
3#-------------------------------------------------------------------------
4# generates an xsl stylesheet containing a template for special
5# cases in the book:
6# - If the version does not begin with a number, it is impossible to know
7# where the package name ends and where the version begins. We therefore
8# use the ENTITY at the beginning of the validated full-xml.
9# - If a package is part of a group of xorg packages (proto, fonts, etc)
10# there is no easy way to extract it from the xml. We use the ENTITY at
11# the top of each file x7*.xml
12# - Some non-versioned packages are needed as dependencies of others: we
13# attribute version 1.0.0 to them. It is just used to know if the package
14# is installed, by checking inst-version.
15# - If a package is versioned but the version is not mentioned in the book
16# (currently only udev), we retrieve the version by other means
17#-------------------------------------------------------------------------
18# Arguments:
19# $1 contains the name of the validated xml book
20# $2 contains the name of the ouput xsl file
21# $3 contains the name of the book sources directory
22#-------------------------------------------------------------------------
23
24BLFS_XML=$1
25if ! test -f ${BLFS_XML}; then
26 echo File \`${BLFS_XML}\' does not exist
27 exit 1
28fi
29SPECIAL_FILE=$2
30if test -z "${SPECIAL_FILE}"; then SPECIAL_FILE=specialCases.xsl;fi
31BLFS_DIR=$3
32if test -z "${BLFS_DIR}"; then BLFS_DIR=$(cd $(dirname ${BLFS_XML})/.. ; pwd);fi
33
34# Packages whose version does not begin with a number
35EXCEPTIONS=$(grep 'ENTITY.*version[ ]*"[^0-9"&.].*[0-9]' ${BLFS_DIR}/packages.ent |
36 sed 's@^[^"]*"\([^"]*\)".*@\1@')
37
38# Non-versioned packages:
39NV_LIST="postlfs-config-profile postlfs-config-random postlfs-config-vimrc \
40initramfs xorg-env kde-pre-install-config kf5-intro \
41lxqt-pre-install lxqt-post-install ojdk-conf tex-path"
42
43cat >$SPECIAL_FILE << EOF
44<?xml version="1.0" encoding="ISO-8859-1"?>
45
46<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
47 version="1.0">
48
49<xsl:template match='*' mode="special">
50 <xsl:choose>
51<!-- Although versioned, this page is not a package. But
52 the sect2 with id "xorg-env" is referred to at several
53 places in the book. We have added it to the list of non
54 versioned packages. -->
55 <xsl:when test="@id='xorg7'">
56 <xsl:apply-templates select="child::sect2" mode="special"/>
57 </xsl:when>
58EOF
59
60# Non-versionned packages. Add to NV_LIST if you need more.
61for nv_id in $NV_LIST; do
62 cat >>$SPECIAL_FILE << EOF
63 <xsl:when test="@id='$nv_id'">
64 <xsl:text> </xsl:text>
65 <package><xsl:text>&#xA; </xsl:text>
66 <xsl:element name="name">$nv_id</xsl:element>
67 <xsl:text>&#xA; </xsl:text>
68 <xsl:element name="version">1.0.0</xsl:element>
69 <xsl:if
70 test="document(\$installed-packages)//package[name=current()/@id]">
71 <xsl:text>&#xA; </xsl:text>
72 <xsl:element name="inst-version">
73 <xsl:value-of
74 select="document(\$installed-packages
75 )//package[name=current()/@id]/version"/>
76 </xsl:element>
77 </xsl:if>
78<!-- Dependencies -->
79 <xsl:apply-templates select=".//para[@role='required' or
80 @role='recommended' or
81 @role='optional']"
82 mode="dependency"/>
83<!-- End dependencies -->
84 <xsl:text>&#xA; </xsl:text>
85 </package><xsl:text>&#xA;</xsl:text>
86 </xsl:when>
87EOF
88done
89
90# Taking packages inside x7proto etc, as versionned modules.
91# We also write a dependency expansion when a dep is of the form
92# xorg7-something. Since that is another template, we need
93# a temporary file, which we shall concatenate at the end
94cat >tmpfile << EOF
95 <xsl:template name="expand-deps">
96 <xsl:param name="section"/>
97 <xsl:param name="status"/>
98 <xsl:param name="build"/>
99 <xsl:choose>
100EOF
101for file in $(ls ${BLFS_DIR}/x/installing/x7* | grep -v x7driver); do
102 id=$(grep xreflabel $file | sed 's@.*id="\([^"]*\).*@\1@')
103 cat >>$SPECIAL_FILE << EOF
104 <xsl:when test="@id='$id'">
105 <xsl:text> </xsl:text>
106 <package><xsl:text>&#xA; </xsl:text>
107 <xsl:element name="name">$id</xsl:element>
108 <xsl:text>&#xA; </xsl:text>
109EOF
110 cat >> tmpfile << EOF
111 <xsl:when test="\$section='$id'">
112EOF
113# We extract the list of packages for an xorg page from
114# the version part of the .xml file. Seems that
115# the order is not always the same as in the "cat" command.
116# So we have to read that command too, since it may be assumed
117# that the preceding package is a dependency of the following,
118# except the first.
119 list_cat="$(sed -n '/>cat/,/EOF</p' $file | grep -v 'cat\|EOF\|#' |
120 awk '{ print $NF }' | sed 's/-&.*//')"
121
122# Rationale for the sed below: the following for breaks words at spaces (unless
123# we tweak IFS). So replace spaces with commas in lines so that only newlines
124# are separators.
125 for pack in \
126 $(grep 'ENTITY.*version' $file | sed 's/[ ]\+/,/g'); do
127 packname=$(echo $pack | sed s'@.*ENTITY,\(.*\)-version.*@\1@')
128 packversion=$(echo $pack | sed 's@[^"]*"\([^"]*\).*@\1@')
129 precpack=NONE
130 for i in $list_cat; do
131 if [ "$i" = "$packname" ]; then break; fi
132 precpack=$i
133 done
134# It may happen that packname is not in list_cat, because its entity
135# is commented out in the xml, but we do not check that (too complicated).
136# In that case, the whole list is scanned, and $precpack=$i at the end.
137# when packname is found in the list $precpack!=$i.
138 if [ "$precpack" = "$i" ]; then continue; fi
139 cat >>$SPECIAL_FILE << EOF
140 <module><xsl:text>&#xA; </xsl:text>
141 <xsl:element name="name">$packname</xsl:element>
142 <xsl:element name="version">$packversion</xsl:element>
143 <xsl:if test="document(\$installed-packages)//package[name='$packname']">
144 <xsl:element name="inst-version">
145 <xsl:value-of
146 select="document(\$installed-packages
147 )//package[name='$packname']/version"/>
148 </xsl:element>
149 </xsl:if>
150<!-- Dependencies -->
151EOF
152 if test $precpack != NONE; then
153 cat >>$SPECIAL_FILE << EOF
154 <xsl:element name="dependency">
155 <xsl:attribute name="status">required</xsl:attribute>
156 <xsl:attribute name="build">before</xsl:attribute>
157 <xsl:attribute name="name">$precpack</xsl:attribute>
158 <xsl:attribute name="type">ref</xsl:attribute>
159 </xsl:element>
160EOF
161 else
162 cat >>$SPECIAL_FILE << EOF
163 <xsl:apply-templates select=".//para[@role='required' or
164 @role='recommended' or
165 @role='optional']"
166 mode="dependency"/>
167EOF
168 fi
169 cat >>$SPECIAL_FILE << EOF
170<!-- End dependencies -->
171 </module>
172EOF
173 cat >> tmpfile << EOF
174 <xsl:element name="dependency">
175 <xsl:attribute name="status">
176 <xsl:value-of select="\$status"/>
177 </xsl:attribute>
178 <xsl:attribute name="build">
179 <xsl:value-of select="\$build"/>
180 </xsl:attribute>
181 <xsl:attribute name="name">$packname</xsl:attribute>
182 <xsl:attribute name="type">ref</xsl:attribute>
183 </xsl:element>
184EOF
185 done
186 cat >>$SPECIAL_FILE << EOF
187 </package>
188 </xsl:when>
189EOF
190 cat >> tmpfile << EOF
191 </xsl:when>
192EOF
193done
194
195for ver_ent in $EXCEPTIONS; do
196 id=$(grep 'xreflabel=".*'$ver_ent $BLFS_XML | sed 's@.*id="\([^"]*\)".*@\1@')
197 [[ -z $id ]] && continue
198 cat >>$SPECIAL_FILE << EOF
199 <xsl:when test="@id='$id'">
200<!-- if there is a sect1 ancestor, we have a module -->
201 <xsl:choose>
202 <xsl:when test="ancestor::sect1">
203 <xsl:text> </xsl:text>
204 <module><xsl:text>&#xA; </xsl:text>
205 <xsl:element name="name">$id</xsl:element>
206 <xsl:text>&#xA; </xsl:text>
207 <xsl:element name="version">$ver_ent</xsl:element>
208 <xsl:if
209 test="document(\$installed-packages)//package[name=current()/@id]">
210 <xsl:text>&#xA; </xsl:text>
211 <xsl:element name="inst-version">
212 <xsl:value-of
213 select="document(\$installed-packages
214 )//package[name=current()/@id]/version"/>
215 </xsl:element>
216 </xsl:if>
217<!-- Dependencies -->
218 <xsl:apply-templates select=".//para[@role='required' or
219 @role='recommended' or
220 @role='optional']"
221 mode="dependency"/>
222<!-- End dependencies -->
223 <xsl:text>&#xA; </xsl:text>
224 </module><xsl:text>&#xA;</xsl:text>
225 </xsl:when>
226 <xsl:otherwise>
227 <xsl:text> </xsl:text>
228 <package><xsl:text>&#xA; </xsl:text>
229 <xsl:element name="name">$id</xsl:element>
230 <xsl:text>&#xA; </xsl:text>
231 <xsl:element name="version">$ver_ent</xsl:element>
232 <xsl:if
233 test="document(\$installed-packages)//package[name=current()/@id]">
234 <xsl:text>&#xA; </xsl:text>
235 <xsl:element name="inst-version">
236 <xsl:value-of
237 select="document(\$installed-packages
238 )//package[name=current()/@id]/version"/>
239 </xsl:element>
240 </xsl:if>
241<!-- Dependencies -->
242 <xsl:apply-templates select=".//para[@role='required' or
243 @role='recommended' or
244 @role='optional']"
245 mode="dependency"/>
246<!-- End dependencies -->
247 <xsl:text>&#xA; </xsl:text>
248 </package><xsl:text>&#xA;</xsl:text>
249 </xsl:otherwise>
250 </xsl:choose>
251 </xsl:when>
252EOF
253done
254
255cat >>$SPECIAL_FILE << EOF
256 <xsl:otherwise>
257 <xsl:apply-templates
258 select="self::node()[contains(translate(@xreflabel,
259 '123456789',
260 '000000000'),
261 '-0')
262 ]"
263 mode="normal"/>
264 </xsl:otherwise>
265 </xsl:choose>
266</xsl:template>
267EOF
268cat $SPECIAL_FILE tmpfile > tmpfile1
269mv tmpfile1 $SPECIAL_FILE
270rm tmpfile
271cat >> $SPECIAL_FILE << EOF
272 <xsl:otherwise>
273 <xsl:message>
274 <xsl:text>You should not be seeing this</xsl:text>
275 </xsl:message>
276 </xsl:otherwise>
277 </xsl:choose>
278</xsl:template>
279</xsl:stylesheet>
280EOF
Note: See TracBrowser for help on using the repository browser.