reap 6.0.2 → 9.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (174) hide show
  1. data/CHANGES +6 -0
  2. data/COPYING +666 -395
  3. data/MANIFEST +139 -0
  4. data/NOTES +12 -0
  5. data/README +19 -163
  6. data/bin/reap-announce +7 -0
  7. data/bin/reap-check-load +8 -0
  8. data/bin/reap-check-syntax +7 -0
  9. data/bin/reap-clean +7 -0
  10. data/bin/reap-clobber +7 -0
  11. data/bin/reap-doc +7 -0
  12. data/bin/reap-doc-rdoc +7 -0
  13. data/bin/reap-doc-ri +7 -0
  14. data/bin/reap-init +69 -0
  15. data/bin/reap-inspect +7 -0
  16. data/bin/reap-install +8 -0
  17. data/bin/reap-install-gem +8 -0
  18. data/bin/reap-log +7 -0
  19. data/bin/reap-log-changes +8 -0
  20. data/bin/reap-log-notes +8 -0
  21. data/bin/reap-make +7 -0
  22. data/bin/reap-make-clean +7 -0
  23. data/bin/reap-make-distclean +7 -0
  24. data/bin/reap-make-extconf +7 -0
  25. data/bin/reap-make-static +8 -0
  26. data/bin/reap-package +8 -0
  27. data/bin/reap-package-gem +7 -0
  28. data/bin/reap-package-tgz +7 -0
  29. data/bin/reap-package-zip +7 -0
  30. data/bin/reap-prepare +7 -0
  31. data/bin/reap-publish +7 -0
  32. data/bin/reap-release +7 -0
  33. data/bin/reap-scaffold +8 -0
  34. data/bin/reap-scm-branch +7 -0
  35. data/bin/reap-scm-tag +7 -0
  36. data/bin/reap-spec +7 -0
  37. data/bin/reap-spec-doc +8 -0
  38. data/bin/reap-stamp +7 -0
  39. data/bin/reap-stats +7 -0
  40. data/bin/reap-test +7 -0
  41. data/bin/reap-test-cross +7 -0
  42. data/bin/reap-test-load +9 -0
  43. data/bin/reap-test-solo +7 -0
  44. data/bin/reap-uninstall +7 -0
  45. data/bin/reap-uninstall-gem +7 -0
  46. data/data/reap/base/CHANGES +19 -0
  47. data/data/reap/base/COPYING +674 -0
  48. data/data/reap/base/NOTES +12 -0
  49. data/data/reap/base/README +8 -0
  50. data/data/reap/build/rake/Rakefile +130 -0
  51. data/{forge/reference/installers → data/reap/build/rake}/setup.rb +155 -97
  52. data/data/reap/build/rake-lite/install.rb +79 -0
  53. data/data/reap/build/tasks/task/rdoc +211 -0
  54. data/data/reap/{setup.rb → build/tasks/task/setup} +248 -200
  55. data/data/reap/build/tasks/task/test +38 -0
  56. data/data/reap/init/meta/project.yaml +21 -0
  57. data/demo/README +15 -0
  58. data/demo/lib/foo/foo.rb +7 -0
  59. data/demo/meta/VERSION +1 -0
  60. data/demo/meta/project.yaml +21 -0
  61. data/lib/reap/application.rb +80 -0
  62. data/lib/reap/default.yaml +77 -0
  63. data/lib/reap/extensions/array.rb +50 -0
  64. data/lib/reap/extensions/hash.rb +63 -0
  65. data/lib/reap/extensions/string.rb +31 -0
  66. data/lib/reap/extensions.rb +6 -0
  67. data/lib/reap/iobject.rb +264 -0
  68. data/lib/reap/manager/announce.rb +193 -0
  69. data/lib/reap/manager/check.rb +109 -0
  70. data/lib/reap/manager/clean.rb +58 -0
  71. data/lib/reap/manager/gem.rb +200 -0
  72. data/lib/reap/manager/html.rb +69 -0
  73. data/lib/reap/manager/log.rb +214 -0
  74. data/lib/reap/manager/make.rb +109 -0
  75. data/lib/reap/manager/pack.rb +232 -0
  76. data/lib/reap/manager/publish.rb +72 -0
  77. data/lib/reap/manager/rdoc.rb +194 -0
  78. data/lib/reap/manager/release.rb +78 -0
  79. data/lib/reap/manager/rubyforge.rb +44 -0
  80. data/lib/reap/manager/scaffold.rb +138 -0
  81. data/lib/reap/manager/scm.rb +66 -0
  82. data/lib/reap/manager/site.rb +27 -0
  83. data/lib/reap/manager/spec.rb +94 -0
  84. data/lib/reap/manager/stats.rb +145 -0
  85. data/lib/reap/manager/svn.rb +76 -0
  86. data/lib/reap/manager/test.rb +389 -0
  87. data/lib/reap/manager.rb +74 -0
  88. data/lib/reap/metadata.rb +603 -0
  89. data/lib/reap/project.rb +165 -0
  90. data/lib/reap/settings.rb +67 -0
  91. data/lib/reap/systems/rubyforge.rb +737 -0
  92. data/lib/reap/systems/subversion.rb +333 -0
  93. data/lib/reap/utilities/fileutils.rb +304 -0
  94. data/lib/reap/utilities/netutils.rb +221 -0
  95. data/lib/reap/utilities/setuputils.rb +124 -0
  96. data/lib/reap/utilities/shellutils.rb +175 -0
  97. data/log/Changelog.txt +107 -0
  98. data/log/FIXME.txt +25 -0
  99. data/log/TODO.txt +72 -0
  100. data/meta/VERSION +1 -0
  101. data/meta/description +4 -0
  102. data/meta/project.yaml +20 -0
  103. data/task/man +14 -0
  104. data/task/rdoc +20 -0
  105. data/{data/reap/scaffold/standard/setup.rb → task/setup} +248 -200
  106. metadata +225 -153
  107. data/ProjectInfo +0 -105
  108. data/bin/reap +0 -5
  109. data/bin/rubytest +0 -5
  110. data/data/reap/install.rb +0 -62
  111. data/data/reap/scaffold/standard/COPYING +0 -403
  112. data/data/reap/scaffold/standard/ChangeLog +0 -0
  113. data/data/reap/scaffold/standard/INSTALL +0 -14
  114. data/data/reap/scaffold/standard/ProjectInfo +0 -77
  115. data/data/reap/scaffold/standard/README +0 -3
  116. data/data/reap/scaffold/standard/Rakefile +0 -10
  117. data/data/reap/scaffold/standard/TODO +0 -0
  118. data/data/reap/scaffold/subversion/trunk/COPYING +0 -403
  119. data/data/reap/scaffold/subversion/trunk/ChangeLog +0 -0
  120. data/data/reap/scaffold/subversion/trunk/INSTALL +0 -14
  121. data/data/reap/scaffold/subversion/trunk/ProjectInfo +0 -76
  122. data/data/reap/scaffold/subversion/trunk/README +0 -3
  123. data/data/reap/scaffold/subversion/trunk/Rakefile +0 -10
  124. data/data/reap/scaffold/subversion/trunk/TODO +0 -0
  125. data/data/reap/scaffold/subversion/trunk/setup.rb +0 -1568
  126. data/forge/ProjectInfo +0 -38
  127. data/forge/ProjectInfo.rb +0 -76
  128. data/forge/TODO +0 -10
  129. data/forge/installer.rb +0 -250
  130. data/forge/reference/Rakefile +0 -124
  131. data/forge/reference/Rakefile.htm +0 -69
  132. data/forge/reference/aRakefile +0 -60
  133. data/forge/reference/compositepublisher.rb +0 -24
  134. data/forge/reference/ftptools.rb +0 -139
  135. data/forge/reference/installers/package.rb +0 -629
  136. data/forge/reference/license-each.rb +0 -85
  137. data/forge/reference/publisher.rb +0 -75
  138. data/forge/reference/rubyforge.rb +0 -247
  139. data/forge/reference/rubyforgepublisher.rb +0 -18
  140. data/forge/reference/sshpublisher.rb +0 -47
  141. data/forge/reference/suby-cvs.rb +0 -46
  142. data/forge/scaffold.rb +0 -126
  143. data/forge/unit_runner/README +0 -6
  144. data/forge/unit_runner/commentrunner.rb +0 -62
  145. data/forge/unit_runner/cunit.rb +0 -17
  146. data/forge/unit_runner/forkedrunner.rb +0 -91
  147. data/forge/unit_runner/sample.rb +0 -16
  148. data/lib/reap/bin/reap.rb +0 -230
  149. data/lib/reap/bin/rubytest.rb +0 -53
  150. data/lib/reap/class/announce.rb +0 -220
  151. data/lib/reap/class/doap.rb +0 -80
  152. data/lib/reap/class/extest.rb +0 -146
  153. data/lib/reap/class/filer.rb +0 -62
  154. data/lib/reap/class/manifest.rb +0 -68
  155. data/lib/reap/class/package.rb +0 -576
  156. data/lib/reap/class/publish.rb +0 -152
  157. data/lib/reap/class/rdoc.rb +0 -123
  158. data/lib/reap/class/test.rb +0 -264
  159. data/lib/reap/projectinfo.rb +0 -208
  160. data/lib/reap/rake.rb +0 -42
  161. data/lib/reap/reap.rb +0 -89
  162. data/lib/reap/tasks.rb +0 -756
  163. data/lib/reap/taskutils.rb +0 -122
  164. data/note/LATEST +0 -44
  165. data/note/doap.xml +0 -28
  166. data/note/history/Rakefile-0.1 +0 -308
  167. data/sample/ProjectInfo +0 -96
  168. data/sample/Rakefile +0 -9
  169. data/sample/Reapfile +0 -11
  170. data/sample/task/demo.rb +0 -15
  171. data/setup.rb +0 -1568
  172. data/web/ProjectInfo.html +0 -75
  173. data/web/images/grape.jpg +0 -0
  174. data/web/index.html +0 -312
@@ -0,0 +1,12 @@
1
+ Foo 0.0.0 has been release!
2
+
3
+
4
+ # NOTE:
5
+ #
6
+ # This is a place to put release notes.
7
+ # Like CHANGES this is also uploaded in the release process.
8
+ # This is good place to mention major changes and things
9
+ # users might need to do to take them into account.
10
+ # (BE SURE TO DELETE THIS NOTE!)
11
+
12
+
@@ -0,0 +1,8 @@
1
+ = README
2
+
3
+ == Installation
4
+
5
+ == Usage
6
+
7
+ == License
8
+
@@ -0,0 +1,130 @@
1
+ #/usr/bin/env ruby
2
+
3
+ ##########################
4
+ # FILL-IN THESE SETTINGS #
5
+ ########################################################################
6
+
7
+ PROJECT_NAME = "my_project"
8
+
9
+ RDOC_DIR = 'doc/rdoc'
10
+ RDOC_TITLE = "#{PROJECT_NAME.capitalize} API"
11
+ RDOC_MAIN = "README"
12
+ RDOC_FILES = ['A-Z*', 'lib', 'ext']
13
+
14
+ ########################################################################
15
+
16
+ # Requirements ---------------------------------------------------------
17
+ require 'rake/clean'
18
+ require 'rake/testtask'
19
+ require 'rake/rdoctask'
20
+
21
+ # Default Tasks ---------------------------------------------------------
22
+ desc "Default task (compile and test)"
23
+ task :default => [:compile, :test]
24
+
25
+ # Clean Tasks ---------------------------------------------------------
26
+ CLEAN.include '**/*.o'
27
+ CLEAN.include '**/*.so'
28
+
29
+ # Clobber Tasks ---------------------------------------------------------
30
+ CLOBBER.include 'doc/rdoc'
31
+ CLOBBER.include '**/*.log'
32
+ CLOBBER.include '**/Makefile'
33
+ CLOBBER.include '**/extconf.h'
34
+
35
+ # RDoc Tasks ---------------------------------------------------------
36
+ desc "Create the RDOC documentation"
37
+ rd = Rake::RDocTask.new(:doc) do |rdoc|
38
+ rdoc.rdoc_dir = RDOC_DIR
39
+ rdoc.title = RDOC_TITLE
40
+ rdoc.options << '--main' << RDOC_MAIN
41
+ rdoc.rdoc_files.include(*RDOC_FILES)
42
+ end
43
+
44
+ # Test Tasks ---------------------------------------------------------
45
+ Rake::TestTask.new(:test) do |t|
46
+ t.test_files = FileList[
47
+ 'tests/**/test_*.rb',
48
+ 'tests/**/tc_*.rb',
49
+ ]
50
+ t.warning = false
51
+ t.verbose = true
52
+ end
53
+
54
+ task :test => :compile
55
+
56
+ # Install Tasks ------------------------------------------------------
57
+ desc "Install to local site directory."
58
+ task :install do
59
+ cmd = File.glob('{setup.rb,install.rb,task/setup,task/install}').first
60
+ if cmd
61
+ system cmd
62
+ else
63
+ abort "No install/setup script found."
64
+ end
65
+ end
66
+
67
+ # Make tasks -----------------------------------------------------
68
+ MAKECMD = ENV['MAKE_CMD'] || 'make'
69
+ MAKEOPTS = ENV['MAKE_OPTS'] || ''
70
+
71
+ exts = File.glob('ext/*/extconf.rb')
72
+ dirs = exts.collect{ |e| File.dirname(e) }
73
+ maks = dirs.collect{ |d| File.join(d, 'Makefile' }
74
+
75
+ unless exts.empty?
76
+ dirs.each do |dir|
77
+ file File.join(dir,'Makefile') => File.join(dir,'extconf.rb') do
78
+ Dir.chdir(dir) do
79
+ ruby 'extconf.rb'
80
+ end
81
+ end
82
+ end
83
+
84
+ desc "Compile the shared object"
85
+ task :compile => maks do
86
+ dirs.each do |dir|
87
+ m = make(dir)
88
+ fail "Make failed (status #{m})" unless m == 0
89
+ end
90
+ end
91
+
92
+ #desc "Install to your site_ruby directory"
93
+ #task :install => :compile do
94
+ # m = make 'install'
95
+ # fail "Make install failed (status #{m})" unless m == 0
96
+ #end
97
+ end
98
+
99
+ def make(dir, target = '')
100
+ Dir.chdir(dir) do
101
+ pid = fork { exec "#{MAKECMD} #{MAKEOPTS} #{target}" }
102
+ Process.waitpid pid
103
+ end
104
+ $?.exitstatus
105
+ end
106
+
107
+
108
+ =begin
109
+ # Packaging / Version number tasks -----------------------------------
110
+ # Used during release packaging if a REL is supplied
111
+ task :update_version do
112
+ unless PKG_VERSION == CURRENT_VERSION
113
+ pkg_vernum = PKG_VERSION.tr('.','').sub(/^0*/,'')
114
+ pkg_vernum << '0' until pkg_vernum.length > 2
115
+
116
+ File.open('ext/xml/libxml.h.new','w+') do |f|
117
+ maj, min, mic, patch = /(\d+)\.(\d+)(?:\.(\d+))?(?:\.(\d+))?/.match(PKG_VERSION).captures
118
+ f << File.read('ext/xml/libxml.h').
119
+ gsub(/RUBY_LIBXML_VERSION\s+"(\d.+)"/) { "RUBY_LIBXML_VERSION \"#{PKG_VERSION}\"" }.
120
+ gsub(/RUBY_LIBXML_VERNUM\s+\d+/) { "RUBY_LIBXML_VERNUM #{pkg_vernum}" }.
121
+ gsub(/RUBY_LIBXML_VER_MAJ\s+\d+/) { "RUBY_LIBXML_VER_MAJ #{maj}" }.
122
+ gsub(/RUBY_LIBXML_VER_MIN\s+\d+/) { "RUBY_LIBXML_VER_MIN #{min}" }.
123
+ gsub(/RUBY_LIBXML_VER_MIC\s+\d+/) { "RUBY_LIBXML_VER_MIC #{mic || 0}" }.
124
+ gsub(/RUBY_LIBXML_VER_PATCH\s+\d+/) { "RUBY_LIBXML_VER_PATCH #{patch || 0}" }
125
+ end
126
+ mv('ext/xml/libxml.h.new', 'ext/xml/libxml.h')
127
+ end
128
+ end
129
+ =end
130
+
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ # Setup and install.
3
4
  #
4
5
  # setup.rb
5
6
  #
@@ -8,6 +9,32 @@
8
9
  # This program is free software.
9
10
  # You can distribute/modify this program under the terms of
10
11
  # the GNU LGPL, Lesser General Public License version 2.1.
12
+
13
+ #
14
+ # Was hardcoded as 'InstalledFiles'
15
+ #
16
+
17
+ INSTALLED_MANIFEST = '.installed'
18
+
19
+ #
20
+ # Was hardcoded as 'packages'.
21
+ #
22
+
23
+ PACKAGES_DIRECTORY = 'src'
24
+
25
+ #
26
+ # Locate and move to the root dir of the project/package.
27
+ # This is setup to put setup in a utilities subdir.
28
+ #
29
+ # TODO Make more robust.
30
+ #
31
+
32
+ ROOT_DIRECTORY = File.dirname(File.dirname(File.expand_path($0)))
33
+
34
+ Dir.chdir(ROOT_DIRECTORY)
35
+
36
+ #
37
+ # Deal with Ruby version issues.
11
38
  #
12
39
 
13
40
  unless Enumerable.method_defined?(:map) # Ruby 1.4.6
@@ -57,7 +84,6 @@ class ConfigTable
57
84
  @config_opt = nil
58
85
  @verbose = true
59
86
  @no_harm = false
60
- @libsrc_pattern = '*.rb' # THIS IS NOT GOOD!!!
61
87
  end
62
88
 
63
89
  attr_accessor :install_prefix
@@ -75,8 +101,6 @@ class ConfigTable
75
101
  @no_harm
76
102
  end
77
103
 
78
- attr_accessor :libsrc_pattern
79
-
80
104
  def [](key)
81
105
  lookup(key).resolve(self)
82
106
  end
@@ -152,7 +176,7 @@ class ConfigTable
152
176
  def standard_entries(rbconfig)
153
177
  c = rbconfig
154
178
 
155
- rubypath = c['bindir'] + '/' + c['ruby_install_name']
179
+ rubypath = File.join(c['bindir'], c['ruby_install_name'] + c['EXEEXT'])
156
180
 
157
181
  major = c['MAJOR'].to_i
158
182
  minor = c['MINOR'].to_i
@@ -375,10 +399,12 @@ class ConfigTable
375
399
 
376
400
  def check(val)
377
401
  return 'yes' unless val
378
- unless /\A(y(es)?|n(o)?|t(rue)?|f(alse))\z/i =~ val
402
+ case val
403
+ when /\Ay(es)?\z/i, /\At(rue)?\z/i then 'yes'
404
+ when /\An(o)?\z/i, /\Af(alse)\z/i then 'no'
405
+ else
379
406
  setup_rb_error "config: --#{@name} accepts only yes/no for argument"
380
407
  end
381
- (/\Ay(es)?|\At(rue)/i =~ value) ? 'yes' : 'no'
382
408
  end
383
409
  end
384
410
 
@@ -466,7 +492,7 @@ class ConfigTable
466
492
  private
467
493
 
468
494
  def check(val)
469
- unless File.dir?("packages/#{val}")
495
+ unless File.dir?("#{PACKAGES_DIRECTORY}/#{val}")
470
496
  setup_rb_error "config: no such package: #{val}"
471
497
  end
472
498
  val
@@ -474,7 +500,7 @@ class ConfigTable
474
500
  end
475
501
 
476
502
  class MetaConfigEnvironment
477
- def intiailize(config, installer)
503
+ def initialize(config, installer)
478
504
  @config = config
479
505
  @installer = installer
480
506
  end
@@ -637,8 +663,8 @@ module FileOperations
637
663
  f.write str
638
664
  }
639
665
  File.chmod mode, realdest
640
- # 0777
641
- File.open("#{objdir_root()}/InstalledFiles", 'a', 0777) {|f|
666
+
667
+ File.open("#{objdir_root()}/#{INSTALLED_MANIFEST}", 'a') {|f|
642
668
  if prefix
643
669
  f.puts realdest.sub(prefix, '')
644
670
  else
@@ -753,7 +779,7 @@ end
753
779
 
754
780
  class ToplevelInstaller
755
781
 
756
- Version = '3.4.0'
782
+ Version = '3.4.1'
757
783
  Copyright = 'Copyright (c) 2000-2005 Minero Aoki'
758
784
 
759
785
  TASKS = [
@@ -773,13 +799,13 @@ class ToplevelInstaller
773
799
  config.load_multipackage_entries if multipackage?
774
800
  config.fixup
775
801
  klass = (multipackage?() ? ToplevelInstallerMulti : ToplevelInstaller)
776
- #klass.new(File.dirname($setup_pwd), config).invoke
777
- klass.new($setup_pwd, config).invoke
802
+ #klass.new(File.dirname($0), config).invoke
803
+ klass.new(ROOT_DIRECTORY, config).invoke
778
804
  end
779
805
 
780
806
  def ToplevelInstaller.multipackage?
781
- #File.dir?(File.dirname($setup_pwd) + '/packages')
782
- File.dir?($setup_pwd + '/packages')
807
+ #File.dir?(File.dirname($0) + '/#{PACKAGES_DIRECTORY}')
808
+ File.dir?(ROOT_DIRECTORY + "/#{PACKAGES_DIRECTORY}")
783
809
  end
784
810
 
785
811
  def ToplevelInstaller.load_rbconfig
@@ -873,9 +899,9 @@ class ToplevelInstaller
873
899
  when '--help'
874
900
  print_usage $stdout
875
901
  exit 0
876
- #when '--version'
877
- # puts "#{File.basename($setup_pwd)} version #{Version}"
878
- # exit 0
902
+ when '--version'
903
+ puts "#{File.basename($0)} version #{Version}"
904
+ exit 0
879
905
  when '--copyright'
880
906
  puts Copyright
881
907
  exit 0
@@ -896,6 +922,7 @@ class ToplevelInstaller
896
922
 
897
923
  def parsearg_no_options
898
924
  unless ARGV.empty?
925
+ task = caller(0).first.slice(%r<`parsearg_(\w+)'>, 1)
899
926
  setup_rb_error "#{task}: unknown options: #{ARGV.join(' ')}"
900
927
  end
901
928
  end
@@ -1031,7 +1058,7 @@ class ToplevelInstallerMulti < ToplevelInstaller
1031
1058
 
1032
1059
  def initialize(ardir_root, config)
1033
1060
  super
1034
- @packages = directories_of("#{@ardir}/packages")
1061
+ @packages = directories_of("#{@ardir}/#{PACKAGES_DIRECTORY}")
1035
1062
  raise 'no package exists' if @packages.empty?
1036
1063
  @root_installer = Installer.new(@config, @ardir, File.expand_path('.'))
1037
1064
  end
@@ -1039,7 +1066,7 @@ class ToplevelInstallerMulti < ToplevelInstaller
1039
1066
  def run_metaconfigs
1040
1067
  @config.load_script "#{@ardir}/metaconfig", self
1041
1068
  @packages.each do |name|
1042
- @config.load_script "#{@ardir}/packages/#{name}/metaconfig"
1069
+ @config.load_script "#{@ardir}/#{PACKAGES_DIRECTORY}/#{name}/metaconfig"
1043
1070
  end
1044
1071
  end
1045
1072
 
@@ -1048,8 +1075,8 @@ class ToplevelInstallerMulti < ToplevelInstaller
1048
1075
  def packages=(list)
1049
1076
  raise 'package list is empty' if list.empty?
1050
1077
  list.each do |name|
1051
- raise "directory packages/#{name} does not exist"\
1052
- unless File.dir?("#{@ardir}/packages/#{name}")
1078
+ raise "directory #{PACKAGES_DIRECTORY}/#{name} does not exist"\
1079
+ unless File.dir?("#{@ardir}/#{PACKAGES_DIRECTORY}/#{name}")
1053
1080
  end
1054
1081
  @packages = list
1055
1082
  end
@@ -1058,8 +1085,8 @@ class ToplevelInstallerMulti < ToplevelInstaller
1058
1085
  @installers = {}
1059
1086
  @packages.each do |pack|
1060
1087
  @installers[pack] = Installer.new(@config,
1061
- "#{@ardir}/packages/#{pack}",
1062
- "packages/#{pack}")
1088
+ "#{@ardir}/#{PACKAGES_DIRECTORY}/#{pack}",
1089
+ "#{PACKAGES_DIRECTORY}/#{pack}")
1063
1090
  end
1064
1091
  with = extract_selection(config('with'))
1065
1092
  without = extract_selection(config('without'))
@@ -1132,11 +1159,11 @@ class ToplevelInstallerMulti < ToplevelInstaller
1132
1159
  #
1133
1160
 
1134
1161
  def each_selected_installers
1135
- Dir.mkdir 'packages' unless File.dir?('packages')
1162
+ Dir.mkdir PACKAGES_DIRECTORY unless File.dir?(PACKAGES_DIRECTORY)
1136
1163
  @selected.each do |pack|
1137
1164
  $stderr.puts "Processing the package `#{pack}' ..." if verbose?
1138
- Dir.mkdir "packages/#{pack}" unless File.dir?("packages/#{pack}")
1139
- Dir.chdir "packages/#{pack}"
1165
+ Dir.mkdir "#{PACKAGES_DIRECTORY}/#{pack}" unless File.dir?("#{PACKAGES_DIRECTORY}/#{pack}")
1166
+ Dir.chdir "#{PACKAGES_DIRECTORY}/#{pack}"
1140
1167
  yield @installers[pack]
1141
1168
  Dir.chdir '../..'
1142
1169
  end
@@ -1177,6 +1204,9 @@ class Installer
1177
1204
  "#<#{self.class} #{File.basename(@srcdir)}>"
1178
1205
  end
1179
1206
 
1207
+ def noop(rel)
1208
+ end
1209
+
1180
1210
  #
1181
1211
  # Hook Script API base methods
1182
1212
  #
@@ -1224,29 +1254,21 @@ class Installer
1224
1254
  exec_task_traverse 'config'
1225
1255
  end
1226
1256
 
1227
- def config_dir_bin(rel)
1228
- end
1229
-
1230
- def config_dir_lib(rel)
1231
- end
1232
-
1233
- def config_dir_man(rel)
1234
- end
1257
+ alias config_dir_bin noop
1258
+ alias config_dir_lib noop
1235
1259
 
1236
1260
  def config_dir_ext(rel)
1237
1261
  extconf if extdir?(curr_srcdir())
1238
1262
  end
1239
1263
 
1264
+ alias config_dir_data noop
1265
+ alias config_dir_conf noop
1266
+ alias config_dir_man noop
1267
+
1240
1268
  def extconf
1241
1269
  ruby "#{curr_srcdir()}/extconf.rb", *@config.config_opt
1242
1270
  end
1243
1271
 
1244
- def config_dir_data(rel)
1245
- end
1246
-
1247
- def config_dir_conf(rel)
1248
- end
1249
-
1250
1272
  #
1251
1273
  # TASK setup
1252
1274
  #
@@ -1257,43 +1279,89 @@ class Installer
1257
1279
 
1258
1280
  def setup_dir_bin(rel)
1259
1281
  files_of(curr_srcdir()).each do |fname|
1260
- adjust_shebang "#{curr_srcdir()}/#{fname}"
1282
+ update_shebang_line "#{curr_srcdir()}/#{fname}"
1261
1283
  end
1262
1284
  end
1263
1285
 
1264
- def adjust_shebang(path)
1286
+ alias setup_dir_lib noop
1287
+
1288
+ def setup_dir_ext(rel)
1289
+ make if extdir?(curr_srcdir())
1290
+ end
1291
+
1292
+ alias setup_dir_data noop
1293
+ alias setup_dir_conf noop
1294
+ alias setup_dir_man noop
1295
+
1296
+ def update_shebang_line(path)
1265
1297
  return if no_harm?
1298
+ return if config('shebang') == 'never'
1299
+ old = Shebang.load(path)
1300
+ if old
1301
+ $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
1302
+ new = new_shebang(old)
1303
+ return if new.to_s == old.to_s
1304
+ else
1305
+ return unless config('shebang') == 'all'
1306
+ new = Shebang.new(config('rubypath'))
1307
+ end
1308
+ $stderr.puts "updating shebang: #{File.basename(path)}" if verbose?
1309
+ open_atomic_writer(path) {|output|
1310
+ File.open(path, 'rb') {|f|
1311
+ f.gets if old # discard
1312
+ output.puts new.to_s
1313
+ output.print f.read
1314
+ }
1315
+ }
1316
+ end
1317
+
1318
+ def new_shebang(old)
1319
+ if /\Aruby/ =~ File.basename(old.cmd)
1320
+ Shebang.new(config('rubypath'), old.args)
1321
+ elsif File.basename(old.cmd) == 'env' and old.args.first == 'ruby'
1322
+ Shebang.new(config('rubypath'), old.args[1..-1])
1323
+ else
1324
+ return old unless config('shebang') == 'all'
1325
+ Shebang.new(config('rubypath'))
1326
+ end
1327
+ end
1328
+
1329
+ def open_atomic_writer(path, &block)
1266
1330
  tmpfile = File.basename(path) + '.tmp'
1267
1331
  begin
1268
- File.open(path, 'rb') {|r|
1269
- first = r.gets
1270
- return unless File.basename(first.sub(/\A\#!/, '').split[0].to_s) == 'ruby'
1271
- $stderr.puts "adjusting shebang: #{File.basename(path)}" if verbose?
1272
- File.open(tmpfile, 'wb') {|w|
1273
- w.print first.sub(/\A\#!\s*\S+/, '#! ' + config('rubypath'))
1274
- w.write r.read
1275
- }
1276
- }
1277
- move_file tmpfile, File.basename(path)
1332
+ File.open(tmpfile, 'wb', &block)
1333
+ File.rename tmpfile, File.basename(path)
1278
1334
  ensure
1279
1335
  File.unlink tmpfile if File.exist?(tmpfile)
1280
1336
  end
1281
1337
  end
1282
1338
 
1283
- def setup_dir_lib(rel)
1284
- end
1339
+ class Shebang
1340
+ def Shebang.load(path)
1341
+ line = nil
1342
+ File.open(path) {|f|
1343
+ line = f.gets
1344
+ }
1345
+ return nil unless /\A#!/ =~ line
1346
+ parse(line)
1347
+ end
1285
1348
 
1286
- def setup_dir_man(rel)
1287
- end
1349
+ def Shebang.parse(line)
1350
+ cmd, *args = *line.strip.sub(/\A\#!/, '').split(' ')
1351
+ new(cmd, args)
1352
+ end
1288
1353
 
1289
- def setup_dir_ext(rel)
1290
- make if extdir?(curr_srcdir())
1291
- end
1354
+ def initialize(cmd, args = [])
1355
+ @cmd = cmd
1356
+ @args = args
1357
+ end
1292
1358
 
1293
- def setup_dir_data(rel)
1294
- end
1359
+ attr_reader :cmd
1360
+ attr_reader :args
1295
1361
 
1296
- def setup_dir_conf(rel)
1362
+ def to_s
1363
+ "#! #{@cmd}" + (@args.empty? ? '' : " #{@args.join(' ')}")
1364
+ end
1297
1365
  end
1298
1366
 
1299
1367
  #
@@ -1301,7 +1369,7 @@ class Installer
1301
1369
  #
1302
1370
 
1303
1371
  def exec_install
1304
- rm_f 'InstalledFiles'
1372
+ rm_f "#{INSTALLED_MANIFEST}"
1305
1373
  exec_task_traverse 'install'
1306
1374
  end
1307
1375
 
@@ -1310,8 +1378,7 @@ class Installer
1310
1378
  end
1311
1379
 
1312
1380
  def install_dir_lib(rel)
1313
- p rubyscripts(), "#{config('rbdir')}/#{rel}", 0644
1314
- install_files rubyscripts(), "#{config('rbdir')}/#{rel}", 0644
1381
+ install_files libfiles(), "#{config('rbdir')}/#{rel}", 0644
1315
1382
  end
1316
1383
 
1317
1384
  def install_dir_ext(rel)
@@ -1342,8 +1409,8 @@ p rubyscripts(), "#{config('rbdir')}/#{rel}", 0644
1342
1409
  end
1343
1410
  end
1344
1411
 
1345
- def rubyscripts
1346
- glob_select(@config.libsrc_pattern, targetfiles())
1412
+ def libfiles
1413
+ glob_reject(%w(*.y *.output), targetfiles())
1347
1414
  end
1348
1415
 
1349
1416
  def rubyextentions(dir)
@@ -1368,7 +1435,7 @@ p rubyscripts(), "#{config('rbdir')}/#{rel}", 0644
1368
1435
  end
1369
1436
 
1370
1437
  # picked up many entries from cvs-1.11.1/src/ignore.c
1371
- JUNK_FILES = %w(
1438
+ JUNK_FILES = %w(
1372
1439
  core RCSLOG tags TAGS .make.state
1373
1440
  .nse_depinfo #* .#* cvslog.* ,* .del-* *.olb
1374
1441
  *~ *.old *.bak *.BAK *.orig *.rej _$* *$
@@ -1421,7 +1488,11 @@ p rubyscripts(), "#{config('rbdir')}/#{rel}", 0644
1421
1488
  return
1422
1489
  end
1423
1490
  $stderr.puts 'Running tests...' if verbose?
1424
- require 'test/unit'
1491
+ begin
1492
+ require 'test/unit'
1493
+ rescue LoadError
1494
+ setup_rb_error 'test/unit cannot loaded. You need Ruby 1.8 or later to invoke this task.'
1495
+ end
1425
1496
  runner = Test::Unit::AutoRunner.new(true)
1426
1497
  runner.to_run << TESTDIR
1427
1498
  runner.run
@@ -1434,26 +1505,20 @@ p rubyscripts(), "#{config('rbdir')}/#{rel}", 0644
1434
1505
  def exec_clean
1435
1506
  exec_task_traverse 'clean'
1436
1507
  rm_f @config.savefile
1437
- rm_f 'InstalledFiles'
1508
+ rm_f "#{INSTALLED_MANIFEST}"
1438
1509
  end
1439
1510
 
1440
- def clean_dir_bin(rel)
1441
- end
1442
-
1443
- def clean_dir_lib(rel)
1444
- end
1511
+ alias clean_dir_bin noop
1512
+ alias clean_dir_lib noop
1513
+ alias clean_dir_data noop
1514
+ alias clean_dir_conf noop
1515
+ alias clean_dir_man noop
1445
1516
 
1446
1517
  def clean_dir_ext(rel)
1447
1518
  return unless extdir?(curr_srcdir())
1448
1519
  make 'clean' if File.file?('Makefile')
1449
1520
  end
1450
1521
 
1451
- def clean_dir_data(rel)
1452
- end
1453
-
1454
- def clean_dir_conf(rel)
1455
- end
1456
-
1457
1522
  #
1458
1523
  # TASK distclean
1459
1524
  #
@@ -1461,34 +1526,29 @@ p rubyscripts(), "#{config('rbdir')}/#{rel}", 0644
1461
1526
  def exec_distclean
1462
1527
  exec_task_traverse 'distclean'
1463
1528
  rm_f @config.savefile
1464
- rm_f 'InstalledFiles'
1529
+ rm_f "#{INSTALLED_MANIFEST}"
1465
1530
  end
1466
1531
 
1467
- def distclean_dir_bin(rel)
1468
- end
1469
-
1470
- def distclean_dir_lib(rel)
1471
- end
1532
+ alias distclean_dir_bin noop
1533
+ alias distclean_dir_lib noop
1472
1534
 
1473
1535
  def distclean_dir_ext(rel)
1474
1536
  return unless extdir?(curr_srcdir())
1475
1537
  make 'distclean' if File.file?('Makefile')
1476
1538
  end
1477
1539
 
1478
- def distclean_dir_data(rel)
1479
- end
1480
-
1481
- def distclean_dir_conf(rel)
1482
- end
1540
+ alias distclean_dir_data noop
1541
+ alias distclean_dir_conf noop
1542
+ alias distclean_dir_man noop
1483
1543
 
1484
1544
  #
1485
- # lib
1545
+ # Traversing
1486
1546
  #
1487
1547
 
1488
1548
  def exec_task_traverse(task)
1489
1549
  run_hook "pre-#{task}"
1490
1550
  FILETYPES.each do |type|
1491
- if config('without-ext') == 'yes' and type == 'ext'
1551
+ if type == 'ext' and config('without-ext') == 'yes'
1492
1552
  $stderr.puts 'skipping ext/* by user option' if verbose?
1493
1553
  next
1494
1554
  end
@@ -1544,7 +1604,6 @@ def setup_rb_error(msg)
1544
1604
  raise SetupError, msg
1545
1605
  end
1546
1606
 
1547
- =begin
1548
1607
  if $0 == __FILE__
1549
1608
  begin
1550
1609
  ToplevelInstaller.invoke
@@ -1555,4 +1614,3 @@ if $0 == __FILE__
1555
1614
  exit 1
1556
1615
  end
1557
1616
  end
1558
- =end