Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install missing dependencies for Ruby 3.2 #763

Merged
merged 4 commits into from
Nov 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 29 additions & 11 deletions configs/components/_base-ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,32 @@
[ "#{platform[:make]} -j$(shell expr $(shell #{platform[:num_cores]}) + 1) install" ]
end

# For the pdk runtime, the ruby bin directory is different then the main bin
# directory. In order to run ruby *outside* of the normal pdk.bat then we need
# to copy all dlls that ruby depends on from the main bin directory to ruby's
# bin directory. This is because the main bin directory is not in our system
# PATH and Windows doesn't support RPATH. However, as mentioned in
# https://learn.microsoft.com/en-us/windows/win32/dlls/dynamic-link-library-search-order,
# Windows searches for DLLs in "The folder the calling process was loaded from
# (the executable's folder)."
#
# The agent runtime used to have the same issue prior to puppet 6, for example
# RE-7593. However, Windows paths were changed to match *nix in puppet 6, see
# commit 4b9d126dd5b. So only the pdk has this issue.
if platform.is_windows? && settings[:bindir] != ruby_bindir
# As things stand right now, ssl should build under [INSTALLDIR]\Puppet\puppet on
# windows. However, if things need to run *outside* of the normal batch file runs
# (puppet.bat ,mco.bat etcc) the location of openssl away from where ruby is
# installed will cause a failure. Specifically this is meant to help services like
# mco that require openssl but don't have access to environment.bat. Refer to
# https://tickets.puppetlabs.com/browse/RE-7593 for details on why this causes
# failures and why these copies fix that.
# -Sean P. McDonald 07/01/2016
bindir = settings[:bindir]

# Ruby 3+
if Gem::Version.new(pkg.get_version) >= Gem::Version.new('3.0')
pkg.install do
[
"cp #{settings[:gcc_bindir]}/libssp-0.dll #{ruby_bindir}",
"cp #{bindir}/libffi-8.dll #{ruby_bindir}",
"cp #{bindir}/libyaml-0-2.dll #{ruby_bindir}"
]
end
end

if platform.architecture == "x64"
gcc_postfix = 'seh'
ssl_postfix = '-x64'
Expand All @@ -131,6 +148,7 @@
ssl_postfix = ''
end

# OpenSSL
if Gem::Version.new(settings[:openssl_version]) >= Gem::Version.new('3.0')
ssl_lib = "libssl-3#{ssl_postfix}.dll"
crypto_lib = "libcrypto-3#{ssl_postfix}.dll"
Expand All @@ -144,9 +162,9 @@

pkg.install do
[
"cp #{settings[:bindir]}/libgcc_s_#{gcc_postfix}-1.dll #{ruby_bindir}",
"cp #{settings[:bindir]}/#{ssl_lib} #{ruby_bindir}",
"cp #{settings[:bindir]}/#{crypto_lib} #{ruby_bindir}",
"cp #{bindir}/libgcc_s_#{gcc_postfix}-1.dll #{ruby_bindir}",
"cp #{bindir}/#{ssl_lib} #{ruby_bindir}",
"cp #{bindir}/#{crypto_lib} #{ruby_bindir}"
]
end

Expand Down
30 changes: 17 additions & 13 deletions configs/components/runtime-pdk.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,30 @@
pkg.install_file File.join(settings[:gcc_bindir], dll), File.join(settings[:bindir], dll)
end

# Ruby needs zlib
tools_bindir = File.join(settings[:tools_root], 'bin')

# curl, openssl, etc need zlib, so install in *main* bin dir
pkg.build_requires "pl-zlib-#{platform.architecture}"
pkg.install_file "#{settings[:tools_root]}/bin/zlib1.dll", "#{settings[:bindir]}/zlib1.dll"
pkg.install_file "#{tools_bindir}/zlib1.dll", "#{settings[:bindir]}/zlib1.dll"

# zlib, gdbm, yaml-cpp and iconv are all runtime dependancies of ruby, and their libraries need
# To exist inside our vendored ruby
pkg.install_file "#{settings[:tools_root]}/bin/zlib1.dll", "#{settings[:ruby_bindir]}/zlib1.dll"
pkg.install_file "#{settings[:tools_root]}/bin/libgdbm-4.dll", "#{settings[:ruby_bindir]}/libgdbm-4.dll"
pkg.install_file "#{settings[:tools_root]}/bin/libgdbm_compat-4.dll", "#{settings[:ruby_bindir]}/libgdbm_compat-4.dll"
pkg.install_file "#{settings[:tools_root]}/bin/libiconv-2.dll", "#{settings[:ruby_bindir]}/libiconv-2.dll"
pkg.install_file "#{settings[:tools_root]}/bin/libffi-6.dll", "#{settings[:ruby_bindir]}/libffi-6.dll"
# to exist inside our primary ruby's bin dir
ruby_bindir = settings[:ruby_bindir]
pkg.install_file "#{tools_bindir}/zlib1.dll", "#{ruby_bindir}/zlib1.dll"
pkg.install_file "#{tools_bindir}/libgdbm-4.dll", "#{ruby_bindir}/libgdbm-4.dll"
pkg.install_file "#{tools_bindir}/libgdbm_compat-4.dll", "#{ruby_bindir}/libgdbm_compat-4.dll"
pkg.install_file "#{tools_bindir}/libiconv-2.dll", "#{ruby_bindir}/libiconv-2.dll"
pkg.install_file "#{tools_bindir}/libffi-6.dll", "#{ruby_bindir}/libffi-6.dll" if settings[:ruby_version].start_with?('2')

# Copy the DLLs into additional ruby install bindirs as well.
if settings.has_key?(:additional_rubies)
settings[:additional_rubies].each do |rubyver, local_settings|
pkg.install_file "#{settings[:tools_root]}/bin/zlib1.dll", "#{local_settings[:ruby_bindir]}/zlib1.dll"
pkg.install_file "#{settings[:tools_root]}/bin/libgdbm-4.dll", "#{local_settings[:ruby_bindir]}/libgdbm-4.dll"
pkg.install_file "#{settings[:tools_root]}/bin/libgdbm_compat-4.dll", "#{local_settings[:ruby_bindir]}/libgdbm_compat-4.dll"
pkg.install_file "#{settings[:tools_root]}/bin/libiconv-2.dll", "#{local_settings[:ruby_bindir]}/libiconv-2.dll"
pkg.install_file "#{settings[:tools_root]}/bin/libffi-6.dll", "#{local_settings[:ruby_bindir]}/libffi-6.dll"
local_bindir = local_settings[:ruby_bindir]
pkg.install_file "#{tools_bindir}/zlib1.dll", "#{local_bindir}/zlib1.dll"
pkg.install_file "#{tools_bindir}/libgdbm-4.dll", "#{local_bindir}/libgdbm-4.dll"
pkg.install_file "#{tools_bindir}/libgdbm_compat-4.dll", "#{local_bindir}/libgdbm_compat-4.dll"
pkg.install_file "#{tools_bindir}/libiconv-2.dll", "#{local_bindir}/libiconv-2.dll"
pkg.install_file "#{tools_bindir}/libffi-6.dll", "#{local_bindir}/libffi-6.dll" if rubyver.start_with?('2')
end
end

Expand Down
6 changes: 0 additions & 6 deletions configs/projects/_pdk-components.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,6 @@
proj.component 'libxslt' unless platform.is_windows?
proj.component "ruby-#{proj.ruby_version}"

# After installing ruby, we need to copy libssp to the ruby bindir on windows
if platform.is_windows?
ruby_component = @project.get_component "ruby-#{proj.ruby_version}"
ruby_component.install.push "cp '#{settings[:bindir]}/libssp-0.dll' '#{settings[:ruby_bindir]}/libssp-0.dll'"
end

proj.component 'ruby-augeas' unless platform.is_windows?
proj.component 'ruby-selinux' if platform.is_el? || platform.is_fedora?
proj.component 'ruby-stomp'
Expand Down
Loading