From bb0a22a8c05994396aa316c242ff8816d8d0a259 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Wed, 6 Apr 2022 22:57:01 +0900 Subject: [PATCH] Obey spec file locations to rubygems --- common.mk | 3 ++- defs/gmake.mk | 2 +- tool/gem-unpack.rb | 5 +++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/common.mk b/common.mk index 7c552cba1e..b4adb2729c 100644 --- a/common.mk +++ b/common.mk @@ -1360,10 +1360,11 @@ extract-gems$(gnumake:yes=-nongnumake): PHONY $(Q) $(RUNRUBY) -C "$(srcdir)" \ -Itool -rfileutils -rgem-unpack -answ \ -e 'BEGIN {FileUtils.mkdir_p(d = ".bundle/gems")}' \ + -e 'BEGIN {FileUtils.mkdir_p(s = ".bundle/specifications")}' \ -e 'gem, ver = *$$F' \ -e 'next if !ver or /^#/=~gem' \ -e 'g = "#{gem}-#{ver}"' \ - -e 'File.directory?("#{d}/#{g}") or Gem.unpack("gems/#{g}.gem", d)' \ + -e 'File.directory?("#{d}/#{g}") or Gem.unpack("gems/#{g}.gem", d, s)' \ -e 'FileUtils.rm_rf("#{d}/#{g}/.github")' \ gems/bundled_gems diff --git a/defs/gmake.mk b/defs/gmake.mk index a625379a68..27e3e21cc4 100644 --- a/defs/gmake.mk +++ b/defs/gmake.mk @@ -295,7 +295,7 @@ extract-gems: | $(patsubst %,.bundle/gems/%,$(bundled-gems)) $(ECHO) Extracting bundle gem $*... $(Q) $(BASERUBY) -C "$(srcdir)" \ -Itool -rgem-unpack \ - -e 'Gem.unpack("gems/$(@F).gem", ".bundle/gems")' + -e 'Gem.unpack("gems/$(@F).gem", ".bundle/gems", ".bundle/specifications")' $(RMALL) "$(srcdir)/$(@:.gem=)/".git* $(srcdir)/.bundle/gems: diff --git a/tool/gem-unpack.rb b/tool/gem-unpack.rb index cb05719463..fe10b0e420 100644 --- a/tool/gem-unpack.rb +++ b/tool/gem-unpack.rb @@ -5,13 +5,14 @@ require 'rubygems/package' # This library is used by "make extract-gems" to # unpack bundled gem files. -def Gem.unpack(file, dir = nil) +def Gem.unpack(file, dir = nil, spec_dir = nil) pkg = Gem::Package.new(file) spec = pkg.spec target = spec.full_name target = File.join(dir, target) if dir pkg.extract_files target - spec_file = File.join(target, "#{spec.name}-#{spec.version}.gemspec") + FileUtils.mkdir_p(spec_dir ||= target) + spec_file = File.join(spec_dir, "#{spec.name}-#{spec.version}.gemspec") open(spec_file, 'wb') do |f| f.print spec.to_ruby end