ruby-changes:74139
From: nagachika <ko1@a...>
Date: Thu, 20 Oct 2022 21:35:38 +0900 (JST)
Subject: [ruby-changes:74139] 4bb62ee572 (ruby_3_1): merge revision(s) 6a8f1a9e5cd1c9c2b3c6925d8d3fa76a29dabf73:
https://git.ruby-lang.org/ruby.git/commit/?id=4bb62ee572 From 4bb62ee57285da427d73ba30e7d76f0f377c9936 Mon Sep 17 00:00:00 2001 From: nagachika <nagachika@r...> Date: Thu, 20 Oct 2022 21:33:39 +0900 Subject: merge revision(s) 6a8f1a9e5cd1c9c2b3c6925d8d3fa76a29dabf73: Copy from bundled gem source for test --- common.mk | 13 +++++++---- defs/gmake.mk | 4 ++++ tool/gem-unpack.rb | 63 +++++++++++++++++++++++++++++++++++------------------- 3 files changed, 54 insertions(+), 26 deletions(-) --- common.mk | 15 +++++++------ defs/gmake.mk | 4 ++++ tool/gem-unpack.rb | 63 +++++++++++++++++++++++++++++++++++------------------- version.h | 2 +- 4 files changed, 55 insertions(+), 29 deletions(-) diff --git a/common.mk b/common.mk index 622f21210c..e161e960ef 100644 --- a/common.mk +++ b/common.mk @@ -1349,7 +1349,7 @@ update-config_files: PHONY https://github.com/ruby/ruby/blob/trunk/common.mk#L1349 refresh-gems: update-bundled_gems prepare-gems prepare-gems: $(HAVE_BASERUBY:yes=update-gems) $(HAVE_BASERUBY:yes=extract-gems) -update-gems$(gnumake:yes=-nongnumake): PHONY +update-gems$(gnumake:yes=-sequential): PHONY $(ECHO) Downloading bundled gem files... $(Q) $(BASERUBY) -C "$(srcdir)" \ -I./tool -rdownloader -answ \ @@ -1363,17 +1363,20 @@ update-gems$(gnumake:yes=-nongnumake): PHONY https://github.com/ruby/ruby/blob/trunk/common.mk#L1363 -e 'FileUtils.rm_rf(old.map{'"|n|"'n.chomp(".gem")})' \ gems/bundled_gems -extract-gems$(gnumake:yes=-nongnumake): PHONY +extract-gems$(gnumake:yes=-sequential): PHONY $(ECHO) Extracting bundled gem files... $(Q) $(RUNRUBY) -C "$(srcdir)" \ -Itool -rgem-unpack -answ \ -e 'BEGIN {FileUtils.mkdir_p(d = ".bundle/gems")}' \ - -e 'BEGIN {FileUtils.mkdir_p(s = ".bundle/specifications")}' \ - -e 'BEGIN {d = ".bundle/gems"}' \ - -e 'gem, ver = *$$F' \ + -e 'gem, ver, _, rev = *$$F' \ -e 'next if !ver or /^#/=~gem' \ -e 'g = "#{gem}-#{ver}"' \ - -e 'File.directory?("#{d}/#{g}") or Gem.unpack("gems/#{g}.gem", ".bundle")' \ + -e 'if File.directory?("#{d}/#{g}")' \ + -e 'elsif rev and File.exist?(gs = "gems/src/#{gem}/#{gem}.gemspec")' \ + -e 'Gem.copy(gs, ".bundle")' \ + -e 'else' \ + -e 'Gem.unpack("gems/#{g}.gem", ".bundle")' \ + -e 'end' \ gems/bundled_gems update-bundled_gems: PHONY diff --git a/defs/gmake.mk b/defs/gmake.mk index 6143402ed3..242f902bce 100644 --- a/defs/gmake.mk +++ b/defs/gmake.mk @@ -289,6 +289,9 @@ gems/%.gem: https://github.com/ruby/ruby/blob/trunk/defs/gmake.mk#L289 -e 'File.unlink(*old) and' \ -e 'FileUtils.rm_rf(old.map{'"|n|"'n.chomp(".gem")})' +ifeq (,) +extract-gems: extract-gems-sequential +else extract-gems: | $(patsubst %,.bundle/gems/%,$(bundled-gems)) .bundle/gems/%: gems/%.gem | .bundle/gems @@ -299,6 +302,7 @@ extract-gems: | $(patsubst %,.bundle/gems/%,$(bundled-gems)) https://github.com/ruby/ruby/blob/trunk/defs/gmake.mk#L302 $(srcdir)/.bundle/gems: $(MAKEDIRS) $@ +endif ifneq ($(filter update-bundled_gems refresh-gems,$(MAKECMDGOALS)),) update-gems: update-bundled_gems diff --git a/tool/gem-unpack.rb b/tool/gem-unpack.rb index c50d47f797..6310c3f92a 100644 --- a/tool/gem-unpack.rb +++ b/tool/gem-unpack.rb @@ -5,30 +5,49 @@ require 'rubygems/package' https://github.com/ruby/ruby/blob/trunk/tool/gem-unpack.rb#L5 # This library is used by "make extract-gems" to # unpack bundled gem files. -def Gem.unpack(file, dir = ".") - pkg = Gem::Package.new(file) - spec = pkg.spec - target = spec.full_name - Gem.ensure_gem_subdirectories(dir) - gem_dir = File.join(dir, "gems", target) - pkg.extract_files gem_dir - spec_dir = spec.extensions.empty? ? "specifications" : File.join("gems", target) - File.binwrite(File.join(dir, spec_dir, "#{target}.gemspec"), spec.to_ruby) - unless spec.extensions.empty? - spec.dependencies.clear - File.binwrite(File.join(dir, spec_dir, ".bundled.#{target}.gemspec"), spec.to_ruby) +class << Gem + def unpack(file, *rest) + pkg = Gem::Package.new(file) + prepare_test(pkg.spec, *rest) {|dir| pkg.extract_files(dir)} + puts "Unpacked #{file}" end - if spec.bindir and spec.executables - bindir = File.join(dir, "bin") - Dir.mkdir(bindir) rescue nil - spec.executables.each do |exe| - File.open(File.join(bindir, exe), "wb", 0o777) {|f| - f.print "#!ruby\n", - %[load File.realpath("../gems/#{target}/#{spec.bindir}/#{exe}", __dir__)\n] - } + + def copy(path, *rest) + spec = Gem::Specification.load(path) + path = File.dirname(path) + prepare_test(spec, *rest) do |dir| + FileUtils.rm_rf(dir) + files = spec.files.reject {|f| f.start_with?(".git")} + dirs = files.map {|f| File.dirname(f) if f.include?("/")}.uniq + FileUtils.mkdir_p(dirs.map {|d| d ? "#{dir}/#{d}" : dir}.sort_by {|d| d.count("/")}) + files.each do |f| + File.copy_stream(File.join(path, f), File.join(dir, f)) + end end + puts "Copied #{path}" end - FileUtils.rm_rf(Dir.glob("#{gem_dir}/.git*")) - puts "Unpacked #{file}" + def prepare_test(spec, dir = ".") + target = spec.full_name + Gem.ensure_gem_subdirectories(dir) + gem_dir = File.join(dir, "gems", target) + yield gem_dir + spec_dir = spec.extensions.empty? ? "specifications" : File.join("gems", target) + File.binwrite(File.join(dir, spec_dir, "#{target}.gemspec"), spec.to_ruby) + unless spec.extensions.empty? + spec.dependencies.clear + File.binwrite(File.join(dir, spec_dir, ".bundled.#{target}.gemspec"), spec.to_ruby) + end + if spec.bindir and spec.executables + bindir = File.join(dir, "bin") + Dir.mkdir(bindir) rescue nil + spec.executables.each do |exe| + File.open(File.join(bindir, exe), "wb", 0o777) {|f| + f.print "#!ruby\n", + %[load File.realpath("../gems/#{target}/#{spec.bindir}/#{exe}", __dir__)\n] + } + end + end + FileUtils.rm_rf(Dir.glob("#{gem_dir}/.git*")) + end end diff --git a/version.h b/version.h index 2bdb143753..c601b75131 100644 --- a/version.h +++ b/version.h @@ -11,7 +11,7 @@ https://github.com/ruby/ruby/blob/trunk/version.h#L11 # define RUBY_VERSION_MINOR RUBY_API_VERSION_MINOR #define RUBY_VERSION_TEENY 3 #define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR -#define RUBY_PATCHLEVEL 118 +#define RUBY_PATCHLEVEL 119 #define RUBY_RELEASE_YEAR 2022 #define RUBY_RELEASE_MONTH 10 -- cgit v1.2.3 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/