summaryrefslogtreecommitdiff
path: root/eclass/ruby-fakegem.eclass
diff options
context:
space:
mode:
Diffstat (limited to 'eclass/ruby-fakegem.eclass')
-rw-r--r--eclass/ruby-fakegem.eclass101
1 files changed, 44 insertions, 57 deletions
diff --git a/eclass/ruby-fakegem.eclass b/eclass/ruby-fakegem.eclass
index 40ff76ce900e..eb6257a50cf9 100644
--- a/eclass/ruby-fakegem.eclass
+++ b/eclass/ruby-fakegem.eclass
@@ -1,4 +1,4 @@
-# Copyright 1999-2023 Gentoo Authors
+# Copyright 1999-2024 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
# @ECLASS: ruby-fakegem.eclass
@@ -8,13 +8,21 @@
# Author: Diego E. Pettenò <flameeyes@gentoo.org>
# Author: Alex Legler <a3li@gentoo.org>
# Author: Hans de Graaff <graaff@gentoo.org>
-# @SUPPORTED_EAPIS: 5 6 7 8
+# @SUPPORTED_EAPIS: 7 8
# @PROVIDES: ruby-ng
# @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.
+if [[ -z ${_RUBY_FAKEGEM_ECLASS} ]]; then
+_RUBY_FAKEGEM_ECLASS=1
+
+case ${EAPI} in
+ 7|8) ;;
+ *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
+esac
+
inherit ruby-ng
# @ECLASS_VARIABLE: RUBY_FAKEGEM_NAME
@@ -61,14 +69,7 @@ RUBY_FAKEGEM_TASK_TEST="${RUBY_FAKEGEM_TASK_TEST-test}"
# - rdoc (calls `rdoc-2`, adds dev-ruby/rdoc to the dependencies);
# - yard (calls `yard`, adds dev-ruby/yard to the dependencies);
# - none
-case ${EAPI} in
- 5|6)
- RUBY_FAKEGEM_RECIPE_DOC="${RUBY_FAKEGEM_RECIPE_DOC-rake}"
- ;;
- *)
- RUBY_FAKEGEM_RECIPE_DOC="${RUBY_FAKEGEM_RECIPE_DOC-rdoc}"
- ;;
-esac
+: "${RUBY_FAKEGEM_RECIPE_DOC=rdoc}"
# @ECLASS_VARIABLE: RUBY_FAKEGEM_DOCDIR
# @DEFAULT_UNSET
@@ -138,11 +139,6 @@ RUBY_FAKEGEM_BINDIR="${RUBY_FAKEGEM_BINDIR-bin}"
# legacy way to install extensions for a long time.
RUBY_FAKEGEM_EXTENSION_LIBDIR="${RUBY_FAKEGEM_EXTENSION_LIBDIR-lib}"
-case ${EAPI} in
- 5|6|7|8) ;;
- *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
-esac
-
RUBY_FAKEGEM_SUFFIX="${RUBY_FAKEGEM_SUFFIX:-}"
@@ -211,13 +207,7 @@ SRC_URI="https://rubygems.org/gems/${RUBY_FAKEGEM_NAME}-${RUBY_FAKEGEM_VERSION}$
ruby_add_bdepend "virtual/rubygems"
ruby_add_rdepend virtual/rubygems
-case ${EAPI} in
- 5|6)
- ;;
- *)
- ruby_add_depend virtual/rubygems
- ;;
-esac
+ruby_add_depend virtual/rubygems
# Many (but not all) extensions use pkgconfig in src_configure.
if [[ ${#RUBY_FAKEGEM_EXTENSIONS[@]} -gt 0 ]]; then
@@ -230,7 +220,7 @@ fi
# This function returns the gems data directory for the ruby
# implementation in question.
ruby_fakegem_gemsdir() {
- debug-print-function ${FUNCNAME} "${@}"
+ debug-print-function ${FUNCNAME} "$@"
local _gemsitedir=$(ruby_rbconfig_value 'sitelibdir')
_gemsitedir=${_gemsitedir//site_ruby/gems}
@@ -249,12 +239,12 @@ ruby_fakegem_gemsdir() {
# @DESCRIPTION:
# Installs the specified file(s) into the gems directory.
ruby_fakegem_doins() {
- debug-print-function ${FUNCNAME} "${@}"
+ debug-print-function ${FUNCNAME} "$@"
(
insinto $(ruby_fakegem_gemsdir)/gems/${RUBY_FAKEGEM_NAME}-${RUBY_FAKEGEM_VERSION}
doins "$@"
- ) || die "failed $0 $@"
+ )
}
# @FUNCTION: ruby_fakegem_newins
@@ -262,7 +252,7 @@ ruby_fakegem_doins() {
# @DESCRIPTION:
# Installs the specified file into the gems directory using the provided filename.
ruby_fakegem_newins() {
- debug-print-function ${FUNCNAME} "${@}"
+ debug-print-function ${FUNCNAME} "$@"
(
# Since newins does not accept full paths but just basenames
@@ -274,7 +264,7 @@ ruby_fakegem_newins() {
insinto $(ruby_fakegem_gemsdir)/gems/${RUBY_FAKEGEM_NAME}-${RUBY_FAKEGEM_VERSION}${newdirname}
newins "$1" ${newbasename}
- ) || die "failed $0 $@"
+ )
}
# @FUNCTION: ruby_fakegem_install_gemspec
@@ -283,7 +273,7 @@ ruby_fakegem_newins() {
# by the RUBY_FAKEGEM_GEMSPEC variable, or generate one using
# ruby_fakegem_genspec.
ruby_fakegem_install_gemspec() {
- debug-print-function ${FUNCNAME} "${@}"
+ debug-print-function ${FUNCNAME} "$@"
local gemspec="${T}"/${RUBY_FAKEGEM_NAME}-${_ruby_implementation}
@@ -299,7 +289,7 @@ ruby_fakegem_install_gemspec() {
ruby_fakegem_genspec ${gemspec}
fi
fi
- ) || die "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."
@@ -312,7 +302,7 @@ ruby_fakegem_install_gemspec() {
# 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() {
- debug-print-function ${FUNCNAME} "${@}"
+ debug-print-function ${FUNCNAME} "$@"
${RUBY} --disable=did_you_mean -e "puts eval(File::open('$1').read).to_ruby" > $2
}
@@ -324,7 +314,7 @@ ruby_fakegem_gemspec_gemspec() {
# the metadata distributed by the gem itself. This is similar to how
# rubygems creates an installation from a .gem file.
ruby_fakegem_metadata_gemspec() {
- debug-print-function ${FUNCNAME} "${@}"
+ debug-print-function ${FUNCNAME} "$@"
${RUBY} --disable=did_you_mean -r yaml -e "puts Gem::Specification.from_yaml(File::open('$1', :encoding => 'UTF-8').read).to_ruby" > $2
}
@@ -343,16 +333,11 @@ ruby_fakegem_metadata_gemspec() {
# 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() {
- debug-print-function ${FUNCNAME} "${@}"
-
- case ${EAPI} in
- 5|6) ;;
- *)
- eqawarn "Generating generic fallback gemspec *without* dependencies"
- eqawarn "This will only work when there are no runtime dependencies"
- eqawarn "Set RUBY_FAKEGEM_GEMSPEC to generate a proper specifications file"
- ;;
- esac
+ debug-print-function ${FUNCNAME} "$@"
+
+ eqawarn "Generating generic fallback gemspec *without* dependencies"
+ eqawarn "This will only work when there are no runtime dependencies"
+ eqawarn "Set RUBY_FAKEGEM_GEMSPEC to generate a proper specifications file"
local required_paths="'lib'"
for path in ${RUBY_FAKEGEM_REQUIRE_PATHS}; do
@@ -384,7 +369,7 @@ EOF
# to inject additional ruby code into the wrapper. This may be useful to
# e.g. force a specific version using the gem command.
ruby_fakegem_binwrapper() {
- debug-print-function ${FUNCNAME} "${@}"
+ debug-print-function ${FUNCNAME} "$@"
(
local gembinary=$1
@@ -430,14 +415,14 @@ EOF
exeinto ${binpath:-/usr/bin}
newexe "${T}"/gembin-wrapper-${gembinary} $(basename $newbinary)
- ) || die "Unable to create fakegem wrapper"
+ )
}
# @FUNCTION: each_fakegem_configure
# @DESCRIPTION:
# Configure extensions defined in RUBY_FAKEGEM_EXTENSIONS, if any.
each_fakegem_configure() {
- debug-print-function ${FUNCNAME} "${@}"
+ debug-print-function ${FUNCNAME} "$@"
tc-export PKG_CONFIG
for extension in "${RUBY_FAKEGEM_EXTENSIONS[@]}" ; do
@@ -449,7 +434,7 @@ each_fakegem_configure() {
# @DESCRIPTION:
# Run each_fakegem_configure for each ruby target
each_ruby_configure() {
- debug-print-function ${FUNCNAME} "${@}"
+ debug-print-function ${FUNCNAME} "$@"
each_fakegem_configure
}
@@ -459,7 +444,7 @@ each_ruby_configure() {
# Build documentation for the package if indicated by the doc USE flag
# and if there is a documentation task defined.
all_fakegem_compile() {
- debug-print-function ${FUNCNAME} "${@}"
+ debug-print-function ${FUNCNAME} "$@"
if [[ -n ${RUBY_FAKEGEM_DOCDIR} ]] && use doc; then
case ${RUBY_FAKEGEM_RECIPE_DOC} in
@@ -481,7 +466,7 @@ all_fakegem_compile() {
# @DESCRIPTION:
# Compile extensions defined in RUBY_FAKEGEM_EXTENSIONS, if any.
each_fakegem_compile() {
- debug-print-function ${FUNCNAME} "${@}"
+ debug-print-function ${FUNCNAME} "$@"
for extension in "${RUBY_FAKEGEM_EXTENSIONS[@]}" ; do
emake V=1 -C ${extension%/*}
@@ -494,7 +479,7 @@ each_fakegem_compile() {
# @DESCRIPTION:
# Run each_fakegem_compile for each ruby target
each_ruby_compile() {
- debug-print-function ${FUNCNAME} "${@}"
+ debug-print-function ${FUNCNAME} "$@"
each_fakegem_compile
}
@@ -503,7 +488,7 @@ each_ruby_compile() {
# @DESCRIPTION:
# Unpack the source archive, including support for unpacking gems.
all_ruby_unpack() {
- debug-print-function ${FUNCNAME} "${@}"
+ debug-print-function ${FUNCNAME} "$@"
# Special support for extracting .gem files; the file need to be
# extracted twice and the mtime from the archive _has_ to be
@@ -548,7 +533,7 @@ all_ruby_unpack() {
# @DESCRIPTION:
# Compile the package.
all_ruby_compile() {
- debug-print-function ${FUNCNAME} "${@}"
+ debug-print-function ${FUNCNAME} "$@"
all_fakegem_compile
}
@@ -557,7 +542,7 @@ all_ruby_compile() {
# @DESCRIPTION:
# Run tests for the package for each ruby target if the test task is defined.
each_fakegem_test() {
- debug-print-function ${FUNCNAME} "${@}"
+ debug-print-function ${FUNCNAME} "$@"
case ${RUBY_FAKEGEM_RECIPE_TEST} in
rake)
@@ -599,7 +584,7 @@ fi
# installed. This is normally done as part of the extension
# installation, but may be useful when we handle extensions manually.
ruby_fakegem_extensions_installed() {
- debug-print-function ${FUNCNAME} "${@}"
+ debug-print-function ${FUNCNAME} "$@"
mkdir -p "${ED}$(ruby_fakegem_extensionsdir)" || die
touch "${ED}$(ruby_fakegem_extensionsdir)/gem.build_complete" || die
@@ -610,7 +595,7 @@ ruby_fakegem_extensions_installed() {
# The directory where rubygems expects extensions for this package
# version.
ruby_fakegem_extensionsdir() {
- debug-print-function ${FUNCNAME} "${@}"
+ debug-print-function ${FUNCNAME} "$@"
# Using formula from ruby src/lib/rubygems/basic_specification.
extensions_dir=$(${RUBY} --disable=did_you_mean -e "puts File.join('extensions', Gem::Platform.local.to_s, Gem.extension_api_version)")
@@ -622,7 +607,7 @@ ruby_fakegem_extensionsdir() {
# @DESCRIPTION:
# Install the package for each ruby target.
each_fakegem_install() {
- debug-print-function ${FUNCNAME} "${@}"
+ debug-print-function ${FUNCNAME} "$@"
ruby_fakegem_install_gemspec
@@ -649,7 +634,7 @@ each_fakegem_install() {
# @DESCRIPTION:
# Install the package for each target.
each_ruby_install() {
- debug-print-function ${FUNCNAME} "${@}"
+ debug-print-function ${FUNCNAME} "$@"
each_fakegem_install
}
@@ -658,7 +643,7 @@ each_ruby_install() {
# @DESCRIPTION:
# Install files common to all ruby targets.
all_fakegem_install() {
- debug-print-function ${FUNCNAME} "${@}"
+ debug-print-function ${FUNCNAME} "$@"
if [[ -n ${RUBY_FAKEGEM_DOCDIR} ]] && use doc; then
for dir in ${RUBY_FAKEGEM_DOCDIR}; do
@@ -693,7 +678,9 @@ all_fakegem_install() {
# @DESCRIPTION:
# Install files common to all ruby targets.
all_ruby_install() {
- debug-print-function ${FUNCNAME} "${@}"
+ debug-print-function ${FUNCNAME} "$@"
all_fakegem_install
}
+
+fi