From 3fa63bdd37d8c15511678536725f32ff8dad4602 Mon Sep 17 00:00:00 2001 From: Max Howell Date: Tue, 26 Dec 2023 09:51:02 +0000 Subject: [PATCH] Fix ability to use `bundle` (#4593) --- projects/rubygems.org/package.yml | 65 +++++++++++++++++++++---------- projects/rubygems.org/proxy | 4 -- 2 files changed, 45 insertions(+), 24 deletions(-) delete mode 100755 projects/rubygems.org/proxy diff --git a/projects/rubygems.org/package.yml b/projects/rubygems.org/package.yml index 8bdbfb82..665d1d00 100644 --- a/projects/rubygems.org/package.yml +++ b/projects/rubygems.org/package.yml @@ -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 don’t 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 - # We’re 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 diff --git a/projects/rubygems.org/proxy b/projects/rubygems.org/proxy deleted file mode 100755 index bbf36f9d..00000000 --- a/projects/rubygems.org/proxy +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -d="$(cd "$(dirname "$0")"/.. && pwd)" -export RUBYLIB="$d/lib" -$d/shim/$(basename "$0") "$@"