reap 03.01 → 4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (231) hide show
  1. data/{LICENSE → COPYING} +0 -0
  2. data/ChangeLog +5 -0
  3. data/ProjectInfo +55 -15
  4. data/README +32 -31
  5. data/Rakefile +0 -141
  6. data/bin/reap +2 -158
  7. data/data/reap/scaffold/COPYING +11 -0
  8. data/data/reap/scaffold/ChangeLog +0 -0
  9. data/data/reap/scaffold/INSTALL +0 -0
  10. data/data/reap/scaffold/ProjectInfo +78 -0
  11. data/data/reap/scaffold/README +0 -0
  12. data/data/reap/scaffold/Rakefile +146 -0
  13. data/data/reap/scaffold/Todo +0 -0
  14. data/data/reap/scaffold/setup.rb +1551 -0
  15. data/dev/Rakefile +60 -0
  16. data/dev/composite_task.rb +27 -0
  17. data/dev/compositepublisher.rb +24 -0
  18. data/dev/ftptools.rb +139 -0
  19. data/dev/license-each.rb +85 -0
  20. data/dev/publisher.rb +75 -0
  21. data/dev/rubyforgepublisher.rb +18 -0
  22. data/dev/sshpublisher.rb +47 -0
  23. data/dev/suby-cvs.rb +46 -0
  24. data/{data/site_ruby/reap/template.yaml → dev/template.rb} +15 -37
  25. data/lib/reap/bin/reap.rb +134 -0
  26. data/lib/reap/lint.rb +0 -0
  27. data/lib/reap/projectinfo.rb +20 -9
  28. data/lib/reap/readymade.rb +21 -0
  29. data/lib/reap/task.rb +119 -70
  30. data/lib/reap/{announce_task.rb → task/announce.rb} +20 -25
  31. data/lib/reap/{filemod_task.rb → task/fileperm.rb} +12 -16
  32. data/lib/reap/task/info.rb +20 -0
  33. data/lib/reap/task/install.rb +33 -0
  34. data/lib/reap/task/noop.rb +26 -0
  35. data/lib/reap/{package_task.rb → task/package.rb} +88 -71
  36. data/lib/reap/{publish_task.rb → task/publish.rb} +5 -13
  37. data/lib/reap/{rdoc_task.rb → task/rdoc.rb} +29 -22
  38. data/lib/reap/task/scaffold.rb +114 -0
  39. data/lib/reap/{test_task.rb → task/test.rb} +33 -26
  40. data/lib/reap/task/testext.rb +110 -0
  41. data/lib/reap/{web_publish_task.rb → task/webpublish.rb} +5 -11
  42. data/lib/reap/tasks.rb +12 -8
  43. data/lib/reap/test.rb +138 -0
  44. data/setup.rb +726 -534
  45. data/web/ProjectInfo +57 -0
  46. data/{pub/www → web}/images/appleboy.jpg +0 -0
  47. data/{pub → web/images}/grape.jpg +0 -0
  48. data/web/index.html +124 -0
  49. data/web/rdoc/classes/Object.html +121 -0
  50. data/{pub/www → web}/rdoc/classes/ProjectInfo.html +36 -36
  51. data/{pub/www/rdoc/classes/ProjectInfo.src/M000055.html → web/rdoc/classes/ProjectInfo.src/M000094.html} +3 -3
  52. data/{pub/www/rdoc/classes/ProjectInfo.src/M000056.html → web/rdoc/classes/ProjectInfo.src/M000095.html} +2 -1
  53. data/web/rdoc/classes/ProjectInfo.src/M000096.html +22 -0
  54. data/{pub/www/rdoc/classes/ProjectInfo.src/M000058.html → web/rdoc/classes/ProjectInfo.src/M000097.html} +1 -1
  55. data/{pub/www/rdoc/classes/ProjectInfo.src/M000059.html → web/rdoc/classes/ProjectInfo.src/M000098.html} +1 -1
  56. data/web/rdoc/classes/Reap.html +248 -0
  57. data/web/rdoc/classes/Reap.src/M000023.html +16 -0
  58. data/web/rdoc/classes/Reap.src/M000024.html +21 -0
  59. data/web/rdoc/classes/Reap.src/M000025.html +16 -0
  60. data/web/rdoc/classes/Reap.src/M000026.html +21 -0
  61. data/{pub/www/rdoc/classes/Reap/AnnounceTask.html → web/rdoc/classes/Reap/Announce.html} +22 -40
  62. data/web/rdoc/classes/Reap/Announce.src/M000030.html +18 -0
  63. data/{pub/www/rdoc/classes/Reap/AnnounceTask.src/M000041.html → web/rdoc/classes/Reap/Announce.src/M000031.html} +13 -10
  64. data/{pub/www/rdoc/classes/Reap/AnnounceTask.src/M000042.html → web/rdoc/classes/Reap/Announce.src/M000032.html} +2 -2
  65. data/{pub/www/rdoc/classes/Reap/InfoTask.html → web/rdoc/classes/Reap/Info.html} +23 -41
  66. data/{pub/www/rdoc/classes/Reap/RDocTask.src/M000002.html → web/rdoc/classes/Reap/Info.src/M000033.html} +4 -4
  67. data/{pub/www/rdoc/classes/Reap/InfoTask.src/M000049.html → web/rdoc/classes/Reap/Info.src/M000034.html} +2 -2
  68. data/{pub/www/rdoc/classes/Reap/NoopTask.src/M000046.html → web/rdoc/classes/Reap/Info.src/M000035.html} +3 -3
  69. data/web/rdoc/classes/Reap/Install.html +193 -0
  70. data/web/rdoc/classes/Reap/Install.src/M000036.html +18 -0
  71. data/{pub/www/rdoc/classes/Reap/AnnounceTask.src/M000040.html → web/rdoc/classes/Reap/Install.src/M000037.html} +6 -4
  72. data/web/rdoc/classes/Reap/Install.src/M000038.html +26 -0
  73. data/{pub/www/rdoc/classes/Reap/NoopTask.html → web/rdoc/classes/Reap/Noop.html} +23 -41
  74. data/web/rdoc/classes/Reap/Noop.src/M000027.html +18 -0
  75. data/{pub/www/rdoc/classes/Reap/NoopTask.src/M000045.html → web/rdoc/classes/Reap/Noop.src/M000028.html} +2 -2
  76. data/{pub/www/rdoc/classes/Reap/InfoTask.src/M000050.html → web/rdoc/classes/Reap/Noop.src/M000029.html} +3 -3
  77. data/{pub/www/rdoc/classes/Reap/PackageTask.html → web/rdoc/classes/Reap/Package.html} +40 -68
  78. data/{pub/www/rdoc/classes/Reap/NoopTask.src/M000044.html → web/rdoc/classes/Reap/Package.src/M000055.html} +4 -4
  79. data/{pub/www/rdoc/classes/Reap/PackageTask.src/M000007.html → web/rdoc/classes/Reap/Package.src/M000056.html} +28 -13
  80. data/{pub/www/rdoc/classes/Reap/PackageTask.src/M000008.html → web/rdoc/classes/Reap/Package.src/M000057.html} +43 -32
  81. data/{pub/www/rdoc/classes/Reap/PackageTask.src/M000009.html → web/rdoc/classes/Reap/Package.src/M000058.html} +13 -3
  82. data/{pub/www/rdoc/classes/Reap/FilemodTask.html → web/rdoc/classes/Reap/Perm.html} +35 -53
  83. data/web/rdoc/classes/Reap/Perm.src/M000078.html +18 -0
  84. data/{pub/www/rdoc/classes/Reap/FilemodTask.src/M000029.html → web/rdoc/classes/Reap/Perm.src/M000079.html} +3 -3
  85. data/{pub/www/rdoc/classes/Reap/FilemodTask.src/M000030.html → web/rdoc/classes/Reap/Perm.src/M000080.html} +2 -2
  86. data/{pub/www/rdoc/classes/Reap/FilemodTask.src/M000031.html → web/rdoc/classes/Reap/Perm.src/M000081.html} +2 -2
  87. data/{pub/www/rdoc/classes/Reap/FilemodTask.src/M000032.html → web/rdoc/classes/Reap/Perm.src/M000082.html} +2 -2
  88. data/{pub/www/rdoc/classes/Reap/PublishTask.html → web/rdoc/classes/Reap/Publish.html} +23 -41
  89. data/web/rdoc/classes/Reap/Publish.src/M000070.html +18 -0
  90. data/{pub/www/rdoc/classes/Reap/PublishTask.src/M000025.html → web/rdoc/classes/Reap/Publish.src/M000071.html} +2 -2
  91. data/{pub/www/rdoc/classes/Reap/PublishTask.src/M000026.html → web/rdoc/classes/Reap/Publish.src/M000072.html} +3 -4
  92. data/{pub/www/rdoc/classes/Reap/RDocTask.html → web/rdoc/classes/Reap/RDoc.html} +23 -41
  93. data/web/rdoc/classes/Reap/RDoc.src/M000059.html +18 -0
  94. data/{pub/www/rdoc/classes/Reap/RDocTask.src/M000003.html → web/rdoc/classes/Reap/RDoc.src/M000060.html} +4 -5
  95. data/{pub/www/rdoc/classes/Reap/RDocTask.src/M000004.html → web/rdoc/classes/Reap/RDoc.src/M000061.html} +26 -9
  96. data/web/rdoc/classes/Reap/Task.html +396 -0
  97. data/web/rdoc/classes/Reap/Task.src/M000039.html +18 -0
  98. data/{pub/www/rdoc/classes/Reap/FilemodTask.src/M000027.html → web/rdoc/classes/Reap/Task.src/M000040.html} +3 -3
  99. data/web/rdoc/classes/Reap/Task.src/M000041.html +16 -0
  100. data/web/rdoc/classes/Reap/Task.src/M000042.html +16 -0
  101. data/{pub/www/rdoc/classes/Reap/NoopTask.src → web/rdoc/classes/Reap/Task.src}/M000043.html +3 -3
  102. data/web/rdoc/classes/Reap/Task.src/M000044.html +22 -0
  103. data/web/rdoc/classes/Reap/Task.src/M000045.html +16 -0
  104. data/web/rdoc/classes/Reap/Task.src/M000046.html +16 -0
  105. data/{pub/www/rdoc/classes/Reap/Task.src/M000034.html → web/rdoc/classes/Reap/Task.src/M000047.html} +2 -4
  106. data/{pub/www/rdoc/classes/Reap/Task.src/M000036.html → web/rdoc/classes/Reap/Task.src/M000048.html} +3 -3
  107. data/web/rdoc/classes/Reap/Task.src/M000049.html +16 -0
  108. data/web/rdoc/classes/Reap/Task.src/M000050.html +27 -0
  109. data/web/rdoc/classes/Reap/Task.src/M000051.html +19 -0
  110. data/{pub/www/rdoc/classes/Reap/Task.src/M000037.html → web/rdoc/classes/Reap/Task.src/M000052.html} +2 -2
  111. data/web/rdoc/classes/Reap/Task.src/M000053.html +18 -0
  112. data/web/rdoc/classes/Reap/Task.src/M000054.html +19 -0
  113. data/{pub/www/rdoc/classes/Reap/TestTask.html → web/rdoc/classes/Reap/Test.html} +47 -56
  114. data/web/rdoc/classes/Reap/Test.src/M000062.html +18 -0
  115. data/{pub/www/rdoc/classes/Reap/TestTask.src/M000016.html → web/rdoc/classes/Reap/Test.src/M000063.html} +5 -4
  116. data/{pub/www/rdoc/classes/Reap/TestTask.src/M000017.html → web/rdoc/classes/Reap/Test.src/M000064.html} +2 -2
  117. data/{pub/www/rdoc/classes/Reap/TestTask.src/M000018.html → web/rdoc/classes/Reap/Test.src/M000065.html} +2 -2
  118. data/{pub/www/rdoc/classes/Reap/TestTask.src/M000019.html → web/rdoc/classes/Reap/Test.src/M000066.html} +18 -4
  119. data/{pub/www/rdoc/classes/Reap/TestTask → web/rdoc/classes/Reap/Test}/TestResults.html +21 -19
  120. data/{pub/www/rdoc/classes/Reap/TestTask/TestResults.src/M000020.html → web/rdoc/classes/Reap/Test/TestResults.src/M000067.html} +2 -2
  121. data/{pub/www/rdoc/classes/Reap/TestTask/TestResults.src/M000021.html → web/rdoc/classes/Reap/Test/TestResults.src/M000068.html} +2 -2
  122. data/{pub/www/rdoc/classes/Reap/TestTask/TestResults.src/M000022.html → web/rdoc/classes/Reap/Test/TestResults.src/M000069.html} +2 -2
  123. data/web/rdoc/classes/Reap/TestExt.html +234 -0
  124. data/{pub/www/rdoc/classes/Reap/InfoTask.src/M000048.html → web/rdoc/classes/Reap/TestExt.src/M000073.html} +4 -4
  125. data/web/rdoc/classes/Reap/TestExt.src/M000074.html +20 -0
  126. data/web/rdoc/classes/Reap/TestExt.src/M000075.html +49 -0
  127. data/web/rdoc/classes/Reap/TestExt.src/M000076.html +34 -0
  128. data/web/rdoc/classes/Reap/TestExt.src/M000077.html +27 -0
  129. data/{pub/www/rdoc/classes/Reap/WebPublishTask.html → web/rdoc/classes/Reap/WebPublish.html} +23 -41
  130. data/{pub/www/rdoc/classes/Reap/WebPublishTask.src/M000011.html → web/rdoc/classes/Reap/WebPublish.src/M000083.html} +4 -4
  131. data/{pub/www/rdoc/classes/Reap/WebPublishTask.src/M000012.html → web/rdoc/classes/Reap/WebPublish.src/M000084.html} +2 -2
  132. data/{pub/www/rdoc/classes/Reap/WebPublishTask.src/M000013.html → web/rdoc/classes/Reap/WebPublish.src/M000085.html} +2 -2
  133. data/web/rdoc/classes/ReapCommand.html +425 -0
  134. data/web/rdoc/classes/ReapCommand.src/M000001.html +16 -0
  135. data/{pub/www/rdoc/classes/Reap/AnnounceTask.src/M000039.html → web/rdoc/classes/ReapCommand.src/M000003.html} +4 -4
  136. data/web/rdoc/classes/ReapCommand.src/M000005.html +16 -0
  137. data/{pub/www/rdoc/classes/Reap/InfoTask.src/M000047.html → web/rdoc/classes/ReapCommand.src/M000007.html} +4 -4
  138. data/web/rdoc/classes/ReapCommand.src/M000009.html +16 -0
  139. data/web/rdoc/classes/ReapCommand.src/M000011.html +16 -0
  140. data/web/rdoc/classes/ReapCommand.src/M000013.html +18 -0
  141. data/web/rdoc/classes/ReapCommand.src/M000014.html +19 -0
  142. data/web/rdoc/classes/ReapCommand.src/M000015.html +19 -0
  143. data/web/rdoc/classes/ReapCommand.src/M000016.html +24 -0
  144. data/web/rdoc/classes/ReapCommand.src/M000018.html +29 -0
  145. data/web/rdoc/classes/Scaffold.html +211 -0
  146. data/web/rdoc/classes/Scaffold.src/M000086.html +16 -0
  147. data/web/rdoc/classes/Scaffold.src/M000087.html +28 -0
  148. data/web/rdoc/classes/Scaffold.src/M000088.html +32 -0
  149. data/web/rdoc/classes/Scaffold.src/M000089.html +18 -0
  150. data/{pub/www/rdoc/classes/RakeTask.html → web/rdoc/classes/UnitTestKernel.html} +28 -34
  151. data/web/rdoc/classes/UnitTestKernel.src/M000019.html +18 -0
  152. data/web/rdoc/classes/UnitTestKernel.src/M000020.html +18 -0
  153. data/web/rdoc/classes/UnitTestKernel.src/M000021.html +22 -0
  154. data/web/rdoc/classes/UnitTestKernel.src/M000022.html +22 -0
  155. data/{pub/www/rdoc/classes/Reap.html → web/rdoc/classes/UnitTesting.html} +48 -54
  156. data/web/rdoc/classes/UnitTesting.src/M000090.html +34 -0
  157. data/web/rdoc/classes/UnitTesting.src/M000091.html +18 -0
  158. data/web/rdoc/classes/UnitTesting/Failure.html +156 -0
  159. data/web/rdoc/classes/UnitTesting/Failure.src/M000092.html +18 -0
  160. data/web/rdoc/classes/UnitTesting/Failure.src/M000093.html +21 -0
  161. data/web/rdoc/created.rid +1 -0
  162. data/web/rdoc/files/ANN.html +107 -0
  163. data/{pub/www/rdoc/files/LICENSE.html → web/rdoc/files/COPYING.html} +3 -3
  164. data/web/rdoc/files/ChangeLog.html +144 -0
  165. data/web/rdoc/files/ProjectInfo.html +190 -0
  166. data/{pub/www → web}/rdoc/files/README.html +38 -35
  167. data/web/rdoc/files/Rakefile.html +101 -0
  168. data/web/rdoc/files/lib/reap/bin/reap_rb.html +129 -0
  169. data/web/rdoc/files/lib/reap/lint_rb.html +101 -0
  170. data/{pub/www → web}/rdoc/files/lib/reap/projectinfo_rb.html +3 -4
  171. data/web/rdoc/files/lib/reap/readymade_rb.html +123 -0
  172. data/{pub/www/rdoc/files/lib/reap/announce_task_rb.html → web/rdoc/files/lib/reap/task/announce_rb.html} +5 -5
  173. data/{pub/www/rdoc/files/lib/reap/filemod_task_rb.html → web/rdoc/files/lib/reap/task/fileperm_rb.html} +5 -5
  174. data/{pub/www/rdoc/files/lib/reap/rdoc_task_rb.html → web/rdoc/files/lib/reap/task/info_rb.html} +5 -5
  175. data/web/rdoc/files/lib/reap/task/install_rb.html +108 -0
  176. data/{pub/www/rdoc/files/lib/reap/noop_task_rb.html → web/rdoc/files/lib/reap/task/noop_rb.html} +5 -5
  177. data/{pub/www/rdoc/files/lib/reap/package_task_rb.html → web/rdoc/files/lib/reap/task/package_rb.html} +5 -5
  178. data/web/rdoc/files/lib/reap/task/publish_rb.html +108 -0
  179. data/web/rdoc/files/lib/reap/task/rdoc_rb.html +108 -0
  180. data/web/rdoc/files/lib/reap/task/scaffold_rb.html +107 -0
  181. data/{pub/www/rdoc/files/lib/reap/test_task_rb.html → web/rdoc/files/lib/reap/task/test_rb.html} +5 -5
  182. data/web/rdoc/files/lib/reap/task/testext_rb.html +109 -0
  183. data/{pub/www/rdoc/files/lib/reap/publish_task_rb.html → web/rdoc/files/lib/reap/task/webpublish_rb.html} +5 -5
  184. data/{pub/www → web}/rdoc/files/lib/reap/task_rb.html +11 -3
  185. data/{pub/www → web}/rdoc/files/lib/reap/tasks_rb.html +10 -9
  186. data/{pub/www/rdoc/files/lib/reap/info_task_rb.html → web/rdoc/files/lib/reap/test_rb.html} +6 -5
  187. data/web/rdoc/fr_class_index.html +47 -0
  188. data/web/rdoc/fr_file_index.html +51 -0
  189. data/web/rdoc/fr_method_index.html +124 -0
  190. data/{pub/www → web}/rdoc/index.html +0 -0
  191. data/{pub/www → web}/rdoc/rdoc-style.css +0 -0
  192. metadata +236 -158
  193. data/lib/reap/info_task.rb +0 -29
  194. data/lib/reap/noop_task.rb +0 -35
  195. data/lib/reap/ready_made.rb +0 -12
  196. data/pub/www/Reapfile +0 -99
  197. data/pub/www/index.html +0 -90
  198. data/pub/www/rdoc/classes/ProjectInfo.src/M000057.html +0 -18
  199. data/pub/www/rdoc/classes/RakeTask.src/M000051.html +0 -18
  200. data/pub/www/rdoc/classes/RakeTask.src/M000052.html +0 -18
  201. data/pub/www/rdoc/classes/RakeTask.src/M000053.html +0 -18
  202. data/pub/www/rdoc/classes/RakeTask.src/M000054.html +0 -18
  203. data/pub/www/rdoc/classes/Reap/FilemodTask.src/M000028.html +0 -18
  204. data/pub/www/rdoc/classes/Reap/PackageTask.src/M000005.html +0 -16
  205. data/pub/www/rdoc/classes/Reap/PackageTask.src/M000006.html +0 -24
  206. data/pub/www/rdoc/classes/Reap/PublishTask.src/M000023.html +0 -16
  207. data/pub/www/rdoc/classes/Reap/PublishTask.src/M000024.html +0 -18
  208. data/pub/www/rdoc/classes/Reap/RDocTask.src/M000001.html +0 -16
  209. data/pub/www/rdoc/classes/Reap/Task.html +0 -239
  210. data/pub/www/rdoc/classes/Reap/Task.src/M000033.html +0 -21
  211. data/pub/www/rdoc/classes/Reap/Task.src/M000035.html +0 -41
  212. data/pub/www/rdoc/classes/Reap/Task.src/M000038.html +0 -19
  213. data/pub/www/rdoc/classes/Reap/TestTask.src/M000014.html +0 -16
  214. data/pub/www/rdoc/classes/Reap/TestTask.src/M000015.html +0 -18
  215. data/pub/www/rdoc/classes/Reap/WebPublishTask.src/M000010.html +0 -16
  216. data/pub/www/rdoc/classes/ReapTask.html +0 -287
  217. data/pub/www/rdoc/classes/ReapTask.src/M000060.html +0 -18
  218. data/pub/www/rdoc/classes/ReapTask.src/M000061.html +0 -18
  219. data/pub/www/rdoc/classes/ReapTask.src/M000062.html +0 -18
  220. data/pub/www/rdoc/classes/ReapTask.src/M000063.html +0 -18
  221. data/pub/www/rdoc/classes/ReapTask.src/M000064.html +0 -18
  222. data/pub/www/rdoc/classes/ReapTask.src/M000065.html +0 -18
  223. data/pub/www/rdoc/classes/ReapTask.src/M000066.html +0 -18
  224. data/pub/www/rdoc/classes/ReapTask.src/M000067.html +0 -18
  225. data/pub/www/rdoc/classes/ReapTask.src/M000068.html +0 -18
  226. data/pub/www/rdoc/created.rid +0 -1
  227. data/pub/www/rdoc/files/lib/reap/ready_made_rb.html +0 -115
  228. data/pub/www/rdoc/files/lib/reap/web_publish_task_rb.html +0 -108
  229. data/pub/www/rdoc/fr_class_index.html +0 -41
  230. data/pub/www/rdoc/fr_file_index.html +0 -41
  231. data/pub/www/rdoc/fr_method_index.html +0 -94
@@ -1,21 +1,15 @@
1
- require 'reap/task'
2
1
 
3
- module ReapTask
4
- def webpublish_task(*args,&blk)
5
- ::Reap::WebPublishTask.new(*args,&blk)
6
- end
7
- end
2
+ require 'reap/task'
8
3
 
9
4
  #
10
5
  # Web Publish Task
11
6
  #
12
- class Reap::WebPublishTask < Reap::Task
7
+ class Reap::WebPublish < Reap::Task
13
8
 
14
- #register 'webpublish'
9
+ section_required true
15
10
 
16
- def default_name ; 'webpublish' ; end
17
- def default_desc
18
- "publish project website to your internet host [reap]"
11
+ def task_desc
12
+ "publish project website to your internet host *"
19
13
  end
20
14
 
21
15
  attr_accessor :host, :type, :dir, :project, :username
@@ -1,9 +1,13 @@
1
1
 
2
- require 'reap/filemod_task'
3
- require 'reap/test_task'
4
- require 'reap/rdoc_task'
5
- require 'reap/announce_task'
6
- require 'reap/package_task'
7
- require 'reap/publish_task'
8
- require 'reap/info_task'
9
- require 'reap/noop_task'
2
+ require 'reap/task/fileperm'
3
+ require 'reap/task/test'
4
+ require 'reap/task/testext'
5
+ require 'reap/task/rdoc'
6
+ require 'reap/task/announce'
7
+ require 'reap/task/package'
8
+ require 'reap/task/publish'
9
+ require 'reap/task/info'
10
+ require 'reap/task/install'
11
+ #require 'reap/task/noop'
12
+ #require 'reap/webpublish'
13
+
@@ -0,0 +1,138 @@
1
+ require 'facet/kernel/sym_esc'
2
+ require 'yaml'
3
+
4
+ $test_mode = false
5
+ $test_failures = []
6
+
7
+
8
+ module UnitTestKernel
9
+
10
+ def assert_on!
11
+ $test_mode = true
12
+ end
13
+
14
+ def assert_off!
15
+ $test_mode = false
16
+ end
17
+
18
+ def assert!(&blk)
19
+ old = $test_mode
20
+ $test_mode = true
21
+ r = blk.call
22
+ $test_mode = old
23
+ return r
24
+ end
25
+
26
+ def no_assertion!(&blk)
27
+ old = $test_mode
28
+ $test_mode = false
29
+ r = blk.call
30
+ $test_mode = old
31
+ return r
32
+ end
33
+
34
+ end
35
+
36
+ class Object
37
+ include UnitTestKernel
38
+ end
39
+
40
+
41
+ module UnitTesting
42
+
43
+ class Failure
44
+
45
+ def to_yaml_properties
46
+ [ '@self', '@method', '@args', '@caller' ]
47
+ end
48
+
49
+ def initialize( slf, meth, args, callr )
50
+ @self = slf
51
+ @method = meth
52
+ @args = args
53
+ @caller = callr
54
+ end
55
+
56
+ end
57
+
58
+
59
+ TRANSPARENT_ASSERTIONS = %w{
60
+ == === eql? equal? kind_of? include?
61
+ member? empty? nil? has_key? key? respond_to?
62
+ between?
63
+ }
64
+
65
+ def self.advise_assertions
66
+
67
+ ObjectSpace.each_object(Module) do |m|
68
+
69
+ TRANSPARENT_ASSERTIONS.each do |meth|
70
+
71
+ nmeth = "assert_#{sym_esc(meth)}"
72
+
73
+ if m.method_defined?(meth)
74
+
75
+ m.class_eval <<-HERE
76
+ alias :#{nmeth} :#{meth}
77
+ def #{meth}(*args)
78
+ if $test_mode
79
+ r = nil
80
+ no_assertion! {
81
+ r = #{nmeth}(*args)
82
+ unless r
83
+ $test_failures << Failure.new( self, :"#{meth}", args, caller[2..-1] )
84
+ end
85
+ }
86
+ return r
87
+ else
88
+ return #{nmeth}(*args)
89
+ end
90
+ end
91
+ HERE
92
+
93
+ end #if
94
+
95
+ end #do
96
+
97
+ end #do
98
+
99
+ end #def
100
+
101
+ def self.report
102
+ y $test_failures
103
+ end
104
+
105
+ end
106
+
107
+ class Object
108
+ include UnitTestKernel
109
+ end
110
+
111
+ UnitTesting.advise_assertions
112
+
113
+
114
+ =begin testing
115
+
116
+ class X
117
+ def a
118
+ 1
119
+ end
120
+ end
121
+
122
+ class TestX < X
123
+
124
+ def test_a
125
+ assert! {
126
+ a == 1
127
+ a == 2
128
+ }
129
+ end
130
+
131
+ end
132
+
133
+ x = TestX.new
134
+ x.test_a
135
+
136
+ UnitTesting.report
137
+
138
+ =end
data/setup.rb CHANGED
@@ -1,8 +1,9 @@
1
1
  #!/usr/bin/env ruby
2
+
2
3
  #
3
4
  # setup.rb
4
5
  #
5
- # Copyright (c) 2000-2004 Minero Aoki
6
+ # Copyright (c) 2000-2005 Minero Aoki
6
7
  #
7
8
  # This program is free software.
8
9
  # You can distribute/modify this program under the terms of
@@ -23,176 +24,71 @@ unless File.respond_to?(:read) # Ruby 1.6
23
24
  end
24
25
  end
25
26
 
27
+ unless Errno.const_defined?(:ENOTEMPTY) # Windows?
28
+ module Errno
29
+ class ENOTEMPTY
30
+ # We do not raise this exception, implementation is not needed.
31
+ end
32
+ end
33
+ end
34
+
26
35
  def File.binread(fname)
27
36
  open(fname, 'rb') {|f|
28
37
  return f.read
29
38
  }
30
39
  end
31
40
 
32
- # for corrupted windows stat(2)
41
+ # for corrupted Windows' stat(2)
33
42
  def File.dir?(path)
34
43
  File.directory?((path[-1,1] == '/') ? path : path + '/')
35
44
  end
36
45
 
37
46
 
38
- class SetupError < StandardError; end
39
-
40
- def setup_rb_error(msg)
41
- raise SetupError, msg
42
- end
43
-
44
- #
45
- # Config
46
- #
47
-
48
- if arg = ARGV.detect {|arg| /\A--rbconfig=/ =~ arg }
49
- ARGV.delete(arg)
50
- require arg.split(/=/, 2)[1]
51
- $".push 'rbconfig.rb'
52
- else
53
- require 'rbconfig'
54
- end
55
-
56
- def multipackage_install?
57
- FileTest.directory?(File.dirname($0) + '/packages')
58
- end
59
-
60
-
61
- class ConfigItem
62
- def initialize(name, template, default, desc)
63
- @name = name.freeze
64
- @template = template
65
- @value = default
66
- @default = default.dup.freeze
67
- @description = desc
68
- end
69
-
70
- attr_reader :name
71
- attr_reader :description
72
-
73
- attr_accessor :default
74
- alias help_default default
75
-
76
- def help_opt
77
- "--#{@name}=#{@template}"
78
- end
79
-
80
- def value
81
- @value
82
- end
83
-
84
- def eval(table)
85
- @value.gsub(%r<\$([^/]+)>) { table[$1] }
86
- end
87
-
88
- def set(val)
89
- @value = check(val)
90
- end
91
-
92
- private
93
-
94
- def check(val)
95
- setup_rb_error "config: --#{name} requires argument" unless val
96
- val
97
- end
98
- end
99
-
100
- class BoolItem < ConfigItem
101
- def config_type
102
- 'bool'
103
- end
104
-
105
- def help_opt
106
- "--#{@name}"
107
- end
108
-
109
- private
47
+ class ConfigTable
110
48
 
111
- def check(val)
112
- return 'yes' unless val
113
- unless /\A(y(es)?|n(o)?|t(rue)?|f(alse))\z/i =~ val
114
- setup_rb_error "config: --#{@name} accepts only yes/no for argument"
115
- end
116
- (/\Ay(es)?|\At(rue)/i =~ value) ? 'yes' : 'no'
117
- end
118
- end
119
-
120
- class PathItem < ConfigItem
121
- def config_type
122
- 'path'
123
- end
124
-
125
- private
49
+ include Enumerable
126
50
 
127
- def check(path)
128
- setup_rb_error "config: --#{@name} requires argument" unless path
129
- path[0,1] == '$' ? path : File.expand_path(path)
51
+ def initialize(rbconfig)
52
+ @rbconfig = rbconfig
53
+ @items = []
54
+ @table = {}
55
+ # options
56
+ @install_prefix = nil
57
+ @config_opt = nil
58
+ @verbose = true
59
+ @no_harm = false
60
+ @libsrc_pattern = '*.rb'
130
61
  end
131
- end
132
62
 
133
- class ProgramItem < ConfigItem
134
- def config_type
135
- 'program'
136
- end
137
- end
63
+ attr_accessor :install_prefix
64
+ attr_accessor :config_opt
138
65
 
139
- class SelectItem < ConfigItem
140
- def initialize(name, template, default, desc)
141
- super
142
- @ok = template.split('/')
143
- end
66
+ attr_writer :verbose
144
67
 
145
- def config_type
146
- 'select'
68
+ def verbose?
69
+ @verbose
147
70
  end
148
71
 
149
- private
150
-
151
- def check(val)
152
- unless @ok.include?(val.strip)
153
- setup_rb_error "config: use --#{@name}=#{@template} (#{val})"
154
- end
155
- val.strip
156
- end
157
- end
72
+ attr_writer :no_harm
158
73
 
159
- class PackageSelectionItem < ConfigItem
160
- def initialize(name, template, default, help_default, desc)
161
- super name, template, default, desc
162
- @help_default = help_default
74
+ def no_harm?
75
+ @no_harm
163
76
  end
164
77
 
165
- attr_reader :help_default
78
+ attr_accessor :libsrc_pattern
166
79
 
167
- def config_type
168
- 'package'
80
+ def [](key)
81
+ lookup(key).resolve(self)
169
82
  end
170
83
 
171
- private
172
-
173
- def check(val)
174
- unless File.dir?("packages/#{val}")
175
- setup_rb_error "config: no such package: #{val}"
176
- end
177
- val
84
+ def []=(key, val)
85
+ lookup(key).set val
178
86
  end
179
- end
180
87
 
181
- class ConfigTable_class
182
-
183
- def initialize(items)
184
- @items = items
185
- @table = {}
186
- items.each do |i|
187
- @table[i.name] = i
188
- end
189
- ALIASES.each do |ali, name|
190
- @table[ali] = @table[name]
191
- end
88
+ def names
89
+ @items.map {|i| i.name }
192
90
  end
193
91
 
194
- include Enumerable
195
-
196
92
  def each(&block)
197
93
  @items.each(&block)
198
94
  end
@@ -202,7 +98,7 @@ class ConfigTable_class
202
98
  end
203
99
 
204
100
  def lookup(name)
205
- @table[name] or raise ArgumentError, "no such config item: #{name}"
101
+ @table[name] or setup_rb_error "no such config item: #{name}"
206
102
  end
207
103
 
208
104
  def add(item)
@@ -217,24 +113,24 @@ class ConfigTable_class
217
113
  item
218
114
  end
219
115
 
220
- def new
221
- dup()
116
+ def load_script(path, inst = nil)
117
+ if File.file?(path)
118
+ MetaConfigEnvironment.new(self, inst).instance_eval File.read(path), path
119
+ end
222
120
  end
223
121
 
224
122
  def savefile
225
123
  '.config'
226
124
  end
227
125
 
228
- def load
126
+ def load_savefile
229
127
  begin
230
- t = dup()
231
128
  File.foreach(savefile()) do |line|
232
129
  k, v = *line.split(/=/, 2)
233
- t[k] = v.strip
130
+ self[k] = v.strip
234
131
  end
235
- t
236
132
  rescue Errno::ENOENT
237
- setup_rb_error $!.message + "#{File.basename($0)} config first"
133
+ setup_rb_error $!.message + "\n#{File.basename($0)} config first"
238
134
  end
239
135
  end
240
136
 
@@ -242,117 +138,151 @@ class ConfigTable_class
242
138
  @items.each {|i| i.value }
243
139
  File.open(savefile(), 'w') {|f|
244
140
  @items.each do |i|
245
- f.printf "%s=%s\n", i.name, i.value if i.value
141
+ f.printf "%s=%s\n", i.name, i.value if i.value? and i.value
246
142
  end
247
143
  }
248
144
  end
249
145
 
250
- def [](key)
251
- lookup(key).eval(self)
146
+ def load_standard_entries
147
+ standard_entries(@rbconfig).each do |ent|
148
+ add ent
149
+ end
252
150
  end
253
151
 
254
- def []=(key, val)
255
- lookup(key).set val
256
- end
152
+ def standard_entries(rbconfig)
153
+ c = rbconfig
154
+
155
+ rubypath = c['bindir'] + '/' + c['ruby_install_name']
156
+
157
+ major = c['MAJOR'].to_i
158
+ minor = c['MINOR'].to_i
159
+ teeny = c['TEENY'].to_i
160
+ version = "#{major}.#{minor}"
161
+
162
+ # ruby ver. >= 1.4.4?
163
+ newpath_p = ((major >= 2) or
164
+ ((major == 1) and
165
+ ((minor >= 5) or
166
+ ((minor == 4) and (teeny >= 4)))))
167
+
168
+ if c['rubylibdir']
169
+ # V > 1.6.3
170
+ libruby = "#{c['prefix']}/lib/ruby"
171
+ librubyver = c['rubylibdir']
172
+ librubyverarch = c['archdir']
173
+ siteruby = c['sitedir']
174
+ siterubyver = c['sitelibdir']
175
+ siterubyverarch = c['sitearchdir']
176
+ elsif newpath_p
177
+ # 1.4.4 <= V <= 1.6.3
178
+ libruby = "#{c['prefix']}/lib/ruby"
179
+ librubyver = "#{c['prefix']}/lib/ruby/#{version}"
180
+ librubyverarch = "#{c['prefix']}/lib/ruby/#{version}/#{c['arch']}"
181
+ siteruby = c['sitedir']
182
+ siterubyver = "$siteruby/#{version}"
183
+ siterubyverarch = "$siterubyver/#{c['arch']}"
184
+ else
185
+ # V < 1.4.4
186
+ libruby = "#{c['prefix']}/lib/ruby"
187
+ librubyver = "#{c['prefix']}/lib/ruby/#{version}"
188
+ librubyverarch = "#{c['prefix']}/lib/ruby/#{version}/#{c['arch']}"
189
+ siteruby = "#{c['prefix']}/lib/ruby/#{version}/site_ruby"
190
+ siterubyver = siteruby
191
+ siterubyverarch = "$siterubyver/#{c['arch']}"
192
+ end
193
+ parameterize = lambda {|path|
194
+ path.sub(/\A#{Regexp.quote(c['prefix'])}/, '$prefix')
195
+ }
257
196
 
258
- end
197
+ if arg = c['configure_args'].split.detect {|arg| /--with-make-prog=/ =~ arg }
198
+ makeprog = arg.sub(/'/, '').split(/=/, 2)[1]
199
+ else
200
+ makeprog = 'make'
201
+ end
259
202
 
260
- c = ::Config::CONFIG
261
-
262
- rubypath = c['bindir'] + '/' + c['ruby_install_name']
263
-
264
- major = c['MAJOR'].to_i
265
- minor = c['MINOR'].to_i
266
- teeny = c['TEENY'].to_i
267
- version = "#{major}.#{minor}"
268
-
269
- # ruby ver. >= 1.4.4?
270
- newpath_p = ((major >= 2) or
271
- ((major == 1) and
272
- ((minor >= 5) or
273
- ((minor == 4) and (teeny >= 4)))))
274
-
275
- if c['rubylibdir']
276
- # V < 1.6.3
277
- _stdruby = c['rubylibdir']
278
- _siteruby = c['sitedir']
279
- _siterubyver = c['sitelibdir']
280
- _siterubyverarch = c['sitearchdir']
281
- elsif newpath_p
282
- # 1.4.4 <= V <= 1.6.3
283
- _stdruby = "$prefix/lib/ruby/#{version}"
284
- _siteruby = c['sitedir']
285
- _siterubyver = "$siteruby/#{version}"
286
- _siterubyverarch = "$siterubyver/#{c['arch']}"
287
- else
288
- # V < 1.4.4
289
- _stdruby = "$prefix/lib/ruby/#{version}"
290
- _siteruby = "$prefix/lib/ruby/#{version}/site_ruby"
291
- _siterubyver = _siteruby
292
- _siterubyverarch = "$siterubyver/#{c['arch']}"
293
- end
294
- libdir = '-* dummy libdir *-'
295
- stdruby = '-* dummy rubylibdir *-'
296
- siteruby = '-* dummy site_ruby *-'
297
- siterubyver = '-* dummy site_ruby version *-'
298
- parameterize = lambda {|path|
299
- path.sub(/\A#{Regexp.quote(c['prefix'])}/, '$prefix')\
300
- .sub(/\A#{Regexp.quote(libdir)}/, '$libdir')\
301
- .sub(/\A#{Regexp.quote(stdruby)}/, '$stdruby')\
302
- .sub(/\A#{Regexp.quote(siteruby)}/, '$siteruby')\
303
- .sub(/\A#{Regexp.quote(siterubyver)}/, '$siterubyver')
304
- }
305
- libdir = parameterize.call(c['libdir'])
306
- stdruby = parameterize.call(_stdruby)
307
- siteruby = parameterize.call(_siteruby)
308
- siterubyver = parameterize.call(_siterubyver)
309
- siterubyverarch = parameterize.call(_siterubyverarch)
310
-
311
- if arg = c['configure_args'].split.detect {|arg| /--with-make-prog=/ =~ arg }
312
- makeprog = arg.sub(/'/, '').split(/=/, 2)[1]
313
- else
314
- makeprog = 'make'
315
- end
203
+ [
204
+ ExecItem.new('installdirs', 'std/site/home',
205
+ 'std: install under libruby; site: install under site_ruby; home: install under $HOME')\
206
+ {|val, table|
207
+ case val
208
+ when 'std'
209
+ table['rbdir'] = '$librubyver'
210
+ table['sodir'] = '$librubyverarch'
211
+ when 'site'
212
+ table['rbdir'] = '$siterubyver'
213
+ table['sodir'] = '$siterubyverarch'
214
+ when 'home'
215
+ setup_rb_error '$HOME was not set' unless ENV['HOME']
216
+ table['prefix'] = ENV['HOME']
217
+ table['rbdir'] = '$libdir/ruby'
218
+ table['sodir'] = '$libdir/ruby'
219
+ end
220
+ },
221
+ PathItem.new('prefix', 'path', c['prefix'],
222
+ 'path prefix of target environment'),
223
+ PathItem.new('bindir', 'path', parameterize.call(c['bindir']),
224
+ 'the directory for commands'),
225
+ PathItem.new('libdir', 'path', parameterize.call(c['libdir']),
226
+ 'the directory for libraries'),
227
+ PathItem.new('datadir', 'path', parameterize.call(c['datadir']),
228
+ 'the directory for shared data'),
229
+ PathItem.new('mandir', 'path', parameterize.call(c['mandir']),
230
+ 'the directory for man pages'),
231
+ PathItem.new('sysconfdir', 'path', parameterize.call(c['sysconfdir']),
232
+ 'the directory for system configuration files'),
233
+ PathItem.new('localstatedir', 'path', parameterize.call(c['localstatedir']),
234
+ 'the directory for local state data'),
235
+ PathItem.new('libruby', 'path', libruby,
236
+ 'the directory for ruby libraries'),
237
+ PathItem.new('librubyver', 'path', librubyver,
238
+ 'the directory for standard ruby libraries'),
239
+ PathItem.new('librubyverarch', 'path', librubyverarch,
240
+ 'the directory for standard ruby extensions'),
241
+ PathItem.new('siteruby', 'path', siteruby,
242
+ 'the directory for version-independent aux ruby libraries'),
243
+ PathItem.new('siterubyver', 'path', siterubyver,
244
+ 'the directory for aux ruby libraries'),
245
+ PathItem.new('siterubyverarch', 'path', siterubyverarch,
246
+ 'the directory for aux ruby binaries'),
247
+ PathItem.new('rbdir', 'path', '$siterubyver',
248
+ 'the directory for ruby scripts'),
249
+ PathItem.new('sodir', 'path', '$siterubyverarch',
250
+ 'the directory for ruby extentions'),
251
+ PathItem.new('rubypath', 'path', rubypath,
252
+ 'the path to set to #! line'),
253
+ ProgramItem.new('rubyprog', 'name', rubypath,
254
+ 'the ruby program using for installation'),
255
+ ProgramItem.new('makeprog', 'name', makeprog,
256
+ 'the make program to compile ruby extentions'),
257
+ SelectItem.new('shebang', 'all/ruby/never', 'ruby',
258
+ 'shebang line (#!) editing mode'),
259
+ BoolItem.new('without-ext', 'yes/no', 'no',
260
+ 'does not compile/install ruby extentions')
261
+ ]
262
+ end
263
+ private :standard_entries
264
+
265
+ def load_multipackage_entries
266
+ multipackage_entries().each do |ent|
267
+ add ent
268
+ end
269
+ end
270
+
271
+ def multipackage_entries
272
+ [
273
+ PackageSelectionItem.new('with', 'name,name...', '', 'ALL',
274
+ 'package names that you want to install'),
275
+ PackageSelectionItem.new('without', 'name,name...', '', 'NONE',
276
+ 'package names that you do not want to install')
277
+ ]
278
+ end
279
+ private :multipackage_entries
316
280
 
317
- common_conf = [
318
- PathItem.new('prefix', 'path', c['prefix'],
319
- 'path prefix of target environment'),
320
- PathItem.new('bindir', 'path', parameterize.call(c['bindir']),
321
- 'the directory for commands'),
322
- PathItem.new('libdir', 'path', libdir,
323
- 'the directory for libraries'),
324
- PathItem.new('datadir', 'path', parameterize.call(c['datadir']),
325
- 'the directory for shared data'),
326
- PathItem.new('mandir', 'path', parameterize.call(c['mandir']),
327
- 'the directory for man pages'),
328
- PathItem.new('sysconfdir', 'path', parameterize.call(c['sysconfdir']),
329
- 'the directory for man pages'),
330
- PathItem.new('stdruby', 'path', stdruby,
331
- 'the directory for standard ruby libraries'),
332
- PathItem.new('siteruby', 'path', siteruby,
333
- 'the directory for version-independent aux ruby libraries'),
334
- PathItem.new('siterubyver', 'path', siterubyver,
335
- 'the directory for aux ruby libraries'),
336
- PathItem.new('siterubyverarch', 'path', siterubyverarch,
337
- 'the directory for aux ruby binaries'),
338
- PathItem.new('rbdir', 'path', '$siterubyver',
339
- 'the directory for ruby scripts'),
340
- PathItem.new('sodir', 'path', '$siterubyverarch',
341
- 'the directory for ruby extentions'),
342
- PathItem.new('rubypath', 'path', rubypath,
343
- 'the path to set to #! line'),
344
- ProgramItem.new('rubyprog', 'name', rubypath,
345
- 'the ruby program using for installation'),
346
- ProgramItem.new('makeprog', 'name', makeprog,
347
- 'the make program to compile ruby extentions'),
348
- SelectItem.new('shebang', 'all/ruby/never', 'ruby',
349
- 'shebang line (#!) editing mode'),
350
- BoolItem.new('without-ext', 'yes/no', 'no',
351
- 'does not compile/install ruby extentions')
352
- ]
353
- class ConfigTable_class # open again
354
281
  ALIASES = {
355
- 'std-ruby' => 'stdruby',
282
+ 'std-ruby' => 'librubyver',
283
+ 'stdruby' => 'librubyver',
284
+ 'rubylibdir' => 'librubyver',
285
+ 'archdir' => 'librubyverarch',
356
286
  'site-ruby-common' => 'siteruby', # For backward compatibility
357
287
  'site-ruby' => 'siterubyver', # For backward compatibility
358
288
  'bin-dir' => 'bindir',
@@ -366,78 +296,246 @@ class ConfigTable_class # open again
366
296
  'make-prog' => 'makeprog',
367
297
  'make' => 'makeprog'
368
298
  }
369
- end
370
- multipackage_conf = [
371
- PackageSelectionItem.new('with', 'name,name...', '', 'ALL',
372
- 'package names that you want to install'),
373
- PackageSelectionItem.new('without', 'name,name...', '', 'NONE',
374
- 'package names that you do not want to install')
375
- ]
376
- if multipackage_install?
377
- ConfigTable = ConfigTable_class.new(common_conf + multipackage_conf)
378
- else
379
- ConfigTable = ConfigTable_class.new(common_conf)
380
- end
381
-
382
-
383
- module MetaConfigAPI
384
299
 
385
- def eval_file_ifexist(fname)
386
- instance_eval File.read(fname), fname, 1 if File.file?(fname)
300
+ def fixup
301
+ ALIASES.each do |ali, name|
302
+ @table[ali] = @table[name]
303
+ end
304
+ @items.freeze
305
+ @table.freeze
306
+ @options_re = /\A--(#{@table.keys.join('|')})(?:=(.*))?\z/
387
307
  end
388
308
 
389
- def config_names
390
- ConfigTable.map {|i| i.name }
309
+ def parse_opt(opt)
310
+ m = @options_re.match(opt) or setup_rb_error "config: unknown option #{opt}"
311
+ m.to_a[1,2]
391
312
  end
392
313
 
393
- def config?(name)
394
- ConfigTable.key?(name)
314
+ def dllext
315
+ @rbconfig['DLEXT']
395
316
  end
396
317
 
397
- def bool_config?(name)
398
- ConfigTable.lookup(name).config_type == 'bool'
318
+ def value_config?(name)
319
+ lookup(name).value?
399
320
  end
400
321
 
401
- def path_config?(name)
402
- ConfigTable.lookup(name).config_type == 'path'
403
- end
322
+ class Item
323
+ def initialize(name, template, default, desc)
324
+ @name = name.freeze
325
+ @template = template
326
+ @value = default
327
+ @default = default
328
+ @description = desc
329
+ end
404
330
 
405
- def value_config?(name)
406
- case ConfigTable.lookup(name).config_type
407
- when 'bool', 'path'
331
+ attr_reader :name
332
+ attr_reader :description
333
+
334
+ attr_accessor :default
335
+ alias help_default default
336
+
337
+ def help_opt
338
+ "--#{@name}=#{@template}"
339
+ end
340
+
341
+ def value?
408
342
  true
409
- else
410
- false
343
+ end
344
+
345
+ def value
346
+ @value
347
+ end
348
+
349
+ def resolve(table)
350
+ @value.gsub(%r<\$([^/]+)>) { table[$1] }
351
+ end
352
+
353
+ def set(val)
354
+ @value = check(val)
355
+ end
356
+
357
+ private
358
+
359
+ def check(val)
360
+ setup_rb_error "config: --#{name} requires argument" unless val
361
+ val
362
+ end
363
+ end
364
+
365
+ class BoolItem < Item
366
+ def config_type
367
+ 'bool'
368
+ end
369
+
370
+ def help_opt
371
+ "--#{@name}"
372
+ end
373
+
374
+ private
375
+
376
+ def check(val)
377
+ return 'yes' unless val
378
+ unless /\A(y(es)?|n(o)?|t(rue)?|f(alse))\z/i =~ val
379
+ setup_rb_error "config: --#{@name} accepts only yes/no for argument"
380
+ end
381
+ (/\Ay(es)?|\At(rue)/i =~ value) ? 'yes' : 'no'
411
382
  end
412
383
  end
413
384
 
414
- def add_config(item)
415
- ConfigTable.add item
385
+ class PathItem < Item
386
+ def config_type
387
+ 'path'
388
+ end
389
+
390
+ private
391
+
392
+ def check(path)
393
+ setup_rb_error "config: --#{@name} requires argument" unless path
394
+ path[0,1] == '$' ? path : File.expand_path(path)
395
+ end
416
396
  end
417
397
 
418
- def add_bool_config(name, default, desc)
419
- ConfigTable.add BoolItem.new(name, 'yes/no', default ? 'yes' : 'no', desc)
398
+ class ProgramItem < Item
399
+ def config_type
400
+ 'program'
401
+ end
420
402
  end
421
403
 
422
- def add_path_config(name, default, desc)
423
- ConfigTable.add PathItem.new(name, 'path', default, desc)
404
+ class SelectItem < Item
405
+ def initialize(name, selection, default, desc)
406
+ super
407
+ @ok = selection.split('/')
408
+ end
409
+
410
+ def config_type
411
+ 'select'
412
+ end
413
+
414
+ private
415
+
416
+ def check(val)
417
+ unless @ok.include?(val.strip)
418
+ setup_rb_error "config: use --#{@name}=#{@template} (#{val})"
419
+ end
420
+ val.strip
421
+ end
424
422
  end
425
423
 
426
- def set_config_default(name, default)
427
- ConfigTable.lookup(name).default = default
424
+ class ExecItem < Item
425
+ def initialize(name, selection, desc, &block)
426
+ super name, selection, nil, desc
427
+ @ok = selection.split('/')
428
+ @action = block
429
+ end
430
+
431
+ def config_type
432
+ 'exec'
433
+ end
434
+
435
+ def value?
436
+ false
437
+ end
438
+
439
+ def resolve(table)
440
+ setup_rb_error "$#{name()} wrongly used as option value"
441
+ end
442
+
443
+ undef set
444
+
445
+ def evaluate(val, table)
446
+ v = val.strip.downcase
447
+ unless @ok.include?(v)
448
+ setup_rb_error "invalid option --#{@name}=#{val} (use #{@template})"
449
+ end
450
+ @action.call v, table
451
+ end
428
452
  end
429
453
 
430
- def remove_config(name)
431
- ConfigTable.remove(name)
454
+ class PackageSelectionItem < Item
455
+ def initialize(name, template, default, help_default, desc)
456
+ super name, template, default, desc
457
+ @help_default = help_default
458
+ end
459
+
460
+ attr_reader :help_default
461
+
462
+ def config_type
463
+ 'package'
464
+ end
465
+
466
+ private
467
+
468
+ def check(val)
469
+ unless File.dir?("packages/#{val}")
470
+ setup_rb_error "config: no such package: #{val}"
471
+ end
472
+ val
473
+ end
432
474
  end
433
475
 
434
- end
476
+ class MetaConfigEnvironment
477
+ def intiailize(config, installer)
478
+ @config = config
479
+ @installer = installer
480
+ end
435
481
 
482
+ def config_names
483
+ @config.names
484
+ end
436
485
 
437
- #
438
- # File Operations
439
- #
486
+ def config?(name)
487
+ @config.key?(name)
488
+ end
489
+
490
+ def bool_config?(name)
491
+ @config.lookup(name).config_type == 'bool'
492
+ end
493
+
494
+ def path_config?(name)
495
+ @config.lookup(name).config_type == 'path'
496
+ end
497
+
498
+ def value_config?(name)
499
+ @config.lookup(name).config_type != 'exec'
500
+ end
501
+
502
+ def add_config(item)
503
+ @config.add item
504
+ end
505
+
506
+ def add_bool_config(name, default, desc)
507
+ @config.add BoolItem.new(name, 'yes/no', default ? 'yes' : 'no', desc)
508
+ end
509
+
510
+ def add_path_config(name, default, desc)
511
+ @config.add PathItem.new(name, 'path', default, desc)
512
+ end
513
+
514
+ def set_config_default(name, default)
515
+ @config.lookup(name).default = default
516
+ end
517
+
518
+ def remove_config(name)
519
+ @config.remove(name)
520
+ end
521
+
522
+ # For only multipackage
523
+ def packages
524
+ raise '[setup.rb fatal] multi-package metaconfig API packages() called for single-package; contact application package vendor' unless @installer
525
+ @installer.packages
526
+ end
440
527
 
528
+ # For only multipackage
529
+ def declare_packages(list)
530
+ raise '[setup.rb fatal] multi-package metaconfig API declare_packages() called for single-package; contact application package vendor' unless @installer
531
+ @installer.packages = list
532
+ end
533
+ end
534
+
535
+ end # class ConfigTable
536
+
537
+
538
+ # This module requires: #verbose?, #no_harm?
441
539
  module FileOperations
442
540
 
443
541
  def mkdir_p(dirname, prefix = nil)
@@ -445,7 +543,7 @@ module FileOperations
445
543
  $stderr.puts "mkdir -p #{dirname}" if verbose?
446
544
  return if no_harm?
447
545
 
448
- # does not check '/'... it's too abnormal case
546
+ # Does not check '/', it's too abnormal.
449
547
  dirs = File.expand_path(dirname).split(%r<(?=/)>)
450
548
  if /\A[a-z]:\z/i =~ dirs[0]
451
549
  disk = dirs.shift
@@ -457,49 +555,73 @@ module FileOperations
457
555
  end
458
556
  end
459
557
 
460
- def rm_f(fname)
461
- $stderr.puts "rm -f #{fname}" if verbose?
558
+ def rm_f(path)
559
+ $stderr.puts "rm -f #{path}" if verbose?
462
560
  return if no_harm?
463
-
464
- if File.exist?(fname) or File.symlink?(fname)
465
- File.chmod 0777, fname
466
- File.unlink fname
467
- end
561
+ force_remove_file path
468
562
  end
469
563
 
470
- def rm_rf(dn)
471
- $stderr.puts "rm -rf #{dn}" if verbose?
564
+ def rm_rf(path)
565
+ $stderr.puts "rm -rf #{path}" if verbose?
472
566
  return if no_harm?
567
+ remove_tree path
568
+ end
473
569
 
474
- Dir.chdir dn
475
- Dir.foreach('.') do |fn|
476
- next if fn == '.'
477
- next if fn == '..'
478
- if File.dir?(fn)
479
- verbose_off {
480
- rm_rf fn
481
- }
570
+ def remove_tree(path)
571
+ if File.symlink?(path)
572
+ remove_file path
573
+ elsif File.dir?(path)
574
+ remove_tree0 path
575
+ else
576
+ force_remove_file path
577
+ end
578
+ end
579
+
580
+ def remove_tree0(path)
581
+ Dir.foreach(path) do |ent|
582
+ next if ent == '.'
583
+ next if ent == '..'
584
+ entpath = "#{path}/#{ent}"
585
+ if File.symlink?(entpath)
586
+ remove_file entpath
587
+ elsif File.dir?(entpath)
588
+ remove_tree0 entpath
482
589
  else
483
- verbose_off {
484
- rm_f fn
485
- }
590
+ force_remove_file entpath
486
591
  end
487
592
  end
488
- Dir.chdir '..'
489
- Dir.rmdir dn
593
+ begin
594
+ Dir.rmdir path
595
+ rescue Errno::ENOTEMPTY
596
+ # directory may not be empty
597
+ end
490
598
  end
491
599
 
492
600
  def move_file(src, dest)
493
- File.unlink dest if File.exist?(dest)
601
+ force_remove_file dest
494
602
  begin
495
603
  File.rename src, dest
496
604
  rescue
497
- File.open(dest, 'wb') {|f| f.write File.binread(src) }
605
+ File.open(dest, 'wb') {|f|
606
+ f.write File.binread(src)
607
+ }
498
608
  File.chmod File.stat(src).mode, dest
499
609
  File.unlink src
500
610
  end
501
611
  end
502
612
 
613
+ def force_remove_file(path)
614
+ begin
615
+ remove_file path
616
+ rescue
617
+ end
618
+ end
619
+
620
+ def remove_file(path)
621
+ File.chmod 0777, path
622
+ File.unlink path
623
+ end
624
+
503
625
  def install(from, dest, mode, prefix = nil)
504
626
  $stderr.puts "install #{from} #{dest}" if verbose?
505
627
  return if no_harm?
@@ -531,66 +653,42 @@ module FileOperations
531
653
  new_content != File.binread(path)
532
654
  end
533
655
 
534
- def command(str)
535
- $stderr.puts str if verbose?
536
- system str or raise RuntimeError, "'system #{str}' failed"
656
+ def command(*args)
657
+ $stderr.puts args.join(' ') if verbose?
658
+ system(*args) or raise RuntimeError,
659
+ "system(#{args.map{|a| a.inspect }.join(' ')}) failed"
537
660
  end
538
661
 
539
- def ruby(str)
540
- command config('rubyprog') + ' ' + str
662
+ def ruby(*args)
663
+ command config('rubyprog'), *args
541
664
  end
542
665
 
543
- def make(task = '')
544
- command config('makeprog') + ' ' + task
666
+ def make(task = nil)
667
+ command(*[config('makeprog'), task].compact)
545
668
  end
546
669
 
547
670
  def extdir?(dir)
548
- File.exist?(dir + '/MANIFEST')
671
+ File.exist?("#{dir}/MANIFEST") or File.exist?("#{dir}/extconf.rb")
549
672
  end
550
673
 
551
- def all_files_in(dirname)
552
- Dir.open(dirname) {|d|
553
- return d.select {|ent| File.file?("#{dirname}/#{ent}") }
674
+ def files_of(dir)
675
+ Dir.open(dir) {|d|
676
+ return d.select {|ent| File.file?("#{dir}/#{ent}") }
554
677
  }
555
678
  end
556
679
 
557
- REJECT_DIRS = %w(
558
- CVS SCCS RCS CVS.adm .svn
559
- )
680
+ DIR_REJECT = %w( . .. CVS SCCS RCS CVS.adm .svn )
560
681
 
561
- def all_dirs_in(dirname)
562
- Dir.open(dirname) {|d|
563
- return d.select {|n| File.dir?("#{dirname}/#{n}") } - %w(. ..) - REJECT_DIRS
682
+ def directories_of(dir)
683
+ Dir.open(dir) {|d|
684
+ return d.select {|ent| File.dir?("#{dir}/#{ent}") } - DIR_REJECT
564
685
  }
565
686
  end
566
687
 
567
688
  end
568
689
 
569
690
 
570
- #
571
- # Main Installer
572
- #
573
-
574
- module HookUtils
575
-
576
- def run_hook(name)
577
- try_run_hook "#{curr_srcdir()}/#{name}" or
578
- try_run_hook "#{curr_srcdir()}/#{name}.rb"
579
- end
580
-
581
- def try_run_hook(fname)
582
- return false unless File.file?(fname)
583
- begin
584
- instance_eval File.read(fname), fname, 1
585
- rescue
586
- setup_rb_error "hook #{fname} failed:\n" + $!.message
587
- end
588
- true
589
- end
590
-
591
- end
592
-
593
-
691
+ # This module requires: #srcdir_root, #objdir_root, #relpath
594
692
  module HookScriptAPI
595
693
 
596
694
  def get_config(key)
@@ -599,6 +697,7 @@ module HookScriptAPI
599
697
 
600
698
  alias config get_config
601
699
 
700
+ # obsolete: use metaconfig to change configuration
602
701
  def set_config(key, val)
603
702
  @config[key] = val
604
703
  end
@@ -607,10 +706,6 @@ module HookScriptAPI
607
706
  # srcdir/objdir (works only in the package directory)
608
707
  #
609
708
 
610
- #abstract srcdir_root
611
- #abstract objdir_root
612
- #abstract relpath
613
-
614
709
  def curr_srcdir
615
710
  "#{srcdir_root()}/#{relpath()}"
616
711
  end
@@ -632,7 +727,7 @@ module HookScriptAPI
632
727
  end
633
728
 
634
729
  def srcfile?(path)
635
- File.file? srcfile(path)
730
+ File.file?(srcfile(path))
636
731
  end
637
732
 
638
733
  def srcentries(path = '.')
@@ -658,8 +753,8 @@ end
658
753
 
659
754
  class ToplevelInstaller
660
755
 
661
- Version = '3.3.1'
662
- Copyright = 'Copyright (c) 2000-2004 Minero Aoki'
756
+ Version = '3.4.0'
757
+ Copyright = 'Copyright (c) 2000-2005 Minero Aoki'
663
758
 
664
759
  TASKS = [
665
760
  [ 'all', 'do config, setup, then install' ],
@@ -667,27 +762,44 @@ class ToplevelInstaller
667
762
  [ 'show', 'shows current configuration' ],
668
763
  [ 'setup', 'compiles ruby extentions and others' ],
669
764
  [ 'install', 'installs files' ],
765
+ [ 'test', 'run all tests in test/' ],
670
766
  [ 'clean', "does `make clean' for each extention" ],
671
767
  [ 'distclean',"does `make distclean' for each extention" ]
672
768
  ]
673
769
 
674
770
  def ToplevelInstaller.invoke
675
- instance().invoke
771
+ config = ConfigTable.new(load_rbconfig())
772
+ config.load_standard_entries
773
+ config.load_multipackage_entries if multipackage?
774
+ config.fixup
775
+ klass = (multipackage?() ? ToplevelInstallerMulti : ToplevelInstaller)
776
+ klass.new(File.dirname($0), config).invoke
676
777
  end
677
778
 
678
- @singleton = nil
679
-
680
- def ToplevelInstaller.instance
681
- @singleton ||= new(File.dirname($0))
682
- @singleton
779
+ def ToplevelInstaller.multipackage?
780
+ File.dir?(File.dirname($0) + '/packages')
683
781
  end
684
782
 
685
- include MetaConfigAPI
783
+ def ToplevelInstaller.load_rbconfig
784
+ if arg = ARGV.detect {|arg| /\A--rbconfig=/ =~ arg }
785
+ ARGV.delete(arg)
786
+ load File.expand_path(arg.split(/=/, 2)[1])
787
+ $".push 'rbconfig.rb'
788
+ else
789
+ require 'rbconfig'
790
+ end
791
+ ::Config::CONFIG
792
+ end
686
793
 
687
- def initialize(ardir_root)
688
- @config = nil
689
- @options = { 'verbose' => true }
794
+ def initialize(ardir_root, config)
690
795
  @ardir = File.expand_path(ardir_root)
796
+ @config = config
797
+ # cache
798
+ @valid_task_re = nil
799
+ end
800
+
801
+ def config(key)
802
+ @config[key]
691
803
  end
692
804
 
693
805
  def inspect
@@ -698,14 +810,20 @@ class ToplevelInstaller
698
810
  run_metaconfigs
699
811
  case task = parsearg_global()
700
812
  when nil, 'all'
701
- @config = load_config('config')
702
813
  parsearg_config
703
814
  init_installers
704
815
  exec_config
705
816
  exec_setup
706
817
  exec_install
707
818
  else
708
- @config = load_config(task)
819
+ case task
820
+ when 'config', 'test'
821
+ ;
822
+ when 'clean', 'distclean'
823
+ @config.load_savefile if File.exist?(@config.savefile)
824
+ else
825
+ @config.load_savefile
826
+ end
709
827
  __send__ "parsearg_#{task}"
710
828
  init_installers
711
829
  __send__ "exec_#{task}"
@@ -713,25 +831,11 @@ class ToplevelInstaller
713
831
  end
714
832
 
715
833
  def run_metaconfigs
716
- eval_file_ifexist "#{@ardir}/metaconfig"
717
- end
718
-
719
- def load_config(task)
720
- case task
721
- when 'config'
722
- ConfigTable.new
723
- when 'clean', 'distclean'
724
- if File.exist?(ConfigTable.savefile)
725
- then ConfigTable.load
726
- else ConfigTable.new
727
- end
728
- else
729
- ConfigTable.load
730
- end
834
+ @config.load_script "#{@ardir}/metaconfig"
731
835
  end
732
836
 
733
837
  def init_installers
734
- @installer = Installer.new(@config, @options, @ardir, File.expand_path('.'))
838
+ @installer = Installer.new(@config, @ardir, File.expand_path('.'))
735
839
  end
736
840
 
737
841
  #
@@ -755,78 +859,88 @@ class ToplevelInstaller
755
859
  #
756
860
 
757
861
  def parsearg_global
758
- valid_task = /\A(?:#{TASKS.map {|task,desc| task }.join '|'})\z/
759
-
760
862
  while arg = ARGV.shift
761
863
  case arg
762
864
  when /\A\w+\z/
763
- setup_rb_error "invalid task: #{arg}" unless valid_task =~ arg
865
+ setup_rb_error "invalid task: #{arg}" unless valid_task?(arg)
764
866
  return arg
765
-
766
867
  when '-q', '--quiet'
767
- @options['verbose'] = false
768
-
769
- when '--verbose'
770
- @options['verbose'] = true
771
-
772
- when '-h', '--help'
868
+ @config.verbose = false
869
+ when '--verbose'
870
+ @config.verbose = true
871
+ when '--help'
773
872
  print_usage $stdout
774
873
  exit 0
775
-
776
- when '-v', '--version'
874
+ when '--version'
777
875
  puts "#{File.basename($0)} version #{Version}"
778
876
  exit 0
779
-
780
877
  when '--copyright'
781
878
  puts Copyright
782
879
  exit 0
783
-
784
880
  else
785
881
  setup_rb_error "unknown global option '#{arg}'"
786
882
  end
787
883
  end
788
-
789
884
  nil
790
885
  end
791
886
 
887
+ def valid_task?(t)
888
+ valid_task_re() =~ t
889
+ end
890
+
891
+ def valid_task_re
892
+ @valid_task_re ||= /\A(?:#{TASKS.map {|task,desc| task }.join('|')})\z/
893
+ end
792
894
 
793
895
  def parsearg_no_options
794
896
  unless ARGV.empty?
795
- setup_rb_error "#{task}: unknown options: #{ARGV.join ' '}"
897
+ setup_rb_error "#{task}: unknown options: #{ARGV.join(' ')}"
796
898
  end
797
899
  end
798
900
 
799
901
  alias parsearg_show parsearg_no_options
800
902
  alias parsearg_setup parsearg_no_options
903
+ alias parsearg_test parsearg_no_options
801
904
  alias parsearg_clean parsearg_no_options
802
905
  alias parsearg_distclean parsearg_no_options
803
906
 
804
907
  def parsearg_config
805
- re = /\A--(#{ConfigTable.map {|i| i.name }.join('|')})(?:=(.*))?\z/
806
- @options['config-opt'] = []
807
-
908
+ evalopt = []
909
+ set = []
910
+ @config.config_opt = []
808
911
  while i = ARGV.shift
809
912
  if /\A--?\z/ =~ i
810
- @options['config-opt'] = ARGV.dup
913
+ @config.config_opt = ARGV.dup
811
914
  break
812
915
  end
813
- m = re.match(i) or setup_rb_error "config: unknown option #{i}"
814
- name, value = *m.to_a[1,2]
815
- @config[name] = value
916
+ name, value = *@config.parse_opt(i)
917
+ if @config.value_config?(name)
918
+ @config[name] = value
919
+ else
920
+ evalopt.push [name, value]
921
+ end
922
+ set.push name
923
+ end
924
+ evalopt.each do |name, value|
925
+ @config.lookup(name).evaluate value, @config
926
+ end
927
+ # Check if configuration is valid
928
+ set.each do |n|
929
+ @config[n] if @config.value_config?(n)
816
930
  end
817
931
  end
818
932
 
819
933
  def parsearg_install
820
- @options['no-harm'] = false
821
- @options['install-prefix'] = ''
934
+ @config.no_harm = false
935
+ @config.install_prefix = ''
822
936
  while a = ARGV.shift
823
937
  case a
824
- when /\A--no-harm\z/
825
- @options['no-harm'] = true
826
- when /\A--prefix=(.*)\z/
827
- path = $1
938
+ when '--no-harm'
939
+ @config.no_harm = true
940
+ when /\A--prefix=/
941
+ path = a.split(/=/, 2)[1]
828
942
  path = File.expand_path(path) unless path[0,1] == '/'
829
- @options['install-prefix'] = path
943
+ @config.install_prefix = path
830
944
  else
831
945
  setup_rb_error "install: unknown option #{a}"
832
946
  end
@@ -848,8 +962,8 @@ class ToplevelInstaller
848
962
  out.puts 'Global options:'
849
963
  out.printf fmt, '-q,--quiet', 'suppress message outputs'
850
964
  out.printf fmt, ' --verbose', 'output messages verbosely'
851
- out.printf fmt, '-h,--help', 'print this message'
852
- out.printf fmt, '-v,--version', 'print version and quit'
965
+ out.printf fmt, ' --help', 'print this message'
966
+ out.printf fmt, ' --version', 'print version and quit'
853
967
  out.printf fmt, ' --copyright', 'print copyright and quit'
854
968
  out.puts
855
969
  out.puts 'Tasks:'
@@ -860,14 +974,14 @@ class ToplevelInstaller
860
974
  fmt = " %-24s %s [%s]\n"
861
975
  out.puts
862
976
  out.puts 'Options for CONFIG or ALL:'
863
- ConfigTable.each do |item|
977
+ @config.each do |item|
864
978
  out.printf fmt, item.help_opt, item.description, item.help_default
865
979
  end
866
980
  out.printf fmt, '--rbconfig=path', 'rbconfig.rb to load',"running ruby's"
867
981
  out.puts
868
982
  out.puts 'Options for INSTALL:'
869
983
  out.printf fmt, '--no-harm', 'only display what to do if given', 'off'
870
- out.printf fmt, '--prefix=path', 'install path prefix', '$prefix'
984
+ out.printf fmt, '--prefix=path', 'install path prefix', ''
871
985
  out.puts
872
986
  end
873
987
 
@@ -888,9 +1002,13 @@ class ToplevelInstaller
888
1002
  @installer.exec_install
889
1003
  end
890
1004
 
1005
+ def exec_test
1006
+ @installer.exec_test
1007
+ end
1008
+
891
1009
  def exec_show
892
- ConfigTable.each do |i|
893
- printf "%-20s %s\n", i.name, i.value
1010
+ @config.each do |i|
1011
+ printf "%-20s %s\n", i.name, i.value if i.value?
894
1012
  end
895
1013
  end
896
1014
 
@@ -902,36 +1020,45 @@ class ToplevelInstaller
902
1020
  @installer.exec_distclean
903
1021
  end
904
1022
 
905
- end
1023
+ end # class ToplevelInstaller
906
1024
 
907
1025
 
908
1026
  class ToplevelInstallerMulti < ToplevelInstaller
909
1027
 
910
- include HookUtils
911
- include HookScriptAPI
912
1028
  include FileOperations
913
1029
 
914
- def initialize(ardir)
1030
+ def initialize(ardir_root, config)
915
1031
  super
916
- @packages = all_dirs_in("#{@ardir}/packages")
1032
+ @packages = directories_of("#{@ardir}/packages")
917
1033
  raise 'no package exists' if @packages.empty?
1034
+ @root_installer = Installer.new(@config, @ardir, File.expand_path('.'))
918
1035
  end
919
1036
 
920
1037
  def run_metaconfigs
921
- eval_file_ifexist "#{@ardir}/metaconfig"
1038
+ @config.load_script "#{@ardir}/metaconfig", self
922
1039
  @packages.each do |name|
923
- eval_file_ifexist "#{@ardir}/packages/#{name}/metaconfig"
1040
+ @config.load_script "#{@ardir}/packages/#{name}/metaconfig"
1041
+ end
1042
+ end
1043
+
1044
+ attr_reader :packages
1045
+
1046
+ def packages=(list)
1047
+ raise 'package list is empty' if list.empty?
1048
+ list.each do |name|
1049
+ raise "directory packages/#{name} does not exist"\
1050
+ unless File.dir?("#{@ardir}/packages/#{name}")
924
1051
  end
1052
+ @packages = list
925
1053
  end
926
1054
 
927
1055
  def init_installers
928
1056
  @installers = {}
929
1057
  @packages.each do |pack|
930
- @installers[pack] = Installer.new(@config, @options,
1058
+ @installers[pack] = Installer.new(@config,
931
1059
  "#{@ardir}/packages/#{pack}",
932
1060
  "packages/#{pack}")
933
1061
  end
934
-
935
1062
  with = extract_selection(config('with'))
936
1063
  without = extract_selection(config('without'))
937
1064
  @selected = @installers.keys.select {|name|
@@ -955,21 +1082,6 @@ class ToplevelInstallerMulti < ToplevelInstaller
955
1082
  f.puts
956
1083
  end
957
1084
 
958
- #
959
- # multi-package metaconfig API
960
- #
961
-
962
- attr_reader :packages
963
-
964
- def declare_packages(list)
965
- raise 'package list is empty' if list.empty?
966
- list.each do |name|
967
- raise "directory packages/#{name} does not exist"\
968
- unless File.dir?("#{@ardir}/packages/#{name}")
969
- end
970
- @packages = list
971
- end
972
-
973
1085
  #
974
1086
  # Task Handlers
975
1087
  #
@@ -993,15 +1105,21 @@ class ToplevelInstallerMulti < ToplevelInstaller
993
1105
  run_hook 'post-install'
994
1106
  end
995
1107
 
1108
+ def exec_test
1109
+ run_hook 'pre-test'
1110
+ each_selected_installers {|inst| inst.exec_test }
1111
+ run_hook 'post-test'
1112
+ end
1113
+
996
1114
  def exec_clean
997
- rm_f ConfigTable.savefile
1115
+ rm_f @config.savefile
998
1116
  run_hook 'pre-clean'
999
1117
  each_selected_installers {|inst| inst.exec_clean }
1000
1118
  run_hook 'post-clean'
1001
1119
  end
1002
1120
 
1003
1121
  def exec_distclean
1004
- rm_f ConfigTable.savefile
1122
+ rm_f @config.savefile
1005
1123
  run_hook 'pre-distclean'
1006
1124
  each_selected_installers {|inst| inst.exec_distclean }
1007
1125
  run_hook 'post-distclean'
@@ -1014,7 +1132,7 @@ class ToplevelInstallerMulti < ToplevelInstaller
1014
1132
  def each_selected_installers
1015
1133
  Dir.mkdir 'packages' unless File.dir?('packages')
1016
1134
  @selected.each do |pack|
1017
- $stderr.puts "Processing the package `#{pack}' ..." if @options['verbose']
1135
+ $stderr.puts "Processing the package `#{pack}' ..." if verbose?
1018
1136
  Dir.mkdir "packages/#{pack}" unless File.dir?("packages/#{pack}")
1019
1137
  Dir.chdir "packages/#{pack}"
1020
1138
  yield @installers[pack]
@@ -1022,28 +1140,32 @@ class ToplevelInstallerMulti < ToplevelInstaller
1022
1140
  end
1023
1141
  end
1024
1142
 
1143
+ def run_hook(id)
1144
+ @root_installer.run_hook id
1145
+ end
1146
+
1147
+ # module FileOperations requires this
1025
1148
  def verbose?
1026
- @options['verbose']
1149
+ @config.verbose?
1027
1150
  end
1028
1151
 
1152
+ # module FileOperations requires this
1029
1153
  def no_harm?
1030
- @options['no-harm']
1154
+ @config.no_harm?
1031
1155
  end
1032
1156
 
1033
- end
1157
+ end # class ToplevelInstallerMulti
1034
1158
 
1035
1159
 
1036
1160
  class Installer
1037
1161
 
1038
- FILETYPES = %w( bin lib ext data )
1162
+ FILETYPES = %w( bin lib ext data conf man )
1039
1163
 
1040
- include HookScriptAPI
1041
- include HookUtils
1042
1164
  include FileOperations
1165
+ include HookScriptAPI
1043
1166
 
1044
- def initialize(config, opt, srcroot, objroot)
1167
+ def initialize(config, srcroot, objroot)
1045
1168
  @config = config
1046
- @options = opt
1047
1169
  @srcdir = File.expand_path(srcroot)
1048
1170
  @objdir = File.expand_path(objroot)
1049
1171
  @currdir = '.'
@@ -1070,23 +1192,25 @@ class Installer
1070
1192
  end
1071
1193
 
1072
1194
  #
1073
- # configs/options
1195
+ # Config Access
1074
1196
  #
1075
1197
 
1076
- def no_harm?
1077
- @options['no-harm']
1198
+ # module FileOperations requires this
1199
+ def verbose?
1200
+ @config.verbose?
1078
1201
  end
1079
1202
 
1080
- def verbose?
1081
- @options['verbose']
1203
+ # module FileOperations requires this
1204
+ def no_harm?
1205
+ @config.no_harm?
1082
1206
  end
1083
1207
 
1084
1208
  def verbose_off
1085
1209
  begin
1086
- save, @options['verbose'] = @options['verbose'], false
1210
+ save, @config.verbose = @config.verbose?, false
1087
1211
  yield
1088
1212
  ensure
1089
- @options['verbose'] = save
1213
+ @config.verbose = save
1090
1214
  end
1091
1215
  end
1092
1216
 
@@ -1104,18 +1228,23 @@ class Installer
1104
1228
  def config_dir_lib(rel)
1105
1229
  end
1106
1230
 
1231
+ def config_dir_man(rel)
1232
+ end
1233
+
1107
1234
  def config_dir_ext(rel)
1108
1235
  extconf if extdir?(curr_srcdir())
1109
1236
  end
1110
1237
 
1111
1238
  def extconf
1112
- opt = @options['config-opt'].join(' ')
1113
- command "#{config('rubyprog')} #{curr_srcdir()}/extconf.rb #{opt}"
1239
+ ruby "#{curr_srcdir()}/extconf.rb", *@config.config_opt
1114
1240
  end
1115
1241
 
1116
1242
  def config_dir_data(rel)
1117
1243
  end
1118
1244
 
1245
+ def config_dir_conf(rel)
1246
+ end
1247
+
1119
1248
  #
1120
1249
  # TASK setup
1121
1250
  #
@@ -1125,7 +1254,7 @@ class Installer
1125
1254
  end
1126
1255
 
1127
1256
  def setup_dir_bin(rel)
1128
- all_files_in(curr_srcdir()).each do |fname|
1257
+ files_of(curr_srcdir()).each do |fname|
1129
1258
  adjust_shebang "#{curr_srcdir()}/#{fname}"
1130
1259
  end
1131
1260
  end
@@ -1136,15 +1265,14 @@ class Installer
1136
1265
  begin
1137
1266
  File.open(path, 'rb') {|r|
1138
1267
  first = r.gets
1139
- return unless File.basename(config('rubypath')) == 'ruby'
1140
- return unless File.basename(first.sub(/\A\#!/, '').split[0]) == 'ruby'
1268
+ return unless File.basename(first.sub(/\A\#!/, '').split[0].to_s) == 'ruby'
1141
1269
  $stderr.puts "adjusting shebang: #{File.basename(path)}" if verbose?
1142
1270
  File.open(tmpfile, 'wb') {|w|
1143
1271
  w.print first.sub(/\A\#!\s*\S+/, '#! ' + config('rubypath'))
1144
1272
  w.write r.read
1145
1273
  }
1146
- move_file tmpfile, File.basename(path)
1147
1274
  }
1275
+ move_file tmpfile, File.basename(path)
1148
1276
  ensure
1149
1277
  File.unlink tmpfile if File.exist?(tmpfile)
1150
1278
  end
@@ -1153,6 +1281,9 @@ class Installer
1153
1281
  def setup_dir_lib(rel)
1154
1282
  end
1155
1283
 
1284
+ def setup_dir_man(rel)
1285
+ end
1286
+
1156
1287
  def setup_dir_ext(rel)
1157
1288
  make if extdir?(curr_srcdir())
1158
1289
  end
@@ -1160,6 +1291,9 @@ class Installer
1160
1291
  def setup_dir_data(rel)
1161
1292
  end
1162
1293
 
1294
+ def setup_dir_conf(rel)
1295
+ end
1296
+
1163
1297
  #
1164
1298
  # TASK install
1165
1299
  #
@@ -1170,63 +1304,77 @@ class Installer
1170
1304
  end
1171
1305
 
1172
1306
  def install_dir_bin(rel)
1173
- install_files collect_filenames_auto(), "#{config('bindir')}/#{rel}", 0755
1307
+ install_files targetfiles(), "#{config('bindir')}/#{rel}", 0755
1174
1308
  end
1175
1309
 
1176
1310
  def install_dir_lib(rel)
1177
- install_files ruby_scripts(), "#{config('rbdir')}/#{rel}", 0644
1311
+ install_files rubyscripts(), "#{config('rbdir')}/#{rel}", 0644
1178
1312
  end
1179
1313
 
1180
1314
  def install_dir_ext(rel)
1181
1315
  return unless extdir?(curr_srcdir())
1182
- install_files ruby_extentions('.'),
1316
+ install_files rubyextentions('.'),
1183
1317
  "#{config('sodir')}/#{File.dirname(rel)}",
1184
1318
  0555
1185
1319
  end
1186
1320
 
1187
1321
  def install_dir_data(rel)
1188
- install_files collect_filenames_auto(), "#{config('datadir')}/#{rel}", 0644
1322
+ install_files targetfiles(), "#{config('datadir')}/#{rel}", 0644
1323
+ end
1324
+
1325
+ def install_dir_conf(rel)
1326
+ # FIXME: should not remove current config files
1327
+ # (rename previous file to .old/.org)
1328
+ install_files targetfiles(), "#{config('sysconfdir')}/#{rel}", 0644
1329
+ end
1330
+
1331
+ def install_dir_man(rel)
1332
+ install_files targetfiles(), "#{config('mandir')}/#{rel}", 0644
1189
1333
  end
1190
1334
 
1191
1335
  def install_files(list, dest, mode)
1192
- mkdir_p dest, @options['install-prefix']
1336
+ mkdir_p dest, @config.install_prefix
1193
1337
  list.each do |fname|
1194
- install fname, dest, mode, @options['install-prefix']
1338
+ install fname, dest, mode, @config.install_prefix
1195
1339
  end
1196
1340
  end
1197
1341
 
1198
- def ruby_scripts
1199
- collect_filenames_auto().select {|n| /\.rb\z/ =~ n }
1342
+ def rubyscripts
1343
+ glob_select(@config.libsrc_pattern, targetfiles())
1200
1344
  end
1201
-
1345
+
1346
+ def rubyextentions(dir)
1347
+ ents = glob_select("*.#{@config.dllext}", targetfiles())
1348
+ if ents.empty?
1349
+ setup_rb_error "no ruby extention exists: 'ruby #{$0} setup' first"
1350
+ end
1351
+ ents
1352
+ end
1353
+
1354
+ def targetfiles
1355
+ mapdir(existfiles() - hookfiles())
1356
+ end
1357
+
1358
+ def mapdir(ents)
1359
+ ents.map {|ent|
1360
+ if File.exist?(ent)
1361
+ then ent # objdir
1362
+ else "#{curr_srcdir()}/#{ent}" # srcdir
1363
+ end
1364
+ }
1365
+ end
1366
+
1202
1367
  # picked up many entries from cvs-1.11.1/src/ignore.c
1203
- reject_patterns = %w(
1368
+ JUNK_FILES = %w(
1204
1369
  core RCSLOG tags TAGS .make.state
1205
1370
  .nse_depinfo #* .#* cvslog.* ,* .del-* *.olb
1206
1371
  *~ *.old *.bak *.BAK *.orig *.rej _$* *$
1207
1372
 
1208
1373
  *.org *.in .*
1209
1374
  )
1210
- mapping = {
1211
- '.' => '\.',
1212
- '$' => '\$',
1213
- '#' => '\#',
1214
- '*' => '.*'
1215
- }
1216
- REJECT_PATTERNS = Regexp.new('\A(?:' +
1217
- reject_patterns.map {|pat|
1218
- pat.gsub(/[\.\$\#\*]/) {|ch| mapping[ch] }
1219
- }.join('|') +
1220
- ')\z')
1221
-
1222
- def collect_filenames_auto
1223
- mapdir((existfiles() - hookfiles()).reject {|fname|
1224
- REJECT_PATTERNS =~ fname
1225
- })
1226
- end
1227
1375
 
1228
1376
  def existfiles
1229
- all_files_in(curr_srcdir()) | all_files_in('.')
1377
+ glob_reject(JUNK_FILES, (files_of(curr_srcdir()) | files_of('.')))
1230
1378
  end
1231
1379
 
1232
1380
  def hookfiles
@@ -1235,24 +1383,45 @@ class Installer
1235
1383
  }.flatten
1236
1384
  end
1237
1385
 
1238
- def mapdir(filelist)
1239
- filelist.map {|fname|
1240
- if File.exist?(fname) # objdir
1241
- fname
1242
- else # srcdir
1243
- File.join(curr_srcdir(), fname)
1244
- end
1245
- }
1386
+ def glob_select(pat, ents)
1387
+ re = globs2re([pat])
1388
+ ents.select {|ent| re =~ ent }
1246
1389
  end
1247
1390
 
1248
- def ruby_extentions(dir)
1249
- Dir.open(dir) {|d|
1250
- ents = d.select {|fname| /\.#{::Config::CONFIG['DLEXT']}\z/ =~ fname }
1251
- if ents.empty?
1252
- setup_rb_error "no ruby extention exists: 'ruby #{$0} setup' first"
1253
- end
1254
- return ents
1255
- }
1391
+ def glob_reject(pats, ents)
1392
+ re = globs2re(pats)
1393
+ ents.reject {|ent| re =~ ent }
1394
+ end
1395
+
1396
+ GLOB2REGEX = {
1397
+ '.' => '\.',
1398
+ '$' => '\$',
1399
+ '#' => '\#',
1400
+ '*' => '.*'
1401
+ }
1402
+
1403
+ def globs2re(pats)
1404
+ /\A(?:#{
1405
+ pats.map {|pat| pat.gsub(/[\.\$\#\*]/) {|ch| GLOB2REGEX[ch] } }.join('|')
1406
+ })\z/
1407
+ end
1408
+
1409
+ #
1410
+ # TASK test
1411
+ #
1412
+
1413
+ TESTDIR = 'test'
1414
+
1415
+ def exec_test
1416
+ unless File.directory?('test')
1417
+ $stderr.puts 'no test in this package' if verbose?
1418
+ return
1419
+ end
1420
+ $stderr.puts 'Running tests...' if verbose?
1421
+ require 'test/unit'
1422
+ runner = Test::Unit::AutoRunner.new(true)
1423
+ runner.to_run << TESTDIR
1424
+ runner.run
1256
1425
  end
1257
1426
 
1258
1427
  #
@@ -1261,7 +1430,7 @@ class Installer
1261
1430
 
1262
1431
  def exec_clean
1263
1432
  exec_task_traverse 'clean'
1264
- rm_f ConfigTable.savefile
1433
+ rm_f @config.savefile
1265
1434
  rm_f 'InstalledFiles'
1266
1435
  end
1267
1436
 
@@ -1279,13 +1448,16 @@ class Installer
1279
1448
  def clean_dir_data(rel)
1280
1449
  end
1281
1450
 
1451
+ def clean_dir_conf(rel)
1452
+ end
1453
+
1282
1454
  #
1283
1455
  # TASK distclean
1284
1456
  #
1285
1457
 
1286
1458
  def exec_distclean
1287
1459
  exec_task_traverse 'distclean'
1288
- rm_f ConfigTable.savefile
1460
+ rm_f @config.savefile
1289
1461
  rm_f 'InstalledFiles'
1290
1462
  end
1291
1463
 
@@ -1300,6 +1472,12 @@ class Installer
1300
1472
  make 'distclean' if File.file?('Makefile')
1301
1473
  end
1302
1474
 
1475
+ def distclean_dir_data(rel)
1476
+ end
1477
+
1478
+ def distclean_dir_conf(rel)
1479
+ end
1480
+
1303
1481
  #
1304
1482
  # lib
1305
1483
  #
@@ -1320,7 +1498,7 @@ class Installer
1320
1498
  dive_into(rel) {
1321
1499
  run_hook "pre-#{task}"
1322
1500
  __send__ mid, rel.sub(%r[\A.*?(?:/|\z)], '')
1323
- all_dirs_in(curr_srcdir()).each do |d|
1501
+ directories_of(curr_srcdir()).each do |d|
1324
1502
  traverse task, "#{rel}/#{d}", mid
1325
1503
  end
1326
1504
  run_hook "post-#{task}"
@@ -1342,16 +1520,30 @@ class Installer
1342
1520
  @currdir = File.dirname(rel)
1343
1521
  end
1344
1522
 
1345
- end
1523
+ def run_hook(id)
1524
+ path = [ "#{curr_srcdir()}/#{id}",
1525
+ "#{curr_srcdir()}/#{id}.rb" ].detect {|cand| File.file?(cand) }
1526
+ return unless path
1527
+ begin
1528
+ instance_eval File.read(path), path, 1
1529
+ rescue
1530
+ raise if $DEBUG
1531
+ setup_rb_error "hook #{path} failed:\n" + $!.message
1532
+ end
1533
+ end
1534
+
1535
+ end # class Installer
1346
1536
 
1347
1537
 
1538
+ class SetupError < StandardError; end
1539
+
1540
+ def setup_rb_error(msg)
1541
+ raise SetupError, msg
1542
+ end
1543
+
1348
1544
  if $0 == __FILE__
1349
1545
  begin
1350
- if multipackage_install?
1351
- ToplevelInstallerMulti.invoke
1352
- else
1353
- ToplevelInstaller.invoke
1354
- end
1546
+ ToplevelInstaller.invoke
1355
1547
  rescue SetupError
1356
1548
  raise if $DEBUG
1357
1549
  $stderr.puts $!.message