forked from puppetlabs/puppet-runtime
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathruby-2.1.9.rb
198 lines (174 loc) · 8.22 KB
/
ruby-2.1.9.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
component "ruby-2.1.9" do |pkg, settings, platform|
pkg.version "2.1.9"
pkg.md5sum "d9d2109d3827789344cc3aceb8e1d697"
# rbconfig-update is used to munge rbconfigs after the fact.
pkg.add_source("file://resources/files/ruby/rbconfig-update.rb")
if platform.is_windows?
pkg.add_source "file://resources/files/ruby/windows_ruby_gem_wrapper.bat"
end
# PDK packages multiple rubies and we need to tweak some settings
# if this is not the *primary* ruby.
if (pkg.get_version != settings[:ruby_version])
# not primary ruby
# ensure we have config for this ruby
unless settings.has_key?(:additional_rubies) && settings[:additional_rubies].has_key?(pkg.get_version)
raise "missing config for additional ruby #{pkg.get_version}"
end
ruby_settings = settings[:additional_rubies][pkg.get_version]
ruby_dir = ruby_settings[:ruby_dir]
ruby_bindir = ruby_settings[:ruby_bindir]
host_ruby = ruby_settings[:host_ruby]
else
# primary ruby
ruby_dir = settings[:ruby_dir]
ruby_bindir = settings[:ruby_bindir]
host_ruby = settings[:host_ruby]
end
# Most ruby configuration happens in the base ruby config:
instance_eval File.read('configs/components/_base-ruby.rb')
# Configuration below should only be applicable to ruby 2.1.9
#########
# PATCHES
#########
base = 'resources/patches/ruby_219'
pkg.apply_patch "#{base}/libyaml_cve-2014-9130.patch"
# Patches from Ruby 2.4 security fixes. See the description and
# comments of RE-9323 for more details.
pkg.apply_patch "#{base}/cve-2017-0898.patch"
pkg.apply_patch "#{base}/cve-2017-10784.patch"
pkg.apply_patch "#{base}/cve-2017-14033.patch"
pkg.apply_patch "#{base}/cve-2017-14064.patch"
pkg.apply_patch "#{base}/cve-2017-17405.patch"
# Patches from Ruby 2.2.10 security fixes from March 2018. See
# RE-10480 for more details.
pkg.apply_patch "#{base}/cve-2018-8780.patch"
pkg.apply_patch "#{base}/cve-2018-6914.patch"
pkg.apply_patch "#{base}/cve-2018-8779.patch"
pkg.apply_patch "#{base}/cve-2018-8778.patch"
pkg.apply_patch "#{base}/cve-2018-8777-1.patch"
pkg.apply_patch "#{base}/cve-2018-8777-2.patch"
pkg.apply_patch "#{base}/cve-2017-17742.patch"
# Patches for https://www.debian.org/lts/security/2019/dla-2007
pkg.apply_patch "#{base}/cve-2019-16201.patch"
pkg.apply_patch "#{base}/cve-2019-16254.patch"
pkg.apply_patch "#{base}/cve-2019-16255.patch"
pkg.apply_patch "#{base}/cve-2019-15845.patch"
if platform.is_aix?
pkg.apply_patch "#{base}/aix_ruby_2.1_libpath_with_opt_dir.patch"
pkg.apply_patch "#{base}/aix_ruby_2.1_fix_proctitle.patch"
pkg.apply_patch "#{base}/aix_ruby_2.1_fix_make_test_failure.patch"
pkg.apply_patch "#{base}/Remove-O_CLOEXEC-check-for-AIX-builds.patch"
end
if platform.is_windows?
pkg.apply_patch "#{base}/windows_ruby_2.1_update_to_rubygems_2.4.5.patch"
pkg.apply_patch "#{base}/windows_ruby_2.1_fixup_generated_batch_files.patch"
pkg.apply_patch "#{base}/windows_remove_DL_deprecated_warning.patch"
pkg.apply_patch "#{base}/windows_ruby_2.1_update_to_rubygems_2.4.5.1.patch"
pkg.apply_patch "#{base}/windows_ruby_2.1_update_rbinstall.patch"
pkg.apply_patch "#{base}/windows_rubygems_cve_2017_0902_0899_0900_0901.patch"
else
pkg.apply_patch "#{base}/rubygems_cve_2017_0902_0899_0900_0901.patch"
end
####################
# ENVIRONMENT, FLAGS
####################
special_flags = " --prefix=#{ruby_dir} --with-opt-dir=#{settings[:prefix]} "
if platform.is_aix?
# This normalizes the build string to something like AIX 7.1.0.0 rather
# than AIX 7.1.0.2 or something
special_flags += " --build=#{settings[:platform_triple]} "
elsif platform.is_solaris? && platform.architecture == "sparc"
special_flags += " --with-baseruby=#{host_ruby} "
elsif platform.is_cross_compiled_linux?
special_flags += " --with-baseruby=#{host_ruby} "
elsif platform.is_windows?
special_flags = " CPPFLAGS='-DFD_SETSIZE=2048' debugflags=-g --prefix=#{ruby_dir} --with-opt-dir=#{settings[:prefix]} "
end
###########
# CONFIGURE
###########
# Here we set --enable-bundled-libyaml to ensure that the libyaml included in
# ruby is used, even if the build system has a copy of libyaml available
pkg.configure do
[
"bash configure \
--enable-shared \
--enable-bundled-libyaml \
--disable-install-doc \
--disable-install-rdoc \
#{settings[:host]} \
#{special_flags}"
]
end
#########
# INSTALL
#########
if platform.is_windows?
# Because the autogenerated batch wrappers for ruby built from source are
# not consistent with legacy builds, we removed the addition of the batch
# wrappers from the build of ruby and instead we will just put them in
# ourselves. note that we can use the same source file for all batch wrappers
# because the batch wrappers use the wrappers file name to find the source
# to execute (i.e. irb.bat will look to execute "irb" due to its filename).
#
# Note that this step must happen before the install step below.
pkg.install do
%w{erb gem irb rake rdoc ri}.map do |name|
"cp ../windows_ruby_gem_wrapper.bat #{ruby_bindir}/#{name}.bat"
end
end
end
target_doubles = {
'aarch64-redhat-linux' => 'aarch64-linux',
'ppc64-redhat-linux' => 'powerpc64-linux',
'ppc64le-redhat-linux' => 'powerpc64le-linux',
'powerpc64le-suse-linux' => 'powerpc64le-linux',
'powerpc64le-linux-gnu' => 'powerpc64le-linux',
'i386-pc-solaris2.10' => 'i386-solaris2.10',
'sparc-sun-solaris2.10' => 'sparc-solaris2.10',
'i386-pc-solaris2.11' => 'i386-solaris2.11',
'sparc-sun-solaris2.11' => 'sparc-solaris2.11',
'arm-linux-gnueabihf' => 'arm-linux-eabihf',
'arm-linux-gnueabi' => 'arm-linux-eabi',
'x86_64-w64-mingw32' => 'x64-mingw32',
'i686-w64-mingw32' => 'i386-mingw32'
}
if target_doubles.has_key?(settings[:platform_triple])
rbconfig_topdir = File.join(ruby_dir, 'lib', 'ruby', '2.1.0', target_doubles[settings[:platform_triple]])
else
rbconfig_topdir = "$$(#{settings[:ruby_bindir]}/ruby -e \"puts RbConfig::CONFIG[\\\"topdir\\\"]\")"
end
rbconfig_changes = {}
if platform.is_aix?
rbconfig_changes["CC"] = "gcc"
elsif platform.is_cross_compiled? || platform.is_solaris?
rbconfig_changes["CC"] = "gcc"
rbconfig_changes["warnflags"] = "-Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wno-tautological-compare -Wno-parentheses-equality -Wno-constant-logical-operand -Wno-self-assign -Wunused-variable -Wimplicit-int -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat -Wsuggest-attribute=noreturn -Wsuggest-attribute=format -Wno-maybe-uninitialized"
if platform.name =~ /el-7-ppc64/
# EL 7 on POWER will fail with -Wl,--compress-debug-sections=zlib so this
# will remove that entry
# Matches both endians
rbconfig_changes["DLDFLAGS"] = "-Wl,-rpath=/opt/puppetlabs/puppet/lib -L/opt/puppetlabs/puppet/lib -Wl,-rpath,/opt/puppetlabs/puppet/lib"
elsif platform.name =~ /solaris-10-sparc/
# ld on solaris 10 sparc does not understand `-Wl,-E` - this is what remains after removing it:
rbconfig_changes["LDFLAGS"] = "-L. -Wl,-rpath=/opt/puppetlabs/puppet/lib -fstack-protector"
# `-Wl,--compress-debug-sections=zlib` is also a problem here:
rbconfig_changes["DLDFLAGS"] = "-Wl,-rpath=/opt/puppetlabs/puppet/lib"
end
elsif platform.is_windows?
rbconfig_changes["CC"] = "x86_64-w64-mingw32-gcc"
end
pkg.add_source("file://resources/files/rubygems/COMODO_RSA_Certification_Authority.pem")
defaults_dir = File.join(settings[:libdir], "ruby/2.1.0/rubygems/ssl_certs")
pkg.directory(defaults_dir)
pkg.install_file "../COMODO_RSA_Certification_Authority.pem", File.join(defaults_dir, 'COMODO_RSA_Certification_Authority.pem')
unless rbconfig_changes.empty?
pkg.install do
[
"#{settings[:host_ruby]} ../rbconfig-update.rb \"#{rbconfig_changes.to_s.gsub('"', '\"')}\" #{rbconfig_topdir}",
"cp original_rbconfig.rb #{settings[:datadir]}/doc/rbconfig-2.1.9-orig.rb",
"cp new_rbconfig.rb #{rbconfig_topdir}/rbconfig.rb",
]
end
end
end