A
Ara.T.Howard
SYNOPSIS
this patch allows any value in Config::CONFIG to be altered from the
command line when using gem. by altering a value, for example bindir, fine
grained control can be affected during the installation proccess. here is the
patch:
PATCH
jib:~ > diff -u gem.org gem
--- gem.org 2005-10-26 14:51:53.000000000 -0600
+++ gem 2005-10-26 17:44:31.000000000 -0600
@@ -14,4 +14,16 @@
# it...its for the source building process.
args = !ARGV.include?("--") ? ARGV.clone : ARGV[0...ARGV.index("--")]
+#
+# munge rbconfig from any command line or environment kv pair
+#
+kvs = []
+re = %r/^ \s* ([^=\s]+) \s* = \s* ([^\s]+) \s* $/x
+args.delete_if{|arg| (m = re.match(arg)) and (kvs << m.to_a.last(2))}
+ENV::each{|k,v| (k =~ %r/^GEM_/) and (kvs << [k.delete('GEM_'), v])}
+unless kvs.empty?
+ require 'rbconfig'
+ kvs.each{|k,v| Config::CONFIG[k] = v}
+end
+
Gem::GemRunner.new.run(args)
EXAMPLE USAGE
jib:~ > which rake
which: no rake in ...
jib: > ruby -r rbconfig -e'p Config::CONFIG["bindir"]'
"/dmsp/reference/ruby-1.8.1//bin"
jib: > gem install bindir=/dmsp/reference/bin rake
Attempting local installation of 'rake'
Local gem file not found: rake*.gem
Attempting remote installation of 'rake'
Successfully installed rake-0.6.2
Installing RDoc documentation for rake-0.6.2...
jib: > which rake
/dmsp/reference/bin/rake
so anything value in Config::CONFIG can be replaced on the command line.
configuration via the environment is also supported. so i could have done the
above via
jib: > export GEM_bindir=/dmsp/reference/bin
jib: > gem install rake
any env var starting with 'GEM_' is taken to be a key/val pair for
Config::CONFIG.
thoughts?
-a
--
===============================================================================
| email :: ara [dot] t [dot] howard [at] noaa [dot] gov
| phone :: 303.497.6469
| anything that contradicts experience and logic should be abandoned.
| -- h.h. the 14th dalai lama
===============================================================================
this patch allows any value in Config::CONFIG to be altered from the
command line when using gem. by altering a value, for example bindir, fine
grained control can be affected during the installation proccess. here is the
patch:
PATCH
jib:~ > diff -u gem.org gem
--- gem.org 2005-10-26 14:51:53.000000000 -0600
+++ gem 2005-10-26 17:44:31.000000000 -0600
@@ -14,4 +14,16 @@
# it...its for the source building process.
args = !ARGV.include?("--") ? ARGV.clone : ARGV[0...ARGV.index("--")]
+#
+# munge rbconfig from any command line or environment kv pair
+#
+kvs = []
+re = %r/^ \s* ([^=\s]+) \s* = \s* ([^\s]+) \s* $/x
+args.delete_if{|arg| (m = re.match(arg)) and (kvs << m.to_a.last(2))}
+ENV::each{|k,v| (k =~ %r/^GEM_/) and (kvs << [k.delete('GEM_'), v])}
+unless kvs.empty?
+ require 'rbconfig'
+ kvs.each{|k,v| Config::CONFIG[k] = v}
+end
+
Gem::GemRunner.new.run(args)
EXAMPLE USAGE
jib:~ > which rake
which: no rake in ...
jib: > ruby -r rbconfig -e'p Config::CONFIG["bindir"]'
"/dmsp/reference/ruby-1.8.1//bin"
jib: > gem install bindir=/dmsp/reference/bin rake
Attempting local installation of 'rake'
Local gem file not found: rake*.gem
Attempting remote installation of 'rake'
Successfully installed rake-0.6.2
Installing RDoc documentation for rake-0.6.2...
jib: > which rake
/dmsp/reference/bin/rake
so anything value in Config::CONFIG can be replaced on the command line.
configuration via the environment is also supported. so i could have done the
above via
jib: > export GEM_bindir=/dmsp/reference/bin
jib: > gem install rake
any env var starting with 'GEM_' is taken to be a key/val pair for
Config::CONFIG.
thoughts?
-a
--
===============================================================================
| email :: ara [dot] t [dot] howard [at] noaa [dot] gov
| phone :: 303.497.6469
| anything that contradicts experience and logic should be abandoned.
| -- h.h. the 14th dalai lama
===============================================================================