summaryrefslogtreecommitdiff
path: root/eclass
diff options
context:
space:
mode:
Diffstat (limited to 'eclass')
-rw-r--r--eclass/acct-group.eclass18
-rw-r--r--eclass/acct-user.eclass22
-rw-r--r--eclass/cargo.eclass56
-rw-r--r--eclass/distutils-r1.eclass112
-rw-r--r--eclass/edo.eclass67
-rw-r--r--eclass/java-osgi.eclass6
-rw-r--r--eclass/linux-info.eclass14
-rw-r--r--eclass/linux-mod-r1.eclass113
-rw-r--r--eclass/llvm.org.eclass13
-rw-r--r--eclass/perl-module.eclass1
-rw-r--r--eclass/plasma.kde.org.eclass2
-rw-r--r--eclass/python-utils-r1.eclass14
-rw-r--r--eclass/rocm.eclass31
-rwxr-xr-xeclass/tests/dist-kernel-utils.sh6
-rwxr-xr-xeclass/tests/eapi7-ver.sh7
-rwxr-xr-xeclass/tests/eapi7-ver_benchmark.sh147
-rwxr-xr-xeclass/tests/edo.sh113
-rwxr-xr-xeclass/tests/toolchain.sh4
-rw-r--r--eclass/tests/version-funcs.sh302
-rw-r--r--eclass/texlive-common.eclass8
-rw-r--r--eclass/texlive-module.eclass12
-rw-r--r--eclass/toolchain.eclass2
22 files changed, 787 insertions, 283 deletions
diff --git a/eclass/acct-group.eclass b/eclass/acct-group.eclass
index a0ad86066309..2c2c88cfc7e1 100644
--- a/eclass/acct-group.eclass
+++ b/eclass/acct-group.eclass
@@ -1,4 +1,4 @@
-# Copyright 2019-2023 Gentoo Authors
+# Copyright 2019-2024 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
# @ECLASS: acct-group.eclass
@@ -50,12 +50,12 @@ inherit user-info
# << Eclass variables >>
# @ECLASS_VARIABLE: ACCT_GROUP_NAME
-# @INTERNAL
# @DESCRIPTION:
# The name of the group. This is forced to ${PN} and the policy
-# prohibits it from being changed.
+# prohibits it from being changed. The variable is left writable for
+# use in overlays; package naming restrictions would prohibit some
+# otherwise-valid group names.
ACCT_GROUP_NAME=${PN}
-readonly ACCT_GROUP_NAME
# @ECLASS_VARIABLE: ACCT_GROUP_ID
# @REQUIRED
@@ -96,8 +96,9 @@ acct-group_pkg_pretend() {
[[ ${ACCT_GROUP_ID} -ge -1 ]] || die "Ebuild error: ACCT_GROUP_ID=${ACCT_GROUP_ID} invalid!"
local group_id=${ACCT_GROUP_ID}
- # check for the override
- local override_name=${ACCT_GROUP_NAME^^}
+ # check for the override, use PN in case this is an overlay and
+ # ACCT_GROUP_NAME is not PN and not valid in a bash variable name
+ local override_name=${PN^^}
local override_var=ACCT_GROUP_${override_name//-/_}_ID
if [[ -n ${!override_var} ]]; then
group_id=${!override_var}
@@ -132,8 +133,9 @@ acct-group_pkg_pretend() {
acct-group_src_install() {
debug-print-function ${FUNCNAME} "${@}"
- # check for the override
- local override_name=${ACCT_GROUP_NAME^^}
+ # check for the override, use PN in case this is an overlay and
+ # ACCT_GROUP_NAME is not PN and not valid in a bash variable name
+ local override_name=${PN^^}
local override_var=ACCT_GROUP_${override_name//-/_}_ID
if [[ -n ${!override_var} ]]; then
ewarn "${override_var}=${!override_var} override in effect, support will not be provided."
diff --git a/eclass/acct-user.eclass b/eclass/acct-user.eclass
index 66a4d6667888..9eab1f4c4ae6 100644
--- a/eclass/acct-user.eclass
+++ b/eclass/acct-user.eclass
@@ -1,4 +1,4 @@
-# Copyright 2019-2023 Gentoo Authors
+# Copyright 2019-2024 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
# @ECLASS: acct-user.eclass
@@ -58,12 +58,12 @@ inherit user-info
# << Eclass variables >>
# @ECLASS_VARIABLE: ACCT_USER_NAME
-# @INTERNAL
# @DESCRIPTION:
-# The name of the user. This is forced to ${PN} and the policy prohibits
-# it from being changed.
+# The name of the user. This is forced to ${PN} and the policy
+# prohibits it from being changed. The variable is left writable for
+# use in overlays; package naming restrictions would prohibit some
+# otherwise-valid usernames.
ACCT_USER_NAME=${PN}
-readonly ACCT_USER_NAME
# @ECLASS_VARIABLE: ACCT_USER_ID
# @REQUIRED
@@ -231,8 +231,9 @@ acct-user_pkg_pretend() {
[[ ${ACCT_USER_ID} -ge -1 ]] || die "Ebuild error: ACCT_USER_ID=${ACCT_USER_ID} invalid!"
local user_id=${ACCT_USER_ID}
- # check for the override
- local override_name=${ACCT_USER_NAME^^}
+ # check for the override, use PN in case this is an overlay and
+ # ACCT_USER_NAME is not PN and not valid in a bash variable name
+ local override_name=${PN^^}
local override_var=ACCT_USER_${override_name//-/_}_ID
if [[ -n ${!override_var} ]]; then
user_id=${!override_var}
@@ -274,8 +275,9 @@ acct-user_src_install() {
# serialize for override support
local ACCT_USER_GROUPS=${ACCT_USER_GROUPS[*]}
- # support make.conf overrides
- local override_name=${ACCT_USER_NAME^^}
+ # support make.conf overrides, use PN in case this is an overlay and
+ # ACCT_USER_NAME is not PN and not valid in a bash variable name
+ local override_name=${PN^^}
override_name=${override_name//-/_}
local var
for var in ACCT_USER_{ID,COMMENT,SHELL,HOME{,_OWNER,_PERMS},GROUPS}; do
@@ -437,7 +439,7 @@ acct-user_pkg_postinst() {
has "${g}" "${groups[@]}" || del_groups+="${del_groups:+, }${g}"
done
if [[ -n ${del_groups} ]]; then
- local override_name=${ACCT_USER_NAME^^}
+ local override_name=${PN^^}
override_name=${override_name//-/_}
ewarn "Removing user ${ACCT_USER_NAME} from group(s): ${del_groups}"
ewarn "To retain the user's group membership in the local system"
diff --git a/eclass/cargo.eclass b/eclass/cargo.eclass
index 0f2da982f60c..a685cd99fb38 100644
--- a/eclass/cargo.eclass
+++ b/eclass/cargo.eclass
@@ -329,40 +329,50 @@ _cargo_gen_git_config() {
cargo_src_unpack() {
debug-print-function ${FUNCNAME} "$@"
- mkdir -p "${ECARGO_VENDOR}" || die
- mkdir -p "${S}" || die
+ mkdir -p "${ECARGO_VENDOR}" "${S}" || die
local archive shasum pkg
+ local crates=()
for archive in ${A}; do
case "${archive}" in
*.crate)
- # when called by pkgdiff-mg, do not unpack crates
- [[ ${PKGBUMPING} == ${PVR} ]] && continue
-
- ebegin "Loading ${archive} into Cargo registry"
- tar -xf "${DISTDIR}"/${archive} -C "${ECARGO_VENDOR}/" || die
- # generate sha256sum of the crate itself as cargo needs this
- shasum=$(sha256sum "${DISTDIR}"/${archive} | cut -d ' ' -f 1)
- pkg=$(basename ${archive} .crate)
- cat <<- EOF > ${ECARGO_VENDOR}/${pkg}/.cargo-checksum.json
- {
- "package": "${shasum}",
- "files": {}
- }
- EOF
- # if this is our target package we need it in ${WORKDIR} too
- # to make ${S} (and handle any revisions too)
- if [[ ${P} == ${pkg}* ]]; then
- tar -xf "${DISTDIR}"/${archive} -C "${WORKDIR}" || die
- fi
- eend $?
+ crates+=( "${archive}" )
;;
*)
- unpack ${archive}
+ unpack "${archive}"
;;
esac
done
+ if [[ ${PKGBUMPING} != ${PVR} && ${crates[@]} ]]; then
+ pushd "${DISTDIR}" >/dev/null || die
+
+ ebegin "Unpacking crates"
+ printf '%s\0' "${crates[@]}" |
+ xargs -0 -P "$(makeopts_jobs)" -n 1 -t -- \
+ tar -x -C "${ECARGO_VENDOR}" -f
+ assert
+ eend $?
+
+ while read -d '' -r shasum archive; do
+ pkg=${archive%.crate}
+ cat <<- EOF > ${ECARGO_VENDOR}/${pkg}/.cargo-checksum.json || die
+ {
+ "package": "${shasum}",
+ "files": {}
+ }
+ EOF
+
+ # if this is our target package we need it in ${WORKDIR} too
+ # to make ${S} (and handle any revisions too)
+ if [[ ${P} == ${pkg}* ]]; then
+ tar -xf "${archive}" -C "${WORKDIR}" || die
+ fi
+ done < <(sha256sum -z "${crates[@]}" || die)
+
+ popd >/dev/null || die
+ fi
+
cargo_gen_config
}
diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass
index a67122a59a33..71b80fafe1a5 100644
--- a/eclass/distutils-r1.eclass
+++ b/eclass/distutils-r1.eclass
@@ -189,6 +189,18 @@ esac
# ${DISTUTILS_DEPS}"
# @CODE
+# @ECLASS_VARIABLE: DISTUTILS_ALLOW_WHEEL_REUSE
+# @DEFAULT_UNSET
+# @USER_VARIABLE
+# @DESCRIPTION:
+# If set to a non-empty value, the eclass is allowed to reuse a wheel
+# that was built for a prior Python implementation, provided that it is
+# compatible with the current one, rather than building a new one.
+#
+# This is an optimization that can avoid the overhead of calling into
+# the build system in pure Python packages and packages using the stable
+# Python ABI.
+
if [[ -z ${_DISTUTILS_R1_ECLASS} ]]; then
_DISTUTILS_R1_ECLASS=1
@@ -267,7 +279,7 @@ _distutils_set_globals() {
;;
scikit-build-core)
bdep+='
- >=dev-python/scikit-build-core-0.8.2[${PYTHON_USEDEP}]
+ >=dev-python/scikit-build-core-0.9.4[${PYTHON_USEDEP}]
'
;;
setuptools)
@@ -1343,6 +1355,10 @@ distutils_wheel_install() {
\) -delete || die
}
+# @VARIABLE: DISTUTILS_WHEEL_PATH
+# @DESCRIPTION:
+# Path to the wheel created by distutils_pep517_install.
+
# @FUNCTION: distutils_pep517_install
# @USAGE: <root>
# @DESCRIPTION:
@@ -1350,7 +1366,8 @@ distutils_wheel_install() {
# backend and install it into <root>.
#
# This function is intended for expert use only. It does not handle
-# wrapping executables.
+# wrapping executables. The wheel path is returned
+# in DISTUTILS_WHEEL_PATH variable.
distutils_pep517_install() {
debug-print-function ${FUNCNAME} "${@}"
[[ ${#} -eq 1 ]] || die "${FUNCNAME} takes exactly one argument: root"
@@ -1440,17 +1457,21 @@ distutils_pep517_install() {
"${DISTUTILS_ARGS[@]}"
)
- # NB: we need to pass strings for boolean fields
- # https://github.com/scikit-build/scikit-build-core/issues/707
+ local -x NINJAOPTS=$(get_NINJAOPTS)
config_settings=$(
"${EPYTHON}" - "${cmake_args[@]}" <<-EOF || die
import json
+ import os
+ import shlex
import sys
+
+ ninjaopts = shlex.split(os.environ["NINJAOPTS"])
print(json.dumps({
+ "build.tool-args": ninjaopts,
"cmake.args": ";".join(sys.argv[1:]),
"cmake.build-type": "${CMAKE_BUILD_TYPE}",
- "cmake.verbose": "true",
- "install.strip": "false",
+ "cmake.verbose": True,
+ "install.strip": False,
}))
EOF
)
@@ -1523,8 +1544,19 @@ distutils_pep517_install() {
[[ -n ${wheel} ]] || die "No wheel name returned"
distutils_wheel_install "${root}" "${WHEEL_BUILD_DIR}/${wheel}"
+
+ DISTUTILS_WHEEL_PATH=${WHEEL_BUILD_DIR}/${wheel}
}
+# @VARIABLE: DISTUTILS_WHEELS
+# @DESCRIPTION:
+# An associative array of wheels created as a result
+# of distutils-r1_python_compile invocations, mapped to the source
+# directories. Note that this includes only wheels implicitly created
+# by the eclass, and not wheels created as a result of direct
+# distutils_pep517_install calls in the ebuild.
+declare -g -A DISTUTILS_WHEELS=()
+
# @FUNCTION: distutils-r1_python_compile
# @USAGE: [additional-args...]
# @DESCRIPTION:
@@ -1534,6 +1566,7 @@ distutils_pep517_install() {
#
# If DISTUTILS_USE_PEP517 is set to any other value, builds a wheel
# using the PEP517 backend and installs it into ${BUILD_DIR}/install.
+# Path to the wheel is then added to DISTUTILS_WHEELS array.
#
# In legacy mode, runs 'esetup.py build'. Any parameters passed to this
# function will be appended to setup.py invocation, i.e. passed
@@ -1568,7 +1601,34 @@ distutils-r1_python_compile() {
esac
if [[ ${DISTUTILS_USE_PEP517} ]]; then
+ if [[ ${DISTUTILS_ALLOW_WHEEL_REUSE} ]]; then
+ local whl
+ for whl in "${!DISTUTILS_WHEELS[@]}"; do
+ # use only wheels corresponding to the current directory
+ if [[ ${PWD} != ${DISTUTILS_WHEELS["${whl}"]} ]]; then
+ continue
+ fi
+
+ # 1. Use pure Python wheels only if we're not expected
+ # to build extensions. Otherwise, we may end up
+ # not building the extension at all when e.g. PyPy3
+ # is built without one.
+ #
+ # 2. For CPython, we can reuse stable ABI wheels. Note
+ # that this relies on the assumption that we're building
+ # from the oldest to the newest implementation,
+ # and the wheels are forward-compatible.
+ if [[ ( ! ${DISTUTILS_EXT} && ${whl} == *py3-none-any* ) ||
+ ( ${EPYTHON} == python* && ${whl} == *-abi3-* ) ]]
+ then
+ distutils_wheel_install "${BUILD_DIR}/install" "${whl}"
+ return
+ fi
+ done
+ fi
+
distutils_pep517_install "${BUILD_DIR}/install"
+ DISTUTILS_WHEELS+=( "${DISTUTILS_WHEEL_PATH}" "${PWD}" )
fi
}
@@ -2004,6 +2064,44 @@ distutils-r1_src_configure() {
return ${ret}
}
+# @FUNCTION: _distutils-r1_compare_installed_files
+# @INTERNAL
+# @DESCRIPTION:
+# Verify the the match between files installed between this and previous
+# implementation.
+_distutils-r1_compare_installed_files() {
+ debug-print-function ${FUNCNAME} "${@}"
+
+ # QA check requires diff(1).
+ if ! type -P diff &>/dev/null; then
+ return
+ fi
+
+ # Perform the check only if at least one potentially reusable wheel
+ # has been produced. Nonpure packages (e.g. NumPy) may install
+ # interpreter configuration details into sitedir.
+ if [[ ${!DISTUTILS_WHEELS[*]} != *-none-any.whl* &&
+ ${!DISTUTILS_WHEELS[*]} != *-abi3-*.whl ]]; then
+ return
+ fi
+
+ local sitedir=${BUILD_DIR}/install$(python_get_sitedir)
+ if [[ -n ${_DISTUTILS_PREVIOUS_SITE} ]]; then
+ diff -dur \
+ --exclude=__pycache__ \
+ --exclude='*.dist-info' \
+ --exclude="*$(get_modname)" \
+ "${_DISTUTILS_PREVIOUS_SITE}" "${sitedir}"
+ if [[ ${?} -ne 0 ]]; then
+ eqawarn "Package creating at least one pure Python wheel installs different"
+ eqawarn "Python files between implementations. See diff in build log, above"
+ eqawarn "this message."
+ fi
+ fi
+
+ _DISTUTILS_PREVIOUS_SITE=${sitedir}
+}
+
# @FUNCTION: _distutils-r1_post_python_compile
# @INTERNAL
# @DESCRIPTION:
@@ -2038,6 +2136,8 @@ _distutils-r1_post_python_compile() {
find "${bindir}" -type f -exec sed -i \
-e "1s@^#!\(${EPREFIX}/usr/bin/\(python\|pypy\)\)@#!${root}\1@" \
{} + || die
+
+ _distutils-r1_compare_installed_files
fi
}
diff --git a/eclass/edo.eclass b/eclass/edo.eclass
index c2e7ed60083f..5fd77a676a8b 100644
--- a/eclass/edo.eclass
+++ b/eclass/edo.eclass
@@ -1,4 +1,4 @@
-# Copyright 2022 Gentoo Authors
+# Copyright 2022-2024 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
# @ECLASS: edo.eclass
@@ -12,10 +12,16 @@
# This eclass provides the 'edo' command, and an 'edob' variant for ebegin/eend,
# which logs the command used verbosely and dies (exits) on failure.
#
-# This eclass should be used only where needed to give a more verbose log, e.g.
-# for invoking non-standard ./configure scripts, or building objects/binaries
-# directly within ebuilds via compiler invocations. It is NOT to be used
-# in place of generic 'command || die' where verbosity is unnecessary.
+# The 'edo' command should be used only where needed to give a more verbose log,
+# e.g. for invoking non-standard ./configure scripts, or building
+# objects/binaries directly within ebuilds via compiler invocations. It is NOT
+# to be used in place of generic 'command || die' where verbosity is
+# unnecessary.
+#
+# The 'edob' command can be used for long running commands, even if
+# those commands produce output. The 'edob' command will suppress the
+# command's output and only present it if the command returned with a
+# non-zero exit status.
case ${EAPI} in
7|8) ;;
*) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
@@ -35,14 +41,55 @@ edo() {
}
# @FUNCTION: edob
-# @USAGE: <command> [<args>...]
+# @USAGE: [-l <log-name>] [-m <message>] <command> [<args>...]
# @DESCRIPTION:
# Executes 'command' with ebegin & eend with any given arguments and exits
-# on failure unless called under 'nonfatal'.
+# on failure unless called under 'nonfatal'. This function redirects
+# stdout and stderr to a log file. The content of the log file is shown
+# if the command returns with a non-zero exit status.
+#
+# If -m <message> is provided, then invokes ebegin with <message>, otherwise
+# a default message is used. If -l <log-name> is provided, then <log-name> is
+# used to construct the name of the log file where stdout and stderr of the
+# command is redirected to.
edob() {
- ebegin "Running $@"
- "$@"
- eend $? || die -n "Failed to run command: $@"
+ local message
+ local log_name
+
+ while true; do
+ case "${1}" in
+ -l|-m)
+ [[ $# -lt 2 ]] && die "Must provide an argument to ${1}"
+ case "${1}" in
+ -l)
+ log_name="${2}"
+ ;;
+ -m)
+ message="${2}"
+ ;;
+ esac
+ shift 2
+ ;;
+ *)
+ break
+ ;;
+ esac
+ done
+
+ [[ -z ${message} ]] && message="Running $@"
+ [[ -z ${log_name} ]] && log_name="$(basename ${1})"
+
+ local log_file="${T}/${log_name}.log"
+
+ ebegin "${message}"
+
+ "$@" &> "${log_file}"
+ local ret=$?
+
+ if ! eend $ret; then
+ cat "${log_file}"
+ die -n "Command \"$@\" failed with exit status $ret"
+ fi
}
fi
diff --git a/eclass/java-osgi.eclass b/eclass/java-osgi.eclass
index 7019fab7b203..172b42225c6e 100644
--- a/eclass/java-osgi.eclass
+++ b/eclass/java-osgi.eclass
@@ -1,4 +1,4 @@
-# Copyright 2007-2022 Gentoo Authors
+# Copyright 2007-2024 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
# @ECLASS: java-osgi.eclass
@@ -6,7 +6,7 @@
# java@gentoo.org
# @AUTHOR:
# Java maintainers <java@gentoo.org>
-# @SUPPORTED_EAPIS: 7 8
+# @SUPPORTED_EAPIS: 8
# @PROVIDES: java-utils-2
# @BLURB: Java OSGi eclass
# @DESCRIPTION:
@@ -16,7 +16,7 @@
# could extend this so that Gentoo Java system would be fully OSGi compliant.
case ${EAPI} in
- 7|8) ;;
+ 8) ;;
*) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
esac
diff --git a/eclass/linux-info.eclass b/eclass/linux-info.eclass
index 864594f607ca..9449a6359d2a 100644
--- a/eclass/linux-info.eclass
+++ b/eclass/linux-info.eclass
@@ -158,6 +158,14 @@ KERNEL_DIR="${KERNEL_DIR:-${ROOT%/}/usr/src/linux}"
# This is a user flag and should under _no circumstances_ be set in the ebuild.
: "${SKIP_KERNEL_CHECK:=""}"
+# @ECLASS_VARIABLE: SKIP_KERNEL_BINPKG_ENV_RESET
+# @DEFAULT_UNSET
+# @DESCRIPTION:
+# If set, do not reset the kernel environment variables when merging a package
+# as a binpkg.
+# Main use-case is for kernel modules, i.e. linux-mod-r1.eclass.
+# This should be set before running linux-info_pkg_setup
+
# And to ensure all the weirdness with crosscompile
inherit toolchain-funcs
[[ ${EAPI} == 6 ]] && inherit eapi7-ver
@@ -696,12 +704,12 @@ linux-info_get_any_version() {
die "${FUNCNAME}() called on non-Linux system, please fix the ebuild"
fi
- if [[ ${MERGE_TYPE} == binary && -z ${LINUX_INFO_BINARY_RESET} ]]; then
+ if [[ ${MERGE_TYPE} == binary && -z ${SKIP_KERNEL_BINPKG_ENV_RESET} ]]; then
unset KV_FULL _LINUX_CONFIG_EXISTS_DONE KV_OUT_DIR
- LINUX_INFO_BINARY_RESET=1
+ SKIP_KERNEL_BINPKG_ENV_RESET=1
fi
- if [[ ${MERGE_TYPE} != binary ]] && ! get_version; then
+ if ! get_version; then
ewarn "Unable to calculate Linux Kernel version for build, attempting to use running version"
fi
diff --git a/eclass/linux-mod-r1.eclass b/eclass/linux-mod-r1.eclass
index 4b267aae4db1..43c5a7d7b140 100644
--- a/eclass/linux-mod-r1.eclass
+++ b/eclass/linux-mod-r1.eclass
@@ -131,6 +131,15 @@ IDEPEND="
sys-apps/kmod[tools]
"
+if [[ ${MODULES_INITRAMFS_IUSE} ]]; then
+ IUSE+=" ${MODULES_INITRAMFS_IUSE}"
+ IDEPEND+="
+ ${MODULES_INITRAMFS_IUSE#+}? (
+ sys-kernel/installkernel
+ )
+ "
+fi
+
if [[ -n ${MODULES_OPTIONAL_IUSE} ]]; then
: "${MODULES_OPTIONAL_IUSE#+}? ( | )"
RDEPEND=${_/|/${RDEPEND}} DEPEND=${_/|/${DEPEND}} \
@@ -179,6 +188,22 @@ fi
#
# May want to look at KERNEL_CHOST before considering this.
+# @ECLASS_VARIABLE: MODULES_INITRAMFS_IUSE
+# @DEFAULT_UNSET
+# @PRE_INHERIT
+# @DESCRIPTION:
+# If set, adds the specified USE flag. When this flag is enabled the
+# installed kernel modules are registered for inclusion in the dracut
+# initramfs. Additionally, if distribution kernels are used
+# (USE="dist-kernel") then these kernels are re-installed.
+#
+# The typical recommended value is "initramfs" or "+initramfs" (global
+# IUSE).
+#
+# If MODULES_INITRAMFS_IUSE is not set, or the specified flag is not
+# enabled, then the installed kernel modules are omitted from the
+# dracut initramfs.
+
# @ECLASS_VARIABLE: MODULES_SIGN_HASH
# @USER_VARIABLE
# @DEFAULT_UNSET
@@ -471,6 +496,19 @@ linux-mod-r1_pkg_postinst() {
dist-kernel_compressed_module_cleanup "${EROOT}/lib/modules/${KV_FULL}"
_modules_update_depmod
+ if [[ -z ${ROOT} && ${MODULES_INITRAMFS_IUSE} ]] &&
+ use dist-kernel && use ${MODULES_INITRAMFS_IUSE#+}
+ then
+ dist-kernel_reinstall_initramfs "${KV_DIR}" "${KV_FULL}"
+ fi
+
+ if has_version virtual/dist-kernel && ! use dist-kernel; then
+ ewarn "virtual/dist-kernel is installed, but USE=\"dist-kernel\""
+ ewarn "is not enabled for ${CATEGORY}/${PN}."
+ ewarn "It's recommended to globally enable the dist-kernel USE flag"
+ ewarn "to automatically trigger initramfs rebuilds on kernel updates"
+ fi
+
# post_process ensures modules were installed and that the eclass' USE
# are likely not no-ops (unfortunately postinst itself may be missed)
[[ -v _MODULES_GLOBAL[ran:post_process] ]] ||
@@ -545,11 +583,13 @@ modules_post_process() {
(( ${#mods[@]} )) ||
die "${FUNCNAME[0]} was called with no installed modules under ${path}"
- # TODO?: find way for sane use with dracut (its 90kernel-modules-extra
- # parses depmod.d files directly and assumes should include its modules
- # which can lead to unnecessarily increased size or stale modules)
-# _modules_process_depmod.d "${mods[@]#"${path}/"}"
+ # TODO?: look into re-introducing after verifying it works as expected,
+ # formerly omitted because dracut's 90kernel-modules-extra parses depmod.d
+ # files directly and assumes should include its modules but we now create
+ # dracut omit files that *hopefully* prevent this
+# _modules_process_depmod.d "${mods[@]##*/}"
+ _modules_process_dracut.conf.d "${mods[@]##*/}"
_modules_process_strip "${mods[@]}"
_modules_process_sign "${mods[@]}"
_modules_sanity_modversion "${mods[@]}" # after strip/sign in case broke it
@@ -622,6 +662,11 @@ _modules_check_migration() {
# Handles linux-info bits to provide usable sources, KV_ variables,
# and CONFIG_CHECK use.
_modules_prepare_kernel() {
+ # The modules we build are specific to each kernel version, we don't
+ # want to reset the environment to use the user selected kernel version.
+ # Bug 931213, 926063
+ SKIP_KERNEL_BINPKG_ENV_RESET=1
+
get_version
# linux-info allows skipping checks if SKIP_KERNEL_CHECK is set and
@@ -650,24 +695,6 @@ _modules_prepare_kernel() {
fi
linux-info_pkg_setup
-
- if use dist-kernel &&
- ! has_version "~virtual/dist-kernel-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}"
- then
- ewarn
- ewarn "The kernel modules in ${CATEGORY}/${PN} are being built for"
- ewarn "kernel version ${KV_FULL}. But this does not match the"
- ewarn "installed version of virtual/dist-kernel."
- ewarn
- ewarn "If this is not intentional, the problem may be corrected by"
- ewarn "using \"eselect kernel\" to set the default kernel version to"
- ewarn "the same version as the installed version of virtual/dist-kernel."
- ewarn
- ewarn "If the distribution kernel is being downgraded, ensure that"
- ewarn "virtual/dist-kernel is also downgraded to the same version"
- ewarn "before rebuilding external kernel modules."
- ewarn
- fi
}
# @FUNCTION: _modules_prepare_sign
@@ -812,7 +839,7 @@ _modules_prepare_toolchain() {
# can work but raises concerns about breaking packages that may use these
if linux_chkconfig_present LTO_CLANG_THIN && tc-ld-is-lld; then
KERNEL_LD=${T}/linux-mod-r1_ld.lld
- printf '#!/usr/bin/env sh\nexec %s "${@}" --thinlto-cache-dir=\n' \
+ printf '#!/usr/bin/env sh\nexec %q "${@}" --thinlto-cache-dir=\n' \
"${LD}" > "${KERNEL_LD}" || die
chmod +x -- "${KERNEL_LD}" || die
fi
@@ -854,7 +881,7 @@ _modules_prepare_toolchain() {
# If enabled in the kernel configuration, this compresses the given
# modules using the same format.
_modules_process_compress() {
- use modules-compress || return
+ use modules-compress || return 0
local -a compress
if linux_chkconfig_present MODULE_COMPRESS_XZ; then
@@ -904,6 +931,21 @@ _modules_process_depmod.d() {
)
}
+# @FUNCTION: _modules_process_dracut.conf.d
+# @USAGE: <module>...
+# @INTERNAL
+# @DESCRIPTION:
+# Create dracut.conf.d snippet defining if module should be included in the
+# initramfs.
+_modules_process_dracut.conf.d() {
+ (
+ insinto /usr/lib/dracut/dracut.conf.d
+ [[ ${MODULES_INITRAMFS_IUSE} ]] && use ${MODULES_INITRAMFS_IUSE#+} &&
+ : add || : omit
+ newins - 10-${PN}.conf <<<"${_}_drivers+=\" ${*%.ko} \""
+ )
+}
+
# @FUNCTION: _modules_process_sign
# @USAGE: <module>...
# @INTERNAL
@@ -1084,7 +1126,10 @@ _modules_sanity_kernelbuilt() {
# @DESCRIPTION:
# Prints a warning if the kernel version is greater than to
# MODULES_KERNEL_MAX (while only considering same amount of version
-# components), or aborts if it is less than MODULES_KERNEL_MIN
+# components), or aborts if it is less than MODULES_KERNEL_MIN.
+#
+# With USE=dist-kernel, also warn if virtual/dist-kernel is of a
+# different version than the one being built against.
_modules_sanity_kernelversion() {
local kv=${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}
@@ -1134,6 +1179,24 @@ _modules_sanity_kernelversion() {
ewarn
fi
fi
+
+ if use dist-kernel &&
+ ! has_version "~virtual/dist-kernel-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}"
+ then
+ ewarn
+ ewarn "The kernel modules in ${CATEGORY}/${PN} are being built for"
+ ewarn "kernel version ${KV_FULL}. But this does not match the"
+ ewarn "installed version of virtual/dist-kernel."
+ ewarn
+ ewarn "If this is not intentional, the problem may be corrected by"
+ ewarn "using \"eselect kernel\" to set the default kernel version to"
+ ewarn "the same version as the installed version of virtual/dist-kernel."
+ ewarn
+ ewarn "If the distribution kernel is being downgraded, ensure that"
+ ewarn "virtual/dist-kernel is also downgraded to the same version"
+ ewarn "before rebuilding external kernel modules."
+ ewarn
+ fi
}
# @FUNCTION: _modules_sanity_modversion
diff --git a/eclass/llvm.org.eclass b/eclass/llvm.org.eclass
index 3ada7d2a373b..9d2dc78e0d92 100644
--- a/eclass/llvm.org.eclass
+++ b/eclass/llvm.org.eclass
@@ -72,14 +72,11 @@ if [[ -z ${_LLVM_SOURCE_TYPE+1} ]]; then
_LLVM_SOURCE_TYPE=snapshot
case ${PV} in
- 19.0.0_pre20240509)
- EGIT_COMMIT=a7ee81e8279e0bf6e05617a4a638e5f2f8e45022
+ 19.0.0_pre20240525)
+ EGIT_COMMIT=7dc2f6602212bf0a0433c157b70e4fc0d70bb730
;;
- 19.0.0_pre20240504)
- EGIT_COMMIT=76aa042dde6ba9ba57c680950f5818259ee02690
- ;;
- 19.0.0_pre20240427)
- EGIT_COMMIT=338561657685c1831a53563b1bc36ffc7470239e
+ 19.0.0_pre20240518)
+ EGIT_COMMIT=702198fc9ac5dba392f9d9ba7c56467996343c0a
;;
*)
die "Unknown snapshot: ${PV}"
@@ -249,7 +246,7 @@ llvm.org_set_globals() {
"
BDEPEND+="
verify-sig? (
- >=sec-keys/openpgp-keys-llvm-16.0.4
+ >=sec-keys/openpgp-keys-llvm-18.1.6
)
"
VERIFY_SIG_OPENPGP_KEY_PATH=/usr/share/openpgp-keys/llvm.asc
diff --git a/eclass/perl-module.eclass b/eclass/perl-module.eclass
index f32c2c237d05..432d1ab315dd 100644
--- a/eclass/perl-module.eclass
+++ b/eclass/perl-module.eclass
@@ -279,7 +279,6 @@ perl-module_src_configure() {
--config ld="$(tc-getCC)" \
--config nm="$(tc-getNM)" \
--config ranlib="$(tc-getRANLIB)" \
- --config ccflags="${CFLAGS}" \
--config optimize="${CFLAGS}" \
--config ldflags="${LDFLAGS}" \
"${myconf_local[@]}"
diff --git a/eclass/plasma.kde.org.eclass b/eclass/plasma.kde.org.eclass
index 491f1fcecc8c..1a626de37bfb 100644
--- a/eclass/plasma.kde.org.eclass
+++ b/eclass/plasma.kde.org.eclass
@@ -63,7 +63,7 @@ if [[ ${KDE_BUILD_TYPE} == live ]]; then
fi
elif [[ -z ${KDE_ORG_COMMIT} ]]; then
case ${PV} in
- 5.??.[6-9][05]* )
+ 5.??.[6-9][05]* | 6.?.[6-9][05]* )
_KDE_SRC_URI+="unstable/plasma/$(ver_cut 1-3)/"
RESTRICT+=" mirror"
;;
diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
index 275ac3a96523..c47565fa1db2 100644
--- a/eclass/python-utils-r1.eclass
+++ b/eclass/python-utils-r1.eclass
@@ -1321,6 +1321,15 @@ _python_check_occluded_packages() {
# Specifies the number of jobs for parallel (pytest-xdist) test runs.
# When unset, defaults to -j from MAKEOPTS, or the current nproc.
+# @ECLASS_VARIABLE: EPYTEST_FLAGS
+# @USER_VARIABLE
+# @DEFAULT_UNSET
+# @DESCRIPTION:
+# Additional flags to pass to pytest. This is intended to be set
+# in the environment when debugging packages (options such as -x or -s
+# are useful here), rather than globally. It must not be set
+# in ebuilds.
+
# @FUNCTION: epytest
# @USAGE: [<args>...]
# @DESCRIPTION:
@@ -1432,10 +1441,10 @@ epytest() {
for x in "${EPYTEST_IGNORE[@]}"; do
args+=( --ignore "${x}" )
done
- set -- "${EPYTHON}" -m pytest "${args[@]}" "${@}"
+ set -- "${EPYTHON}" -m pytest "${args[@]}" "${@}" ${EPYTEST_FLAGS}
echo "${@}" >&2
- "${@}" || die -n "pytest failed with ${EPYTHON}"
+ "${@}"
local ret=${?}
# remove common temporary directories left over by pytest plugins
@@ -1446,6 +1455,7 @@ epytest() {
find "${BUILD_DIR}" -name '*-pytest-*.pyc' -delete || die
fi
+ [[ ${ret} -ne 0 ]] && die -n "pytest failed with ${EPYTHON}"
return ${ret}
}
diff --git a/eclass/rocm.eclass b/eclass/rocm.eclass
index 9804ecde97d0..7039455dec6b 100644
--- a/eclass/rocm.eclass
+++ b/eclass/rocm.eclass
@@ -1,4 +1,4 @@
-# Copyright 2022-2023 Gentoo Authors
+# Copyright 2022-2024 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
# @ECLASS: rocm.eclass
@@ -161,7 +161,7 @@ _rocm_set_globals() {
gfx906 gfx908 gfx90a gfx1030
)
;;
- 5.*|9999)
+ 5.*)
unofficial_amdgpu_targets=(
gfx803 gfx900 gfx1010 gfx1011 gfx1012
gfx1031 gfx1100 gfx1101 gfx1102
@@ -170,6 +170,16 @@ _rocm_set_globals() {
gfx906 gfx908 gfx90a gfx1030
)
;;
+ 6.*|9999)
+ unofficial_amdgpu_targets=(
+ gfx803 gfx900 gfx940 gfx941
+ gfx1010 gfx1011 gfx1012
+ gfx1031 gfx1101 gfx1102
+ )
+ official_amdgpu_targets=(
+ gfx906 gfx908 gfx90a gfx942 gfx1030 gfx1100
+ )
+ ;;
*)
die "Unknown ROCm major version! Please update rocm.eclass before bumping to new ebuilds"
;;
@@ -201,22 +211,7 @@ unset -f _rocm_set_globals
# Append default target feature to GPU arch. See
# https://llvm.org/docs/AMDGPUUsage.html#target-features
get_amdgpu_flags() {
- local amdgpu_target_flags
- for gpu_target in ${AMDGPU_TARGETS}; do
- local target_feature=
- case ${gpu_target} in
- gfx906|gfx908)
- target_feature=:xnack-
- ;;
- gfx90a)
- target_feature=:xnack+
- ;;
- *)
- ;;
- esac
- amdgpu_target_flags+="${gpu_target}${target_feature};"
- done
- echo "${amdgpu_target_flags}"
+ echo $(printf "%s;" ${AMDGPU_TARGETS[@]})
}
# @FUNCTION: check_amdgpu
diff --git a/eclass/tests/dist-kernel-utils.sh b/eclass/tests/dist-kernel-utils.sh
index 7f04f55ce302..50ba001f8e9c 100755
--- a/eclass/tests/dist-kernel-utils.sh
+++ b/eclass/tests/dist-kernel-utils.sh
@@ -1,14 +1,14 @@
#!/usr/bin/env bash
-# Copyright 2022 Gentoo Authors
+# Copyright 2022-2024 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
source tests-common.sh || exit
+# TODO: hack because tests-common don't implement ver_cut
+source version-funcs.sh || exit
inherit dist-kernel-utils
-# TODO: hack because tests-common don't implement ver_cut
-EAPI=6 inherit eapi7-ver
test_PV_to_KV() {
local kv=${1}
diff --git a/eclass/tests/eapi7-ver.sh b/eclass/tests/eapi7-ver.sh
index 13cd671e7158..ee7e6d728ef7 100755
--- a/eclass/tests/eapi7-ver.sh
+++ b/eclass/tests/eapi7-ver.sh
@@ -1,12 +1,9 @@
#!/bin/bash
-# Copyright 1999-2017 Gentoo Foundation
+# Copyright 1999-2024 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
-EAPI=6
-
source tests-common.sh || exit
-
-inherit eapi7-ver
+source version-funcs.sh || exit
teq() {
local expected=${1}; shift
diff --git a/eclass/tests/eapi7-ver_benchmark.sh b/eclass/tests/eapi7-ver_benchmark.sh
deleted file mode 100755
index ab324edb95c9..000000000000
--- a/eclass/tests/eapi7-ver_benchmark.sh
+++ /dev/null
@@ -1,147 +0,0 @@
-#!/bin/bash
-# Copyright 1999-2017 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-
-EAPI=6
-
-source tests-common.sh || exit
-
-inherit eapi7-ver versionator
-
-cutting() {
- local x
- for x in {1..1000}; do
- ver_cut 1 1.2.3
- ver_cut 1-2 1.2.3
- ver_cut 2- 1.2.3
- ver_cut 1- 1.2.3
- ver_cut 3-4 1.2.3b_alpha4
- ver_cut 5 1.2.3b_alpha4
- ver_cut 1-2 .1.2.3
- ver_cut 0-2 .1.2.3
- ver_cut 2-3 1.2.3.
- ver_cut 2- 1.2.3.
- ver_cut 2-4 1.2.3.
- done >/dev/null
-}
-
-cutting_versionator() {
- local x
- for x in {1..100}; do
- get_version_component_range 1 1.2.3
- get_version_component_range 1-2 1.2.3
- get_version_component_range 2- 1.2.3
- get_version_component_range 1- 1.2.3
- get_version_component_range 3-4 1.2.3b_alpha4
- get_version_component_range 5 1.2.3b_alpha4
- get_version_component_range 1-2 .1.2.3
- get_version_component_range 0-2 .1.2.3
- get_version_component_range 2-3 1.2.3.
- get_version_component_range 2- 1.2.3.
- get_version_component_range 2-4 1.2.3.
- done >/dev/null
-}
-
-replacing() {
- local x
- for x in {1..1000}; do
- ver_rs 1 - 1.2.3
- ver_rs 2 - 1.2.3
- ver_rs 1-2 - 1.2.3.4
- ver_rs 2- - 1.2.3.4
- ver_rs 2 . 1.2-3
- ver_rs 3 . 1.2.3a
- ver_rs 2-3 - 1.2_alpha4
- #ver_rs 3 - 2 "" 1.2.3b_alpha4
- #ver_rs 3-5 _ 4-6 - a1b2c3d4e5
- ver_rs 1 - .1.2.3
- ver_rs 0 - .1.2.3
- done >/dev/null
-}
-
-replacing_versionator() {
- local x
- for x in {1..100}; do
- replace_version_separator 1 - 1.2.3
- replace_version_separator 2 - 1.2.3
- replace_version_separator 1-2 - 1.2.3.4
- replace_version_separator 2- - 1.2.3.4
- replace_version_separator 2 . 1.2-3
- replace_version_separator 3 . 1.2.3a
- replace_version_separator 2-3 - 1.2_alpha4
- #replace_version_separator 3 - 2 "" 1.2.3b_alpha4
- #replace_version_separator 3-5 _ 4-6 - a1b2c3d4e5
- replace_version_separator 1 - .1.2.3
- replace_version_separator 0 - .1.2.3
- done >/dev/null
-}
-
-comparing() {
- local x
- for x in {1..1000}; do
- ver_test 1b_p1 -le 1_p1
- ver_test 1.1b -le 1.1
- ver_test 12.2.5 -le 12.2b
- ver_test 4.0 -le 5.0
- ver_test 5 -le 5.0
- ver_test 1.0_pre2 -le 1.0_p2
- ver_test 1.0_alpha2 -le 1.0_p2
- ver_test 1.0_alpha1 -le 1.0_beta1
- ver_test 1.0_beta3 -le 1.0_rc3
- ver_test 1.001000000000000001 -le 1.001000000000000002
- done
-}
-
-comparing_versionator() {
- local x
- for x in {1..100}; do
- version_is_at_least 1b_p1 1_p1
- version_is_at_least 1.1b 1.1
- version_is_at_least 12.2.5 12.2b
- version_is_at_least 4.0 5.0
- version_is_at_least 5 5.0
- version_is_at_least 1.0_pre2 1.0_p2
- version_is_at_least 1.0_alpha2 1.0_p2
- version_is_at_least 1.0_alpha1 1.0_beta1
- version_is_at_least 1.0_beta3 1.0_rc3
- version_is_at_least 1.001000000000000001 1.001000000000000002
- done
-}
-
-get_times() {
- local factor=${1}; shift
- echo "${*}"
- local real=()
- local user=()
-
- for x in {1..5}; do
- while read tt tv; do
- case ${tt} in
- real) real+=( $(dc -e "${tv} ${factor} * p") );;
- user) user+=( $(dc -e "${tv} ${factor} * p") );;
- esac
- done < <( ( time -p "${@}" ) 2>&1 )
- done
-
- [[ ${#real[@]} == 5 ]] || die "Did not get 5 real times"
- [[ ${#user[@]} == 5 ]] || die "Did not get 5 user times"
-
- local sum
- for v in real user; do
- vr="${v}[*]"
- sum=$(dc -e "${!vr} + + + + 3 k 5 / p")
-
- vr="${v}[@]"
- printf '%s %4.2f %4.2f %4.2f %4.2f %4.2f => %4.2f avg\n' \
- "${v}" "${!vr}" "${sum}"
- done
-}
-
-export LC_ALL=C
-
-get_times 1 cutting
-get_times 10 cutting_versionator
-get_times 1 replacing
-get_times 10 replacing_versionator
-get_times 1 comparing
-get_times 10 comparing_versionator
diff --git a/eclass/tests/edo.sh b/eclass/tests/edo.sh
new file mode 100755
index 000000000000..cac03e0401ba
--- /dev/null
+++ b/eclass/tests/edo.sh
@@ -0,0 +1,113 @@
+#!/bin/bash
+# Copyright 1999-2024 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+source tests-common.sh || exit
+
+inherit edo
+
+make_some_noise() {
+ echo "Here is some noise:"
+ echo "${1:?Must provide some noise}"
+ echo "EoN"
+}
+
+test_edob_simple() {
+ tbegin "edob with output test"
+ (
+ edob make_some_noise foo
+ eend $?
+ ) &> "${T}/edob.out"
+ local res=$?
+ if [[ $res -ne 0 ]]; then
+ tend $res
+ return 0
+ fi
+
+ local log_file="${T}/make_some_noise.log"
+ local second_line="$(sed -n '2p' "${log_file}")"
+ [[ "${second_line}" == "foo" ]];
+ tend $? "Unexpected output, found \"${second_line}\", expected \"foo\""
+
+ rm "${log_file}" || die
+}
+
+test_edob_explicit_log_name() {
+ tbegin "edob with explicit logfile name"
+ (
+ edob -l mylog make_some_noise bar
+ eend $?
+ ) &> "${T}/edob.out"
+ local res=$?
+ if [[ $res -ne 0 ]]; then
+ cat "${T}/edob.out"
+ tend $res
+ return 0
+ fi
+
+ local log_file="${T}/mylog.log"
+ local second_line="$(sed -n '2p' "${log_file}")"
+ [[ "${second_line}" == "bar" ]];
+ tend $? "Unexpected output, found \"${second_line}\", expected \"foo\""
+
+ rm "${log_file}" || die
+}
+
+test_edob_explicit_message() {
+ tbegin "edob with explicit message"
+ (
+ edob -m "Making some noise" make_some_noise baz
+ eend $?
+ ) &> "${T}/edob.out"
+ local res=$?
+ if [[ $res -ne 0 ]]; then
+ cat "${T}/edob.out"
+ tend $res
+ return 0
+ fi
+
+ local log_file="${T}/make_some_noise.log"
+ local second_line="$(sed -n '2p' "${log_file}")"
+ [[ "${second_line}" == "baz" ]];
+ tend $? "Unexpected output, found \"${second_line}\", expected \"baz\""
+
+ rm "${log_file}" || die
+}
+
+test_edob_failure() {
+ make_some_noise_and_fail() {
+ make_some_noise "$@"
+ return 1
+ }
+
+ tbegin "edob with failing command"
+ (
+ edob -m "Making some noise" make_some_noise_and_fail quz
+ eend $?
+ ) &> "${T}/edob.out"
+ local res=$?
+ # Now, this time we expect res to be exactly '1'.
+ if [[ $res -ne 1 ]]; then
+ tend 1
+ return 1
+ fi
+
+ local log_file="${T}/make_some_noise_and_fail.log"
+ local second_line="$(sed -n '2p' "${log_file}")"
+ [[ "${second_line}" == "quz" ]];
+ tend $? "Unexpected output, found \"${second_line}\", expected \"quz\""
+
+ rm "${log_file}" || die
+
+ local fourth_line_of_edob_out="$(sed -n '4p' "${T}/edob.out")"
+ [[ "${fourth_line_of_edob_out}" == "quz" ]];
+ tend $? "Unexpected output, found \"${fourth_line_of_edob_out}\", expected \"quz\""
+}
+
+test_edob_simple
+test_edob_explicit_log_name
+test_edob_explicit_message
+test_edob_failure
+
+texit
diff --git a/eclass/tests/toolchain.sh b/eclass/tests/toolchain.sh
index 1f21e7d842b1..6f8df5b4fc4a 100755
--- a/eclass/tests/toolchain.sh
+++ b/eclass/tests/toolchain.sh
@@ -1,5 +1,5 @@
#!/bin/bash
-# Copyright 1999-2023 Gentoo Authors
+# Copyright 1999-2024 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
@@ -9,8 +9,8 @@ TOOLCHAIN_GCC_PV=11.3.0
PR=r0
source tests-common.sh || exit
+source version-funcs.sh || exit
-EAPI=6 inherit eapi7-ver
EAPI=7 inherit toolchain
# Ignore actually running version of gcc and fake new version
diff --git a/eclass/tests/version-funcs.sh b/eclass/tests/version-funcs.sh
new file mode 100644
index 000000000000..6e83c01666f0
--- /dev/null
+++ b/eclass/tests/version-funcs.sh
@@ -0,0 +1,302 @@
+#!/bin/bash
+# Copyright 1999-2024 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+# @ECLASS: eapi7-ver.eclass
+# @MAINTAINER:
+# PMS team <pms@gentoo.org>
+# @AUTHOR:
+# Ulrich Müller <ulm@gentoo.org>
+# Michał Górny <mgorny@gentoo.org>
+# @BLURB: Testing implementation of EAPI 7 version manipulators
+# @DESCRIPTION:
+# A stand-alone implementation of the version manipulation functions
+# aimed for EAPI 7. Intended to be used for wider testing of
+# the proposed functions and to allow ebuilds to switch to the new
+# model early, with minimal change needed for actual EAPI 7.
+#
+# https://bugs.gentoo.org/482170
+#
+# @SUBSECTION Version strings
+#
+# The functions support arbitrary version strings consisting of version
+# components interspersed with (possibly empty) version separators.
+#
+# A version component can either consist purely of digits ([0-9]+)
+# or purely of uppercase and lowercase letters ([A-Za-z]+). A version
+# separator is either a string of any other characters ([^A-Za-z0-9]+),
+# or it occurs at the transition between a sequence of letters
+# and a sequence of digits, or vice versa. In the latter case,
+# the version separator is an empty string.
+#
+# The version is processed left-to-right, and each successive component
+# is assigned numbers starting with 1. The components are either split
+# on version separators or on boundaries between digits and letters
+# (in which case the separator between the components is empty).
+# Version separators are assigned numbers starting with 1 for
+# the separator between 1st and 2nd components. As a special case,
+# if the version string starts with a separator, it is assigned index 0.
+#
+# Examples:
+#
+# @CODE
+# 1.2b-alpha4 -> 1 . 2 '' b - alpha '' 4
+# c s c s c s c s c
+# 1 1 2 2 3 3 4 4 5
+#
+# .11. -> . 11 .
+# s c s
+# 0 1 1
+# @CODE
+#
+# @SUBSECTION Ranges
+#
+# A range can be specified as 'm' for m-th version component, 'm-'
+# for all components starting with m-th or 'm-n' for components starting
+# at m-th and ending at n-th (inclusive). If the range spans outside
+# the version string, it is truncated silently.
+
+# @FUNCTION: _ver_parse_range
+# @USAGE: <range> <max>
+# @INTERNAL
+# @DESCRIPTION:
+# Parse the range string <range>, setting 'start' and 'end' variables
+# to the appropriate bounds. <max> specifies the appropriate upper
+# bound for the range; the user-specified value is truncated to this.
+_ver_parse_range() {
+ local range=${1}
+ local max=${2}
+
+ [[ ${range} == [0-9]* ]] \
+ || die "${FUNCNAME}: range must start with a number"
+ start=${range%-*}
+ [[ ${range} == *-* ]] && end=${range#*-} || end=${start}
+ if [[ ${end} ]]; then
+ [[ ${start} -le ${end} ]] \
+ || die "${FUNCNAME}: end of range must be >= start"
+ [[ ${end} -le ${max} ]] || end=${max}
+ else
+ end=${max}
+ fi
+}
+
+# @FUNCTION: _ver_split
+# @USAGE: <version>
+# @INTERNAL
+# @DESCRIPTION:
+# Split the version string <version> into separator-component array.
+# Sets 'comp' to an array of the form: ( s_0 c_1 s_1 c_2 s_2 c_3... )
+# where s_i are separators and c_i are components.
+_ver_split() {
+ local v=${1} LC_ALL=C
+
+ comp=()
+
+ # get separators and components
+ local s c
+ while [[ ${v} ]]; do
+ # cut the separator
+ s=${v%%[a-zA-Z0-9]*}
+ v=${v:${#s}}
+ # cut the next component; it can be either digits or letters
+ [[ ${v} == [0-9]* ]] && c=${v%%[^0-9]*} || c=${v%%[^a-zA-Z]*}
+ v=${v:${#c}}
+
+ comp+=( "${s}" "${c}" )
+ done
+}
+
+# @FUNCTION: ver_cut
+# @USAGE: <range> [<version>]
+# @DESCRIPTION:
+# Print the substring of the version string containing components
+# defined by the <range> and the version separators between them.
+# Processes <version> if specified, ${PV} otherwise.
+#
+# For the syntax of versions and ranges, please see the eclass
+# description.
+ver_cut() {
+ local range=${1}
+ local v=${2:-${PV}}
+ local start end
+ local -a comp
+
+ _ver_split "${v}"
+ local max=$((${#comp[@]}/2))
+ _ver_parse_range "${range}" "${max}"
+
+ if [[ ${start} -gt 0 ]]; then
+ start=$(( start*2 - 1 ))
+ fi
+ # Work around a bug in bash-3.2, where "${comp[*]:start:end*2-start}"
+ # inserts stray 0x7f characters for empty array elements
+ printf "%s" "${comp[@]:start:end*2-start}" $'\n'
+}
+
+# @FUNCTION: ver_rs
+# @USAGE: <range> <repl> [<range> <repl>...] [<version>]
+# @DESCRIPTION:
+# Print the version string after substituting the specified version
+# separators at <range> with <repl> (string). Multiple '<range> <repl>'
+# pairs can be specified. Processes <version> if specified,
+# ${PV} otherwise.
+#
+# For the syntax of versions and ranges, please see the eclass
+# description.
+ver_rs() {
+ local v
+ (( ${#} & 1 )) && v=${@: -1} || v=${PV}
+ local start end i
+ local -a comp
+
+ _ver_split "${v}"
+ local max=$((${#comp[@]}/2 - 1))
+
+ while [[ ${#} -ge 2 ]]; do
+ _ver_parse_range "${1}" "${max}"
+ for (( i = start*2; i <= end*2; i+=2 )); do
+ [[ ${i} -eq 0 && -z ${comp[i]} ]] && continue
+ comp[i]=${2}
+ done
+ shift 2
+ done
+
+ local IFS=
+ echo "${comp[*]}"
+}
+
+# @FUNCTION: _ver_compare_int
+# @USAGE: <a> <b>
+# @RETURN: 0 if <a> -eq <b>, 1 if <a> -lt <b>, 3 if <a> -gt <b>
+# @INTERNAL
+# @DESCRIPTION:
+# Compare two non-negative integers <a> and <b>, of arbitrary length.
+# If <a> is equal to, less than, or greater than <b>, return 0, 1, or 3
+# as exit status, respectively.
+_ver_compare_int() {
+ local a=$1 b=$2 d=$(( ${#1}-${#2} ))
+
+ # Zero-pad to equal length if necessary.
+ if [[ ${d} -gt 0 ]]; then
+ printf -v b "%0${d}d%s" 0 "${b}"
+ elif [[ ${d} -lt 0 ]]; then
+ printf -v a "%0$(( -d ))d%s" 0 "${a}"
+ fi
+
+ [[ ${a} > ${b} ]] && return 3
+ [[ ${a} == "${b}" ]]
+}
+
+# @FUNCTION: _ver_compare
+# @USAGE: <va> <vb>
+# @RETURN: 1 if <va> < <vb>, 2 if <va> = <vb>, 3 if <va> > <vb>
+# @INTERNAL
+# @DESCRIPTION:
+# Compare two versions <va> and <vb>. If <va> is less than, equal to,
+# or greater than <vb>, return 1, 2, or 3 as exit status, respectively.
+_ver_compare() {
+ local va=${1} vb=${2} a an al as ar b bn bl bs br re LC_ALL=C
+
+ re="^([0-9]+(\.[0-9]+)*)([a-z]?)((_(alpha|beta|pre|rc|p)[0-9]*)*)(-r[0-9]+)?$"
+
+ [[ ${va} =~ ${re} ]] || die "${FUNCNAME}: invalid version: ${va}"
+ an=${BASH_REMATCH[1]}
+ al=${BASH_REMATCH[3]}
+ as=${BASH_REMATCH[4]}
+ ar=${BASH_REMATCH[7]}
+
+ [[ ${vb} =~ ${re} ]] || die "${FUNCNAME}: invalid version: ${vb}"
+ bn=${BASH_REMATCH[1]}
+ bl=${BASH_REMATCH[3]}
+ bs=${BASH_REMATCH[4]}
+ br=${BASH_REMATCH[7]}
+
+ # Compare numeric components (PMS algorithm 3.2)
+ # First component
+ _ver_compare_int "${an%%.*}" "${bn%%.*}" || return
+
+ while [[ ${an} == *.* && ${bn} == *.* ]]; do
+ # Other components (PMS algorithm 3.3)
+ an=${an#*.}
+ bn=${bn#*.}
+ a=${an%%.*}
+ b=${bn%%.*}
+ if [[ ${a} == 0* || ${b} == 0* ]]; then
+ # Remove any trailing zeros
+ [[ ${a} =~ 0+$ ]] && a=${a%"${BASH_REMATCH[0]}"}
+ [[ ${b} =~ 0+$ ]] && b=${b%"${BASH_REMATCH[0]}"}
+ [[ ${a} > ${b} ]] && return 3
+ [[ ${a} < ${b} ]] && return 1
+ else
+ _ver_compare_int "${a}" "${b}" || return
+ fi
+ done
+ [[ ${an} == *.* ]] && return 3
+ [[ ${bn} == *.* ]] && return 1
+
+ # Compare letter components (PMS algorithm 3.4)
+ [[ ${al} > ${bl} ]] && return 3
+ [[ ${al} < ${bl} ]] && return 1
+
+ # Compare suffixes (PMS algorithm 3.5)
+ as=${as#_}${as:+_}
+ bs=${bs#_}${bs:+_}
+ while [[ -n ${as} && -n ${bs} ]]; do
+ # Compare each suffix (PMS algorithm 3.6)
+ a=${as%%_*}
+ b=${bs%%_*}
+ if [[ ${a%%[0-9]*} == "${b%%[0-9]*}" ]]; then
+ _ver_compare_int "${a##*[a-z]}" "${b##*[a-z]}" || return
+ else
+ # Check for p first
+ [[ ${a%%[0-9]*} == p ]] && return 3
+ [[ ${b%%[0-9]*} == p ]] && return 1
+ # Hack: Use that alpha < beta < pre < rc alphabetically
+ [[ ${a} > ${b} ]] && return 3 || return 1
+ fi
+ as=${as#*_}
+ bs=${bs#*_}
+ done
+ if [[ -n ${as} ]]; then
+ [[ ${as} == p[_0-9]* ]] && return 3 || return 1
+ elif [[ -n ${bs} ]]; then
+ [[ ${bs} == p[_0-9]* ]] && return 1 || return 3
+ fi
+
+ # Compare revision components (PMS algorithm 3.7)
+ _ver_compare_int "${ar#-r}" "${br#-r}" || return
+
+ return 2
+}
+
+# @FUNCTION: ver_test
+# @USAGE: [<v1>] <op> <v2>
+# @DESCRIPTION:
+# Check if the relation <v1> <op> <v2> is true. If <v1> is not specified,
+# default to ${PVR}. <op> can be -gt, -ge, -eq, -ne, -le, -lt.
+# Both versions must conform to the PMS version syntax (with optional
+# revision parts), and the comparison is performed according to
+# the algorithm specified in the PMS.
+ver_test() {
+ local va op vb
+
+ if [[ $# -eq 3 ]]; then
+ va=${1}
+ shift
+ else
+ va=${PVR}
+ fi
+
+ [[ $# -eq 2 ]] || die "${FUNCNAME}: bad number of arguments"
+
+ op=${1}
+ vb=${2}
+
+ case ${op} in
+ -eq|-ne|-lt|-le|-gt|-ge) ;;
+ *) die "${FUNCNAME}: invalid operator: ${op}" ;;
+ esac
+
+ _ver_compare "${va}" "${vb}"
+ test $? "${op}" 2
+}
diff --git a/eclass/texlive-common.eclass b/eclass/texlive-common.eclass
index 15d475799a88..072581dde78e 100644
--- a/eclass/texlive-common.eclass
+++ b/eclass/texlive-common.eclass
@@ -22,6 +22,8 @@ case ${EAPI} in
*) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
esac
+inherit edo
+
if [[ -z ${_TEXLIVE_COMMON_ECLASS} ]]; then
_TEXLIVE_COMMON_ECLASS=1
@@ -199,9 +201,9 @@ etexmf-update() {
efmtutil-sys() {
if has_version 'app-text/texlive-core' ; then
if [[ -z ${ROOT} && -x "${EPREFIX}"/usr/bin/fmtutil-sys ]] ; then
- einfo "Rebuilding formats"
- "${EPREFIX}"/usr/bin/fmtutil-sys --all &> /dev/null ||
- die -n "fmtutil-sys returned non-zero exit status ${?}"
+ edob -m "Rebuilding TexLive formats" \
+ -l fmtutils-sys-all \
+ "${EPREFIX}"/usr/bin/fmtutil-sys --all
else
ewarn "Cannot run fmtutil-sys for some reason."
ewarn "Your formats might be inconsistent with your installed ${PN} version"
diff --git a/eclass/texlive-module.eclass b/eclass/texlive-module.eclass
index da33e25a39dc..d7ec59c25a8a 100644
--- a/eclass/texlive-module.eclass
+++ b/eclass/texlive-module.eclass
@@ -360,7 +360,7 @@ texlive-module_src_install() {
cp -pR texmf-doc "${ED}/usr/share/" || die
fi
- if ver_test -ge 2023 && [[ ${CATEGORY} == dev-texlive ]]; then
+ if ver_test -ge 2023 && [[ -d texmf-dist/doc/man && ${CATEGORY} == dev-texlive ]]; then
local texlive_core_man_pages=(
afm2pl.1
aleph.1
@@ -538,9 +538,13 @@ texlive-module_src_install() {
ebegin "Installing man pages"
find texmf-dist/doc/man -type f -name '*.[0-9n]' -print |
grep -v "${grep_expressions[@]}" |
- xargs -d '\n' --no-run-if-empty doman
- [[ "${PIPESTATUS[*]}" =~ ^0(" 0")*$ ]]
- eend $? || die "error installing man pages"
+ xargs -d '\n' --no-run-if-empty nonfatal doman
+ local pipestatus="${PIPESTATUS[*]}"
+ # The grep in the middle of the pipe may return 1 in case
+ # everything from the input is dropped.
+ # See https://bugs.gentoo.org/931994
+ [[ ${pipestatus} == "0 "[01]" 0" ]]
+ eend $? || die "error installing man pages (pipestatus: ${pipestatus})"
# Delete all man pages under texmf-dist/doc/man
find texmf-dist/doc/man -type f -name '*.[0-9n]' -delete ||
diff --git a/eclass/toolchain.eclass b/eclass/toolchain.eclass
index 25dedd4e5262..7d69f3b90e91 100644
--- a/eclass/toolchain.eclass
+++ b/eclass/toolchain.eclass
@@ -393,7 +393,7 @@ fi
# TODO: Add a pkg_setup & pkg_pretend check for whether the active compiler
# supports Ada.
-if tc_has_feature ada ; then
+if [[ ${PN} != gnat-gpl ]] && tc_has_feature ada ; then
BDEPEND+=" ada? ( || ( sys-devel/gcc[ada] dev-lang/gnat-gpl[ada] ) )"
fi