Fix ability to use bundle (#4593)

This commit is contained in:
Max Howell 2023-12-26 09:51:02 +00:00 committed by GitHub
parent b5fb5aff59
commit 3fa63bdd37
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 45 additions and 24 deletions

View file

@ -18,21 +18,18 @@ build:
ruby-lang.org: ~3.1 # testing a theory
script:
- ruby setup.rb
--prefix={{prefix}}
--env-shebang
--no-ri
--no-rdoc
- run: cp $SRCROOT/props/proxy .
working-directory: ${{prefix}}/shim
--prefix={{prefix}}
--env-shebang
--no-ri
--no-rdoc
- 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
sed -i -e 's/Gem.default_dir/Gem.default_system_dir/' lib/rubygems/path_support.rb
working-directory: ${{prefix}}
- run: sed -i'' -e 's/Gem.state_home, "gem",/Gem.state_home,/' defaults.rb
- run: sed -i -e 's/Gem.state_home, "gem",/Gem.state_home,/' defaults.rb
working-directory: ${{prefix}}/lib/rubygems
if: '>=3.4'
@ -44,30 +41,51 @@ build:
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
- run: sed -i -e
's/Dir\.mkdir dir, \*\[options\[:dir_mode\].*/FileUtils.mkdir_p dir, *[options[:dir_mode] \&\& 0o755].compact/'
installer.rb
working-directory: ${{prefix}}/lib/rubygems
# these are provided by ruby-lang.org
# we dont know why they turn up here too…
# they turn up here since that is how gem handles deps
# but ruby is in PATH and has these and that is the preference
- run: rm rake rbs rdbg typeprof
working-directory: ${{prefix}}/bin
# Were not a “GEMHOME” since we *are* gem, so yeah instead
# we have a RUBYLIB hack via our proxy script
# bundle and bundler are “gem” shims that try to invoke rubygems magic
# to figure out which bundler etc. to run. However this is not what we
# need since we are a specifically packages rubygems version and only
# want to use ourselves.
# REF https://github.com/pkgxdev/pantry/issues/4010
- run: |
for x in *; do
mv $x ../shim
ln -s ../shim/proxy $x
for tool in bundle bundler; do
rm $tool
cp $PROP $tool
done
working-directory: ${{prefix}}/bin
prop: |
#!/bin/sh
d="$(cd "$(dirname "$0")"/.. && pwd)"
export RUBYLIB="$d/lib"
exec "$d"/gems/bundler-*/exe/bundle "$@"
working-directory:
${{prefix}}/bin
# ruby has a neat feature where it will look for a ruby shebang and
# ignore everything from before that, so we can make scripts that execute
# as POSIX shell and then re-exec themselves as ruby scripts
- run:
echo "$(cat $PROP gem)" > gem
prop: |
#!/bin/sh
RUBYLIB="$(cd "$(dirname "$0")"/../lib && pwd)" exec ruby "$0" "$@"
working-directory:
${{prefix}}/bin
# clean up empty, unused directory
- rmdir {{prefix}}/plugins
test:
env:
HOME: $PWD
vRUBY: ${{deps.ruby-lang.org.version.marketing}}.0
script:
# for debug
@ -88,6 +106,13 @@ test:
test -d ~/.gem/ruby/$vRUBY/gems/hexapdf-$v
fi
- run: |
mv $FIXTURE Gemfile
bundle install --path vendor/bundle
fixture: |
source 'https://rubygems.org'
gem 'warbler', platforms: :jruby
provides:
- bin/bundle
- bin/bundler

View file

@ -1,4 +0,0 @@
#!/bin/sh
d="$(cd "$(dirname "$0")"/.. && pwd)"
export RUBYLIB="$d/lib"
$d/shim/$(basename "$0") "$@"