Files
chromebrew/packages/glibc_lib237.rb
Satadru Pramanik, DO, MPH, MEng 386f42ff6e Fix for require issues with highline and glibc 2.37 refactor (#10363)
* Adjust highline requires.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Refactor glibc_build237.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Adjust cmake logic for cmake_build_relative_dir.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Update buildsystems...

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Rebuild glibc 2.37 packages.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Adjust fixup for case of loading from much older crew.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Try to handle loading fixup on older crew update.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Handle older crew setups.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Use rubocop exclusion for only const.rb and fixup.rb.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Remove attr_accessor from buildsystems.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Force update compatible if coming from an older crew.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* remove require_gem from package.rb

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Add fallback for remove.rb

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* const tweaks...

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Adjust const.rb & fixup.rb to remove error messages on load after require.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Make remove run crew update compatible if being run on a newer underlying chromebrew.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* lint

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Adjust fixup to be more resilient to being loaded in an older crew.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Switch from symbolized json import.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* fixup

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* fixup

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* fixup

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* fixup

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Revert most changes.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Adjust essential deps handling in fixup.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Cleanup save_json in fixup.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* update highline

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* save json more.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* save json more.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* test remove changes

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Add more remove debug code.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Add more remove debug code.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* add debug to fixup

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* add debug to fixup

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* add debug to fixup

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* fixup

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Refresh crew json when calling crew functions or exiting fixup.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Refresh crew json when calling crew functions or exiting fixup.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* fixup

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* fix json string usage in remove

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* essential package debugging

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* fixup

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* fixup

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Adjust remove debugging...

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* more remove debugging

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Remove debugging code from commands/remove.rb

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Remove more debugging code from lib/fixup.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Adjust remove test to test both remove with and without debug argument.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Update const.rb to not set x86 constants when not on x86.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Set x86 constants to nil when not on x86.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Bump crew version.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

---------

Signed-off-by: Satadru Pramanik <satadru@gmail.com>
2024-08-31 14:06:18 -05:00

87 lines
3.7 KiB
Ruby

require 'package'
Package.load_package("#{__dir__}/glibc_build237.rb")
class Glibc_lib237 < Package
description 'glibc libraries'
homepage Glibc_build237.homepage
version '2.37-patchelf2' # Do not use @_ver here, it will break the installer.
license Glibc_build237.license
compatibility 'x86_64 aarch64 armv7l'
min_glibc version.split('-').first
max_glibc version.split('-').first
source_url 'SKIP'
binary_compression 'tar.zst'
binary_sha256({
aarch64: '5c704c9649dca04ddd8a3b3c3a46a81cdf95a162e07362b64992452876297545',
armv7l: '5c704c9649dca04ddd8a3b3c3a46a81cdf95a162e07362b64992452876297545',
x86_64: 'd83b21de790dbf7e33418ad86dd44fb2af933cc811985f2482c8fad696654220'
})
depends_on 'glibc_build237' => :build
conflicts_ok
no_source_build
# strip breaks libc.so.6
no_strip
no_upstream_update
def self.install
puts 'Installing Glibc_build237 to pull files for build...'.lightblue
@filelist_path = File.join(CREW_META_PATH, 'glibc_build237.filelist')
abort 'File list for Glibc_build237 does not exist! Please run: crew reinstall glibc_build237'.lightred unless File.file?(@filelist_path)
@filelist = File.readlines(@filelist_path, chomp: true).sort
@filelist.each do |filename|
next unless (filename.include?('.so') || filename.include?('bin/')) && File.file?(filename)
@destpath = File.join(CREW_DEST_DIR, filename)
@filename_target = File.realpath(filename)
FileUtils.install @filename_target, @destpath
end
if ARCH == 'x86_64'
puts 'Skipping creating symlinks from system Glibc libraries...'.orange
else
# Create symlinks to system glibc libraries.
glibc_libs = %w[libanl.so.1 libc_malloc_debug.so.0 libdl.so.2
libmvec.so.1 libnss_dns.so.2 libnss_files.so.2 libpthread.so.0
libresolv.so.2 librt.so.1 libthread_db.so.1 libutil.so.1]
glibc_libs.delete_if { |lib| lib == 'libc.so.6' } if (ARCH == 'x86_64') && (Gem::Version.new(LIBC_VERSION) >= Gem::Version.new('2.37'))
glibc_libs.each do |lib|
# Do not replace libraries that have been patched for our glibc libC.so.6.
next if Kernel.system("patchelf --print-needed #{File.join(CREW_LIB_PREFIX, lib)} | grep -q libC.so.6")
puts "Creating symlink of system Glibc's /#{ARCH_LIB}/#{lib} into #{CREW_DEST_LIB_PREFIX}/#{lib}...".orange
FileUtils.ln_sf "/#{ARCH_LIB}/#{lib}", "#{CREW_DEST_LIB_PREFIX}/#{lib}"
end
end
end
def self.postinstall
return unless (ARCH == 'x86_64') && (Gem::Version.new(LIBC_VERSION) >= Gem::Version.new('2.37'))
puts "patchelf is needed. Please run: 'crew install patchelf ; crew postinstall #{name}'".lightred unless File.file?(File.join(CREW_PREFIX, 'bin/patchelf'))
# Link the system libc.so.6 to also require our renamed libC.so.6
# which provides the float128 functions strtof128, strfromf128,
# and __strtof128_nan.
libc_patch_libraries = %w[libc.so.6 libm.so.6 libstdc++.so.6]
libc_patch_libraries.keep_if { |lib| File.file?(File.join(CREW_LIB_PREFIX, lib)) }
libc_patch_libraries.delete_if { |lib| Kernel.system "patchelf --print-needed #{File.join(CREW_LIB_PREFIX, lib)} | grep -q libC.so.6" }
return if libc_patch_libraries.empty?
if File.file?(File.join(CREW_LIB_PREFIX, 'libC.so.6'))
Dir.chdir(CREW_LIB_PREFIX) do
libc_patch_libraries.each do |lib|
FileUtils.cp lib, "#{lib}.tmp"
Kernel.system "patchelf --add-needed libC.so.6 #{lib}.tmp" and Kernel.system "patchelf --remove-needed libc.so.6 #{lib}.tmp"
FileUtils.mv "#{lib}.tmp", lib
puts "#{lib} patched for use with Chromebrew's glibc.".lightgreen
end
end
end
end
end