source: BLFS/gen-special.sh@ e3ccc27

ablfs-more legacy trunk
Last change on this file since e3ccc27 was 05f3977, checked in by Pierre Labastie <pierre@…>, 6 years ago

Add initramfs to non-versioned packages

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