diff options
author | Hans de Graaff <graaff@gentoo.org> | 2010-12-28 12:07:15 +0000 |
---|---|---|
committer | Hans de Graaff <graaff@gentoo.org> | 2010-12-28 12:07:15 +0000 |
commit | 01f137973a872a7e003cb575e5412bb814e66aaa (patch) | |
tree | a156ddcef18ae70caf0944856a22ded0ca2594d0 /eclass | |
parent | app-cdr/cdrtools conflict must be also in RDEPEND (diff) | |
download | gentoo-2-01f137973a872a7e003cb575e5412bb814e66aaa.tar.gz gentoo-2-01f137973a872a7e003cb575e5412bb814e66aaa.tar.bz2 gentoo-2-01f137973a872a7e003cb575e5412bb814e66aaa.zip |
Try to install the normal upstream gemspec file from either the gem metadata or the source gemspec file and use our own version only as a fallback.
Diffstat (limited to 'eclass')
-rw-r--r-- | eclass/ruby-fakegem.eclass | 95 |
1 files changed, 76 insertions, 19 deletions
diff --git a/eclass/ruby-fakegem.eclass b/eclass/ruby-fakegem.eclass index 5e92cbc022b5..e1ef05d317cf 100644 --- a/eclass/ruby-fakegem.eclass +++ b/eclass/ruby-fakegem.eclass @@ -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-fakegem.eclass,v 1.26 2010/12/18 09:57:24 graaff Exp $ +# $Header: /var/cvsroot/gentoo-x86/eclass/ruby-fakegem.eclass,v 1.27 2010/12/28 12:07:15 graaff Exp $ # # @ECLASS: ruby-fakegem.eclass # @MAINTAINER: @@ -59,6 +59,11 @@ inherit ruby-ng # Extra require paths (beside lib) to add to the specification # RUBY_FAKEGEM_REQUIRE_PATHS="" +# @ECLASS-VARIABLE: RUBY_FAKEGEM_GEMSPEC +# @DESCRIPTION: +# Filename of .gemspec file to install instead of generating a generic one. +# RUBY_FAKEGEM_GEMSPEC="" + RUBY_FAKEGEM_NAME="${RUBY_FAKEGEM_NAME:-${PN}}" RUBY_FAKEGEM_VERSION="${RUBY_FAKEGEM_VERSION:-${PV/_pre/.pre}}" RUBY_FAKEGEM_SUFFIX="${RUBY_FAKEGEM_SUFFIX:-}" @@ -84,6 +89,7 @@ fi SRC_URI="mirror://rubygems/${RUBY_FAKEGEM_NAME}-${RUBY_FAKEGEM_VERSION}${RUBY_FAKEGEM_SUFFIX:+-${RUBY_FAKEGEM_SUFFIX}}.gem" +ruby_add_bdepend dev-ruby/rubygems ruby_add_rdepend dev-ruby/rubygems # @FUNCTION: ruby_fakegem_gemsdir @@ -135,28 +141,78 @@ ruby_fakegem_newins() { ) || die "failed $0 $@" } +# @FUNCTION: ruby_fakegem_install_gemspec +# @DESCRIPTION: +# Install a .gemspec file for this package. Either use the file indicated +# by the RUBY_FAKEGEM_GEMSPEC variable, or generate one using +# ruby_fakegem_genspec. +ruby_fakegem_install_gemspec() { + local gemspec="${T}"/${RUBY_FAKEGEM_NAME}-${_ruby_implementation} + + ( + if [[ ${RUBY_FAKEGEM_GEMSPEC} != "" ]]; then + ruby_fakegem_gemspec_gemspec ${RUBY_FAKEGEM_GEMSPEC} ${gemspec} + else + local metadata="${WORKDIR}"/${_ruby_implementation}/metadata + + if [[ -e ${metadata} ]]; then + ruby_fakegem_metadata_gemspec ${metadata} ${gemspec} + else + ruby_fakegem_genspec ${gemspec} + fi + fi + ) || "Unable to generate gemspec file." + + insinto $(ruby_fakegem_gemsdir)/specifications + newins ${gemspec} ${RUBY_FAKEGEM_NAME}-${RUBY_FAKEGEM_VERSION}.gemspec || die "Unable to install gemspec file." +} + +# @FUNCTION: ruby_fakegem_gemspec_gemspec +# @USAGE: gemspec-input gemspec-output +# @DESCRIPTION: +# Generates an installable version of the specification indicated by +# RUBY_FAKEGEM_GEMSPEC. This file is eval'ed to produce a final specification +# in a way similar to packaging the gemspec file. +ruby_fakegem_gemspec_gemspec() { + ${RUBY} -e "puts eval(File::open('$1').read).to_ruby" > $2 +} + +# @FUNCTION: ruby_fakegem_metadata_gemspec +# @USAGE: gemspec-metadata gemspec-output +# @DESCRIPTION: +# Generates an installable version of the specification indicated by +# the metadata distributed by the gem itself. This is similar to how +# rubygems creates an installation from a .gem file. +ruby_fakegem_metadata_gemspec() { + ${RUBY} -r yaml -e "puts Gem::Specification.from_yaml(File::open('$1').read).to_ruby" > $2 +} + # @FUNCTION: ruby_fakegem_genspec +# @USAGE: output-gemspec # @DESCRIPTION: # Generates a gemspec for the package and places it into the "specifications" # directory of RubyGems. +# If the metadata normally distributed with a gem is present then that is +# used to generate the gemspec file. +# +# As a fallback we can generate our own version. # In the gemspec, the following values are set: name, version, summary, # homepage, and require_paths=["lib"]. # See RUBY_FAKEGEM_NAME and RUBY_FAKEGEM_VERSION for setting name and version. # See RUBY_FAKEGEM_REQUIRE_PATHS for setting extra require paths. ruby_fakegem_genspec() { - ( - local required_paths="'lib'" - for path in ${RUBY_FAKEGEM_REQUIRE_PATHS}; do - required_paths="${required_paths}, '${path}'" - done + local required_paths="'lib'" + for path in ${RUBY_FAKEGEM_REQUIRE_PATHS}; do + required_paths="${required_paths}, '${path}'" + done - # We use the _ruby_implementation variable to avoid having stray - # copies with different implementations; while for now we're using - # the same exact content, we might have differences in the future, - # so better taking this into consideration. - local quoted_description=${DESCRIPTION//\"/\\\"} - cat - > "${T}"/${RUBY_FAKEGEM_NAME}-${_ruby_implementation} <<EOF -# generated by ruby-fakegem.eclass $Revision: 1.26 $ + # We use the _ruby_implementation variable to avoid having stray + # copies with different implementations; while for now we're using + # the same exact content, we might have differences in the future, + # so better taking this into consideration. + local quoted_description=${DESCRIPTION//\"/\\\"} + cat - > $1 <<EOF +# generated by ruby-fakegem.eclass $Revision: 1.27 $ Gem::Specification.new do |s| s.name = "${RUBY_FAKEGEM_NAME}" s.version = "${RUBY_FAKEGEM_VERSION}" @@ -165,10 +221,6 @@ Gem::Specification.new do |s| s.require_paths = [${required_paths}] end EOF - - insinto $(ruby_fakegem_gemsdir)/specifications - newins "${T}"/${RUBY_FAKEGEM_NAME}-${_ruby_implementation} ${RUBY_FAKEGEM_NAME}-${RUBY_FAKEGEM_VERSION}.gemspec - ) || die "Unable to install fake gemspec" } # @FUNCTION: ruby_fakegem_binwrapper @@ -210,7 +262,7 @@ ruby_fakegem_binwrapper() { #!${rubycmd} # This is a simplified version of the RubyGems wrapper # -# Generated by ruby-fakegem.eclass $Revision: 1.26 $ +# Generated by ruby-fakegem.eclass $Revision: 1.27 $ require 'rubygems' @@ -251,12 +303,17 @@ all_ruby_unpack() { tar -mxf ${DISTDIR}/${archive} || die eend $? + ebegin "Uncompressing metadata" + gunzip metadata.gz || die + eend $? + mkdir "${S}" pushd "${S}" &>/dev/null ebegin "Unpacking data.tar.gz" tar -mxf "${my_WORKDIR}"/data.tar.gz || die eend $? + popd &>/dev/null ;; *.patch.bz2) @@ -302,7 +359,7 @@ fi # @DESCRIPTION: # Install the package for each ruby target. each_fakegem_install() { - ruby_fakegem_genspec + ruby_fakegem_install_gemspec local _gemlibdirs="${RUBY_FAKEGEM_EXTRAINSTALL}" for directory in bin lib; do |