Skip to content
This repository
Newer
Older
100644 240 lines (178 sloc) 5.477 kb
f9b95a42 »
2007-09-28 Gem::ruby now returns the full path. Added Gem::prefix to make self u…
1 #--
2 # Copyright 2006, 2007 by Chad Fowler, Rich Kilmer, Jim Weirich, Eric Hodel
3 # and others.
4 # All rights reserved.
5 # See LICENSE.txt for permissions.
6 #++
228a3801 »
2004-10-30 Changing to setup.rb. Needs testing!
7
300b243a »
2007-10-17 Unset RUBYOPT when installing. Fixes bug #14683 submitted by Lyle Joh…
8 # Make sure rubygems isn't already loaded.
9 if ENV['RUBYOPT'] =~ /rubygems/ then
10 ENV.delete 'RUBYOPT'
11
12 ruby = File.join Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name']
13 ruby << Config::CONFIG['EXEEXT']
14
15 exec(ruby, 'setup.rb', *ARGV)
16 end
17
f9b95a42 »
2007-09-28 Gem::ruby now returns the full path. Added Gem::prefix to make self u…
18 $:.unshift 'lib'
19 require 'rubygems'
c7886fd5 »
2007-03-17 update to setup.rb 3.4.1
20
f9b95a42 »
2007-09-28 Gem::ruby now returns the full path. Added Gem::prefix to make self u…
21 require 'fileutils'
22 require 'rbconfig'
23 require 'rdoc/rdoc'
24 require 'tmpdir'
c7886fd5 »
2007-03-17 update to setup.rb 3.4.1
25
f9b95a42 »
2007-09-28 Gem::ruby now returns the full path. Added Gem::prefix to make self u…
26 include FileUtils::Verbose
c7886fd5 »
2007-03-17 update to setup.rb 3.4.1
27
f9b95a42 »
2007-09-28 Gem::ruby now returns the full path. Added Gem::prefix to make self u…
28 # check ruby version
c7886fd5 »
2007-03-17 update to setup.rb 3.4.1
29
f9b95a42 »
2007-09-28 Gem::ruby now returns the full path. Added Gem::prefix to make self u…
30 required_version = Gem::Version::Requirement.create(">= 1.8.2")
228a3801 »
2004-10-30 Changing to setup.rb. Needs testing!
31
f9b95a42 »
2007-09-28 Gem::ruby now returns the full path. Added Gem::prefix to make self u…
32 unless required_version.satisfied_by? Gem::Version.new(RUBY_VERSION) then
33 abort "Expected Ruby version #{required_version}, was #{RUBY_VERSION}"
228a3801 »
2004-10-30 Changing to setup.rb. Needs testing!
34 end
35
f9b95a42 »
2007-09-28 Gem::ruby now returns the full path. Added Gem::prefix to make self u…
36 # install stuff
228a3801 »
2004-10-30 Changing to setup.rb. Needs testing!
37
f9b95a42 »
2007-09-28 Gem::ruby now returns the full path. Added Gem::prefix to make self u…
38 lib_dir = nil
39 bin_dir = nil
228a3801 »
2004-10-30 Changing to setup.rb. Needs testing!
40
f9b95a42 »
2007-09-28 Gem::ruby now returns the full path. Added Gem::prefix to make self u…
41 if ARGV.grep(/^--prefix/).empty? then
42 lib_dir = Config::CONFIG['sitelibdir']
43 bin_dir = Config::CONFIG['bindir']
44 else
45 prefix = nil
228a3801 »
2004-10-30 Changing to setup.rb. Needs testing!
46
f9b95a42 »
2007-09-28 Gem::ruby now returns the full path. Added Gem::prefix to make self u…
47 ARGV.grep(/^--prefix=(.*)/)
48 if $1.nil? or $1.empty? then
49 path_index = ARGV.index '--prefix'
50 prefix = ARGV[path_index + 1]
51 else
52 prefix = $1
228a3801 »
2004-10-30 Changing to setup.rb. Needs testing!
53 end
54
f9b95a42 »
2007-09-28 Gem::ruby now returns the full path. Added Gem::prefix to make self u…
55 raise "invalid --prefix #{prefix.inspect}" if prefix.nil?
228a3801 »
2004-10-30 Changing to setup.rb. Needs testing!
56
f9b95a42 »
2007-09-28 Gem::ruby now returns the full path. Added Gem::prefix to make self u…
57 lib_dir = File.join prefix, 'lib'
58 bin_dir = File.join prefix, 'bin'
228a3801 »
2004-10-30 Changing to setup.rb. Needs testing!
59
f9b95a42 »
2007-09-28 Gem::ruby now returns the full path. Added Gem::prefix to make self u…
60 mkdir_p lib_dir
61 mkdir_p bin_dir
228a3801 »
2004-10-30 Changing to setup.rb. Needs testing!
62 end
63
f9b95a42 »
2007-09-28 Gem::ruby now returns the full path. Added Gem::prefix to make self u…
64 Dir.chdir 'lib' do
65 lib_files = Dir[File.join('**', '*rb')]
228a3801 »
2004-10-30 Changing to setup.rb. Needs testing!
66
f9b95a42 »
2007-09-28 Gem::ruby now returns the full path. Added Gem::prefix to make self u…
67 lib_files.each do |lib_file|
68 dest_file = File.join lib_dir, lib_file
69 dest_dir = File.dirname dest_file
70 mkdir_p dest_dir unless File.directory? dest_dir
228a3801 »
2004-10-30 Changing to setup.rb. Needs testing!
71
f9b95a42 »
2007-09-28 Gem::ruby now returns the full path. Added Gem::prefix to make self u…
72 install lib_file, dest_file, :mode => 0644
c7886fd5 »
2007-03-17 update to setup.rb 3.4.1
73 end
f9b95a42 »
2007-09-28 Gem::ruby now returns the full path. Added Gem::prefix to make self u…
74 end
228a3801 »
2004-10-30 Changing to setup.rb. Needs testing!
75
f9b95a42 »
2007-09-28 Gem::ruby now returns the full path. Added Gem::prefix to make self u…
76 Dir.chdir 'bin' do
77 bin_files = Dir['*']
228a3801 »
2004-10-30 Changing to setup.rb. Needs testing!
78
f9b95a42 »
2007-09-28 Gem::ruby now returns the full path. Added Gem::prefix to make self u…
79 bin_files.each do |bin_file|
80 dest_file = File.join bin_dir, bin_file
81 bin_tmp_file = File.join Dir.tmpdir, bin_file
228a3801 »
2004-10-30 Changing to setup.rb. Needs testing!
82
f9b95a42 »
2007-09-28 Gem::ruby now returns the full path. Added Gem::prefix to make self u…
83 begin
84 cp bin_file, bin_tmp_file
85 bin = File.readlines bin_tmp_file
86 bin[0] = "#!#{Gem.ruby}\n"
228a3801 »
2004-10-30 Changing to setup.rb. Needs testing!
87
f9b95a42 »
2007-09-28 Gem::ruby now returns the full path. Added Gem::prefix to make self u…
88 File.open bin_tmp_file, 'w' do |fp|
89 fp.puts bin.join
228a3801 »
2004-10-30 Changing to setup.rb. Needs testing!
90 end
91
f9b95a42 »
2007-09-28 Gem::ruby now returns the full path. Added Gem::prefix to make self u…
92 install bin_tmp_file, dest_file, :mode => 0755
228a3801 »
2004-10-30 Changing to setup.rb. Needs testing!
93 ensure
f9b95a42 »
2007-09-28 Gem::ruby now returns the full path. Added Gem::prefix to make self u…
94 rm bin_tmp_file
228a3801 »
2004-10-30 Changing to setup.rb. Needs testing!
95 end
96
f9b95a42 »
2007-09-28 Gem::ruby now returns the full path. Added Gem::prefix to make self u…
97 next unless Gem.win_platform?
228a3801 »
2004-10-30 Changing to setup.rb. Needs testing!
98
99 begin
f9b95a42 »
2007-09-28 Gem::ruby now returns the full path. Added Gem::prefix to make self u…
100 bin_cmd_file = File.join Dir.tmpdir, "#{bin_file}.cmd"
228a3801 »
2004-10-30 Changing to setup.rb. Needs testing!
101
f9b95a42 »
2007-09-28 Gem::ruby now returns the full path. Added Gem::prefix to make self u…
102 File.open bin_cmd_file, 'w' do |file|
103 file.puts %{@"#{Gem.ruby}" "#{bin_file}" %1 %2 %3 %4 %5 %6 %7 %8 %9}
c7886fd5 »
2007-03-17 update to setup.rb 3.4.1
104 end
105
f9b95a42 »
2007-09-28 Gem::ruby now returns the full path. Added Gem::prefix to make self u…
106 install bin_cmd_file, "#{dest_file}.cmd", :mode => 0755
107 ensure
108 rm bin_cmd_file
109 end
228a3801 »
2004-10-30 Changing to setup.rb. Needs testing!
110 end
f9b95a42 »
2007-09-28 Gem::ruby now returns the full path. Added Gem::prefix to make self u…
111 end
228a3801 »
2004-10-30 Changing to setup.rb. Needs testing!
112
48efd101 »
2007-10-16 Install bin files for old gem executables
113 # Replace old bin files with ones that abort.
114
115 old_bin_files = {
116 'gem_mirror' => 'gem mirror',
117 'gem_server' => 'gem server',
118 'gemlock' => 'gem lock',
119 'gemri' => 'ri',
120 'gemwhich' => 'gem which',
121 'index_gem_repository.rb' => 'gem generate_index',
122 }
123
124 old_bin_files.each do |old_bin_file, new_name|
125 old_bin_path = File.join bin_dir, old_bin_file
126 next unless File.exist? old_bin_path
127
acf61166 »
2007-10-17 Simpler mswin deprecation scripts.
128 deprecation_message = "`#{old_bin_file}` has been deprecated. Use `#{new_name}` instead."
129
48efd101 »
2007-10-16 Install bin files for old gem executables
130 File.open old_bin_path, 'w' do |fp|
131 fp.write <<-EOF
132 #!#{Gem.ruby}
133
acf61166 »
2007-10-17 Simpler mswin deprecation scripts.
134 abort "#{deprecation_message}"
48efd101 »
2007-10-16 Install bin files for old gem executables
135 EOF
136 end
137
138 next unless Gem.win_platform?
139
140 File.open "#{old_bin_path}.cmd", 'w' do |fp|
acf61166 »
2007-10-17 Simpler mswin deprecation scripts.
141 fp.puts %{@ECHO.#{deprecation_message}}
48efd101 »
2007-10-16 Install bin files for old gem executables
142 end
143 end
144
2e8c2a56 »
2007-10-13 Remove source caches on install
145 # Remove source caches
146
147 require 'rubygems/source_info_cache'
148
149 user_cache_file = Gem::SourceInfoCache.user_cache_file
150 system_cache_file = Gem::SourceInfoCache.system_cache_file
151
152 rm user_cache_file if File.writable? user_cache_file
153 rm system_cache_file if File.writable? system_cache_file
154
f9b95a42 »
2007-09-28 Gem::ruby now returns the full path. Added Gem::prefix to make self u…
155 # install RDoc
228a3801 »
2004-10-30 Changing to setup.rb. Needs testing!
156
f9b95a42 »
2007-09-28 Gem::ruby now returns the full path. Added Gem::prefix to make self u…
157 gem_doc_dir = File.join Gem.dir, 'doc'
228a3801 »
2004-10-30 Changing to setup.rb. Needs testing!
158
f9b95a42 »
2007-09-28 Gem::ruby now returns the full path. Added Gem::prefix to make self u…
159 if File.writable? gem_doc_dir then
160 puts "Removing old RubyGems RDoc and ri..."
b882a3cf »
2007-10-13 Only clear RDoc for rubygems
161 Dir[File.join(Gem.dir, 'doc', 'rubygems-[0-9]*')].each do |dir|
f9b95a42 »
2007-09-28 Gem::ruby now returns the full path. Added Gem::prefix to make self u…
162 rm_rf dir
c7886fd5 »
2007-03-17 update to setup.rb 3.4.1
163 end
164
f9b95a42 »
2007-09-28 Gem::ruby now returns the full path. Added Gem::prefix to make self u…
165 def run_rdoc(*args)
166 args << '--quiet'
167 args << '--main' << 'README'
168 args << '.' << 'README' << 'LICENSE.txt' << 'GPL.txt'
c7886fd5 »
2007-03-17 update to setup.rb 3.4.1
169
f9b95a42 »
2007-09-28 Gem::ruby now returns the full path. Added Gem::prefix to make self u…
170 r = RDoc::RDoc.new
171 r.document args
c7886fd5 »
2007-03-17 update to setup.rb 3.4.1
172 end
173
f9b95a42 »
2007-09-28 Gem::ruby now returns the full path. Added Gem::prefix to make self u…
174 rubygems_name = "rubygems-#{Gem::RubyGemsVersion}"
c7886fd5 »
2007-03-17 update to setup.rb 3.4.1
175
f9b95a42 »
2007-09-28 Gem::ruby now returns the full path. Added Gem::prefix to make self u…
176 doc_dir = File.join Gem.dir, 'doc', rubygems_name
c7886fd5 »
2007-03-17 update to setup.rb 3.4.1
177
f9b95a42 »
2007-09-28 Gem::ruby now returns the full path. Added Gem::prefix to make self u…
178 unless ARGV.include? '--no-ri' then
179 ri_dir = File.join doc_dir, 'ri'
180 puts "Installing #{rubygems_name} ri into #{ri_dir}..."
181 run_rdoc '--ri', '--op', ri_dir
228a3801 »
2004-10-30 Changing to setup.rb. Needs testing!
182 end
183
f9b95a42 »
2007-09-28 Gem::ruby now returns the full path. Added Gem::prefix to make self u…
184 unless ARGV.include? '--no-rdoc' then
185 rdoc_dir = File.join(doc_dir, 'rdoc')
186 puts "Installing #{rubygems_name} rdoc into #{rdoc_dir}..."
187 run_rdoc '--op', rdoc_dir
228a3801 »
2004-10-30 Changing to setup.rb. Needs testing!
188 end
f9b95a42 »
2007-09-28 Gem::ruby now returns the full path. Added Gem::prefix to make self u…
189 else
190 puts "Skipping RDoc generation, #{gem_doc_dir} not writable"
191 puts "Set the GEM_HOME environment variable if you want RDoc generated"
192 end
228a3801 »
2004-10-30 Changing to setup.rb. Needs testing!
193
f9b95a42 »
2007-09-28 Gem::ruby now returns the full path. Added Gem::prefix to make self u…
194 # Remove stubs
228a3801 »
2004-10-30 Changing to setup.rb. Needs testing!
195
f9b95a42 »
2007-09-28 Gem::ruby now returns the full path. Added Gem::prefix to make self u…
196 def stub?(path)
7f2c7787 »
2007-09-30 Make setup.rb work on 1.9
197 return unless File.readable? path
f9b95a42 »
2007-09-28 Gem::ruby now returns the full path. Added Gem::prefix to make self u…
198 File.read(path, 40) =~ /^# This file was generated by RubyGems/ and
199 File.readlines(path).size < 20
200 end
228a3801 »
2004-10-30 Changing to setup.rb. Needs testing!
201
f9b95a42 »
2007-09-28 Gem::ruby now returns the full path. Added Gem::prefix to make self u…
202 puts <<-EOF.gsub(/^ */, '')
203 As of RubyGems 0.8.0, library stubs are no longer needed.
204 Searching $LOAD_PATH for stubs to optionally delete (may take a while)...
205 EOF
228a3801 »
2004-10-30 Changing to setup.rb. Needs testing!
206
f9b95a42 »
2007-09-28 Gem::ruby now returns the full path. Added Gem::prefix to make self u…
207 gemfiles = Dir[File.join("{#{($LOAD_PATH).join(',')}}", '**', '*.rb')]
208 gemfiles = gemfiles.map { |file| File.expand_path file }.uniq
228a3801 »
2004-10-30 Changing to setup.rb. Needs testing!
209
f9b95a42 »
2007-09-28 Gem::ruby now returns the full path. Added Gem::prefix to make self u…
210 puts "...done."
228a3801 »
2004-10-30 Changing to setup.rb. Needs testing!
211
f9b95a42 »
2007-09-28 Gem::ruby now returns the full path. Added Gem::prefix to make self u…
212 seen_stub = false
c7886fd5 »
2007-03-17 update to setup.rb 3.4.1
213
f9b95a42 »
2007-09-28 Gem::ruby now returns the full path. Added Gem::prefix to make self u…
214 gemfiles.each do |file|
215 next if File.directory? file
216 next unless stub? file
228a3801 »
2004-10-30 Changing to setup.rb. Needs testing!
217
f9b95a42 »
2007-09-28 Gem::ruby now returns the full path. Added Gem::prefix to make self u…
218 unless seen_stub then
219 puts "\nRubyGems has detected stubs that can be removed. Confirm their removal:"
228a3801 »
2004-10-30 Changing to setup.rb. Needs testing!
220 end
f9b95a42 »
2007-09-28 Gem::ruby now returns the full path. Added Gem::prefix to make self u…
221 seen_stub = true
228a3801 »
2004-10-30 Changing to setup.rb. Needs testing!
222
f9b95a42 »
2007-09-28 Gem::ruby now returns the full path. Added Gem::prefix to make self u…
223 print " * remove #{file}? [y/n] "
224 answer = gets
228a3801 »
2004-10-30 Changing to setup.rb. Needs testing!
225
f9b95a42 »
2007-09-28 Gem::ruby now returns the full path. Added Gem::prefix to make self u…
226 if answer =~ /y/i then
227 unlink file
228 puts " (removed)"
229 else
230 puts " (skipping)"
c7886fd5 »
2007-03-17 update to setup.rb 3.4.1
231 end
232 end
228a3801 »
2004-10-30 Changing to setup.rb. Needs testing!
233
f9b95a42 »
2007-09-28 Gem::ruby now returns the full path. Added Gem::prefix to make self u…
234 if seen_stub then
235 puts "Finished with library stubs."
236 else
237 puts "No library stubs found."
228a3801 »
2004-10-30 Changing to setup.rb. Needs testing!
238 end
f9b95a42 »
2007-09-28 Gem::ruby now returns the full path. Added Gem::prefix to make self u…
239
Something went wrong with that request. Please try again.