fix(rubygems)

patches don't age well.

closes #4440
closes #4450
This commit is contained in:
Jacob Heider 2023-12-15 17:04:32 -05:00 committed by Jacob Heider
parent 1614e01c30
commit e151a37e98
5 changed files with 44 additions and 44 deletions

View file

@ -26,16 +26,3 @@ index 8e0182f..aa53e4c 100644
##
# Returns binary extensions dir for specified RubyGems base dir or nil
# if such directory cannot be determined.
diff --git a/lib/rubygems/path_support.rb b/lib/rubygems/path_support.rb
index d601e65..0c78dba 100644
--- a/lib/rubygems/path_support.rb
+++ b/lib/rubygems/path_support.rb
@@ -23,7 +23,7 @@ class Gem::PathSupport
# hashtable, or defaults to ENV, the system environment.
#
def initialize(env)
- @home = env["GEM_HOME"] || Gem.default_dir
+ @home = env["GEM_HOME"] || Gem.default_system_dir
if File::ALT_SEPARATOR
@home = @home.gsub(File::ALT_SEPARATOR, File::SEPARATOR)

View file

@ -1,13 +1,16 @@
diff --git a/lib/rubygems/defaults.rb b/lib/rubygems/defaults.rb
index b186375..de168c4 100644
--- a/lib/rubygems/defaults.rb
+++ b/lib/rubygems/defaults.rb
@@ -137,7 +129,7 @@ def self.config_file
# The path to standard location of the user's state file.
diff --git a/lib/rubygems/installer.rb b/lib/rubygems/installer.rb
index 8fef455..3ef4e30 100644
--- a/lib/rubygems/installer.rb
+++ b/lib/rubygems/installer.rb
@@ -188,9 +188,9 @@ def initialize(package, options={})
@package.prog_mode = options[:prog_mode]
@package.data_mode = options[:data_mode]
def self.state_file
- @state_file ||= File.join(Gem.state_home, "gem", "last_update_check").tap(&Gem::UNTAINT)
+ @state_file ||= File.join(Gem.state_home, "last_update_check").tap(&Gem::UNTAINT)
end
##
- if options[:user_install]
+ if options[:user_install] or options[:user_install].nil? and not File.writable? Gem.paths.home
@gem_home = Gem.user_dir
- @bin_dir = Gem.bindir gem_home unless options[:bin_dir]
+ @bin_dir = File.join(Gem.user_home, ".local/bin") unless options[:bin_dir]
@plugins_dir = Gem.plugindir(gem_home)
check_that_user_bin_dir_is_in_path
end

View file

@ -0,0 +1,16 @@
diff -ru a/lib/rubygems/installer.rb b/lib/rubygems/installer.rb
--- a/lib/rubygems/installer.rb 2023-12-15 18:44:02
+++ b/lib/rubygems/installer.rb 2023-12-15 19:04:30
@@ -691,6 +691,12 @@
@plugins_dir = File.join(@build_root, @plugins_dir.gsub(/^[a-zA-Z]:/, ""))
alert_warning "You build with buildroot.\n Build root: #{@build_root}\n Bin dir: #{@bin_dir}\n Gem home: #{@gem_home}\n Plugins dir: #{@plugins_dir}"
end
+
+ unless File.writable? @gem_home
+ @bin_dir = File.join(Gem.user_home, ".local/bin")
+ @gem_home = Gem.user_dir
+ @plugins_dir = File.join(Gem.user_dir, "plugins")
+ end
end
def check_that_user_bin_dir_is_in_path # :nodoc:

View file

@ -148,19 +148,3 @@ index b186375..de168c4 100644
end
##
diff --git a/lib/rubygems/installer.rb b/lib/rubygems/installer.rb
index 8fef455..3ef4e30 100644
--- a/lib/rubygems/installer.rb
+++ b/lib/rubygems/installer.rb
@@ -188,9 +188,9 @@ def initialize(package, options={})
@package.prog_mode = options[:prog_mode]
@package.data_mode = options[:data_mode]
- if options[:user_install]
+ if options[:user_install] or options[:user_install].nil? and not File.writable? Gem.paths.home
@gem_home = Gem.user_dir
- @bin_dir = Gem.bindir gem_home unless options[:bin_dir]
+ @bin_dir = File.join(Gem.user_home, ".local/bin") unless options[:bin_dir]
@plugins_dir = Gem.plugindir(gem_home)
check_that_user_bin_dir_is_in_path
end

View file

@ -29,11 +29,21 @@ build:
- run: |
patch -p1 < "$SRCROOT"/props/fit-n-finish.patch
patch -p1 < "$SRCROOT"/props/fit-n-finish.2.patch
sed -i'' -e 's/Gem.default_dir/Gem.default_system_dir/' lib/rubygems/path_support.rb
working-directory: ${{prefix}}
- run: |
patch -p1 < "$SRCROOT"/props/fit-n-finish.3.patch
working-directory: ${{prefix}}
- run: sed -i'' -e 's/Gem.state_home, "gem",/Gem.state_home,/' defaults.rb
working-directory: ${{prefix}}/lib/rubygems
if: '>=3.4'
- run: patch -p1 < "$SRCROOT"/props/fit-n-finish.3.patch
working-directory: ${{prefix}}
if: '<3.5'
- run: patch -p1 < "$SRCROOT"/props/fit-n-finish.4.patch
working-directory: ${{prefix}}
if: '>=3.5'
- run: |
sed -i.bak -e 's/Dir\.mkdir dir, \*\[options\[:dir_mode\].*/FileUtils.mkdir_p dir, *[options[:dir_mode] \&\& 0o755].compact/' installer.rb
rm installer.rb.bak