source: BLFS/gen-special.sh@ 280cff6a

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

Make kf5-intro versioned

kf5-intro contains kf5-frameworks version, so should be run
each time there is a new version. We retrieve this version
from packages.ent, and we put it in packages.xml. This should
be enough.

  • Property mode set to 100755
File size: 11.5 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
[280cff6a]62# Actually, kf5-intro contains some version info, so should be
63# versioned. For other packages, we define version to 1.0.0
64# because the DTD needs a version tag.
65 DUM_VER=1.0.0
66 if [ $nv_id = kf5-intro ]; then
67 DUM_VER=$(grep kf5-version $BLFS_DIR/packages.ent | \
68 sed 's/.*"\([^"]*\).*/\1/')
69 fi
[5fb012d]70 cat >>$SPECIAL_FILE << EOF
71 <xsl:when test="@id='$nv_id'">
72 <xsl:text> </xsl:text>
73 <package><xsl:text>&#xA; </xsl:text>
74 <xsl:element name="name">$nv_id</xsl:element>
75 <xsl:text>&#xA; </xsl:text>
[280cff6a]76 <xsl:element name="version">$DUM_VER</xsl:element>
[5fb012d]77 <xsl:if
78 test="document(\$installed-packages)//package[name=current()/@id]">
79 <xsl:text>&#xA; </xsl:text>
80 <xsl:element name="inst-version">
81 <xsl:value-of
82 select="document(\$installed-packages
83 )//package[name=current()/@id]/version"/>
84 </xsl:element>
85 </xsl:if>
86<!-- Dependencies -->
87 <xsl:apply-templates select=".//para[@role='required' or
88 @role='recommended' or
89 @role='optional']"
90 mode="dependency"/>
91<!-- End dependencies -->
92 <xsl:text>&#xA; </xsl:text>
93 </package><xsl:text>&#xA;</xsl:text>
94 </xsl:when>
95EOF
96done
97
[e6a1ec3]98# Taking packages contained in pages installing several packages (x7* except
99# x7driver, kf5-frameworks, and plasma5-all), as versionned modules.
[e576789]100# We also write a dependency expansion when a dep is of the form
[e6a1ec3]101# xorg7-something or kf5-frameworks or plasma5-build. Since that is another
102# template, we need a temporary file, which we shall concatenate at the end
[e576789]103cat >tmpfile << EOF
104 <xsl:template name="expand-deps">
105 <xsl:param name="section"/>
106 <xsl:param name="status"/>
[7a0c3d2]107 <xsl:param name="build"/>
[e576789]108 <xsl:choose>
109EOF
[0cd09c6]110for file in $(ls ${BLFS_DIR}/x/installing/x7* | grep -v x7driver) \
111 ${BLFS_DIR}/kde/kf5/kf5-frameworks.xml \
112 ${BLFS_DIR}/kde/plasma5/plasma-all.xml; do
[e576789]113 id=$(grep xreflabel $file | sed 's@.*id="\([^"]*\).*@\1@')
114 cat >>$SPECIAL_FILE << EOF
115 <xsl:when test="@id='$id'">
116 <xsl:text> </xsl:text>
117 <package><xsl:text>&#xA; </xsl:text>
118 <xsl:element name="name">$id</xsl:element>
119 <xsl:text>&#xA; </xsl:text>
120EOF
121 cat >> tmpfile << EOF
122 <xsl:when test="\$section='$id'">
123EOF
[e6a1ec3]124# We extract the list of packages for those pages from
125# the "cat" command that creates the md5 file. We assume
[e576789]126# that the preceding package is a dependency of the following,
127# except the first.
[e6a1ec3]128# note that some pages may have several "cat" command, so we have to
129# make a complex regex for the first line to save. All those lines have
130# .md5 in them except the one for x7legacy that has .dat.
131# we need also to remove lines beginning with #.
132# Note that only xorg pages have '&' in them. So for kde
133# pages, what is extracted it the full tarball name.
[3439ff6]134 list_cat="$(sed -n '/>cat.*\.\(md5\|dat\)/,/EOF</p' $file | \
135 grep -v '>cat\|EOF<\|#' | \
136 awk '{ print $NF }' | sed 's/-&.*//')"
[e576789]137
[0cd09c6]138 precpack=NONE
139 for pack in $list_cat; do
140 if grep -q x7 $file; then # this is an xorg package
141 packname=$pack
[e6a1ec3]142# We extract the version from the ENTITY parts of the .xml file.
[0cd09c6]143 packversion=$(grep "ENTITY ${pack}-version" $file | \
144 sed 's@[^"]*"\([^"]*\).*@\1@')
145 else
[e6a1ec3]146 packname=${pack%-[[:digit:]]*}
[0cd09c6]147 packversion=$(echo $pack | sed 's/[^.]*-\([.[:digit:]]*\)\.tar.*/\1/')
148 fi
[e576789]149 cat >>$SPECIAL_FILE << EOF
150 <module><xsl:text>&#xA; </xsl:text>
151 <xsl:element name="name">$packname</xsl:element>
152 <xsl:element name="version">$packversion</xsl:element>
153 <xsl:if test="document(\$installed-packages)//package[name='$packname']">
154 <xsl:element name="inst-version">
155 <xsl:value-of
156 select="document(\$installed-packages
157 )//package[name='$packname']/version"/>
158 </xsl:element>
159 </xsl:if>
160<!-- Dependencies -->
161EOF
162 if test $precpack != NONE; then
163 cat >>$SPECIAL_FILE << EOF
164 <xsl:element name="dependency">
165 <xsl:attribute name="status">required</xsl:attribute>
[7a0c3d2]166 <xsl:attribute name="build">before</xsl:attribute>
[e576789]167 <xsl:attribute name="name">$precpack</xsl:attribute>
168 <xsl:attribute name="type">ref</xsl:attribute>
169 </xsl:element>
170EOF
171 else
172 cat >>$SPECIAL_FILE << EOF
173 <xsl:apply-templates select=".//para[@role='required' or
174 @role='recommended' or
175 @role='optional']"
176 mode="dependency"/>
177EOF
178 fi
179 cat >>$SPECIAL_FILE << EOF
180<!-- End dependencies -->
181 </module>
182EOF
[5ed69f8]183# cat >> tmpfile << EOF
184# <xsl:element name="dependency">
185# <xsl:attribute name="status">
186# <xsl:value-of select="\$status"/>
187# </xsl:attribute>
188# <xsl:attribute name="build">
189# <xsl:value-of select="\$build"/>
190# </xsl:attribute>
191# <xsl:attribute name="name">$packname</xsl:attribute>
192# <xsl:attribute name="type">ref</xsl:attribute>
193# </xsl:element>
194#EOF
195 precpack=$packname
196 done
197 cat >>$SPECIAL_FILE << EOF
198 </package>
199 </xsl:when>
200EOF
201 cat >> tmpfile << EOF
[e576789]202 <xsl:element name="dependency">
203 <xsl:attribute name="status">
204 <xsl:value-of select="\$status"/>
205 </xsl:attribute>
[7a0c3d2]206 <xsl:attribute name="build">
207 <xsl:value-of select="\$build"/>
208 </xsl:attribute>
[e576789]209 <xsl:attribute name="name">$packname</xsl:attribute>
210 <xsl:attribute name="type">ref</xsl:attribute>
211 </xsl:element>
212 </xsl:when>
213EOF
214done
215
216for ver_ent in $EXCEPTIONS; do
217 id=$(grep 'xreflabel=".*'$ver_ent $BLFS_XML | sed 's@.*id="\([^"]*\)".*@\1@')
218 [[ -z $id ]] && continue
219 cat >>$SPECIAL_FILE << EOF
220 <xsl:when test="@id='$id'">
[1646303]221<!-- if there is a sect1 ancestor, we have a module -->
222 <xsl:choose>
223 <xsl:when test="ancestor::sect1">
224 <xsl:text> </xsl:text>
225 <module><xsl:text>&#xA; </xsl:text>
226 <xsl:element name="name">$id</xsl:element>
227 <xsl:text>&#xA; </xsl:text>
228 <xsl:element name="version">$ver_ent</xsl:element>
229 <xsl:if
230 test="document(\$installed-packages)//package[name=current()/@id]">
231 <xsl:text>&#xA; </xsl:text>
232 <xsl:element name="inst-version">
233 <xsl:value-of
234 select="document(\$installed-packages
235 )//package[name=current()/@id]/version"/>
236 </xsl:element>
237 </xsl:if>
[e576789]238<!-- Dependencies -->
[1646303]239 <xsl:apply-templates select=".//para[@role='required' or
240 @role='recommended' or
241 @role='optional']"
242 mode="dependency"/>
[e576789]243<!-- End dependencies -->
[1646303]244 <xsl:text>&#xA; </xsl:text>
245 </module><xsl:text>&#xA;</xsl:text>
246 </xsl:when>
247 <xsl:otherwise>
248 <xsl:text> </xsl:text>
249 <package><xsl:text>&#xA; </xsl:text>
250 <xsl:element name="name">$id</xsl:element>
251 <xsl:text>&#xA; </xsl:text>
252 <xsl:element name="version">$ver_ent</xsl:element>
253 <xsl:if
254 test="document(\$installed-packages)//package[name=current()/@id]">
255 <xsl:text>&#xA; </xsl:text>
256 <xsl:element name="inst-version">
257 <xsl:value-of
258 select="document(\$installed-packages
259 )//package[name=current()/@id]/version"/>
260 </xsl:element>
261 </xsl:if>
262<!-- Dependencies -->
263 <xsl:apply-templates select=".//para[@role='required' or
264 @role='recommended' or
265 @role='optional']"
266 mode="dependency"/>
267<!-- End dependencies -->
268 <xsl:text>&#xA; </xsl:text>
269 </package><xsl:text>&#xA;</xsl:text>
270 </xsl:otherwise>
271 </xsl:choose>
[e576789]272 </xsl:when>
273EOF
274done
275
276cat >>$SPECIAL_FILE << EOF
277 <xsl:otherwise>
278 <xsl:apply-templates
279 select="self::node()[contains(translate(@xreflabel,
280 '123456789',
281 '000000000'),
282 '-0')
283 ]"
284 mode="normal"/>
285 </xsl:otherwise>
286 </xsl:choose>
287</xsl:template>
288EOF
289cat $SPECIAL_FILE tmpfile > tmpfile1
290mv tmpfile1 $SPECIAL_FILE
291rm tmpfile
292cat >> $SPECIAL_FILE << EOF
293 <xsl:otherwise>
294 <xsl:message>
295 <xsl:text>You should not be seeing this</xsl:text>
296 </xsl:message>
297 </xsl:otherwise>
298 </xsl:choose>
299</xsl:template>
300</xsl:stylesheet>
301EOF
Note: See TracBrowser for help on using the repository browser.