mirror of
https://github.com/ivabus/pantry
synced 2024-11-22 16:35:07 +03:00
relocatability fixes for ruby and gem (#322)
Refs https://github.com/teaxyz/cli/issues/374
This commit is contained in:
parent
74fa81843b
commit
d70837f2c8
5 changed files with 267 additions and 10 deletions
BIN
.DS_Store
vendored
Normal file
BIN
.DS_Store
vendored
Normal file
Binary file not shown.
28
projects/ruby-lang.org/mkconfig.rb.diff
Normal file
28
projects/ruby-lang.org/mkconfig.rb.diff
Normal file
|
@ -0,0 +1,28 @@
|
|||
diff --git a/tool/mkconfig.rb b/tool/mkconfig.rb
|
||||
index e6d61c5..1517669 100755
|
||||
--- a/tool/mkconfig.rb
|
||||
+++ b/tool/mkconfig.rb
|
||||
@@ -73,6 +73,7 @@ File.foreach "config.status" do |line|
|
||||
when /^sitearch$/; val = '$(arch)' if val.empty?
|
||||
when /^DESTDIR$/; next
|
||||
when /RUBYGEMS/; next
|
||||
+ when /^sysconfdir$/; val = '$(kegdir)/etc'
|
||||
end
|
||||
case val
|
||||
when /^\$\(ac_\w+\)$/; next
|
||||
@@ -191,6 +192,7 @@ module RbConfig
|
||||
]
|
||||
print " # Ruby installed directory.\n"
|
||||
print " TOPDIR = File.dirname(__FILE__).chomp!(#{relative_archdir.dump})\n"
|
||||
+print " KEGDIR = TOPDIR ? File.dirname(TOPDIR) : nil\n"
|
||||
print " # DESTDIR on make install.\n"
|
||||
print " DESTDIR = ", (drive ? "TOPDIR && TOPDIR[/\\A[a-z]:/i] || " : ""), "'' unless defined? DESTDIR\n"
|
||||
print <<'ARCH' if universal
|
||||
@@ -293,6 +295,7 @@ print <<EOS
|
||||
CONFIG["platform"] = #{platform || '"$(arch)"'}
|
||||
CONFIG["archdir"] = "$(rubyarchdir)"
|
||||
CONFIG["topdir"] = File.dirname(__FILE__)
|
||||
+ CONFIG["kegdir"] = KEGDIR || "$(prefix)"
|
||||
# Almost same with CONFIG. MAKEFILE_CONFIG has other variable
|
||||
# reference like below.
|
||||
#
|
|
@ -16,16 +16,13 @@ build:
|
|||
gnu.org/gettext: ^0.21
|
||||
tea.xyz/gx/cc: c99
|
||||
tea.xyz/gx/make: '*'
|
||||
gnu.org/patch: '*'
|
||||
script: |
|
||||
patch -p1 < props/mkconfig.rb.diff
|
||||
|
||||
./configure --prefix="{{prefix}}" --enable-load-relative --disable-rubygems
|
||||
make --jobs {{hw.concurrency}} install
|
||||
|
||||
cd "{{prefix}}/lib/ruby/{{version.major}}.{{version.minor}}.0/rubygems"
|
||||
|
||||
# use the GEM_PATH we want
|
||||
sed -i.bak -e 's;@default_dir ||=.*;@default_dir ||= File.expand_path(File.join(__FILE__, "../../../../../../gems", RbConfig::CONFIG["ruby_version"]));' defaults.rb
|
||||
rm defaults.rb.bak
|
||||
|
||||
cd "{{prefix}}/bin"
|
||||
|
||||
# we provide these as `rubygems.org`
|
||||
|
@ -37,6 +34,19 @@ build:
|
|||
sed -i.bak -e 's_#!{{prefix}}/bin/ruby_#!/usr/bin/env ruby_' $shim
|
||||
rm $shim.bak
|
||||
done
|
||||
|
||||
cd ../lib/ruby/{{version.major}}.{{version.minor}}.0
|
||||
|
||||
# ruby itself provides the gems for these and we don’t want that
|
||||
# we want to pkg them ourselves as part of rubygems.org
|
||||
for x in bundler rubygems bundler.rb rubygems.rb; do
|
||||
if test -d $x; then
|
||||
rm -rf $x
|
||||
else
|
||||
rm $x
|
||||
fi
|
||||
ln -s ../../../../rubygems.org/v\*/lib/$x
|
||||
done
|
||||
env:
|
||||
shims:
|
||||
- erb
|
||||
|
@ -54,9 +64,12 @@ test:
|
|||
tea.xyz/gx/make: '*'
|
||||
script: |
|
||||
ruby -e 'puts "Hello World!"'
|
||||
gem install hexapdf -v 0.28.0
|
||||
hexapdf version
|
||||
gem install hexapdf -v 0.28.0 --bindir=. --no-user-install
|
||||
./hexapdf version
|
||||
test -d "{{tea.prefix}}"/ruby-lang.org/gems/{{version.major}}.{{version.minor}}.0/gems/hexapdf-0.28.0
|
||||
gem install bundle
|
||||
test -d ~/.gem/ruby/{{version.major}}.{{version.minor}}.0/gems/bundle-0.0.1
|
||||
test -f ~/.local/bin/bundle
|
||||
|
||||
provides:
|
||||
- bin/erb
|
||||
|
|
203
projects/rubygems.org/fit-n-finish.patch
Normal file
203
projects/rubygems.org/fit-n-finish.patch
Normal file
|
@ -0,0 +1,203 @@
|
|||
diff --git a/lib/rubygems.rb b/lib/rubygems.rb
|
||||
index e42aca8..84128e1 100644
|
||||
--- a/lib/rubygems.rb
|
||||
+++ b/lib/rubygems.rb
|
||||
@@ -297,10 +297,12 @@ def self.binary_mode
|
||||
##
|
||||
# The path where gem executables are to be installed.
|
||||
|
||||
- def self.bindir(install_dir=Gem.dir)
|
||||
- return File.join install_dir, "bin" unless
|
||||
- install_dir.to_s == Gem.default_dir.to_s
|
||||
- Gem.default_bindir
|
||||
+ def self.bindir(install_dir=nil)
|
||||
+ if install_dir
|
||||
+ File.join install_dir, "bin"
|
||||
+ else
|
||||
+ Gem.default_bindir
|
||||
+ end
|
||||
end
|
||||
|
||||
##
|
||||
diff --git a/lib/rubygems/config_file.rb b/lib/rubygems/config_file.rb
|
||||
index 4aa8b4d..8354c08 100644
|
||||
--- a/lib/rubygems/config_file.rb
|
||||
+++ b/lib/rubygems/config_file.rb
|
||||
@@ -62,12 +62,7 @@ class Gem::ConfigFile
|
||||
# :stopdoc:
|
||||
|
||||
SYSTEM_CONFIG_PATH =
|
||||
- begin
|
||||
- require "etc"
|
||||
- Etc.sysconfdir
|
||||
- rescue LoadError, NoMethodError
|
||||
- RbConfig::CONFIG["sysconfdir"] || "/etc"
|
||||
- end
|
||||
+ RbConfig::CONFIG["sysconfdir"] || "/etc"
|
||||
|
||||
# :startdoc:
|
||||
|
||||
diff --git a/lib/rubygems/defaults.rb b/lib/rubygems/defaults.rb
|
||||
index 8daff0b..1fab83c 100644
|
||||
--- a/lib/rubygems/defaults.rb
|
||||
+++ b/lib/rubygems/defaults.rb
|
||||
@@ -20,13 +20,7 @@ def self.default_sources
|
||||
# specified in the environment
|
||||
|
||||
def self.default_spec_cache_dir
|
||||
- default_spec_cache_dir = File.join Gem.user_home, ".gem", "specs"
|
||||
-
|
||||
- unless File.exist?(default_spec_cache_dir)
|
||||
- default_spec_cache_dir = File.join Gem.data_home, "gem", "specs"
|
||||
- end
|
||||
-
|
||||
- default_spec_cache_dir
|
||||
+ File.join Gem.data_home, "specs"
|
||||
end
|
||||
|
||||
##
|
||||
@@ -34,7 +28,7 @@ def self.default_spec_cache_dir
|
||||
# specified in the environment
|
||||
|
||||
def self.default_dir
|
||||
- @default_dir ||= File.join(RbConfig::CONFIG["rubylibprefix"], "gems", RbConfig::CONFIG["ruby_version"])
|
||||
+ @default_dir ||= File.expand_path(File.join(__FILE__, "../../../../../ruby-lang.org/gems", RbConfig::CONFIG["ruby_version"]))
|
||||
end
|
||||
|
||||
##
|
||||
@@ -100,8 +94,7 @@ def self.user_home
|
||||
# Path for gems in the user's home directory
|
||||
|
||||
def self.user_dir
|
||||
- gem_dir = File.join(Gem.user_home, ".gem")
|
||||
- gem_dir = File.join(Gem.data_home, "gem") unless File.exist?(gem_dir)
|
||||
+ gem_dir = Gem.data_home
|
||||
parts = [gem_dir, ruby_engine]
|
||||
parts << RbConfig::CONFIG["ruby_version"] unless RbConfig::CONFIG["ruby_version"].empty?
|
||||
File.join parts
|
||||
@@ -111,18 +104,17 @@ def self.user_dir
|
||||
# The path to standard location of the user's configuration directory.
|
||||
|
||||
def self.config_home
|
||||
- @config_home ||= (ENV["XDG_CONFIG_HOME"] || File.join(Gem.user_home, ".config"))
|
||||
+ @config_home ||= (ENV["XDG_CONFIG_HOME"] || File.join(Gem.user_home, ".gem"))
|
||||
end
|
||||
|
||||
##
|
||||
# Finds the user's config file
|
||||
|
||||
def self.find_config_file
|
||||
- gemrc = File.join Gem.user_home, ".gemrc"
|
||||
- if File.exist? gemrc
|
||||
- gemrc
|
||||
+ @gemrc = if ENV["XDG_CONFIG_HOME"]
|
||||
+ File.join ENV["XDG_CONFIG_HOME"], "gemrc"
|
||||
else
|
||||
- File.join Gem.config_home, "gem", "gemrc"
|
||||
+ File.join Gem.user_home, ".gemrc"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -137,7 +129,7 @@ def self.config_file
|
||||
# The path to standard location of the user's state file.
|
||||
|
||||
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
|
||||
|
||||
##
|
||||
@@ -151,14 +143,18 @@ def self.cache_home
|
||||
# The path to standard location of the user's data directory.
|
||||
|
||||
def self.data_home
|
||||
- @data_home ||= (ENV["XDG_DATA_HOME"] || File.join(Gem.user_home, ".local", "share"))
|
||||
+ @data_home ||= if ENV["XDG_DATA_HOME"]
|
||||
+ File.join(ENV["XDG_DATA_HOME"], "gem")
|
||||
+ else
|
||||
+ File.join(Gem.user_home, ".gem")
|
||||
+ end
|
||||
end
|
||||
|
||||
##
|
||||
# The path to standard location of the user's state directory.
|
||||
|
||||
def self.state_home
|
||||
- @data_home ||= (ENV["XDG_STATE_HOME"] || File.join(Gem.user_home, ".local", "state"))
|
||||
+ File.join(Gem.data_home, "state")
|
||||
end
|
||||
|
||||
##
|
||||
@@ -197,7 +193,7 @@ def self.default_exec_format
|
||||
# The default directory for binaries
|
||||
|
||||
def self.default_bindir
|
||||
- RbConfig::CONFIG["bindir"]
|
||||
+ "/usr/local/bin"
|
||||
end
|
||||
|
||||
def self.ruby_engine
|
||||
@@ -208,26 +204,14 @@ def self.ruby_engine
|
||||
# The default signing key path
|
||||
|
||||
def self.default_key_path
|
||||
- default_key_path = File.join Gem.user_home, ".gem", "gem-private_key.pem"
|
||||
-
|
||||
- unless File.exist?(default_key_path)
|
||||
- default_key_path = File.join Gem.data_home, "gem", "gem-private_key.pem"
|
||||
- end
|
||||
-
|
||||
- default_key_path
|
||||
+ File.join Gem.data_home, "private-key.pem"
|
||||
end
|
||||
|
||||
##
|
||||
# The default signing certificate chain path
|
||||
|
||||
def self.default_cert_path
|
||||
- default_cert_path = File.join Gem.user_home, ".gem", "gem-public_cert.pem"
|
||||
-
|
||||
- unless File.exist?(default_cert_path)
|
||||
- default_cert_path = File.join Gem.data_home, "gem", "gem-public_cert.pem"
|
||||
- end
|
||||
-
|
||||
- default_cert_path
|
||||
+ File.join Gem.data_home, "public-cert.pem"
|
||||
end
|
||||
|
||||
##
|
||||
@@ -267,7 +251,10 @@ def self.vendor_dir # :nodoc:
|
||||
# end
|
||||
|
||||
def self.operating_system_defaults
|
||||
- {}
|
||||
+ {
|
||||
+ 'install' => '--no-rdoc --no-ri --env-shebang --user-install',
|
||||
+ 'update' => '--no-rdoc --no-ri --env-shebang --user-install'
|
||||
+ }
|
||||
end
|
||||
|
||||
##
|
||||
|
||||
diff --git a/lib/rubygems/installer.rb b/lib/rubygems/installer.rb
|
||||
index 9fbb282..8fa8bd9 100644
|
||||
--- a/lib/rubygems/installer.rb
|
||||
+++ b/lib/rubygems/installer.rb
|
||||
@@ -190,7 +190,7 @@ def initialize(package, options={})
|
||||
|
||||
if options[:user_install]
|
||||
@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
|
||||
@@ -953,7 +953,7 @@ def write_cache_file
|
||||
|
||||
def ensure_writable_dir(dir) # :nodoc:
|
||||
begin
|
||||
- Dir.mkdir dir, *[options[:dir_mode] && 0755].compact
|
||||
+ FileUtils.mkdir_p dir, *[options[:dir_mode] && 0755].compact
|
||||
rescue SystemCallError
|
||||
raise unless File.directory? dir
|
||||
end
|
|
@ -9,18 +9,31 @@ dependencies:
|
|||
ruby-lang.org: '>=2.3'
|
||||
|
||||
build:
|
||||
dependencies:
|
||||
gnu.org/patch: '*'
|
||||
script: |
|
||||
ruby setup.rb --prefix={{prefix}} --env-shebang
|
||||
ruby setup.rb --prefix={{prefix}} --env-shebang --no-ri --no-rdoc
|
||||
cd "{{prefix}}"
|
||||
patch -p1 < "$SRCROOT"/props/fit-n-finish.patch
|
||||
|
||||
runtime:
|
||||
env:
|
||||
# HACK that is only required for this ruby package
|
||||
# since we cannot use `gem` to build `gem` itself
|
||||
RUBYLIB: ${{prefix}}/lib
|
||||
|
||||
test:
|
||||
dependencies:
|
||||
tea.xyz/gx/cc: c99
|
||||
tea.xyz/gx/make: '*'
|
||||
env:
|
||||
HOME: $PWD
|
||||
script: |
|
||||
gem install awesome_print
|
||||
ruby -e 'require "rubygems"' -e 'require "awesome_print"' -e'ap $LOAD_PATH'
|
||||
#TODO test -d ~/.gem/ruby/{{deps.ruby.version.major}}.{{deps.ruby.version.minor}}.0/gems/hexapdf-0.28.0
|
||||
gem install hexapdf
|
||||
hexapdf version
|
||||
~/.local/bin/hexapdf version
|
||||
|
||||
provides:
|
||||
- bin/bundle
|
||||
|
|
Loading…
Reference in a new issue