patcheslist.xsl 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. <xsl:text> umask 002&#x0a;&#x0a;</xsl:text>
  16. <!-- Create dest.dir if it don't exist -->
  17. <xsl:text> install -d -m 775 -g lfswww </xsl:text>
  18. <xsl:value-of select="$dest.dir"/>
  19. <xsl:text> &amp;&amp;&#x0a;</xsl:text>
  20. <xsl:text> cd </xsl:text>
  21. <xsl:value-of select="$dest.dir"/>
  22. <xsl:text> &amp;&amp;&#x0a;&#x0a;</xsl:text>
  23. <!-- Touch a dummy patch to prevent fails if dest dir is empty, then remove old patches -->
  24. <xsl:text> touch dummy.patch &amp;&amp;&#x0a; rm -f *.patch &amp;&amp;&#x0a;&#x0a;</xsl:text>
  25. <xsl:apply-templates/>
  26. <!-- Ensure correct owneship -->
  27. <xsl:text>&#x0a; chgrp lfswww *.patch &amp;&amp;&#x0a;</xsl:text>
  28. <xsl:text>&#x0a; exit&#x0a;</xsl:text>
  29. </xsl:template>
  30. <xsl:template match="//text()"/>
  31. <xsl:template match="//ulink">
  32. <!-- Match only local patches links and skip duplicated URLs splitted for PDF output-->
  33. <xsl:if test="contains(@url, '.patch') and contains(@url, '&patches-root;')
  34. and not(ancestor-or-self::*/@condition = 'pdf')">
  35. <xsl:variable name="patch.name" select="substring-after(@url, '&patches-root;')"/>
  36. <xsl:variable name="cut"
  37. select="translate(substring-after($patch.name, '-'), '0123456789', '0000000000')"/>
  38. <xsl:variable name="patch.name2">
  39. <xsl:value-of select="substring-before($patch.name, '-')"/>
  40. <xsl:text>-</xsl:text>
  41. <xsl:value-of select="$cut"/>
  42. </xsl:variable>
  43. <xsl:text> cp /home/httpd/www.linuxfromscratch.org/patches/downloads/</xsl:text>
  44. <xsl:value-of select="substring-before($patch.name2, '-0')"/>
  45. <xsl:text>/</xsl:text>
  46. <xsl:value-of select="$patch.name"/>
  47. <xsl:text> . &#x0a;</xsl:text>
  48. </xsl:if>
  49. </xsl:template>
  50. </xsl:stylesheet>