ruby/gems fixes (#2184)

hopefully got all the edgecases this time
This commit is contained in:
Max Howell 2023-06-16 09:33:37 -04:00 committed by GitHub
parent 61c02be2f9
commit 4eb1cca264
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 145 additions and 36 deletions

View file

@ -3,6 +3,8 @@ distributable:
strip-components: 1
versions:
# ruby have *some* releases, but historically only have tags
# so if we want to build older releases we can only scan tags
github: ruby/ruby/tags
dependencies:
@ -21,12 +23,11 @@ build:
gnu.org/autoconf: '*'
linux:
ruby-lang.org: ~3.1 # ruby requires ruby to build
# ^^ only linux because we got issues on darwin currently
# ^^ only linux because we got issues on darwin currently and darwin provides ruby (for now)
env:
ARGS:
- --prefix="{{prefix}}"
- --enable-load-relative # makes us relocatable
- --disable-rubygems # we provide rubygems.org
- --without-gmp
- --with-rubyarchprefix={{prefix}}/lib/ruby # no need for architecture specific crap
- --with-rubyhdrdir={{prefix}}/include # ^^
@ -48,6 +49,24 @@ build:
- fix-shebangs.ts ${{prefix}}/bin/*
# ruby itself provides the gems for these and we dont want that
# we want to pkg them ourselves as part of rubygems.org
# to ensure the user gets a good ruby experience rubygems is marked as
# a companion which in most use means gems are automatically added to the
# pkgenv. Ruby behaves well if gems isn't around but the user may get
# unexpected errors in scenarios where they constructed an pkgenv manually
- working-directory:
${{prefix}}/lib/ruby/{{version.marketing}}.0
run: |
for x in bundler rubygems bundler.rb rubygems.rb; do
if test -d $x; then
rm -rf $x
else
rm $x
fi
done
rm -rf ../gems/3.2.0/gems/bundler-*.*.*
- run: |
rm -rf share/ri
rm -rf share/doc
@ -72,11 +91,35 @@ build:
test:
dependencies:
tea.xyz/gx/cc: c99 # for native extensions
tea.xyz/gx/cc: c99 # for native extensions
tea.xyz/gx/make: '*'
script: |
ruby -e 'puts "Hello World!"'
echo 'puts 1' | irb
rubygems.org: '*' # is a companion __however__ brewkit doesnt add companions to the env automatically
script:
- |
ruby -e 'puts "Hello World!"'
# echo 'puts 1' | irb
# ^^ FIXME `The terminfo database could not be found`
# tests the libraries that come with Ruby can be utilized
- run: |
mv $FIXTURE a.rb
ruby a.rb
fixture: |
require 'date'
puts Date.today
# tests the gems that come with Ruby can be utilized
- run: |
mv $FIXTURE a.rb
ruby a.rb
fixture: |
require 'matrix'
matrix = Matrix[[1, 2], [3, 4]]
transpose_matrix = matrix.transpose
determinant = matrix.determinant
puts "Original matrix:\n#{matrix}"
puts "Transposed matrix:\n#{transpose_matrix}"
puts "Determinant of the matrix: #{determinant}"
provides:
- bin/erb

View file

@ -0,0 +1,41 @@
diff --git a/lib/rubygems.rb b/lib/rubygems.rb
index 29552d9..814c4f4 100644
--- a/lib/rubygems.rb
+++ b/lib/rubygems.rb
@@ -299,7 +299,7 @@ module Gem
def self.bindir(install_dir=Gem.dir)
return File.join install_dir, "bin" unless
- install_dir.to_s == Gem.default_dir.to_s
+ install_dir.to_s == Gem.default_system_dir.to_s
Gem.default_bindir
end
diff --git a/lib/rubygems/defaults.rb b/lib/rubygems/defaults.rb
index 8e0182f..aa53e4c 100644
--- a/lib/rubygems/defaults.rb
+++ b/lib/rubygems/defaults.rb
@@ -31,6 +31,10 @@ module Gem
@default_dir ||= File.join(RbConfig::CONFIG["rubylibprefix"], "gems", RbConfig::CONFIG["ruby_version"])
end
+ def self.default_system_dir
+ File.join("/usr/local/lib/ruby/gems", RbConfig::CONFIG["ruby_version"])
+ end
+
##
# 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

@ -17,7 +17,7 @@ index 4aa8b4d..8354c08 100644
# :startdoc:
diff --git a/lib/rubygems/defaults.rb b/lib/rubygems/defaults.rb
index b186375..3835559 100644
index b186375..de168c4 100644
--- a/lib/rubygems/defaults.rb
+++ b/lib/rubygems/defaults.rb
@@ -20,13 +20,7 @@ def self.default_sources
@ -40,7 +40,7 @@ index b186375..3835559 100644
def self.default_dir
- @default_dir ||= File.join(RbConfig::CONFIG["rubylibprefix"], "gems", RbConfig::CONFIG["ruby_version"])
+ @default_dir ||= File.join("/usr/local/lib/ruby/gems", RbConfig::CONFIG["ruby_version"])
+ @default_dir ||= File.join(RbConfig::CONFIG["rubylibprefix"], "gems", RbConfig::CONFIG["ruby_version"])
end
##
@ -99,7 +99,15 @@ index b186375..3835559 100644
end
##
@@ -197,7 +193,7 @@ def self.default_exec_format
@@ -176,6 +172,7 @@ def self.default_path
path << user_dir if user_home && File.exist?(user_home)
path << default_dir
path << vendor_dir if vendor_dir && File.directory?(vendor_dir)
+ path << File.expand_path(File.join(__FILE__, "../../../../../ruby-lang.org", "v#{RbConfig::CONFIG["RUBY_PROGRAM_VERSION"]}", "lib/ruby/gems", RbConfig::CONFIG["ruby_version"]))
path
end
@@ -197,7 +194,7 @@ def self.default_exec_format
# The default directory for binaries
def self.default_bindir
@ -108,7 +116,7 @@ index b186375..3835559 100644
end
def self.ruby_engine
@@ -208,26 +204,14 @@ def self.ruby_engine
@@ -208,26 +205,14 @@ def self.ruby_engine
# The default signing key path
def self.default_key_path
@ -137,7 +145,7 @@ index b186375..3835559 100644
end
##
@@ -267,7 +251,10 @@ def self.vendor_dir # :nodoc:
@@ -267,7 +252,10 @@ def self.vendor_dir # :nodoc:
# end
def self.operating_system_defaults
@ -150,7 +158,7 @@ index b186375..3835559 100644
##
diff --git a/lib/rubygems/installer.rb b/lib/rubygems/installer.rb
index 9fbb282..3be62a6 100644
index 8fef455..3ef4e30 100644
--- a/lib/rubygems/installer.rb
+++ b/lib/rubygems/installer.rb
@@ -188,9 +188,9 @@ def initialize(package, options={})
@ -165,7 +173,7 @@ index 9fbb282..3be62a6 100644
@plugins_dir = Gem.plugindir(gem_home)
check_that_user_bin_dir_is_in_path
end
@@ -953,7 +953,7 @@ def write_cache_file
@@ -955,7 +955,7 @@ def write_cache_file
def ensure_writable_dir(dir) # :nodoc:
begin

View file

@ -8,31 +8,41 @@ versions:
dependencies:
ruby-lang.org: '>=2.3'
runtime:
env:
RUBYLIB: ${{prefix}}/lib
build:
dependencies:
gnu.org/patch: '*'
script:
- ruby setup.rb --prefix={{prefix}} --env-shebang --no-ri --no-rdoc
- ruby setup.rb
--prefix={{prefix}}
--env-shebang
--no-ri
--no-rdoc
- working-directory: ${{prefix}}/shim
run: cp $SRCROOT/props/proxy .
- run: cp $SRCROOT/props/proxy .
working-directory: ${{prefix}}/shim
- working-directory: ${{prefix}}
run: patch -p1 < "$SRCROOT"/props/fit-n-finish.patch
- run: |
patch -p1 < "$SRCROOT"/props/fit-n-finish.patch
patch -p1 < "$SRCROOT"/props/fit-n-finish.2.patch
working-directory: ${{prefix}}
- working-directory: ${{prefix}}/bin
# these are provided by ruby-lang.org
# we dont know why they turn up here too…
run: rm rake rbs rdbg typeprof
# these are provided by ruby-lang.org
# we dont know why they turn up here too…
- run: rm rake rbs rdbg typeprof
working-directory: ${{prefix}}/bin
- working-directory: ${{prefix}}/bin
# Were not a “GEMHOME” since we *are* gem, so yeah instead
# we have a RUBYLIB hack via our proxy script
run: |
# Were not a “GEMHOME” since we *are* gem, so yeah instead
# we have a RUBYLIB hack via our proxy script
- run: |
for x in *; do
mv $x ../shim
ln -s ../shim/proxy $x
done
working-directory: ${{prefix}}/bin
- rmdir {{prefix}}/plugins
@ -43,17 +53,24 @@ test:
env:
HOME: $PWD
vRUBY: ${{deps.ruby-lang.org.version.marketing}}.0
script: |
gem install awesome_print
ruby -e 'require "rubygems"' -e 'require "awesome_print"' -e'ap $LOAD_PATH'
gem install hexapdf
v="$(~/.local/bin/hexapdf version | cut -d' ' -f2)"
test -d ~/.gem/ruby/$vRUBY/gems/hexapdf-$v #FIXME ruby version
script:
# for debug
- gem env
gem install bundle
test -d ~/.gem/ruby/{{deps.ruby-lang.org.version.marketing}}.0/gems/bundle-0.0.1
test -f ~/.local/bin/bundle
~/.local/bin/bundle --version
- |
gem install awesome_print --verbose
ruby -e 'require "rubygems"' -e 'require "awesome_print"' -e'ap $LOAD_PATH'
- |
gem install hexapdf --verbose
if [ -w /usr/local/lib/ruby/ ]; then
v="$(/usr/local/bin/hexapdf version | cut -d' ' -f2)"
test -d /usr/local/lib/ruby/gems/$vRUBY/gems/hexapdf-$v
else
v="$(~/.local/bin/hexapdf version | cut -d' ' -f2)"
test -d ~/.gem/ruby/$vRUBY/gems/hexapdf-$v
fi
provides:
- bin/bundle