mirror of
https://github.com/chromebrew/chromebrew.git
synced 2026-01-08 23:18:10 -05:00
Ruby gem install adjustments. (#10580)
Signed-off-by: Satadru Pramanik <satadru@gmail.com>
This commit is contained in:
committed by
GitHub
parent
a4394867e1
commit
8a99729ed0
96
bin/crew
96
bin/crew
@@ -143,6 +143,12 @@ end
|
||||
at_exit do
|
||||
GnomePostinstall.run unless GnomePostinstall.gnome_packages.blank?
|
||||
|
||||
# Do gem cleanups all at once if needed.
|
||||
unless @gems_needing_cleanup.blank?
|
||||
puts "Running gem cleanup for gems: #{@gems_needing_cleanup.join(' ')}".orange
|
||||
system "gem cleanup #{@gems_needing_cleanup.join(' ')}"
|
||||
end
|
||||
|
||||
# Print exit messages.
|
||||
ExitMessage.print
|
||||
end
|
||||
@@ -253,53 +259,55 @@ end
|
||||
def update
|
||||
abort "'crew update' is used to update crew itself. Use 'crew upgrade <package1> [<package2> ...]' to update specific packages.".orange if @pkg_name
|
||||
|
||||
# The following is used in fixup.rb to determine if crew update needs to
|
||||
# be run again.
|
||||
@crew_const_git_commit = `git -C #{CREW_LIB_PATH} log -n1 --oneline #{CREW_LIB_PATH}/lib/const.rb`.split.first
|
||||
unless CREW_NO_GIT
|
||||
# The following is used in fixup.rb to determine if crew update needs to
|
||||
# be run again.
|
||||
@crew_const_git_commit = `git -C #{CREW_LIB_PATH} log -n1 --oneline #{CREW_LIB_PATH}/lib/const.rb`.split.first
|
||||
|
||||
unless Dir.exist?(File.join(CREW_LIB_PATH, '.git'))
|
||||
puts 'Fixing Chromebrew system git repo clone...'.orange
|
||||
system(<<~GIT_REPAIR_COMMANDS, chdir: CREW_LIB_PATH, %i[out err] => File::NULL)
|
||||
## Run the git setup commands used in install.sh.
|
||||
# Make the git default branch error messages go away.
|
||||
git config --global init.defaultBranch main
|
||||
# Setup the dir with git information.
|
||||
git init --ref-format=reftable
|
||||
git remote add origin #{CREW_REPO}
|
||||
# Help handle situations where GitHub is down.
|
||||
git config --local http.lowSpeedLimit 1000
|
||||
git config --local http.lowSpeedTime 5
|
||||
# Checkout, overwriting local files.
|
||||
git fetch --all
|
||||
git checkout -f master
|
||||
git reset --hard origin/#{CREW_BRANCH}
|
||||
GIT_REPAIR_COMMANDS
|
||||
unless Dir.exist?(File.join(CREW_LIB_PATH, '.git'))
|
||||
puts 'Fixing Chromebrew system git repo clone...'.orange
|
||||
system(<<~GIT_REPAIR_COMMANDS, chdir: CREW_LIB_PATH, %i[out err] => File::NULL)
|
||||
## Run the git setup commands used in install.sh.
|
||||
# Make the git default branch error messages go away.
|
||||
git config --global init.defaultBranch main
|
||||
# Setup the dir with git information.
|
||||
git init --ref-format=reftable
|
||||
git remote add origin #{CREW_REPO}
|
||||
# Help handle situations where GitHub is down.
|
||||
git config --local http.lowSpeedLimit 1000
|
||||
git config --local http.lowSpeedTime 5
|
||||
# Checkout, overwriting local files.
|
||||
git fetch --all
|
||||
git checkout -f master
|
||||
git reset --hard origin/#{CREW_BRANCH}
|
||||
GIT_REPAIR_COMMANDS
|
||||
end
|
||||
|
||||
system(<<~GIT_UPDATE_COMMANDS, chdir: CREW_LIB_PATH, exception: true)
|
||||
## Update crew from git.
|
||||
# Set sparse-checkout folders.
|
||||
git sparse-checkout set packages manifest/#{ARCH} lib commands bin crew tests tools
|
||||
git sparse-checkout reapply
|
||||
git fetch #{CREW_REPO} #{CREW_BRANCH}
|
||||
git reset --hard FETCH_HEAD
|
||||
GIT_UPDATE_COMMANDS
|
||||
system(<<~GIT_RESTORE_MTIME_COMMAND, chdir: CREW_LIB_PATH, exception: true) if File.file?("#{CREW_PREFIX}/bin/git-restore-mtime")
|
||||
# Set the mtime on each file in git to the date the file was added,
|
||||
# not to the date of the last git pull.
|
||||
git-restore-mtime -sq 2>/dev/null
|
||||
GIT_RESTORE_MTIME_COMMAND
|
||||
|
||||
if Time.now.to_i - @last_update_check > (CREW_UPDATE_CHECK_INTERVAL * 3600 * 24)
|
||||
puts 'Updating RubyGems.'.orange
|
||||
system 'gem update -N --system'
|
||||
system 'gem cleanup'
|
||||
end
|
||||
puts 'Package lists, crew, and library updated.'
|
||||
|
||||
# Do any fixups necessary after crew has updated from git.
|
||||
load "#{CREW_LIB_PATH}/lib/fixup.rb"
|
||||
end
|
||||
|
||||
system(<<~GIT_UPDATE_COMMANDS, chdir: CREW_LIB_PATH, exception: true)
|
||||
## Update crew from git.
|
||||
# Set sparse-checkout folders.
|
||||
git sparse-checkout set packages manifest/#{ARCH} lib commands bin crew tests tools
|
||||
git sparse-checkout reapply
|
||||
git fetch #{CREW_REPO} #{CREW_BRANCH}
|
||||
git reset --hard FETCH_HEAD
|
||||
GIT_UPDATE_COMMANDS
|
||||
system(<<~GIT_RESTORE_MTIME_COMMAND, chdir: CREW_LIB_PATH, exception: true) if File.file?("#{CREW_PREFIX}/bin/git-restore-mtime")
|
||||
# Set the mtime on each file in git to the date the file was added,
|
||||
# not to the date of the last git pull.
|
||||
git-restore-mtime -sq 2>/dev/null
|
||||
GIT_RESTORE_MTIME_COMMAND
|
||||
|
||||
if Time.now.to_i - @last_update_check > (CREW_UPDATE_CHECK_INTERVAL * 3600 * 24)
|
||||
puts 'Updating RubyGems.'.orange
|
||||
system 'gem update -N --system'
|
||||
system 'gem cleanup'
|
||||
end
|
||||
puts 'Package lists, crew, and library updated.'
|
||||
|
||||
# Do any fixups necessary after crew has updated from git.
|
||||
load "#{CREW_LIB_PATH}/lib/fixup.rb"
|
||||
|
||||
# update compatible packages
|
||||
generate_compatible
|
||||
# check for outdated installed packages
|
||||
|
||||
@@ -41,10 +41,10 @@ def set_vars(passed_name = nil, passed_version = nil)
|
||||
# This assumes the package class name starts with 'Ruby_' and
|
||||
# version is in the form '(gem version)-ruby-(ruby version)'.
|
||||
# For example, name 'Ruby_awesome' and version '1.0.0-ruby-3.3'.
|
||||
gem_name_test = passed_name.gsub(/^ruby_/, '')
|
||||
@remote_gem_ver = Gem.latest_version_for(gem_name_test).to_s
|
||||
@remote_gem_ver = Gem.latest_version_for(gem_name_test.gsub!('_', '-')).to_s if @remote_gem_ver.empty?
|
||||
@gem_name = gem_name_test
|
||||
# Just use the fetcher.suggest_gems_from_name function to figure out
|
||||
# proper gem name with the appropriate dashes and underscores.
|
||||
@gem_name = Gem::SpecFetcher.fetcher.suggest_gems_from_name(passed_name.gsub(/^ruby_/, '')).first
|
||||
@remote_gem_ver = Gem.latest_version_for(@gem_name).to_s
|
||||
@gem_ver = passed_version.split('-').first.to_s
|
||||
@gem_package_ver = @gem_ver.dup
|
||||
# Use latest gem version.
|
||||
@@ -58,25 +58,14 @@ class RUBY < Package
|
||||
|
||||
def self.preflight
|
||||
@install_gem ||= true
|
||||
@force_gem_build ||= false
|
||||
set_vars(name, version)
|
||||
puts "Examining #{@gem_name} gem...".orange
|
||||
@gem_filelist_path = File.join(CREW_META_PATH, "#{name}.filelist")
|
||||
@gem_latest_version_installed = Kernel.system "gem list -i \"^#{@gem_name}\$\" -v #{@gem_ver}", %i[out err] => File::NULL
|
||||
@gem_latest_version_installed = Kernel.system "gem search -l -i \"^#{@gem_name}\$\" -v #{@gem_ver}", %i[out err] => File::NULL
|
||||
crewlog "preflight: @gem_name: #{@gem_name}, @gem_ver: #{@gem_ver}, @gem_latest_version_installed: #{@gem_latest_version_installed} && @remote_gem_ver.to_s: #{Gem::Version.new(@remote_gem_ver.to_s)} == Gem::Version.new(@gem_ver): #{Gem::Version.new(@gem_ver)} && File.file?(@gem_filelist_path): #{File.file?(@gem_filelist_path)}"
|
||||
# Create a filelist from the gem if the latest gem version is
|
||||
# installed but the filelist doesn't exist.
|
||||
if @gem_latest_version_installed && !File.file?(@gem_filelist_path)
|
||||
# Verify gem is installed before trying to get files from the gem...
|
||||
begin
|
||||
gem @gem_name
|
||||
rescue LoadError
|
||||
puts " -> install #{@gem_name} gem".orange
|
||||
Gem.install(@gem_name)
|
||||
gem @gem_name
|
||||
end
|
||||
system "gem contents #{@gem_name} > #{@gem_filelist_path}"
|
||||
end
|
||||
Kernel.system "gem contents #{@gem_name}", %i[out] => [@gem_filelist_path, 'w'] if @gem_latest_version_installed && !File.file?(@gem_filelist_path)
|
||||
# If the version number gem reports isn't the same as the version
|
||||
# number that Chromebrew has recorded, force an install.
|
||||
# Otherwise we can skip the install and bail.
|
||||
@@ -104,7 +93,7 @@ class RUBY < Package
|
||||
end
|
||||
|
||||
def self.install
|
||||
gem_anyversion_installed = Kernel.system "gem list -i \"^#{@gem_name}\$\"", %i[out err] => File::NULL
|
||||
gem_anyversion_installed = Kernel.system "gem search -l -i \"^#{@gem_name}\$\"", %i[out err] => File::NULL
|
||||
crewlog "install: @gem_name: #{@gem_name}, @gem_ver: #{@gem_ver}, !@gem_latest_version_installed && gem_anyversion_installed: #{!@gem_latest_version_installed && gem_anyversion_installed}, @gem_latest_version_installed: #{@gem_latest_version_installed} && @remote_gem_ver.to_s: #{Gem::Version.new(@remote_gem_ver.to_s)} == Gem::Version.new(@gem_ver): #{Gem::Version.new(@gem_ver)} && File.file?(@gem_filelist_path): #{File.file?(@gem_filelist_path)}"
|
||||
crewlog "no_compile_needed?: #{no_compile_needed?} @gem_binary_build_needed.blank?: #{@gem_binary_build_needed.blank?}, gem_compile_needed?: #{gem_compile_needed?}"
|
||||
unless @install_gem
|
||||
@@ -123,13 +112,13 @@ class RUBY < Package
|
||||
end
|
||||
elsif gem_anyversion_installed
|
||||
puts "Updating #{@gem_name} gem to #{@gem_ver}...".orange
|
||||
system "gem update -N #{@gem_name} --conservative"
|
||||
Kernel.system "gem update -N #{@gem_name} --conservative"
|
||||
else
|
||||
puts "Installing #{@gem_name} gem #{@gem_ver}...".orange
|
||||
system "gem install -N #{@gem_name} --conservative"
|
||||
Kernel.system "gem install -N #{@gem_name} --conservative"
|
||||
end
|
||||
system "gem cleanup #{@gem_name}"
|
||||
system "gem contents #{@gem_name} > #{@gem_filelist_path}"
|
||||
@gems_needing_cleanup = Array(@gems_needing_cleanup) << @gem_name
|
||||
Kernel.system "gem contents #{@gem_name}", %i[out] => [@gem_filelist_path, 'w']
|
||||
@ruby_install_extras&.call
|
||||
@install_gem = false
|
||||
@just_built_gem = false
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
require 'etc'
|
||||
|
||||
OLD_CREW_VERSION ||= defined?(CREW_VERSION) ? CREW_VERSION : '1.0'
|
||||
CREW_VERSION ||= '1.53.8' unless defined?(CREW_VERSION) && CREW_VERSION == OLD_CREW_VERSION
|
||||
CREW_VERSION ||= '1.53.9' unless defined?(CREW_VERSION) && CREW_VERSION == OLD_CREW_VERSION
|
||||
|
||||
# Kernel architecture.
|
||||
KERN_ARCH ||= Etc.uname[:machine]
|
||||
@@ -93,6 +93,7 @@ CREW_DEST_HOME ||= File.join(CREW_DEST_DIR, HOME)
|
||||
CREW_CACHE_DIR ||= ENV.fetch('CREW_CACHE_DIR', "#{HOME}/.cache/crewcache") unless defined?(CREW_CACHE_DIR)
|
||||
CREW_CACHE_BUILD ||= ENV.fetch('CREW_CACHE_BUILD', false) unless defined?(CREW_CACHE_BUILD)
|
||||
CREW_CACHE_FAILED_BUILD ||= ENV.fetch('CREW_CACHE_FAILED_BUILD', false) unless defined?(CREW_CACHE_FAILED_BUILD)
|
||||
CREW_NO_GIT ||= ENV.fetch('CREW_NO_GIT', false) unless defined?(CREW_NO_GIT)
|
||||
|
||||
CREW_DEBUG ||= ARGV.intersect?(%w[-D --debug]) unless defined?(CREW_DEBUG)
|
||||
CREW_FORCE ||= ARGV.intersect?(%w[-f --force]) unless defined?(CREW_FORCE)
|
||||
|
||||
Reference in New Issue
Block a user