summaryrefslogtreecommitdiff
path: root/tool/rbinstall.rb
diff options
context:
space:
mode:
Diffstat (limited to 'tool/rbinstall.rb')
-rwxr-xr-xtool/rbinstall.rb669
1 files changed, 396 insertions, 273 deletions
diff --git a/tool/rbinstall.rb b/tool/rbinstall.rb
index 85d05eff25..db01e0b79d 100755
--- a/tool/rbinstall.rb
+++ b/tool/rbinstall.rb
@@ -28,6 +28,7 @@ begin
rescue LoadError
$" << "zlib.rb"
end
+require_relative 'lib/path'
INDENT = " "*36
STDOUT.sync = true
@@ -96,6 +97,20 @@ def parse_args(argv = ARGV)
opt.on('--gnumake') {gnumake = true}
opt.on('--debug-symbols=SUFFIX', /\w+/) {|name| $debug_symbols = ".#{name}"}
+ unless $install_procs.empty?
+ w = (w = ENV["COLUMNS"] and (w = w.to_i) > 80) ? w - 30 : 50
+ opt.on("\n""Types for --install and --exclude:")
+ mesg = +" "
+ $install_procs.each_key do |t|
+ if mesg.size + t.size > w
+ opt.on(mesg)
+ mesg = +" "
+ end
+ mesg << " " << t.to_s
+ end
+ opt.on(mesg)
+ end
+
opt.order!(argv) do |v|
case v
when /\AINSTALL[-_]([-\w]+)=(.*)/
@@ -205,15 +220,20 @@ def ln_sf(src, dest)
end
$made_dirs = {}
+
+def dir_creating(dir)
+ $made_dirs.fetch(dir) do
+ $made_dirs[dir] = true
+ $installed_list.puts(File.join(dir, "")) if $installed_list
+ yield if defined?(yield)
+ end
+end
+
def makedirs(dirs)
dirs = fu_list(dirs)
dirs.collect! do |dir|
realdir = with_destdir(dir)
- realdir unless $made_dirs.fetch(dir) do
- $made_dirs[dir] = true
- $installed_list.puts(File.join(dir, "")) if $installed_list
- File.directory?(realdir)
- end
+ realdir unless dir_creating(dir) {File.directory?(realdir)}
end.compact!
super(dirs, :mode => $dir_mode) unless dirs.empty?
end
@@ -346,6 +366,13 @@ rubyw_install_name = CONFIG["rubyw_install_name"]
goruby_install_name = "go" + ruby_install_name
bindir = CONFIG["bindir", true]
+if CONFIG["libdirname"] == "archlibdir"
+ libexecdir = MAKEFILE_CONFIG["archlibdir"].dup
+ unless libexecdir.sub!(/\$\(lib\K(?=dir\))/) {"exec"}
+ libexecdir = "$(libexecdir)/$(arch)"
+ end
+ archbindir = RbConfig.expand(libexecdir) + "/bin"
+end
libdir = CONFIG[CONFIG.fetch("libdirname", "libdir"), true]
rubyhdrdir = CONFIG["rubyhdrdir", true]
archhdrdir = CONFIG["rubyarchhdrdir"] || (rubyhdrdir + "/" + CONFIG['arch'])
@@ -369,106 +396,6 @@ load_relative = CONFIG["LIBRUBY_RELATIVE"] == 'yes'
rdoc_noinst = %w[created.rid]
-install?(:local, :arch, :bin, :'bin-arch') do
- prepare "binary commands", bindir
-
- install ruby_install_name+exeext, bindir, :mode => $prog_mode, :strip => $strip
- if rubyw_install_name and !rubyw_install_name.empty?
- install rubyw_install_name+exeext, bindir, :mode => $prog_mode, :strip => $strip
- end
- # emcc produces ruby and ruby.wasm, the first is a JavaScript file of runtime support
- # to load and execute the second .wasm file. Both are required to execute ruby
- if RUBY_PLATFORM =~ /emscripten/ and File.exist? ruby_install_name+".wasm"
- install ruby_install_name+".wasm", bindir, :mode => $prog_mode, :strip => $strip
- end
- if File.exist? goruby_install_name+exeext
- install goruby_install_name+exeext, bindir, :mode => $prog_mode, :strip => $strip
- end
- if enable_shared and dll != lib
- install dll, bindir, :mode => $prog_mode, :strip => $strip
- end
-end
-
-install?(:local, :arch, :lib, :'lib-arch') do
- prepare "base libraries", libdir
-
- install lib, libdir, :mode => $prog_mode, :strip => $strip unless lib == arc
- install arc, libdir, :mode => $data_mode unless CONFIG["INSTALL_STATIC_LIBRARY"] == "no"
- if dll == lib and dll != arc
- for link in CONFIG["LIBRUBY_ALIASES"].split - [File.basename(dll)]
- ln_sf(dll, File.join(libdir, link))
- end
- end
-
- prepare "arch files", archlibdir
- install "rbconfig.rb", archlibdir, :mode => $data_mode
- if CONFIG["ARCHFILE"]
- for file in CONFIG["ARCHFILE"].split
- install file, archlibdir, :mode => $data_mode
- end
- end
-end
-
-install?(:local, :arch, :data) do
- pc = CONFIG["ruby_pc"]
- if pc and File.file?(pc) and File.size?(pc)
- prepare "pkgconfig data", pkgconfigdir = File.join(libdir, "pkgconfig")
- install pc, pkgconfigdir, :mode => $data_mode
- end
-end
-
-install?(:ext, :arch, :'ext-arch') do
- prepare "extension objects", archlibdir
- noinst = %w[-* -*/] | (CONFIG["no_install_files"] || "").split
- install_recursive("#{$extout}/#{CONFIG['arch']}", archlibdir, :no_install => noinst, :mode => $prog_mode, :strip => $strip)
- prepare "extension objects", sitearchlibdir
- prepare "extension objects", vendorarchlibdir
- if extso = File.read("exts.mk")[/^EXTSO[ \t]*=[ \t]*((?:.*\\\n)*.*)/, 1] and
- !(extso = extso.gsub(/\\\n/, '').split).empty?
- libpathenv = CONFIG["LIBPATHENV"]
- dest = CONFIG[!libpathenv || libpathenv == "PATH" ? "bindir" : "libdir"]
- prepare "external libraries", dest
- for file in extso
- install file, dest, :mode => $prog_mode
- end
- end
-end
-install?(:ext, :arch, :hdr, :'arch-hdr', :'hdr-arch') do
- prepare "extension headers", archhdrdir
- install_recursive("#{$extout}/include/#{CONFIG['arch']}", archhdrdir, :glob => "*.h", :mode => $data_mode)
- install_recursive("#{$extout}/include/#{CONFIG['arch']}", archhdrdir, :glob => "rb_mjit_header-*.obj", :mode => $data_mode)
- install_recursive("#{$extout}/include/#{CONFIG['arch']}", archhdrdir, :glob => "rb_mjit_header-*.pch", :mode => $data_mode)
-end
-install?(:ext, :comm, :'ext-comm') do
- prepare "extension scripts", rubylibdir
- install_recursive("#{$extout}/common", rubylibdir, :mode => $data_mode)
- prepare "extension scripts", sitelibdir
- prepare "extension scripts", vendorlibdir
-end
-install?(:ext, :comm, :hdr, :'comm-hdr', :'hdr-comm') do
- hdrdir = rubyhdrdir + "/ruby"
- prepare "extension headers", hdrdir
- install_recursive("#{$extout}/include/ruby", hdrdir, :glob => "*.h", :mode => $data_mode)
-end
-
-install?(:doc, :rdoc) do
- if $rdocdir
- ridatadir = File.join(CONFIG['ridir'], CONFIG['ruby_version'], "system")
- prepare "rdoc", ridatadir
- install_recursive($rdocdir, ridatadir, :no_install => rdoc_noinst, :mode => $data_mode)
- end
-end
-install?(:doc, :html) do
- if $htmldir
- prepare "html-docs", docdir
- install_recursive($htmldir, docdir+"/html", :no_install => rdoc_noinst, :mode => $data_mode)
- end
-end
-install?(:doc, :capi) do
- prepare "capi-docs", docdir
- install_recursive "doc/capi", docdir+"/capi", :mode => $data_mode
-end
-
prolog_script = <<EOS
bindir="#{load_relative ? '${0%/*}' : bindir.gsub(/\"/, '\\\\"')}"
EOS
@@ -584,129 +511,6 @@ $script_installer = Class.new(installer) do
break new(ruby_shebang, ruby_bin, ruby_install_name, nil, trans)
end
-install?(:local, :comm, :bin, :'bin-comm') do
- prepare "command scripts", bindir
-
- install_recursive(File.join(srcdir, "bin"), bindir, :maxdepth => 1) do |src, cmd|
- $script_installer.install(src, cmd)
- end
-end
-
-install?(:local, :comm, :lib) do
- prepare "library scripts", rubylibdir
- noinst = %w[*.txt *.rdoc *.gemspec]
- install_recursive(File.join(srcdir, "lib"), rubylibdir, :no_install => noinst, :mode => $data_mode)
-end
-
-install?(:local, :comm, :hdr, :'comm-hdr') do
- prepare "common headers", rubyhdrdir
-
- noinst = []
- unless RUBY_PLATFORM =~ /mswin|mingw|bccwin/
- noinst << "win32.h"
- end
- noinst = nil if noinst.empty?
- install_recursive(File.join(srcdir, "include"), rubyhdrdir, :no_install => noinst, :glob => "*.{h,hpp}", :mode => $data_mode)
-end
-
-install?(:local, :comm, :man) do
- mdocs = Dir["#{srcdir}/man/*.[1-9]"]
- prepare "manpages", mandir, ([] | mdocs.collect {|mdoc| mdoc[/\d+$/]}).sort.collect {|sec| "man#{sec}"}
-
- case $mantype
- when /\.(?:(gz)|bz2)\z/
- compress = $1 ? "gzip" : "bzip2"
- suffix = $&
- end
- mandir = File.join(mandir, "man")
- has_goruby = File.exist?(goruby_install_name+exeext)
- require File.join(srcdir, "tool/mdoc2man.rb") if /\Adoc\b/ !~ $mantype
- mdocs.each do |mdoc|
- next unless File.file?(mdoc) and File.read(mdoc, 1) == '.'
- base = File.basename(mdoc)
- if base == "goruby.1"
- next unless has_goruby
- end
-
- destdir = mandir + (section = mdoc[/\d+$/])
- destname = ruby_install_name.sub(/ruby/, base.chomp(".#{section}"))
- destfile = File.join(destdir, "#{destname}.#{section}")
-
- if /\Adoc\b/ =~ $mantype
- if compress
- begin
- w = IO.popen(compress, "rb", in: mdoc, &:read)
- rescue
- else
- destfile << suffix
- end
- end
- if w
- open_for_install(destfile, $data_mode) {w}
- else
- install mdoc, destfile, :mode => $data_mode
- end
- else
- class << (w = [])
- alias print push
- end
- if File.basename(mdoc).start_with?('bundle') ||
- File.basename(mdoc).start_with?('gemfile')
- w = File.read(mdoc)
- else
- File.open(mdoc) {|r| Mdoc2Man.mdoc2man(r, w)}
- w = w.join("")
- end
- if compress
- begin
- w = IO.popen(compress, "r+b") do |f|
- Thread.start {f.write w; f.close_write}
- f.read
- end
- rescue
- else
- destfile << suffix
- end
- end
- open_for_install(destfile, $data_mode) {w}
- end
- end
-end
-
-install?(:dbg, :nodefault) do
- prepare "debugger commands", bindir
- prepare "debugger scripts", rubylibdir
- conf = RbConfig::MAKEFILE_CONFIG.merge({"prefix"=>"${prefix#/}"})
- Dir.glob(File.join(srcdir, "template/ruby-*db.in")) do |src|
- cmd = $script_installer.transform(File.basename(src, ".in"))
- open_for_install(File.join(bindir, cmd), $script_mode) {
- RbConfig.expand(File.read(src), conf)
- }
- end
- Dir.glob(File.join(srcdir, "misc/lldb_*")) do |src|
- if File.directory?(src)
- install_recursive src, File.join(rubylibdir, File.basename(src))
- else
- install src, rubylibdir
- end
- end
- install File.join(srcdir, ".gdbinit"), File.join(rubylibdir, "gdbinit")
- if $debug_symbols
- {
- ruby_install_name => bindir,
- rubyw_install_name => bindir,
- goruby_install_name => bindir,
- dll => libdir,
- }.each do |src, dest|
- next if src.empty?
- src += $debug_symbols
- if File.directory?(src)
- install_recursive src, File.join(dest, src)
- end
- end
- end
-end
-
module RbInstall
def self.no_write(options = nil)
u = File.umask(0022)
@@ -745,47 +549,108 @@ module RbInstall
end
def collect
- ruby_libraries.sort
+ requirable_features.sort
+ end
+
+ private
+
+ def features_from_makefile(makefile_path)
+ makefile = File.read(makefile_path)
+
+ name = makefile[/^TARGET[ \t]*=[ \t]*((?:.*\\\n)*.*)/, 1]
+ return [] if name.nil? || name.empty?
+
+ feature = makefile[/^DLLIB[ \t]*=[ \t]*((?:.*\\\n)*.*)/, 1]
+ feature = feature.sub("$(TARGET)", name)
+
+ target_prefix = makefile[/^target_prefix[ \t]*=[ \t]*((?:.*\\\n)*.*)/, 1]
+ feature = File.join(target_prefix.delete_prefix("/"), feature) unless target_prefix.empty?
+
+ Array(feature)
end
class Ext < self
- def skip_install?(files)
+ def requirable_features
# install ext only when it's configured
- !File.exist?("#{$ext_build_dir}/#{relative_base}/Makefile")
+ return [] unless File.exist?(makefile_path)
+
+ ruby_features + ext_features
+ end
+
+ private
+
+ def ruby_features
+ Dir.glob("**/*.rb", base: "#{makefile_dir}/lib")
+ end
+
+ def ext_features
+ features_from_makefile(makefile_path)
+ end
+
+ def makefile_path
+ if File.exist?("#{makefile_dir}/Makefile")
+ "#{makefile_dir}/Makefile"
+ else
+ # for out-of-place build
+ "#{$ext_build_dir}/#{relative_base}/Makefile"
+ end
end
- def ruby_libraries
- Dir.glob("lib/**/*.rb", base: "#{srcdir}/ext/#{relative_base}")
+ def makefile_dir
+ "#{root}/#{relative_base}"
+ end
+
+ def root
+ File.expand_path($ext_build_dir, srcdir)
end
end
class Lib < self
- def skip_install?(files)
- files.empty?
+ def requirable_features
+ ruby_features + ext_features
end
- def ruby_libraries
+ private
+
+ def ruby_features
gemname = File.basename(gemspec, ".gemspec")
base = relative_base || gemname
# for lib/net/net-smtp.gemspec
if m = /.*(?=-(.*)\z)/.match(gemname)
base = File.join(base, *m.to_a.select {|n| !base.include?(n)})
end
- files = Dir.glob("lib/#{base}{.rb,/**/*.rb}", base: srcdir)
+ files = Dir.glob("#{base}{.rb,/**/*.rb}", base: root)
if !relative_base and files.empty? # no files at the toplevel
# pseudo gem like ruby2_keywords
- files << "lib/#{gemname}.rb"
+ files << "#{gemname}.rb"
end
case gemname
when "net-http"
- files << "lib/net/https.rb"
+ files << "net/https.rb"
when "optparse"
- files << "lib/optionparser.rb"
+ files << "optionparser.rb"
end
files
end
+
+ def ext_features
+ loaded_gemspec = load_gemspec("#{root}/#{gemspec}")
+ extension = loaded_gemspec.extensions.first
+ return [] unless extension
+
+ extconf = File.expand_path(extension, srcdir)
+ ext_build_dir = File.dirname(extconf)
+ makefile_path = "#{ext_build_dir}/Makefile"
+ return [] unless File.exist?(makefile_path)
+
+ features_from_makefile(makefile_path)
+ end
+
+ def root
+ "#{srcdir}/lib"
+ end
end
end
end
@@ -823,10 +688,7 @@ module RbInstall
end
end
- class GemInstaller < Gem::Installer
- end
-
- class UnpackedInstaller < GemInstaller
+ class UnpackedInstaller < Gem::Installer
def write_cache_file
end
@@ -850,11 +712,6 @@ module RbInstall
super
end
- def generate_bin_script(filename, bindir)
- return if same_bin_script?(filename, bindir)
- super
- end
-
def same_bin_script?(filename, bindir)
path = File.join(bindir, formatted_program_filename(filename))
begin
@@ -873,11 +730,10 @@ module RbInstall
super unless $dryrun
$installed_list.puts(without_destdir(default_spec_file)) if $installed_list
end
- end
- class GemInstaller
def install
spec.post_install_message = nil
+ dir_creating(without_destdir(gem_dir))
RbInstall.no_write(options) {super}
end
@@ -886,6 +742,7 @@ module RbInstall
end
def generate_bin_script(filename, bindir)
+ return if same_bin_script?(filename, bindir)
name = formatted_program_filename(filename)
unless $dryrun
super
@@ -907,29 +764,23 @@ module RbInstall
end
end
-# :startdoc:
-
-install?(:ext, :comm, :gem, :'default-gems', :'default-gems-comm') do
- install_default_gem('lib', srcdir, bindir)
-end
-install?(:ext, :arch, :gem, :'default-gems', :'default-gems-arch') do
- install_default_gem('ext', srcdir, bindir)
-end
-
def load_gemspec(file, base = nil)
file = File.realpath(file)
code = File.read(file, encoding: "utf-8:-")
+
+ files = []
+ Dir.glob("**/*", File::FNM_DOTMATCH, base: base) do |n|
+ case File.basename(n); when ".", ".."; next; end
+ next if File.directory?(File.join(base, n))
+ files << n.dump
+ end if base
code.gsub!(/(?:`git[^\`]*`|%x\[git[^\]]*\])\.split\([^\)]*\)/m) do
- files = []
- if base
- Dir.glob("**/*", File::FNM_DOTMATCH, base: base) do |n|
- case File.basename(n); when ".", ".."; next; end
- next if File.directory?(File.join(base, n))
- files << n.dump
- end
- end
"[" + files.join(", ") + "]"
end
+ code.gsub!(/IO\.popen\(.*git.*?\)/) do
+ "[" + files.join(", ") + "] || itself"
+ end
+
spec = eval(code, binding, file)
unless Gem::Specification === spec
raise TypeError, "[#{file}] isn't a Gem::Specification (#{spec.class} instead)."
@@ -967,7 +818,7 @@ def install_default_gem(dir, srcdir, bindir)
spec = load_gemspec("#{base}/#{src}")
file_collector = RbInstall::Specs::FileCollector.for(srcdir, dir, src)
files = file_collector.collect
- if file_collector.skip_install?(files)
+ if files.empty?
next
end
spec.files = files
@@ -990,6 +841,261 @@ def install_default_gem(dir, srcdir, bindir)
end
end
+# :startdoc:
+
+install?(:local, :arch, :bin, :'bin-arch') do
+ prepare "binary commands", (dest = archbindir || bindir)
+
+ def (bins = []).add(name)
+ push(name)
+ name
+ end
+
+ install bins.add(ruby_install_name+exeext), dest, :mode => $prog_mode, :strip => $strip
+ if rubyw_install_name and !rubyw_install_name.empty?
+ install bins.add(rubyw_install_name+exeext), dest, :mode => $prog_mode, :strip => $strip
+ end
+ # emcc produces ruby and ruby.wasm, the first is a JavaScript file of runtime support
+ # to load and execute the second .wasm file. Both are required to execute ruby
+ if RUBY_PLATFORM =~ /emscripten/ and File.exist? ruby_install_name+".wasm"
+ install bins.add(ruby_install_name+".wasm"), dest, :mode => $prog_mode, :strip => $strip
+ end
+ if File.exist? goruby_install_name+exeext
+ install bins.add(goruby_install_name+exeext), dest, :mode => $prog_mode, :strip => $strip
+ end
+ if enable_shared and dll != lib
+ install bins.add(dll), dest, :mode => $prog_mode, :strip => $strip
+ end
+ if archbindir
+ prepare "binary command links", bindir
+ relpath = Path.relative(archbindir, bindir)
+ bins.each do |f|
+ ln_sf(File.join(relpath, f), File.join(bindir, f))
+ end
+ end
+end
+
+install?(:local, :arch, :lib, :'lib-arch') do
+ prepare "base libraries", libdir
+
+ install lib, libdir, :mode => $prog_mode, :strip => $strip unless lib == arc
+ install arc, libdir, :mode => $data_mode unless CONFIG["INSTALL_STATIC_LIBRARY"] == "no"
+ if dll == lib and dll != arc
+ for link in CONFIG["LIBRUBY_ALIASES"].split - [File.basename(dll)]
+ ln_sf(dll, File.join(libdir, link))
+ end
+ end
+
+ prepare "arch files", archlibdir
+ install "rbconfig.rb", archlibdir, :mode => $data_mode
+ if CONFIG["ARCHFILE"]
+ for file in CONFIG["ARCHFILE"].split
+ install file, archlibdir, :mode => $data_mode
+ end
+ end
+end
+
+install?(:local, :arch, :data) do
+ pc = CONFIG["ruby_pc"]
+ if pc and File.file?(pc) and File.size?(pc)
+ prepare "pkgconfig data", pkgconfigdir = File.join(libdir, "pkgconfig")
+ install pc, pkgconfigdir, :mode => $data_mode
+ if (pkgconfig_base = CONFIG["libdir", true]) != libdir
+ prepare "pkgconfig data link", File.join(pkgconfig_base, "pkgconfig")
+ ln_sf(File.join("..", Path.relative(pkgconfigdir, pkgconfig_base), pc),
+ File.join(pkgconfig_base, "pkgconfig", pc))
+ end
+ end
+end
+
+install?(:ext, :arch, :'ext-arch') do
+ prepare "extension objects", archlibdir
+ noinst = %w[-* -*/] | (CONFIG["no_install_files"] || "").split
+ install_recursive("#{$extout}/#{CONFIG['arch']}", archlibdir, :no_install => noinst, :mode => $prog_mode, :strip => $strip)
+ prepare "extension objects", sitearchlibdir
+ prepare "extension objects", vendorarchlibdir
+ if extso = File.read("exts.mk")[/^EXTSO[ \t]*=[ \t]*((?:.*\\\n)*.*)/, 1] and
+ !(extso = extso.gsub(/\\\n/, '').split).empty?
+ libpathenv = CONFIG["LIBPATHENV"]
+ dest = CONFIG[!libpathenv || libpathenv == "PATH" ? "bindir" : "libdir"]
+ prepare "external libraries", dest
+ for file in extso
+ install file, dest, :mode => $prog_mode
+ end
+ end
+end
+
+install?(:ext, :arch, :hdr, :'arch-hdr', :'hdr-arch') do
+ prepare "extension headers", archhdrdir
+ install_recursive("#{$extout}/include/#{CONFIG['arch']}", archhdrdir, :glob => "*.h", :mode => $data_mode)
+ install_recursive("#{$extout}/include/#{CONFIG['arch']}", archhdrdir, :glob => "rb_rjit_header-*.obj", :mode => $data_mode)
+ install_recursive("#{$extout}/include/#{CONFIG['arch']}", archhdrdir, :glob => "rb_rjit_header-*.pch", :mode => $data_mode)
+end
+
+install?(:ext, :comm, :'ext-comm') do
+ prepare "extension scripts", rubylibdir
+ install_recursive("#{$extout}/common", rubylibdir, :mode => $data_mode)
+ prepare "extension scripts", sitelibdir
+ prepare "extension scripts", vendorlibdir
+end
+
+install?(:ext, :comm, :hdr, :'comm-hdr', :'hdr-comm') do
+ hdrdir = rubyhdrdir + "/ruby"
+ prepare "extension headers", hdrdir
+ install_recursive("#{$extout}/include/ruby", hdrdir, :glob => "*.h", :mode => $data_mode)
+end
+
+install?(:doc, :rdoc) do
+ if $rdocdir
+ ridatadir = File.join(CONFIG['ridir'], CONFIG['ruby_version'], "system")
+ prepare "rdoc", ridatadir
+ install_recursive($rdocdir, ridatadir, :no_install => rdoc_noinst, :mode => $data_mode)
+ end
+end
+
+install?(:doc, :html) do
+ if $htmldir
+ prepare "html-docs", docdir
+ install_recursive($htmldir, docdir+"/html", :no_install => rdoc_noinst, :mode => $data_mode)
+ end
+end
+
+install?(:doc, :capi) do
+ prepare "capi-docs", docdir
+ install_recursive "doc/capi", docdir+"/capi", :mode => $data_mode
+end
+
+install?(:local, :comm, :bin, :'bin-comm') do
+ prepare "command scripts", bindir
+
+ install_recursive(File.join(srcdir, "bin"), bindir, :maxdepth => 1) do |src, cmd|
+ $script_installer.install(src, cmd)
+ end
+end
+
+install?(:local, :comm, :lib) do
+ prepare "library scripts", rubylibdir
+ noinst = %w[*.txt *.rdoc *.gemspec]
+ install_recursive(File.join(srcdir, "lib"), rubylibdir, :no_install => noinst, :mode => $data_mode)
+end
+
+install?(:local, :comm, :hdr, :'comm-hdr') do
+ prepare "common headers", rubyhdrdir
+
+ noinst = []
+ unless RUBY_PLATFORM =~ /mswin|mingw|bccwin/
+ noinst << "win32.h"
+ end
+ noinst = nil if noinst.empty?
+ install_recursive(File.join(srcdir, "include"), rubyhdrdir, :no_install => noinst, :glob => "*.{h,hpp}", :mode => $data_mode)
+end
+
+install?(:local, :comm, :man) do
+ mdocs = Dir["#{srcdir}/man/*.[1-9]"]
+ prepare "manpages", mandir, ([] | mdocs.collect {|mdoc| mdoc[/\d+$/]}).sort.collect {|sec| "man#{sec}"}
+
+ case $mantype
+ when /\.(?:(gz)|bz2)\z/
+ compress = $1 ? "gzip" : "bzip2"
+ suffix = $&
+ end
+ mandir = File.join(mandir, "man")
+ has_goruby = File.exist?(goruby_install_name+exeext)
+ require File.join(srcdir, "tool/mdoc2man.rb") if /\Adoc\b/ !~ $mantype
+ mdocs.each do |mdoc|
+ next unless File.file?(mdoc) and File.read(mdoc, 1) == '.'
+ base = File.basename(mdoc)
+ if base == "goruby.1"
+ next unless has_goruby
+ end
+
+ destdir = mandir + (section = mdoc[/\d+$/])
+ destname = ruby_install_name.sub(/ruby/, base.chomp(".#{section}"))
+ destfile = File.join(destdir, "#{destname}.#{section}")
+
+ if /\Adoc\b/ =~ $mantype
+ if compress
+ begin
+ w = IO.popen(compress, "rb", in: mdoc, &:read)
+ rescue
+ else
+ destfile << suffix
+ end
+ end
+ if w
+ open_for_install(destfile, $data_mode) {w}
+ else
+ install mdoc, destfile, :mode => $data_mode
+ end
+ else
+ class << (w = [])
+ alias print push
+ end
+ if File.basename(mdoc).start_with?('bundle') ||
+ File.basename(mdoc).start_with?('gemfile')
+ w = File.read(mdoc)
+ else
+ File.open(mdoc) {|r| Mdoc2Man.mdoc2man(r, w)}
+ w = w.join("")
+ end
+ if compress
+ begin
+ w = IO.popen(compress, "r+b") do |f|
+ Thread.start {f.write w; f.close_write}
+ f.read
+ end
+ rescue
+ else
+ destfile << suffix
+ end
+ end
+ open_for_install(destfile, $data_mode) {w}
+ end
+ end
+end
+
+install?(:dbg, :nodefault) do
+ prepare "debugger commands", bindir
+ prepare "debugger scripts", rubylibdir
+ conf = MAKEFILE_CONFIG.merge({"prefix"=>"${prefix#/}"})
+ Dir.glob(File.join(srcdir, "template/ruby-*db.in")) do |src|
+ cmd = $script_installer.transform(File.basename(src, ".in"))
+ open_for_install(File.join(bindir, cmd), $script_mode) {
+ RbConfig.expand(File.read(src), conf)
+ }
+ end
+ Dir.glob(File.join(srcdir, "misc/lldb_*")) do |src|
+ if File.directory?(src)
+ install_recursive src, File.join(rubylibdir, File.basename(src))
+ else
+ install src, rubylibdir
+ end
+ end
+ install File.join(srcdir, ".gdbinit"), File.join(rubylibdir, "gdbinit")
+ if $debug_symbols
+ {
+ ruby_install_name => archbindir || bindir,
+ rubyw_install_name => archbindir || bindir,
+ goruby_install_name => archbindir || bindir,
+ dll => libdir,
+ }.each do |src, dest|
+ next if src.empty?
+ src += $debug_symbols
+ if File.directory?(src)
+ install_recursive src, File.join(dest, src)
+ end
+ end
+ end
+end
+
+install?(:ext, :comm, :gem, :'default-gems', :'default-gems-comm') do
+ install_default_gem('lib', srcdir, bindir)
+end
+
+install?(:ext, :arch, :gem, :'default-gems', :'default-gems-arch') do
+ install_default_gem('ext', srcdir, bindir)
+end
+
install?(:ext, :comm, :gem, :'bundled-gems') do
gem_dir = Gem.default_dir
install_dir = with_destdir(gem_dir)
@@ -1026,13 +1132,22 @@ install?(:ext, :comm, :gem, :'bundled-gems') do
File.foreach("#{srcdir}/gems/bundled_gems") do |name|
next if /^\s*(?:#|$)/ =~ name
next unless /^(\S+)\s+(\S+).*/ =~ name
+ gem = $1
gem_name = "#$1-#$2"
- path = "#{srcdir}/.bundle/specifications/#{gem_name}.gemspec"
+ # Try to find the original gemspec file
+ path = "#{srcdir}/.bundle/gems/#{gem_name}/#{gem}.gemspec"
unless File.exist?(path)
+ # Try to find the gemspec file for C ext gems
+ # ex .bundle/gems/debug-1.7.1/debug-1.7.1.gemspec
+ # This gemspec keep the original dependencies
path = "#{srcdir}/.bundle/gems/#{gem_name}/#{gem_name}.gemspec"
unless File.exist?(path)
- skipped[gem_name] = "gemspec not found"
- next
+ # Try to find the gemspec file for gems that hasn't own gemspec
+ path = "#{srcdir}/.bundle/specifications/#{gem_name}.gemspec"
+ unless File.exist?(path)
+ skipped[gem_name] = "gemspec not found"
+ next
+ end
end
end
spec = load_gemspec(path, "#{srcdir}/.bundle/gems/#{gem_name}")
@@ -1044,6 +1159,11 @@ install?(:ext, :comm, :gem, :'bundled-gems') do
skipped[gem_name] = "full name unmatch #{spec.full_name}"
next
end
+ # Skip install C ext bundled gem if it is build failed or not found
+ if !spec.extensions.empty? && !File.exist?("#{build_dir}/#{gem_name}/gem.build_complete")
+ skipped[gem_name] = "extensions not found or build failed #{spec.full_name}"
+ next
+ end
spec.extension_dir = "#{extensions_dir}/#{spec.full_name}"
package = RbInstall::DirPackage.new spec
ins = RbInstall::UnpackedInstaller.new(package, options)
@@ -1085,7 +1205,6 @@ installs = $install.map do |inst|
end
installs.flatten!
installs -= $exclude.map {|exc| $install_procs[exc]}.flatten
-puts "Installing to #$destdir" unless installs.empty?
installs.each do |block|
dir = Dir.pwd
begin
@@ -1094,5 +1213,9 @@ installs.each do |block|
Dir.chdir(dir)
end
end
+unless installs.empty? or $destdir.empty?
+ require_relative 'lib/colorize'
+ puts "Installed under #{Colorize.new.info($destdir)}"
+end
# vi:set sw=2: