# 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.8 2009/12/26 17:06:02 flameeyes Exp $ # # @ECLASS: ruby-fakegem.eclass # @MAINTAINER: # Ruby herd # # Author: Diego E. Pettenò # # Author: Alex Legler # # @BLURB: An eclass for installing Ruby packages to behave like RubyGems. # @DESCRIPTION: # This eclass allows to install arbitrary Ruby libraries (including Gems), # providing integration into the RubyGems system even for "regular" packages. # inherit ruby-ng # @ECLASS-VARIABLE: RUBY_FAKEGEM_NAME # @DESCRIPTION: # Sets the Gem name for the generated fake gemspec. # RUBY_FAKEGEM_NAME="${PN}" # @ECLASS-VARIABLE: RUBY_FAKEGEM_VERSION # @DESCRIPTION: # Sets the Gem version for the generated fake gemspec. # RUBY_FAKEGEM_VERSION="${PV}" # @ECLASS-VARIABLE: RUBY_FAKEGEM_TASK_DOC # @DESCRIPTION: # Specify the rake(1) task to run to generate documentation. # RUBY_FAKEGEM_TASK_DOC="rdoc" # @ECLASS-VARIABLE: RUBY_FAKEGEM_TASK_TEST # @DESCRIPTION: # Specify the rake(1) task used for executing tests. # RUBY_FAKEGEM_TASK_TEST="test" # @ECLASS-VARIABLE: RUBY_FAKEGEM_DOCDIR # @DESCRIPTION: # Specify the directory under which the documentation is built; # if empty no documentation will be installed automatically. # RUBY_FAKEGEM_DOCDIR="" # @ECLASS-VARIABLE: RUBY_FAKEGEM_EXTRADOC # @DESCRIPTION: # Extra documentation to install (readme, changelogs, …). # RUBY_FAKEGEM_EXTRADOC="" # @ECLASS-VARIABLE: RUBY_FAKEGEM_BINWRAP # @DESCRIPTION: # Binaries to wrap around (relative to the bin/ directory) # RUBY_FAKEGEM_BINWRAP="*" # @ECLASS-VARIABLE: RUBY_FAKEGEM_REQUIRE_PATHS # @DESCRIPTION: # Extra require paths (beside lib) to add to the specification # RUBY_FAKEGEM_BINWRAP="" RUBY_FAKEGEM_NAME="${RUBY_FAKEGEM_NAME:-${PN}}" RUBY_FAKEGEM_VERSION="${RUBY_FAKEGEM_VERSION:-${PV}}" RUBY_FAKEGEM_TASK_DOC="${RUBY_FAKEGEM_TASK_DOC-rdoc}" RUBY_FAKEGEM_TASK_TEST="${RUBY_FAKEGEM_TASK_TEST-test}" RUBY_FAKEGEM_BINWRAP="${RUBY_FAKEGEM_BINWRAP-*}" if [[ ${RUBY_FAKEGEM_TASK_DOC} != "" ]]; then IUSE="$IUSE doc" ruby_add_bdepend doc "dev-ruby/rake" fi if [[ ${RUBY_FAKEGEM_TASK_TEST} != "" ]]; then IUSE="$IUSE test" ruby_add_bdepend test "dev-ruby/rake" fi SRC_URI="mirror://rubygems/${RUBY_FAKEGEM_NAME}-${RUBY_FAKEGEM_VERSION}.gem" ruby_add_rdepend virtual/rubygems # @FUNCTION: ruby_fakegem_gemsdir # @RETURN: Returns the gem data directory # @DESCRIPTION: # This function returns the gems data directory for the ruby # implementation in question. ruby_fakegem_gemsdir() { local _gemsitedir=$(${RUBY} -r rbconfig -e 'print Config::CONFIG["sitelibdir"]' | sed -e 's:site_ruby:gems:') [[ -z ${_gemsitedir} ]] && { eerror "Unable to find the gems dir" die "Unable to find the gems dir" } echo "${_gemsitedir}" } # @FUNCTION: ruby_fakegem_doins # @USAGE: file [file...] # @DESCRIPTION: # Installs the specified file(s) into the gems directory. ruby_fakegem_doins() { ( insinto $(ruby_fakegem_gemsdir)/gems/${RUBY_FAKEGEM_NAME}-${RUBY_FAKEGEM_VERSION} doins "$@" ) || die "failed $0 $@" } # @FUNCTION: ruby_fakegem_newsins() # @USAGE: file filename # @DESCRIPTION: # Installs the specified file into the gems directory using the provided filename. ruby_fakegem_newins() { ( # Since newins does not accept full paths but just basenames # for the target file, we want to extend it here. local newdirname=/$(dirname "$2") [[ ${newdirname} == "/." ]] && newdirname= local newbasename=$(basename "$2") insinto $(ruby_fakegem_gemsdir)/gems/${RUBY_FAKEGEM_NAME}-${RUBY_FAKEGEM_VERSION}${newdirname} newins "$1" ${newbasename} ) || die "failed $0 $@" } # @FUNCTION: ruby_fakegem_genspec # @DESCRIPTION: # Generates a gemspec for the package and places it into the "specifications" # directory of RubyGems. # 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 # 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. cat - > "${T}"/${RUBY_FAKEGEM_NAME}-${_ruby_implementation} < "${T}"/gembin-wrapper-${gembinary} <