fix use of bundler as a gem

many little fixes and tweaks here. Requires newer brewkit.
This commit is contained in:
Max Howell 2023-12-27 08:06:43 +00:00
parent 36ba4f26bc
commit c137ff6003
2 changed files with 40 additions and 23 deletions

View file

@ -10,7 +10,7 @@ dependencies:
runtime: runtime:
env: env:
RUBYLIB: ${{prefix}}/lib RUBYLIB: ${{prefix}}/lib:$RUBYLIB
build: build:
dependencies: dependencies:
@ -24,12 +24,12 @@ build:
--no-rdoc --no-rdoc
- run: | - run: |
patch -p1 < "$SRCROOT"/props/fit-n-finish.patch patch -p1 < "$SRCROOT"/props/fit-n-finish.1.patch
patch -p1 < "$SRCROOT"/props/fit-n-finish.2.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 -ie 's/Gem.default_dir/Gem.default_system_dir/' lib/rubygems/path_support.rb
working-directory: ${{prefix}} working-directory: ${{prefix}}
- run: sed -i -e 's/Gem.state_home, "gem",/Gem.state_home,/' defaults.rb - run: sed -ie 's/Gem.state_home, "gem",/Gem.state_home,/' defaults.rb
working-directory: ${{prefix}}/lib/rubygems working-directory: ${{prefix}}/lib/rubygems
if: '>=3.4' if: '>=3.4'
@ -41,7 +41,7 @@ build:
working-directory: ${{prefix}} working-directory: ${{prefix}}
if: '>=3.5' if: '>=3.5'
- run: sed -i -e - run: sed -ie
's/Dir\.mkdir dir, \*\[options\[:dir_mode\].*/FileUtils.mkdir_p dir, *[options[:dir_mode] \&\& 0o755].compact/' 's/Dir\.mkdir dir, \*\[options\[:dir_mode\].*/FileUtils.mkdir_p dir, *[options[:dir_mode] \&\& 0o755].compact/'
installer.rb installer.rb
working-directory: ${{prefix}}/lib/rubygems working-directory: ${{prefix}}/lib/rubygems
@ -52,34 +52,37 @@ build:
- run: rm rake rbs rdbg typeprof - run: rm rake rbs rdbg typeprof
working-directory: ${{prefix}}/bin working-directory: ${{prefix}}/bin
# bundle and bundler are “gem” shims that try to invoke rubygems magic # ruby has a neat feature where it will look for a ruby shebang and
# to figure out which bundler etc. to run. However this is not what we # ignore everything from before that, so we can make scripts that execute
# need since we are a specifically packages rubygems version and only # as POSIX shell and then re-exec themselves as ruby scripts
# want to use ourselves.
# REF https://github.com/pkgxdev/pantry/issues/4010 # REF https://github.com/pkgxdev/pantry/issues/4010
- run: | - run: |
for tool in bundle bundler; do for tool in bundle bundler; do
rm $tool echo "$(cat $PROP gems/bundler-*/exe/$tool)" > bin/$tool
cp $PROP $tool
done done
echo "$(cat $PROP bin/gem)" > bin/gem
prop: | prop: |
#!/bin/sh #!/bin/sh
d="$(cd "$(dirname "$0")"/.. && pwd)" d="$(cd "$(dirname "$0")"/.. && pwd)"
export RUBYLIB="$d/lib" export RUBYLIB="$d/lib"
exec "$d"/gems/bundler-*/exe/bundle "$@" if [ -z "$GEM_PATH" ]; then
export GEM_PATH="$d"
else
export GEM_PATH="$d:$GEM_PATH"
fi
exec ruby "$0" "$@"
working-directory: working-directory:
${{prefix}}/bin ${{prefix}}
# ruby has a neat feature where it will look for a ruby shebang and # no longer needed
# ignore everything from before that, so we can make scripts that execute - rm -rf {{prefix}}/gems
# as POSIX shell and then re-exec themselves as ruby scripts
- run: # the bundler code figures out the “gem path” for itself by checking for this directory structure
echo "$(cat $PROP gem)" > gem # for some reason we are not installed in a gem-compatible way and
prop: | # `GEM_PATH` is not used here (but it is later)
#!/bin/sh # FIXME this stuff is messy, ideally wed do much less stuff since it breaks easily with new releases
RUBYLIB="$(cd "$(dirname "$0")"/../lib && pwd)" exec ruby "$0" "$@" - run: ln -s bin exe
working-directory: working-directory: ${{prefix}}
${{prefix}}/bin
# clean up empty, unused directory # clean up empty, unused directory
- rmdir {{prefix}}/plugins - rmdir {{prefix}}/plugins
@ -106,13 +109,27 @@ test:
test -d ~/.gem/ruby/$vRUBY/gems/hexapdf-$v test -d ~/.gem/ruby/$vRUBY/gems/hexapdf-$v
fi fi
# test for https://github.com/pkgxdev/pantry/issues/4010
- run: | - run: |
export GEM_HOME=$HOME/.bundler
mv $FIXTURE Gemfile mv $FIXTURE Gemfile
bundle install --path vendor/bundle bundle install --path vendor/bundle
fixture: | fixture: |
source 'https://rubygems.org' source 'https://rubygems.org'
gem 'warbler', platforms: :jruby gem 'warbler', platforms: :jruby
# verifies that our bundler can be used as a gem
- run:
ruby $FIXTURE
fixture:
content: |
require 'bundler/inline'
gemfile do
source 'https://rubygems.org'
gem 'ruby-macho', '~> 3'
end
extname: rb
provides: provides:
- bin/bundle - bin/bundle
- bin/bundler - bin/bundler