On Fri, 17 Nov 2006 21:01:06 -0000, <ara.t.howard / noaa.gov> wrote:

> On Sat, 18 Nov 2006 Ara.T.Howard / noaa.gov wrote:
>
>> On Sat, 18 Nov 2006, Daniel Berger wrote:
>>
>>> Bil Kleb wrote:
>>>> ara.t.howard / noaa.gov wrote:
>>>>>  searching the docs and archives - i'm still unclear:  is there, or  
>>>>> is there
>>>>> not a way to have gems run pre-post install steps?
>>>>  Don't think so,
>>>>    http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/203058
>>>  Bummer.  Ross Bamford does have a feature request in:
>>>   
>>> http://rubyforge.org/tracker/index.php?func=detail&aid=2890&group_id=126&atid=578
>>
>> found a workaround
>>
>>  spec.extensions = 'extconf.rb'
>>
>>
>> now, do whatever you like in extconf.rb
>
> scratch that.  doesn't work quite right.
>
> -a

I played around with the same idea before I made that feature request. It  
can be made to work, but you do have to generate a Makefile out of your  
extconf to get it to work without warnings. Also, you need to stick to the  
'source in lib/' layout or it'll complain during install.

E.g.

# --- extconf.rb
require 'mkmf'

puts "This is my pre-install code"

create_makefile('test')


# --- test.gemspec
spec = Gem::Specification.new do |s|
   s.name = 'test'
   s.summary = 'extconf hack'
   s.description = 'testing extconf hack'
   s.version = '0.0.1'
   s.extensions << 'extconf.rb'

   s.files = ['lib/test.rb']
   s.require_path = 'lib'
end


$ su -c 'gem install test-0.0.1.gem'
Password:
Building native extensions.  This could take a while...
ruby extconf.rb install test-0.0.1.gem
This is my pre-install code
creating Makefile

make
make: Nothing to be done for `all'.

make install
make: Nothing to be done for `install'.

make clean
Successfully installed test, version 0.0.1

It's messy, but I think it's a good argument for having pre/post hooks  
anyway - I understand the security concerns, but if we can do this extconf  
trick, isn't that academic anyway?

Cheers,
-- 
Ross Bamford - rosco / roscopeco.remove.co.uk