source: BLFS/gen-special.sh@ 640cd57

ablfs-more trunk
Last change on this file since 640cd57 was 5ed69f8, checked in by Pierre Labastie <pierre.labastie@…>, 13 months ago

Dependency on xorg7-* only on last package

Our gen-special.sh transforms a dependency on compound packages
(xorg7-*) on a dependency on the list of packages. This generates
a lot of trials when removing circular dependencies, because if the
dependency on xorg7-* is optional, all packages in the list are tried
in turn, while it is sure that anyway the dependecy must be eliminated.
If the dependency is only on the last package, the circular dep
is eliminated at first try.

  • Property mode set to 100755
File size: 11.1 KB
RevLine 
[e576789]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
[5fb012d]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
[e576789]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
[4f3c433]35EXCEPTIONS=$(grep 'ENTITY.*version[ ]*"[^0-9"&.].*[0-9]' ${BLFS_DIR}/packages.ent |
[e576789]36 sed 's@^[^"]*"\([^"]*\)".*@\1@')
37
[5fb012d]38# Non-versioned packages:
[625cb14]39NV_LIST="postlfs-config-profile postlfs-config-random postlfs-config-vimrc \
[05f3977]40initramfs xorg-env kde-pre-install-config kf5-intro \
[625cb14]41lxqt-pre-install lxqt-post-install ojdk-conf tex-path"
[5fb012d]42
[e576789]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>
[82bd7a6]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>
[e576789]58EOF
59
[5fb012d]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
[e576789]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"/>
[7a0c3d2]98 <xsl:param name="build"/>
[e576789]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.
[9eb3dbe]119 list_cat="$(sed -n '/>cat/,/EOF</p' $file | grep -v 'cat\|EOF\|#' |
[342c862]120 awk '{ print $NF }' | sed 's/-&.*//')"
[e576789]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
[c2af9cd7]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
[e576789]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>
[7a0c3d2]156 <xsl:attribute name="build">before</xsl:attribute>
[e576789]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
[5ed69f8]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>
184#EOF
185 precpack=$packname
186 done
187 cat >>$SPECIAL_FILE << EOF
188 </package>
189 </xsl:when>
190EOF
191 cat >> tmpfile << EOF
[e576789]192 <xsl:element name="dependency">
193 <xsl:attribute name="status">
194 <xsl:value-of select="\$status"/>
195 </xsl:attribute>
[7a0c3d2]196 <xsl:attribute name="build">
197 <xsl:value-of select="\$build"/>
198 </xsl:attribute>
[e576789]199 <xsl:attribute name="name">$packname</xsl:attribute>
200 <xsl:attribute name="type">ref</xsl:attribute>
201 </xsl:element>
202 </xsl:when>
203EOF
204done
205
206for ver_ent in $EXCEPTIONS; do
207 id=$(grep 'xreflabel=".*'$ver_ent $BLFS_XML | sed 's@.*id="\([^"]*\)".*@\1@')
208 [[ -z $id ]] && continue
209 cat >>$SPECIAL_FILE << EOF
210 <xsl:when test="@id='$id'">
[1646303]211<!-- if there is a sect1 ancestor, we have a module -->
212 <xsl:choose>
213 <xsl:when test="ancestor::sect1">
214 <xsl:text> </xsl:text>
215 <module><xsl:text>&#xA; </xsl:text>
216 <xsl:element name="name">$id</xsl:element>
217 <xsl:text>&#xA; </xsl:text>
218 <xsl:element name="version">$ver_ent</xsl:element>
219 <xsl:if
220 test="document(\$installed-packages)//package[name=current()/@id]">
221 <xsl:text>&#xA; </xsl:text>
222 <xsl:element name="inst-version">
223 <xsl:value-of
224 select="document(\$installed-packages
225 )//package[name=current()/@id]/version"/>
226 </xsl:element>
227 </xsl:if>
[e576789]228<!-- Dependencies -->
[1646303]229 <xsl:apply-templates select=".//para[@role='required' or
230 @role='recommended' or
231 @role='optional']"
232 mode="dependency"/>
[e576789]233<!-- End dependencies -->
[1646303]234 <xsl:text>&#xA; </xsl:text>
235 </module><xsl:text>&#xA;</xsl:text>
236 </xsl:when>
237 <xsl:otherwise>
238 <xsl:text> </xsl:text>
239 <package><xsl:text>&#xA; </xsl:text>
240 <xsl:element name="name">$id</xsl:element>
241 <xsl:text>&#xA; </xsl:text>
242 <xsl:element name="version">$ver_ent</xsl:element>
243 <xsl:if
244 test="document(\$installed-packages)//package[name=current()/@id]">
245 <xsl:text>&#xA; </xsl:text>
246 <xsl:element name="inst-version">
247 <xsl:value-of
248 select="document(\$installed-packages
249 )//package[name=current()/@id]/version"/>
250 </xsl:element>
251 </xsl:if>
252<!-- Dependencies -->
253 <xsl:apply-templates select=".//para[@role='required' or
254 @role='recommended' or
255 @role='optional']"
256 mode="dependency"/>
257<!-- End dependencies -->
258 <xsl:text>&#xA; </xsl:text>
259 </package><xsl:text>&#xA;</xsl:text>
260 </xsl:otherwise>
261 </xsl:choose>
[e576789]262 </xsl:when>
263EOF
264done
265
266cat >>$SPECIAL_FILE << EOF
267 <xsl:otherwise>
268 <xsl:apply-templates
269 select="self::node()[contains(translate(@xreflabel,
270 '123456789',
271 '000000000'),
272 '-0')
273 ]"
274 mode="normal"/>
275 </xsl:otherwise>
276 </xsl:choose>
277</xsl:template>
278EOF
279cat $SPECIAL_FILE tmpfile > tmpfile1
280mv tmpfile1 $SPECIAL_FILE
281rm tmpfile
282cat >> $SPECIAL_FILE << EOF
283 <xsl:otherwise>
284 <xsl:message>
285 <xsl:text>You should not be seeing this</xsl:text>
286 </xsl:message>
287 </xsl:otherwise>
288 </xsl:choose>
289</xsl:template>
290</xsl:stylesheet>
291EOF
Note: See TracBrowser for help on using the repository browser.