patcheslist.xsl 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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('/srv/www/', substring-after('&patches-root;', 'http://'))"/>
  12. </xsl:param>
  13. <xsl:template match="/">
  14. <xsl:text>#! /bin/bash
  15. function copy
  16. {
  17. cp $1 $2 >>copyerrs 2>&amp;1
  18. }
  19. umask 002 &#x0a;&#x0a;</xsl:text>
  20. <!-- Create dest.dir if it don't exist -->
  21. <xsl:text>install -d -m 775 -g lfswww </xsl:text>
  22. <xsl:value-of select="$dest.dir"/>
  23. <xsl:text> &amp;&amp;&#x0a;</xsl:text>
  24. <xsl:text>cd </xsl:text>
  25. <xsl:value-of select="$dest.dir"/>
  26. <xsl:text> &amp;&amp;&#x0a;&#x0a;</xsl:text>
  27. <!-- Remove old patches -->
  28. <xsl:text>rm -f *.patch copyerrs &amp;&amp; &#x0a;&#x0a;</xsl:text>
  29. <xsl:apply-templates/>
  30. <!-- Ensure correct owneship -->
  31. <xsl:text>&#x0a;chgrp lfswww *.patch &amp;&amp;&#x0a;</xsl:text>
  32. <xsl:text>
  33. if [ `wc -l copyerrs | sed 's/ *//' | cut -f1 -d' '` -gt 0 ]; then
  34. mail -s "Missing LFS patches" lfs-book@linuxfromscratch.org &lt; copyerrs
  35. fi&#x0a;&#x0a;</xsl:text>
  36. <xsl:text>exit&#x0a;</xsl:text>
  37. </xsl:template>
  38. <xsl:template match="//text()"/>
  39. <xsl:template match="//ulink">
  40. <!-- Match only local patches links and skip duplicated URLs splitted for PDF output-->
  41. <xsl:if test="contains(@url, '.patch') and contains(@url, '&patches-root;')
  42. and not(ancestor-or-self::*/@condition = 'pdf')">
  43. <xsl:variable name="patch.name" select="substring-after(@url, '&patches-root;')"/>
  44. <xsl:variable name="cut"
  45. select="translate(substring-after($patch.name, '-'), '0123456789', '0000000000')"/>
  46. <xsl:variable name="patch.name2">
  47. <xsl:value-of select="substring-before($patch.name, '-')"/>
  48. <xsl:text>-</xsl:text>
  49. <xsl:value-of select="$cut"/>
  50. </xsl:variable>
  51. <xsl:text>copy /srv/www/www.linuxfromscratch.org/patches/downloads/</xsl:text>
  52. <xsl:value-of select="substring-before($patch.name2, '-0')"/>
  53. <xsl:text>/</xsl:text>
  54. <xsl:value-of select="$patch.name"/>
  55. <xsl:text> . &#x0a;</xsl:text>
  56. </xsl:if>
  57. </xsl:template>
  58. </xsl:stylesheet>