patcheslist.xsl 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?xml version='1.0' encoding='ISO-8859-1'?>
  2. <!DOCTYPE xsl:stylesheet [
  3. <!ENTITY % general-entities SYSTEM "../general.ent">
  4. %general-entities;
  5. ]>
  6. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  7. version="1.0">
  8. <xsl:output method="text"/>
  9. <!-- Allow select the dest dir at runtime -->
  10. <xsl:param name="dest.dir">
  11. <xsl:value-of select="concat('/home/httpd/', substring-after('&patches-root;', 'http://'))"/>
  12. </xsl:param>
  13. <xsl:template match="/">
  14. <xsl:text>#! /bin/bash&#x0a;&#x0a;</xsl:text>
  15. <!-- Create dest.dir if it don't exist -->
  16. <xsl:text> mkdir -p </xsl:text>
  17. <xsl:value-of select="$dest.dir"/>
  18. <xsl:text> &amp;&amp;&#x0a;</xsl:text>
  19. <xsl:text> cd </xsl:text>
  20. <xsl:value-of select="$dest.dir"/>
  21. <xsl:text> &amp;&amp;&#x0a;&#x0a;</xsl:text>
  22. <!-- Touch a dummy patch to prevent fails if dest dir is empty, then remove old patches -->
  23. <xsl:text> touch dummy.patch &amp;&amp;&#x0a; rm -f *.patch &amp;&amp;&#x0a;&#x0a;</xsl:text>
  24. <xsl:apply-templates/>
  25. <!-- Ensure correct owneship -->
  26. <xsl:text>&#x0a; chgrp lfswww *.patch &amp;&amp;&#x0a;</xsl:text>
  27. <xsl:text>&#x0a; exit&#x0a;</xsl:text>
  28. </xsl:template>
  29. <xsl:template match="//text()"/>
  30. <xsl:template match="//ulink">
  31. <!-- Match only local patches links and skip duplicated URLs splitted for PDF output-->
  32. <xsl:if test="contains(@url, '.patch') and contains(@url, '&patches-root;')
  33. and not(ancestor-or-self::*/@condition = 'pdf')">
  34. <xsl:variable name="patch.name" select="substring-after(@url, '&patches-root;')"/>
  35. <xsl:variable name="cut"
  36. select="translate(substring-after($patch.name, '-'), '0123456789', '0000000000')"/>
  37. <xsl:variable name="patch.name2">
  38. <xsl:value-of select="substring-before($patch.name, '-')"/>
  39. <xsl:text>-</xsl:text>
  40. <xsl:value-of select="$cut"/>
  41. </xsl:variable>
  42. <xsl:text> cp /home/httpd/www.linuxfromscratch.org/patches/downloads/</xsl:text>
  43. <xsl:value-of select="substring-before($patch.name2, '-0')"/>
  44. <xsl:text>/</xsl:text>
  45. <xsl:value-of select="$patch.name"/>
  46. <xsl:text> . &#x0a;</xsl:text>
  47. </xsl:if>
  48. </xsl:template>
  49. </xsl:stylesheet>