| 1 | # Copyright 1999-2009 Gentoo Foundation |
1 | # Copyright 1999-2009 Gentoo Foundation |
| 2 | # Distributed under the terms of the GNU General Public License v2 |
2 | # Distributed under the terms of the GNU General Public License v2 |
| 3 | # $Header: /var/cvsroot/gentoo-x86/eclass/ruby-fakegem.eclass,v 1.10 2010/01/09 21:16:37 flameeyes Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/ruby-fakegem.eclass,v 1.15 2010/02/19 08:47:36 flameeyes Exp $ |
| 4 | # |
4 | # |
| 5 | # @ECLASS: ruby-fakegem.eclass |
5 | # @ECLASS: ruby-fakegem.eclass |
| 6 | # @MAINTAINER: |
6 | # @MAINTAINER: |
| 7 | # Ruby herd <ruby@gentoo.org> |
7 | # Ruby herd <ruby@gentoo.org> |
| 8 | # |
8 | # |
| … | |
… | |
| 58 | # @DESCRIPTION: |
58 | # @DESCRIPTION: |
| 59 | # Extra require paths (beside lib) to add to the specification |
59 | # Extra require paths (beside lib) to add to the specification |
| 60 | # RUBY_FAKEGEM_REQUIRE_PATHS="" |
60 | # RUBY_FAKEGEM_REQUIRE_PATHS="" |
| 61 | |
61 | |
| 62 | RUBY_FAKEGEM_NAME="${RUBY_FAKEGEM_NAME:-${PN}}" |
62 | RUBY_FAKEGEM_NAME="${RUBY_FAKEGEM_NAME:-${PN}}" |
| 63 | RUBY_FAKEGEM_VERSION="${RUBY_FAKEGEM_VERSION:-${PV}}" |
63 | RUBY_FAKEGEM_VERSION="${RUBY_FAKEGEM_VERSION:-${PV/_pre/.pre}}" |
|
|
64 | RUBY_FAKEGEM_SUFFIX="${RUBY_FAKEGEM_SUFFIX:-}" |
| 64 | |
65 | |
| 65 | RUBY_FAKEGEM_TASK_DOC="${RUBY_FAKEGEM_TASK_DOC-rdoc}" |
66 | RUBY_FAKEGEM_TASK_DOC="${RUBY_FAKEGEM_TASK_DOC-rdoc}" |
| 66 | RUBY_FAKEGEM_TASK_TEST="${RUBY_FAKEGEM_TASK_TEST-test}" |
67 | RUBY_FAKEGEM_TASK_TEST="${RUBY_FAKEGEM_TASK_TEST-test}" |
| 67 | |
68 | |
| 68 | RUBY_FAKEGEM_BINWRAP="${RUBY_FAKEGEM_BINWRAP-*}" |
69 | RUBY_FAKEGEM_BINWRAP="${RUBY_FAKEGEM_BINWRAP-*}" |
| … | |
… | |
| 75 | if [[ ${RUBY_FAKEGEM_TASK_TEST} != "" ]]; then |
76 | if [[ ${RUBY_FAKEGEM_TASK_TEST} != "" ]]; then |
| 76 | IUSE="$IUSE test" |
77 | IUSE="$IUSE test" |
| 77 | ruby_add_bdepend test "dev-ruby/rake" |
78 | ruby_add_bdepend test "dev-ruby/rake" |
| 78 | fi |
79 | fi |
| 79 | |
80 | |
| 80 | SRC_URI="mirror://rubygems/${RUBY_FAKEGEM_NAME}-${RUBY_FAKEGEM_VERSION}.gem" |
81 | SRC_URI="mirror://rubygems/${RUBY_FAKEGEM_NAME}-${RUBY_FAKEGEM_VERSION}${RUBY_FAKEGEM_SUFFIX:+-${RUBY_FAKEGEM_SUFFIX}}.gem" |
| 81 | |
82 | |
| 82 | ruby_add_rdepend virtual/rubygems |
83 | ruby_add_rdepend virtual/rubygems |
| 83 | |
84 | |
| 84 | # @FUNCTION: ruby_fakegem_gemsdir |
85 | # @FUNCTION: ruby_fakegem_gemsdir |
| 85 | # @RETURN: Returns the gem data directory |
86 | # @RETURN: Returns the gem data directory |
| … | |
… | |
| 143 | |
144 | |
| 144 | # We use the _ruby_implementation variable to avoid having stray |
145 | # We use the _ruby_implementation variable to avoid having stray |
| 145 | # copies with different implementations; while for now we're using |
146 | # copies with different implementations; while for now we're using |
| 146 | # the same exact content, we might have differences in the future, |
147 | # the same exact content, we might have differences in the future, |
| 147 | # so better taking this into consideration. |
148 | # so better taking this into consideration. |
|
|
149 | local quoted_description=${DESCRIPTION//\"/\\\"} |
| 148 | cat - > "${T}"/${RUBY_FAKEGEM_NAME}-${_ruby_implementation} <<EOF |
150 | cat - > "${T}"/${RUBY_FAKEGEM_NAME}-${_ruby_implementation} <<EOF |
| 149 | Gem::Specification.new do |s| |
151 | Gem::Specification.new do |s| |
| 150 | s.name = "${RUBY_FAKEGEM_NAME}" |
152 | s.name = "${RUBY_FAKEGEM_NAME}" |
| 151 | s.version = "${RUBY_FAKEGEM_VERSION}" |
153 | s.version = "${RUBY_FAKEGEM_VERSION}" |
| 152 | s.summary = "${DESCRIPTION}" |
154 | s.summary = "${quoted_description}" |
| 153 | s.homepage = "${HOMEPAGE}" |
155 | s.homepage = "${HOMEPAGE}" |
| 154 | s.require_paths = [${required_paths}] |
156 | s.require_paths = [${required_paths}] |
| 155 | end |
157 | end |
| 156 | EOF |
158 | EOF |
| 157 | |
159 | |
| … | |
… | |
| 168 | ruby_fakegem_binwrapper() { |
170 | ruby_fakegem_binwrapper() { |
| 169 | ( |
171 | ( |
| 170 | local gembinary=$1 |
172 | local gembinary=$1 |
| 171 | local newbinary=${2:-/usr/bin/$gembinary} |
173 | local newbinary=${2:-/usr/bin/$gembinary} |
| 172 | local relativegembinary=${RUBY_FAKEGEM_NAME}-${RUBY_FAKEGEM_VERSION}/bin/${gembinary} |
174 | local relativegembinary=${RUBY_FAKEGEM_NAME}-${RUBY_FAKEGEM_VERSION}/bin/${gembinary} |
|
|
175 | local binpath=$(dirname $newbinary) |
|
|
176 | [[ ${binpath} = . ]] && binpath=/usr/bin |
| 173 | |
177 | |
| 174 | cat - > "${T}"/gembin-wrapper-${gembinary} <<EOF |
178 | cat - > "${T}"/gembin-wrapper-${gembinary} <<EOF |
| 175 | #!/usr/bin/env ruby |
179 | #!/usr/bin/env ruby |
| 176 | # This is a simplified version of the RubyGems wrapper |
180 | # This is a simplified version of the RubyGems wrapper |
| 177 | # |
181 | # |
| … | |
… | |
| 181 | |
185 | |
| 182 | load Gem::default_path[-1] + "/gems/${relativegembinary}" |
186 | load Gem::default_path[-1] + "/gems/${relativegembinary}" |
| 183 | |
187 | |
| 184 | EOF |
188 | EOF |
| 185 | |
189 | |
| 186 | exeinto $(dirname $newbinary) |
190 | exeinto ${binpath:-/usr/bin} |
| 187 | newexe "${T}"/gembin-wrapper-${gembinary} $(basename $newbinary) |
191 | newexe "${T}"/gembin-wrapper-${gembinary} $(basename $newbinary) |
| 188 | ) || die "Unable to create fakegem wrapper" |
192 | ) || die "Unable to create fakegem wrapper" |
| 189 | } |
193 | } |
| 190 | |
194 | |
| 191 | # @FUNCTION: all_fakegem_compile |
195 | # @FUNCTION: all_fakegem_compile |
| … | |
… | |
| 213 | ebegin "Unpacking .gem file..." |
217 | ebegin "Unpacking .gem file..." |
| 214 | tar -mxf ${DISTDIR}/${A} || die |
218 | tar -mxf ${DISTDIR}/${A} || die |
| 215 | eend $? |
219 | eend $? |
| 216 | |
220 | |
| 217 | mkdir "${S}" |
221 | mkdir "${S}" |
| 218 | pushd "${S}" |
222 | pushd "${S}" &>/dev/null |
| 219 | |
223 | |
| 220 | ebegin "Unpacking data.tar.gz" |
224 | ebegin "Unpacking data.tar.gz" |
| 221 | tar -mxf "${my_WORKDIR}"/data.tar.gz || die |
225 | tar -mxf "${my_WORKDIR}"/data.tar.gz || die |
| 222 | eend $? |
226 | eend $? |
|
|
227 | popd &>/dev/null |
| 223 | else |
228 | else |
| 224 | [[ -n ${A} ]] && unpack ${A} |
229 | [[ -n ${A} ]] && unpack ${A} |
| 225 | fi |
230 | fi |
| 226 | } |
231 | } |
| 227 | |
232 | |
| … | |
… | |
| 235 | # @FUNCTION: each_fakegem_test |
240 | # @FUNCTION: each_fakegem_test |
| 236 | # @DESCRIPTION: |
241 | # @DESCRIPTION: |
| 237 | # Run tests for the package for each ruby target if the test task is defined. |
242 | # Run tests for the package for each ruby target if the test task is defined. |
| 238 | each_fakegem_test() { |
243 | each_fakegem_test() { |
| 239 | local rubyflags= |
244 | local rubyflags= |
| 240 | |
|
|
| 241 | if [[ ${RUBY_FAKEGEM_TASK_TEST} != "" ]]; then |
|
|
| 242 | ${RUBY} ${rubyflags} -S rake ${RUBY_FAKEGEM_TASK_TEST} || die "tests failed" |
245 | ${RUBY} ${rubyflags} -S rake ${RUBY_FAKEGEM_TASK_TEST} || die "tests failed" |
| 243 | else |
|
|
| 244 | echo "No test task defined, skipping tests." |
|
|
| 245 | fi |
|
|
| 246 | } |
246 | } |
| 247 | |
247 | |
|
|
248 | if [[ ${RUBY_FAKEGEM_TASK_TEST} != "" ]]; then |
| 248 | # @FUNCTION: each_ruby_test |
249 | # @FUNCTION: each_ruby_test |
| 249 | # @DESCRIPTION: |
250 | # @DESCRIPTION: |
| 250 | # Run the tests for this package. |
251 | # Run the tests for this package. |
| 251 | each_ruby_test() { |
252 | each_ruby_test() { |
| 252 | each_fakegem_test |
253 | each_fakegem_test |
| 253 | } |
254 | } |
|
|
255 | fi |
| 254 | |
256 | |
| 255 | # @FUNCTION: each_fakegem_install |
257 | # @FUNCTION: each_fakegem_install |
| 256 | # @DESCRIPTION: |
258 | # @DESCRIPTION: |
| 257 | # Install the package for each ruby target. |
259 | # Install the package for each ruby target. |
| 258 | each_fakegem_install() { |
260 | each_fakegem_install() { |
| 259 | ruby_fakegem_genspec |
261 | ruby_fakegem_genspec |
| 260 | |
262 | |
| 261 | local _gemlibdirs= |
263 | local _gemlibdirs="${RUBY_FAKEGEM_EXTRAINSTALL}" |
| 262 | for directory in bin lib ${RUBY_FAKEGEM_EXTRAINSTALL}; do |
264 | for directory in bin lib; do |
| 263 | [[ -d ${directory} ]] && _gemlibdirs="${_gemlibdirs} ${directory}" |
265 | [[ -d ${directory} ]] && _gemlibdirs="${_gemlibdirs} ${directory}" |
| 264 | done |
266 | done |
| 265 | |
267 | |
| 266 | [[ -n ${_gemlibdirs} ]] && \ |
268 | [[ -n ${_gemlibdirs} ]] && \ |
| 267 | ruby_fakegem_doins -r ${_gemlibdirs} |
269 | ruby_fakegem_doins -r ${_gemlibdirs} |
| … | |
… | |
| 278 | # @DESCRIPTION: |
280 | # @DESCRIPTION: |
| 279 | # Install files common to all ruby targets. |
281 | # Install files common to all ruby targets. |
| 280 | all_fakegem_install() { |
282 | all_fakegem_install() { |
| 281 | if [[ -n ${RUBY_FAKEGEM_DOCDIR} ]] && [[ ${RUBY_FAKEGEM_TASK_DOC} != "" ]] && use doc; then |
283 | if [[ -n ${RUBY_FAKEGEM_DOCDIR} ]] && [[ ${RUBY_FAKEGEM_TASK_DOC} != "" ]] && use doc; then |
| 282 | for dir in ${RUBY_FAKEGEM_DOCDIR}; do |
284 | for dir in ${RUBY_FAKEGEM_DOCDIR}; do |
| 283 | pushd ${dir} |
285 | pushd ${dir} &>/dev/null |
| 284 | dohtml -r * || die "failed to install documentation" |
286 | dohtml -r * || die "failed to install documentation" |
| 285 | popd |
287 | popd &>/dev/null |
| 286 | done |
288 | done |
| 287 | fi |
289 | fi |
| 288 | |
290 | |
| 289 | if [[ -n ${RUBY_FAKEGEM_EXTRADOC} ]]; then |
291 | if [[ -n ${RUBY_FAKEGEM_EXTRADOC} ]]; then |
| 290 | dodoc ${RUBY_FAKEGEM_EXTRADOC} || die "failed to install further documentation" |
292 | dodoc ${RUBY_FAKEGEM_EXTRADOC} || die "failed to install further documentation" |
| … | |
… | |
| 294 | # same binaries, or something is wrong anyway, so... |
296 | # same binaries, or something is wrong anyway, so... |
| 295 | if [[ -n ${RUBY_FAKEGEM_BINWRAP} ]]; then |
297 | if [[ -n ${RUBY_FAKEGEM_BINWRAP} ]]; then |
| 296 | local bindir=$(find "${D}" -type d -path "*/gems/${RUBY_FAKEGEM_NAME}-${RUBY_FAKEGEM_VERSION}/bin" -print -quit) |
298 | local bindir=$(find "${D}" -type d -path "*/gems/${RUBY_FAKEGEM_NAME}-${RUBY_FAKEGEM_VERSION}/bin" -print -quit) |
| 297 | |
299 | |
| 298 | if [[ -d "${bindir}" ]]; then |
300 | if [[ -d "${bindir}" ]]; then |
| 299 | pushd "${bindir}" |
301 | pushd "${bindir}" &>/dev/null |
| 300 | local binaries=$(eval ls ${RUBY_FAKEGEM_BINWRAP}) |
302 | local binaries=$(eval ls ${RUBY_FAKEGEM_BINWRAP}) |
| 301 | for binary in $binaries; do |
303 | for binary in $binaries; do |
| 302 | ruby_fakegem_binwrapper $binary |
304 | ruby_fakegem_binwrapper $binary |
| 303 | done |
305 | done |
| 304 | popd |
306 | popd &>/dev/null |
| 305 | fi |
307 | fi |
| 306 | fi |
308 | fi |
| 307 | } |
309 | } |
| 308 | |
310 | |
| 309 | # @FUNCTION: all_ruby_install |
311 | # @FUNCTION: all_ruby_install |