* lib/rubygems/ext/builder.rb (Gem::Ext::Builder.make): Pass

DESTDIR via command line to override what's in MAKEFLAGS.  This
  fixes an installation problem under a package building
  environment where DESTDIR is specified in the (parent) command
  line. [Fixes GH-327]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41629 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
knu 2013-06-25 13:28:57 +00:00
Родитель 7565d728b6
Коммит 8cc3103722
6 изменённых файлов: 89 добавлений и 24 удалений

Просмотреть файл

@ -1,3 +1,11 @@
Tue Jun 25 22:28:07 2013 Akinori MUSHA <knu@iDaemons.org>
* lib/rubygems/ext/builder.rb (Gem::Ext::Builder.make): Pass
DESTDIR via command line to override what's in MAKEFLAGS. This
fixes an installation problem under a package building
environment where DESTDIR is specified in the (parent) command
line. [Fixes GH-327]
Tue Jun 25 21:43:13 2013 Tanaka Akira <akr@fsij.org> Tue Jun 25 21:43:13 2013 Tanaka Akira <akr@fsij.org>
* bignum.c (big2dbl): Use (BDIGIT)1 instead of 1UL. * bignum.c (big2dbl): Use (BDIGIT)1 instead of 1UL.

Просмотреть файл

@ -23,9 +23,14 @@ class Gem::Ext::Builder
make_program = (/mswin/ =~ RUBY_PLATFORM) ? 'nmake' : 'make' make_program = (/mswin/ =~ RUBY_PLATFORM) ? 'nmake' : 'make'
end end
['', ' install'].each do |target| ['', 'install'].each do |target|
cmd = "#{make_program}#{target}" # Pass DESTDIR via command line to override what's in MAKEFLAGS
run(cmd, results, "make#{target}") cmd = [
make_program,
'"DESTDIR=%s"' % ENV['DESTDIR'],
target
].join(' ').rstrip
run(cmd, results, "make #{target}".rstrip)
end end
end end

Просмотреть файл

@ -28,6 +28,7 @@ require 'rubygems/test_utilities'
require 'pp' require 'pp'
require 'zlib' require 'zlib'
require 'pathname' require 'pathname'
require 'shellwords'
Gem.load_yaml Gem.load_yaml
require 'rubygems/mock_gem_ui' require 'rubygems/mock_gem_ui'
@ -89,6 +90,63 @@ class Gem::TestCase < MiniTest::Unit::TestCase
refute File.exist?(path), msg refute File.exist?(path), msg
end end
def scan_make_command_lines(output)
output.scan(/^#{Regexp.escape make_command}(?:[[:blank:]].*)?$/)
end
def parse_make_command_line(line)
command, *args = line.shellsplit
targets = []
macros = {}
args.each do |arg|
case arg
when /\A(\w+)=/
macros[$1] = $'
else
targets << arg
end
end
targets << '' if targets.empty?
{
:command => command,
:targets => targets,
:macros => macros,
}
end
def assert_contains_make_command(target, output, msg = nil)
if output.match(/\n/)
msg = message(msg) {
'Expected output containing make command "%s": %s' % [
('%s %s' % [make_command, target]).rstrip,
output.inspect
]
}
else
msg = message(msg) {
'Expected make command "%s": %s' % [
('%s %s' % [make_command, target]).rstrip,
output.inspect
]
}
end
assert scan_make_command_lines(output).any? { |line|
make = parse_make_command_line(line)
if make[:targets].include?(target)
yield make, line if block_given?
true
else
false
end
}, msg
end
include Gem::DefaultUserInteraction include Gem::DefaultUserInteraction
undef_method :default_test if instance_methods.include? 'default_test' or undef_method :default_test if instance_methods.include? 'default_test' or

Просмотреть файл

@ -38,8 +38,8 @@ install (FILES test.txt DESTINATION bin)
assert_match \ assert_match \
%r%^cmake \. -DCMAKE_INSTALL_PREFIX=#{Regexp.escape @dest_path}%, output %r%^cmake \. -DCMAKE_INSTALL_PREFIX=#{Regexp.escape @dest_path}%, output
assert_match %r%#{Regexp.escape @ext}%, output assert_match %r%#{Regexp.escape @ext}%, output
assert_match %r%^#{Regexp.escape make_command}$%, output assert_contains_make_command '', output
assert_match %r%^#{Regexp.escape make_command} install$%, output assert_contains_make_command 'install', output
assert_match %r%test\.txt%, output assert_match %r%test\.txt%, output
end end
@ -82,8 +82,8 @@ install (FILES test.txt DESTINATION bin)
output = output.join "\n" output = output.join "\n"
assert_match %r%^#{make_command}%, output assert_contains_make_command '', output
assert_match %r%^#{make_command} install%, output assert_contains_make_command 'install', output
end end
end end

Просмотреть файл

@ -30,9 +30,9 @@ class TestGemExtConfigureBuilder < Gem::TestCase
assert_equal "sh ./configure --prefix=#{@dest_path}", output.shift assert_equal "sh ./configure --prefix=#{@dest_path}", output.shift
assert_equal "", output.shift assert_equal "", output.shift
assert_equal make_command, output.shift assert_contains_make_command '', output.shift
assert_match(/^ok$/m, output.shift) assert_match(/^ok$/m, output.shift)
assert_equal make_command + " install", output.shift assert_contains_make_command 'install', output.shift
assert_match(/^ok$/m, output.shift) assert_match(/^ok$/m, output.shift)
end end
@ -76,8 +76,8 @@ class TestGemExtConfigureBuilder < Gem::TestCase
Gem::Ext::ConfigureBuilder.build nil, nil, @dest_path, output Gem::Ext::ConfigureBuilder.build nil, nil, @dest_path, output
end end
assert_equal make_command, output[0] assert_contains_make_command '', output[0]
assert_equal "#{make_command} install", output[2] assert_contains_make_command 'install', output[2]
end end
end end

Просмотреть файл

@ -32,14 +32,8 @@ class TestGemExtExtConfBuilder < Gem::TestCase
assert_match(/^#{Gem.ruby} extconf.rb/, output[0]) assert_match(/^#{Gem.ruby} extconf.rb/, output[0])
assert_equal "creating Makefile\n", output[1] assert_equal "creating Makefile\n", output[1]
case RUBY_PLATFORM assert_contains_make_command '', output[2]
when /mswin/ then assert_contains_make_command 'install', output[4]
assert_equal "nmake", output[2]
assert_equal "nmake install", output[4]
else
assert_equal "make", output[2]
assert_equal "make install", output[4]
end
end end
def test_class_build_rbconfig_make_prog def test_class_build_rbconfig_make_prog
@ -56,8 +50,8 @@ class TestGemExtExtConfBuilder < Gem::TestCase
end end
assert_equal "creating Makefile\n", output[1] assert_equal "creating Makefile\n", output[1]
assert_equal make_command, output[2] assert_contains_make_command '', output[2]
assert_equal "#{make_command} install", output[4] assert_contains_make_command 'install', output[4]
ensure ensure
RbConfig::CONFIG['configure_args'] = configure_args RbConfig::CONFIG['configure_args'] = configure_args
end end
@ -80,7 +74,7 @@ class TestGemExtExtConfBuilder < Gem::TestCase
end end
assert_equal "creating Makefile\n", output[1] assert_equal "creating Makefile\n", output[1]
assert_equal "anothermake", output[2] assert_contains_make_command '', output[2]
ensure ensure
RbConfig::CONFIG['configure_args'] = configure_args RbConfig::CONFIG['configure_args'] = configure_args
ENV['make'] = env_make ENV['make'] = env_make
@ -132,8 +126,8 @@ checking for main\(\) in .*?nonexistent/m, error.message)
Gem::Ext::ExtConfBuilder.make @ext, output Gem::Ext::ExtConfBuilder.make @ext, output
end end
assert_equal make_command, output[0] assert_contains_make_command '', output[0]
assert_equal "#{make_command} install", output[2] assert_contains_make_command 'install', output[2]
end end
def test_class_make_no_Makefile def test_class_make_no_Makefile