diff --git a/configs/components/_base-ruby.rb b/configs/components/_base-ruby.rb index 5d8adabf..fa9d8400 100644 --- a/configs/components/_base-ruby.rb +++ b/configs/components/_base-ruby.rb @@ -16,12 +16,7 @@ # ENVIRONMENT ############# -if platform.is_cross_compiled_linux? - pkg.environment 'PATH', "#{settings[:bindir]}:$(PATH)" - pkg.environment 'CC', "/opt/pl-build-tools/bin/#{settings[:platform_triple]}-gcc" - pkg.environment 'CXX', "/opt/pl-build-tools/bin/#{settings[:platform_triple]}-g++" - pkg.environment 'LDFLAGS', "-Wl,-rpath=#{settings[:libdir]}" -elsif platform.is_windows? +if platform.is_windows? pkg.environment 'PATH', "$(shell cygpath -u #{settings[:gcc_bindir]}):$(shell cygpath -u #{settings[:tools_root]}/bin):$(shell cygpath -u #{settings[:tools_root]}/include):$(shell cygpath -u #{settings[:bindir]}):$(shell cygpath -u #{ruby_bindir}):$(shell cygpath -u #{settings[:includedir]}):$(PATH)" pkg.environment 'CYGWIN', settings[:cygwin] @@ -45,8 +40,6 @@ pkg.build_requires "openssl-#{settings[:openssl_version]}" -pkg.build_requires "runtime-#{settings[:runtime_project]}" if platform.is_cross_compiled_linux? - ####### # BUILD ####### diff --git a/configs/components/_base-rubygem.rb b/configs/components/_base-rubygem.rb index e211d365..4ac000de 100644 --- a/configs/components/_base-rubygem.rb +++ b/configs/components/_base-rubygem.rb @@ -11,7 +11,6 @@ raise "You must set the `pkg.version` in your rubygem component before instance_eval'ing _base_rubygem.rb" unless version && !version.empty? pkg.build_requires "runtime-#{settings[:runtime_project]}" -pkg.build_requires 'pl-ruby-patch' if platform.is_cross_compiled? if platform.is_windows? pkg.environment 'PATH', diff --git a/configs/components/augeas.rb b/configs/components/augeas.rb index 9b1a808e..7c4225ef 100644 --- a/configs/components/augeas.rb +++ b/configs/components/augeas.rb @@ -28,18 +28,12 @@ if platform.is_rpm? if platform.architecture =~ /aarch64/ pkg.build_requires "runtime-#{settings[:runtime_project]}" - pkg.environment 'PATH', "/opt/pl-build-tools/bin:$(PATH):#{settings[:bindir]}" + pkg.environment 'PATH', "$(PATH):#{settings[:bindir]}" pkg.environment 'CFLAGS', settings[:cflags] pkg.environment 'LDFLAGS', settings[:ldflags] end elsif platform.is_deb? pkg.requires 'libreadline6' - - if platform.is_cross_compiled_linux? - pkg.environment 'PATH', "/opt/pl-build-tools/bin:$(PATH):#{settings[:bindir]}" - pkg.environment 'CFLAGS', settings[:cflags] - pkg.environment 'LDFLAGS', settings[:ldflags] - end elsif platform.is_macos? pkg.environment 'PATH', '$(PATH):/opt/homebrew/bin:/usr/local/bin' pkg.environment 'CFLAGS', settings[:cflags] diff --git a/configs/components/curl.rb b/configs/components/curl.rb index bbc06142..a35aff93 100644 --- a/configs/components/curl.rb +++ b/configs/components/curl.rb @@ -9,18 +9,13 @@ pkg.build_requires 'puppet-ca-bundle' ldflags = settings[:ldflags] - if platform.is_cross_compiled_linux? - pkg.build_requires "runtime-#{settings[:runtime_project]}" - pkg.environment 'PATH', "/opt/pl-build-tools/bin:$(PATH):#{settings[:bindir]}" - pkg.environment 'PKG_CONFIG_PATH', '/opt/puppetlabs/puppet/lib/pkgconfig' - pkg.environment 'PATH', '/opt/pl-build-tools/bin:$(PATH)' - elsif platform.is_windows? + if platform.is_windows? pkg.build_requires "runtime-#{settings[:runtime_project]}" pkg.environment 'PATH', "$(shell cygpath -u #{settings[:gcc_bindir]}):$(PATH)" pkg.environment 'NM', '/usr/bin/nm' if platform.name =~ /windowsfips-2016/ pkg.environment 'CYGWIN', settings[:cygwin] else - pkg.environment 'PATH', "/opt/pl-build-tools/bin:$(PATH):#{settings[:bindir]}" + pkg.environment 'PATH', "$(PATH):#{settings[:bindir]}" end configure_options = [] diff --git a/configs/components/dmidecode.rb b/configs/components/dmidecode.rb index 593bb6e4..9a4d05c9 100644 --- a/configs/components/dmidecode.rb +++ b/configs/components/dmidecode.rb @@ -10,14 +10,6 @@ pkg.environment 'LDFLAGS', settings[:ldflags] pkg.environment 'CFLAGS', settings[:cflags] - if platform.is_cross_compiled? - # The Makefile doesn't honor environment overrides, so we need to - # edit it directly for cross-compiling - pkg.configure do - ["sed -i \"s|gcc|/opt/pl-build-tools/bin/#{settings[:platform_triple]}-gcc|g\" Makefile"] - end - end - pkg.build do ["#{platform[:make]} -j$(shell expr $(shell #{platform[:num_cores]}) + 1)"] end diff --git a/configs/components/libffi.rb b/configs/components/libffi.rb index a88349fb..d0d75024 100644 --- a/configs/components/libffi.rb +++ b/configs/components/libffi.rb @@ -5,24 +5,15 @@ pkg.load_from_json('configs/components/libffi.json') pkg.mirror "#{settings[:buildsources_url]}/#{pkg.get_name}-#{pkg.get_version}.tar.gz" - if platform.is_cross_compiled_linux? - pkg.environment 'PATH', "/opt/pl-build-tools/bin:$(PATH):#{settings[:bindir]}" - pkg.environment 'CFLAGS', settings[:cflags] - pkg.environment 'LDFLAGS', settings[:ldflags] - elsif platform.is_macos? - pkg.environment 'LDFLAGS', settings[:ldflags] - pkg.environment 'CFLAGS', settings[:cflags] + pkg.environment 'LDFLAGS', settings[:ldflags] + pkg.environment 'CFLAGS', settings[:cflags] + + if platform.is_macos? pkg.environment 'CC', settings[:cc] pkg.environment 'MACOSX_DEPLOYMENT_TARGET', settings[:deployment_target] elsif platform.is_windows? pkg.environment 'PATH', "$(shell cygpath -u #{settings[:gcc_bindir]}):$(PATH)" - pkg.environment 'LDFLAGS', settings[:ldflags] - pkg.environment 'CFLAGS', settings[:cflags] - pkg.apply_patch 'resources/patches/libffi/revert_clang_32bit.patch' if platform.architecture == 'x86' - else - pkg.environment 'LDFLAGS', settings[:ldflags] - pkg.environment 'CFLAGS', settings[:cflags] end pkg.build_requires "runtime-#{settings[:runtime_project]}" diff --git a/configs/components/libxml2.rb b/configs/components/libxml2.rb index 95091145..ef9cf327 100644 --- a/configs/components/libxml2.rb +++ b/configs/components/libxml2.rb @@ -7,18 +7,12 @@ pkg.load_from_json('configs/components/libxml2.json') pkg.mirror "#{settings[:buildsources_url]}/libxml2-#{pkg.get_version}.tar.xz" - if platform.is_cross_compiled_linux? - pkg.environment 'PATH', "/opt/pl-build-tools/bin:$(PATH):#{settings[:bindir]}" - pkg.environment 'CFLAGS', settings[:cflags] - pkg.environment 'LDFLAGS', settings[:ldflags] - elsif platform.is_macos? - pkg.environment 'LDFLAGS', settings[:ldflags] - pkg.environment 'CFLAGS', settings[:cflags] + pkg.environment 'LDFLAGS', settings[:ldflags] + pkg.environment 'CFLAGS', settings[:cflags] + + if platform.is_macos? pkg.environment 'CC', settings[:cc] pkg.environment 'MACOSX_DEPLOYMENT_TARGET', settings[:deployment_target] - else - pkg.environment 'LDFLAGS', settings[:ldflags] - pkg.environment 'CFLAGS', settings[:cflags] end pkg.build_requires "runtime-#{settings[:runtime_project]}" diff --git a/configs/components/libyaml.rb b/configs/components/libyaml.rb index d2acfe9f..4a9be668 100644 --- a/configs/components/libyaml.rb +++ b/configs/components/libyaml.rb @@ -5,22 +5,14 @@ pkg.load_from_json('configs/components/libyaml.json') pkg.mirror "#{settings[:buildsources_url]}/yaml-#{pkg.get_version}.tar.gz" - if platform.is_cross_compiled_linux? - pkg.environment 'PATH', "/opt/pl-build-tools/bin:$(PATH):#{settings[:bindir]}" - pkg.environment 'CFLAGS', settings[:cflags] - pkg.environment 'LDFLAGS', settings[:ldflags] - elsif platform.is_macos? - pkg.environment 'LDFLAGS', settings[:ldflags] - pkg.environment 'CFLAGS', settings[:cflags] + pkg.environment 'LDFLAGS', settings[:ldflags] + pkg.environment 'CFLAGS', settings[:cflags] + + if platform.is_macos? pkg.environment 'CC', settings[:cc] pkg.environment 'MACOSX_DEPLOYMENT_TARGET', settings[:deployment_target] elsif platform.is_windows? pkg.environment 'PATH', "$(shell cygpath -u #{settings[:gcc_bindir]}):$(PATH)" - pkg.environment 'LDFLAGS', settings[:ldflags] - pkg.environment 'CFLAGS', settings[:cflags] - else - pkg.environment 'LDFLAGS', settings[:ldflags] - pkg.environment 'CFLAGS', settings[:cflags] end pkg.build_requires "runtime-#{settings[:runtime_project]}" diff --git a/configs/components/openssl-3.0.rb b/configs/components/openssl-3.0.rb index d03f0113..d320c769 100644 --- a/configs/components/openssl-3.0.rb +++ b/configs/components/openssl-3.0.rb @@ -37,7 +37,7 @@ target = "darwin64-#{platform.architecture}" elsif platform.is_linux? - pkg.environment 'PATH', '/opt/pl-build-tools/bin:$(PATH):/usr/local/bin' + pkg.environment 'PATH', '$(PATH):/usr/local/bin' ldflags = "#{settings[:ldflags]} -Wl,-z,relro" case platform.architecture diff --git a/configs/components/pl-ruby-patch.rb b/configs/components/pl-ruby-patch.rb deleted file mode 100644 index 9c9dc809..00000000 --- a/configs/components/pl-ruby-patch.rb +++ /dev/null @@ -1,35 +0,0 @@ -# This component patches the pl-ruby package on cross compiled -# platforms. Ruby gem components should require this. -# -# We have to do this when installing gems with native extensions in -# order to trick rubygems into thinking we have a different ruby -# version and target architecture -# -# This component should also be present in the puppet-agent project -component 'pl-ruby-patch' do |pkg, settings, platform| - if platform.is_cross_compiled? - - pkg.add_source('file://resources/files/ruby/patch-hostruby.rb') - - # The `target_triple` determines which directory native extensions are stored in the - # compiled ruby and must match ruby's naming convention. - # weird architecture naming conventions... - target_triple = if platform.architecture =~ /ppc64el|ppc64le/ - 'powerpc64le-linux' - elsif platform.name == 'solaris-11-sparc' - 'sparc-solaris-2.11' - elsif platform.name =~ /solaris-10/ - 'sparc-solaris' - elsif platform.is_macos? - 'arm64-darwin' - else - "#{platform.architecture}-linux" - end - - pkg.install do - [ - "#{settings[:host_ruby]} patch-hostruby.rb #{settings[:ruby_version]} #{target_triple}" - ] - end - end -end diff --git a/configs/components/puppet-ca-bundle.rb b/configs/components/puppet-ca-bundle.rb index 021d32fe..6bb87fdd 100644 --- a/configs/components/puppet-ca-bundle.rb +++ b/configs/components/puppet-ca-bundle.rb @@ -3,12 +3,7 @@ pkg.build_requires "openssl-#{settings[:openssl_version]}" - openssl_cmd = if platform.is_cross_compiled_linux? - # Use the build host's openssl command, not our cross-compiled or vendored one - '/usr/bin/openssl' - else - "#{settings[:bindir]}/openssl" - end + openssl_cmd = "#{settings[:bindir]}/openssl" target = if platform.is_fips? 'install-fips' diff --git a/configs/components/readline.rb b/configs/components/readline.rb index 7c2f39c2..f7af9a92 100644 --- a/configs/components/readline.rb +++ b/configs/components/readline.rb @@ -10,18 +10,12 @@ pkg.load_from_json('configs/components/readline.json') pkg.mirror "#{settings[:buildsources_url]}/#{pkg.get_name}-#{pkg.get_version}.tar.gz" - if platform.is_cross_compiled_linux? - pkg.environment 'PATH', "/opt/pl-build-tools/bin:$(PATH):#{settings[:bindir]}" - pkg.environment 'CFLAGS', settings[:cflags] - pkg.environment 'LDFLAGS', settings[:ldflags] - elsif platform.is_macos? - pkg.environment 'LDFLAGS', settings[:ldflags] - pkg.environment 'CFLAGS', settings[:cflags] + pkg.environment 'LDFLAGS', settings[:ldflags] + pkg.environment 'CFLAGS', settings[:cflags] + + if platform.is_macos? pkg.environment 'CC', settings[:cc] pkg.environment 'MACOSX_DEPLOYMENT_TARGET', settings[:deployment_target] - else - pkg.environment 'LDFLAGS', settings[:ldflags] - pkg.environment 'CFLAGS', settings[:cflags] end pkg.build_requires "runtime-#{settings[:runtime_project]}" diff --git a/configs/components/ruby-3.2.rb b/configs/components/ruby-3.2.rb index b735393a..bb1c5c95 100644 --- a/configs/components/ruby-3.2.rb +++ b/configs/components/ruby-3.2.rb @@ -24,8 +24,6 @@ base = 'resources/patches/ruby_32' - pkg.apply_patch "#{base}/rbinstall_gem_path.patch" if platform.is_cross_compiled? - if platform.is_windows? pkg.apply_patch "#{base}/windows_mingw32_mkmf.patch" pkg.apply_patch "#{base}/ruby-faster-load_32.patch" @@ -83,8 +81,6 @@ pkg.environment 'optflags', optflags pkg.environment 'CFLAGS', optflags pkg.environment 'MAKE', 'make' - elsif platform.is_cross_compiled? - pkg.environment 'CROSS_COMPILING', 'true' else pkg.environment 'optflags', '-O2' end @@ -103,26 +99,13 @@ # Ruby's build process requires a "base" ruby and we need a ruby to install # gems into the /opt/puppetlabs/puppet/lib directory. # - # For cross-compiles, the base ruby must be executable on the host we're - # building on (usually Intel), not the arch we're building for (such as - # SPARC). This is usually pl-ruby. - # # For native compiles, we don't want ruby's build process to use whatever ruby # is in the PATH, as it's probably too old to build ruby 3.2. And we don't # want to use/maintain pl-ruby if we don't have to. Instead set baseruby to # "no" which will force ruby to build and use miniruby. - special_flags += if platform.is_cross_compiled? - " --with-baseruby=#{host_ruby} " - else - ' --with-baseruby=no ' - end - - if platform.is_cross_compiled? && platform.is_macos? - # When the target arch is aarch64, ruby incorrectly selects the 'ucontext' coroutine - # implementation instead of 'arm64', so specify 'amd64' explicitly - # https://github.com/ruby/ruby/blob/c9c2245c0a25176072e02db9254f0e0c84c805cd/configure.ac#L2329-L2330 - special_flags += ' --with-coroutine=arm64 ' - elsif platform.is_windows? + special_flags += ' --with-baseruby=no ' + + if platform.is_windows? # ruby's configure script guesses the build host is `cygwin`, because we're using # cygwin opensshd & bash. So mkmf will convert compiler paths, e.g. -IC:/... to # cygwin paths, -I/cygdrive/c/..., which confuses mingw-w64. So specify the build @@ -207,22 +190,7 @@ # then the CC override allows us to build ffi_c.so for ARM as well. The # "host" ruby is configured in _shared-agent-settings rbconfig_changes = {} - if platform.is_cross_compiled? - 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 =~ /sles-12-ppc64le/ - # the ancient gcc version on sles-12-ppc64le does not understand -fstack-protector-strong, so remove the `strong` part - rbconfig_changes['LDFLAGS'] = - '-L. -Wl,-rpath=/opt/puppetlabs/puppet/lib -fstack-protector -rdynamic -Wl,-export-dynamic -L/opt/puppetlabs/puppet/lib' - end - elsif platform.is_macos? + if platform.is_macos? rbconfig_changes['CC'] = "#{settings[:cc]} #{cflags}" elsif platform.is_windows? rbconfig_changes['CC'] = if platform.architecture == 'x64' diff --git a/configs/components/ruby-augeas.rb b/configs/components/ruby-augeas.rb index f0ea6176..b51d30c8 100644 --- a/configs/components/ruby-augeas.rb +++ b/configs/components/ruby-augeas.rb @@ -11,19 +11,14 @@ pkg.environment 'CONFIGURE_ARGS', '--vendor' pkg.environment 'PKG_CONFIG_PATH', "#{File.join(settings[:libdir], 'pkgconfig')}:/usr/lib/pkgconfig" - if platform.is_cross_compiled? && (platform.is_linux? || platform.is_macos?) - pkg.environment 'RUBY', settings[:host_ruby] - ruby = "#{settings[:host_ruby]} -r#{settings[:datadir]}/doc/rbconfig-#{settings[:ruby_version]}-orig.rb" - pkg.environment 'LDFLAGS', settings[:ldflags] - elsif platform.is_macos? + ruby = File.join(settings[:ruby_bindir], 'ruby') + + if platform.is_macos? pkg.environment 'PATH', '$(PATH):/opt/homebrew/bin' if platform.architecture == 'arm64' pkg.environment 'CC', settings[:cc] pkg.environment 'CFLAGS', settings[:cflags] pkg.environment 'LDFLAGS', settings[:ldflags] pkg.environment 'MACOSX_DEPLOYMENT_TARGET', settings[:deployment_target] - ruby = File.join(settings[:ruby_bindir], 'ruby') - else - ruby = File.join(settings[:ruby_bindir], 'ruby') end pkg.build do @@ -65,12 +60,6 @@ ] end - if platform.is_cross_compiled_linux? - pkg.install do - "chown root:root #{augeas_rb_target}" - end - end - # Clean after install in case we are building for multiple rubies. pkg.install do "#{platform[:make]} -e clean" diff --git a/configs/components/ruby-selinux.rb b/configs/components/ruby-selinux.rb index 5c8c3f30..35c01f37 100644 --- a/configs/components/ruby-selinux.rb +++ b/configs/components/ruby-selinux.rb @@ -73,11 +73,6 @@ # Instead, we use the headers provided in the tarball. system_include.prepend('-I./include ') if platform.name =~ /el-(9|10)/ - if platform.is_cross_compiled_linux? - pkg.environment 'RUBY', settings[:host_ruby] - ruby = "#{settings[:host_ruby]} -r#{settings[:datadir]}/doc/rbconfig-#{settings[:ruby_version]}-orig.rb" - end - cflags = '' pkg.build do diff --git a/configs/components/ruby-shadow.rb b/configs/components/ruby-shadow.rb index 18b640b8..953ed4c9 100644 --- a/configs/components/ruby-shadow.rb +++ b/configs/components/ruby-shadow.rb @@ -7,20 +7,11 @@ pkg.load_from_json('configs/components/ruby-shadow.json') pkg.build_requires "ruby-#{settings[:ruby_version]}" - if !platform.is_cross_compiled? && platform.architecture == 'sparc' - pkg.environment 'PATH', '$(PATH):/opt/pl-build-tools/bin:/usr/ccs/bin:/usr/sfw/bin' - else - pkg.environment 'PATH', '$(PATH):/usr/ccs/bin:/usr/sfw/bin' - end + pkg.environment 'PATH', '$(PATH):/usr/ccs/bin:/usr/sfw/bin' pkg.environment 'CONFIGURE_ARGS', '--vendor' - if platform.is_cross_compiled? - pkg.environment 'RUBY', settings[:host_ruby] - ruby = "#{settings[:host_ruby]} -r#{settings[:datadir]}/doc/rbconfig-#{settings[:ruby_version]}-orig.rb" - else - ruby = File.join(settings[:ruby_bindir], 'ruby') - end + ruby = File.join(settings[:ruby_bindir], 'ruby') base = 'resources/patches/ruby_32' # https://github.com/apalmblad/ruby-shadow/issues/26 diff --git a/configs/components/rubygem-ffi.rb b/configs/components/rubygem-ffi.rb index b8d18b77..2a143321 100644 --- a/configs/components/rubygem-ffi.rb +++ b/configs/components/rubygem-ffi.rb @@ -5,7 +5,7 @@ # Notes: # Read the comments in the code below carefully. ##### -component 'rubygem-ffi' do |pkg, settings, platform| +component 'rubygem-ffi' do |pkg, settings, _platform| ### Maintained by update_gems automation ### pkg.version '1.17.4' pkg.sha256sum 'bcd1642e06f0d16fc9e09ac6d49c3a7298b9789bcb58127302f934e437d60acf' @@ -27,17 +27,4 @@ instance_eval File.read('configs/components/_base-rubygem.rb') pkg.environment 'PKG_CONFIG_PATH', '/opt/puppetlabs/puppet/lib/pkgconfig:$(PKG_CONFIG_PATH)' - - if platform.is_cross_compiled? && !platform.is_macos? - # Change this someday if we ever end up cross compiling OpenVox on Linux - # as we won't be using pl-build-tools there - base_ruby = '/opt/pl-build-tools/lib/ruby/2.1.0' - - # FFI 1.13.1 forced the minimum required ruby version to ~> 2.3 - # In order to be able to install the gem using pl-ruby(2.1.9) - # we need to remove the required ruby version check - pkg.configure do - %(#{platform[:sed]} -i '0,/ensure_required_ruby_version_met/b; /ensure_required_ruby_version_met/d' #{base_ruby}/rubygems/installer.rb) - end - end end diff --git a/configs/components/runtime-agent.rb b/configs/components/runtime-agent.rb index c12555a2..483bcf52 100644 --- a/configs/components/runtime-agent.rb +++ b/configs/components/runtime-agent.rb @@ -3,14 +3,6 @@ pkg.environment 'PROJECT_SHORTNAME', 'puppet' pkg.add_source 'file://resources/files/runtime/runtime.sh' - if platform.is_macos? && platform.is_cross_compiled? && (settings[:ruby_version] =~ /^3\./) - pkg.install do - # These are dependencies of ruby@3.x, remove symlinks from /usr/local - # so our build doesn't use the wrong headers - "cd /etc/homebrew && su test -c '#{platform.brew} unlink openssl libyaml'" - end - end - if platform.is_windows? lib_type = platform.architecture == 'x64' ? 'seh' : 'sjlj' pkg.install_file "#{settings[:gcc_bindir]}/libgcc_s_#{lib_type}-1.dll", diff --git a/configs/components/virt-what.rb b/configs/components/virt-what.rb index ebe188cb..ca44d4cf 100644 --- a/configs/components/virt-what.rb +++ b/configs/components/virt-what.rb @@ -13,21 +13,13 @@ pkg.replaces 'pe-virt-what' - # Run-time requirements - requires 'util-linux' unless platform.is_deb? - - pkg.build_requires 'util-linux' if platform.is_rpm? - - if platform.is_cross_compiled_linux? - host_opt = "--host #{settings[:platform_triple]}" - - pkg.environment 'PATH' => "/opt/pl-build-tools/bin:$$PATH:#{settings[:bindir]}" - pkg.environment 'CFLAGS' => settings[:cflags] - pkg.environment 'LDFLAGS' => settings[:ldflags] + if platform.is_rpm? + requires 'util-linux' + pkg.build_requires 'util-linux' end pkg.configure do - ["./configure --prefix=#{settings[:prefix]} --sbindir=#{settings[:prefix]}/bin --libexecdir=#{settings[:prefix]}/lib/virt-what #{host_opt}"] + ["./configure --prefix=#{settings[:prefix]} --sbindir=#{settings[:prefix]}/bin --libexecdir=#{settings[:prefix]}/lib/virt-what"] end pkg.build do diff --git a/configs/projects/_shared-agent-settings.rb b/configs/projects/_shared-agent-settings.rb index 4d68aa76..175721b6 100644 --- a/configs/projects/_shared-agent-settings.rb +++ b/configs/projects/_shared-agent-settings.rb @@ -78,7 +78,6 @@ raise "Couldn't find a :ruby_version setting in the project file" unless proj.ruby_version ruby_base_version = proj.ruby_version.gsub(/(\d+)\.(\d+)(\.\d+)?/, '\1.\2.0') -ruby_version_y = proj.ruby_version.gsub(/(\d+)\.(\d+)(\.\d+)?/, '\1.\2') proj.setting(:gem_home, File.join(proj.libdir, 'ruby', 'gems', ruby_base_version)) proj.setting(:ruby_vendordir, File.join(proj.libdir, 'ruby', 'vendor_ruby')) @@ -90,7 +89,6 @@ # Cross-compiled Linux platforms platform_triple = 'arm-linux-gnueabihf' if platform.architecture == 'armhf' -platform_triple = 'aarch64-apple-darwin' if platform.is_cross_compiled? && platform.is_macos? # Ruby's build process needs a functional "baseruby". When native compiling, # ruby will build "miniruby" and use that as "baseruby". When cross compiling, @@ -100,22 +98,12 @@ if platform.is_windows? proj.setting(:host_ruby, File.join(proj.ruby_bindir, 'ruby.exe')) proj.setting(:host_gem, File.join(proj.ruby_bindir, 'gem.bat')) -elsif platform.is_cross_compiled? && platform.is_linux? - proj.setting(:host_ruby, '/opt/pl-build-tools/bin/ruby') - proj.setting(:host_gem, '/opt/pl-build-tools/bin/gem') -elsif platform.is_cross_compiled? && platform.is_macos? - proj.setting(:host_ruby, "/usr/local/opt/ruby@#{ruby_version_y}/bin/ruby") - proj.setting(:host_gem, "/usr/local/opt/ruby@#{ruby_version_y}/bin/gem") else proj.setting(:host_ruby, File.join(proj.ruby_bindir, 'ruby')) proj.setting(:host_gem, File.join(proj.ruby_bindir, 'gem')) end -if platform.is_cross_compiled_linux? - host = "--host #{platform_triple}" -elsif platform.is_cross_compiled? && platform.is_macos? - host = '--host aarch64-apple-darwin --build x86_64-apple-darwin --target aarch64-apple-darwin' -elsif platform.is_windows? +if platform.is_windows? # For windows, we need to ensure we are building for mingw not cygwin platform_triple = platform.platform_triple host = "--host #{platform_triple}" @@ -145,8 +133,6 @@ proj.setting(:ldflags, ldflags) proj.setting(:cygwin, 'nodosfilewarning winsymlinks:native') -else - proj.setting(:tools_root, '/opt/pl-build-tools') end if platform.is_macos? diff --git a/configs/projects/agent-runtime-8.x.rb b/configs/projects/agent-runtime-8.x.rb index 2228112f..5c5d6ac6 100644 --- a/configs/projects/agent-runtime-8.x.rb +++ b/configs/projects/agent-runtime-8.x.rb @@ -16,12 +16,6 @@ # Directory for gems shared by puppet and puppetserver proj.setting(:puppet_gem_vendor_dir, File.join(proj.libdir, 'ruby', 'vendor_gems')) - # Ruby 2.7 loads openssl on installation. Because pl-ruby was not - # built with openssl support, we switch to compile with system - # rubies. - # Solaris 11 seems to work with pl-ruby, and 10 is handled in _shared-agent-settings.rb. - proj.setting(:host_ruby, '/usr/bin/ruby') if platform.is_cross_compiled_linux? - # Ruby 2.6 (RubyGems 3.0.1) removed the --ri and --rdoc # options. Switch to using --no-document which is available starting # with RubyGems 2.0.0preview2. This should also cover cross-compiled @@ -89,10 +83,6 @@ proj.component 'ruby-selinux' end - if platform.is_cross_compiled? - proj.component 'pl-ruby-patch' - end - if platform.is_windows? proj.component 'rubygem-minitar' end diff --git a/configs/projects/agent-runtime-main.rb b/configs/projects/agent-runtime-main.rb index a0de9392..1925e8a2 100644 --- a/configs/projects/agent-runtime-main.rb +++ b/configs/projects/agent-runtime-main.rb @@ -16,12 +16,6 @@ # Directory for gems shared by puppet and puppetserver proj.setting(:puppet_gem_vendor_dir, File.join(proj.libdir, 'ruby', 'vendor_gems')) - # Ruby 2.7 loads openssl on installation. Because pl-ruby was not - # built with openssl support, we switch to compile with system - # rubies. - # Solaris 11 seems to work with pl-ruby, and 10 is handled in _shared-agent-settings.rb. - proj.setting(:host_ruby, '/usr/bin/ruby') if platform.is_cross_compiled_linux? - # Ruby 2.6 (RubyGems 3.0.1) removed the --ri and --rdoc # options. Switch to using --no-document which is available starting # with RubyGems 2.0.0preview2. This should also cover cross-compiled @@ -89,10 +83,6 @@ proj.component 'ruby-selinux' end - if platform.is_cross_compiled? - proj.component 'pl-ruby-patch' - end - if platform.is_windows? proj.component 'rubygem-minitar' end diff --git a/resources/files/ruby/patch-hostruby.rb b/resources/files/ruby/patch-hostruby.rb deleted file mode 100644 index 9b7afd40..00000000 --- a/resources/files/ruby/patch-hostruby.rb +++ /dev/null @@ -1,141 +0,0 @@ -# When cross compiling we need to run gem install using the host ruby, but -# force ruby to use our overridden rbconfig.rb. To do that, we insert a -# require statement between the ruby executable and it's first argument, -# thereby hooking the ruby process. -# -# In the future we could use the --target-rbconfig= option to point -# to our rbconfig.rb. But that option is only available in newer ruby versions. -require 'rbconfig' -require 'tempfile' - -if ARGV.length < 2 - warn <<~USAGE - USAGE: patch-hostruby.rb - - example: patch-hostruby.rb 3.2.2 arm64-darwin - USAGE - exit(1) -end - -# target ruby versions (what we're trying to build) -target_ruby_version = ARGV[0] -target_triple = ARGV[1] -target_api_version = target_ruby_version.gsub(/\.\d*$/, '.0') - -# host ruby (the ruby we execute to build the target) -host_rubylibdir = RbConfig::CONFIG['rubylibdir'] -GEM_VERSION = Gem::Version.new(Gem::VERSION) - -# Rewrite the file in-place securely, yielding each line to the caller -def rewrite(file) - # create temp file in the same directory as the file we're patching, - # so rename doesn't cross filesystems - tmpfile = Tempfile.new(File.basename(file), File.dirname(file)) - begin - File.open("#{file}.orig", 'w') do |orig| - File.open(file, 'r').readlines.each do |line| - orig.write(line) - yield line - tmpfile.write(line) - end - end - ensure - tmpfile.close - File.unlink(file) - File.rename(tmpfile.path, file) - tmpfile.unlink - end -end - -# Based on the RUBYGEMS version of the host ruby, the line and file that needs patching is different -# Note the RUBY version doesn't matter (for either the host or target ruby). -# -# Here we define different intervals. For each interval, we specify the regexp to match, what to -# replace it with, and which file to edit in-place. Note `\&` is a placeholder for whatever the regexp -# was, that way we can easily append to it. And since it's in a double quoted string, it's escaped -# as `\\&` -# -if Gem::Version.new('2.0.0') >= GEM_VERSION - # $ git show v2.0.0:lib/rubygems/ext/ext_conf_builder.rb - # cmd = "#{Gem.ruby} #{File.basename extension}" - regexp = /{Gem\.ruby}/ - replace = "\\& -r/opt/puppetlabs/puppet/share/doc/rbconfig-#{target_ruby_version}-orig.rb" - builder = 'rubygems/ext/ext_conf_builder.rb' -elsif Gem::Version.new('3.0.0') > GEM_VERSION # there weren't any tags between >= 2.7.11 and < 3.0.0 - # $ git show v2.0.1:lib/rubygems/ext/ext_conf_builder.rb - # cmd = [Gem.ruby, File.basename(extension), *args].join ' ' - # - # $ git show v2.7.11:lib/rubygems/ext/ext_conf_builder.rb - # cmd = [Gem.ruby, "-r", get_relative_path(siteconf.path), File.basename(extension), *args].join ' ' - regexp = /Gem\.ruby/ - replace = "\\&, '-r/opt/puppetlabs/puppet/share/doc/rbconfig-#{target_ruby_version}-orig.rb'" - builder = 'rubygems/ext/ext_conf_builder.rb' -elsif Gem::Version.new('3.4.8') >= GEM_VERSION - # $ git show v3.0.0:lib/rubygems/ext/ext_conf_builder.rb - # cmd = Gem.ruby.shellsplit << "-I" << File.expand_path("../../..", __FILE__) << - # - # $ git show v3.4.8:lib/rubygems/ext/ext_conf_builder.rb - # cmd = Gem.ruby.shellsplit << "-I" << File.expand_path("../..", __dir__) << File.basename(extension) - regexp = /Gem\.ruby\.shellsplit/ - replace = "\\& << '-r/opt/puppetlabs/puppet/share/doc/rbconfig-#{target_ruby_version}-orig.rb'" - builder = 'rubygems/ext/ext_conf_builder.rb' -elsif Gem::Version.new('3.4.14') >= GEM_VERSION - # NOTE: rubygems 3.4.9 moved the code to builder.rb - # - # $ git show v3.4.9:lib/rubygems/ext/builder.rb - # cmd = Gem.ruby.shellsplit - # - # $ git show v3.4.14:lib/rubygems/ext/builder.rb - # cmd = Gem.ruby.shellsplit - regexp = /Gem\.ruby\.shellsplit/ - replace = "\\& << '-r/opt/puppetlabs/puppet/share/doc/rbconfig-#{target_ruby_version}-orig.rb'" - builder = 'rubygems/ext/builder.rb' -elsif Gem::Version.new('3.5.16') >= GEM_VERSION - # $ git show v3.4.9:lib/rubygems/ext/builder.rb - # cmd = Shellwords.split(Gem.ruby) - # - # $ git show v3.5.10:lib/rubygems/ext/builder.rb - # cmd = Shellwords.split(Gem.ruby) - regexp = /Shellwords\.split\(Gem\.ruby\)/ - replace = "\\& << '-r/opt/puppetlabs/puppet/share/doc/rbconfig-#{target_ruby_version}-orig.rb'" - builder = 'rubygems/ext/builder.rb' -else - raise "We don't know how to patch rubygems #{GEM_VERSION}" -end - -# path to the builder file on the HOST ruby -builder = File.join(host_rubylibdir, builder) - -raise "We can't patch #{builder} because it doesn't exist" unless File.exist?(builder) - -# hook rubygems builder so it loads our rbconfig when building native gems -patched = false -rewrite(builder) do |line| - patched = true if line.gsub!(regexp, replace) -end - -raise "Failed to patch rubygems hook, because we couldn't match #{regexp} in #{builder}" unless patched - -puts "Patched '#{regexp.inspect}' in #{builder}" - -# solaris 10 uses ruby 2.0 which doesn't install native extensions based on architecture -if RUBY_PLATFORM !~ /solaris2\.10$/ || RUBY_VERSION != '2.0.0' - # ensure native extensions are written to a directory that matches the - # architecture of the target ruby we're building for. To do that we - # patch the host ruby to pretend to be the target architecture. - triple_patched = false - api_version_patched = false - spec_file = "#{host_rubylibdir}/rubygems/basic_specification.rb" - rewrite(spec_file) do |line| - triple_patched = true if line.gsub!(/Gem::Platform\.local\.to_s/, "'#{target_triple}'") - api_version_patched = true if line.gsub!(/Gem\.extension_api_version/, "'#{target_api_version}'") - end - - raise "Failed to patch '#{target_triple}' in #{spec_file}" unless triple_patched - - puts "Patched '#{target_triple}' in #{spec_file}" - - raise "Failed to patch '#{target_api_version}' in #{spec_file}" unless api_version_patched - - puts "Patched '#{target_api_version}' in #{spec_file}" -end diff --git a/resources/patches/ruby_32/rbinstall_gem_path.patch b/resources/patches/ruby_32/rbinstall_gem_path.patch deleted file mode 100644 index 531795a7..00000000 --- a/resources/patches/ruby_32/rbinstall_gem_path.patch +++ /dev/null @@ -1,22 +0,0 @@ -diff --git a/tool/rbinstall.rb b/tool/rbinstall.rb -index f910fca57b..8eebd3f522 100755 ---- a/tool/rbinstall.rb -+++ b/tool/rbinstall.rb -@@ -942,7 +942,7 @@ def load_gemspec(file, base = nil) - end - - def install_default_gem(dir, srcdir, bindir) -- gem_dir = Gem.default_dir -+ gem_dir = "/opt/puppetlabs/puppet/lib/ruby/gems/3.2.0" - install_dir = with_destdir(gem_dir) - prepare "default gems from #{dir}", gem_dir - RbInstall.no_write do -@@ -991,7 +991,7 @@ def install_default_gem(dir, srcdir, bindir) - end - - install?(:ext, :comm, :gem, :'bundled-gems') do -- gem_dir = Gem.default_dir -+ gem_dir = "/opt/puppetlabs/puppet/lib/ruby/gems/3.2.0" - install_dir = with_destdir(gem_dir) - prepare "bundled gems", gem_dir - RbInstall.no_write do