Skip to content

Commit fb82ba2

Browse files
committed
merge revision(s) 41629: [Backport ruby#8533]
* 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 rubyGH-327] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@41635 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1 parent 9f11010 commit fb82ba2

File tree

7 files changed

+92
-27
lines changed

7 files changed

+92
-27
lines changed

ChangeLog

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
Wed Jun 26 02:25:52 2013 Akinori MUSHA <[email protected]>
2+
3+
* lib/rubygems/ext/builder.rb (Gem::Ext::Builder.make): Pass
4+
DESTDIR via command line to override what's in MAKEFLAGS. This
5+
fixes an installation problem under a package building
6+
environment where DESTDIR is specified in the (parent) command
7+
line. [Fixes GH-327]
8+
19
Tue Jun 25 00:12:19 2013 Zachary Scott <[email protected]>
210

311
* array.c: Return value in Array overview example found by @PragTob

lib/rubygems/ext/builder.rb

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,14 @@ def self.make(dest_path, results)
2323
make_program = (/mswin/ =~ RUBY_PLATFORM) ? 'nmake' : 'make'
2424
end
2525

26-
['', ' install'].each do |target|
27-
cmd = "#{make_program}#{target}"
28-
run(cmd, results, "make#{target}")
26+
['', 'install'].each do |target|
27+
# Pass DESTDIR via command line to override what's in MAKEFLAGS
28+
cmd = [
29+
make_program,
30+
'"DESTDIR=%s"' % ENV['DESTDIR'],
31+
target
32+
].join(' ').rstrip
33+
run(cmd, results, "make #{target}".rstrip)
2934
end
3035
end
3136

lib/rubygems/test_case.rb

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
require 'pp'
2929
require 'zlib'
3030
require 'pathname'
31+
require 'shellwords'
3132
Gem.load_yaml
3233

3334
require 'rubygems/mock_gem_ui'
@@ -89,6 +90,63 @@ def refute_path_exists path, msg = nil
8990
refute File.exist?(path), msg
9091
end
9192

93+
def scan_make_command_lines(output)
94+
output.scan(/^#{Regexp.escape make_command}(?:[[:blank:]].*)?$/)
95+
end
96+
97+
def parse_make_command_line(line)
98+
command, *args = line.shellsplit
99+
100+
targets = []
101+
macros = {}
102+
103+
args.each do |arg|
104+
case arg
105+
when /\A(\w+)=/
106+
macros[$1] = $'
107+
else
108+
targets << arg
109+
end
110+
end
111+
112+
targets << '' if targets.empty?
113+
114+
{
115+
:command => command,
116+
:targets => targets,
117+
:macros => macros,
118+
}
119+
end
120+
121+
def assert_contains_make_command(target, output, msg = nil)
122+
if output.match(/\n/)
123+
msg = message(msg) {
124+
'Expected output containing make command "%s": %s' % [
125+
('%s %s' % [make_command, target]).rstrip,
126+
output.inspect
127+
]
128+
}
129+
else
130+
msg = message(msg) {
131+
'Expected make command "%s": %s' % [
132+
('%s %s' % [make_command, target]).rstrip,
133+
output.inspect
134+
]
135+
}
136+
end
137+
138+
assert scan_make_command_lines(output).any? { |line|
139+
make = parse_make_command_line(line)
140+
141+
if make[:targets].include?(target)
142+
yield make, line if block_given?
143+
true
144+
else
145+
false
146+
end
147+
}, msg
148+
end
149+
92150
include Gem::DefaultUserInteraction
93151

94152
undef_method :default_test if instance_methods.include? 'default_test' or

test/rubygems/test_gem_ext_cmake_builder.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ def test_self_build
3838
assert_match \
3939
%r%^cmake \. -DCMAKE_INSTALL_PREFIX=#{Regexp.escape @dest_path}%, output
4040
assert_match %r%#{Regexp.escape @ext}%, output
41-
assert_match %r%^#{Regexp.escape make_command}$%, output
42-
assert_match %r%^#{Regexp.escape make_command} install$%, output
41+
assert_contains_make_command '', output
42+
assert_contains_make_command 'install', output
4343
assert_match %r%test\.txt%, output
4444
end
4545

@@ -82,8 +82,8 @@ def test_self_build_has_makefile
8282

8383
output = output.join "\n"
8484

85-
assert_match %r%^#{make_command}%, output
86-
assert_match %r%^#{make_command} install%, output
85+
assert_contains_make_command '', output
86+
assert_contains_make_command 'install', output
8787
end
8888

8989
end

test/rubygems/test_gem_ext_configure_builder.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ def test_self_build
3030

3131
assert_equal "sh ./configure --prefix=#{@dest_path}", output.shift
3232
assert_equal "", output.shift
33-
assert_equal make_command, output.shift
33+
assert_contains_make_command '', output.shift
3434
assert_match(/^ok$/m, output.shift)
35-
assert_equal make_command + " install", output.shift
35+
assert_contains_make_command 'install', output.shift
3636
assert_match(/^ok$/m, output.shift)
3737
end
3838

@@ -76,8 +76,8 @@ def test_self_build_has_makefile
7676
Gem::Ext::ConfigureBuilder.build nil, nil, @dest_path, output
7777
end
7878

79-
assert_equal make_command, output[0]
80-
assert_equal "#{make_command} install", output[2]
79+
assert_contains_make_command '', output[0]
80+
assert_contains_make_command 'install', output[2]
8181
end
8282

8383
end

test/rubygems/test_gem_ext_ext_conf_builder.rb

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,8 @@ def test_class_build
3232

3333
assert_match(/^#{Gem.ruby} extconf.rb/, output[0])
3434
assert_equal "creating Makefile\n", output[1]
35-
case RUBY_PLATFORM
36-
when /mswin/ then
37-
assert_equal "nmake", output[2]
38-
assert_equal "nmake install", output[4]
39-
else
40-
assert_equal "make", output[2]
41-
assert_equal "make install", output[4]
42-
end
35+
assert_contains_make_command '', output[2]
36+
assert_contains_make_command 'install', output[4]
4337
end
4438

4539
def test_class_build_rbconfig_make_prog
@@ -56,8 +50,8 @@ def test_class_build_rbconfig_make_prog
5650
end
5751

5852
assert_equal "creating Makefile\n", output[1]
59-
assert_equal make_command, output[2]
60-
assert_equal "#{make_command} install", output[4]
53+
assert_contains_make_command '', output[2]
54+
assert_contains_make_command 'install', output[4]
6155
ensure
6256
RbConfig::CONFIG['configure_args'] = configure_args
6357
end
@@ -80,7 +74,7 @@ def test_class_build_env_make
8074
end
8175

8276
assert_equal "creating Makefile\n", output[1]
83-
assert_equal "anothermake", output[2]
77+
assert_contains_make_command '', output[2]
8478
ensure
8579
RbConfig::CONFIG['configure_args'] = configure_args
8680
ENV['make'] = env_make
@@ -132,8 +126,8 @@ def test_class_make
132126
Gem::Ext::ExtConfBuilder.make @ext, output
133127
end
134128

135-
assert_equal make_command, output[0]
136-
assert_equal "#{make_command} install", output[2]
129+
assert_contains_make_command '', output[0]
130+
assert_contains_make_command 'install', output[2]
137131
end
138132

139133
def test_class_make_no_Makefile

version.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#define RUBY_VERSION "2.0.0"
2-
#define RUBY_RELEASE_DATE "2013-06-25"
3-
#define RUBY_PATCHLEVEL 241
2+
#define RUBY_RELEASE_DATE "2013-06-26"
3+
#define RUBY_PATCHLEVEL 242
44

55
#define RUBY_RELEASE_YEAR 2013
66
#define RUBY_RELEASE_MONTH 6
7-
#define RUBY_RELEASE_DAY 25
7+
#define RUBY_RELEASE_DAY 26
88

99
#include "ruby/version.h"
1010

0 commit comments

Comments
 (0)