main.aap 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. # Aap recipe for Portuguese Vim spell files.
  2. # See ftp://ftp.vim.org/pub/vim/runtime/spell/README.txt
  3. # Use a freshly compiled Vim if it exists.
  4. @if os.path.exists('../../../src/vim'):
  5. VIM = ../../../src/vim
  6. @else:
  7. :progsearch VIM vim
  8. SPELLDIR = ..
  9. FILES = pt_PT.aff pt_PT.dic
  10. pt_BR.aff pt_BR.dic
  11. #
  12. # Fetching the pt_PT files from the Natura project.
  13. #
  14. PT_FNAME = oo3x-pt-PT.oxt
  15. PT_DIR = http://extensions.services.openoffice.org/e-files/1196/5/$(PT_FNAME)
  16. :attr {fetch = $PT_DIR} $PT_FNAME
  17. #
  18. # Fetching the pt_BR files from BrOffice.org (Brazilian OOo).
  19. #
  20. BR_FNAME = Vero_pt_BR_V207AOC.oxt
  21. BR_DIR = http://www.broffice.org/files/$(BR_FNAME)
  22. :attr {fetch = $BR_DIR} $BR_FNAME
  23. all: $SPELLDIR/pt.latin1.spl $SPELLDIR/pt.utf-8.spl \
  24. ../README_pt.txt
  25. $SPELLDIR/pt.latin1.spl : $FILES
  26. :sys env LANG=pt_PT.ISO-8859-1 LC_ALL=pt_PT.ISO-8859-1
  27. $VIM -u NONE -e -c "mkspell! $SPELLDIR/pt pt_PT pt_BR" -c q
  28. $SPELLDIR/pt.utf-8.spl : $FILES
  29. :sys env LANG=pt_PT.UTF-8 LC_ALL=pt_PT.UTF-8
  30. $VIM -u NONE -e -c "mkspell! $SPELLDIR/pt pt_PT pt_BR" -c q
  31. ../README_pt.txt: README_pt_PT.txt README_pt_BR.txt
  32. :print pt_PT >!$target
  33. :cat README_pt_PT.txt | :eval re.sub('\r', '', stdin) >>$target
  34. :print =================================================== >>$target
  35. :print pt_BR: >>$target
  36. :cat README_pt_BR.txt | :eval re.sub('\r', '', stdin) >>$target
  37. # The files don't depend on the .zip file so that we can delete it.
  38. # Only download the zip file if the targets don't exist.
  39. pt_PT.aff pt_PT.dic: {buildcheck=}
  40. :assertpkg unzip patch
  41. :fetch $PT_FNAME
  42. :sys $UNZIP $PT_FNAME
  43. :delete $PT_FNAME
  44. :move dictionaries/pt_PT.dic .
  45. :move dictionaries/pt_PT.aff .
  46. :move dictionaries/README_pt_PT.txt .
  47. :move dictionaries/COPYING COPYING_pt_PT.txt
  48. :delete {r}{f} dictionaries
  49. :delete {r}{f} META-INF
  50. :delete {f} description.xml
  51. :delete {f} dictionaries.xcu
  52. :delete {f} LICENSES.txt
  53. # Remove grammar items and the duplicates this causes
  54. :sys $VIM pt_PT.dic -u NONE -e -c "%s/\t.*//" -c "2,$$ sort u" -c update -c q
  55. :sys $VIM pt_PT.aff -u NONE -e -c "%s/\S\+=\S\+$$//" -c update -c q
  56. @if not os.path.exists('pt_PT.orig.aff'):
  57. :copy pt_PT.aff pt_PT.orig.aff
  58. @if not os.path.exists('pt_PT.orig.dic'):
  59. :copy pt_PT.dic pt_PT.orig.dic
  60. @if os.path.exists('pt_PT.diff'):
  61. :sys patch <pt_PT.diff
  62. pt_BR.aff pt_BR.dic: {buildcheck=}
  63. :assertpkg unzip patch
  64. :fetch $BR_FNAME
  65. :sys $UNZIP $BR_FNAME
  66. :delete $BR_FNAME
  67. :delete {f} description.xml
  68. :delete {f} dictionaries.xcu
  69. :delete {f} hyph_pt_BR.dic
  70. :delete {r}{f} META-INF
  71. :delete {f} README_en.TXT
  72. :delete {f} README_hyph_pt_BR.TXT
  73. :sys $VIM README_pt_BR.TXT -u NONE -N -e -c "set ff=unix" -c update -c q
  74. :move README_pt_BR.TXT README_pt_BR.txt
  75. :sys $VIM pt_BR.dic -u NONE -N -e -c "set ff=unix" -c update -c q
  76. :sys $VIM pt_BR.aff -u NONE -N -e -c "set ff=unix" -c update -c q
  77. @if not os.path.exists('pt_BR.orig.aff'):
  78. :copy pt_BR.aff pt_BR.orig.aff
  79. @if not os.path.exists('pt_BR.orig.dic'):
  80. :copy pt_BR.dic pt_BR.orig.dic
  81. @if os.path.exists('pt_BR.diff'):
  82. :sys patch <pt_BR.diff
  83. # Generate diff files, so that others can get the OpenOffice files and apply
  84. # the diffs to get the Vim versions.
  85. diff:
  86. :assertpkg diff
  87. :sys {force} diff -a -C 1 pt_PT.orig.aff pt_PT.aff >pt_PT.diff
  88. :sys {force} diff -a -C 1 pt_PT.orig.dic pt_PT.dic >>pt_PT.diff
  89. :sys {force} diff -a -C 1 pt_BR.orig.aff pt_BR.aff >pt_BR.diff
  90. :sys {force} diff -a -C 1 pt_BR.orig.dic pt_BR.dic >>pt_BR.diff
  91. # Delete all downloaded and generated files.
  92. clean: clean_pt_BR clean_pt_PT
  93. clean_pt_BR:
  94. :delete {f} pt_BR.aff
  95. :delete {f} pt_BR.dic
  96. :delete {f} pt_BR.orig.aff
  97. :delete {f} pt_BR.orig.dic
  98. :delete {f} README_pt_BR.txt
  99. clean_pt_PT:
  100. :delete {f} pt_PT.aff
  101. :delete {f} pt_PT.dic
  102. :delete {f} pt_PT.orig.aff
  103. :delete {f} pt_PT.orig.dic
  104. :delete {f} README_pt_PT.txt
  105. :delete {f} COPYING_pt_PT.txt
  106. # Check for updated OpenOffice spell files. When there are changes the
  107. # ".new.aff" and ".new.dic" files are left behind for manual inspection.
  108. # TO BE IMPLEMENTED
  109. check: check-pt check-br
  110. check-pt:
  111. :assertpkg unzip diff
  112. :fetch $PT_FNAME
  113. :mkdir tmp
  114. :cd tmp
  115. @try:
  116. @import stat
  117. :sys $UNZIP ../$PT_FNAME
  118. :sys {force} diff ../pt_PT.orig.aff pt_PT.aff >d
  119. @if os.stat('d')[stat.ST_SIZE] > 0:
  120. :copy pt_PT.aff ../pt_PT.new.aff
  121. :sys {force} diff ../pt_PT.orig.dic pt_PT.dic >d
  122. @if os.stat('d')[stat.ST_SIZE] > 0:
  123. :copy pt_PT.dic ../pt_PT.new.dic
  124. @finally:
  125. :cd ..
  126. :delete {r}{f}{q} tmp
  127. :delete $PT_FNAME
  128. check-br:
  129. :assertpkg unzip diff
  130. :fetch $BR_FNAME
  131. :mkdir tmp
  132. :cd tmp
  133. @try:
  134. @import stat
  135. :sys $UNZIP ../$BR_FNAME
  136. :sys {force} diff ../pt_BR.orig.aff pt_BR.aff >d
  137. @if os.stat('d')[stat.ST_SIZE] > 0:
  138. :copy pt_BR.aff ../pt_BR.new.aff
  139. :sys {force} diff ../pt_BR.orig.dic pt_BR.dic >d
  140. @if os.stat('d')[stat.ST_SIZE] > 0:
  141. :copy pt_BR.dic ../pt_BR.new.dic
  142. @finally:
  143. :cd ..
  144. :delete {r}{f}{q} tmp
  145. :delete $BR_FNAME
  146. # vim: set sts=4 sw=4 :