Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 330543 - please review mods for ruby-ng.eclass from Gentoo Prefix overlay
Summary: please review mods for ruby-ng.eclass from Gentoo Prefix overlay
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Eclasses (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Gentoo Ruby Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-07-30 16:16 UTC by Jeremy Olexa (darkside) (RETIRED)
Modified: 2010-07-30 16:56 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
ruby-ng-prefix.diff r2 (ruby-ng-prefix.diff,2.22 KB, patch)
2010-07-30 16:39 UTC, Jeremy Olexa (darkside) (RETIRED)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jeremy Olexa (darkside) (RETIRED) archtester gentoo-dev Security 2010-07-30 16:16:18 UTC
I'm working on ruby stuff today, I guess.

inline diff:

Index: ruby-ng.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/ruby-ng.eclass,v
retrieving revision 1.23
diff -u -r1.23 ruby-ng.eclass
--- ruby-ng.eclass      30 Jul 2010 15:05:08 -0000      1.23
+++ ruby-ng.eclass      30 Jul 2010 16:12:14 -0000
@@ -1,6 +1,6 @@
 # Copyright 1999-2009 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/ruby-ng.eclass,v 1.23 2010/07/30 15:0
5:08 flameeyes Exp $
+# $Header: $
 #
 # @ECLASS: ruby-ng.eclass
 # @MAINTAINER:
@@ -53,7 +53,7 @@
 case ${EAPI} in
        0|1)
                die "Unsupported EAPI=${EAPI} (too old) for ruby-ng.eclass" ;;
-       2) ;;
+       2|3) ;;
        *)
                die "Unknown EAPI=${EAPI} for ruby-ng.eclass"
 esac
@@ -392,7 +392,14 @@

 _each_ruby_check_install() {
        local libruby_basename=$(${RUBY} -rrbconfig -e 'puts Config::CONFIG["LIBRUBY_SO"]')
-       local libruby_soname=$(scanelf -F "%S#F" -qS "/usr/$(get_libdir)/${libruby_basename}")
+       if [[ ${CHOST} == *-darwin ]] ; then
+               # we have a Mach-O object here
+               local libruby_soname=$(scanmacho -F "%S#F" -qS "${EPREFIX}/usr/$(get_libdir)/${libruby_basename}")
+               # install_names are absolute
+               libruby_soname=${libruby_soname##*/}
+       else
+               local libruby_soname=$(scanelf -F "%S#F" -qS "${EPREFIX}/usr/$(get_libdir)/${libruby_basename}")
+       fi
        local sitedir=$(${RUBY} -rrbconfig -e 'puts Config::CONFIG["sitedir"]')
        local sitelibdir=$(${RUBY} -rrbconfig -e 'puts Config::CONFIG["sitelibdir"]')

@@ -413,9 +420,15 @@
        # extensions via ruby-fakegem; make sure to check only in sitelibdir, since
        # that's what changes between two implementations (otherwise you'd get false
        # positives now that Ruby 1.9.2 installs with the same sitedir as 1.8)
-       scanelf -qnR "${D}${sitelibdir}" "${D}${sitelibdir/site_ruby/gems}" \
-               | fgrep -v "${libruby_soname}" \
-               > "${T}"/ruby-ng-${_ruby_implementation}-mislink.log
+       if [[ ${CHOST} == *-darwin* ]] ; then
+               scanmacho -qnR "${D}${sitedir}" "${D}${sitelibdir/site_ruby/gems}" \
+                       | fgrep -v "${libruby_soname}" \
+                       > "${T}"/ruby-ng-${_ruby_implementation}-mislink.log
+       else
+               scanelf -qnR "${D}${sitedir}" "${D}${sitelibdir/site_ruby/gems}" \
+                       | fgrep -v "${libruby_soname}" \
+                       > "${T}"/ruby-ng-${_ruby_implementation}-mislink.log
+       fi

        if [[ -s "${T}"/ruby-ng-${_ruby_implementation}-mislink.log ]]; then
                ewarn "Extensions installed for ${_ruby_implementation} with missing links to ${libruby_soname}"
@@ -453,7 +466,8 @@
 doruby() {
        [[ -z ${RUBY} ]] && die "\$RUBY is not set"
        ( # don't want to pollute calling env 
-               insinto $(ruby_rbconfig_value 'sitelibdir')
+               sitelibdir=$(ruby_rbconfig_value 'sitelibdir')
+               insinto ${sitelibdir#${EPREFIX}}
                insopts -m 0644
                doins "$@"
        ) || die "failed to install $@"


That is the basic concept. I don't like that it forces every consumer to be EAPI=3 because $EPREFIX is used. So, we can define EPREFIX to "" if EAPI2 is used.

Thoughts?
Comment 1 Diego Elio Pettenò (RETIRED) gentoo-dev 2010-07-30 16:24:00 UTC
Hrm can you please provide it as a .diff file next time? it's quite unreadable because of word wrapping this way.

Anyway, I don't like the two ifs on CHOST, can't we wrap that up in a single

scancmd=scanelf
[[ ${CHOST} == *-darwin ]] && scancmd=scanmacho

$scancmd -F...

and then use $(basename) (rather than relying /) unconditionally?

I don't think performance is much of a point here, but readability certainly is.
Comment 2 Jeremy Olexa (darkside) (RETIRED) archtester gentoo-dev Security 2010-07-30 16:39:05 UTC
Created attachment 240729 [details, diff]
ruby-ng-prefix.diff r2

You are right, I was thinking of that as soon as I submitted it. Here is a smaller diff with $scancmd usage.
Comment 3 Diego Elio Pettenò (RETIRED) gentoo-dev 2010-07-30 16:56:34 UTC
Applied, thanks!