Do not reinstall from source on gem upgrades when a built gem is available. — py3_libxml2 → 2.15.1 (#13158)

* Do not reinstall from source on gem upgrades when a built gem is available.

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

* Fix py3_libxml2 build.

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

* Document changes in-line.

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

* libxml2: Package File Update Run on linux/386 container.

* Allow def archive to overwrite output file.

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

* libxml2: Package File Update Run on linux/arm/v7 container.

---------

Signed-off-by: Satadru Pramanik <satadru@gmail.com>
Co-authored-by: chromebrew-actions[bot] <chromebrew-actions[bot]@users.noreply.github.com>
Co-authored-by: satmandu <satmandu@users.noreply.github.com>
This commit is contained in:
Satadru Pramanik, DO, MPH, MEng
2025-10-17 13:37:56 -04:00
committed by GitHub
parent a6683c95a8
commit fc08f3c26c
8 changed files with 68 additions and 73 deletions

View File

@@ -274,25 +274,26 @@ def update
## Update crew from git. ## Update crew from git.
# Set sparse-checkout folders. # Set sparse-checkout folders.
system "git sparse-checkout set packages manifest/#{ARCH} lib commands bin crew tests tools", chdir: CREW_LIB_PATH, exception: true @silent = CREW_UNATTENDED ? '&>/dev/null' : ''
system 'git sparse-checkout reapply', chdir: CREW_LIB_PATH, exception: true system "git sparse-checkout set packages manifest/#{ARCH} lib commands bin crew tests tools #{@silent}", chdir: CREW_LIB_PATH, exception: true
system "git fetch #{CREW_REPO} #{CREW_BRANCH}", chdir: CREW_LIB_PATH, exception: true system "git sparse-checkout reapply #{@silent}", chdir: CREW_LIB_PATH, exception: true
system "git fetch #{CREW_REPO} #{CREW_BRANCH} #{@silent}", chdir: CREW_LIB_PATH, exception: true
# Now that we've fetched all the new changes, see if lib/const.rb was changed. # Now that we've fetched all the new changes, see if lib/const.rb was changed.
# We do this before resetting to FETCH_HEAD because we lose the original HEAD when doing so. # We do this before resetting to FETCH_HEAD because we lose the original HEAD when doing so.
to_update = `cd #{CREW_LIB_PATH} && git show --name-only HEAD..FETCH_HEAD`.include?('lib/const.rb') to_update = `cd #{CREW_LIB_PATH} && git show --name-only HEAD..FETCH_HEAD`.include?('lib/const.rb')
system('git reset --hard FETCH_HEAD', chdir: CREW_LIB_PATH, exception: true) system("git reset --hard FETCH_HEAD #{@silent}", chdir: CREW_LIB_PATH, exception: true)
if Time.now.to_i - @last_update_check > (CREW_UPDATE_CHECK_INTERVAL * 3600 * 24) if Time.now.to_i - @last_update_check > (CREW_UPDATE_CHECK_INTERVAL * 3600 * 24)
puts 'Updating RubyGems.'.orange puts 'Updating RubyGems.'.orange
system 'gem update -N --system' system "gem update -N --system #{@silent}"
system 'gem cleanup' system "gem cleanup #{@silent}"
end end
puts 'Package lists, crew, and library updated.' puts 'Package lists, crew, and library updated.' unless CREW_UNATTENDED
# If lib/const.rb was changed, CREW_VERSION was bumped, so we re-run crew update. # If lib/const.rb was changed, CREW_VERSION was bumped, so we re-run crew update.
if to_update if to_update
puts 'Restarting crew update since there is an updated crew version.'.lightcyan puts 'Restarting crew update since there is an updated crew version.'.lightcyan unless CREW_UNATTENDED
puts "CREW_REPO=#{CREW_REPO} CREW_BRANCH=#{CREW_BRANCH} crew update".orange if CREW_VERBOSE puts "CREW_REPO=#{CREW_REPO} CREW_BRANCH=#{CREW_BRANCH} crew update".orange if CREW_VERBOSE
exec "CREW_REPO=#{CREW_REPO} CREW_BRANCH=#{CREW_BRANCH} crew update" exec "CREW_REPO=#{CREW_REPO} CREW_BRANCH=#{CREW_BRANCH} crew update"
end end
@@ -336,7 +337,9 @@ def update
end end
end end
if CREW_UNATTENDED && can_be_updated.positive? # Don't be clever about checking to see if updatable packages can be
# updated here. Let tools/build_updated_packages.rb handle that.
if CREW_UNATTENDED && updatable_packages.length.positive?
puts updatable_packages.to_json puts updatable_packages.to_json
elsif can_be_updated.positive? elsif can_be_updated.positive?
puts "\n#{can_be_updated} packages can be updated." puts "\n#{can_be_updated} packages can be updated."
@@ -1592,7 +1595,7 @@ def archive_package(crew_archive_dest)
@pkg_name_lockfile = CrewLockfile.new "#{crew_archive_dest}/#{pkg_name}.lock" @pkg_name_lockfile = CrewLockfile.new "#{crew_archive_dest}/#{pkg_name}.lock"
begin begin
@pkg_name_lockfile.lock @pkg_name_lockfile.lock
system "tar c * | nice -n 20 zstd -T0 --ultra -20 -o #{crew_archive_dest}/#{pkg_name} -" system "tar c * | nice -n 20 zstd -T0 --ultra -20 -f -o #{crew_archive_dest}/#{pkg_name} -"
ensure ensure
@pkg_name_lockfile.unlock @pkg_name_lockfile.unlock
end end

View File

@@ -21,6 +21,24 @@ def check_gem_binary_build_needed(ruby_gem_name = nil, ruby_gem_version = nil)
return @build_needed return @build_needed
end end
def gem_info(ruby_gem_name = nil)
# @ruby_gem_version comes from the set_vars function.
installed_gem_search = [`gem list --no-update-sources -l -e #{ruby_gem_name}`.chomp.to_s].grep(/#{ruby_gem_name}/)[0]
if installed_gem_search
installed_gem_info = installed_gem_search.delete('()').gsub('default:', '').gsub(',', '').split
@gem_installed_version = installed_gem_info[1]
@gem_outdated = (Gem::Version.new(@ruby_gem_version) > Gem::Version.new(@gem_installed_version))
@gem_latest_version_installed = Gem::Version.new(@ruby_gem_version) <= Gem::Version.new(@gem_installed_version)
else
# If the current gem being installed is not installed this should
# be false. This will also handle cases of the current installed
# gem as per 'gem list' being the same version as the version
# being upgraded to.
@gem_latest_version_installed = false
end
crewlog "@ruby_gem_version: #{@ruby_gem_version} gem_installed_version: #{@gem_installed_version} @gem_outdated: #{@gem_outdated} @gem_latest_version_installed: #{@gem_latest_version_installed}"
end
def set_vars(passed_name = nil, passed_version = nil) def set_vars(passed_name = nil, passed_version = nil)
# crewlog "Setting gem variables... name: #{passed_name}, version: #{passed_version}" # crewlog "Setting gem variables... name: #{passed_name}, version: #{passed_version}"
# This assumes the package class name starts with 'Ruby_' and # This assumes the package class name starts with 'Ruby_' and
@@ -67,7 +85,12 @@ def set_vars(passed_name = nil, passed_version = nil)
end end
def save_gem_filelist(gem_name = nil, gem_filelist_path = nil) def save_gem_filelist(gem_name = nil, gem_filelist_path = nil)
files = `gem install #{gem_name} &>/dev/null ; gem contents #{gem_name}`.chomp.split crewlog "@gem_latest_version_installed: #{@gem_latest_version_installed}"
files = if @gem_latest_version_installed
`gem contents #{gem_name}`.chomp.split
else
`gem install #{gem_name} &>/dev/null ; gem contents #{gem_name}`.chomp.split
end
exes = files.grep(%r{/exe/|/bin/}) exes = files.grep(%r{/exe/|/bin/})
# Gem.bindir should end up being #{CREW_PREFIX}/bin. # Gem.bindir should end up being #{CREW_PREFIX}/bin.
exes&.map! { |x| x.gsub(%r{^.*(/exe/|/bin/)}, "#{Gem.bindir}/") } exes&.map! { |x| x.gsub(%r{^.*(/exe/|/bin/)}, "#{Gem.bindir}/") }
@@ -97,14 +120,7 @@ class RUBY < Package
set_vars(name, version) set_vars(name, version)
puts "Examining #{@ruby_gem_name} gem...".orange puts "Examining #{@ruby_gem_name} gem...".orange
@gem_filelist_path = File.join(CREW_META_PATH, "#{name}.filelist") @gem_filelist_path = File.join(CREW_META_PATH, "#{name}.filelist")
installed_gem_search = [`gem list -l -e #{@ruby_gem_name}`.chomp.to_s].grep(/#{@ruby_gem_name}/)[0] gem_info(@ruby_gem_name)
if installed_gem_search
installed_gem_info = installed_gem_search.delete('()').gsub('default:', '').gsub(',', '').split
@gem_installed_version = installed_gem_info[1]
@gem_outdated = (Gem::Version.new(@ruby_gem_version) > Gem::Version.new(@gem_installed_version))
@gem_latest_version_installed = Gem::Version.new(@ruby_gem_version) <= Gem::Version.new(@gem_installed_version)
crewlog "@ruby_gem_version: #{@ruby_gem_version} @gem_installed_version: #{@gem_installed_version} @gem_outdated: #{@gem_outdated} @gem_latest_version_installed: #{@gem_latest_version_installed}"
end
# Create a filelist from the gem if the latest gem version is # Create a filelist from the gem if the latest gem version is
# installed. # installed.
@@ -149,20 +165,7 @@ class RUBY < Package
puts "#{@ruby_gem_name} #{@gem_installed_version} is properly installed.".lightgreen puts "#{@ruby_gem_name} #{@gem_installed_version} is properly installed.".lightgreen
return return
end end
installed_gem_search = [`gem list --no-update-sources -l -e #{@ruby_gem_name}`.chomp.to_s].grep(/#{@ruby_gem_name}/)[0] gem_info(@ruby_gem_name)
if installed_gem_search
installed_gem_info = installed_gem_search.delete('()').gsub('default:', '').gsub(',', '').split
@gem_installed_version = installed_gem_info[1]
@gem_outdated = (Gem::Version.new(@ruby_gem_version) > Gem::Version.new(@gem_installed_version))
@gem_latest_version_installed = Gem::Version.new(@ruby_gem_version) <= Gem::Version.new(@gem_installed_version)
crewlog "@ruby_gem_version: #{@ruby_gem_version} @gem_installed_version: #{@gem_installed_version} @gem_outdated: #{@gem_outdated} @gem_latest_version_installed: #{@gem_latest_version_installed}"
else
# If the current gem being installed is not installed this should
# be false. This will also handle cases of the current installed
# gem as per 'gem list' being the same version as the version
# being upgraded to.
@gem_latest_version_installed = false
end
crewlog "no_compile_needed?: #{no_compile_needed?} @gem_binary_build_needed.blank?: #{@gem_binary_build_needed.blank?}, gem_compile_needed?: #{gem_compile_needed?}" crewlog "no_compile_needed?: #{no_compile_needed?} @gem_binary_build_needed.blank?: #{@gem_binary_build_needed.blank?}, gem_compile_needed?: #{gem_compile_needed?}"
puts "#{@ruby_gem_name.capitalize} needs a binary gem built!".orange unless @gem_binary_build_needed.blank? puts "#{@ruby_gem_name.capitalize} needs a binary gem built!".orange unless @gem_binary_build_needed.blank?
@@ -181,6 +184,8 @@ class RUBY < Package
puts "Installing #{@ruby_gem_name} gem #{@ruby_gem_version}...".orange puts "Installing #{@ruby_gem_name} gem #{@ruby_gem_version}...".orange
Kernel.system "gem install --no-update-sources -N #{@ruby_gem_name} --conservative" Kernel.system "gem install --no-update-sources -N #{@ruby_gem_name} --conservative"
end end
# Check gem versions again.
gem_info(@ruby_gem_name)
@gems_needing_cleanup = Array(@gems_needing_cleanup) << @ruby_gem_name unless @gem_latest_version_installed @gems_needing_cleanup = Array(@gems_needing_cleanup) << @ruby_gem_name unless @gem_latest_version_installed
save_gem_filelist(@ruby_gem_name, @gem_filelist_path) save_gem_filelist(@ruby_gem_name, @gem_filelist_path)
@ruby_install_extras&.call @ruby_install_extras&.call

View File

@@ -4,7 +4,7 @@ require 'etc'
require 'open3' require 'open3'
OLD_CREW_VERSION ||= defined?(CREW_VERSION) ? CREW_VERSION : '1.0' OLD_CREW_VERSION ||= defined?(CREW_VERSION) ? CREW_VERSION : '1.0'
CREW_VERSION ||= '1.67.7' unless defined?(CREW_VERSION) && CREW_VERSION == OLD_CREW_VERSION CREW_VERSION ||= '1.67.8' unless defined?(CREW_VERSION) && CREW_VERSION == OLD_CREW_VERSION
# Kernel architecture. # Kernel architecture.
KERN_ARCH ||= Etc.uname[:machine] KERN_ARCH ||= Etc.uname[:machine]

View File

@@ -13,15 +13,16 @@ require_gem('highline')
# All needed constants & variables should be defined here in case they # All needed constants & variables should be defined here in case they
# have not yet been loaded or fixup is being run standalone. # have not yet been loaded or fixup is being run standalone.
CREW_VERBOSE ||= ARGV.intersect?(%w[-v --verbose]) unless defined?(CREW_VERBOSE) CREW_UNATTENDED ||= ENV.fetch('CREW_UNATTENDED', false) unless defined?(CREW_UNATTENDED)
CREW_VERBOSE ||= ARGV.intersect?(%w[-v --verbose]) unless defined?(CREW_VERBOSE)
CREW_PREFIX ||= '/usr/local' CREW_PREFIX ||= '/usr/local'
CREW_LIB_PATH ||= File.join(CREW_PREFIX, 'lib/crew') CREW_LIB_PATH ||= File.join(CREW_PREFIX, 'lib/crew')
CREW_CONFIG_PATH ||= File.join(CREW_PREFIX, 'etc/crew') CREW_CONFIG_PATH ||= File.join(CREW_PREFIX, 'etc/crew')
CREW_META_PATH ||= File.join(CREW_CONFIG_PATH, 'meta') CREW_META_PATH ||= File.join(CREW_CONFIG_PATH, 'meta')
CREW_REPO ||= ENV.fetch('CREW_REPO', 'https://github.com/chromebrew/chromebrew.git') unless defined?(CREW_REPO) 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) CREW_BRANCH ||= ENV.fetch('CREW_BRANCH', 'master') unless defined?(CREW_BRANCH)
load "#{CREW_LIB_PATH}/lib/const.rb" load "#{CREW_LIB_PATH}/lib/const.rb"
load "#{CREW_LIB_PATH}/lib/package.rb" load "#{CREW_LIB_PATH}/lib/package.rb"
@@ -277,7 +278,7 @@ if File.exist?("#{CREW_PREFIX}/bin/upx") && File.exist?("#{CREW_PREFIX}/bin/patc
# errors on arm. # errors on arm.
# Running find twice because it involves less ruby overhead than saving # Running find twice because it involves less ruby overhead than saving
# the output in memory, and also doing that in ruby is VERY SLOW. # the output in memory, and also doing that in ruby is VERY SLOW.
puts 'Please wait while upx is run to uncompress binaries...'.lightblue puts 'Please wait while upx is run to uncompress binaries...'.lightblue unless CREW_UNATTENDED
Kernel.system "#{CREW_PREFIX}/bin/find #{CREW_PREFIX}/bin -type f -print0 | xargs -0 -P#{CREW_NPROC} -n1 -r bash -c 'header=$(head -c4 ${0}); elfheader='$(printf '\\\177ELF')' ; arheader=\\!\\<ar ; case $header in $elfheader|$arheader) upx -qq -d ${0} ;; esac'", %i[err] => File::NULL, exception: false Kernel.system "#{CREW_PREFIX}/bin/find #{CREW_PREFIX}/bin -type f -print0 | xargs -0 -P#{CREW_NPROC} -n1 -r bash -c 'header=$(head -c4 ${0}); elfheader='$(printf '\\\177ELF')' ; arheader=\\!\\<ar ; case $header in $elfheader|$arheader) upx -qq -d ${0} ;; esac'", %i[err] => File::NULL, exception: false
unless CREW_GLIBC_INTERPRETER.blank? unless CREW_GLIBC_INTERPRETER.blank?

View File

@@ -1,10 +1,6 @@
# Total size: 1204334 # Total size: 926178
/usr/local/lib/python3.13/site-packages/__pycache__/drv_libxml2.cpython-313.pyc /usr/local/lib/python3.13/site-packages/__pycache__/drv_libxml2.cpython-313.pyc
/usr/local/lib/python3.13/site-packages/__pycache__/libxml2.cpython-313.pyc /usr/local/lib/python3.13/site-packages/__pycache__/libxml2.cpython-313.pyc
/usr/local/lib/python3.13/site-packages/drv_libxml2.py /usr/local/lib/python3.13/site-packages/drv_libxml2.py
/usr/local/lib/python3.13/site-packages/libxml2.py /usr/local/lib/python3.13/site-packages/libxml2.py
/usr/local/lib/python3.13/site-packages/libxml2_python-2.15.0-py3.13.egg-info/PKG-INFO
/usr/local/lib/python3.13/site-packages/libxml2_python-2.15.0-py3.13.egg-info/SOURCES.txt
/usr/local/lib/python3.13/site-packages/libxml2_python-2.15.0-py3.13.egg-info/dependency_links.txt
/usr/local/lib/python3.13/site-packages/libxml2_python-2.15.0-py3.13.egg-info/top_level.txt
/usr/local/lib/python3.13/site-packages/libxml2mod.cpython-313-arm-linux-gnueabihf.so /usr/local/lib/python3.13/site-packages/libxml2mod.cpython-313-arm-linux-gnueabihf.so

View File

@@ -1,10 +1,6 @@
# Total size: 1149074 # Total size: 1013810
/usr/local/lib/python3.13/site-packages/__pycache__/drv_libxml2.cpython-313.pyc /usr/local/lib/python3.13/site-packages/__pycache__/drv_libxml2.cpython-313.pyc
/usr/local/lib/python3.13/site-packages/__pycache__/libxml2.cpython-313.pyc /usr/local/lib/python3.13/site-packages/__pycache__/libxml2.cpython-313.pyc
/usr/local/lib/python3.13/site-packages/drv_libxml2.py /usr/local/lib/python3.13/site-packages/drv_libxml2.py
/usr/local/lib/python3.13/site-packages/libxml2.py /usr/local/lib/python3.13/site-packages/libxml2.py
/usr/local/lib/python3.13/site-packages/libxml2_python-2.15.0-py3.13.egg-info/PKG-INFO
/usr/local/lib/python3.13/site-packages/libxml2_python-2.15.0-py3.13.egg-info/SOURCES.txt
/usr/local/lib/python3.13/site-packages/libxml2_python-2.15.0-py3.13.egg-info/dependency_links.txt
/usr/local/lib/python3.13/site-packages/libxml2_python-2.15.0-py3.13.egg-info/top_level.txt
/usr/local/lib/python3.13/site-packages/libxml2mod.cpython-313-i386-linux-gnu.so /usr/local/lib/python3.13/site-packages/libxml2mod.cpython-313-i386-linux-gnu.so

View File

@@ -1,10 +1,6 @@
# Total size: 1199174 # Total size: 1027606
/usr/local/lib64/python3.13/site-packages/__pycache__/drv_libxml2.cpython-313.pyc /usr/local/lib/python3.13/site-packages/__pycache__/drv_libxml2.cpython-313.pyc
/usr/local/lib64/python3.13/site-packages/__pycache__/libxml2.cpython-313.pyc /usr/local/lib/python3.13/site-packages/__pycache__/libxml2.cpython-313.pyc
/usr/local/lib64/python3.13/site-packages/drv_libxml2.py /usr/local/lib/python3.13/site-packages/drv_libxml2.py
/usr/local/lib64/python3.13/site-packages/libxml2.py /usr/local/lib/python3.13/site-packages/libxml2.py
/usr/local/lib64/python3.13/site-packages/libxml2_python-2.15.0-py3.13.egg-info/PKG-INFO
/usr/local/lib64/python3.13/site-packages/libxml2_python-2.15.0-py3.13.egg-info/SOURCES.txt
/usr/local/lib64/python3.13/site-packages/libxml2_python-2.15.0-py3.13.egg-info/dependency_links.txt
/usr/local/lib64/python3.13/site-packages/libxml2_python-2.15.0-py3.13.egg-info/top_level.txt
/usr/local/lib64/python3.13/site-packages/libxml2mod.cpython-313-x86_64-linux-gnu.so /usr/local/lib64/python3.13/site-packages/libxml2mod.cpython-313-x86_64-linux-gnu.so

View File

@@ -1,7 +1,7 @@
require 'buildsystems/python' require 'buildsystems/meson'
Package.load_package("#{__dir__}/libxml2.rb") Package.load_package("#{__dir__}/libxml2.rb")
class Py3_libxml2 < Python class Py3_libxml2 < Meson
description 'Libxml2-python provides access to libxml2 and libxslt in Python.' description 'Libxml2-python provides access to libxml2 and libxslt in Python.'
homepage 'https://gitlab.gnome.org/GNOME/libxml2/' homepage 'https://gitlab.gnome.org/GNOME/libxml2/'
version "#{Libxml2.version}-#{CREW_PY_VER}" version "#{Libxml2.version}-#{CREW_PY_VER}"
@@ -12,25 +12,23 @@ class Py3_libxml2 < Python
binary_compression 'tar.zst' binary_compression 'tar.zst'
binary_sha256({ binary_sha256({
aarch64: '70eb4306e4d9423a526a65ded96b09fecd02516888bacc37dedda686f69c502b', aarch64: '895baa31f28448f33d4718a9344f6a6f76f776cbbc61dbfc1cada50c4ecc8f09',
armv7l: '70eb4306e4d9423a526a65ded96b09fecd02516888bacc37dedda686f69c502b', armv7l: '895baa31f28448f33d4718a9344f6a6f76f776cbbc61dbfc1cada50c4ecc8f09',
i686: 'fe7d08b6e0a806bad7a9da897855ed2ede8eaa6cab540d0a3c29abccd9baf8fb', i686: 'a4f2a5578ede036fb088af2c14b1afcc133e294d45aa3ec16793d232359cddac',
x86_64: '8bd40fc45196607b451f118a956375edddd5ada3c5e1e79a46fe924333bdf921' x86_64: '306e60eeebba8b24bb040362608e1479fc25f1ec7c838313280d850915d95e16'
}) })
depends_on 'glibc' # R depends_on 'glibc' # R
depends_on 'libxml2' # R depends_on 'libxml2' # R
depends_on 'py3_setuptools' => :build depends_on 'py3_setuptools' => :build
depends_on 'python3' # R depends_on 'python3' # R
depends_on 'zlib' # R
no_fhs no_fhs
python_build_relative_dir 'python' meson_options '-Dpython=enabled'
meson_install_extras do
def self.prebuild FileUtils.rm(Dir.glob("#{CREW_DEST_PREFIX}/**/*").reject { |f| f.include?(CREW_PY_VER.sub('py', 'python')) || !File.file?(f) })
system 'autoreconf -fiv' # Delete remaining empty dirs.
system "./configure #{CREW_CONFIGURE_OPTIONS} --with-python" Dir["#{CREW_DEST_PREFIX}**/"].reverse_each { |d| Dir.rmdir d if Dir.empty?(d) }
system 'make'
end end
end end