Skip to content

Commit 0f3c148

Browse files
committed
(PDK-784) Add Ruby 2.1 specific components for ruby addons
1 parent b33344a commit 0f3c148

9 files changed

+287
-172
lines changed

Diff for: configs/components/_base-ruby-augeas.rb

+109
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
# This file is a basis for multiple versions/targets of ruby-augeas.
2+
# It should not be included as a component; Instead other components should
3+
# load it with instance_eval. See ruby-x.y-augeas.rb configs.
4+
#
5+
6+
# These can be overridden by the including component.
7+
ruby_version ||= settings[:ruby_version]
8+
host_ruby ||= settings[:host_ruby]
9+
ruby_dir ||= settings[:ruby_dir]
10+
ruby_bindir ||= settings[:ruby_bindir]
11+
12+
pkg.version "0.5.0"
13+
pkg.md5sum "a132eace43ce13ccd059e22c0b1188ac"
14+
pkg.url "http://download.augeas.net/ruby/ruby-augeas-#{pkg.get_version}.tgz"
15+
pkg.mirror "#{settings[:buildsources_url]}/ruby-augeas-#{pkg.get_version}.tar.gz"
16+
17+
pkg.build_requires "ruby-#{ruby_version}"
18+
pkg.build_requires "augeas"
19+
20+
pkg.environment "PATH", "$(PATH):/opt/pl-build-tools/bin:/usr/local/bin:/opt/csw/bin:/usr/ccs/bin:/usr/sfw/bin"
21+
if platform.is_aix?
22+
pkg.build_requires "http://osmirror.delivery.puppetlabs.net/AIX_MIRROR/pkg-config-0.19-6.aix5.2.ppc.rpm"
23+
pkg.environment "CC", "/opt/pl-build-tools/bin/gcc"
24+
pkg.environment "RUBY", host_ruby
25+
pkg.environment "LDFLAGS", " -brtl #{settings[:ldflags]}"
26+
end
27+
28+
pkg.environment "CONFIGURE_ARGS", '--vendor'
29+
pkg.environment "PKG_CONFIG_PATH", "#{File.join(settings[:libdir], 'pkgconfig')}:/usr/lib/pkgconfig"
30+
31+
if platform.is_solaris?
32+
if platform.architecture == 'sparc'
33+
pkg.environment "RUBY", host_ruby
34+
end
35+
ruby = "#{host_ruby} -r#{settings[:datadir]}/doc/rbconfig-#{ruby_version}-orig.rb"
36+
elsif platform.is_cross_compiled_linux?
37+
pkg.environment "RUBY", host_ruby
38+
ruby = "#{host_ruby} -r#{settings[:datadir]}/doc/rbconfig-#{ruby_version}-orig.rb"
39+
pkg.environment "LDFLAGS", settings[:ldflags]
40+
else
41+
ruby = File.join(ruby_bindir, 'ruby')
42+
end
43+
44+
# This is a disturbing workaround needed for s390x based systems, that
45+
# for some reason isn't encountered with our other architecture cross
46+
# builds. When trying to build the augeas test cases for extconf.rb,
47+
# the process fails with "/opt/pl-build-tools/bin/s390x-linux-gnu-gcc:
48+
# error while loading shared libraries: /opt/puppetlabs/puppet/lib/libstdc++.so.6:
49+
# ELF file data encoding not little-endian". It will also complain in
50+
# the same way about libgcc. If however we temporarily move these
51+
# libraries out of the way, extconf.rb and the cross-compile work
52+
# properly. This needs to be fixed, but I've spent over a week analyzing
53+
# every possible angle that could cause this, from rbconfig settings to
54+
# strace logs, and we need to move forward on this platform.
55+
# FIXME: Scott Garman Jun 2016
56+
if platform.architecture == "s390x"
57+
pkg.configure do
58+
[
59+
"mkdir #{settings[:libdir]}/hide",
60+
"mv #{settings[:libdir]}/libstdc* #{settings[:libdir]}/hide/",
61+
"mv #{settings[:libdir]}/libgcc* #{settings[:libdir]}/hide/"
62+
]
63+
end
64+
end
65+
66+
pkg.build do
67+
build_commands = []
68+
build_commands << "#{ruby} ext/augeas/extconf.rb"
69+
build_commands << "#{platform[:make]} -e -j$(shell expr $(shell #{platform[:num_cores]}) + 1)"
70+
71+
build_commands
72+
end
73+
74+
if settings[:ruby_vendordir]
75+
augeas_rb_target = File.join(settings[:ruby_vendordir], 'augeas.rb')
76+
else
77+
# If no alternate vendordir has been set, install into default
78+
# vendordir for this ruby version.
79+
augeas_rb_target = File.join(ruby_dir, 'lib', 'ruby', 'vendor_ruby', 'augeas.rb')
80+
end
81+
82+
pkg.install_file 'lib/augeas.rb', augeas_rb_target
83+
84+
pkg.install do
85+
[
86+
"#{platform[:make]} -e -j$(shell expr $(shell #{platform[:num_cores]}) + 1) DESTDIR=/ install",
87+
]
88+
end
89+
90+
if platform.is_solaris? || platform.is_cross_compiled_linux?
91+
pkg.install do
92+
"chown root:root #{augeas_rb_target}"
93+
end
94+
end
95+
96+
# Undo the gross hack from the configure step
97+
if platform.architecture == "s390x"
98+
pkg.install do
99+
[
100+
"mv #{settings[:libdir]}/hide/* #{settings[:libdir]}/",
101+
"rmdir #{settings[:libdir]}/hide/"
102+
]
103+
end
104+
end
105+
106+
# Clean after install in case we are building for multiple rubies.
107+
pkg.install do
108+
"#{platform[:make]} -e clean"
109+
end

Diff for: configs/components/_base-ruby-selinux.rb

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# This file is a basis for multiple versions/targets of ruby-selinux.
2+
# It should not be included as a component; Instead other components should
3+
# load it with instance_eval. See ruby-x.y-selinux.rb configs.
4+
#
5+
6+
# These can be overridden by the including component.
7+
ruby_version ||= settings[:ruby_version]
8+
host_ruby ||= settings[:host_ruby]
9+
ruby_bindir ||= settings[:ruby_bindir]
10+
11+
if platform.name =~ /^el-5-.*$/
12+
# This is a _REALLY_ old version of libselinux found only in Fedora/RH archives and not upstream
13+
pkg.version "1.33.4"
14+
pkg.md5sum "08762379de2242926854080dad649b67"
15+
pkg.apply_patch "resources/patches/ruby-selinux/libselinux-rhat.patch"
16+
pkg.url "http://pkgs.fedoraproject.org/repo/pkgs/libselinux/libselinux-1.33.4.tgz/08762379de2242926854080dad649b67/libselinux-1.33.4.tgz"
17+
pkg.mirror "#{settings[:buildsources_url]}/libselinux-#{pkg.get_version}.tgz"
18+
19+
# This version of libselinux does not supply a file for pkg-config; Augeas 1.10.1 expects one, though:
20+
pkg.add_source "file://resources/files/ruby-selinux/libselinux-1.33.4.pc"
21+
pkg.install do
22+
["cp ../libselinux-1.33.4.pc #{settings[:libdir]}/pkgconfig/libselinux.pc"]
23+
end
24+
else
25+
pkg.version "2.0.94"
26+
pkg.md5sum "544f75aab11c2af352facc51af12029f"
27+
pkg.url "https://raw.githubusercontent.com/wiki/SELinuxProject/selinux/files/releases/20100525/devel/libselinux-#{pkg.get_version}.tar.gz"
28+
pkg.mirror "#{settings[:buildsources_url]}/libselinux-#{pkg.get_version}.tar.gz"
29+
end
30+
31+
pkg.build_requires "ruby-#{ruby_version}"
32+
pkg.build_requires "swig"
33+
pkg.build_requires "libsepol"
34+
pkg.build_requires "libsepol-devel"
35+
pkg.build_requires "libselinux-devel"
36+
37+
cc = "/opt/pl-build-tools/bin/gcc"
38+
system_include = "-I/usr/include"
39+
ruby = "#{ruby_bindir}/ruby -rrbconfig"
40+
41+
if platform.is_cross_compiled_linux?
42+
cc = "/opt/pl-build-tools/bin/#{settings[:platform_triple]}-gcc"
43+
system_include = "-I/opt/pl-build-tools/#{settings[:platform_triple]}/sysroot/usr/include"
44+
pkg.environment "RUBY", host_ruby
45+
ruby = "#{host_ruby} -r#{settings[:datadir]}/doc/rbconfig-#{ruby_version}-orig.rb"
46+
end
47+
48+
pkg.build do
49+
[
50+
"export RUBYHDRDIR=$(shell #{ruby} -e 'puts RbConfig::CONFIG[\"rubyhdrdir\"]')",
51+
"export VENDORARCHDIR=$(shell #{ruby} -e 'puts RbConfig::CONFIG[\"vendorarchdir\"]')",
52+
"export ARCHDIR=$${RUBYHDRDIR}/$(shell #{ruby} -e 'puts RbConfig::CONFIG[\"arch\"]')",
53+
"export INCLUDESTR=\"-I#{settings[:includedir]} -I$${RUBYHDRDIR} -I$${ARCHDIR}\"",
54+
"cp -pr src/{selinuxswig_ruby.i,selinuxswig.i} .",
55+
"swig -Wall -ruby #{system_include} -o selinuxswig_ruby_wrap.c -outdir ./ selinuxswig_ruby.i",
56+
"#{cc} $${INCLUDESTR} #{system_include} -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -fPIC -DSHARED -c -o selinuxswig_ruby_wrap.lo selinuxswig_ruby_wrap.c",
57+
"#{cc} $${INCLUDESTR} #{system_include} -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -shared -o _rubyselinux.so selinuxswig_ruby_wrap.lo -lselinux -Wl,-soname,_rubyselinux.so",
58+
]
59+
end
60+
61+
pkg.install do
62+
[
63+
"export VENDORARCHDIR=$(shell #{ruby} -e 'puts RbConfig::CONFIG[\"vendorarchdir\"]')",
64+
"install -d $${VENDORARCHDIR}",
65+
"install -p -m755 _rubyselinux.so $${VENDORARCHDIR}/selinux.so",
66+
"#{platform[:make]} -e clean",
67+
]
68+
end

Diff for: configs/components/_base-ruby-stomp.rb

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# This file is a basis for multiple versions/targets of ruby-stomp.
2+
# It should not be included as a component; Instead other components should
3+
# load it with instance_eval. See ruby-x.y-stomp.rb configs.
4+
#
5+
6+
# These can be overridden by the including component.
7+
ruby_version ||= settings[:ruby_version]
8+
ruby_bindir ||= settings[:ruby_bindir]
9+
gem_home ||= settings[:gem_home]
10+
gem_install ||= settings[:gem_install]
11+
12+
# Projects may define a :ruby_stomp_version setting, or we use 1.4.4 by default:
13+
version = settings[:ruby_stomp_version] || '1.4.4'
14+
pkg.version version
15+
16+
case version
17+
when '1.4.4'
18+
pkg.md5sum "1224b9efe7381cea25c506c9c6e28373"
19+
when '1.3.3'
20+
pkg.md5sum "50a2c1b66982b426d67a83f56f4bc0e2"
21+
else
22+
raise "ruby-stomp version #{version} has not been configured; Cannot continue."
23+
end
24+
25+
pkg.url "https://rubygems.org/downloads/stomp-#{pkg.get_version}.gem"
26+
pkg.mirror "#{settings[:buildsources_url]}/stomp-#{pkg.get_version}.gem"
27+
28+
pkg.build_requires "ruby-#{ruby_version}"
29+
30+
# Because we are cross-compiling on sparc, we can't use the rubygems we just built.
31+
# Instead we use the host gem installation and override GEM_HOME. Yay?
32+
pkg.environment "GEM_HOME", gem_home
33+
34+
if platform.is_windows?
35+
pkg.environment "PATH", "$(shell cygpath -u #{settings[:gcc_bindir]}):$(shell cygpath -u #{ruby_bindir}):$(shell cygpath -u #{settings[:bindir]}):/cygdrive/c/Windows/system32:/cygdrive/c/Windows:/cygdrive/c/Windows/System32/WindowsPowerShell/v1.0"
36+
end
37+
38+
# PA-25 in order to install gems in a cross-compiled environment we need to
39+
# set RUBYLIB to include puppet and hiera, so that their gemspecs can resolve
40+
# hiera/version and puppet/version requires. Without this the gem install
41+
# will fail by blowing out the stack.
42+
if settings[:ruby_vendordir]
43+
pkg.environment "RUBYLIB", "#{settings[:ruby_vendordir]}:$(RUBYLIB)"
44+
end
45+
46+
if version == '1.3.3'
47+
base = 'resources/patches/ruby-stomp'
48+
pkg.apply_patch "#{base}/verify_client_certs.patch", destination: "#{gem_home}/gems/stomp-#{pkg.get_version}", after: "install"
49+
pkg.apply_patch "#{base}/connection_loss_reconnect_fix.patch", destination: "#{gem_home}/gems/stomp-#{pkg.get_version}", after: "install"
50+
end
51+
52+
pkg.install do
53+
["#{gem_install} stomp-#{pkg.get_version}.gem"]
54+
end

Diff for: configs/components/ruby-2.1-augeas.rb

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
component "ruby-2.1-augeas" do |pkg, settings, platform|
2+
expected_ruby_version = '2.1.9'
3+
4+
unless settings[:ruby_version] == expected_ruby_version
5+
unless settings.has_key?(:additional_rubies) && settings[:additional_rubies].has_key?(expected_ruby_version)
6+
raise "No config found for Ruby #{expected_ruby_version} in settings[:additional_rubies]"
7+
end
8+
9+
ruby_settings = settings[:additional_rubies][expected_ruby_version]
10+
11+
ruby_version = ruby_settings[:ruby_version]
12+
host_ruby = ruby_settings[:host_ruby]
13+
ruby_dir = ruby_settings[:ruby_dir]
14+
ruby_bindir = ruby_settings[:ruby_bindir]
15+
end
16+
17+
instance_eval File.read('configs/components/_base-ruby-augeas.rb')
18+
end

Diff for: configs/components/ruby-2.1-selinux.rb

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
component "ruby-2.1-selinux" do |pkg, settings, platform|
2+
expected_ruby_version = '2.1.9'
3+
4+
unless settings[:ruby_version] == expected_ruby_version
5+
unless settings.has_key?(:additional_rubies) && settings[:additional_rubies].has_key?(expected_ruby_version)
6+
raise "No config found for Ruby #{expected_ruby_version} in settings[:additional_rubies]"
7+
end
8+
9+
ruby_settings = settings[:additional_rubies][expected_ruby_version]
10+
11+
ruby_version = ruby_settings[:ruby_version]
12+
host_ruby = ruby_settings[:host_ruby]
13+
ruby_bindir = ruby_settings[:ruby_bindir]
14+
end
15+
16+
instance_eval File.read('configs/components/_base-ruby-selinux.rb')
17+
end

Diff for: configs/components/ruby-2.1-stomp.rb

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
component "ruby-stomp" do |pkg, settings, platform|
2+
expected_ruby_version = '2.1.9'
3+
4+
unless settings[:ruby_version] == expected_ruby_version
5+
unless settings.has_key?(:additional_rubies) && settings[:additional_rubies].has_key?(expected_ruby_version)
6+
raise "No config found for Ruby #{expected_ruby_version} in settings[:additional_rubies]"
7+
end
8+
9+
ruby_settings = settings[:additional_rubies][expected_ruby_version]
10+
11+
ruby_version = ruby_settings[:ruby_version]
12+
ruby_bindir = ruby_settings[:ruby_bindir]
13+
gem_home = ruby_settings[:gem_home]
14+
gem_install = ruby_settings[:gem_install]
15+
end
16+
17+
instance_eval File.read('configs/components/_base-ruby-stomp.rb')
18+
end

Diff for: configs/components/ruby-augeas.rb

+1-79
Original file line numberDiff line numberDiff line change
@@ -1,81 +1,3 @@
11
component "ruby-augeas" do |pkg, settings, platform|
2-
pkg.version "0.5.0"
3-
pkg.md5sum "a132eace43ce13ccd059e22c0b1188ac"
4-
pkg.url "http://download.augeas.net/ruby/ruby-augeas-#{pkg.get_version}.tgz"
5-
pkg.mirror "#{settings[:buildsources_url]}/ruby-augeas-#{pkg.get_version}.tar.gz"
6-
7-
pkg.build_requires "ruby-#{settings[:ruby_version]}"
8-
pkg.build_requires "augeas"
9-
10-
pkg.environment "PATH", "$(PATH):/opt/pl-build-tools/bin:/usr/local/bin:/opt/csw/bin:/usr/ccs/bin:/usr/sfw/bin"
11-
if platform.is_aix?
12-
pkg.build_requires "http://osmirror.delivery.puppetlabs.net/AIX_MIRROR/pkg-config-0.19-6.aix5.2.ppc.rpm"
13-
pkg.environment "CC", "/opt/pl-build-tools/bin/gcc"
14-
pkg.environment "RUBY", settings[:host_ruby]
15-
pkg.environment "LDFLAGS", " -brtl #{settings[:ldflags]}"
16-
end
17-
18-
pkg.environment "CONFIGURE_ARGS", '--vendor'
19-
pkg.environment "PKG_CONFIG_PATH", "#{File.join(settings[:libdir], 'pkgconfig')}:/usr/lib/pkgconfig"
20-
21-
if platform.is_solaris?
22-
if platform.architecture == 'sparc'
23-
pkg.environment "RUBY", settings[:host_ruby]
24-
end
25-
ruby = "#{settings[:host_ruby]} -r#{settings[:datadir]}/doc/rbconfig.rb"
26-
elsif platform.is_cross_compiled_linux?
27-
pkg.environment "RUBY", settings[:host_ruby]
28-
ruby = "#{settings[:host_ruby]} -r#{settings[:datadir]}/doc/rbconfig.rb"
29-
pkg.environment "LDFLAGS", settings[:ldflags]
30-
else
31-
ruby = File.join(settings[:ruby_bindir], 'ruby')
32-
end
33-
34-
# This is a disturbing workaround needed for s390x based systems, that
35-
# for some reason isn't encountered with our other architecture cross
36-
# builds. When trying to build the augeas test cases for extconf.rb,
37-
# the process fails with "/opt/pl-build-tools/bin/s390x-linux-gnu-gcc:
38-
# error while loading shared libraries: /opt/puppetlabs/puppet/lib/libstdc++.so.6:
39-
# ELF file data encoding not little-endian". It will also complain in
40-
# the same way about libgcc. If however we temporarily move these
41-
# libraries out of the way, extconf.rb and the cross-compile work
42-
# properly. This needs to be fixed, but I've spent over a week analyzing
43-
# every possible angle that could cause this, from rbconfig settings to
44-
# strace logs, and we need to move forward on this platform.
45-
# FIXME: Scott Garman Jun 2016
46-
if platform.architecture == "s390x"
47-
pkg.configure do
48-
[
49-
"mkdir #{settings[:libdir]}/hide",
50-
"mv #{settings[:libdir]}/libstdc* #{settings[:libdir]}/hide/",
51-
"mv #{settings[:libdir]}/libgcc* #{settings[:libdir]}/hide/"
52-
]
53-
end
54-
end
55-
56-
pkg.build do
57-
["#{ruby} ext/augeas/extconf.rb",
58-
"#{platform[:make]} -e -j$(shell expr $(shell #{platform[:num_cores]}) + 1)"]
59-
end
60-
61-
pkg.install_file 'lib/augeas.rb', File.join(settings[:ruby_vendordir], 'augeas.rb')
62-
pkg.install do
63-
[
64-
"#{platform[:make]} -e -j$(shell expr $(shell #{platform[:num_cores]}) + 1) DESTDIR=/ install",
65-
]
66-
end
67-
68-
pkg.install do
69-
"chown root:root #{settings[:ruby_vendordir]}/augeas.rb"
70-
end if platform.is_solaris? || platform.is_cross_compiled_linux?
71-
72-
# Undo the gross hack from the configure step
73-
if platform.architecture == "s390x"
74-
pkg.install do
75-
[
76-
"mv #{settings[:libdir]}/hide/* #{settings[:libdir]}/",
77-
"rmdir #{settings[:libdir]}/hide/"
78-
]
79-
end
80-
end
2+
instance_eval File.read('configs/components/_base-ruby-augeas.rb')
813
end

0 commit comments

Comments
 (0)