- Timestamp:
- 03/31/2013 05:25:21 PM (11 years ago)
- Branches:
- ablfs
- Children:
- 9fe527f
- Parents:
- d0c94a3
- Location:
- BLFS
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
BLFS/gen-special.sh
rd0c94a3 rd236bbd 2 2 3 3 # $Id: gen-special.sh 21 2012-02-16 15:06:19Z labastie $ 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 # - If a pacakge is versioned but the version is not mentioned in the book 15 # (currently only udev), we retrieve the version by other means 16 #------------------------------------------------------------------------- 17 # Arguments: 18 # $1 contains the name of the validated xml book 19 # $2 contains the name of the ouput xsl file 20 # $3 contains the name of the book sources directory 21 #------------------------------------------------------------------------- 4 22 5 23 BLFS_XML=$1 6 24 if ! test -f ${BLFS_XML}; then 7 echo ${BLFS_XML}does not exist25 echo File \`${BLFS_XML}\' does not exist 8 26 exit 1 9 27 fi 10 28 SPECIAL_FILE=$2 11 29 if test -z "${SPECIAL_FILE}"; then SPECIAL_FILE=specialCases.xsl;fi 30 BLFS_DIR=$3 31 if test -z "${BLFS_DIR}"; then BLFS_DIR=$(cd $(dirname ${BLFS_XML})/.. ; pwd);fi 32 12 33 # Packages whose version does not begin with a number 13 34 EXCEPTIONS=$(grep 'ENTITY.*version[ ]*"[^0-9"&.].*[0-9]' $BLFS_XML | 14 35 sed 's@^[^"]*"\([^"]*\)".*@\1@') 15 # Version for X Window packages without a version in the book 16 XVERSION=$(grep 'ENTITY xorg-version' $BLFS_XML | 17 sed 's@^[^"]*"\([^"]*\)".*@\1@') 18 # The case of udev 36 19 37 # Set PATH to be sure to find udevadm 20 38 SAVPATH=$PATH … … 30 48 <xsl:template match='*' mode="special"> 31 49 <xsl:choose> 32 <xsl:when test=" @id='udev'">50 <xsl:when test="contains(@id,'udev')"> 33 51 <xsl:text> </xsl:text> 34 52 <package><xsl:text>
 </xsl:text> … … 54 72 </package><xsl:text>
</xsl:text> 55 73 </xsl:when> 74 <!-- Although versioned, this page is not a package --> 56 75 <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'))"> 76 EOF 77 78 # Taking packages inside x7proto etc, as versionned modules. 79 # We also write a dependency expansion when a dep is of the form 80 # xorg7-something. Since that is another template, we need 81 # a temporary file, which we shall concatenate at the end 82 cat >tmpfile << EOF 83 <xsl:template name="expand-deps"> 84 <xsl:param name="section"/> 85 <xsl:param name="status"/> 86 <xsl:choose> 87 EOF 88 for file in $(ls ${BLFS_DIR}/x/installing/x7* | grep -v x7driver); do 89 id=$(grep xreflabel $file | sed 's@.*id="\([^"]*\).*@\1@') 90 cat >>$SPECIAL_FILE << EOF 91 <xsl:when test="@id='$id'"> 62 92 <xsl:text> </xsl:text> 63 93 <package><xsl:text>
 </xsl:text> 64 <xsl:element name="name"> <xsl:value-of select="@id"/></xsl:element>94 <xsl:element name="name">$id</xsl:element> 65 95 <xsl:text>
 </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>
 </xsl:text> 70 <xsl:element name="inst-version"> 71 <xsl:value-of 72 select="document(\$installed-packages 73 )//package[name=current()/@id]/version"/> 96 EOF 97 cat >> tmpfile << EOF 98 <xsl:when test="\$section='$id'"> 99 EOF 100 # In the list, the preceding package is a dependency of the following, 101 # except the first: 102 precpack=NONE 103 # Rationale for the sed below: the following for breaks words at spaces (unless 104 # we tweak IFS). So replace spaces with commas in lines so that only newlines 105 # are separators. 106 for pack in \ 107 $(grep 'ENTITY.*version' $file | sed 's/[ ]\+/,/g'); do 108 packname=$(echo $pack | sed s'@.*ENTITY,\(.*\)-version.*@\1@') 109 packversion=$(echo $pack | sed 's@[^"]*"\([^"]*\).*@\1@') 110 cat >>$SPECIAL_FILE << EOF 111 <module><xsl:text>
 </xsl:text> 112 <xsl:element name="name">$packname</xsl:element> 113 <xsl:element name="version">$packversion</xsl:element> 114 <xsl:if test="document(\$installed-packages)//package[name='$packname']"> 115 <xsl:element name="inst-version"> 116 <xsl:value-of 117 select="document(\$installed-packages 118 )//package[name='$packname']/version"/> 119 </xsl:element> 120 </xsl:if> 121 <!-- Dependencies --> 122 EOF 123 if test $precpack != NONE; then 124 cat >>$SPECIAL_FILE << EOF 125 <xsl:element name="dependency"> 126 <xsl:attribute name="status">required</xsl:attribute> 127 <xsl:attribute name="name">$precpack</xsl:attribute> 128 <xsl:attribute name="type">ref</xsl:attribute> 74 129 </xsl:element> 75 </xsl:if> 76 <!-- Dependencies --> 77 <xsl:text> 78 </xsl:text> 130 EOF 131 else 132 cat >>$SPECIAL_FILE << EOF 133 <xsl:apply-templates select=".//para[@role='required' or 134 @role='recommended' or 135 @role='optional']" 136 mode="dependency"/> 137 EOF 138 fi 139 cat >>$SPECIAL_FILE << EOF 140 <!-- End dependencies --> 141 </module> 142 EOF 143 cat >> tmpfile << EOF 79 144 <xsl:element name="dependency"> 80 <xsl:attribute name="status">required</xsl:attribute> 81 <xsl:attribute name="name"> 82 <xsl:value-of 83 select="preceding-sibling::sect1[1]/@id"/> 145 <xsl:attribute name="status"> 146 <xsl:value-of select="\$status"/> 84 147 </xsl:attribute> 148 <xsl:attribute name="name">$packname</xsl:attribute> 85 149 <xsl:attribute name="type">ref</xsl:attribute> 86 150 </xsl:element> 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>
 </xsl:text> 93 </package><xsl:text>
</xsl:text> 94 </xsl:when> 95 EOF 151 EOF 152 precpack=$packname 153 done 154 cat >>$SPECIAL_FILE << EOF 155 </package> 156 </xsl:when> 157 EOF 158 cat >> tmpfile << EOF 159 </xsl:when> 160 EOF 161 done 96 162 97 163 for ver_ent in $EXCEPTIONS; do … … 138 204 </xsl:choose> 139 205 </xsl:template> 140 206 EOF 207 cat $SPECIAL_FILE tmpfile > tmpfile1 208 mv tmpfile1 $SPECIAL_FILE 209 rm tmpfile 210 cat >> $SPECIAL_FILE << EOF 211 <xsl:otherwise> 212 <xsl:message> 213 <xsl:text>You should not be seeing this</xsl:text> 214 </xsl:message> 215 </xsl:otherwise> 216 </xsl:choose> 217 </xsl:template> 141 218 </xsl:stylesheet> 142 219 EOF -
BLFS/xsl/gen_config.xsl
rd0c94a3 rd236bbd 182 182 </xsl:if> 183 183 <xsl:text>" 184 			default	n 185 186 </xsl:text> 184 			default	</xsl:text> 185 <xsl:choose> 186 <xsl:when test="contains(../name,'xorg')"> 187 <xsl:text>y 188 189 </xsl:text> 190 </xsl:when> 191 <xsl:otherwise> 192 <xsl:text>n 193 194 </xsl:text> 195 </xsl:otherwise> 196 </xsl:choose> 187 197 </xsl:if> 188 198 </xsl:template> -
BLFS/xsl/gen_pkg_list.xsl
rd0c94a3 rd236bbd 257 257 <!-- No ulink for now (see special case for Perl modules) --> 258 258 <xsl:for-each select="./xref"> 259 <xsl:text> 259 <xsl:choose> 260 <xsl:when test="contains(@linkend,'xorg7-')"> 261 <xsl:call-template name="expand-deps"> 262 <xsl:with-param name="section"> 263 <xsl:value-of select="@linkend"/> 264 </xsl:with-param> 265 <xsl:with-param name="status"> 266 <xsl:value-of select="$status"/> 267 </xsl:with-param> 268 </xsl:call-template> 269 </xsl:when> 270 <xsl:otherwise> 271 <xsl:text> 260 272 </xsl:text> 261 <xsl:element name="dependency"> 262 <xsl:attribute name="status"> 263 <xsl:value-of select="$status"/> 264 </xsl:attribute> 265 <xsl:attribute name="name"> 266 <xsl:value-of select="@linkend"/> 267 </xsl:attribute> 268 <xsl:attribute name="type">ref</xsl:attribute> 269 </xsl:element> 273 <xsl:element name="dependency"> 274 <xsl:attribute name="status"> 275 <xsl:value-of select="$status"/> 276 </xsl:attribute> 277 <xsl:attribute name="name"> 278 <xsl:value-of select="@linkend"/> 279 </xsl:attribute> 280 <xsl:attribute name="type">ref</xsl:attribute> 281 </xsl:element> 282 </xsl:otherwise> 283 </xsl:choose> 270 284 </xsl:for-each> 271 285 </xsl:template> -
BLFS/xsl/make_book.xsl
rd0c94a3 rd236bbd 35 35 </xsl:template> 36 36 37 <!-- apply-templates for each id in the list. 37 <!-- apply-templates for each item in the list. 38 Normally, those items are id of nodes. 38 39 Those nodes can be sect1 (normal case), 39 40 sect2 (python modules or DBus bindings) 40 41 bridgehead (perl modules) 41 42 para (dependency of perl modules). 42 The templates after this one treat each of those cases--> 43 The templates after this one treat each of those cases. 44 However, some items are xorg package names, and not id. 45 We need special instructions in that case. 46 The difficulty is that some of those names *are* id's, 47 because they are referenced in the index. 48 Hopefully, none of those id's are sect{1,2}, bridgehead or para...--> 43 49 <xsl:template name="apply-list"> 44 50 <xsl:param name="list" select="''"/> … … 46 52 <xsl:choose> 47 53 <xsl:when test="contains($list,' ')"> 48 <xsl:apply-templates select="id(substring-before($list,' '))"/> 54 <xsl:call-template name="apply-list"> 55 <xsl:with-param name="list" 56 select="substring-before($list,' ')"/> 57 </xsl:call-template> 49 58 <xsl:call-template name="apply-list"> 50 59 <xsl:with-param name="list" … … 53 62 </xsl:when> 54 63 <xsl:otherwise> 55 <xsl:apply-templates select="id($list)"/> 64 <xsl:choose> 65 <xsl:when test="not(id($list)/self::sect1|sect2|para|bridgehead)"> 66 <xsl:apply-templates 67 select="//sect1[contains(string(.//userinput),$list)]" 68 mode="xorg"> 69 <xsl:with-param name="package" select="$list"/> 70 </xsl:apply-templates> 71 </xsl:when> 72 <xsl:otherwise> 73 <xsl:apply-templates select="id($list)"/> 74 </xsl:otherwise> 75 </xsl:choose> 56 76 </xsl:otherwise> 57 77 </xsl:choose> … … 266 286 </sect2> 267 287 </xsl:template> 288 289 <!-- we have got an xorg package. We are at the installation page 290 but now we need to make an autonomous page from the global 291 one --> 292 <xsl:template match="sect1" mode="xorg"> 293 <xsl:param name="package"/> 294 <xsl:variable name="tarball"> 295 <xsl:call-template name="tarball"> 296 <xsl:with-param name="package" select="$package"/> 297 <xsl:with-param name="cat-md5" 298 select="string(.//userinput[starts-with(string(),'cat')])"/> 299 </xsl:call-template> 300 </xsl:variable> 301 <xsl:variable name="md5sum"> 302 <xsl:call-template name="md5sum"> 303 <xsl:with-param name="package" select="$package"/> 304 <xsl:with-param name="cat-md5" 305 select=".//userinput[starts-with(string(),'cat')]"/> 306 </xsl:call-template> 307 </xsl:variable> 308 <xsl:variable name="install-instructions"> 309 <xsl:call-template name="inst-instr"> 310 <xsl:with-param name="inst-instr" 311 select=".//userinput[starts-with(string(),'for')]"/> 312 </xsl:call-template> 313 </xsl:variable> 314 <xsl:element name="sect1"> 315 <xsl:attribute name="id"><xsl:value-of select="$package"/></xsl:attribute> 316 <xsl:processing-instruction name="dbhtml"> 317 filename="<xsl:value-of select='$package'/>.html" 318 </xsl:processing-instruction> 319 <title><xsl:value-of select="$package"/></title> 320 <sect2 role="package"> 321 <title>Introduction to <xsl:value-of select="$package"/></title> 322 <bridgehead renderas="sect3">Package Information</bridgehead> 323 <itemizedlist spacing="compact"> 324 <listitem> 325 <para>Download (HTTP): <xsl:element name="ulink"> 326 <xsl:attribute name="url"> 327 <xsl:value-of 328 select=".//para[contains(string(),'(HTTP)')]/ulink/@url"/> 329 <xsl:value-of select="$tarball"/> 330 </xsl:attribute> 331 </xsl:element> 332 </para> 333 </listitem> 334 <listitem> 335 <para>Download (FTP): <xsl:element name="ulink"> 336 <xsl:attribute name="url"> 337 <xsl:value-of 338 select=".//para[contains(string(),'(FTP)')]/ulink/@url"/> 339 <xsl:value-of select="$tarball"/> 340 </xsl:attribute> 341 </xsl:element> 342 </para> 343 </listitem> 344 <listitem> 345 <para> 346 Download MD5 sum: <xsl:value-of select="$md5sum"/> 347 </para> 348 </listitem> 349 </itemizedlist> 350 </sect2> 351 <sect2 role="installation"> 352 <title>Installation of <xsl:value-of select="$package"/></title> 353 354 <para> 355 Install <application><xsl:value-of select="$package"/></application> 356 by running the following commands: 357 </para> 358 359 <screen><userinput>packagedir=<xsl:value-of 360 select="substring-before($tarball,'.tar.bz2')"/> 361 <xsl:text>
</xsl:text> 362 <xsl:value-of select="substring-before($install-instructions, 363 'as_root')"/> 364 </userinput></screen> 365 366 <para> 367 Now as the <systemitem class="username">root</systemitem> user: 368 </para> 369 <screen role='root'> 370 <userinput><xsl:value-of select="substring-after( 371 $install-instructions, 372 'as_root')"/> 373 </userinput> 374 </screen> 375 </sect2> 376 </xsl:element><!-- sect1 --> 377 378 </xsl:template> 379 380 <!-- get the tarball name from the text that comes from the .md5 file --> 381 <xsl:template name="tarball"> 382 <xsl:param name="package"/> 383 <xsl:param name="cat-md5"/> 384 <!-- DEBUG 385 <xsl:message><xsl:text>Entering "tarball" template: 386 package is: </xsl:text> 387 <xsl:value-of select="$package"/><xsl:text> 388 cat-md5 is: </xsl:text> 389 <xsl:value-of select="$cat-md5"/> 390 </xsl:message> 391 END DEBUG --> 392 <xsl:choose> 393 <xsl:when test="contains(substring-before($cat-md5,$package),'
')"> 394 <xsl:call-template name="tarball"> 395 <xsl:with-param name="package" select="$package"/> 396 <xsl:with-param name="cat-md5" 397 select="substring-after($cat-md5,'
')"/> 398 </xsl:call-template> 399 </xsl:when> 400 <xsl:otherwise> 401 <xsl:copy-of select="substring-after( 402 substring-before($cat-md5,'
'),' ')"/> 403 </xsl:otherwise> 404 </xsl:choose> 405 </xsl:template> 406 <!-- same for md5sum --> 407 <xsl:template name="md5sum"> 408 <xsl:param name="package"/> 409 <xsl:param name="cat-md5"/> 410 <xsl:choose> 411 <xsl:when test="contains(substring-before($cat-md5,$package),'
')"> 412 <xsl:call-template name="md5sum"> 413 <xsl:with-param name="package" select="$package"/> 414 <xsl:with-param name="cat-md5" 415 select="substring-after($cat-md5,'
')"/> 416 </xsl:call-template> 417 </xsl:when> 418 <xsl:otherwise> 419 <xsl:copy-of select="substring-before($cat-md5,' ')"/> 420 </xsl:otherwise> 421 </xsl:choose> 422 </xsl:template> 423 424 <xsl:template name="inst-instr"> 425 <xsl:param name="inst-instr"/> 426 <xsl:choose> 427 <xsl:when test="contains($inst-instr,'pushd')"> 428 <xsl:call-template name="inst-instr"> 429 <xsl:with-param name="inst-instr" 430 select="substring-after( 431 substring-after($inst-instr,'pushd'), 432 '
')"/> 433 </xsl:call-template> 434 </xsl:when> 435 <xsl:otherwise> 436 <xsl:copy-of select="substring-before($inst-instr,'popd')"/> 437 </xsl:otherwise> 438 </xsl:choose> 439 </xsl:template> 268 440 </xsl:stylesheet>
Note:
See TracChangeset
for help on using the changeset viewer.