- Timestamp:
- 02/22/2012 05:09:47 PM (13 years ago)
- Branches:
- ablfs
- Children:
- c1987b0
- Parents:
- 0216209
- Location:
- BLFS/xsl
- Files:
-
- 5 added
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
BLFS/xsl/scripts.xsl
r0216209 r63fc514 6 6 version="1.0"> 7 7 8 <!-- $Id $ -->8 <!-- $Id: scripts.xsl 34 2012-02-21 16:05:09Z labastie $ --> 9 9 10 10 <!-- XSLT stylesheet to create shell scripts from "linear build" BLFS books. --> … … 20 20 21 21 <xsl:template match="sect1"> 22 <xsl:if test="(count(descendant::screen/userinput) > 0 and 23 count(descendant::screen/userinput) > 24 count(descendant::screen[@role='nodump'])) and 25 @id != 'locale-issues' and @id != 'xorg7' and 26 @id != 'x-setup'"> 27 22 23 <xsl:if test="@id != 'bootscripts'"> 28 24 <!-- The file names --> 29 25 <xsl:variable name="filename" select="@id"/> 30 31 <!-- Package name (use "Download FTP" by default. If empty, use "Download HTTP" -->32 <xsl:variable name="package">33 <xsl:choose>34 <xsl:when35 test="string-length(sect2[@role='package']/itemizedlist/listitem[2]/para/ulink/@url)36 > '10'">37 <xsl:call-template name="package_name">38 <xsl:with-param name="url"39 select="sect2[@role='package']/itemizedlist/listitem[2]/para/ulink/@url"/>40 </xsl:call-template>41 </xsl:when>42 <xsl:otherwise>43 <xsl:call-template name="package_name">44 <xsl:with-param name="url"45 select="sect2[@role='package']/itemizedlist/listitem[1]/para/ulink/@url"/>46 </xsl:call-template>47 </xsl:otherwise>48 </xsl:choose>49 </xsl:variable>50 51 <!-- FTP dir name -->52 <xsl:variable name="ftpdir">53 <xsl:call-template name="ftp_dir">54 <xsl:with-param name="package" select="$package"/>55 </xsl:call-template>56 </xsl:variable>57 26 58 27 <!-- The build order --> … … 77 46 <xsl:message> 78 47 <xsl:text>SCRIPT is </xsl:text> 79 <xsl:value-of select="concat($order,'-',$filename)"/> 80 <xsl:text>
 PACKAGE is </xsl:text> 81 <xsl:value-of select="$package"/> 48 <xsl:value-of select="concat($order,'-z-',$filename)"/> 82 49 <xsl:text>
 FTPDIR is </xsl:text> 83 <xsl:value-of select="$f tpdir"/>50 <xsl:value-of select="$filename"/> 84 51 <xsl:text>

</xsl:text> 85 52 </xsl:message> … … 95 62 @id = 'xorg7-proto' or @id = 'xorg7-util')"> 96 63 <!-- Variables --> 64 <!-- These three lines could be important if SRC_ARCHIVE, 65 FTP_SERVER and SRCDIR were not set in the environment. 66 But they are not tested for length or anything later, 67 so not needed 97 68 <xsl:text>SRC_ARCHIVE=$SRC_ARCHIVE
</xsl:text> 98 <xsl:text>FTP_SERVER=$FTP_SERVER
 
PACKAGE=</xsl:text>99 <xsl: value-of select="$package"/>69 <xsl:text>FTP_SERVER=$FTP_SERVER
</xsl:text> 70 <xsl:text>SRC_DIR=$SRC_DIR

</xsl:text>--> 100 71 <xsl:text>
PKG_DIR=</xsl:text> 101 <xsl:value-of select="$f tpdir"/>102 <xsl:text>
 SRC_DIR=$SRC_DIR

</xsl:text>72 <xsl:value-of select="$filename"/> 73 <xsl:text>
</xsl:text> 103 74 <!-- Download code and build commands --> 104 <xsl:apply-templates select="sect2"> 105 <xsl:with-param name="package" select="$package"/> 106 <xsl:with-param name="ftpdir" select="$ftpdir"/> 107 </xsl:apply-templates> 75 <xsl:apply-templates select="sect2"/> 108 76 <!-- Clean-up --> 109 <xsl:if test="not(@id='mesalib')"> 77 <!-- xorg7-server used to require mesalib tree being present. 78 That is no more true 79 <xsl:if test="not(@id='mesalib')"> --> 110 80 <xsl:text>cd $SRC_DIR/$PKG_DIR
</xsl:text> 111 81 <xsl:text>rm -rf $UNPACKDIR unpacked

</xsl:text> 82 <!-- Same reason as preceding comment 112 83 </xsl:if> 113 84 <xsl:if test="@id='xorg7-server'"> … … 115 86 UNPACKDIR=`head -n1 unpacked | sed 's@^./@@;s@/.*@@'` 116 87 rm -rf $UNPACKDIR unpacked

</xsl:text> 117 </xsl:if> 88 </xsl:if> --> 118 89 </xsl:when> 119 90 <!-- Xorg7 pseudo-packages --> 120 91 <xsl:when test="contains(@id,'xorg7') and not(@id = 'xorg7-server')"> 121 <xsl:text> SRC_DIR=$SRC_DIR92 <xsl:text># Useless SRC_DIR=$SRC_DIR 122 93 123 94 cd $SRC_DIR … … 133 104 <xsl:text>exit</xsl:text> 134 105 </exsl:document> 135 136 106 </xsl:if> 137 107 </xsl:template> … … 140 110 141 111 <xsl:template match="sect2"> 142 <xsl:param name="package" select="foo"/>143 <xsl:param name="ftpdir" select="foo"/>144 112 <xsl:choose> 145 113 <xsl:when test="@role = 'package'"> 146 114 <xsl:text>mkdir -p $SRC_DIR/$PKG_DIR
</xsl:text> 147 115 <xsl:text>cd $SRC_DIR/$PKG_DIR
</xsl:text> 148 <xsl:apply-templates select="itemizedlist/listitem/para"> 149 <xsl:with-param name="package" select="$package"/> 150 <xsl:with-param name="ftpdir" select="$ftpdir"/> 151 </xsl:apply-templates> 116 <xsl:apply-templates select="bridgehead[@renderas='sect3']"/> 152 117 <xsl:text>
</xsl:text> 153 118 </xsl:when> … … 168 133 </xsl:when> 169 134 <xsl:when test="@role = 'configuration'"> 170 <xsl:apply-templates select=".//screen"/> 171 <xsl:text>
</xsl:text> 135 <xsl:apply-templates select=".//screen" mode="config"/> 172 136 </xsl:when> 173 137 </xsl:choose> … … 180 144 </xsl:when> 181 145 <xsl:when test="not(@role)"> 182 <xsl:text>SRC_ARCHIVE=$SRC_ARCHIVE183 FTP_SERVER=$FTP_SERVER
</xsl:text> 146 <!-- Useless <xsl:text>SRC_ARCHIVE=$SRC_ARCHIVE 147 FTP_SERVER=$FTP_SERVER
</xsl:text> --> 184 148 <xsl:apply-templates select=".//screen" mode="sect-ver"/> 185 149 <xsl:text>mkdir -p ${section}
cd ${section}
</xsl:text> … … 196 160 cp $SRC_ARCHIVE/${line} ${line} 197 161 else 198 wget ${FTP_SERVER}conglomeration/Xorg/${line} || \199 wget http://xorg.freedesktop.org/releases/individual/${section}/${line}162 wget -T 30 -t 5 ${FTP_X_SERVER}pub/individual/${section}/${line} || \ 163 wget -T 30 -t 5 http://xorg.freedesktop.org/releases/individual/${section}/${line} 200 164 fi 201 165 fi … … 246 210 <xsl:value-of select="substring-before($sub-url,'?')"/> 247 211 </xsl:when> 248 <xsl:when test="contains($sub-url,'.patch')"/> 212 <!-- Should never happen 213 <xsl:when test="contains($sub-url,'.patch')"/> --> 249 214 <xsl:otherwise> 250 215 <xsl:value-of select="$sub-url"/> … … 255 220 </xsl:template> 256 221 257 <xsl:template name="ftp_dir"> 258 <xsl:param name="package" select="foo"/> 259 <!-- A lot of hardcoded dir names. Not full revised yet. --> 260 <xsl:choose> 261 <!-- cdparanoia --> 262 <xsl:when test="contains($package, '-III')"> 263 <xsl:text>cdparanoia</xsl:text> 264 </xsl:when> 265 <!-- DobBook 3.1 --> 266 <xsl:when test="contains($package, 'docbk31')"> 267 <xsl:text>docbk</xsl:text> 268 </xsl:when> 269 <!-- gc --> 270 <xsl:when test="contains($package, 'gc6')"> 271 <xsl:text>gc</xsl:text> 272 </xsl:when> 273 <!-- ISO-codes --> 274 <xsl:when test="contains($package, 'iso-codes')"> 275 <xsl:text>iso-codes</xsl:text> 276 </xsl:when> 277 <!-- JPEG --> 278 <xsl:when test="contains($package, 'jpegsrc')"> 279 <xsl:text>jpeg</xsl:text> 280 </xsl:when> 281 <!-- lynx --> 282 <xsl:when test="contains($package, 'lynx')"> 283 <xsl:text>lynx</xsl:text> 284 </xsl:when> 285 <!-- ntp --> 286 <xsl:when test="contains($package, 'ntp')"> 287 <xsl:text>ntp</xsl:text> 288 </xsl:when> 289 <!-- OpenLDAP --> 290 <xsl:when test="contains($package, 'openldap')"> 291 <xsl:text>openldap</xsl:text> 292 </xsl:when> 293 <!-- Open Office --> 294 <xsl:when test="contains($package, 'OOo')"> 295 <xsl:text>OOo</xsl:text> 296 </xsl:when> 297 <!-- pine --> 298 <xsl:when test="contains($package, 'pine')"> 299 <xsl:text>pine</xsl:text> 300 </xsl:when> 301 <!-- portmap --> 302 <xsl:when test="contains($package, 'portmap')"> 303 <xsl:text>portmap</xsl:text> 304 </xsl:when> 305 <!-- psutils --> 306 <xsl:when test="contains($package, 'psutils')"> 307 <xsl:text>psutils</xsl:text> 308 </xsl:when> 309 <!-- qpopper --> 310 <xsl:when test="contains($package, 'qpopper')"> 311 <xsl:text>qpopper</xsl:text> 312 </xsl:when> 313 <!-- QT --> 314 <xsl:when test="contains($package, 'qt-x')"> 315 <xsl:text>qt-x11-free</xsl:text> 316 </xsl:when> 317 <!-- sendmail --> 318 <xsl:when test="contains($package, 'sendmail')"> 319 <xsl:text>sendmail</xsl:text> 320 </xsl:when> 321 <!-- Slib --> 322 <xsl:when test="contains($package, 'slib')"> 323 <xsl:text>slib</xsl:text> 324 </xsl:when> 325 <!-- TCL --> 326 <xsl:when test="contains($package, 'tcl')"> 327 <xsl:text>tcl</xsl:text> 328 </xsl:when> 329 <!-- tcpwrappers --> 330 <xsl:when test="contains($package, 'tcp_wrappers')"> 331 <xsl:text>tcp_wrappers</xsl:text> 332 </xsl:when> 333 <!-- TeTeX --> 334 <xsl:when test="contains($package, 'tetex')"> 335 <xsl:text>tetex</xsl:text> 336 </xsl:when> 337 <!-- Tidy --> 338 <xsl:when test="contains($package, 'tidy')"> 339 <xsl:text>tidy</xsl:text> 340 </xsl:when> 341 <!-- Tk --> 342 <xsl:when test="contains($package, 'tk8')"> 343 <xsl:text>tk</xsl:text> 344 </xsl:when> 345 <!-- unzip --> 346 <xsl:when test="contains($package, 'unzip')"> 347 <xsl:text>unzip</xsl:text> 348 </xsl:when> 349 <!-- wireless_tools --> 350 <xsl:when test="contains($package, 'wireless_tools')"> 351 <xsl:text>wireless_tools</xsl:text> 352 </xsl:when> 353 <!-- whois --> 354 <xsl:when test="contains($package, 'whois')"> 355 <xsl:text>whois</xsl:text> 356 </xsl:when> 357 <!-- XOrg --> 358 <xsl:when test="contains($package, 'X11R6')"> 359 <xsl:text>Xorg</xsl:text> 360 </xsl:when> 361 <!-- zip --> 362 <xsl:when test="contains($package, 'zip2')"> 363 <xsl:text>zip</xsl:text> 364 </xsl:when> 365 <!-- General rule --> 366 <xsl:otherwise> 367 <xsl:variable name="cut" 368 select="translate(substring-after($package, '-'), '0123456789', '0000000000')"/> 369 <xsl:variable name="package2"> 370 <xsl:value-of select="substring-before($package, '-')"/> 371 <xsl:text>-</xsl:text> 372 <xsl:value-of select="$cut"/> 222 <xsl:template match="bridgehead"> 223 <xsl:choose> 224 <xsl:when test="string()='Package Information'"> 225 <xsl:variable name="url"> 226 <xsl:choose> 227 <xsl:when 228 test="string-length( 229 following-sibling::itemizedlist[1]/listitem[1]/para/ulink/@url) 230 > 10"> 231 <xsl:value-of select= 232 "following-sibling::itemizedlist[1]/listitem[1]/para/ulink/@url"/> 233 </xsl:when> 234 <xsl:otherwise> 235 <xsl:value-of select= 236 "following-sibling::itemizedlist[1]/listitem[2]/para/ulink/@url"/> 237 </xsl:otherwise> 238 </xsl:choose> 373 239 </xsl:variable> 374 <xsl:value-of select="substring-before($package2, '-0')"/> 375 </xsl:otherwise> 376 </xsl:choose> 377 </xsl:template> 378 379 <xsl:template match="itemizedlist/listitem/para"> 380 <xsl:param name="package" select="foo"/> 381 <xsl:param name="ftpdir" select="foo"/> 382 <xsl:choose> 383 <!-- This depend on all package pages having both "Download HTTP" and "Download FTP" lines --> 384 <xsl:when test="contains(string(),'HTTP')"> 385 <xsl:text>if [[ ! -f $PACKAGE ]] ; then
</xsl:text> 240 <xsl:variable name="package"> 241 <xsl:call-template name="package_name"> 242 <xsl:with-param name="url" select="$url"/> 243 </xsl:call-template> 244 </xsl:variable> 245 <xsl:variable 246 name="first_letter" 247 select="translate(substring($package,1,1), 248 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 249 'abcdefghijklmnopqrstuvwxyz')"/> 250 <xsl:text>PACKAGE=</xsl:text> 251 <xsl:value-of select="$package"/> 252 <xsl:text>
if [[ ! -f $PACKAGE ]] ; then
</xsl:text> 386 253 <!-- SRC_ARCHIVE may have subdirectories or not --> 387 254 <xsl:text> if [[ -f $SRC_ARCHIVE/$PKG_DIR/$PACKAGE ]] ; then
</xsl:text> … … 390 257 <xsl:text> cp $SRC_ARCHIVE/$PACKAGE $PACKAGE
 else
</xsl:text> 391 258 <!-- The FTP_SERVER mirror --> 392 <xsl:text> wget ${FTP_SERVER}conglomeration/$PKG_DIR/$PACKAGE</xsl:text> 259 <xsl:text> wget -T 30 -t 5 ${FTP_SERVER}svn/</xsl:text> 260 <xsl:value-of select="$first_letter"/> 261 <xsl:text>/$PACKAGE</xsl:text> 262 <xsl:apply-templates 263 select="following-sibling::itemizedlist[1]/listitem/para" 264 mode="package"/> 265 </xsl:when> 266 <xsl:when test="string()='Additional Downloads'"> 267 <xsl:apply-templates 268 select="following-sibling::itemizedlist[1]/listitem/para" 269 mode="additional"/> 270 </xsl:when> 271 <xsl:otherwise/> 272 </xsl:choose> 273 </xsl:template> 274 275 <xsl:template match="para" mode="package"> 276 <xsl:choose> 277 <xsl:when test="contains(string(),'HTTP')"> 393 278 <!-- Upstream HTTP URL --> 394 279 <xsl:if test="string-length(ulink/@url) > '10'"> 395 <xsl:text> || \
 wget </xsl:text>280 <xsl:text> || \
 wget -T 30 -t 5 </xsl:text> 396 281 <xsl:choose> 397 282 <xsl:when test="contains(ulink/@url,'?')"> … … 402 287 </xsl:otherwise> 403 288 </xsl:choose> 289 <xsl:if test="not(contains(string(parent::listitem/following-sibling::listitem[1]/para),'FTP'))"> 290 <xsl:text>
 fi
fi
</xsl:text> 291 </xsl:if> 404 292 </xsl:if> 405 293 </xsl:when> … … 407 295 <!-- Upstream FTP URL --> 408 296 <xsl:if test="string-length(ulink/@url) > '10'"> 409 <xsl:text> || \
 wget </xsl:text>297 <xsl:text> || \
 wget -T 30 -t 5 </xsl:text> 410 298 <xsl:value-of select="ulink/@url"/> 411 299 </xsl:if> … … 417 305 <xsl:text>  $PACKAGE" | md5sum -c -
</xsl:text> 418 306 </xsl:when> 419 <!-- Patches --> 307 </xsl:choose> 308 </xsl:template> 309 310 <xsl:template match="para" mode="additional"> 311 <xsl:choose> 420 312 <xsl:when test="contains(string(ulink/@url),'.patch')"> 421 <xsl:text>wget </xsl:text>313 <xsl:text>wget -T 30 -t 5 </xsl:text> 422 314 <xsl:value-of select="ulink/@url"/> 423 315 <xsl:text>
</xsl:text> 316 </xsl:when> 317 <xsl:when test="ulink"> 318 <xsl:if test="string-length(ulink/@url) > '10'"> 319 <xsl:variable name="package"> 320 <xsl:call-template name="package_name"> 321 <xsl:with-param name="url" select="ulink/@url"/> 322 </xsl:call-template> 323 </xsl:variable> 324 <xsl:variable 325 name="first_letter" 326 select="translate(substring($package,1,1), 327 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 328 'abcdefghijklmnopqrstuvwxyz')"/> 329 <xsl:text>PACKAGE1=</xsl:text> 330 <xsl:value-of select="$package"/> 331 <xsl:text>
if [[ ! -f $PACKAGE1 ]] ; then
</xsl:text> 332 <!-- SRC_ARCHIVE may have subdirectories or not --> 333 <xsl:text> if [[ -f $SRC_ARCHIVE/$PKG_DIR/$PACKAGE1 ]] ; then
</xsl:text> 334 <xsl:text> cp $SRC_ARCHIVE/$PKG_DIR/$PACKAGE1 $PACKAGE1
</xsl:text> 335 <xsl:text> elif [[ -f $SRC_ARCHIVE/$PACKAGE1 ]] ; then
</xsl:text> 336 <xsl:text> cp $SRC_ARCHIVE/$PACKAGE1 $PACKAGE1
 else
</xsl:text> 337 <!-- The FTP_SERVER mirror --> 338 <xsl:text> wget -T 30 -t 5 ${FTP_SERVER}blfs/svn/</xsl:text> 339 <xsl:value-of select="$first_letter"/> 340 <xsl:text>/$PACKAGE1</xsl:text> 341 <xsl:text> || \
 wget -T 30 -t 5 </xsl:text> 342 <xsl:value-of select="ulink/@url"/> 343 <xsl:text>
 fi
fi
</xsl:text> 344 </xsl:if> 345 </xsl:when> 346 <xsl:when test="contains(string(),'MD5')"> 347 <xsl:text>echo "</xsl:text> 348 <xsl:value-of select="substring-after(string(),'sum: ')"/> 349 <xsl:text>  $PACKAGE1" | md5sum -c -
</xsl:text> 424 350 </xsl:when> 425 351 </xsl:choose> … … 429 355 <xsl:if test="contains(string(ulink/@url),'.md5') or 430 356 contains(string(ulink/@url),'.wget')"> 431 <xsl:text>wget </xsl:text>357 <xsl:text>wget -T 30 -t 5 </xsl:text> 432 358 <xsl:value-of select="ulink/@url"/> 433 359 <xsl:text>
</xsl:text> … … 437 363 <xsl:template match="itemizedlist/listitem/para" mode="xorg7-patch"> 438 364 <xsl:if test="contains(string(ulink/@url),'.patch')"> 439 <xsl:text>wget </xsl:text>365 <xsl:text>wget -T 30 -t 5 </xsl:text> 440 366 <xsl:value-of select="ulink/@url"/> 441 367 <xsl:text>
</xsl:text> … … 458 384 </xsl:template> 459 385 386 <xsl:template match="screen" mode="config"> 387 <xsl:if test="preceding-sibling::para[1]/xref[@linkend='bootscripts']"> 388 <xsl:text>[[ ! -d $SRC_DIR/blfs-bootscripts ]] && mkdir $SRC_DIR/blfs-bootscripts 389 pushd $SRC_DIR/blfs-bootscripts 390 URL=</xsl:text> 391 <xsl:value-of select="id('bootscripts')//itemizedlist//ulink/@url"/><xsl:text> 392 BOOTPACKG=$(basename $URL) 393 [[ ! -f "$BOOTPACKG" ]] && { wget -T 30 -t 5 $URL; rm -f unpacked; } 394 if [[ -e unpacked ]] ; then 395 UNPACKDIR=`head -n1 unpacked | sed 's@^./@@;s@/.*@@'` 396 if ! [[ -d $UNPACKDIR ]]; then 397 rm unpacked 398 tar -xvf $BOOTPACKG > unpacked 399 UNPACKDIR=`head -n1 unpacked | sed 's@^./@@;s@/.*@@'` 400 fi 401 else 402 tar -xvf $BOOTPACKG > unpacked 403 UNPACKDIR=`head -n1 unpacked | sed 's@^./@@;s@/.*@@'` 404 fi 405 cd $UNPACKDIR 406 </xsl:text> 407 </xsl:if> 408 <xsl:apply-templates select='.'/> 409 <xsl:if test="preceding-sibling::para[1]/xref[@linkend='bootscripts']"> 410 <xsl:text> 411 popd</xsl:text> 412 </xsl:if> 413 <xsl:text>
</xsl:text> 414 </xsl:template> 415 460 416 <xsl:template match="screen" mode="sect-ver"> 461 417 <xsl:text>section=</xsl:text> … … 482 438 483 439 <xsl:template match="replaceable"> 440 <!-- Not needed anymore 484 441 <xsl:choose> 485 442 <xsl:when test="ancestor::sect1[@id='xorg7-server']"> 486 443 <xsl:text>$SRC_DIR/MesaLib</xsl:text> 487 444 </xsl:when> 488 <xsl:otherwise> 445 <xsl:otherwise> --> 489 446 <xsl:text>**EDITME</xsl:text> 490 447 <xsl:apply-templates/> 491 448 <xsl:text>EDITME**</xsl:text> 492 </xsl:otherwise>493 </xsl:choose> 449 <!-- </xsl:otherwise> 450 </xsl:choose> --> 494 451 </xsl:template> 495 452
Note:
See TracChangeset
for help on using the changeset viewer.