/[gentoo-x86]/eclass/ruby-fakegem.eclass
Gentoo

Diff of /eclass/ruby-fakegem.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.10 Revision 1.14
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.14 2010/02/13 08:45:03 graaff 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#
143 143
144 # We use the _ruby_implementation variable to avoid having stray 144 # We use the _ruby_implementation variable to avoid having stray
145 # copies with different implementations; while for now we're using 145 # copies with different implementations; while for now we're using
146 # the same exact content, we might have differences in the future, 146 # the same exact content, we might have differences in the future,
147 # so better taking this into consideration. 147 # so better taking this into consideration.
148 local quoted_description=${DESCRIPTION//\"/\\\"}
148 cat - > "${T}"/${RUBY_FAKEGEM_NAME}-${_ruby_implementation} <<EOF 149 cat - > "${T}"/${RUBY_FAKEGEM_NAME}-${_ruby_implementation} <<EOF
149Gem::Specification.new do |s| 150Gem::Specification.new do |s|
150 s.name = "${RUBY_FAKEGEM_NAME}" 151 s.name = "${RUBY_FAKEGEM_NAME}"
151 s.version = "${RUBY_FAKEGEM_VERSION}" 152 s.version = "${RUBY_FAKEGEM_VERSION}"
152 s.summary = "${DESCRIPTION}" 153 s.summary = "${quoted_description}"
153 s.homepage = "${HOMEPAGE}" 154 s.homepage = "${HOMEPAGE}"
154 s.require_paths = [${required_paths}] 155 s.require_paths = [${required_paths}]
155end 156end
156EOF 157EOF
157 158
168ruby_fakegem_binwrapper() { 169ruby_fakegem_binwrapper() {
169 ( 170 (
170 local gembinary=$1 171 local gembinary=$1
171 local newbinary=${2:-/usr/bin/$gembinary} 172 local newbinary=${2:-/usr/bin/$gembinary}
172 local relativegembinary=${RUBY_FAKEGEM_NAME}-${RUBY_FAKEGEM_VERSION}/bin/${gembinary} 173 local relativegembinary=${RUBY_FAKEGEM_NAME}-${RUBY_FAKEGEM_VERSION}/bin/${gembinary}
174 local binpath=$(dirname $newbinary)
175 [[ ${binpath} = . ]] && binpath=/usr/bin
173 176
174 cat - > "${T}"/gembin-wrapper-${gembinary} <<EOF 177 cat - > "${T}"/gembin-wrapper-${gembinary} <<EOF
175#!/usr/bin/env ruby 178#!/usr/bin/env ruby
176# This is a simplified version of the RubyGems wrapper 179# This is a simplified version of the RubyGems wrapper
177# 180#
181 184
182load Gem::default_path[-1] + "/gems/${relativegembinary}" 185load Gem::default_path[-1] + "/gems/${relativegembinary}"
183 186
184EOF 187EOF
185 188
186 exeinto $(dirname $newbinary) 189 exeinto ${binpath:-/usr/bin}
187 newexe "${T}"/gembin-wrapper-${gembinary} $(basename $newbinary) 190 newexe "${T}"/gembin-wrapper-${gembinary} $(basename $newbinary)
188 ) || die "Unable to create fakegem wrapper" 191 ) || die "Unable to create fakegem wrapper"
189} 192}
190 193
191# @FUNCTION: all_fakegem_compile 194# @FUNCTION: all_fakegem_compile
213 ebegin "Unpacking .gem file..." 216 ebegin "Unpacking .gem file..."
214 tar -mxf ${DISTDIR}/${A} || die 217 tar -mxf ${DISTDIR}/${A} || die
215 eend $? 218 eend $?
216 219
217 mkdir "${S}" 220 mkdir "${S}"
218 pushd "${S}" 221 pushd "${S}" &>/dev/null
219 222
220 ebegin "Unpacking data.tar.gz" 223 ebegin "Unpacking data.tar.gz"
221 tar -mxf "${my_WORKDIR}"/data.tar.gz || die 224 tar -mxf "${my_WORKDIR}"/data.tar.gz || die
222 eend $? 225 eend $?
226 popd &>/dev/null
223 else 227 else
224 [[ -n ${A} ]] && unpack ${A} 228 [[ -n ${A} ]] && unpack ${A}
225 fi 229 fi
226} 230}
227 231
235# @FUNCTION: each_fakegem_test 239# @FUNCTION: each_fakegem_test
236# @DESCRIPTION: 240# @DESCRIPTION:
237# Run tests for the package for each ruby target if the test task is defined. 241# Run tests for the package for each ruby target if the test task is defined.
238each_fakegem_test() { 242each_fakegem_test() {
239 local rubyflags= 243 local rubyflags=
240
241 if [[ ${RUBY_FAKEGEM_TASK_TEST} != "" ]]; then
242 ${RUBY} ${rubyflags} -S rake ${RUBY_FAKEGEM_TASK_TEST} || die "tests failed" 244 ${RUBY} ${rubyflags} -S rake ${RUBY_FAKEGEM_TASK_TEST} || die "tests failed"
243 else
244 echo "No test task defined, skipping tests."
245 fi
246} 245}
247 246
247if [[ ${RUBY_FAKEGEM_TASK_TEST} != "" ]]; then
248# @FUNCTION: each_ruby_test 248 # @FUNCTION: each_ruby_test
249# @DESCRIPTION: 249 # @DESCRIPTION:
250# Run the tests for this package. 250 # Run the tests for this package.
251each_ruby_test() { 251 each_ruby_test() {
252 each_fakegem_test 252 each_fakegem_test
253} 253 }
254fi
254 255
255# @FUNCTION: each_fakegem_install 256# @FUNCTION: each_fakegem_install
256# @DESCRIPTION: 257# @DESCRIPTION:
257# Install the package for each ruby target. 258# Install the package for each ruby target.
258each_fakegem_install() { 259each_fakegem_install() {
259 ruby_fakegem_genspec 260 ruby_fakegem_genspec
260 261
261 local _gemlibdirs= 262 local _gemlibdirs="${RUBY_FAKEGEM_EXTRAINSTALL}"
262 for directory in bin lib ${RUBY_FAKEGEM_EXTRAINSTALL}; do 263 for directory in bin lib; do
263 [[ -d ${directory} ]] && _gemlibdirs="${_gemlibdirs} ${directory}" 264 [[ -d ${directory} ]] && _gemlibdirs="${_gemlibdirs} ${directory}"
264 done 265 done
265 266
266 [[ -n ${_gemlibdirs} ]] && \ 267 [[ -n ${_gemlibdirs} ]] && \
267 ruby_fakegem_doins -r ${_gemlibdirs} 268 ruby_fakegem_doins -r ${_gemlibdirs}
278# @DESCRIPTION: 279# @DESCRIPTION:
279# Install files common to all ruby targets. 280# Install files common to all ruby targets.
280all_fakegem_install() { 281all_fakegem_install() {
281 if [[ -n ${RUBY_FAKEGEM_DOCDIR} ]] && [[ ${RUBY_FAKEGEM_TASK_DOC} != "" ]] && use doc; then 282 if [[ -n ${RUBY_FAKEGEM_DOCDIR} ]] && [[ ${RUBY_FAKEGEM_TASK_DOC} != "" ]] && use doc; then
282 for dir in ${RUBY_FAKEGEM_DOCDIR}; do 283 for dir in ${RUBY_FAKEGEM_DOCDIR}; do
283 pushd ${dir} 284 pushd ${dir} &>/dev/null
284 dohtml -r * || die "failed to install documentation" 285 dohtml -r * || die "failed to install documentation"
285 popd 286 popd &>/dev/null
286 done 287 done
287 fi 288 fi
288 289
289 if [[ -n ${RUBY_FAKEGEM_EXTRADOC} ]]; then 290 if [[ -n ${RUBY_FAKEGEM_EXTRADOC} ]]; then
290 dodoc ${RUBY_FAKEGEM_EXTRADOC} || die "failed to install further documentation" 291 dodoc ${RUBY_FAKEGEM_EXTRADOC} || die "failed to install further documentation"
294 # same binaries, or something is wrong anyway, so... 295 # same binaries, or something is wrong anyway, so...
295 if [[ -n ${RUBY_FAKEGEM_BINWRAP} ]]; then 296 if [[ -n ${RUBY_FAKEGEM_BINWRAP} ]]; then
296 local bindir=$(find "${D}" -type d -path "*/gems/${RUBY_FAKEGEM_NAME}-${RUBY_FAKEGEM_VERSION}/bin" -print -quit) 297 local bindir=$(find "${D}" -type d -path "*/gems/${RUBY_FAKEGEM_NAME}-${RUBY_FAKEGEM_VERSION}/bin" -print -quit)
297 298
298 if [[ -d "${bindir}" ]]; then 299 if [[ -d "${bindir}" ]]; then
299 pushd "${bindir}" 300 pushd "${bindir}" &>/dev/null
300 local binaries=$(eval ls ${RUBY_FAKEGEM_BINWRAP}) 301 local binaries=$(eval ls ${RUBY_FAKEGEM_BINWRAP})
301 for binary in $binaries; do 302 for binary in $binaries; do
302 ruby_fakegem_binwrapper $binary 303 ruby_fakegem_binwrapper $binary
303 done 304 done
304 popd 305 popd &>/dev/null
305 fi 306 fi
306 fi 307 fi
307} 308}
308 309
309# @FUNCTION: all_ruby_install 310# @FUNCTION: all_ruby_install

Legend:
Removed from v.1.10  
changed lines
  Added in v.1.14

  ViewVC Help
Powered by ViewVC 1.1.20