summaryrefslogtreecommitdiff
path: root/eclass
diff options
context:
space:
mode:
authorV3n3RiX <venerix@koprulu.sector>2024-07-15 12:27:33 +0100
committerV3n3RiX <venerix@koprulu.sector>2024-07-15 12:27:33 +0100
commit868fd5dc8aab84930cfaa5252b8be06b35552765 (patch)
tree0c0cebf818c30c6f871f00ce1e7599775a7e561c /eclass
parentf7adcd4ee556b2c3a420239c13fb74113d791f6a (diff)
gentoo auto-resync : 15:07:2024 - 12:27:33
Diffstat (limited to 'eclass')
-rw-r--r--eclass/Manifest.gzbin39235 -> 39549 bytes
-rw-r--r--eclass/gnome.org.eclass19
-rw-r--r--eclass/gnome2-utils.eclass97
-rw-r--r--eclass/gnome2.eclass38
-rw-r--r--eclass/rebar-utils.eclass160
-rw-r--r--eclass/rebar.eclass112
-rw-r--r--eclass/rebar3.eclass194
7 files changed, 407 insertions, 213 deletions
diff --git a/eclass/Manifest.gz b/eclass/Manifest.gz
index 1c02ac319a8f..9e0230d8dc84 100644
--- a/eclass/Manifest.gz
+++ b/eclass/Manifest.gz
Binary files differ
diff --git a/eclass/gnome.org.eclass b/eclass/gnome.org.eclass
index 760dc2ba0b66..70884edefef7 100644
--- a/eclass/gnome.org.eclass
+++ b/eclass/gnome.org.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: gnome.org.eclass
@@ -7,22 +7,19 @@
# @AUTHOR:
# Authors: Spidler <spidler@gentoo.org> with help of carparski.
# eclass variable additions and documentation: Gilles Dartiguelongue <eva@gentoo.org>
-# @SUPPORTED_EAPIS: 5 6 7 8
+# @SUPPORTED_EAPIS: 7 8
# @BLURB: Helper eclass for gnome.org hosted archives
# @DESCRIPTION:
# Provide a default SRC_URI for tarball hosted on gnome.org mirrors.
case ${EAPI} in
- 5|6|7|8) ;;
+ 7|8) ;;
*) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
esac
if [[ -z ${_GNOME_ORG_ECLASS} ]] ; then
_GNOME_ORG_ECLASS=1
-# versionator inherit kept for older EAPIs due to ebuilds (potentially) relying on it
-[[ ${EAPI} == [56] ]] && inherit eapi7-ver versionator
-
# @ECLASS_VARIABLE: GNOME_TARBALL_SUFFIX
# @PRE_INHERIT
# @DESCRIPTION:
@@ -33,19 +30,13 @@ _GNOME_ORG_ECLASS=1
# Even though xz-utils are in @system, they must still be added to BDEPEND; see
# https://archives.gentoo.org/gentoo-dev/msg_a0d4833eb314d1be5d5802a3b710e0a4.xml
-if [[ ${GNOME_TARBALL_SUFFIX} == "xz" ]]; then
- if [[ ${EAPI} != [56] ]]; then
- BDEPEND="app-arch/xz-utils"
- else
- DEPEND="app-arch/xz-utils"
- fi
-fi
+[[ ${GNOME_TARBALL_SUFFIX} == "xz" ]] && BDEPEND="app-arch/xz-utils"
# @ECLASS_VARIABLE: GNOME_ORG_MODULE
# @DESCRIPTION:
# Name of the module as hosted on gnome.org mirrors.
# Leave unset if package name matches module name.
-: "${GNOME_ORG_MODULE:=$PN}"
+: "${GNOME_ORG_MODULE:=${PN}}"
# @ECLASS_VARIABLE: GNOME_ORG_RELEASE
# @INTERNAL
diff --git a/eclass/gnome2-utils.eclass b/eclass/gnome2-utils.eclass
index bbee2a419dfc..dd4014c09bf7 100644
--- a/eclass/gnome2-utils.eclass
+++ b/eclass/gnome2-utils.eclass
@@ -4,7 +4,7 @@
# @ECLASS: gnome2-utils.eclass
# @MAINTAINER:
# gnome@gentoo.org
-# @SUPPORTED_EAPIS: 5 6 7 8
+# @SUPPORTED_EAPIS: 7 8
# @PROVIDES: xdg-utils
# @BLURB: Auxiliary functions commonly used by Gnome packages.
# @DESCRIPTION:
@@ -15,13 +15,12 @@
# * GConf schemas management
# * scrollkeeper (old Gnome help system) management
-[[ ${EAPI} == 5 ]] && inherit multilib
# toolchain-funs.eclass: tc-is-cross-compiler
# xdg-utils.eclass: xdg_environment_reset, xdg_icon_cache_update
inherit toolchain-funcs xdg-utils
case ${EAPI} in
- 5|6|7|8) ;;
+ 7|8) ;;
*) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
esac
@@ -100,7 +99,7 @@ gnome2_environment_reset() {
# Ensure we don't rely on dconf/gconf while building, bug #511946
export GSETTINGS_BACKEND="memory"
- if has ${EAPI} 6 7; then
+ if [[ ${EAPI} == 7 ]]; then
# Try to cover the packages honoring this variable, bug #508124
export GST_INSPECT="$(type -P true)"
@@ -126,7 +125,7 @@ gnome2_gconf_savelist() {
# using gconftool-2.
# This function should be called from pkg_postinst.
gnome2_gconf_install() {
- local updater="${EROOT%/}${GCONFTOOL_BIN}"
+ local updater="${EROOT}${GCONFTOOL_BIN}"
if [[ -z "${GNOME2_ECLASS_SCHEMAS}" ]]; then
debug-print "No GNOME 2 GConf schemas found"
@@ -148,15 +147,15 @@ gnome2_gconf_install() {
# We are ready to install the GCONF Scheme now
unset GCONF_DISABLE_MAKEFILE_SCHEMA_INSTALL
- export GCONF_CONFIG_SOURCE="$("${updater}" --get-default-source | sed "s;:/;:${ROOT%/}/;")"
+ export GCONF_CONFIG_SOURCE="$("${updater}" --get-default-source | sed "s;:/;:${ROOT}/;")"
einfo "Installing GNOME 2 GConf schemas"
local F
for F in ${GNOME2_ECLASS_SCHEMAS}; do
- if [[ -e "${EROOT%/}/${F}" ]]; then
+ if [[ -e "${EROOT}/${F}" ]]; then
debug-print "Installing schema: ${F}"
- "${updater}" --makefile-install-rule "${EROOT%/}/${F}" 1>/dev/null
+ "${updater}" --makefile-install-rule "${EROOT}/${F}" 1>/dev/null
fi
done
@@ -174,7 +173,7 @@ gnome2_gconf_install() {
# Removes schema files previously installed by the current ebuild from Gconf's
# database.
gnome2_gconf_uninstall() {
- local updater="${EROOT%/}${GCONFTOOL_BIN}"
+ local updater="${EROOT}${GCONFTOOL_BIN}"
if [[ -z "${GNOME2_ECLASS_SCHEMAS}" ]]; then
debug-print "No GNOME 2 GConf schemas found"
@@ -194,15 +193,15 @@ gnome2_gconf_uninstall() {
fi
unset GCONF_DISABLE_MAKEFILE_SCHEMA_INSTALL
- export GCONF_CONFIG_SOURCE="$("${updater}" --get-default-source | sed "s;:/;:${ROOT%/}/;")"
+ export GCONF_CONFIG_SOURCE="$("${updater}" --get-default-source | sed "s;:/;:${ROOT}/;")"
einfo "Uninstalling GNOME 2 GConf schemas"
local F
for F in ${GNOME2_ECLASS_SCHEMAS}; do
- if [[ -e "${EROOT%/}/${F}" ]]; then
+ if [[ -e "${EROOT}/${F}" ]]; then
debug-print "Uninstalling gconf schema: ${F}"
- "${updater}" --makefile-uninstall-rule "${EROOT%/}/${F}" 1>/dev/null
+ "${updater}" --makefile-uninstall-rule "${EROOT}/${F}" 1>/dev/null
fi
done
@@ -221,31 +220,29 @@ gnome2_gconf_uninstall() {
# calls to scrollkeeper-update and sandbox violations.
# This function should be called from src_prepare.
gnome2_omf_fix() {
- local omf_makefiles filename
-
- omf_makefiles="$@"
+ local omf_makefiles=( "$@" )
if [[ -f ${S}/omf.make ]] ; then
- omf_makefiles="${omf_makefiles} ${S}/omf.make"
+ omf_makefiles+=( "${S}"/omf.make )
fi
if [[ -f ${S}/gnome-doc-utils.make ]] ; then
- omf_makefiles="${omf_makefiles} ${S}/gnome-doc-utils.make"
+ omf_makefiles+=( "${S}"/gnome-doc-utils.make )
fi
# testing fixing of all makefiles found
# The sort is important to ensure .am is listed before the respective .in for
# maintainer mode regeneration not kicking in due to .am being newer than .in
- for filename in $(find "${S}" -name "Makefile.in" -o -name "Makefile.am" |sort) ; do
- omf_makefiles="${omf_makefiles} ${filename}"
- done
+ local filename
+ while IFS="" read -r filename ; do
+ omf_makefiles+=( "${filename}" )
+ done < <(find "${S}" -name "Makefile.in" -o -name "Makefile.am" | sort)
ebegin "Fixing OMF Makefiles"
- local retval=0
+ local omf retval=0
local fails=( )
-
- for omf in ${omf_makefiles} ; do
+ for omf in "${omf_makefiles[@]}" ; do
sed -i -e 's:scrollkeeper-update:true:' "${omf}"
retval=$?
@@ -253,7 +250,7 @@ gnome2_omf_fix() {
debug-print "updating of ${omf} failed"
# Add to the list of failures
- fails[$(( ${#fails[@]} + 1 ))]=$omf
+ fails+=( "${omf}" )
retval=2
fi
@@ -261,6 +258,7 @@ gnome2_omf_fix() {
eend $retval
+ local f
for f in "${fails[@]}" ; do
eerror "Failed to update OMF Makefile $f"
done
@@ -282,7 +280,7 @@ gnome2_scrollkeeper_savelist() {
# Updates the global scrollkeeper database.
# This function should be called from pkg_postinst and pkg_postrm.
gnome2_scrollkeeper_update() {
- local updater="${EROOT%/}${SCROLLKEEPER_UPDATE_BIN}"
+ local updater="${EROOT}${SCROLLKEEPER_UPDATE_BIN}"
if [[ -z "${GNOME2_ECLASS_SCROLLS}" ]]; then
debug-print "No scroll cache to update"
@@ -303,7 +301,7 @@ gnome2_scrollkeeper_update() {
fi
ebegin "Updating scrollkeeper database ..."
- "${updater}" -q -p "${EROOT%/}${SCROLLKEEPER_DIR}"
+ "${updater}" -q -p "${EROOT}${SCROLLKEEPER_DIR}"
eend $?
}
@@ -324,7 +322,7 @@ gnome2_schemas_savelist() {
# Updates GSettings schemas.
# This function should be called from pkg_postinst and pkg_postrm.
gnome2_schemas_update() {
- local updater="${EROOT%/}${GLIB_COMPILE_SCHEMAS}"
+ local updater="${EROOT}${GLIB_COMPILE_SCHEMAS}"
if tc-is-cross-compiler ; then
ewarn "Updating of GSettings schemas skipped due to cross-compilation."
@@ -340,7 +338,7 @@ gnome2_schemas_update() {
fi
ebegin "Updating GSettings schemas"
- ${updater} --allow-any-name "$@" "${EROOT%/}/usr/share/glib-2.0/schemas" &>/dev/null
+ ${updater} --allow-any-name "$@" "${EROOT}/usr/share/glib-2.0/schemas" &>/dev/null
eend $?
}
@@ -360,8 +358,8 @@ gnome2_gdk_pixbuf_savelist() {
# Updates gdk-pixbuf loader cache if GNOME2_ECLASS_GDK_PIXBUF_LOADERS has some.
# This function should be called from pkg_postinst and pkg_postrm.
gnome2_gdk_pixbuf_update() {
- local updater="${EROOT%/}/usr/bin/${CHOST}-gdk-pixbuf-query-loaders"
- [[ -x ${updater} ]] || updater="${EROOT%/}/usr/bin/gdk-pixbuf-query-loaders"
+ local updater="${EROOT}/usr/bin/${CHOST}-gdk-pixbuf-query-loaders"
+ [[ -x ${updater} ]] || updater="${EROOT}/usr/bin/gdk-pixbuf-query-loaders"
if tc-is-cross-compiler ; then
ewarn "Updating of gdk-pixbuf loader cache skipped due to cross-compilation."
@@ -380,7 +378,7 @@ gnome2_gdk_pixbuf_update() {
local tmp_file=$(mktemp "${T}"/tmp.XXXXXXXXXX) || die "Failed to create temporary file"
${updater} 1> "${tmp_file}" &&
chmod 0644 "${tmp_file}" &&
- cp -f "${tmp_file}" "${EROOT%/}/usr/$(get_libdir)/gdk-pixbuf-2.0/2.10.0/loaders.cache" &&
+ cp -f "${tmp_file}" "${EROOT}/usr/$(get_libdir)/gdk-pixbuf-2.0/2.10.0/loaders.cache" &&
rm "${tmp_file}" # don't replace this with mv, required for SELinux support
eend $?
}
@@ -398,7 +396,7 @@ gnome2_query_immodules_gtk2() {
fi
ebegin "Updating gtk2 input method module cache"
- GTK_IM_MODULE_FILE="${EROOT%/}/usr/$(get_libdir)/gtk-2.0/2.10.0/immodules.cache" \
+ GTK_IM_MODULE_FILE="${EROOT}/usr/$(get_libdir)/gtk-2.0/2.10.0/immodules.cache" \
"${updater}" --update-cache
eend $?
}
@@ -416,7 +414,7 @@ gnome2_query_immodules_gtk3() {
fi
ebegin "Updating gtk3 input method module cache"
- GTK_IM_MODULE_FILE="${EROOT%/}/usr/$(get_libdir)/gtk-3.0/3.0.0/immodules.cache" \
+ GTK_IM_MODULE_FILE="${EROOT}/usr/$(get_libdir)/gtk-3.0/3.0.0/immodules.cache" \
"${updater}" --update-cache
eend $?
}
@@ -426,8 +424,8 @@ gnome2_query_immodules_gtk3() {
# Updates glib's gio modules cache.
# This function should be called from pkg_postinst and pkg_postrm.
gnome2_giomodule_cache_update() {
- local updater="${EROOT%/}/usr/bin/${CHOST}-gio-querymodules"
- [[ -x ${updater} ]] || updater="${EROOT%/}/usr/bin/gio-querymodules"
+ local updater="${EROOT}/usr/bin/${CHOST}-gio-querymodules"
+ [[ -x ${updater} ]] || updater="${EROOT}/usr/bin/gio-querymodules"
if tc-is-cross-compiler ; then
ewarn "Updating of GIO modules cache skipped due to cross-compilation."
@@ -443,7 +441,7 @@ gnome2_giomodule_cache_update() {
fi
ebegin "Updating GIO modules cache"
- ${updater} "${EROOT%/}"/usr/$(get_libdir)/gio/modules
+ ${updater} "${EROOT}"/usr/$(get_libdir)/gio/modules
eend $?
}
@@ -486,30 +484,3 @@ gnome2_disable_deprecation_warning() {
ewarn "Failed to disable deprecation warnings in ${makefile}"
done
}
-
-case ${EAPI} in
-5|6)
-
-# @FUNCTION: gnome2_icon_savelist
-# @DESCRIPTION:
-# Find the icons that are about to be installed and save their location
-# in the GNOME2_ECLASS_ICONS environment variable. This is only
-# necessary for eclass implementations that call
-# gnome2_icon_cache_update conditionally.
-# This function should be called from pkg_preinst.
-gnome2_icon_savelist() {
- pushd "${ED}" > /dev/null || die
- export GNOME2_ECLASS_ICONS=$(find 'usr/share/icons' -maxdepth 1 -mindepth 1 -type d 2> /dev/null)
- popd > /dev/null || die
-}
-
-# @FUNCTION: gnome2_icon_cache_update
-# @DESCRIPTION:
-# Updates Gtk+ icon cache files under /usr/share/icons.
-# Deprecated. Please use xdg_icon_cache_update from xdg-utils.eclass
-gnome2_icon_cache_update() {
- xdg_icon_cache_update
-}
-
-;;
-esac
diff --git a/eclass/gnome2.eclass b/eclass/gnome2.eclass
index 66de2df97f9f..9ef5d92a1c9e 100644
--- a/eclass/gnome2.eclass
+++ b/eclass/gnome2.eclass
@@ -4,7 +4,7 @@
# @ECLASS: gnome2.eclass
# @MAINTAINER:
# gnome@gentoo.org
-# @SUPPORTED_EAPIS: 6 7 8
+# @SUPPORTED_EAPIS: 7 8
# @PROVIDES: gnome2-utils
# @BLURB: Provides phases for Gnome/Gtk+ based packages.
# @DESCRIPTION:
@@ -12,7 +12,7 @@
# GNOME framework. For additional functions, see gnome2-utils.eclass.
case ${EAPI} in
- 6|7|8) ;;
+ 7|8) ;;
*) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
esac
@@ -22,11 +22,9 @@ _GNOME2_ECLASS=1
# @ECLASS_VARIABLE: GNOME2_EAUTORECONF
# @DEFAULT_UNSET
# @DESCRIPTION:
-# Run eautoreconf instead of only elibtoolize
-GNOME2_EAUTORECONF=${GNOME2_EAUTORECONF:-""}
+# Run eautoreconf instead of only elibtoolize if set to "yes".
[[ ${GNOME2_EAUTORECONF} == yes ]] && inherit autotools
-[[ ${EAPI} == 6 ]] && inherit ltprune
inherit libtool gnome.org gnome2-utils xdg
@@ -34,7 +32,6 @@ inherit libtool gnome.org gnome2-utils xdg
# @DEFAULT_UNSET
# @DESCRIPTION:
# Extra options passed to elibtoolize
-ELTCONF=${ELTCONF:-""}
# @ECLASS_VARIABLE: GNOME2_ECLASS_GIO_MODULES
# @INTERNAL
@@ -42,13 +39,10 @@ ELTCONF=${ELTCONF:-""}
# Array containing glib GIO modules
# @ECLASS_VARIABLE: GNOME2_LA_PUNT
+# @DEFAULT_UNSET
# @DESCRIPTION:
-# In EAPI 6, it relies on prune_libtool_files (from ltprune.eclass) for
-# this. Later EAPIs use find ... -delete. Available values for GNOME2_LA_PUNT:
-# - "no": will not clean any .la files
-# - "yes": will run prune_libtool_files --modules
-# - If it is not set, it will run prune_libtool_files
-GNOME2_LA_PUNT=${GNOME2_LA_PUNT:-""}
+# If set to "no", no .la files will be cleaned, otherwise
+# will run "find ... -delete" in src_install.
# @FUNCTION: gnome2_src_prepare
# @DESCRIPTION:
@@ -141,8 +135,7 @@ gnome2_src_install() {
export GCONF_DISABLE_MAKEFILE_SCHEMA_INSTALL="1"
local sk_tmp_dir="/var/lib/scrollkeeper"
- # scrollkeeper-update from rarian doesn't do anything. Then, since eapi6
- # we stop taking care of it
+ # scrollkeeper-update from rarian doesn't do anything.
#
# if this is not present, scrollkeeper-update may segfault and
# create bogus directories in /var/lib/
@@ -150,9 +143,8 @@ gnome2_src_install() {
unset GCONF_DISABLE_MAKEFILE_SCHEMA_INSTALL
- # Handle documentation as 'default' for eapi5, bug #373131
- # Since eapi6 this is handled by default on its own plus MAINTAINERS and HACKING
- # files that are really common in gnome packages (bug #573390)
+ # Install MAINTAINERS and HACKING which are really common
+ # in gnome packages (bug #573390)
local d
for d in HACKING MAINTAINERS; do
[[ -s ${d} ]] && dodoc "${d}"
@@ -170,16 +162,8 @@ gnome2_src_install() {
rm -rf "${ED}/usr/share/applications/mimeinfo.cache" || die
# Delete all .la files
- if has ${EAPI} 6; then
- case "${GNOME2_LA_PUNT}" in
- yes) prune_libtool_files --modules;;
- no) ;;
- *) prune_libtool_files;;
- esac
- else
- if [[ ${GNOME2_LA_PUNT} != 'no' ]]; then
- find "${ED}" -name '*.la' -delete || die
- fi
+ if [[ ${GNOME2_LA_PUNT} != no ]]; then
+ find "${ED}" -type f -name '*.la' -delete || die
fi
}
diff --git a/eclass/rebar-utils.eclass b/eclass/rebar-utils.eclass
new file mode 100644
index 000000000000..5657908eb8e9
--- /dev/null
+++ b/eclass/rebar-utils.eclass
@@ -0,0 +1,160 @@
+# Copyright 1999-2024 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+# @ECLASS: rebar-utils.eclass
+# @MAINTAINER:
+# Florian Schmaus <flow@gentoo.org>
+# @AUTHOR:
+# Amadeusz Żołnowski <aidecoe@gentoo.org>
+# @SUPPORTED_EAPIS: 7 8
+# @BLURB: Auxiliary functions for using dev-util/rebar.
+# @DESCRIPTION:
+# This eclass provides a set of axiliary functions commonly needed
+# when building Erlang/OTP packages with rebar.
+
+case ${EAPI} in
+ 7|8) ;;
+ *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
+esac
+
+if [[ -z ${_REBAR_UTILS_ECLASS} ]]; then
+_REBAR_UTILS_ECLASS=1
+
+# @ECLASS_VARIABLE: REBAR_APP_SRC
+# @DESCRIPTION:
+# Relative path to .app.src description file. Defaults to
+# 'src/${PN}.app.src'.
+: "${REBAR_APP_SRC:=src/${PN}.app.src}"
+
+# @FUNCTION: get_erl_libs
+# @RETURN: the path to Erlang lib directory
+# @DESCRIPTION:
+# Get the full path without EPREFIX to Erlang lib directory.
+get_erl_libs() {
+ echo "/usr/$(get_libdir)/erlang/lib"
+}
+
+# @FUNCTION: _rebar_find_dep
+# @INTERNAL
+# @USAGE: <project_name>
+# @RETURN: 0 success, 1 dependency not found, 2 multiple versions found
+# @DESCRIPTION:
+# Find a Erlang package/project by name in Erlang lib directory. Project
+# directory is usually suffixed with version. It is matched to '<project_name>'
+# or '<project_name>-*'.
+_rebar_find_dep() {
+ local pn="${1}"
+ local p
+ local result
+
+ pushd "${EPREFIX}$(get_erl_libs)" >/dev/null || return 1
+ for p in ${pn} ${pn}-*; do
+ if [[ -d ${p} ]]; then
+ # Ensure there's at most one matching.
+ [[ ${result} ]] && return 2
+ result="${p}"
+ fi
+ done
+ popd >/dev/null || die
+
+ [[ ${result} ]] || return 1
+ echo "${result}"
+}
+
+# @FUNCTION: rebar_disable_coverage
+# @USAGE: [<rebar_config>]
+# @DESCRIPTION:
+# Disable coverage in rebar.config. This is a workaround for failing coverage.
+# Coverage is not relevant in this context, so there's no harm to disable it,
+# although the issue should be fixed.
+rebar_disable_coverage() {
+ debug-print-function ${FUNCNAME} "${@}"
+
+ local rebar_config="${1:-rebar.config}"
+
+ sed -e 's/{cover_enabled, true}/{cover_enabled, false}/' \
+ -i "${rebar_config}" \
+ || die "failed to disable coverage in ${rebar_config}"
+}
+
+# @FUNCTION: rebar_fix_include_path
+# @USAGE: <project_name> [<rebar_config>]
+# @DESCRIPTION:
+# Fix path in rebar.config to 'include' directory of dependent project/package,
+# so it points to installation in system Erlang lib rather than relative 'deps'
+# directory.
+#
+# <rebar_config> is optional. Default is 'rebar.config'.
+#
+# The function dies on failure.
+rebar_fix_include_path() {
+ debug-print-function ${FUNCNAME} "${@}"
+
+ local pn="${1}"
+ local rebar_config="${2:-rebar.config}"
+ local erl_libs="${EPREFIX}$(get_erl_libs)"
+ local p
+
+ p="$(_rebar_find_dep "${pn}")" \
+ || die "failed to unambiguously resolve dependency of '${pn}'"
+
+ gawk -i inplace \
+ -v erl_libs="${erl_libs}" -v pn="${pn}" -v p="${p}" '
+/^{[[:space:]]*erl_opts[[:space:]]*,/, /}[[:space:]]*\.$/ {
+ pattern = "\"(./)?deps/" pn "/include\"";
+ if (match($0, "{i,[[:space:]]*" pattern "[[:space:]]*}")) {
+ sub(pattern, "\"" erl_libs "/" p "/include\"");
+ }
+ print $0;
+ next;
+}
+1
+' "${rebar_config}" || die "failed to fix include paths in ${rebar_config} for '${pn}'"
+}
+
+# @FUNCTION: rebar_remove_deps
+# @USAGE: [<rebar_config>]
+# @DESCRIPTION:
+# Remove dependencies list from rebar.config and deceive build rules that any
+# dependencies are already fetched and built. Otherwise rebar tries to fetch
+# dependencies and compile them.
+#
+# <rebar_config> is optional. Default is 'rebar.config'.
+#
+# The function dies on failure.
+rebar_remove_deps() {
+ debug-print-function ${FUNCNAME} "${@}"
+
+ local rebar_config="${1:-rebar.config}"
+
+ mkdir -p "${S}/deps" && :>"${S}/deps/.got" && :>"${S}/deps/.built" || die
+ gawk -i inplace '
+/^{[[:space:]]*deps[[:space:]]*,/, /}[[:space:]]*\.$/ {
+ if ($0 ~ /}[[:space:]]*\.$/) {
+ print "{deps, []}.";
+ }
+ next;
+}
+1
+' "${rebar_config}" || die "failed to remove deps from ${rebar_config}"
+}
+
+# @FUNCTION: rebar_set_vsn
+# @USAGE: [<version>]
+# @DESCRIPTION:
+# Set version in project description file if it's not set.
+#
+# <version> is optional. Default is PV stripped from version suffix.
+#
+# The function dies on failure.
+rebar_set_vsn() {
+ debug-print-function ${FUNCNAME} "${@}"
+
+ local version="${1:-${PV%_*}}"
+
+ sed -e "s/vsn, git/vsn, \"${version}\"/" \
+ -i "${S}/${REBAR_APP_SRC}" \
+ || die "failed to set version in src/${PN}.app.src"
+}
+
+fi
diff --git a/eclass/rebar.eclass b/eclass/rebar.eclass
index 97638c761814..1e4e845a9adb 100644
--- a/eclass/rebar.eclass
+++ b/eclass/rebar.eclass
@@ -7,6 +7,7 @@
# @AUTHOR:
# Amadeusz Żołnowski <aidecoe@gentoo.org>
# @SUPPORTED_EAPIS: 7 8
+# @PROVIDES: rebar-utils
# @BLURB: Build Erlang/OTP projects using dev-util/rebar.
# @DESCRIPTION:
# An eclass providing functions to build Erlang/OTP projects using
@@ -27,6 +28,8 @@ esac
if [[ -z ${_REBAR_ECLASS} ]]; then
_REBAR_ECLASS=1
+inherit rebar-utils
+
RDEPEND="dev-lang/erlang:="
DEPEND="${RDEPEND}"
BDEPEND="
@@ -34,19 +37,6 @@ BDEPEND="
>=sys-apps/gawk-4.1
"
-# @ECLASS_VARIABLE: REBAR_APP_SRC
-# @DESCRIPTION:
-# Relative path to .app.src description file.
-REBAR_APP_SRC="${REBAR_APP_SRC-src/${PN}.app.src}"
-
-# @FUNCTION: get_erl_libs
-# @RETURN: the path to Erlang lib directory
-# @DESCRIPTION:
-# Get the full path without EPREFIX to Erlang lib directory.
-get_erl_libs() {
- echo "/usr/$(get_libdir)/erlang/lib"
-}
-
# @FUNCTION: _rebar_find_dep
# @INTERNAL
# @USAGE: <project_name>
@@ -74,22 +64,6 @@ _rebar_find_dep() {
echo "${result}"
}
-# @FUNCTION: rebar_disable_coverage
-# @USAGE: [<rebar_config>]
-# @DESCRIPTION:
-# Disable coverage in rebar.config. This is a workaround for failing coverage.
-# Coverage is not relevant in this context, so there's no harm to disable it,
-# although the issue should be fixed.
-rebar_disable_coverage() {
- debug-print-function ${FUNCNAME} "${@}"
-
- local rebar_config="${1:-rebar.config}"
-
- sed -e 's/{cover_enabled, true}/{cover_enabled, false}/' \
- -i "${rebar_config}" \
- || die "failed to disable coverage in ${rebar_config}"
-}
-
# @FUNCTION: erebar
# @USAGE: <targets>
# @DESCRIPTION:
@@ -105,86 +79,6 @@ erebar() {
rebar -v skip_deps=true "$@" || die -n "rebar $@ failed"
}
-# @FUNCTION: rebar_fix_include_path
-# @USAGE: <project_name> [<rebar_config>]
-# @DESCRIPTION:
-# Fix path in rebar.config to 'include' directory of dependent project/package,
-# so it points to installation in system Erlang lib rather than relative 'deps'
-# directory.
-#
-# <rebar_config> is optional. Default is 'rebar.config'.
-#
-# The function dies on failure.
-rebar_fix_include_path() {
- debug-print-function ${FUNCNAME} "${@}"
-
- local pn="${1}"
- local rebar_config="${2:-rebar.config}"
- local erl_libs="${EPREFIX}$(get_erl_libs)"
- local p
-
- p="$(_rebar_find_dep "${pn}")" \
- || die "failed to unambiguously resolve dependency of '${pn}'"
-
- gawk -i inplace \
- -v erl_libs="${erl_libs}" -v pn="${pn}" -v p="${p}" '
-/^{[[:space:]]*erl_opts[[:space:]]*,/, /}[[:space:]]*\.$/ {
- pattern = "\"(./)?deps/" pn "/include\"";
- if (match($0, "{i,[[:space:]]*" pattern "[[:space:]]*}")) {
- sub(pattern, "\"" erl_libs "/" p "/include\"");
- }
- print $0;
- next;
-}
-1
-' "${rebar_config}" || die "failed to fix include paths in ${rebar_config} for '${pn}'"
-}
-
-# @FUNCTION: rebar_remove_deps
-# @USAGE: [<rebar_config>]
-# @DESCRIPTION:
-# Remove dependencies list from rebar.config and deceive build rules that any
-# dependencies are already fetched and built. Otherwise rebar tries to fetch
-# dependencies and compile them.
-#
-# <rebar_config> is optional. Default is 'rebar.config'.
-#
-# The function dies on failure.
-rebar_remove_deps() {
- debug-print-function ${FUNCNAME} "${@}"
-
- local rebar_config="${1:-rebar.config}"
-
- mkdir -p "${S}/deps" && :>"${S}/deps/.got" && :>"${S}/deps/.built" || die
- gawk -i inplace '
-/^{[[:space:]]*deps[[:space:]]*,/, /}[[:space:]]*\.$/ {
- if ($0 ~ /}[[:space:]]*\.$/) {
- print "{deps, []}.";
- }
- next;
-}
-1
-' "${rebar_config}" || die "failed to remove deps from ${rebar_config}"
-}
-
-# @FUNCTION: rebar_set_vsn
-# @USAGE: [<version>]
-# @DESCRIPTION:
-# Set version in project description file if it's not set.
-#
-# <version> is optional. Default is PV stripped from version suffix.
-#
-# The function dies on failure.
-rebar_set_vsn() {
- debug-print-function ${FUNCNAME} "${@}"
-
- local version="${1:-${PV%_*}}"
-
- sed -e "s/vsn, git/vsn, \"${version}\"/" \
- -i "${S}/${REBAR_APP_SRC}" \
- || die "failed to set version in src/${PN}.app.src"
-}
-
# @FUNCTION: rebar_src_prepare
# @DESCRIPTION:
# Prevent rebar from fetching and compiling dependencies. Set version in
diff --git a/eclass/rebar3.eclass b/eclass/rebar3.eclass
new file mode 100644
index 000000000000..f6383b9c8cdd
--- /dev/null
+++ b/eclass/rebar3.eclass
@@ -0,0 +1,194 @@
+# Copyright 1999-2024 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+# @ECLASS: rebar3.eclass
+# @MAINTAINER:
+# Florian Schmaus <flow@gentoo.org>
+# @AUTHOR:
+# Amadeusz Żołnowski <aidecoe@gentoo.org>
+# Anna (cybertailor) Vyalkova <cyber+gentoo@sysrq.in>
+# @SUPPORTED_EAPIS: 8
+# @PROVIDES: rebar-utils
+# @BLURB: Build Erlang/OTP projects using dev-util/rebar:3.
+# @DESCRIPTION:
+# An eclass providing functions to build Erlang/OTP projects using
+# dev-util/rebar:3.
+#
+# rebar is a tool which tries to resolve dependencies itself which is by
+# cloning remote git repositories. Dependent projects are usually expected to
+# be in sub-directory 'deps' rather than looking at system Erlang lib
+# directory. Projects relying on rebar usually don't have 'install' make
+# targets. The eclass workarounds some of these problems. It handles
+# installation in a generic way for Erlang/OTP structured projects.
+
+case ${EAPI} in
+ 8) ;;
+ *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
+esac
+
+if [[ -z ${_REBAR3_ECLASS} ]]; then
+_REBAR3_ECLASS=1
+
+inherit edo rebar-utils
+
+RDEPEND="dev-lang/erlang:="
+DEPEND="${RDEPEND}"
+BDEPEND="
+ dev-util/rebar:3
+ >=sys-apps/gawk-4.1
+"
+
+# @ECLASS_VARIABLE: REBAR_PROFILE
+# @DESCRIPTION:
+# Rebar profile to use. Defaults to
+# 'default'.
+: "${REBAR_PROFILE:=default}"
+
+# @FUNCTION: _rebar_find_dep
+# @INTERNAL
+# @USAGE: <project_name>
+# @RETURN: 0 success, 1 dependency not found, 2 multiple versions found
+# @DESCRIPTION:
+# Find a Erlang package/project by name in Erlang lib directory. Project
+# directory is usually suffixed with version. It is matched to '<project_name>'
+# or '<project_name>-*'.
+_rebar_find_dep() {
+ local pn="${1}"
+ local p
+ local result
+
+ pushd "${EPREFIX}$(get_erl_libs)" >/dev/null || return 1
+ for p in ${pn} ${pn}-*; do
+ if [[ -d ${p} ]]; then
+ # Ensure there's at most one matching.
+ [[ ${result} ]] && return 2
+ result="${p}"
+ fi
+ done
+ popd >/dev/null || die
+
+ [[ ${result} ]] || return 1
+ echo "${result}"
+}
+
+# @FUNCTION: erebar3
+# @USAGE: <targets>
+# @DESCRIPTION:
+# Run rebar with verbose flag. Die on failure.
+erebar3() {
+ debug-print-function ${FUNCNAME} "${@}"
+
+ (( $# > 0 )) || die "${FUNCNAME}: at least one target is required"
+
+ case ${1} in
+ eunit|ct)
+ local -x ERL_LIBS="." ;;
+ *)
+ local -x ERL_LIBS="${EPREFIX}$(get_erl_libs)" ;;
+ esac
+
+ local -x HEX_OFFLINE=true
+ edo rebar3 "$@"
+}
+
+# @FUNCTION: rebar3_src_prepare
+# @DESCRIPTION:
+# Prevent rebar3 from fetching and compiling dependencies. Set version in
+# project description file if it's not set.
+#
+# Existence of rebar.config is optional, but file description file must exist
+# at 'src/${PN}.app.src'.
+rebar3_src_prepare() {
+ debug-print-function ${FUNCNAME} "${@}"
+
+ default
+ rebar_set_vsn
+
+ if [[ -f rebar.lock ]]; then
+ rm rebar.lock || die
+ fi
+
+ if [[ -f rebar.config ]]; then
+ rebar_disable_coverage
+ rebar_remove_deps
+ fi
+}
+
+# @FUNCTION: rebar3_src_configure
+# @DESCRIPTION:
+# Configure with ERL_LIBS set.
+rebar3_src_configure() {
+ debug-print-function ${FUNCNAME} "${@}"
+
+ local -x ERL_LIBS="${EPREFIX}$(get_erl_libs)"
+ default
+}
+
+# @FUNCTION: rebar3_src_compile
+# @DESCRIPTION:
+# Compile project with rebar3.
+rebar3_src_compile() {
+ debug-print-function ${FUNCNAME} "${@}"
+
+ erebar3 as "${REBAR_PROFILE}" release --all
+}
+
+# @FUNCTION: rebar3_src_test
+# @DESCRIPTION:
+# Run unit tests.
+rebar3_src_test() {
+ debug-print-function ${FUNCNAME} "${@}"
+
+ erebar3 eunit -v
+}
+
+# @FUNCTION: rebar3_install_lib
+# @USAGE: <dir>
+# @DESCRIPTION:
+# Install BEAM files, include headers and native libraries.
+#
+# Function expects that project conforms to Erlang/OTP structure.
+rebar3_install_lib() {
+ debug-print-function ${FUNCNAME} "${@}"
+
+ local dest="$(get_erl_libs)/${P}"
+ insinto "${dest}"
+
+ pushd "${1?}" >/dev/null || die
+ for dir in ebin include priv; do
+ if [[ -d ${dir} && ! -L ${dir} ]]; then
+ doins -r "${dir}"
+ fi
+ done
+ popd >/dev/null || die
+}
+
+# @FUNCTION: rebar3_src_install
+# @DESCRIPTION:
+# Install built release or library.
+#
+# Function expects that project conforms to Erlang/OTP structure.
+rebar3_src_install() {
+ debug-print-function ${FUNCNAME} "${@}"
+
+ pushd "_build/${REBAR_PROFILE}" >/dev/null || die
+ if [[ -d rel/${PN} ]]; then
+ if ! declare -f rebar3_install_release >/dev/null; then
+ die "${FUNCNAME}: a custom function named 'rebar3_install_release' is required to install a release"
+ fi
+ pushd rel/${PN} >/dev/null || die
+ rebar3_install_release || die
+ popd >/dev/null || die
+ elif [[ -d lib/${PN} ]]; then
+ rebar3_install_lib lib/${PN}
+ else
+ die "No releases or libraries to install"
+ fi
+ popd >/dev/null || die
+
+ einstalldocs
+}
+
+fi
+
+EXPORT_FUNCTIONS src_prepare src_compile src_test src_install