Am 23.02.2012 09:30 schrieb Corinna Vinschen:
> If you ran rebaseall, then ruby's shared libs should have been rebased
> as well.

This is not necessarily true if you've got gems (just like perl CPAN
modules) not packaged by cygwin installed.

For that I've hacked a rubyrebase script from the cygwin supplied
perlrebase script. I've attached it here, maybe it can be useful for other
people as well.

Feel free to use it for whatever you want, public domain, CC-0, whatever.


Michael
#!/bin/sh

# The default ruby modules are properly rebased, a rebase clash is very 
unlikely.
# However with more and more ruby gems being added over time,
# *** fatal error - unable to remap some.dll to same address as parent
# will become more likely, and those new DLLs are not rebased by a normal 
rebaseall.
# rubyrebase starts afresh all ruby DLLs from a pretty low base upwards.

suff=$1
baseaddr=$2
# use a rather low base and go upwards, might clash with some Win7 system dlls
baseaddr=${baseaddr:=0x57000000}
ruby=/usr/local/bin/ruby$suff.exe
if [ ! -f $ruby ]; then
  ruby=/usr/bin/ruby$suff.exe
  if [ ! -f $ruby ]; then
    echo "$ruby and /usr/local/bin/ruby.exe not found"
    echo "usage: rubyrebase [1.8 [baseaddr]]"
    exit
  fi
fi
dll=$(ldd $ruby | $ruby -anle 'print $F[2] if /cygruby/')
if [ ! -e /usr/bin/rebase.exe ]; then
  echo "/usr/bin/rebase.exe not found. Install the rebase package"
  exit
fi

archdir=$($ruby -rrbconfig -e 'puts RbConfig::CONFIG["archdir"]')
sitedir=$($ruby -rrbconfig -e 'puts RbConfig::CONFIG["sitearchdir"]')
vendordir=$($ruby -rrbconfig -e 'puts RbConfig::CONFIG["vendorarchdir"]')
ext=$($ruby -rrbconfig -e 'puts RbConfig::CONFIG["DLEXT"]')

# write to a local .lst to be able to re-order dlls locally
echo $ruby > rebase$suff.lst
echo $dll >> rebase$suff.lst
/usr/bin/find $archdir -name \*.$ext >> rebase$suff.lst
/usr/bin/find $sitedir -name \*.$ext >> rebase$suff.lst
/usr/bin/find $vendordir -name \*.$ext >> rebase$suff.lst
# rubygems might not be installed, in this case ruby errors and the error 
message is not likely to be a valid directory :)
for i in $($ruby -rrubygems -e 'Gem.path.each {|f| puts f}'); do if [ -d $i ]; 
then /usr/bin/find $i -name \*.$ext >> rebase$suff.lst; fi done

/usr/bin/cat rebase$suff.lst | /usr/bin/xargs chmod ug+w 
[ -e /usr/bin/peflags.exe ] && /usr/bin/peflags -t $ruby
/usr/bin/rebase -v -b $baseaddr -T rebase$suff.lst
[ -e /usr/bin/peflags.exe ] && /usr/bin/grep .so rebase$suff.lst | 
/usr/bin/peflags -d0 -T - >/dev/null
/usr/bin/cat rebase$suff.lst | /usr/bin/xargs chmod g-w
--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

Reply via email to