reap 5.10.10 → 6.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (224) hide show
  1. data/COPYING +400 -8
  2. data/README +136 -75
  3. data/bin/reap +2 -2
  4. data/bin/rubytest +5 -0
  5. data/data/reap/scaffold/standard/COPYING +403 -0
  6. data/data/reap/scaffold/{ChangeLog → standard/ChangeLog} +0 -0
  7. data/data/reap/scaffold/standard/INSTALL +14 -0
  8. data/data/reap/scaffold/{ProjectInfo → standard/ProjectInfo} +23 -24
  9. data/data/reap/scaffold/standard/README +3 -0
  10. data/data/reap/scaffold/standard/Rakefile +10 -0
  11. data/{Rakefile → data/reap/scaffold/standard/TODO} +0 -0
  12. data/data/reap/scaffold/{setup.rb → standard/setup.rb} +287 -270
  13. data/data/reap/scaffold/subversion/trunk/COPYING +403 -0
  14. data/data/reap/scaffold/{INSTALL → subversion/trunk/ChangeLog} +0 -0
  15. data/data/reap/scaffold/subversion/trunk/INSTALL +14 -0
  16. data/data/reap/scaffold/subversion/trunk/ProjectInfo +76 -0
  17. data/data/reap/scaffold/subversion/trunk/README +3 -0
  18. data/data/reap/scaffold/subversion/trunk/Rakefile +10 -0
  19. data/data/reap/scaffold/{README → subversion/trunk/TODO} +0 -0
  20. data/data/reap/scaffold/subversion/trunk/setup.rb +1568 -0
  21. data/data/reap/setup.rb +1568 -0
  22. data/lib/reap/bin/reap.rb +176 -80
  23. data/lib/reap/bin/rubytest.rb +53 -0
  24. data/lib/reap/class/announce.rb +220 -0
  25. data/lib/reap/class/doap.rb +80 -0
  26. data/lib/reap/class/extest.rb +151 -0
  27. data/lib/reap/class/filer.rb +62 -0
  28. data/lib/reap/class/installer.rb +178 -0
  29. data/lib/reap/class/manifest.rb +72 -0
  30. data/lib/reap/class/package.rb +468 -0
  31. data/lib/reap/class/publish.rb +152 -0
  32. data/lib/reap/class/rdoc.rb +131 -0
  33. data/lib/reap/class/test.rb +269 -0
  34. data/lib/reap/projectinfo.rb +187 -30
  35. data/lib/reap/rake.rb +42 -0
  36. data/lib/reap/reap.rb +89 -0
  37. data/lib/reap/tasks.rb +672 -11
  38. data/lib/reap/taskutils.rb +122 -0
  39. data/sample/ProjectInfo +96 -0
  40. data/sample/Rakefile +9 -0
  41. data/sample/Reapfile +11 -0
  42. data/sample/task/demo.rb +15 -0
  43. data/setup.rb +287 -272
  44. metadata +99 -257
  45. data/ANN +0 -3
  46. data/ChangeLog +0 -25
  47. data/ProjectInfo +0 -65
  48. data/data/reap/scaffold/COPYING +0 -11
  49. data/data/reap/scaffold/Rakefile +0 -146
  50. data/data/reap/scaffold/Todo +0 -0
  51. data/dev/Rakefile +0 -60
  52. data/dev/composite_task.rb +0 -27
  53. data/dev/compositepublisher.rb +0 -24
  54. data/dev/ftptools.rb +0 -139
  55. data/dev/license-each.rb +0 -85
  56. data/dev/publisher.rb +0 -75
  57. data/dev/rubyforgepublisher.rb +0 -18
  58. data/dev/sshpublisher.rb +0 -47
  59. data/dev/suby-cvs.rb +0 -46
  60. data/dev/template.rb +0 -72
  61. data/lib/reap/lint.rb +0 -0
  62. data/lib/reap/readymade.rb +0 -21
  63. data/lib/reap/task.rb +0 -187
  64. data/lib/reap/task/announce.rb +0 -156
  65. data/lib/reap/task/fileperm.rb +0 -82
  66. data/lib/reap/task/info.rb +0 -20
  67. data/lib/reap/task/install.rb +0 -33
  68. data/lib/reap/task/noop.rb +0 -26
  69. data/lib/reap/task/package.rb +0 -204
  70. data/lib/reap/task/publish.rb +0 -49
  71. data/lib/reap/task/rdoc.rb +0 -82
  72. data/lib/reap/task/scaffold.rb +0 -114
  73. data/lib/reap/task/test.rb +0 -186
  74. data/lib/reap/task/testext.rb +0 -110
  75. data/lib/reap/task/webpublish.rb +0 -43
  76. data/lib/reap/test.rb +0 -138
  77. data/test/tc_reap.rb +0 -11
  78. data/web/ProjectInfo +0 -57
  79. data/web/images/appleboy.jpg +0 -0
  80. data/web/images/grape.jpg +0 -0
  81. data/web/index.html +0 -124
  82. data/web/rdoc/classes/Object.html +0 -121
  83. data/web/rdoc/classes/ProjectInfo.html +0 -207
  84. data/web/rdoc/classes/ProjectInfo.src/M000094.html +0 -18
  85. data/web/rdoc/classes/ProjectInfo.src/M000095.html +0 -24
  86. data/web/rdoc/classes/ProjectInfo.src/M000096.html +0 -22
  87. data/web/rdoc/classes/ProjectInfo.src/M000097.html +0 -21
  88. data/web/rdoc/classes/ProjectInfo.src/M000098.html +0 -18
  89. data/web/rdoc/classes/Reap.html +0 -248
  90. data/web/rdoc/classes/Reap.src/M000023.html +0 -16
  91. data/web/rdoc/classes/Reap.src/M000024.html +0 -21
  92. data/web/rdoc/classes/Reap.src/M000025.html +0 -16
  93. data/web/rdoc/classes/Reap.src/M000026.html +0 -21
  94. data/web/rdoc/classes/Reap/Announce.html +0 -262
  95. data/web/rdoc/classes/Reap/Announce.src/M000030.html +0 -18
  96. data/web/rdoc/classes/Reap/Announce.src/M000031.html +0 -114
  97. data/web/rdoc/classes/Reap/Announce.src/M000032.html +0 -46
  98. data/web/rdoc/classes/Reap/Info.html +0 -176
  99. data/web/rdoc/classes/Reap/Info.src/M000033.html +0 -18
  100. data/web/rdoc/classes/Reap/Info.src/M000034.html +0 -17
  101. data/web/rdoc/classes/Reap/Info.src/M000035.html +0 -18
  102. data/web/rdoc/classes/Reap/Install.html +0 -193
  103. data/web/rdoc/classes/Reap/Install.src/M000036.html +0 -18
  104. data/web/rdoc/classes/Reap/Install.src/M000037.html +0 -20
  105. data/web/rdoc/classes/Reap/Install.src/M000038.html +0 -26
  106. data/web/rdoc/classes/Reap/Noop.html +0 -192
  107. data/web/rdoc/classes/Reap/Noop.src/M000027.html +0 -18
  108. data/web/rdoc/classes/Reap/Noop.src/M000028.html +0 -17
  109. data/web/rdoc/classes/Reap/Noop.src/M000029.html +0 -18
  110. data/web/rdoc/classes/Reap/Package.html +0 -310
  111. data/web/rdoc/classes/Reap/Package.src/M000055.html +0 -18
  112. data/web/rdoc/classes/Reap/Package.src/M000056.html +0 -68
  113. data/web/rdoc/classes/Reap/Package.src/M000057.html +0 -84
  114. data/web/rdoc/classes/Reap/Package.src/M000058.html +0 -61
  115. data/web/rdoc/classes/Reap/Perm.html +0 -236
  116. data/web/rdoc/classes/Reap/Perm.src/M000078.html +0 -18
  117. data/web/rdoc/classes/Reap/Perm.src/M000079.html +0 -21
  118. data/web/rdoc/classes/Reap/Perm.src/M000080.html +0 -42
  119. data/web/rdoc/classes/Reap/Perm.src/M000081.html +0 -26
  120. data/web/rdoc/classes/Reap/Perm.src/M000082.html +0 -18
  121. data/web/rdoc/classes/Reap/Publish.html +0 -213
  122. data/web/rdoc/classes/Reap/Publish.src/M000070.html +0 -18
  123. data/web/rdoc/classes/Reap/Publish.src/M000071.html +0 -22
  124. data/web/rdoc/classes/Reap/Publish.src/M000072.html +0 -37
  125. data/web/rdoc/classes/Reap/RDoc.html +0 -218
  126. data/web/rdoc/classes/Reap/RDoc.src/M000059.html +0 -18
  127. data/web/rdoc/classes/Reap/RDoc.src/M000060.html +0 -24
  128. data/web/rdoc/classes/Reap/RDoc.src/M000061.html +0 -70
  129. data/web/rdoc/classes/Reap/Task.html +0 -396
  130. data/web/rdoc/classes/Reap/Task.src/M000039.html +0 -18
  131. data/web/rdoc/classes/Reap/Task.src/M000040.html +0 -16
  132. data/web/rdoc/classes/Reap/Task.src/M000041.html +0 -16
  133. data/web/rdoc/classes/Reap/Task.src/M000042.html +0 -16
  134. data/web/rdoc/classes/Reap/Task.src/M000043.html +0 -16
  135. data/web/rdoc/classes/Reap/Task.src/M000044.html +0 -22
  136. data/web/rdoc/classes/Reap/Task.src/M000045.html +0 -16
  137. data/web/rdoc/classes/Reap/Task.src/M000046.html +0 -16
  138. data/web/rdoc/classes/Reap/Task.src/M000047.html +0 -16
  139. data/web/rdoc/classes/Reap/Task.src/M000048.html +0 -16
  140. data/web/rdoc/classes/Reap/Task.src/M000049.html +0 -16
  141. data/web/rdoc/classes/Reap/Task.src/M000050.html +0 -27
  142. data/web/rdoc/classes/Reap/Task.src/M000051.html +0 -19
  143. data/web/rdoc/classes/Reap/Task.src/M000052.html +0 -18
  144. data/web/rdoc/classes/Reap/Task.src/M000053.html +0 -18
  145. data/web/rdoc/classes/Reap/Task.src/M000054.html +0 -19
  146. data/web/rdoc/classes/Reap/Test.html +0 -253
  147. data/web/rdoc/classes/Reap/Test.src/M000062.html +0 -18
  148. data/web/rdoc/classes/Reap/Test.src/M000063.html +0 -26
  149. data/web/rdoc/classes/Reap/Test.src/M000064.html +0 -77
  150. data/web/rdoc/classes/Reap/Test.src/M000065.html +0 -27
  151. data/web/rdoc/classes/Reap/Test.src/M000066.html +0 -50
  152. data/web/rdoc/classes/Reap/Test/TestResults.html +0 -205
  153. data/web/rdoc/classes/Reap/Test/TestResults.src/M000067.html +0 -21
  154. data/web/rdoc/classes/Reap/Test/TestResults.src/M000068.html +0 -21
  155. data/web/rdoc/classes/Reap/Test/TestResults.src/M000069.html +0 -23
  156. data/web/rdoc/classes/Reap/TestExt.html +0 -234
  157. data/web/rdoc/classes/Reap/TestExt.src/M000073.html +0 -18
  158. data/web/rdoc/classes/Reap/TestExt.src/M000074.html +0 -20
  159. data/web/rdoc/classes/Reap/TestExt.src/M000075.html +0 -49
  160. data/web/rdoc/classes/Reap/TestExt.src/M000076.html +0 -34
  161. data/web/rdoc/classes/Reap/TestExt.src/M000077.html +0 -27
  162. data/web/rdoc/classes/Reap/WebPublish.html +0 -213
  163. data/web/rdoc/classes/Reap/WebPublish.src/M000083.html +0 -18
  164. data/web/rdoc/classes/Reap/WebPublish.src/M000084.html +0 -21
  165. data/web/rdoc/classes/Reap/WebPublish.src/M000085.html +0 -32
  166. data/web/rdoc/classes/ReapCommand.html +0 -425
  167. data/web/rdoc/classes/ReapCommand.src/M000001.html +0 -16
  168. data/web/rdoc/classes/ReapCommand.src/M000003.html +0 -16
  169. data/web/rdoc/classes/ReapCommand.src/M000005.html +0 -16
  170. data/web/rdoc/classes/ReapCommand.src/M000007.html +0 -16
  171. data/web/rdoc/classes/ReapCommand.src/M000009.html +0 -16
  172. data/web/rdoc/classes/ReapCommand.src/M000011.html +0 -16
  173. data/web/rdoc/classes/ReapCommand.src/M000013.html +0 -18
  174. data/web/rdoc/classes/ReapCommand.src/M000014.html +0 -19
  175. data/web/rdoc/classes/ReapCommand.src/M000015.html +0 -19
  176. data/web/rdoc/classes/ReapCommand.src/M000016.html +0 -24
  177. data/web/rdoc/classes/ReapCommand.src/M000018.html +0 -29
  178. data/web/rdoc/classes/Scaffold.html +0 -211
  179. data/web/rdoc/classes/Scaffold.src/M000086.html +0 -16
  180. data/web/rdoc/classes/Scaffold.src/M000087.html +0 -28
  181. data/web/rdoc/classes/Scaffold.src/M000088.html +0 -32
  182. data/web/rdoc/classes/Scaffold.src/M000089.html +0 -18
  183. data/web/rdoc/classes/UnitTestKernel.html +0 -176
  184. data/web/rdoc/classes/UnitTestKernel.src/M000019.html +0 -18
  185. data/web/rdoc/classes/UnitTestKernel.src/M000020.html +0 -18
  186. data/web/rdoc/classes/UnitTestKernel.src/M000021.html +0 -22
  187. data/web/rdoc/classes/UnitTestKernel.src/M000022.html +0 -22
  188. data/web/rdoc/classes/UnitTesting.html +0 -165
  189. data/web/rdoc/classes/UnitTesting.src/M000090.html +0 -34
  190. data/web/rdoc/classes/UnitTesting.src/M000091.html +0 -18
  191. data/web/rdoc/classes/UnitTesting/Failure.html +0 -156
  192. data/web/rdoc/classes/UnitTesting/Failure.src/M000092.html +0 -18
  193. data/web/rdoc/classes/UnitTesting/Failure.src/M000093.html +0 -21
  194. data/web/rdoc/created.rid +0 -1
  195. data/web/rdoc/files/ANN.html +0 -107
  196. data/web/rdoc/files/COPYING.html +0 -119
  197. data/web/rdoc/files/ChangeLog.html +0 -144
  198. data/web/rdoc/files/ProjectInfo.html +0 -190
  199. data/web/rdoc/files/README.html +0 -274
  200. data/web/rdoc/files/Rakefile.html +0 -101
  201. data/web/rdoc/files/lib/reap/bin/reap_rb.html +0 -129
  202. data/web/rdoc/files/lib/reap/lint_rb.html +0 -101
  203. data/web/rdoc/files/lib/reap/projectinfo_rb.html +0 -110
  204. data/web/rdoc/files/lib/reap/readymade_rb.html +0 -123
  205. data/web/rdoc/files/lib/reap/task/announce_rb.html +0 -114
  206. data/web/rdoc/files/lib/reap/task/fileperm_rb.html +0 -108
  207. data/web/rdoc/files/lib/reap/task/info_rb.html +0 -108
  208. data/web/rdoc/files/lib/reap/task/install_rb.html +0 -108
  209. data/web/rdoc/files/lib/reap/task/noop_rb.html +0 -108
  210. data/web/rdoc/files/lib/reap/task/package_rb.html +0 -109
  211. data/web/rdoc/files/lib/reap/task/publish_rb.html +0 -108
  212. data/web/rdoc/files/lib/reap/task/rdoc_rb.html +0 -108
  213. data/web/rdoc/files/lib/reap/task/scaffold_rb.html +0 -107
  214. data/web/rdoc/files/lib/reap/task/test_rb.html +0 -110
  215. data/web/rdoc/files/lib/reap/task/testext_rb.html +0 -109
  216. data/web/rdoc/files/lib/reap/task/webpublish_rb.html +0 -108
  217. data/web/rdoc/files/lib/reap/task_rb.html +0 -120
  218. data/web/rdoc/files/lib/reap/tasks_rb.html +0 -116
  219. data/web/rdoc/files/lib/reap/test_rb.html +0 -109
  220. data/web/rdoc/fr_class_index.html +0 -47
  221. data/web/rdoc/fr_file_index.html +0 -51
  222. data/web/rdoc/fr_method_index.html +0 -124
  223. data/web/rdoc/index.html +0 -24
  224. data/web/rdoc/rdoc-style.css +0 -208
@@ -0,0 +1,122 @@
1
+ require 'fileutils'
2
+
3
+ # Extensions to time to allow comparisons
4
+ # with an early time class. This was borrowed from Rake.
5
+ # --
6
+ # TODO Ultimately this might be able to be replaced
7
+ # by -Infinity (see Infinity class in development folder).
8
+ #++
9
+
10
+ class Time
11
+ require 'singleton'
12
+
13
+ # EarlyTime is a fake timestamp that occurs _before_
14
+ # any other time value.
15
+ class Earlier
16
+ include Comparable
17
+ include Singleton
18
+
19
+ def <=>(other)
20
+ -1
21
+ end
22
+
23
+ def to_s
24
+ "<EARLY TIME>"
25
+ end
26
+ end
27
+
28
+ EARLY = Earlier.instance
29
+
30
+ alias_method :rake_original_time_compare, :<=>
31
+
32
+ def <=>(other)
33
+ if Earlier === other
34
+ - other.<=>(self)
35
+ else
36
+ rake_original_time_compare(other)
37
+ end
38
+ end
39
+ end
40
+
41
+ # Reap module holds the TaskUtils.
42
+
43
+ module Reap
44
+
45
+ # Support module for task development.
46
+
47
+ module TaskUtils
48
+
49
+ # Useful for populating a class.
50
+ # Maybe this should have a different name --perhaps
51
+ # just use Facets #set_with.
52
+
53
+ def initialize( data={} )
54
+ data.each do |k,v|
55
+ send( "#{k}=", v ) if respond_to?("#{k}=")
56
+ end
57
+ end
58
+
59
+ # OpenCascade interface to teh ProjectInfo file.
60
+
61
+ def master
62
+ @taskutils_master ||= ProjectInfo.instance.to_opencascade
63
+ end
64
+
65
+ # If +name+ is a hash this will split the name => preq parameter
66
+ # into [name, preq], otherwise it just return +name+.
67
+ # Teh hash is expected to have only one element.
68
+
69
+ def preq_from_name( name )
70
+ if Hash === name
71
+ #a = [name.keys, name.values].flatten
72
+ return *(name.to_a.flatten)
73
+ else
74
+ name
75
+ end
76
+ end
77
+
78
+ # Output and then shellout a command. Doesn't actually
79
+ # shellout if $PRETEND is set.
80
+
81
+ def sh( arg )
82
+ tell arg
83
+ system arg unless $PRETEND
84
+ end
85
+
86
+ # Convenience method for puts. Using this instead of
87
+ # puts may help beautify or redirect output in
88
+ # future versions.
89
+
90
+ def tell( statement )
91
+ puts statement
92
+ end
93
+
94
+ # Conveniene method to get simple console reply.
95
+
96
+ def ask( question, answers=nil )
97
+ print "#{question}"
98
+ print " [#{answers}] " if answers
99
+ until inp = $stdin.gets[0,1] ; sleep 1 ; end ; puts
100
+ inp
101
+ end
102
+
103
+ # Makes sure there is a setup.rb file in the
104
+ # project directory.
105
+
106
+ def provide_setup_rb( trunk='.' )
107
+ setup_rb_file = File.join( trunk, 'setup.rb' )
108
+ return true if File.exists?( setup_rb_file )
109
+ if dir = Gem.gempath('reap')
110
+ src = File.join( dir, 'data', 'reap', 'setup.rb' )
111
+ else
112
+ src = File.join( Config::CONFIG['datadir'], 'reap', 'setup.rb' )
113
+ end
114
+ if File.exists?( src )
115
+ FileUtils.cp( src, trunk )
116
+ true
117
+ end
118
+ end
119
+
120
+ end
121
+
122
+ end
@@ -0,0 +1,96 @@
1
+ --- %YAML:1.0
2
+
3
+ version : 1.0.0
4
+ status : 'beta'
5
+
6
+ title : Reap-Sample
7
+ name : reap
8
+ author : Thomas Sawyer
9
+ created : '2006-06-01'
10
+ email : &email transfire@gmail.com
11
+ homepage : "http://reap.rubyforge.org"
12
+
13
+ summary : The Flexible Ruby Project Management Assistant
14
+
15
+ description: >
16
+ Reap comprises a set of tasks commonly needed by Ruby package
17
+ developers/deployers, such as testing, packaging, releasing, etc.
18
+ You can also use Reap to create your own custom tasks.
19
+ Reap utilizes a YAML configuration file to harvest common project
20
+ information, significantly simplifying these chores.
21
+
22
+ rubyforge:
23
+ project : reap
24
+ username : transami
25
+
26
+ #install: !!installer
27
+ # template: |
28
+ # bin bin * .
29
+ # lib lib/reap **/* $name/$version
30
+
31
+ #package: !!package
32
+ # distribute : [ tar.bz2, gem ]
33
+ # dependencies : [ facets ]
34
+ # executables : [ reap, rubytest ]
35
+ # dir: release
36
+ # exclude:
37
+ # - dist
38
+ # - web
39
+ # - doc/dev
40
+ # - doc/scrap
41
+
42
+ #release: !!release
43
+ # host : rubyforge.org
44
+ # username : transami
45
+ # project : reap
46
+ # groupid : 811
47
+ # package : Reap
48
+ # dir : release
49
+
50
+ #publish: !!publish
51
+ # target : rubyforge
52
+ # type : web
53
+ # host : rubyforge.org
54
+ # username : transami
55
+ # dir : web
56
+
57
+ #rdoc: !!rdoc
58
+ # dir: 'web/doc/api'
59
+ # main: README
60
+
61
+ ann: !!announce
62
+ to : transfire@gmail.com # ruby-talk@ruby-lang.org
63
+ from : *email
64
+ domain : unit.rubyforge.org
65
+ server : smtp.gmail.com
66
+ port : 587
67
+ account : *email # transfire@gmail.com
68
+ type : login # cram_md5, plain
69
+ security : tls # ~, tls, ssl (not working yet)
70
+ #file : notes/LATEST # which file contains announcement
71
+ memo :
72
+ Congragulations! You've given Reap a try! Go ahead and
73
+ announce it the world!
74
+ slogan : REAP THE REWARDS!
75
+ links : []
76
+
77
+ doap: !!doap
78
+
79
+ loc: !!linecount
80
+ include: '*'
81
+
82
+ # perm: !!perm
83
+ # filemod: 644
84
+ # dirmod: 755
85
+ # user: trans
86
+ # group: users
87
+
88
+ demo: !!demo
89
+ desc: Give a task an alternate description.
90
+ message: Hello Baby!
91
+
92
+ # mytask: !!custom
93
+ # desc: This is a test of a cutom task.
94
+ # task:
95
+ # puts "Hello Moto!"
96
+
@@ -0,0 +1,9 @@
1
+ require 'reap/rake'
2
+
3
+ desc "I call it what I will"
4
+
5
+ info :info
6
+
7
+ demo( :d2 ) do |t|
8
+ t.message = "Hey There!"
9
+ end
@@ -0,0 +1,11 @@
1
+
2
+ desc "I call it what I will"
3
+
4
+ demo :d2 do |t|
5
+ t.message = "Hey There!"
6
+ end
7
+
8
+ file 'notes/doap.xml' => 'ProjectInfo' do
9
+ puts "not a thing"
10
+ end
11
+
@@ -0,0 +1,15 @@
1
+
2
+ module Tasks
3
+
4
+ def demo( name, &data )
5
+
6
+ desc "Demonstrate a custom task" unless desc
7
+
8
+ task name do
9
+ data = data.to_openobject
10
+ puts data.message
11
+ end
12
+
13
+ end
14
+
15
+ end
data/setup.rb CHANGED
@@ -1,5 +1,3 @@
1
- #!/usr/bin/env ruby
2
-
3
1
  #
4
2
  # setup.rb
5
3
  #
@@ -10,21 +8,50 @@
10
8
  # the GNU LGPL, Lesser General Public License version 2.1.
11
9
  #
12
10
 
13
- unless Enumerable.method_defined?(:map) # Ruby 1.4.6
14
- module Enumerable
15
- alias map collect
16
- end
11
+ #############################
12
+ # Forked from version 3.2.1 #
13
+ # #
14
+ # -trans #
15
+ #############################
16
+
17
+ # CHANGE No longer need to support 1.4.6 or 1.6 versions of Ruby.
18
+
19
+ # unless Enumerable.method_defined?(:map) # Ruby 1.4.6
20
+ # module Enumerable
21
+ # alias map collect
22
+ # end
23
+ # end
24
+
25
+ # unless File.respond_to?(:read) # Ruby 1.6
26
+ # def File.read(fname)
27
+ # open(fname) {|f|
28
+ # return f.read
29
+ # }
30
+ # end
31
+ # end
32
+
33
+ # This is hack!
34
+ # This is needed to install within an abitrary root dir.
35
+ # B/c setup.rb has become spegetti code, I was forced to do this hack.
36
+ # Setup.rb shuld be re-writ. I would use package.rb instead but
37
+ # it lacks hooks and extension compilation. But we'll keep
38
+ # an eye on that one for the future. -trans.
39
+
40
+ $setup_install_root = nil
41
+ ARGV.each{ |a|
42
+ if md = /--root=(.*)/.match( a )
43
+ $setup_install_root = md[1]
44
+ end
45
+ }
46
+ if $setup_install_root
47
+ ARGV.delete("--root=#{$setup_install_root}")
48
+ $setup_install_root = File.expand_path($setup_install_root)
49
+ puts "(root=#{$setup_install_root})"
17
50
  end
18
51
 
19
- unless File.respond_to?(:read) # Ruby 1.6
20
- def File.read(fname)
21
- open(fname) {|f|
22
- return f.read
23
- }
24
- end
25
- end
52
+ # Windows?
26
53
 
27
- unless Errno.const_defined?(:ENOTEMPTY) # Windows?
54
+ unless Errno.const_defined?(:ENOTEMPTY)
28
55
  module Errno
29
56
  class ENOTEMPTY
30
57
  # We do not raise this exception, implementation is not needed.
@@ -57,25 +84,16 @@ class ConfigTable
57
84
  @config_opt = nil
58
85
  @verbose = true
59
86
  @no_harm = false
60
- @libsrc_pattern = '*.rb'
61
87
  end
62
88
 
63
89
  attr_accessor :install_prefix
64
90
  attr_accessor :config_opt
65
91
 
66
- attr_writer :verbose
67
-
68
- def verbose?
69
- @verbose
70
- end
71
-
72
- attr_writer :no_harm
73
-
74
- def no_harm?
75
- @no_harm
76
- end
92
+ def verbose=(x) @verbose = x end
93
+ def verbose?() @verbose end
77
94
 
78
- attr_accessor :libsrc_pattern
95
+ def no_harm=(x) @no_harm = x end
96
+ def no_harm?() @no_harm end
79
97
 
80
98
  def [](key)
81
99
  lookup(key).resolve(self)
@@ -119,9 +137,7 @@ class ConfigTable
119
137
  end
120
138
  end
121
139
 
122
- def savefile
123
- '.config'
124
- end
140
+ def savefile() '.config' end
125
141
 
126
142
  def load_savefile
127
143
  begin
@@ -144,124 +160,126 @@ class ConfigTable
144
160
  end
145
161
 
146
162
  def load_standard_entries
147
- standard_entries(@rbconfig).each do |ent|
163
+ #standard_entries(@rbconfig).each do |ent|
164
+ standard_entries.each do |ent|
148
165
  add ent
149
166
  end
150
167
  end
151
168
 
152
- def standard_entries(rbconfig)
153
- c = rbconfig
169
+ def standard_entries #(rbconfig)
170
+ rbconfig = @rbconfig
154
171
 
155
- rubypath = c['bindir'] + '/' + c['ruby_install_name']
172
+ rubypath = File.join(rbconfig['bindir'], rbconfig['ruby_install_name'] + rbconfig['EXEEXT'])
156
173
 
157
- major = c['MAJOR'].to_i
158
- minor = c['MINOR'].to_i
159
- teeny = c['TEENY'].to_i
174
+ major = rbconfig['MAJOR'].to_i
175
+ minor = rbconfig['MINOR'].to_i
176
+ teeny = rbconfig['TEENY'].to_i
160
177
  version = "#{major}.#{minor}"
161
178
 
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)))))
179
+ # CHANGE Do not need to support these old versions any more.
180
+
181
+ # # ruby ver. >= 1.4.4?
182
+ # newpath_p = ((major >= 2) or
183
+ # ((major == 1) and
184
+ # ((minor >= 5) or
185
+ # ((minor == 4) and (teeny >= 4)))))
167
186
 
168
- if c['rubylibdir']
187
+ #if c['rubylibdir']
169
188
  # 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
189
+
190
+ root = '/'
191
+ prefix = rbconfig['prefix']
192
+
193
+ libruby = "#{prefix}/lib/ruby"
194
+ librubyver = rbconfig['rubylibdir']
195
+ librubyverarch = rbconfig['archdir']
196
+ siteruby = rbconfig['sitedir']
197
+ siterubyver = rbconfig['sitelibdir']
198
+ siterubyverarch = rbconfig['sitearchdir']
199
+
200
+ bindir = paramize(rbconfig['bindir'])
201
+ libdir = paramize(rbconfig['libdir'])
202
+ datadir = paramize(rbconfig['datadir'])
203
+ mandir = paramize(rbconfig['mandir'])
204
+ sysconfdir = paramize(rbconfig['sysconfdir'])
205
+ localstatedir = paramize(rbconfig['localstatedir'])
206
+
207
+ # elsif newpath_p
208
+ # # 1.4.4 <= V <= 1.6.3
209
+ # libruby = "#{c['prefix']}/lib/ruby"
210
+ # librubyver = "#{c['prefix']}/lib/ruby/#{version}"
211
+ # librubyverarch = "#{c['prefix']}/lib/ruby/#{version}/#{c['arch']}"
212
+ # siteruby = c['sitedir']
213
+ # siterubyver = "$siteruby/#{version}"
214
+ # siterubyverarch = "$siterubyver/#{c['arch']}"
215
+ # else
216
+ # # V < 1.4.4
217
+ # libruby = "#{c['prefix']}/lib/ruby"
218
+ # librubyver = "#{c['prefix']}/lib/ruby/#{version}"
219
+ # librubyverarch = "#{c['prefix']}/lib/ruby/#{version}/#{c['arch']}"
220
+ # siteruby = "#{c['prefix']}/lib/ruby/#{version}/site_ruby"
221
+ # siterubyver = siteruby
222
+ # siterubyverarch = "$siterubyver/#{c['arch']}"
223
+ # end
224
+
193
225
  parameterize = lambda {|path|
194
- path.sub(/\A#{Regexp.quote(c['prefix'])}/, '$prefix')
226
+ path.sub(/\A#{Regexp.quote(rbconfig['prefix'])}/, '$prefix')
195
227
  }
196
228
 
197
- if arg = c['configure_args'].split.detect {|arg| /--with-make-prog=/ =~ arg }
229
+ if arg = rbconfig['configure_args'].split.detect {|arg| /--with-make-prog=/ =~ arg }
198
230
  makeprog = arg.sub(/'/, '').split(/=/, 2)[1]
199
231
  else
200
232
  makeprog = 'make'
201
233
  end
202
234
 
235
+ installdir_lambda = lambda {|val, table|
236
+ case val
237
+ when 'std'
238
+ table['rbdir'] = '$librubyver'
239
+ table['sodir'] = '$librubyverarch'
240
+ when 'site'
241
+ table['rbdir'] = '$siterubyver'
242
+ table['sodir'] = '$siterubyverarch'
243
+ when 'home'
244
+ setup_rb_error '$HOME was not set' unless ENV['HOME']
245
+ table['prefix'] = ENV['HOME']
246
+ table['rbdir'] = '$libdir/ruby'
247
+ table['sodir'] = '$libdir/ruby'
248
+ end
249
+ }
250
+
203
251
  [
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')
252
+ ExecItem.new('installdirs', 'std/site/home', 'install under libruby, site_ruby or $HOME respectively', &installdir_lambda),
253
+ PathItem.new('root', 'path', root, 'root destination directory'),
254
+ PathItem.new('prefix', 'path', prefix, 'path prefix of target environment'),
255
+ PathItem.new('bindir', 'path', bindir, 'the directory for commands'),
256
+ PathItem.new('libdir', 'path', libdir, 'the directory for libraries'),
257
+ PathItem.new('datadir', 'path', datadir, 'the directory for shared data'),
258
+ PathItem.new('mandir', 'path', mandir, 'the directory for man pages'),
259
+ PathItem.new('sysconfdir', 'path', sysconfdir, 'the directory for system configuration files'),
260
+ PathItem.new('localstatedir', 'path', localstatedir, 'the directory for local state data'),
261
+ PathItem.new('libruby', 'path', libruby, 'the directory for ruby libraries'),
262
+ PathItem.new('librubyver', 'path', librubyver, 'the directory for standard ruby libraries'),
263
+ PathItem.new('librubyverarch', 'path', librubyverarch, 'the directory for standard ruby extensions'),
264
+ PathItem.new('siteruby', 'path', siteruby, 'the directory for version-independent aux ruby libraries'),
265
+ PathItem.new('siterubyver', 'path', siterubyver, 'the directory for aux ruby libraries'),
266
+ PathItem.new('siterubyverarch', 'path', siterubyverarch, 'the directory for aux ruby binaries'),
267
+ PathItem.new('rbdir', 'path', '$siterubyver', 'the directory for ruby scripts'),
268
+ PathItem.new('sodir', 'path', '$siterubyverarch', 'the directory for ruby extentions'),
269
+ PathItem.new('rubypath', 'path', rubypath, 'the path to set to #! line'),
270
+ ProgramItem.new('rubyprog', 'name', rubypath, 'the ruby program using for installation'),
271
+ ProgramItem.new('makeprog', 'name', makeprog, 'the make program to compile ruby extentions'),
272
+ SelectItem.new('shebang', 'all/ruby/never', 'ruby', 'shebang line (#!) editing mode'),
273
+ BoolItem.new('without-ext', 'yes/no', 'no', 'does not compile/install ruby extentions')
261
274
  ]
262
275
  end
263
276
  private :standard_entries
264
277
 
278
+ def paramize( path )
279
+ path.sub(/\A#{Regexp.quote(@rbconfig['prefix'])}/, '$prefix')
280
+ end
281
+ private :paramize
282
+
265
283
  def load_multipackage_entries
266
284
  multipackage_entries().each do |ent|
267
285
  add ent
@@ -270,10 +288,8 @@ class ConfigTable
270
288
 
271
289
  def multipackage_entries
272
290
  [
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')
291
+ PackageSelectionItem.new('with', 'name,name...', '', 'ALL', 'package names that you want to install'),
292
+ PackageSelectionItem.new('without', 'name,name...', '', 'NONE', 'package names that you do not want to install')
277
293
  ]
278
294
  end
279
295
  private :multipackage_entries
@@ -338,13 +354,8 @@ class ConfigTable
338
354
  "--#{@name}=#{@template}"
339
355
  end
340
356
 
341
- def value?
342
- true
343
- end
344
-
345
- def value
346
- @value
347
- end
357
+ def value? ; true ; end
358
+ def value ; @value ; end
348
359
 
349
360
  def resolve(table)
350
361
  @value.gsub(%r<\$([^/]+)>) { table[$1] }
@@ -363,9 +374,7 @@ class ConfigTable
363
374
  end
364
375
 
365
376
  class BoolItem < Item
366
- def config_type
367
- 'bool'
368
- end
377
+ def config_type() 'bool' end
369
378
 
370
379
  def help_opt
371
380
  "--#{@name}"
@@ -375,20 +384,19 @@ class ConfigTable
375
384
 
376
385
  def check(val)
377
386
  return 'yes' unless val
378
- unless /\A(y(es)?|n(o)?|t(rue)?|f(alse))\z/i =~ val
387
+ case val
388
+ when /\Ay(es)?\z/i, /\At(rue)?\z/i then 'yes'
389
+ when /\An(o)?\z/i, /\Af(alse)\z/i then 'no'
390
+ else
379
391
  setup_rb_error "config: --#{@name} accepts only yes/no for argument"
380
392
  end
381
- (/\Ay(es)?|\At(rue)/i =~ value) ? 'yes' : 'no'
382
393
  end
383
394
  end
384
395
 
385
396
  class PathItem < Item
386
- def config_type
387
- 'path'
388
- end
397
+ def config_type() 'path' end
389
398
 
390
399
  private
391
-
392
400
  def check(path)
393
401
  setup_rb_error "config: --#{@name} requires argument" unless path
394
402
  path[0,1] == '$' ? path : File.expand_path(path)
@@ -396,9 +404,7 @@ class ConfigTable
396
404
  end
397
405
 
398
406
  class ProgramItem < Item
399
- def config_type
400
- 'program'
401
- end
407
+ def config_type() 'program' end
402
408
  end
403
409
 
404
410
  class SelectItem < Item
@@ -407,12 +413,9 @@ class ConfigTable
407
413
  @ok = selection.split('/')
408
414
  end
409
415
 
410
- def config_type
411
- 'select'
412
- end
416
+ def config_type() 'select' end
413
417
 
414
418
  private
415
-
416
419
  def check(val)
417
420
  unless @ok.include?(val.strip)
418
421
  setup_rb_error "config: use --#{@name}=#{@template} (#{val})"
@@ -474,7 +477,7 @@ class ConfigTable
474
477
  end
475
478
 
476
479
  class MetaConfigEnvironment
477
- def intiailize(config, installer)
480
+ def initialize(config, installer)
478
481
  @config = config
479
482
  @installer = installer
480
483
  end
@@ -539,7 +542,9 @@ end # class ConfigTable
539
542
  module FileOperations
540
543
 
541
544
  def mkdir_p(dirname, prefix = nil)
542
- dirname = prefix + File.expand_path(dirname) if prefix
545
+ dirname = File.join(prefix, File.expand_path(dirname)) if prefix
546
+ dirname = File.join( $setup_install_root, dirname ) if $setup_install_root
547
+
543
548
  $stderr.puts "mkdir -p #{dirname}" if verbose?
544
549
  return if no_harm?
545
550
 
@@ -623,11 +628,15 @@ module FileOperations
623
628
  end
624
629
 
625
630
  def install(from, dest, mode, prefix = nil)
631
+
632
+ realdest = prefix ? File.join(prefix, File.expand_path(dest)) : dest
633
+ realdest = File.join($setup_install_root, File.expand_path(realdest)) if $setup_install_root
634
+
626
635
  $stderr.puts "install #{from} #{dest}" if verbose?
627
636
  return if no_harm?
628
637
 
629
- realdest = prefix ? prefix + File.expand_path(dest) : dest
630
638
  realdest = File.join(realdest, File.basename(from)) if File.dir?(realdest)
639
+
631
640
  str = File.binread(from)
632
641
  if diff?(str, realdest)
633
642
  verbose_off {
@@ -638,6 +647,10 @@ module FileOperations
638
647
  }
639
648
  File.chmod mode, realdest
640
649
 
650
+ # Do not make InstalledFiles entry if to alternate root.
651
+ # This prevents problem with root permissions on this file.
652
+ return true unless $setup_install_root
653
+
641
654
  File.open("#{objdir_root()}/InstalledFiles", 'a') {|f|
642
655
  if prefix
643
656
  f.puts realdest.sub(prefix, '')
@@ -662,7 +675,7 @@ module FileOperations
662
675
  def ruby(*args)
663
676
  command config('rubyprog'), *args
664
677
  end
665
-
678
+
666
679
  def make(task = nil)
667
680
  command(*[config('makeprog'), task].compact)
668
681
  end
@@ -702,33 +715,14 @@ module HookScriptAPI
702
715
  @config[key] = val
703
716
  end
704
717
 
705
- #
706
718
  # srcdir/objdir (works only in the package directory)
707
- #
708
719
 
709
- def curr_srcdir
710
- "#{srcdir_root()}/#{relpath()}"
711
- end
712
-
713
- def curr_objdir
714
- "#{objdir_root()}/#{relpath()}"
715
- end
716
-
717
- def srcfile(path)
718
- "#{curr_srcdir()}/#{path}"
719
- end
720
-
721
- def srcexist?(path)
722
- File.exist?(srcfile(path))
723
- end
724
-
725
- def srcdirectory?(path)
726
- File.dir?(srcfile(path))
727
- end
728
-
729
- def srcfile?(path)
730
- File.file?(srcfile(path))
731
- end
720
+ def curr_srcdir() "#{srcdir_root()}/#{relpath()}" end
721
+ def curr_objdir() "#{objdir_root()}/#{relpath()}" end
722
+ def srcfile(path) "#{curr_srcdir()}/#{path}" end
723
+ def srcexist?(path) File.exist?(srcfile(path)) end
724
+ def srcdirectory?(path) File.dir?(srcfile(path)) end
725
+ def srcfile?(path) File.file?(srcfile(path)) end
732
726
 
733
727
  def srcentries(path = '.')
734
728
  Dir.open("#{curr_srcdir()}/#{path}") {|d|
@@ -753,7 +747,7 @@ end
753
747
 
754
748
  class ToplevelInstaller
755
749
 
756
- Version = '3.4.0'
750
+ Version = '3.4.1'
757
751
  Copyright = 'Copyright (c) 2000-2005 Minero Aoki'
758
752
 
759
753
  TASKS = [
@@ -767,8 +761,8 @@ class ToplevelInstaller
767
761
  [ 'distclean',"does `make distclean' for each extention" ]
768
762
  ]
769
763
 
770
- def ToplevelInstaller.invoke
771
- config = ConfigTable.new(load_rbconfig())
764
+ def self.invoke
765
+ config = ConfigTable.new(load_rbconfig)
772
766
  config.load_standard_entries
773
767
  config.load_multipackage_entries if multipackage?
774
768
  config.fixup
@@ -776,11 +770,11 @@ class ToplevelInstaller
776
770
  klass.new(File.dirname($0), config).invoke
777
771
  end
778
772
 
779
- def ToplevelInstaller.multipackage?
773
+ def self.multipackage?
780
774
  File.dir?(File.dirname($0) + '/packages')
781
775
  end
782
776
 
783
- def ToplevelInstaller.load_rbconfig
777
+ def self.load_rbconfig
784
778
  if arg = ARGV.detect {|arg| /\A--rbconfig=/ =~ arg }
785
779
  ARGV.delete(arg)
786
780
  load File.expand_path(arg.split(/=/, 2)[1])
@@ -791,6 +785,7 @@ class ToplevelInstaller
791
785
  ::Config::CONFIG
792
786
  end
793
787
 
788
+
794
789
  def initialize(ardir_root, config)
795
790
  @ardir = File.expand_path(ardir_root)
796
791
  @config = config
@@ -829,7 +824,7 @@ class ToplevelInstaller
829
824
  __send__ "exec_#{task}"
830
825
  end
831
826
  end
832
-
827
+
833
828
  def run_metaconfigs
834
829
  @config.load_script "#{@ardir}/metaconfig"
835
830
  end
@@ -842,17 +837,9 @@ class ToplevelInstaller
842
837
  # Hook Script API bases
843
838
  #
844
839
 
845
- def srcdir_root
846
- @ardir
847
- end
848
-
849
- def objdir_root
850
- '.'
851
- end
852
-
853
- def relpath
854
- '.'
855
- end
840
+ def srcdir_root() @ardir end
841
+ def objdir_root() '.' end
842
+ def relpath() '.' end
856
843
 
857
844
  #
858
845
  # Option Parsing
@@ -894,6 +881,7 @@ class ToplevelInstaller
894
881
 
895
882
  def parsearg_no_options
896
883
  unless ARGV.empty?
884
+ task = caller(0).first.slice(%r<`parsearg_(\w+)'>, 1)
897
885
  setup_rb_error "#{task}: unknown options: #{ARGV.join(' ')}"
898
886
  end
899
887
  end
@@ -981,6 +969,7 @@ class ToplevelInstaller
981
969
  out.puts
982
970
  out.puts 'Options for INSTALL:'
983
971
  out.printf fmt, '--no-harm', 'only display what to do if given', 'off'
972
+ out.printf fmt, '--root=path', 'install root directory (effects all paths)', '/'
984
973
  out.printf fmt, '--prefix=path', 'install path prefix', ''
985
974
  out.puts
986
975
  end
@@ -1175,21 +1164,15 @@ class Installer
1175
1164
  "#<#{self.class} #{File.basename(@srcdir)}>"
1176
1165
  end
1177
1166
 
1167
+ def noop(rel) ; end
1168
+
1178
1169
  #
1179
1170
  # Hook Script API base methods
1180
1171
  #
1181
1172
 
1182
- def srcdir_root
1183
- @srcdir
1184
- end
1185
-
1186
- def objdir_root
1187
- @objdir
1188
- end
1189
-
1190
- def relpath
1191
- @currdir
1192
- end
1173
+ def srcdir_root() @srcdir end
1174
+ def objdir_root() @objdir end
1175
+ def relpath() @currdir end
1193
1176
 
1194
1177
  #
1195
1178
  # Config Access
@@ -1222,29 +1205,21 @@ class Installer
1222
1205
  exec_task_traverse 'config'
1223
1206
  end
1224
1207
 
1225
- def config_dir_bin(rel)
1226
- end
1227
-
1228
- def config_dir_lib(rel)
1229
- end
1230
-
1231
- def config_dir_man(rel)
1232
- end
1208
+ alias config_dir_bin noop
1209
+ alias config_dir_lib noop
1233
1210
 
1234
1211
  def config_dir_ext(rel)
1235
1212
  extconf if extdir?(curr_srcdir())
1236
1213
  end
1237
1214
 
1215
+ alias config_dir_data noop
1216
+ alias config_dir_conf noop
1217
+ alias config_dir_man noop
1218
+
1238
1219
  def extconf
1239
1220
  ruby "#{curr_srcdir()}/extconf.rb", *@config.config_opt
1240
1221
  end
1241
1222
 
1242
- def config_dir_data(rel)
1243
- end
1244
-
1245
- def config_dir_conf(rel)
1246
- end
1247
-
1248
1223
  #
1249
1224
  # TASK setup
1250
1225
  #
@@ -1255,43 +1230,89 @@ class Installer
1255
1230
 
1256
1231
  def setup_dir_bin(rel)
1257
1232
  files_of(curr_srcdir()).each do |fname|
1258
- adjust_shebang "#{curr_srcdir()}/#{fname}"
1233
+ update_shebang_line "#{curr_srcdir()}/#{fname}"
1259
1234
  end
1260
1235
  end
1261
1236
 
1262
- def adjust_shebang(path)
1237
+ alias setup_dir_lib noop
1238
+
1239
+ def setup_dir_ext(rel)
1240
+ make if extdir?(curr_srcdir())
1241
+ end
1242
+
1243
+ alias setup_dir_data noop
1244
+ alias setup_dir_conf noop
1245
+ alias setup_dir_man noop
1246
+
1247
+ def update_shebang_line(path)
1263
1248
  return if no_harm?
1249
+ return if config('shebang') == 'never'
1250
+ old = Shebang.load(path)
1251
+ if old
1252
+ $stderr.puts "warning: #{path}: Shebang line includes too many args. It is not portable and your program may not work." if old.args.size > 1
1253
+ new = new_shebang(old)
1254
+ return if new.to_s == old.to_s
1255
+ else
1256
+ return unless config('shebang') == 'all'
1257
+ new = Shebang.new(config('rubypath'))
1258
+ end
1259
+ $stderr.puts "updating shebang: #{File.basename(path)}" if verbose?
1260
+ open_atomic_writer(path) {|output|
1261
+ File.open(path, 'rb') {|f|
1262
+ f.gets if old # discard
1263
+ output.puts new.to_s
1264
+ output.print f.read
1265
+ }
1266
+ }
1267
+ end
1268
+
1269
+ def new_shebang(old)
1270
+ if /\Aruby/ =~ File.basename(old.cmd)
1271
+ Shebang.new(config('rubypath'), old.args)
1272
+ elsif File.basename(old.cmd) == 'env' and old.args.first == 'ruby'
1273
+ Shebang.new(config('rubypath'), old.args[1..-1])
1274
+ else
1275
+ return old unless config('shebang') == 'all'
1276
+ Shebang.new(config('rubypath'))
1277
+ end
1278
+ end
1279
+
1280
+ def open_atomic_writer(path, &block)
1264
1281
  tmpfile = File.basename(path) + '.tmp'
1265
1282
  begin
1266
- File.open(path, 'rb') {|r|
1267
- first = r.gets
1268
- return unless File.basename(first.sub(/\A\#!/, '').split[0].to_s) == 'ruby'
1269
- $stderr.puts "adjusting shebang: #{File.basename(path)}" if verbose?
1270
- File.open(tmpfile, 'wb') {|w|
1271
- w.print first.sub(/\A\#!\s*\S+/, '#! ' + config('rubypath'))
1272
- w.write r.read
1273
- }
1274
- }
1275
- move_file tmpfile, File.basename(path)
1283
+ File.open(tmpfile, 'wb', &block)
1284
+ File.rename tmpfile, File.basename(path)
1276
1285
  ensure
1277
1286
  File.unlink tmpfile if File.exist?(tmpfile)
1278
1287
  end
1279
1288
  end
1280
1289
 
1281
- def setup_dir_lib(rel)
1282
- end
1290
+ class Shebang
1291
+ def Shebang.load(path)
1292
+ line = nil
1293
+ File.open(path) {|f|
1294
+ line = f.gets
1295
+ }
1296
+ return nil unless /\A#!/ =~ line
1297
+ parse(line)
1298
+ end
1283
1299
 
1284
- def setup_dir_man(rel)
1285
- end
1300
+ def Shebang.parse(line)
1301
+ cmd, *args = *line.strip.sub(/\A\#!/, '').split(' ')
1302
+ new(cmd, args)
1303
+ end
1286
1304
 
1287
- def setup_dir_ext(rel)
1288
- make if extdir?(curr_srcdir())
1289
- end
1305
+ def initialize(cmd, args = [])
1306
+ @cmd = cmd
1307
+ @args = args
1308
+ end
1290
1309
 
1291
- def setup_dir_data(rel)
1292
- end
1310
+ attr_reader :cmd
1311
+ attr_reader :args
1293
1312
 
1294
- def setup_dir_conf(rel)
1313
+ def to_s
1314
+ "#! #{@cmd}" + (@args.empty? ? '' : " #{@args.join(' ')}")
1315
+ end
1295
1316
  end
1296
1317
 
1297
1318
  #
@@ -1308,7 +1329,7 @@ class Installer
1308
1329
  end
1309
1330
 
1310
1331
  def install_dir_lib(rel)
1311
- install_files rubyscripts(), "#{config('rbdir')}/#{rel}", 0644
1332
+ install_files libfiles(), "#{config('rbdir')}/#{rel}", 0644
1312
1333
  end
1313
1334
 
1314
1335
  def install_dir_ext(rel)
@@ -1334,13 +1355,14 @@ class Installer
1334
1355
 
1335
1356
  def install_files(list, dest, mode)
1336
1357
  mkdir_p dest, @config.install_prefix
1358
+ #mkdir_p dest, offset_dir
1337
1359
  list.each do |fname|
1338
1360
  install fname, dest, mode, @config.install_prefix
1339
1361
  end
1340
1362
  end
1341
1363
 
1342
- def rubyscripts
1343
- glob_select(@config.libsrc_pattern, targetfiles())
1364
+ def libfiles
1365
+ glob_reject(%w(*.y *.output), targetfiles())
1344
1366
  end
1345
1367
 
1346
1368
  def rubyextentions(dir)
@@ -1418,7 +1440,11 @@ class Installer
1418
1440
  return
1419
1441
  end
1420
1442
  $stderr.puts 'Running tests...' if verbose?
1421
- require 'test/unit'
1443
+ begin
1444
+ require 'test/unit'
1445
+ rescue LoadError
1446
+ setup_rb_error 'test/unit cannot loaded. You need Ruby 1.8 or later to invoke this task.'
1447
+ end
1422
1448
  runner = Test::Unit::AutoRunner.new(true)
1423
1449
  runner.to_run << TESTDIR
1424
1450
  runner.run
@@ -1434,23 +1460,17 @@ class Installer
1434
1460
  rm_f 'InstalledFiles'
1435
1461
  end
1436
1462
 
1437
- def clean_dir_bin(rel)
1438
- end
1439
-
1440
- def clean_dir_lib(rel)
1441
- end
1463
+ alias clean_dir_bin noop
1464
+ alias clean_dir_lib noop
1465
+ alias clean_dir_data noop
1466
+ alias clean_dir_conf noop
1467
+ alias clean_dir_man noop
1442
1468
 
1443
1469
  def clean_dir_ext(rel)
1444
1470
  return unless extdir?(curr_srcdir())
1445
1471
  make 'clean' if File.file?('Makefile')
1446
1472
  end
1447
1473
 
1448
- def clean_dir_data(rel)
1449
- end
1450
-
1451
- def clean_dir_conf(rel)
1452
- end
1453
-
1454
1474
  #
1455
1475
  # TASK distclean
1456
1476
  #
@@ -1461,31 +1481,26 @@ class Installer
1461
1481
  rm_f 'InstalledFiles'
1462
1482
  end
1463
1483
 
1464
- def distclean_dir_bin(rel)
1465
- end
1466
-
1467
- def distclean_dir_lib(rel)
1468
- end
1484
+ alias distclean_dir_bin noop
1485
+ alias distclean_dir_lib noop
1469
1486
 
1470
1487
  def distclean_dir_ext(rel)
1471
1488
  return unless extdir?(curr_srcdir())
1472
1489
  make 'distclean' if File.file?('Makefile')
1473
1490
  end
1474
1491
 
1475
- def distclean_dir_data(rel)
1476
- end
1477
-
1478
- def distclean_dir_conf(rel)
1479
- end
1492
+ alias distclean_dir_data noop
1493
+ alias distclean_dir_conf noop
1494
+ alias distclean_dir_man noop
1480
1495
 
1481
1496
  #
1482
- # lib
1497
+ # Traversing
1483
1498
  #
1484
1499
 
1485
1500
  def exec_task_traverse(task)
1486
1501
  run_hook "pre-#{task}"
1487
1502
  FILETYPES.each do |type|
1488
- if config('without-ext') == 'yes' and type == 'ext'
1503
+ if type == 'ext' and config('without-ext') == 'yes'
1489
1504
  $stderr.puts 'skipping ext/* by user option' if verbose?
1490
1505
  next
1491
1506
  end