forked from puppetlabs/puppet-runtime
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_base-ruby-augeas.rb
126 lines (110 loc) · 4.51 KB
/
_base-ruby-augeas.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
# This file is a basis for multiple versions/targets of ruby-augeas.
# It should not be included as a component; Instead other components should
# load it with instance_eval. See ruby-x.y-augeas.rb configs.
#
pkg.add_source("file://resources/patches/augeas/ruby-augeas-0.5.0-patch_c_extension.patch")
# These can be overridden by the including component.
ruby_version ||= settings[:ruby_version]
host_ruby ||= settings[:host_ruby]
ruby_dir ||= settings[:ruby_dir]
ruby_bindir ||= settings[:ruby_bindir]
pkg.version "0.5.0"
pkg.md5sum "a132eace43ce13ccd059e22c0b1188ac"
pkg.url "http://download.augeas.net/ruby/ruby-augeas-#{pkg.get_version}.tgz"
pkg.mirror "#{settings[:buildsources_url]}/ruby-augeas-#{pkg.get_version}.tgz"
pkg.build_requires "ruby-#{ruby_version}"
pkg.build_requires "augeas"
pkg.environment "PATH", "$(PATH):/opt/pl-build-tools/bin:/usr/local/bin:/opt/csw/bin:/usr/ccs/bin:/usr/sfw/bin"
if platform.is_aix?
if platform.name == 'aix-7.1-ppc'
pkg.environment "CC", "/opt/pl-build-tools/bin/gcc"
# pl-build-tools was added to PATH above
else
pkg.environment "CC", "/opt/freeware/bin/gcc"
pkg.environment "PATH", "$(PATH):/opt/freeware/bin"
end
pkg.environment "RUBY", host_ruby
pkg.environment "LDFLAGS", " -brtl #{settings[:ldflags]}"
end
pkg.environment "CONFIGURE_ARGS", '--vendor'
pkg.environment "PKG_CONFIG_PATH", "#{File.join(settings[:libdir], 'pkgconfig')}:/usr/lib/pkgconfig"
if platform.is_solaris?
if platform.architecture == 'sparc'
pkg.environment "RUBY", host_ruby
end
ruby = "#{host_ruby} -r#{settings[:datadir]}/doc/rbconfig-#{ruby_version}-orig.rb"
elsif platform.is_cross_compiled?
if platform.is_linux? || platform.is_macos?
pkg.environment "RUBY", host_ruby
pkg.environment 'CC', 'clang -target arm64-apple-macos11' if platform.name =~ /osx-11/
pkg.environment 'CC', 'clang -target arm64-apple-macos12' if platform.name =~ /osx-12/
ruby = "#{host_ruby} -r#{settings[:datadir]}/doc/rbconfig-#{ruby_version}-orig.rb"
pkg.environment "LDFLAGS", settings[:ldflags]
end
else
ruby = File.join(ruby_bindir, 'ruby')
end
# This is a disturbing workaround needed for s390x based systems, that
# for some reason isn't encountered with our other architecture cross
# builds. When trying to build the augeas test cases for extconf.rb,
# the process fails with "/opt/pl-build-tools/bin/s390x-linux-gnu-gcc:
# error while loading shared libraries: /opt/puppetlabs/puppet/lib/libstdc++.so.6:
# ELF file data encoding not little-endian". It will also complain in
# the same way about libgcc. If however we temporarily move these
# libraries out of the way, extconf.rb and the cross-compile work
# properly. This needs to be fixed, but I've spent over a week analyzing
# every possible angle that could cause this, from rbconfig settings to
# strace logs, and we need to move forward on this platform.
#
# This seems to apply directly to Linux on ppc64 - I've gotten successful builds
# with this change.
# FIXME: Scott Garman Jun 2016
if platform.architecture == "ppc64"
pkg.configure do
[
"mkdir #{settings[:libdir]}/hide",
"mv #{settings[:libdir]}/libstdc* #{settings[:libdir]}/hide/",
"mv #{settings[:libdir]}/libgcc* #{settings[:libdir]}/hide/"
]
end
end
pkg.build do
build_commands = []
if ruby_version =~ /^3/
build_commands << "#{platform.patch} --strip=2 --fuzz=0 --ignore-whitespace --no-backup-if-mismatch < ../ruby-augeas-0.5.0-patch_c_extension.patch"
end
build_commands << "#{ruby} ext/augeas/extconf.rb"
build_commands << "#{platform[:make]} -e -j$(shell expr $(shell #{platform[:num_cores]}) + 1)"
build_commands
end
if settings[:ruby_vendordir]
augeas_rb_target = File.join(settings[:ruby_vendordir], 'augeas.rb')
else
# If no alternate vendordir has been set, install into default
# vendordir for this ruby version.
augeas_rb_target = File.join(ruby_dir, 'lib', 'ruby', 'vendor_ruby', 'augeas.rb')
end
pkg.install_file 'lib/augeas.rb', augeas_rb_target
pkg.install do
[
"#{platform[:make]} -e -j$(shell expr $(shell #{platform[:num_cores]}) + 1) DESTDIR=/ install",
]
end
if platform.is_solaris? || platform.is_cross_compiled_linux?
pkg.install do
"chown root:root #{augeas_rb_target}"
end
end
# Undo the gross hack from the configure step
if platform.architecture == "ppc64"
pkg.install do
[
"mv #{settings[:libdir]}/hide/* #{settings[:libdir]}/",
"rmdir #{settings[:libdir]}/hide/"
]
end
end
# Clean after install in case we are building for multiple rubies.
pkg.install do
"#{platform[:make]} -e clean"
end