mirror of
https://github.com/chromebrew/chromebrew.git
synced 2026-01-08 23:18:10 -05:00
glibc rebuild + breakout of crew_preload => fix installs. (#11949)
* glibc: Several improvements Signed-off-by: SupeChicken666 <me@supechicken666.dev> * Unset LD_PRELOAD before build Signed-off-by: SupeChicken666 <me@supechicken666.dev> * Adjust make to avoid segfaults. Signed-off-by: Satadru Pramanik <satadru@gmail.com> * build changes Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Add built packages for linux/386 to glibc_update * Add built packages for linux/amd64 to glibc_update * Add built packages for linux/arm/v7 to glibc_update * add armv7l binaries Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Make lib64 aarch64 changes clearer. Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Adjust crew_profile_base to remove LD_LIBRARY_PATH Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Adjust LD_LIBRARY_PATH setting again. Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Handle arm multiarch. Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Adjust installer LD_LIBRARY_PATH Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Remove core. Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Update install.sh to working version. Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Add crew_preload package. Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Update preload logic... Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Update hashes, add crew_preload to CREW_ESSENTIAL_PACKAGES. Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Remove preload install sections from install.sh now that there is a separate crew_preload package. Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Add build instructions reference to crew_preload package. Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Bring over more from the old install.sh Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Fix install on older systems. Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Let CREW_ESSENTIAL_PACKAGES work on older syatems. Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Move down setting of repo variables to after initial system checks exit. Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Use right ldconfig. Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Remove sudo from ldconfig call. Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Adjust locale generation. Signed-off-by: Satadru Pramanik <satadru@gmail.com> * cleanup Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Add condition for crew_preload. Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Remove duplicate hashes. Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Handle some install errors. Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Update ncurses, readline, bash Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Add update of sudo_rs Signed-off-by: Satadru Pramanik <satadru@gmail.com> * ruby updates Signed-off-by: Satadru Pramanik <satadru@gmail.com> * llvm => 20.1.6 Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Rust rebuilds to work on older container glibcs... Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Remove instance variable. Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Add libxcrypt to core. Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Use our versions of core apps where possible, since they will likely be newer than system binaries. Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Universalize fixup to work with pre_glibc_standalone branch. Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Rename function to better describe what it does. Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Rebuild filecmd and update edit. Signed-off-by: Satadru Pramanik <satadru@gmail.com> * package updates/rebuilds Signed-off-by: Satadru Pramanik <satadru@gmail.com> * updates and rebuilds Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Update unit tests. Signed-off-by: Satadru Pramanik <satadru@gmail.com> * fixup Signed-off-by: Satadru Pramanik <satadru@gmail.com> * gettext rebuild Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Add upx and patchelf to essential packages, to avoid unit test failure. Signed-off-by: Satadru Pramanik <satadru@gmail.com> * updates & rebuilds Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Update install.sh Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Install adjustment. Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Install adjustment. Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Break out curl dependencies in install.sh Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Adjust install.sh for arm. Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Handle remove during upgrade of special packages. Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Adjust to notice empty CREW_ESSENTIAL_PACKAGES during remove. Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Add libxcrypt to CREW_ESSENTIAL_PACKAGES Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Adjust CREW_STANDALONE_UPGRADE_ORDER Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Lint ruby package as per new rubocop. Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Simplify getrealdeps.rb Signed-off-by: Satadru Pramanik <satadru@gmail.com> * lint Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Ruby rebuild Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Add usage of docker tmpfs to workflows. Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Update python3 Signed-off-by: Satadru Pramanik <satadru@gmail.com> * rebuild ruby Signed-off-by: Satadru Pramanik <satadru@gmail.com> * rebuild zlib Signed-off-by: Satadru Pramanik <satadru@gmail.com> * install testing Signed-off-by: Satadru Pramanik <satadru@gmail.com> * curl rebuild with older glibc Signed-off-by: Satadru Pramanik <satadru@gmail.com> * cleanup Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Adjust packages to reduce subshells during install. Signed-off-by: Satadru Pramanik <satadru@gmail.com> * lint Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Handle ELOOP exception. Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Add gcc15 rebuild. Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Rebuild binutils without gcc version. Signed-off-by: Satadru Pramanik <satadru@gmail.com> * lint Signed-off-by: Satadru Pramanik <satadru@gmail.com> * lint Signed-off-by: Satadru Pramanik <satadru@gmail.com> * update cmake Signed-off-by: Satadru Pramanik <satadru@gmail.com> * lint Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Add date stamp to installer.sh Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Update libxml2 Signed-off-by: Satadru Pramanik <satadru@gmail.com> * shared_mime_info rebuild Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Many updates rebuilt on a lower glibc Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Add updates Signed-off-by: Satadru Pramanik <satadru@gmail.com> * updates Signed-off-by: Satadru Pramanik <satadru@gmail.com> * sync up from pre_glibc_standalone Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Merge pre_glibc_standalone and master versions of glibc.rb. Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Sync back deprecated glibc packages from pre_glibc_standalone. Signed-off-by: Satadru Pramanik <satadru@gmail.com> * lint packages/rust.rb Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Add versioning to installer error message. Signed-off-by: Satadru Pramanik <satadru@gmail.com> * perl => 5.40.2 Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Add more variable setting to install.sh Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Reverse logic in glibc.rb Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Adjust curl_wrapper logic in install.sh Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Allow glibc package to pass rubocop. Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Adjust installer. Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Gate new glibc behind CREW_PRE_GLIBC_STANDALONE env variable. Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Update lib/const.rb Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update mold Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Adjust installer. Signed-off-by: Satadru Pramanik <satadru@gmail.com> * debug Signed-off-by: Satadru Pramanik <satadru@gmail.com> * rebuild uchardet Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Python Tweaks. Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Python Tweaks Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Arm install adjustment Signed-off-by: Satadru Pramanik <satadru@gmail.com> * xzutils rebuild Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Adjust installer to detect i686 in container. Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Add message to source bashrc to end of install. Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Fix Updater workflow Signed-off-by: Satadru Pramanik <satadru@gmail.com> * updates Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Rebuild lz4, adjust meson buildsystem to handle alternate location for meson files. Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Rebuild zlib Signed-off-by: Satadru Pramanik <satadru@gmail.com> * rebuild xzutils Signed-off-by: Satadru Pramanik <satadru@gmail.com> * rebuild libyaml Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Rebuilds of acl and attr for i686 Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Update automake and add no_filefix to autotools buildsystem. Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Rebuild acl, attr, and revert from gettext 0.25, which is broken when using autopoint on x86_64 and armv7l. Signed-off-by: Satadru Pramanik <satadru@gmail.com> * adjust core for i686 Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Adjustments for i686 installs. Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Add ruby_prism to ruby_rubocop_ast package. Signed-off-by: Satadru Pramanik <satadru@gmail.com> * lint Signed-off-by: Satadru Pramanik <satadru@gmail.com> * updates Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Adjust messages Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Update compatibility of uutils_coreutils. Signed-off-by: Satadru Pramanik <satadru@gmail.com> * lint Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Adjust install for both M136 hatch and M136 strongbad. Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Use Concurrent Ruby for upx and patchelf. Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Switch installer to using static zstd. Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Update packages/zstd_static.rb Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Make final crew update in install more robust. Signed-off-by: Satadru Pramanik <satadru@gmail.com> * install adjustments. Signed-off-by: Satadru Pramanik <satadru@gmail.com> * lint Signed-off-by: Satadru Pramanik <satadru@gmail.com> --------- Signed-off-by: SupeChicken666 <me@supechicken666.dev> Signed-off-by: Satadru Pramanik <satadru@gmail.com> Co-authored-by: SupeChicken666 <me@supechicken666.dev> Co-authored-by: Satadru Pramanik <satadru@gmail.com> Co-authored-by: satmandu <satmandu@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Ed Reel <edreel@gmail.com>
This commit is contained in:
committed by
GitHub
parent
77775caa56
commit
a34f619bdb
124
lib/fixup.rb
124
lib/fixup.rb
@@ -20,8 +20,8 @@ CREW_LIB_PATH ||= File.join(CREW_PREFIX, 'lib/crew')
|
||||
|
||||
CREW_CONFIG_PATH ||= File.join(CREW_PREFIX, 'etc/crew')
|
||||
CREW_META_PATH ||= File.join(CREW_CONFIG_PATH, 'meta')
|
||||
CREW_REPO ||= 'https://github.com/chromebrew/chromebrew.git'
|
||||
CREW_BRANCH ||= 'master'
|
||||
CREW_REPO ||= ENV.fetch('CREW_REPO', 'https://github.com/chromebrew/chromebrew.git') unless defined?(CREW_REPO)
|
||||
CREW_BRANCH ||= ENV.fetch('CREW_BRANCH', 'master') unless defined?(CREW_BRANCH)
|
||||
|
||||
load "#{CREW_LIB_PATH}/lib/const.rb"
|
||||
load "#{CREW_LIB_PATH}/lib/package.rb"
|
||||
@@ -112,9 +112,6 @@ renamed_packages = Set[
|
||||
{ pkg_name: 'codium', pkg_rename: 'vscodium', comments: 'Renamed to better match upstream.' },
|
||||
{ pkg_name: 'dstat', pkg_rename: 'py3_dool', comments: 'Following upstream rename.' },
|
||||
{ pkg_name: 'ffcall', pkg_rename: 'libffcall', comments: 'Renamed to better match upstream.' },
|
||||
{ pkg_name: 'glibc_dev', pkg_rename: 'glibc', comments: 'Renamed to better match upstream.' },
|
||||
{ pkg_name: 'glibc_lib', pkg_rename: 'glibc', comments: 'Renamed to better match upstream.' },
|
||||
{ pkg_name: 'glibc_standalone', pkg_rename: 'glibc', comments: 'Renamed to better match upstream.' },
|
||||
{ pkg_name: 'itstool', pkg_rename: 'py3_itstool', comments: 'Renamed to indicate switch to pip buildsystem.' },
|
||||
{ pkg_name: 'jsonc', pkg_rename: 'json_c', comments: 'Renamed to better match upstream.' },
|
||||
{ pkg_name: 'libcurl', pkg_rename: 'curl', comments: 'Renamed to better match upstream.' },
|
||||
@@ -162,29 +159,16 @@ renamed_packages = Set[
|
||||
{ pkg_name: 'zlibpkg', pkg_rename: 'zlib', comments: 'Renamed to better match upstream.' }
|
||||
]
|
||||
|
||||
unless CREW_PRE_GLIBC_STANDALONE
|
||||
renamed_packages << { pkg_name: 'glibc_dev', pkg_rename: 'glibc', comments: 'Renamed to better match upstream.' }
|
||||
renamed_packages << { pkg_name: 'glibc_lib', pkg_rename: 'glibc', comments: 'Renamed to better match upstream.' }
|
||||
renamed_packages << { pkg_name: 'glibc_standalone', pkg_rename: 'glibc', comments: 'Renamed to better match upstream.' }
|
||||
end
|
||||
|
||||
deprecated_packages = Set[
|
||||
{ pkg_name: 'epydoc', comments: 'Abandoned upstream, only supports Python 2.' },
|
||||
{ pkg_name: 'gfbgraph', commwnts: 'Deprecated upstteam.' },
|
||||
{ pkg_name: 'gfbgraph', commwnts: 'Deprecated upstream.' },
|
||||
{ pkg_name: 'git_prompt', comments: 'Integrated into git package.' },
|
||||
{ pkg_name: 'glibc_build223', comments: 'We are moving away from system glibc.' },
|
||||
{ pkg_name: 'glibc_build227', comments: 'We are moving away from system glibc.' },
|
||||
{ pkg_name: 'glibc_build232', comments: 'We are moving away from system glibc.' },
|
||||
{ pkg_name: 'glibc_build233', comments: 'We are moving away from system glibc.' },
|
||||
{ pkg_name: 'glibc_build235', comments: 'We are moving away from system glibc.' },
|
||||
{ pkg_name: 'glibc_build237', comments: 'We are moving away from system glibc.' },
|
||||
{ pkg_name: 'glibc_dev223', comments: 'We are moving away from system glibc.' },
|
||||
{ pkg_name: 'glibc_dev227', comments: 'We are moving away from system glibc.' },
|
||||
{ pkg_name: 'glibc_dev232', comments: 'We are moving away from system glibc.' },
|
||||
{ pkg_name: 'glibc_dev233', comments: 'We are moving away from system glibc.' },
|
||||
{ pkg_name: 'glibc_dev235', comments: 'We are moving away from system glibc.' },
|
||||
{ pkg_name: 'glibc_dev237', comments: 'We are moving away from system glibc.' },
|
||||
{ pkg_name: 'glibc_fallthrough', comments: 'We are moving away from system glibc.' },
|
||||
{ pkg_name: 'glibc_lib223', comments: 'We are moving away from system glibc.' },
|
||||
{ pkg_name: 'glibc_lib227', comments: 'We are moving away from system glibc.' },
|
||||
{ pkg_name: 'glibc_lib232', comments: 'We are moving away from system glibc.' },
|
||||
{ pkg_name: 'glibc_lib233', comments: 'We are moving away from system glibc.' },
|
||||
{ pkg_name: 'glibc_lib235', comments: 'We are moving away from system glibc.' },
|
||||
{ pkg_name: 'glibc_lib237', comments: 'We are moving away from system glibc.' },
|
||||
{ pkg_name: 'gnome_session', comments: 'No longer compatible with any architecture, requires systemd.' },
|
||||
{ pkg_name: 'gnome_settings_daemon', comments: 'No longer compatible with any architecture, requires systemd.' },
|
||||
{ pkg_name: 'gnome_shell', comments: 'No longer compatible with any architecture, requires systemd.' },
|
||||
@@ -205,6 +189,28 @@ deprecated_packages = Set[
|
||||
{ pkg_name: 'skype', comments: 'Officially sunsetting and will be shut down soon.' }
|
||||
]
|
||||
|
||||
unless CREW_PRE_GLIBC_STANDALONE
|
||||
deprecated_packages << { pkg_name: 'glibc_build223', comments: 'We are moving away from system glibc.' }
|
||||
deprecated_packages << { pkg_name: 'glibc_build227', comments: 'We are moving away from system glibc.' }
|
||||
deprecated_packages << { pkg_name: 'glibc_build232', comments: 'We are moving away from system glibc.' }
|
||||
deprecated_packages << { pkg_name: 'glibc_build233', comments: 'We are moving away from system glibc.' }
|
||||
deprecated_packages << { pkg_name: 'glibc_build235', comments: 'We are moving away from system glibc.' }
|
||||
deprecated_packages << { pkg_name: 'glibc_build237', comments: 'We are moving away from system glibc.' }
|
||||
deprecated_packages << { pkg_name: 'glibc_dev223', comments: 'We are moving away from system glibc.' }
|
||||
deprecated_packages << { pkg_name: 'glibc_dev227', comments: 'We are moving away from system glibc.' }
|
||||
deprecated_packages << { pkg_name: 'glibc_dev232', comments: 'We are moving away from system glibc.' }
|
||||
deprecated_packages << { pkg_name: 'glibc_dev233', comments: 'We are moving away from system glibc.' }
|
||||
deprecated_packages << { pkg_name: 'glibc_dev235', comments: 'We are moving away from system glibc.' }
|
||||
deprecated_packages << { pkg_name: 'glibc_dev237', comments: 'We are moving away from system glibc.' }
|
||||
deprecated_packages << { pkg_name: 'glibc_fallthrough', comments: 'We are moving away from system glibc.' }
|
||||
deprecated_packages << { pkg_name: 'glibc_lib223', comments: 'We are moving away from system glibc.' }
|
||||
deprecated_packages << { pkg_name: 'glibc_lib227', comments: 'We are moving away from system glibc.' }
|
||||
deprecated_packages << { pkg_name: 'glibc_lib232', comments: 'We are moving away from system glibc.' }
|
||||
deprecated_packages << { pkg_name: 'glibc_lib233', comments: 'We are moving away from system glibc.' }
|
||||
deprecated_packages << { pkg_name: 'glibc_lib235', comments: 'We are moving away from system glibc.' }
|
||||
deprecated_packages << { pkg_name: 'glibc_lib237', comments: 'We are moving away from system glibc.' }
|
||||
end
|
||||
|
||||
# Handle package renames.
|
||||
renamed_pkgs = renamed_packages.map { |h| h[:pkg_name] }
|
||||
installed_pkgs_to_rename = @installed_packages & renamed_pkgs
|
||||
@@ -282,39 +288,55 @@ unless installed_pkgs_to_deprecate.empty?
|
||||
end
|
||||
|
||||
if File.exist?("#{CREW_PREFIX}/bin/upx") && File.exist?("#{CREW_PREFIX}/bin/patchelf")
|
||||
puts 'Running upx to uncompress binaries and patchelf to patch binary interpreter paths.'.lightblue
|
||||
abort('No Patchelf found!').lightred unless File.file?("#{CREW_PREFIX}/bin/patchelf")
|
||||
abort('No Upx found!').lightred unless File.file?("#{CREW_PREFIX}/bin/upx")
|
||||
abort("No Upx found! Please run 'crew install upx'").lightred unless File.file?("#{CREW_PREFIX}/bin/upx")
|
||||
abort("No Patchelf found! Please run 'crew install patchelf'").lightred unless File.file?("#{CREW_PREFIX}/bin/patchelf")
|
||||
puts "Running upx to uncompress binaries #{'and patchelf to patch binary interpreter paths ' unless CREW_PRE_GLIBC_STANDALONE}if needed.".lightblue
|
||||
# Look for installed binaries and libraries in /usr/local and the lib
|
||||
# prefix directories.
|
||||
execfiles = `find #{CREW_PREFIX}/bin #{CREW_LIB_PREFIX} -executable -type f ! \\( -name '*.a' \\) | xargs -P#{CREW_NPROC} -n1 sh -c '[ "$(head -c4 ${1})" = "\x7FELF" ] && echo ${1}' -- 2> /dev/null`.split
|
||||
execfiles = Find.find("#{CREW_PREFIX}/bin", CREW_LIB_PREFIX).select { |p| File.executable?(p) }
|
||||
return if execfiles.empty?
|
||||
|
||||
@localdir = File.expand_path('../../.')
|
||||
require_gem 'concurrent-ruby'
|
||||
pool = Concurrent::ThreadPoolExecutor.new(
|
||||
min_threads: 1,
|
||||
max_threads: CREW_NPROC,
|
||||
max_queue: 0, # unbounded work queue
|
||||
fallback_policy: :caller_runs
|
||||
)
|
||||
execfiles.each do |execfiletopatch|
|
||||
next unless File.file?(execfiletopatch)
|
||||
# Decompress the binary if compressed.
|
||||
system "upx -qq -d #{execfiletopatch}", %i[err] => File::NULL
|
||||
# Check for existing interpreter.
|
||||
@interpreter, _read_interpreter_stderr_s, @read_interpreter_status = Open3.capture3("patchelf --print-interpreter #{execfiletopatch}")
|
||||
# Set interpreter unless the interpreter read failed or is already
|
||||
# set appropriately.
|
||||
unless @read_interpreter_status && @interpreter == CREW_GLIBC_INTERPRETER
|
||||
puts "Running patchelf on #{execfiletopatch} to set interpreter".orange if CREW_VERBOSE
|
||||
_set_interpreter_stdout, @set_interpreter_stderr = Open3.capture3("patchelf --set-interpreter #{CREW_GLIBC_INTERPRETER} #{execfiletopatch}")
|
||||
puts "#{execfiletopatch}: @set_interpreter_stderr: #{@set_interpreter_stderr.chomp}".lightpurple if !@set_interpreter_stderr.blank? && CREW_VERBOSE
|
||||
|
||||
pool.post do
|
||||
# Decompress the binary if compressed.
|
||||
system "upx -qq -d #{execfiletopatch}", %i[err] => File::NULL, exception: false
|
||||
|
||||
# Check for existing interpreter.
|
||||
next if CREW_GLIBC_INTERPRETER.blank?
|
||||
|
||||
@interpreter, _read_interpreter_stderr_s, @read_interpreter_status = Open3.capture3("patchelf --print-interpreter #{execfiletopatch}")
|
||||
# Set interpreter unless the interpreter read failed or is already
|
||||
# set appropriately.
|
||||
unless @read_interpreter_status && @interpreter == CREW_GLIBC_INTERPRETER
|
||||
puts "Running patchelf on #{execfiletopatch} to set interpreter".orange if CREW_VERBOSE
|
||||
_set_interpreter_stdout, @set_interpreter_stderr = Open3.capture3("patchelf --set-interpreter #{CREW_GLIBC_INTERPRETER} #{execfiletopatch}")
|
||||
puts "#{execfiletopatch}: @set_interpreter_stderr: #{@set_interpreter_stderr.chomp}".lightpurple if !@set_interpreter_stderr.blank? && CREW_VERBOSE
|
||||
end
|
||||
# Try to read any existing rpath.
|
||||
@read_rpath_stdout_s, @read_rpath_stderr_s, @read_rpath_status = Open3.capture3("patchelf --print-rpath #{execfiletopatch}")
|
||||
@exec_rpath = @read_rpath_stdout_s.chomp
|
||||
@rpath_status = @read_rpath_status
|
||||
puts "#{execfiletopatch}: @read_rpath_stderr_s: #{@read_rpath_stderr_s}".lightpurple if !@read_rpath_stderr_s.blank? && CREW_VERBOSE
|
||||
# Set rpath if rpath read didn't fail, an rpath exists, and does not
|
||||
# already contain CREW_GLIBC_PREFIX.
|
||||
next if !@read_rpath_rpath_status || @exec_rpath.blank? || @exec_rpath.include?(CREW_GLIBC_PREFIX)
|
||||
puts "#{execfiletopatch.gsub(@localdir, '')} has an existing rpath of #{@exec_rpath}".lightpurple if CREW_VERBOSE
|
||||
puts "Prefixing #{CREW_GLIBC_PREFIX} to #{@exec_rpath} rpath for #{execfiletopatch.gsub(@localdir, '')}.".lightblue
|
||||
@set_rpath_stdout_s, @set_rpath_stderr_s, @set_rpath_status = Open3.capture3("patchelf --set-rpath #{CREW_GLIBC_PREFIX}:#{@exec_rpath} #{execfiletopatch}")
|
||||
puts "#{execfiletopatch}: @set_rpath_stderr_s: #{@set_rpath_stderr_s}".lightpurple if !@set_rpath_stderr_s.blank? && CREW_VERBOSE
|
||||
end
|
||||
# Try to read any existing rpath.
|
||||
@read_rpath_stdout_s, @read_rpath_stderr_s, @read_rpath_status = Open3.capture3("patchelf --print-rpath #{execfiletopatch}")
|
||||
@exec_rpath = @read_rpath_stdout_s.chomp
|
||||
@rpath_status = @read_rpath_status
|
||||
puts "#{execfiletopatch}: @read_rpath_stderr_s: #{@read_rpath_stderr_s}".lightpurple if !@read_rpath_stderr_s.blank? && CREW_VERBOSE
|
||||
# Set rpath if rpath read didn't fail, an rpath exists, and does not
|
||||
# already contain CREW_GLIBC_PREFIX.
|
||||
next if !@read_rpath_rpath_status || @exec_rpath.blank? || @exec_rpath.include?(CREW_GLIBC_PREFIX)
|
||||
puts "#{execfiletopatch} has an existing rpath of #{@exec_rpath}".lightpurple if CREW_VERBOSE
|
||||
puts "Prefixing #{CREW_GLIBC_PREFIX} to #{@exec_rpath} rpath for #{execfiletopatch}.".lightblue
|
||||
@set_rpath_stdout_s, @set_rpath_stderr_s, @set_rpath_status = Open3.capture3("patchelf --set-rpath #{CREW_GLIBC_PREFIX}:#{@exec_rpath} #{execfiletopatch}")
|
||||
puts "#{execfiletopatch}: @set_rpath_stderr_s: #{@set_rpath_stderr_s}".lightpurple if !@set_rpath_stderr_s.blank? && CREW_VERBOSE
|
||||
pool.shutdown
|
||||
pool.wait_for_termination
|
||||
end
|
||||
else
|
||||
abort 'Please install upx and patchelf first by running \'crew install upx patchelf\'.'.lightred
|
||||
|
||||
Reference in New Issue
Block a user