Skip to content
This repository has been archived by the owner on Jan 15, 2025. It is now read-only.

Commit

Permalink
(PA-6422) Namespace gem_install_options
Browse files Browse the repository at this point in the history
Settings are shared across all components, so `settings[:gem_install_options]`
in the ffi gem caused its options to be passed to gems that follow like gssapi
in the bolt-runtime:

    /opt/puppetlabs/bolt/bin/gem install --no-document --local --bindir=/opt/puppetlabs/bolt/bin gssapi-1.3.1.gem -- --disable-system-libffi

This commit namespaces the options so they only apply when installing that
specific gem. The namespace is based on the full gem name like `rubygems-ffi`,
not the short name `ffi`.
  • Loading branch information
joshcooper committed May 10, 2024
1 parent e2f5148 commit 433e811
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
5 changes: 3 additions & 2 deletions configs/components/_base-rubygem.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,14 @@

# If a gem needs more command line options to install set the :gem_install_options
# in its component file rubygem-<compoment>, before the instance_eval of this file.
if settings[:gem_install_options].nil?
gem_install_options = settings["#{pkg.get_name}_gem_install_options".to_sym]
if gem_install_options.nil?
pkg.install do
"#{settings[:gem_install]} #{name}-#{version}.gem"
end
else
pkg.install do
"#{settings[:gem_install]} #{name}-#{version}.gem #{settings[:gem_install_options]}"
"#{settings[:gem_install]} #{name}-#{version}.gem #{gem_install_options}"
end
end

11 changes: 6 additions & 5 deletions configs/components/rubygem-ffi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,12 @@
# gem *always* uses the libffi.so we already built. Note the term "system" is
# misleading, because we override PKG_CONFIG_PATH below so that our libffi.so
# is preferred, not the one in /usr/lib.
settings[:gem_install_options] = if rb_major_minor_version > 2.7
"-- --enable-system-libffi"
else
"-- --disable-system-libffi"
end
settings["#{pkg.get_name}_gem_install_options".to_sym] =
if rb_major_minor_version > 2.7
"-- --enable-system-libffi"
else
"-- --disable-system-libffi"
end
instance_eval File.read('configs/components/_base-rubygem.rb')
end

Expand Down
4 changes: 2 additions & 2 deletions configs/components/rubygem-nokogiri.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
component 'rubygem-nokogiri' do |pkg, _settings, _platform|
component 'rubygem-nokogiri' do |pkg, settings, _platform|
pkg.version '1.14.2'
pkg.sha256sum 'c765a74aac6cf430a710bb0b6038b8ee11f177393cd6ae8dadc7a44a6e2658b6'

settings[:gem_install_options] = "--platform=ruby -- \
settings["#{pkg.get_name}_gem_install_options".to_sym] = "--platform=ruby -- \
--use-system-libraries \
--with-xml2-lib=#{settings[:libdir]} \
--with-xml2-include=#{settings[:includedir]}/libxml2 \
Expand Down

0 comments on commit 433e811

Please sign in to comment.