diff options
Diffstat (limited to 'eclass')
142 files changed, 4484 insertions, 2766 deletions
diff --git a/eclass/Manifest.gz b/eclass/Manifest.gz Binary files differindex 495d2358ba33..ed1c0911ab22 100644 --- a/eclass/Manifest.gz +++ b/eclass/Manifest.gz diff --git a/eclass/acct-group.eclass b/eclass/acct-group.eclass index 2c2c88cfc7e1..00908dbd8982 100644 --- a/eclass/acct-group.eclass +++ b/eclass/acct-group.eclass @@ -78,7 +78,7 @@ ACCT_GROUP_NAME=${PN} # << Boilerplate ebuild variables >> : "${DESCRIPTION:="System group: ${ACCT_GROUP_NAME}"}" : "${SLOT:=0}" -: "${KEYWORDS:=~alpha amd64 arm arm64 hppa ~ia64 ~loong ~m68k ~mips ppc ppc64 ~riscv ~s390 sparc x86 ~amd64-linux ~x86-linux ~arm64-macos ~ppc-macos ~x64-macos ~x64-solaris}" +: "${KEYWORDS:=~alpha amd64 arm arm64 hppa ~loong ~m68k ~mips ppc ppc64 ~riscv ~s390 sparc x86 ~amd64-linux ~x86-linux ~arm64-macos ~ppc-macos ~x64-macos ~x64-solaris}" S=${WORKDIR} diff --git a/eclass/acct-user.eclass b/eclass/acct-user.eclass index 9eab1f4c4ae6..19c5239eaede 100644 --- a/eclass/acct-user.eclass +++ b/eclass/acct-user.eclass @@ -144,7 +144,7 @@ ACCT_USER_NAME=${PN} # << Boilerplate ebuild variables >> : "${DESCRIPTION:="System user: ${ACCT_USER_NAME}"}" : "${SLOT:=0}" -: "${KEYWORDS:=~alpha amd64 arm arm64 hppa ~ia64 ~loong ~m68k ~mips ppc ppc64 ~riscv ~s390 sparc x86 ~amd64-linux ~x86-linux ~arm64-macos ~ppc-macos ~x64-macos ~x64-solaris}" +: "${KEYWORDS:=~alpha amd64 arm arm64 hppa ~loong ~m68k ~mips ppc ppc64 ~riscv ~s390 sparc x86 ~amd64-linux ~x86-linux ~arm64-macos ~ppc-macos ~x64-macos ~x64-solaris}" S=${WORKDIR} diff --git a/eclass/apache-module.eclass b/eclass/apache-module.eclass index 5a84ffedf71a..07bdb79e08a2 100644 --- a/eclass/apache-module.eclass +++ b/eclass/apache-module.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: apache-module.eclass @@ -44,14 +44,19 @@ # </IfDefine> # @CODE -case ${EAPI} in - 6|7|8) ;; - *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; -esac if [[ -z ${_APACHE_MODULE_ECLASS} ]]; then _APACHE_MODULE_ECLASS=1 +case ${EAPI} in + 6) + ewarn "${CATEGORY}/${PF}: ebuild uses ${ECLASS} with deprecated EAPI ${EAPI}!" + ewarn "${CATEGORY}/${PF}: Support will be removed on 2024-10-08. Please port to newer EAPI." + ;; + 7|8) ;; + *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; +esac + inherit depend.apache # ============================================================================== diff --git a/eclass/autotools.eclass b/eclass/autotools.eclass index a456e9b9f589..0571b18ba525 100644 --- a/eclass/autotools.eclass +++ b/eclass/autotools.eclass @@ -13,11 +13,6 @@ # Note: We require GNU m4, as does autoconf. So feel free to use any features # from the GNU version of m4 without worrying about other variants (i.e. BSD). -case ${EAPI} in - 6|7|8) ;; - *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; -esac - if [[ ${_AUTOTOOLS_AUTO_DEPEND+set} == "set" ]] ; then # See if we were included already, but someone changed the value # of AUTOTOOLS_AUTO_DEPEND on us. We could reload the entire @@ -31,6 +26,15 @@ fi if [[ -z ${_AUTOTOOLS_ECLASS} ]] ; then _AUTOTOOLS_ECLASS=1 +case ${EAPI} in + 6) + ewarn "${CATEGORY}/${PF}: ebuild uses ${ECLASS} with deprecated EAPI ${EAPI}!" + ewarn "${CATEGORY}/${PF}: Support will be removed on 2024-10-08. Please port to newer EAPI." + ;; + 7|8) ;; + *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; +esac + [[ ${EAPI} == 6 ]] && inherit eqawarn GNUCONFIG_AUTO_DEPEND=no @@ -94,7 +98,7 @@ _LATEST_AUTOCONF=( 2.72-r1:2.72 2.71-r6:2.71 ) # Do NOT change this variable in your ebuilds! # If you want to force a newer minor version, you can specify the correct # WANT value by using a colon: <PV>:<WANT_AUTOMAKE> -_LATEST_AUTOMAKE=( 1.16.5:1.16 ) +_LATEST_AUTOMAKE=( 1.17-r1:1.17 1.16.5:1.16 ) _automake_atom="dev-build/automake" _autoconf_atom="dev-build/autoconf" diff --git a/eclass/bash-completion-r1.eclass b/eclass/bash-completion-r1.eclass index df1a2a54d39a..be506793ae94 100644 --- a/eclass/bash-completion-r1.eclass +++ b/eclass/bash-completion-r1.eclass @@ -1,4 +1,4 @@ -# Copyright 1999-2022 Gentoo Authors +# Copyright 1999-2024 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 # @ECLASS: bash-completion-r1.eclass @@ -29,7 +29,11 @@ _BASH_COMPLETION_R1_ECLASS=1 inherit toolchain-funcs case ${EAPI} in - 5|6|7|8) ;; + 6) + ewarn "${CATEGORY}/${PF}: ebuild uses ${ECLASS} with deprecated EAPI ${EAPI}!" + ewarn "${CATEGORY}/${PF}: Support will be removed on 2024-10-08. Please port to newer EAPI." + ;; + 7|8) ;; *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; esac diff --git a/eclass/bzr.eclass b/eclass/bzr.eclass deleted file mode 100644 index d522326773e1..000000000000 --- a/eclass/bzr.eclass +++ /dev/null @@ -1,257 +0,0 @@ -# Copyright 1999-2023 Gentoo Authors -# Distributed under the terms of the GNU General Public License v2 - -# @ECLASS: bzr.eclass -# @MAINTAINER: -# Ulrich Müller <ulm@gentoo.org> -# @AUTHOR: -# Jorge Manuel B. S. Vicetto <jmbsvicetto@gentoo.org> -# Mark Lee <bzr-gentoo-overlay@lazymalevolence.com> -# Ulrich Müller <ulm@gentoo.org> -# Christian Faulhammer <fauli@gentoo.org> -# @SUPPORTED_EAPIS: 7 8 -# @BLURB: generic fetching functions for the Bazaar VCS -# @DESCRIPTION: -# The bzr.eclass provides functions to fetch and unpack sources from -# repositories of the Bazaar distributed version control system. -# The eclass was originally derived from git.eclass. -# -# Note: Just set EBZR_REPO_URI to the URI of the branch and src_unpack() -# of this eclass will export the branch to ${WORKDIR}/${P}. - -case ${EAPI} in - 7|8) ;; - *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; -esac - -PROPERTIES+=" live" - -BDEPEND="dev-vcs/breezy" - -# @ECLASS_VARIABLE: EBZR_STORE_DIR -# @USER_VARIABLE -# @DESCRIPTION: -# The directory to store all fetched Bazaar live sources. -: "${EBZR_STORE_DIR:=${PORTAGE_ACTUAL_DISTDIR:-${DISTDIR}}/bzr-src}" - -# @ECLASS_VARIABLE: EBZR_UNPACK_DIR -# @DESCRIPTION: -# The working directory where the sources are copied to. -: "${EBZR_UNPACK_DIR:=${WORKDIR}/${P}}" - -# @ECLASS_VARIABLE: EBZR_INIT_REPO_CMD -# @DESCRIPTION: -# The Bazaar command to initialise a shared repository. -: "${EBZR_INIT_REPO_CMD:="brz init-shared-repository --no-trees"}" - -# @ECLASS_VARIABLE: EBZR_FETCH_CMD -# @DESCRIPTION: -# The Bazaar command to fetch the sources. -: "${EBZR_FETCH_CMD:="brz branch --no-tree"}" - -# @ECLASS_VARIABLE: EBZR_UPDATE_CMD -# @DESCRIPTION: -# The Bazaar command to update the sources. -: "${EBZR_UPDATE_CMD:="brz pull --overwrite-tags"}" - -# @ECLASS_VARIABLE: EBZR_EXPORT_CMD -# @DESCRIPTION: -# The Bazaar command to export a branch. -: "${EBZR_EXPORT_CMD:="brz export"}" - -# @ECLASS_VARIABLE: EBZR_CHECKOUT_CMD -# @DESCRIPTION: -# The Bazaar command to checkout a branch. -: "${EBZR_CHECKOUT_CMD:="brz checkout --lightweight -q"}" - -# @ECLASS_VARIABLE: EBZR_REVNO_CMD -# @DESCRIPTION: -# The Bazaar command to list a revision number of the branch. -: "${EBZR_REVNO_CMD:="brz revno"}" - -# @ECLASS_VARIABLE: EBZR_OPTIONS -# @DEFAULT_UNSET -# @DESCRIPTION: -# The options passed to the fetch and update commands. - -# @ECLASS_VARIABLE: EBZR_REPO_URI -# @DEFAULT_UNSET -# @REQUIRED -# @DESCRIPTION: -# The repository URI for the source package. - -# @ECLASS_VARIABLE: EBZR_PROJECT -# @DESCRIPTION: -# The project name of your ebuild. Normally, the branch will be stored -# in the ${EBZR_STORE_DIR}/${EBZR_PROJECT} directory. -# -# If EBZR_BRANCH is set (see below), then a shared repository will be -# created in that directory, and the branch will be located in -# ${EBZR_STORE_DIR}/${EBZR_PROJECT}/${EBZR_BRANCH}. -: "${EBZR_PROJECT:=${PN}}" - -# @ECLASS_VARIABLE: EBZR_BRANCH -# @DEFAULT_UNSET -# @DESCRIPTION: -# The directory where to store the branch within a shared repository, -# relative to ${EBZR_STORE_DIR}/${EBZR_PROJECT}. -# -# This variable should be set if there are several live ebuilds for -# different branches of the same upstream project. The branches can -# then share the same repository in EBZR_PROJECT, which will save both -# data traffic volume and disk space. -# -# If there is only a live ebuild for one single branch, EBZR_BRANCH -# needs not be set. In this case, the branch will be stored in a -# stand-alone repository directly in EBZR_PROJECT. - -# @ECLASS_VARIABLE: EBZR_REVISION -# @DEFAULT_UNSET -# @DESCRIPTION: -# Revision to fetch, defaults to the latest (see brz help revisionspec). - -# @ECLASS_VARIABLE: EBZR_OFFLINE -# @USER_VARIABLE -# @DESCRIPTION: -# Set this variable to a non-empty value to disable automatic updating -# of a bzr source tree. This is intended to be set outside the ebuild -# by users. -: "${EBZR_OFFLINE=${EVCS_OFFLINE}}" - -# @ECLASS_VARIABLE: EVCS_UMASK -# @USER_VARIABLE -# @DEFAULT_UNSET -# @DESCRIPTION: -# Set this variable to a custom umask. This is intended to be set by -# users. By setting this to something like 002, it can make life easier -# for people who do development as non-root (but are in the portage -# group), and then switch over to building with FEATURES=userpriv. -# Or vice-versa. Shouldn't be a security issue here as anyone who has -# portage group write access already can screw the system over in more -# creative ways. - -# @ECLASS_VARIABLE: EBZR_WORKDIR_CHECKOUT -# @DEFAULT_UNSET -# @DESCRIPTION: -# If this variable is set to a non-empty value, EBZR_CHECKOUT_CMD will -# be used instead of EBZR_EXPORT_CMD to copy the sources to WORKDIR. - -# @FUNCTION: _bzr_initial_fetch -# @USAGE: <repository URI> <branch directory> -# @INTERNAL -# @DESCRIPTION: -# Internal function, retrieves the source code from a repository for the -# first time, using ${EBZR_FETCH_CMD}. -_bzr_initial_fetch() { - local repo_uri=$1 branch_dir=$2 - - if [[ -n ${EBZR_OFFLINE} ]]; then - die "EBZR_OFFLINE cannot be used when there is no local branch yet." - fi - - # fetch branch - einfo "bzr branch start -->" - einfo " repository: ${repo_uri} => ${branch_dir}" - - ${EBZR_FETCH_CMD} ${EBZR_OPTIONS} "${repo_uri}" "${branch_dir}" \ - || die "${ECLASS}: can't branch from ${repo_uri}" -} - -# @FUNCTION: _bzr_update -# @USAGE: <repository URI> <branch directory> -# @INTERNAL -# @DESCRIPTION: -# Internal function, updates the source code from a repository, using -# ${EBZR_UPDATE_CMD}. -_bzr_update() { - local repo_uri=$1 branch_dir=$2 - - if [[ -n ${EBZR_OFFLINE} ]]; then - einfo "skipping bzr pull -->" - einfo " repository: ${repo_uri}" - else - # update branch - einfo "bzr pull start -->" - einfo " repository: ${repo_uri}" - - pushd "${branch_dir}" > /dev/null \ - || die "${ECLASS}: can't chdir to ${branch_dir}" - ${EBZR_UPDATE_CMD} ${EBZR_OPTIONS} "${repo_uri}" \ - || die "${ECLASS}: can't pull from ${repo_uri}" - popd > /dev/null || die "${ECLASS}: popd failed" - fi -} - -# @FUNCTION: bzr_fetch -# @DESCRIPTION: -# Wrapper function to fetch sources from a Bazaar repository with -# bzr branch or bzr pull, depending on whether there is an existing -# working copy. -bzr_fetch() { - local repo_dir branch_dir save_umask - - [[ -n ${EBZR_REPO_URI} ]] || die "${ECLASS}: EBZR_REPO_URI is empty" - - if [[ ! -d ${EBZR_STORE_DIR} ]]; then - ( - addwrite / - mkdir -p "${EBZR_STORE_DIR}" \ - || die "${ECLASS}: can't mkdir ${EBZR_STORE_DIR}" - ) - fi - - pushd "${EBZR_STORE_DIR}" > /dev/null \ - || die "${ECLASS}: can't chdir to ${EBZR_STORE_DIR}" - - repo_dir=${EBZR_STORE_DIR}/${EBZR_PROJECT} - branch_dir=${repo_dir}${EBZR_BRANCH:+/${EBZR_BRANCH}} - - if [[ -n ${EVCS_UMASK} ]]; then - save_umask=$(umask) || die - umask "${EVCS_UMASK}" || die - fi - addwrite "${EBZR_STORE_DIR}" - - if [[ ! -d ${branch_dir}/.bzr ]]; then - if [[ ${repo_dir} != "${branch_dir}" && ! -d ${repo_dir}/.bzr ]]; then - einfo "creating shared bzr repository: ${repo_dir}" - ${EBZR_INIT_REPO_CMD} "${repo_dir}" \ - || die "${ECLASS}: can't create shared repository" - fi - _bzr_initial_fetch "${EBZR_REPO_URI}" "${branch_dir}" - else - _bzr_update "${EBZR_REPO_URI}" "${branch_dir}" - fi - - if [[ -n ${save_umask} ]]; then - umask "${save_umask}" || die - fi - - cd "${branch_dir}" || die "${ECLASS}: can't chdir to ${branch_dir}" - - # Save revision number in environment. #311101 - export EBZR_REVNO=$(${EBZR_REVNO_CMD}) - - if [[ -n ${EBZR_WORKDIR_CHECKOUT} ]]; then - einfo "checking out ..." - ${EBZR_CHECKOUT_CMD} ${EBZR_REVISION:+-r ${EBZR_REVISION}} \ - . "${EBZR_UNPACK_DIR}" || die "${ECLASS}: checkout failed" - else - einfo "exporting ..." - ${EBZR_EXPORT_CMD} ${EBZR_REVISION:+-r ${EBZR_REVISION}} \ - "${EBZR_UNPACK_DIR}" . || die "${ECLASS}: export failed" - fi - einfo \ - "revision ${EBZR_REVISION:-${EBZR_REVNO}} is now in ${EBZR_UNPACK_DIR}" - - popd > /dev/null || die "${ECLASS}: popd failed" -} - -# @FUNCTION: bzr_src_unpack -# @DESCRIPTION: -# Default src_unpack(), calls bzr_fetch. -bzr_src_unpack() { - bzr_fetch -} - -EXPORT_FUNCTIONS src_unpack diff --git a/eclass/cargo.eclass b/eclass/cargo.eclass index a685cd99fb38..3a63e5027250 100644 --- a/eclass/cargo.eclass +++ b/eclass/cargo.eclass @@ -7,11 +7,11 @@ # @AUTHOR: # Doug Goldstein <cardoe@gentoo.org> # Georgy Yakovlev <gyakovlev@gentoo.org> -# @SUPPORTED_EAPIS: 7 8 +# @SUPPORTED_EAPIS: 8 # @BLURB: common functions and variables for cargo builds case ${EAPI} in - 7|8) ;; + 8) ;; *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; esac @@ -23,10 +23,6 @@ _CARGO_ECLASS=1 RUST_DEPEND="virtual/rust" case ${EAPI} in - 7) - # 1.37 added 'cargo vendor' subcommand and net.offline config knob - RUST_DEPEND=">=virtual/rust-1.37.0" - ;; 8) # 1.39 added --workspace # 1.46 added --target dir @@ -38,7 +34,7 @@ case ${EAPI} in ;; esac -inherit flag-o-matic multiprocessing toolchain-funcs +inherit flag-o-matic multiprocessing rust-toolchain toolchain-funcs [[ ! ${CARGO_OPTIONAL} ]] && BDEPEND="${RUST_DEPEND}" @@ -52,7 +48,7 @@ ECARGO_VENDOR="${ECARGO_HOME}/gentoo" # @PRE_INHERIT # @DESCRIPTION: # Bash string containing all crates that are to be downloaded. -# It is used by cargo_crate_uris. +# It is used by cargo_crate_uris. Typically generated by app-portage/pycargoebuild. # # Ideally, crate names and versions should be separated by a `@` # character. A legacy syntax using hyphen is also supported but it is @@ -113,7 +109,7 @@ ECARGO_VENDOR="${ECARGO_HOME}/gentoo" # # If you enable CARGO_OPTIONAL, you have to set BDEPEND on virtual/rust # for your package and call at least cargo_gen_config manually before using -# other src_functions of this eclass. +# other src_functions or cargo_env of this eclass. # Note that cargo_gen_config is automatically called by cargo_src_unpack. # @ECLASS_VARIABLE: myfeatures @@ -252,7 +248,7 @@ cargo_crate_uris() { # @FUNCTION: cargo_gen_config # @DESCRIPTION: -# Generate the $CARGO_HOME/config necessary to use our local registry and settings. +# Generate the $CARGO_HOME/config.toml necessary to use our local registry and settings. # Cargo can also be configured through environment variables in addition to the TOML syntax below. # For each configuration key below of the form foo.bar the environment variable CARGO_FOO_BAR # can also be used to define the value. @@ -265,7 +261,7 @@ cargo_gen_config() { mkdir -p "${ECARGO_HOME}" || die - cat > "${ECARGO_HOME}/config" <<- _EOF_ || die "Failed to create cargo config" + cat > "${ECARGO_HOME}/config.toml" <<- _EOF_ || die "Failed to create cargo config" [source.gentoo] directory = "${ECARGO_VENDOR}" @@ -323,6 +319,14 @@ _cargo_gen_git_config() { fi } +# @FUNCTION: cargo_target_dir +# @DESCRIPTION: +# Return the directory within target that contains the build, e.g. +# target/aarch64-unknown-linux-gnu/release. +cargo_target_dir() { + echo "${CARGO_TARGET_DIR:-target}/$(rust_abi)/$(usex debug debug release)" +} + # @FUNCTION: cargo_src_unpack # @DESCRIPTION: # Unpacks the package and the cargo registry. @@ -517,21 +521,92 @@ cargo_src_configure() { [[ ${ECARGO_ARGS[@]} ]] && einfo "Configured with: ${ECARGO_ARGS[@]}" } -# @FUNCTION: cargo_src_compile +# @FUNCTION: cargo_env +# @USAGE: Command with its arguments # @DESCRIPTION: -# Build the package using cargo build. -cargo_src_compile() { - debug-print-function ${FUNCNAME} "$@" - +# Run the given command under an environment needed for performing tasks with +# Cargo such as building. RUSTFLAGS are appended to additional flags set here. +# Ensure these are set consistently between Cargo invocations, otherwise +# rebuilds will occur. Project-specific rustflags set against [build] will not +# take affect due to Cargo limitations, so add these to your ebuild's RUSTFLAGS +# if they seem important. +cargo_env() { [[ ${_CARGO_GEN_CONFIG_HAS_RUN} ]] || \ die "FATAL: please call cargo_gen_config before using ${FUNCNAME}" + # Shadow flag variables so that filtering below remains local. + local flag + for flag in $(all-flag-vars); do + local -x "${flag}=${!flag}" + done + + # Rust extensions are incompatible with C/C++ LTO compiler see e.g. + # https://bugs.gentoo.org/910220 filter-lto + tc-export AR CC CXX PKG_CONFIG + # Set vars for cc-rs crate. + local -x \ + HOST_AR=$(tc-getBUILD_AR) + HOST_CC=$(tc-getBUILD_CC) + HOST_CXX=$(tc-getBUILD_CXX) + HOST_CFLAGS=${BUILD_CFLAGS} + HOST_CXXFLAGS=${BUILD_CXXFLAGS} + + # Unfortunately, Cargo is *really* bad at handling flags. In short, it uses + # the first of the RUSTFLAGS env var, any target-specific config, and then + # any generic [build] config. It can merge within the latter two types from + # different sources, but it will not merge across these different types, so + # if a project sets flags under [target.'cfg(all())'], it will override any + # flags we set under [build] and vice-versa. + # + # It has been common for users and ebuilds to set RUSTFLAGS, which would + # have overridden whatever a project sets anyway, so the least-worst option + # is to include those RUSTFLAGS in target-specific config here, which will + # merge with any the project sets. Only flags in generic [build] config set + # by the project will be lost, and ebuilds will need to add those to + # RUSTFLAGS themselves if they are important. + # + # We could potentially inspect a project's generic [build] config and + # reapply those flags ourselves, but that would require a proper toml parser + # like tomlq, it might lead to confusion where projects also have + # target-specific config, and converting arrays to strings may not work + # well. Nightly features to inspect the config might help here in future. + # + # As of Rust 1.80, it is not possible to set separate flags for the build + # host and the target host when cross-compiling. The flags given are applied + # to the target host only with no flags being applied to the build host. The + # nightly host-config feature will improve this situation later. + # + # The default linker is "cc" so override by setting linker to CC in the + # RUSTFLAGS. The given linker cannot include any arguments, so split these + # into link-args along with LDFLAGS. + local -x CARGO_BUILD_TARGET=$(rust_abi) + local TRIPLE=${CARGO_BUILD_TARGET//-/_} + local TRIPLE=${TRIPLE^^} LD_A=( $(tc-getCC) ${LDFLAGS} ) + local -x CARGO_TARGET_"${TRIPLE}"_RUSTFLAGS="-C strip=none -C linker=${LD_A[0]}" + [[ ${#LD_A[@]} -gt 1 ]] && local CARGO_TARGET_"${TRIPLE}"_RUSTFLAGS+="$(printf -- ' -C link-arg=%s' "${LD_A[@]:1}")" + local CARGO_TARGET_"${TRIPLE}"_RUSTFLAGS+=" ${RUSTFLAGS}" + + ( + # These variables will override the above, even if empty, so unset them + # locally. Do this in a subshell so that they remain set afterwards. + unset CARGO_BUILD_RUSTFLAGS CARGO_ENCODED_RUSTFLAGS RUSTFLAGS + + "${@}" + ) +} + +# @FUNCTION: cargo_src_compile +# @DESCRIPTION: +# Build the package using cargo build. +cargo_src_compile() { + debug-print-function ${FUNCNAME} "$@" + set -- cargo build $(usex debug "" --release) ${ECARGO_ARGS[@]} "$@" einfo "${@}" - "${@}" || die "cargo build failed" + cargo_env "${@}" || die "cargo build failed" } # @FUNCTION: cargo_src_install @@ -543,30 +618,16 @@ cargo_src_compile() { cargo_src_install() { debug-print-function ${FUNCNAME} "$@" - [[ ${_CARGO_GEN_CONFIG_HAS_RUN} ]] || \ - die "FATAL: please call cargo_gen_config before using ${FUNCNAME}" - set -- cargo install $(has --path ${@} || echo --path ./) \ --root "${ED}/usr" \ ${GIT_CRATES[@]:+--frozen} \ $(usex debug --debug "") \ ${ECARGO_ARGS[@]} "$@" einfo "${@}" - "${@}" || die "cargo install failed" + cargo_env "${@}" || die "cargo install failed" rm -f "${ED}/usr/.crates.toml" || die rm -f "${ED}/usr/.crates2.json" || die - - # it turned out to be non-standard dir, so get rid of it future EAPI - # and only run for EAPI=7 - # https://bugs.gentoo.org/715890 - case ${EAPI:-0} in - 7) - if [ -d "${S}/man" ]; then - doman "${S}/man" || return 0 - fi - ;; - esac } # @FUNCTION: cargo_src_test @@ -575,12 +636,9 @@ cargo_src_install() { cargo_src_test() { debug-print-function ${FUNCNAME} "$@" - [[ ${_CARGO_GEN_CONFIG_HAS_RUN} ]] || \ - die "FATAL: please call cargo_gen_config before using ${FUNCNAME}" - set -- cargo test $(usex debug "" --release) ${ECARGO_ARGS[@]} "$@" einfo "${@}" - "${@}" || die "cargo test failed" + cargo_env "${@}" || die "cargo test failed" } fi diff --git a/eclass/cdrom.eclass b/eclass/cdrom.eclass index 4e56db951196..4f7ba663beba 100644 --- a/eclass/cdrom.eclass +++ b/eclass/cdrom.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: cdrom.eclass @@ -15,14 +15,18 @@ # eclass will require RESTRICT="bindist" but the point still stands. # The functions are generally called in src_unpack. -case ${EAPI:-0} in - 6|7|8) ;; - *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; -esac - if [[ -z ${_CDROM_ECLASS} ]]; then _CDROM_ECLASS=1 +case ${EAPI} in + 6) + ewarn "${CATEGORY}/${PF}: ebuild uses ${ECLASS} with deprecated EAPI ${EAPI}!" + ewarn "${CATEGORY}/${PF}: Support will be removed on 2024-10-08. Please port to newer EAPI." + ;; + 7|8) ;; + *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; +esac + inherit portability # @ECLASS_VARIABLE: CDROM_OPTIONAL diff --git a/eclass/check-reqs.eclass b/eclass/check-reqs.eclass index fac2f4553d74..02ff61187c45 100644 --- a/eclass/check-reqs.eclass +++ b/eclass/check-reqs.eclass @@ -1,4 +1,4 @@ -# Copyright 2004-2023 Gentoo Authors +# Copyright 2004-2024 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 # @ECLASS: check-reqs.eclass @@ -38,14 +38,18 @@ # These checks should probably mostly work on non-Linux, and they should # probably degrade gracefully if they don't. Probably. +if [[ -z ${_CHECK_REQS_ECLASS} ]]; then +_CHECK_REQS_ECLASS=1 + case ${EAPI} in - 6|7|8) ;; + 6) + ewarn "${CATEGORY}/${PF}: ebuild uses ${ECLASS} with deprecated EAPI ${EAPI}!" + ewarn "${CATEGORY}/${PF}: Support will be removed on 2024-10-08. Please port to newer EAPI." + ;; + 7|8) ;; *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; esac -if [[ -z ${_CHECK_REQS_ECLASS} ]]; then -_CHECK_REQS_ECLASS=1 - # @ECLASS_VARIABLE: CHECKREQS_MEMORY # @DEFAULT_UNSET # @DESCRIPTION: diff --git a/eclass/cmake.eclass b/eclass/cmake.eclass index 908e2356ead2..8079a5cb037b 100644 --- a/eclass/cmake.eclass +++ b/eclass/cmake.eclass @@ -388,7 +388,7 @@ cmake_src_prepare() { local name for name in "${modules_list[@]}" ; do if [[ ${EAPI} == 7 ]]; then - find "${S}" -name ${name}.cmake -exec rm -v {} + || die + find "${S}" -name "${name}.cmake" -exec rm -v {} + || die else find -name "${name}.cmake" -exec rm -v {} + || die fi @@ -541,12 +541,17 @@ cmake_src_configure() { set(CMAKE_INSTALL_DOCDIR "${EPREFIX}/usr/share/doc/${PF}" CACHE PATH "") set(BUILD_SHARED_LIBS ON CACHE BOOL "") set(Python3_FIND_UNVERSIONED_NAMES FIRST CACHE STRING "") - set(FETCHCONTENT_FULLY_DISCONNECTED ON CACHE BOOL "") set(CMAKE_DISABLE_PRECOMPILE_HEADERS ON CACHE BOOL "") + set(CMAKE_TLS_VERIFY ON CACHE BOOL "") + set(CMAKE_COMPILE_WARNING_AS_ERROR OFF CACHE BOOL "") _EOF_ if [[ -n ${_ECM_ECLASS} ]]; then - echo 'set(ECM_DISABLE_QMLPLUGINDUMP ON CACHE BOOL "")' >> "${common_config}" || die + cat >> ${common_config} <<- _EOF_ || die + set(ECM_DISABLE_QMLPLUGINDUMP ON CACHE BOOL "") + set(ECM_DISABLE_APPSTREAMTEST ON CACHE BOOL "") + set(ECM_DISABLE_GIT ON CACHE BOOL "") + _EOF_ fi # See bug 689410 diff --git a/eclass/common-lisp-3.eclass b/eclass/common-lisp-3.eclass index 26d31268a598..cc906d0d5cca 100644 --- a/eclass/common-lisp-3.eclass +++ b/eclass/common-lisp-3.eclass @@ -1,17 +1,17 @@ -# Copyright 1999-2023 Gentoo Authors +# Copyright 1999-2024 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 # @ECLASS: common-lisp-3.eclass # @MAINTAINER: # Common Lisp project <common-lisp@gentoo.org> -# @SUPPORTED_EAPIS: 6 7 +# @SUPPORTED_EAPIS: 7 8 # @BLURB: functions to support the installation of Common Lisp libraries # @DESCRIPTION: # Since Common Lisp libraries share similar structure, this eclass aims # to provide a simple way to write ebuilds with these characteristics. case ${EAPI} in - 6|7) ;; + 7|8) ;; *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; esac @@ -27,14 +27,14 @@ CLIMPLEMENTATIONS="sbcl clisp clozurecl cmucl ecl gcl abcl" # @DESCRIPTION: # Default path of Common Lisp libraries sources. Sources will # be installed into ${CLSOURCEROOT}/${CLPACKAGE}. -CLSOURCEROOT="${ROOT%/}"/usr/share/common-lisp/source +CLSOURCEROOT="${ROOT}"/usr/share/common-lisp/source # @ECLASS_VARIABLE: CLSYSTEMROOT # @DESCRIPTION: # Default path to find any asdf file. Any asdf files will be # symlinked in ${CLSYSTEMROOT}/${CLSYSTEM} as they may be in # an arbitrarily deeply nested directory under ${CLSOURCEROOT}/${CLPACKAGE}. -CLSYSTEMROOT="${ROOT%/}"/usr/share/common-lisp/systems +CLSYSTEMROOT="${ROOT}"/usr/share/common-lisp/systems # @ECLASS_VARIABLE: CLPACKAGE # @DESCRIPTION: @@ -121,7 +121,8 @@ common-lisp-install-sources() { local fpredicate=$(common-lisp-get-fpredicate "${ftype}") - for path in "${@}" ; do + local path + for path ; do if [[ -f ${path} ]] ; then common-lisp-install-one-source ${fpredicate} "${path}" "$(dirname "${path}")" elif [[ -d ${path} ]] ; then @@ -148,7 +149,7 @@ common-lisp-install-sources() { # Installs ${1} asdf file in CLSOURCEROOT/CLPACKAGE and symlinks it in # CLSYSTEMROOT. common-lisp-install-one-asdf() { - [[ $# != 1 ]] && die "${FUNCNAME[0]} must receive exactly one argument" + [[ $# -eq 1 ]] || die "${FUNCNAME[0]} must receive exactly one argument" # the suffix «.asd» is optional local source=${1%.asd}.asd @@ -166,9 +167,11 @@ common-lisp-install-one-asdf() { common-lisp-install-asdf() { dodir "${CLSYSTEMROOT}" - [[ $# = 0 ]] && set - ${CLSYSTEMS} - [[ $# = 0 ]] && set - $(find . -type f -name \*.asd) - for sys in "${@}" ; do + [[ $# -eq 0 ]] && set - ${CLSYSTEMS} + [[ $# -eq 0 ]] && set - $(find . -type f -name \*.asd) + + local sys + for sys ; do common-lisp-install-one-asdf ${sys} done } @@ -187,6 +190,7 @@ common-lisp-3_src_install() { # Outputs an installed Common Lisp implementation. Transverses # CLIMPLEMENTATIONS to find it. common-lisp-find-lisp-impl() { + local lisp for lisp in ${CLIMPLEMENTATIONS} ; do [[ "$(best_version dev-lisp/${lisp})" ]] && echo "${lisp}" && return done @@ -203,7 +207,7 @@ common-lisp-find-lisp-impl() { # * CL_LOAD: load a certain file # * CL_EVAL: eval a certain expression at startup common-lisp-export-impl-args() { - if [[ $# != 1 ]]; then + if [[ $# -ne 1 ]]; then eerror "Usage: ${FUNCNAME[0]} lisp-implementation" die "${FUNCNAME[0]}: wrong number of arguments: $#" fi @@ -211,7 +215,7 @@ common-lisp-export-impl-args() { case "${CL_BINARY}" in sbcl) CL_BINARY="${CL_BINARY} --non-interactive" - CL_NORC="--sysinit /dev/null --userinit /dev/null" + CL_NORC="--no-sysinit --no-userinit" CL_LOAD="--load" CL_EVAL="--eval" ;; diff --git a/eclass/depend.apache.eclass b/eclass/depend.apache.eclass index 8f0469931d2c..60926c298f04 100644 --- a/eclass/depend.apache.eclass +++ b/eclass/depend.apache.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: depend.apache.eclass @@ -40,12 +40,13 @@ # } # @CODE -case ${EAPI:-0} in - 6|7|8) - ;; - *) - die "EAPI=${EAPI} is not supported by depend.apache.eclass" +case ${EAPI} in + 6) + ewarn "${CATEGORY}/${PF}: ebuild uses ${ECLASS} with deprecated EAPI ${EAPI}!" + ewarn "${CATEGORY}/${PF}: Support will be removed on 2024-10-08. Please port to newer EAPI." ;; + 7|8) ;; + *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; esac # ============================================================================== diff --git a/eclass/desktop.eclass b/eclass/desktop.eclass index 780971342ba1..144514c8f7c2 100644 --- a/eclass/desktop.eclass +++ b/eclass/desktop.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: desktop.eclass @@ -8,7 +8,11 @@ # @BLURB: support for desktop files, menus, and icons case ${EAPI} in - 6|7|8) ;; + 6) + ewarn "${CATEGORY}/${PF}: ebuild uses ${ECLASS} with deprecated EAPI ${EAPI}!" + ewarn "${CATEGORY}/${PF}: Support will be removed on 2024-10-08. Please port to newer EAPI." + ;; + 7|8) ;; *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; esac diff --git a/eclass/dist-kernel-utils.eclass b/eclass/dist-kernel-utils.eclass index 13137f8c863c..bb058d488a13 100644 --- a/eclass/dist-kernel-utils.eclass +++ b/eclass/dist-kernel-utils.eclass @@ -1,4 +1,4 @@ -# Copyright 2020-2023 Gentoo Authors +# Copyright 2020-2024 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 # @ECLASS: dist-kernel-utils.eclass @@ -26,7 +26,7 @@ case ${EAPI} in *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; esac -inherit toolchain-funcs +inherit mount-boot-utils toolchain-funcs # @FUNCTION: dist-kernel_get_image_path # @DESCRIPTION: @@ -79,11 +79,38 @@ dist-kernel_install_kernel() { local image=${2} local map=${3} - ebegin "Installing the kernel via installkernel" - # note: .config is taken relatively to System.map; - # initrd relatively to bzImage - ARCH=$(tc-arch-kernel) installkernel "${version}" "${image}" "${map}" - eend ${?} || die -n "Installing the kernel failed" + local success= + # not an actual loop but allows error handling with 'break' + while true; do + nonfatal mount-boot_check_status || break + + ebegin "Installing the kernel via installkernel" + # note: .config is taken relatively to System.map; + # initrd relatively to bzImage + ARCH=$(tc-arch-kernel) installkernel "${version}" "${image}" "${map}" || break + eend ${?} || die -n "Installing the kernel failed" + + success=1 + break + done + + if [[ ! ${success} ]]; then + # Fallback string, if the identifier file is not found + local kernel="<name of your kernel pakcage>:<kernel version>" + # Try to read dist-kernel identifier to more accurately instruct users + local k_id_file=${image%$(dist-kernel_get_image_path)}/dist-kernel + if [[ -f ${k_id_file} ]]; then + kernel=\'\=$(<${k_id_file})\' + fi + + eerror + eerror "The kernel was not deployed successfully. Inspect the failure" + eerror "in the logs above and once you resolve the problems please" + eerror "run the equivalent of the following command to try again:" + eerror + eerror " emerge --config ${kernel}" + die "Kernel install failed, please fix the problems and run emerge --config" + fi } # @FUNCTION: dist-kernel_reinstall_initramfs @@ -132,6 +159,35 @@ dist-kernel_PV_to_KV() { echo "${kv}" } +# @FUNCTION: dist-kernel_get_module_suffix +# @USAGE: <kernel_config> +# @DESCRIPTION: +# Returns the suffix for kernel modules based on the CONFIG_MODULES_COMPESS_* +# setting in the kernel config and USE=modules-compress. +dist-kernel_get_module_suffix() { + debug-print-function ${FUNCNAME} "${@}" + + [[ ${#} -eq 1 ]] || die "${FUNCNAME}: invalid arguments" + + local config=${1} + + if ! in_iuse modules-compress || ! use modules-compress; then + echo .ko + elif [[ ! -r ${config} ]]; then + die "Cannot find kernel config ${config}" + elif grep -q "CONFIG_MODULE_COMPRESS_NONE=y" "${config}"; then + echo .ko + elif grep -q "CONFIG_MODULE_COMPRESS_GZIP=y" "${config}"; then + echo .ko.gz + elif grep -q "CONFIG_MODULE_COMPRESS_XZ=y" "${config}"; then + echo .ko.xz + elif grep -q "CONFIG_MODULE_COMPRESS_ZSTD=y" "${config}"; then + echo .ko.zst + else + die "Module compression is enabled, but compressor not known" + fi +} + # @FUNCTION: dist-kernel_compressed_module_cleanup # @USAGE: <path> # @DESCRIPTION: @@ -142,20 +198,41 @@ dist-kernel_compressed_module_cleanup() { [[ ${#} -ne 1 ]] && die "${FUNCNAME}: invalid arguments" local path=${1} - local basename f + local config_path=/usr/src/linux-${KV_FULL}/.config + + local option + for option in config source/.config build/.config; do + if [[ -f ${path}/${option} ]]; then + config_path=${path}/${option} + break + fi + done + + local preferred= + [[ -f ${config_path} ]] && preferred=$(dist-kernel_get_module_suffix "${config_path}") + + local basename suffix while read -r basename; do local prev= - for f in "${path}/${basename}"{,.gz,.xz,.zst}; do - if [[ ! -e ${f} ]]; then - continue + for suffix in .ko .ko.gz .ko.xz .ko.zst; do + [[ ${suffix} == ${preferred} ]] && continue + local current=${path}/${basename}${suffix} + [[ -f ${current} ]] || continue + + if [[ -f ${path}/${basename}${preferred} ]]; then + # If the module with the desired compression exists, remove + # all other variations. + rm -v "${current}" || die elif [[ -z ${prev} ]]; then - prev=${f} - elif [[ ${f} -nt ${prev} ]]; then + # If not, then keep whichever of the duplicate modules is the + # newest. Normally you should not end up here. + prev=${current} + elif [[ ${current} -nt ${prev} ]]; then rm -v "${prev}" || die - prev=${f} + prev=${current} else - rm -v "${f}" || die + rm -v "${current}" || die fi done done < <( @@ -165,7 +242,8 @@ dist-kernel_compressed_module_cleanup() { -o -name '*.ko.gz' \ -o -name '*.ko.xz' \ -o -name '*.ko.zst' \ - \) | sed -e 's:[.]\(gz\|xz\|zst\)$::' | sort | uniq -d || die + \) | sed -e 's:[.]ko\(\|[.]gz\|[.]xz\|[.]zst\)$::' | + sort | uniq -d || die ) } diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass index 71b80fafe1a5..5a6ebdcede8a 100644 --- a/eclass/distutils-r1.eclass +++ b/eclass/distutils-r1.eclass @@ -78,6 +78,11 @@ esac # for your package (using ${PYTHON_DEPS}) and to either call # distutils-r1 default phase functions or call the build system # manually. +# +# Note that if DISTUTILS_SINGLE_IMPL is used, python-single-r1 exports +# pkg_setup() function. In that case, it is necessary to redefine +# pkg_setup() to call python-single-r1_pkg_setup over correct +# conditions. # @ECLASS_VARIABLE: DISTUTILS_SINGLE_IMPL # @DEFAULT_UNSET @@ -94,7 +99,7 @@ esac # @PRE_INHERIT # @DEFAULT_UNSET # @DESCRIPTION: -# Enable the PEP 517 mode for the specified build system. In this mode, +# Enable the PEP517 mode for the specified build system. In this mode, # the complete build and install is done in python_compile(), # a venv-style install tree is provided to python_test(), # and python_install() just merges the temporary install tree @@ -177,7 +182,7 @@ esac # This is an eclass-generated build-time dependency string for the build # system packages. This string is automatically appended to BDEPEND # unless DISTUTILS_OPTIONAL is used. This variable is available only -# in PEP 517 mode. +# in PEP517 mode. # # Example use: # @CODE @@ -190,7 +195,6 @@ esac # @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 @@ -200,6 +204,23 @@ esac # 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. +: ${DISTUTILS_ALLOW_WHEEL_REUSE=1} + +# @ECLASS_VARIABLE: BUILD_DIR +# @OUTPUT_VARIABLE +# @DEFAULT_UNSET +# @DESCRIPTION: +# The current build directory. In global scope, it is supposed to +# contain an initial build directory; if unset, it defaults to ${S}. +# +# When running in multi-impl mode, the BUILD_DIR variable is set +# by python-r1.eclass. Otherwise, it is set by distutils-r1.eclass +# for consistency. +# +# Example value: +# @CODE +# ${WORKDIR}/foo-1.3-python3_12 +# @CODE if [[ -z ${_DISTUTILS_R1_ECLASS} ]]; then _DISTUTILS_R1_ECLASS=1 @@ -364,54 +385,9 @@ _distutils_set_globals() { _distutils_set_globals unset -f _distutils_set_globals -# @ECLASS_VARIABLE: PATCHES -# @DEFAULT_UNSET -# @DESCRIPTION: -# An array containing patches to be applied to the sources before -# copying them. -# -# If unset, no custom patches will be applied. -# -# Please note, however, that at some point the eclass may apply -# additional distutils patches/quirks independently of this variable. -# -# Example: -# @CODE -# PATCHES=( "${FILESDIR}"/${P}-make-gentoo-happy.patch ) -# @CODE - -# @ECLASS_VARIABLE: DOCS -# @DEFAULT_UNSET -# @DESCRIPTION: -# An array containing documents installed using dodoc. The files listed -# there must exist in the directory from which -# distutils-r1_python_install_all() is run (${S} by default). -# -# If unset, the function will instead look up files matching default -# filename pattern list (from the Package Manager Specification), -# and install those found. -# -# Example: -# @CODE -# DOCS=( NEWS README ) -# @CODE - -# @ECLASS_VARIABLE: HTML_DOCS -# @DEFAULT_UNSET -# @DESCRIPTION: -# An array containing documents installed using dohtml. The files -# and directories listed there must exist in the directory from which -# distutils-r1_python_install_all() is run (${S} by default). -# -# If unset, no HTML docs will be installed. -# -# Example: -# @CODE -# HTML_DOCS=( doc/html/. ) -# @CODE - # @ECLASS_VARIABLE: DISTUTILS_IN_SOURCE_BUILD # @DEFAULT_UNSET +# @DEPRECATED: (none) # @DESCRIPTION: # If set to a non-null value, in-source builds will be enabled. # If unset, the default is to use in-source builds when python_prepare() @@ -425,6 +401,9 @@ unset -f _distutils_set_globals # on the sources directly, prepending setup.py arguments with # 'build --build-base ${BUILD_DIR}' to enforce keeping & using built # files in the specific root. +# +# In-source builds are deprecated and no longer supported in PEP517 +# mode. # @ECLASS_VARIABLE: DISTUTILS_ALL_SUBPHASE_IMPLS # @DEFAULT_UNSET @@ -587,22 +566,21 @@ distutils_enable_sphinx() { } # @FUNCTION: distutils_enable_tests -# @USAGE: [--install] <test-runner> +# @USAGE: <test-runner> # @DESCRIPTION: # Set up IUSE, RESTRICT, BDEPEND and python_test() for running tests # with the specified test runner. Also copies the current value # of RDEPEND to test?-BDEPEND. The test-runner argument must be one of: # +# - import-check: `pytest --import-check` fallback (for use when there are +# no tests to run) +# # - pytest: dev-python/pytest # # - setup.py: setup.py test (no deps included) # # - unittest: for built-in Python unittest module # -# Additionally, if --install is passed as the first parameter, -# 'distutils_install_for_testing --via-root' is called before running -# the test suite. -# # This function is meant as a helper for common use cases, and it only # takes care of basic setup. You still need to list additional test # dependencies manually. If you have uncommon use case, you should @@ -613,23 +591,22 @@ distutils_enable_sphinx() { distutils_enable_tests() { debug-print-function ${FUNCNAME} "${@}" - _DISTUTILS_TEST_INSTALL= case ${1} in --install) - if [[ ${DISTUTILS_USE_PEP517} ]]; then - die "${FUNCNAME} --install is not implemented in PEP517 mode" - fi - _DISTUTILS_TEST_INSTALL=1 - shift + die "${FUNCNAME} --install is no longer supported" ;; esac [[ ${#} -eq 1 ]] || die "${FUNCNAME} takes exactly one argument: test-runner" local test_deps=${RDEPEND} + local test_pkgs= case ${1} in + import-check) + test_pkgs+=' dev-python/pytest-import-check[${PYTHON_USEDEP}]' + ;& pytest) - local test_pkgs='>=dev-python/pytest-7.4.4[${PYTHON_USEDEP}]' + test_pkgs+=' >=dev-python/pytest-7.4.4[${PYTHON_USEDEP}]' if [[ -n ${EPYTEST_TIMEOUT} ]]; then test_pkgs+=' dev-python/pytest-timeout[${PYTHON_USEDEP}]' fi @@ -734,123 +711,12 @@ esetup.py() { } # @FUNCTION: distutils_install_for_testing -# @USAGE: [--via-root|--via-home|--via-venv] [<args>...] +# @DEPRECATED: DISTUTILS_USE_PEP517=... # @DESCRIPTION: -# Install the package into a temporary location for running tests. -# Update PYTHONPATH appropriately and set TEST_DIR to the test -# installation root. The Python packages will be installed in 'lib' -# subdir, and scripts in 'scripts' subdir (like in BUILD_DIR). -# -# Please note that this function should be only used if package uses -# namespaces (and therefore proper install needs to be done to enforce -# PYTHONPATH) or tests rely on the results of install command. -# For most of the packages, tests built in BUILD_DIR are good enough. -# -# The function supports three install modes. These are: -# -# --via-root (the default) that uses 'setup.py install --root=...' -# combined with PYTHONPATH and is recommended for the majority -# of packages. -# -# --via-venv that creates a (non-isolated) venv and installs the package -# into it via 'setup.py install'. This mode does not use PYTHONPATH -# but requires python to be called via PATH. It may solve a few corner -# cases that --via-root do not support. -# -# --via-home that uses 'setup.py install --home=...'. This is -# a historical mode that was mostly broken by setuptools 50.3.0+. -# If your package does not work with the other two modes but works with -# this one, please report a bug. -# -# Please note that in order to test the solution properly you need -# to unmerge the package first. -# -# This function is not available in PEP517 mode. The eclass provides -# a venv-style install unconditionally and therefore it should no longer -# be necessary. +# This function used to provide an installed package for running tests. +# It is no longer implemented, PEP517 mode must be used instead. distutils_install_for_testing() { - debug-print-function ${FUNCNAME} "${@}" - - if [[ ${DISTUTILS_USE_PEP517} ]]; then - die "${FUNCNAME} is not implemented in PEP517 mode" - fi - - # A few notes about --via-home mode: - # 1) 'install --home' is terribly broken on pypy, so we need - # to override --install-lib and --install-scripts, - # 2) non-root 'install' complains about PYTHONPATH and missing dirs, - # so we need to set it properly and mkdir them, - # 3) it runs a bunch of commands which write random files to cwd, - # in order to avoid that, we add the necessary path overrides - # in _distutils-r1_create_setup_cfg. - - local install_method=root - case ${1} in - --via-home) - [[ ${EAPI} == 7 ]] || die "${*} is banned in EAPI ${EAPI}" - install_method=home - shift - ;; - --via-root) - install_method=root - shift - ;; - --via-venv) - install_method=venv - shift - ;; - esac - - TEST_DIR=${BUILD_DIR}/test - local add_args=() - - if [[ ${install_method} == venv ]]; then - # create a quasi-venv - mkdir -p "${TEST_DIR}"/bin || die - ln -s "${PYTHON}" "${TEST_DIR}/bin/${EPYTHON}" || die - ln -s "${EPYTHON}" "${TEST_DIR}/bin/python3" || die - ln -s "${EPYTHON}" "${TEST_DIR}/bin/python" || die - cat > "${TEST_DIR}"/pyvenv.cfg <<-EOF || die - include-system-site-packages = true - EOF - - # we only do the minimal necessary subset of activate script - PATH=${TEST_DIR}/bin:${PATH} - # unset PYTHONPATH in order to prevent BUILD_DIR from overriding - # venv packages - unset PYTHONPATH - - # force root-style install (note: venv adds TEST_DIR to prefixes, - # so we need to pass --root=/) - add_args=( - --root=/ - ) - else - local bindir=${TEST_DIR}/scripts - local libdir=${TEST_DIR}/lib - PATH=${bindir}:${PATH} - PYTHONPATH=${libdir}:${PYTHONPATH} - - case ${install_method} in - home) - add_args=( - --home="${TEST_DIR}" - --install-lib="${libdir}" - --install-scripts="${bindir}" - ) - mkdir -p "${libdir}" || die - ;; - root) - add_args=( - --root="${TEST_DIR}" - --install-lib=lib - --install-scripts=scripts - ) - ;; - esac - fi - - esetup.py install "${add_args[@]}" "${@}" + die "${FUNCNAME} has been removed, please use PEP517 mode instead" } # @FUNCTION: distutils_write_namespace @@ -1070,6 +936,7 @@ _distutils-r1_print_package_versions() { # distutils patches and/or quirks. distutils-r1_python_prepare_all() { debug-print-function ${FUNCNAME} "${@}" + _python_sanity_checks _distutils-r1_check_all_phase_mismatch if [[ ! ${DISTUTILS_OPTIONAL} ]]; then @@ -1362,7 +1229,7 @@ distutils_wheel_install() { # @FUNCTION: distutils_pep517_install # @USAGE: <root> # @DESCRIPTION: -# Build the wheel for the package in the current directory using PEP 517 +# Build the wheel for the package in the current directory using PEP517 # backend and install it into <root>. # # This function is intended for expert use only. It does not handle @@ -1385,7 +1252,11 @@ distutils_pep517_install() { die "mydistutilsargs are banned in PEP517 mode (use DISTUTILS_ARGS)" fi - local config_settings= + local cmd=() config_settings= + if has cargo ${INHERITED} && [[ ${_CARGO_GEN_CONFIG_HAS_RUN} ]]; then + cmd+=( cargo_env ) + fi + case ${DISTUTILS_USE_PEP517} in maturin) # `maturin pep517 build-wheel --help` for options @@ -1522,9 +1393,14 @@ distutils_pep517_install() { ;; esac + # https://pyo3.rs/latest/building-and-distribution.html#cross-compiling + if tc-is-cross-compiler; then + local -x PYO3_CROSS_LIB_DIR=${SYSROOT}/$(python_get_stdlib) + fi + local build_backend=$(_distutils-r1_get_backend) einfo " Building the wheel for ${PWD#${WORKDIR}/} via ${build_backend}" - local cmd=( + cmd+=( "${EPYTHON}" -m gpep517 build-wheel --prefix="${EPREFIX}/usr" --backend "${build_backend}" @@ -1700,11 +1576,10 @@ distutils-r1_python_test() { _python_check_EPYTHON - if [[ ${_DISTUTILS_TEST_INSTALL} ]]; then - distutils_install_for_testing - fi - case ${_DISTUTILS_TEST_RUNNER} in + import-check) + epytest --import-check "${BUILD_DIR}/install$(python_get_sitedir)" + ;; pytest) epytest ;; @@ -1893,9 +1768,7 @@ distutils-r1_run_phase() { else local -x PYTHONPATH="${BUILD_DIR}/lib:${PYTHONPATH}" - # make PATH local for distutils_install_for_testing calls - # it makes little sense to let user modify PATH in per-impl phases - # and _all() already localizes it + # make PATH local (for historical reasons) local -x PATH=${PATH} if _python_impl_matches "${EPYTHON}" 3.{9..11}; then @@ -1929,16 +1802,6 @@ distutils-r1_run_phase() { # bug fixes from Cython (this works only when setup.py is using # cythonize() but it's better than nothing) local -x CYTHON_FORCE_REGEN=1 - - # Rust extensions are incompatible with C/C++ LTO compiler - # see e.g. https://bugs.gentoo.org/910220 - if has cargo ${INHERITED}; then - local x - for x in $(all-flag-vars); do - local -x "${x}=${!x}" - done - filter-lto - fi fi # silence warnings when pydevd is loaded on Python 3.11+ @@ -2080,7 +1943,7 @@ _distutils-r1_compare_installed_files() { # 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* && + if [[ ${!DISTUTILS_WHEELS[*]} != *py3-none-any.whl* && ${!DISTUTILS_WHEELS[*]} != *-abi3-*.whl ]]; then return fi @@ -2248,8 +2111,10 @@ _distutils-r1_post_python_install() { local strays=() local p mapfile -d $'\0' -t strays < <( + # jar for jpype, https://bugs.gentoo.org/937642 find "${sitedir}" -maxdepth 1 -type f '!' '(' \ -name '*.egg-info' -o \ + -name '*.jar' -o \ -name '*.pth' -o \ -name '*.py' -o \ -name '*.pyi' -o \ diff --git a/eclass/dune.eclass b/eclass/dune.eclass index f0faea007c9f..ba54e87ceaf9 100644 --- a/eclass/dune.eclass +++ b/eclass/dune.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: dune.eclass @@ -185,6 +185,10 @@ dune-install() { } dune_src_install() { + # OCaml generates textrels on 32-bit arches + if use arm || use ppc || use x86 ; then + export QA_TEXTRELS='.*' + fi dune-install ${1:-${DUNE_PKG_NAME}} } diff --git a/eclass/eapi7-ver.eclass b/eclass/eapi7-ver.eclass index a23e76ad3ee3..85c0856f73b3 100644 --- a/eclass/eapi7-ver.eclass +++ b/eclass/eapi7-ver.eclass @@ -1,6 +1,7 @@ # Copyright 1999-2021 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 +# @DEAD # @ECLASS: eapi7-ver.eclass # @MAINTAINER: # PMS team <pms@gentoo.org> diff --git a/eclass/ecm-common.eclass b/eclass/ecm-common.eclass new file mode 100644 index 000000000000..c0c2b4f7e644 --- /dev/null +++ b/eclass/ecm-common.eclass @@ -0,0 +1,401 @@ +# Copyright 2024 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +# @ECLASS: ecm-common.eclass +# @MAINTAINER: +# kde@gentoo.org +# @SUPPORTED_EAPIS: 8 +# @PROVIDES: cmake +# @BLURB: Standalone CMake calling std. ECM macros to install common files only. +# @DESCRIPTION: +# This eclass is used for installing common files of packages using ECM macros, +# most of the time translations, but optionally also icons and kcfg files. This +# is mainly useful for packages split from a single upstream tarball, or for +# collision handling of slotted package versions, which need to share a common +# files package. +# Conventionally we will use ${PN}-common for these split packages. + +case ${EAPI} in + 8) ;; + *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; +esac + +if [[ -z ${_ECM_COMMON_ECLASS} ]]; then +_ECM_COMMON_ECLASS=1 + +inherit cmake + +# @ECLASS_VARIABLE: KFMIN +# @DEFAULT_UNSET +# @DESCRIPTION: +# Minimum version of Frameworks to require. Default value for kde-frameworks +# is ${PV} and 6.0.0 baseline for everything else. +# If set to <5.240, it is assumed dependencies are fulfilled by KF5/Qt5 +# alternatively, thus a block of SLOT=5 shadow dependencies added. +if [[ ${CATEGORY} = kde-frameworks ]]; then + : "${KFMIN:=$(ver_cut 1-2)}" +fi +: "${KFMIN:=6.0.0}" + +# @ECLASS_VARIABLE: _KFSLOT +# @INTERNAL +# @DESCRIPTION: +# KDE Frameworks main slot dependency for consistently finding all KF5 or KF6 +# in CMakeLists.txt. Consistency over installed KF packages is established via +# BDEPEND, then detected in pkg_setup(). +# Is passed as -DQT_MAJOR_VERSION=${_KFSLOT} in src_configure() too. +_KFSLOT=6 + +# @ECLASS_VARIABLE: KF5_BDEPEND +# @PRE_INHERIT +# @DESCRIPTION: +# Dynamic KF5 dependency list. +if [[ ${KF5_BDEPEND} ]]; then + [[ ${KF5_BDEPEND@a} == *a* ]] || + die "KF5_BDEPEND must be an array" +else + KF5_BDEPEND=( ) +fi + +# @ECLASS_VARIABLE: KF6_BDEPEND +# @PRE_INHERIT +# @DESCRIPTION: +# Dynamic KF6 dependency list. +if [[ ${KF6_BDEPEND} ]]; then + [[ ${KF6_BDEPEND@a} == *a* ]] || + die "KF6_BDEPEND must be an array" +else + KF6_BDEPEND=( ) +fi + +# @ECLASS_VARIABLE: ECM_I18N +# @PRE_INHERIT +# @DESCRIPTION: +# Will accept "true" (default) or "false". If set to "false", do nothing. +# Otherwise, add kde-frameworks/ki18n:* to BDEPEND, find KF[56]I18n and let +# ki18n_install(po) generate and install translations. +: "${ECM_I18N:=true}" + +# @ECLASS_VARIABLE: ECM_HANDBOOK +# @PRE_INHERIT +# @DESCRIPTION: +# Will accept "true" or "false" (default). If set to "false", do nothing. +# Otherwise, add "+handbook" to IUSE, add kde-frameworks/kdoctools:* to BDEPEND +# find KF[56]DocTools in CMake, call add_subdirectory(ECM_HANDBOOK_DIRS) +# and let let kdoctools_install(po) generate and install translated docbook +# files. +: "${ECM_HANDBOOK:=false}" + +# @ECLASS_VARIABLE: ECM_HANDBOOK_DIRS +# @PRE_INHERIT +# @DESCRIPTION: +# Default is "doc" which is correct for the vast majority of packages. Specifies +# one or more directories containing untranslated docbook file(s) relative to +# ${S} to be added via add_subdirectory. +if [[ ${ECM_HANDBOOK_DIRS} ]]; then + [[ ${ECM_HANDBOOK_DIRS@a} == *a* ]] || + die "ECM_HANDBOOK_DIRS must be an array" +else + ECM_HANDBOOK_DIRS=( doc ) +fi + +# @ECLASS_VARIABLE: ECM_INSTALL_FILES +# @DEFAULT_UNSET +# @DESCRIPTION: +# Array of <file>:<destination_path> tuples to install by CMake via +# install(FILES <file> DESTINATION <destination_path>) +if [[ ${ECM_INSTALL_FILES} ]]; then + [[ ${ECM_INSTALL_FILES@a} == *a* ]] || + die "ECM_INSTALL_FILES must be an array" +fi + +# @ECLASS_VARIABLE: ECM_INSTALL_ICONS +# @DEFAULT_UNSET +# @DESCRIPTION: +# Array of <icon>:<icon_install_dir> tuples to feed to ECMInstallIcons +# via ecm_install_icons(ICONS <icon> DESTINATION <icon_install_dir) +if [[ ${ECM_INSTALL_ICONS} ]]; then + [[ ${ECM_INSTALL_ICONS@a} == *a* ]] || + die "ECM_INSTALL_ICONS must be an array" +fi + +# @ECLASS_VARIABLE: ECM_KCM_TARGETS +# @DEFAULT_UNSET +# @PRE_INHERIT +# @DESCRIPTION: +# Array of <target>:<subdir> tuples to feed to ECMInstallIcons via +# ecmcommon_generate_desktop_file(<target> <subdir>), which is this +# eclass adaptation of kcmutils_generate_desktop_file. +if [[ ${ECM_KCM_TARGETS} ]]; then + [[ ${ECM_KCM_TARGETS@a} == *a* ]] || + die "ECM_KCM_TARGETS must be an array" +fi + +DESCRIPTION="Common files for ${PN/-common/}" + +BDEPEND=">=kde-frameworks/extra-cmake-modules-${KFMIN}:*" + +case ${ECM_I18N} in + true) + KF5_BDEPEND+=( "kde-frameworks/ki18n:5" ) + KF6_BDEPEND+=( "kde-frameworks/ki18n:6" ) + ;; + false) ;; + *) + eerror "Unknown value for \${ECM_I18N}" + die "Value ${ECM_I18N} is not supported" + ;; +esac + +case ${ECM_HANDBOOK} in + true) + IUSE+=" +handbook" + KF5_BDEPEND+=( "handbook? ( kde-frameworks/kdoctools:5 )" ) + KF6_BDEPEND+=( "handbook? ( kde-frameworks/kdoctools:6 )" ) + ;; + false) ;; + *) + eerror "Unknown value for \${ECM_HANDBOOK}" + die "Value ${ECM_HANDBOOK} is not supported" + ;; +esac + +if [[ ${ECM_KCM_TARGETS} ]]; then + KF5_BDEPEND+=( "kde-frameworks/kcmutils:5" ) + KF6_BDEPEND+=( "kde-frameworks/kcmutils:6" ) +fi + +if $(ver_test ${KFMIN} -lt 5.240) && [[ ${KF6_BDEPEND} && ${KF5_BDEPEND} ]]; then + BDEPEND+=" || ( ( ${KF6_BDEPEND[*]} ) ( ${KF5_BDEPEND[*]} ) )" +else + BDEPEND+=" ${KF6_BDEPEND[*]}" +fi + +# @FUNCTION: _ecm-common_preamble +# @INTERNAL +# @DESCRIPTION: +# Create a CMakeLists.txt file with minimum ECM setup. +_ecm-common_preamble() { + cat > CMakeLists.txt <<- _EOF_ || die + cmake_minimum_required(VERSION 3.16) + project(${PN} VERSION ${PV}) + + find_package(ECM "${KFMIN}" REQUIRED NO_MODULE) + set(CMAKE_MODULE_PATH \${ECM_MODULE_PATH}) + + # Set by pkg_setup(); Use this if need to differ between KF5 or KF6 + set(KFSLOT ${_KFSLOT}) + set(KDE_INSTALL_DOCBUNDLEDIR "${EPREFIX}/usr/share/help" CACHE PATH "") + + include(KDEInstallDirs) + include(ECMOptionalAddSubdirectory) # commonly used + include(FeatureSummary) + _EOF_ + + if [[ ${ECM_INSTALL_ICONS} ]]; then + cat >> CMakeLists.txt <<- _EOF_ || die + include(ECMInstallIcons) + _EOF_ + fi +} + +# @FUNCTION: _ecm-common_i18n +# @INTERNAL +# @DESCRIPTION: +# Find KF[56]I18n and call ki18n_install(po). +_ecm-common_i18n() { + [[ ${ECM_I18N} == true ]] || return + cat >> CMakeLists.txt <<- _EOF_ || die + find_package(KF\${KFSLOT}I18n REQUIRED) + ki18n_install(po) + _EOF_ +} + +# @FUNCTION: _ecm-common_docs +# @INTERNAL +# @DESCRIPTION: +# Find KF[56]DocTools, call kdoctools_install(po) and +# add_subdirectory(${ECM_HANDBOOK_DIRS}) +_ecm-common_docs() { + { in_iuse handbook && use handbook; } || return + + cat >> CMakeLists.txt <<- _EOF_ || die + find_package(KF\${KFSLOT}DocTools REQUIRED) + kdoctools_install(po) + _EOF_ + + local i + for i in "${ECM_HANDBOOK_DIRS[@]}"; do + if [[ -d ${i} ]]; then + cat >> CMakeLists.txt <<- _EOF_ || die + add_subdirectory(${i}) + _EOF_ + fi + done +} + +# @FUNCTION: _ecm-common_generate_desktop_file +# @INTERNAL +# @DESCRIPTION: +# Find KF[56]KCMUtils and iterate through ECM_KCM_TARGETS to generate +# desktop files out of json. +_ecm-common_generate_desktop_file() { + [[ ${ECM_KCM_TARGETS} ]] || return + + cat >> CMakeLists.txt <<- _EOF_ || die + find_package(KF\${KFSLOT}KCMUtils REQUIRED) + # extracted from kcmutils_generate_desktop_file(kcm_target) + function(ecmcommon_generate_desktop_file kcm_target subdir) + set(IN_FILE \${CMAKE_CURRENT_SOURCE_DIR}/\${subdir}\${kcm_target}.json) + set(OUT_FILE \${CMAKE_CURRENT_BINARY_DIR}/\${kcm_target}.desktop) + add_custom_target(\${kcm_target}-kcm-desktop-gen ALL + COMMAND KF\${KFSLOT}::kcmdesktopfilegenerator \${IN_FILE} \${OUT_FILE} + DEPENDS \${IN_FILE}) + install(FILES \${OUT_FILE} DESTINATION \${KDE_INSTALL_APPDIR}) + endfunction() + _EOF_ + + local i + for i in "${ECM_KCM_TARGETS[@]}"; do + cat >> CMakeLists.txt <<- _EOF_ || die + ecmcommon_generate_desktop_file(${i%:*} ${i#*:}) + _EOF_ + done +} + +# @FUNCTION: _ecm-common_ecm_install_icons +# @INTERNAL +# @DESCRIPTION: +# Installs icons listed in ECM_INSTALL_ICONS using ecm_install_icons +_ecm-common_ecm_install_icons() { + [[ ${ECM_INSTALL_ICONS} ]] || return + local i + for i in "${ECM_INSTALL_ICONS[@]}"; do + cat >> CMakeLists.txt <<- _EOF_ || die + ecm_install_icons(ICONS ${i%:*} DESTINATION ${i#*:}) + _EOF_ + done +} + +# @FUNCTION: _ecm-common_ecm_install_files +# @INTERNAL +# @DESCRIPTION: +# Installs files listed in ECM_INSTALL_FILES using install(FILES ...) +_ecm-common_ecm_install_files() { + [[ ${ECM_INSTALL_FILES} ]] || return + local i + for i in "${ECM_INSTALL_FILES[@]}"; do + cat >> CMakeLists.txt <<- _EOF_ || die + install(FILES ${i%:*} DESTINATION ${i#*:}) + _EOF_ + done +} + +# @FUNCTION: ecm-common_inject_heredoc +# @DESCRIPTION: +# Override this to inject custom Heredoc into the root CMakeLists.txt +ecm-common_inject_heredoc() { + debug-print-function ${FUNCNAME} "$@" +} + +# @FUNCTION: _ecm-common_summary +# @INTERNAL +# @DESCRIPTION: +# Just calls feature_summary +_ecm-common_summary() { + cat >> CMakeLists.txt <<- _EOF_ || die + + feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES) + _EOF_ +} + +# @FUNCTION: _ecm-common-check_deps +# @INTERNAL +# @DESCRIPTION: +# Check existence of requested KF6 dependencies. +_ecm-common-check_deps() { + local chk=0 + case ${1} in + i18n) + if [[ ${ECM_I18N} ]]; then + chk=$(has_version -b "kde-frameworks/ki18n:6") + fi + ;; + doctools) + if [[ ${ECM_HANDBOOK} ]] && in_iuse handbook; then + if use handbook; then + chk=$(has_version -b "kde-frameworks/kdoctools:6") + fi + fi + ;; + kcmutils) + if [[ ${ECM_KCM_TARGETS} ]]; then + chk=$(has_version -b "kde-frameworks/kcmutils:6") + fi + ;; + *) + eerror "Unknown value for _ecm-common-check_deps()" + die "Value ${1} is not supported" + ;; + esac + return ${chk} +} + +# @FUNCTION: ecm-common-check_deps +# @DESCRIPTION: +# Override this to add more KF6 has_version checks to pkg_setup(), +# corresponding with any additional KF6_BDEPEND defined pre-inherit. +# If false, we'll assume KF5 dependencies are fulfilled via BDEPEND. +ecm-common-check_deps() { + return 0 +} + +# @FUNCTION: ecm-common_pkg_setup +# @DESCRIPTION: +# If KFMIN is not lower than 5.240 (default is 6.0.0), do nothing. +# Otherwise, dDetermine which of KF5 or KF6-based depgraph is complete, +# preferring KF6. The result is stored in _KFSLOT, which is then handed +# to CMakeLists.txt as KFSLOT var for further use. +ecm-common_pkg_setup() { + $(ver_test ${KFMIN} -ge 5.240) && return + + if _ecm-common-check_deps i18n && _ecm-common-check_deps doctools && + _ecm-common-check_deps kcmutils && ecm-common-check_deps + then + _KFSLOT=6 + else + _KFSLOT=5 + fi +} + +# @FUNCTION: ecm-common_src_prepare +# @DESCRIPTION: +# Wrapper for cmake_src_prepare with a Heredoc replacing the standard +# root CMakeLists.txt file to only generate and install translations. +ecm-common_src_prepare() { + debug-print-function ${FUNCNAME} "$@" + + _ecm-common_preamble + _ecm-common_i18n + _ecm-common_docs + _ecm-common_generate_desktop_file + _ecm-common_ecm_install_icons + _ecm-common_ecm_install_files + ecm-common_inject_heredoc + _ecm-common_summary + + cmake_src_prepare +} + +# @FUNCTION: ecm-common_src_configure +# @DESCRIPTION: +# Passes -DQT_MAJOR_VERSION=${_KFSLOT} only. +ecm-common_src_configure() { + # necessary for at least KF6KCMUtils + local mycmakeargs=( -DQT_MAJOR_VERSION=${_KFSLOT} ) + cmake_src_configure +} + +fi + +EXPORT_FUNCTIONS pkg_setup src_prepare src_configure diff --git a/eclass/ecm.eclass b/eclass/ecm.eclass index 6d64815984cc..fbe1a23cf205 100644 --- a/eclass/ecm.eclass +++ b/eclass/ecm.eclass @@ -84,8 +84,8 @@ fi # @ECLASS_VARIABLE: ECM_HANDBOOK # @DESCRIPTION: -# Will accept "true", "false", "optional", "forceoptional". If set to "false", -# do nothing. +# Will accept "true", "false", "optional", "forceoptional", "forceoff". +# If set to "false" (default), do nothing. # Otherwise, add "+handbook" to IUSE, add the appropriate dependency, and let # KF${_KFSLOT}DocTools generate and install the handbook from docbook file(s) # found in ECM_HANDBOOK_DIR. However if !handbook, disable build of @@ -122,6 +122,15 @@ if [[ ${CATEGORY} = kde-frameworks ]]; then fi : "${ECM_QTHELP:=false}" +# @ECLASS_VARIABLE: ECM_REMOVE_FROM_INSTALL +# @DEFAULT_UNSET +# @DESCRIPTION: +# Array of <paths> to remove from install image. +if [[ ${ECM_REMOVE_FROM_INSTALL} ]]; then + [[ ${ECM_REMOVE_FROM_INSTALL@a} == *a* ]] || + die "ECM_REMOVE_FROM_INSTALL must be an array" +fi + # @ECLASS_VARIABLE: ECM_TEST # @DEFAULT_UNSET # @DESCRIPTION: @@ -233,7 +242,7 @@ case ${ECM_HANDBOOK} in IUSE+=" +handbook" BDEPEND+=" handbook? ( >=kde-frameworks/kdoctools-${KFMIN}:${_KFSLOT} )" ;; - false) ;; + false|forceoff) ;; *) eerror "Unknown value for \${ECM_HANDBOOK}" die "Value ${ECM_HANDBOOK} is not supported" @@ -277,14 +286,15 @@ BDEPEND+=" dev-libs/libpcre2:* >=kde-frameworks/extra-cmake-modules-${KFMIN}:* " -RDEPEND+=" >=kde-frameworks/kf-env-4" if [[ ${ECM_TEST} != false ]]; then IUSE+=" test" RESTRICT+=" !test? ( test )" fi if [[ ${_KFSLOT} == 6 ]]; then + RDEPEND+=" >=kde-frameworks/kf-env-6" COMMONDEPEND+=" dev-qt/qtbase:${_KFSLOT}" else + RDEPEND+=" >=kde-frameworks/kf-env-4" COMMONDEPEND+=" dev-qt/qtcore:${_KFSLOT}" if [[ ${ECM_TEST} != false ]]; then DEPEND+=" test? ( dev-qt/qttest:5 )" @@ -306,7 +316,7 @@ unset COMMONDEPEND # @DESCRIPTION: # Determine if the current GCC version is acceptable, otherwise die. _ecm_check_gcc_version() { - if [[ ${MERGE_TYPE} != binary && -v ${KDE_GCC_MINIMAL} ]] && tc-is-gcc; then + if [[ ${MERGE_TYPE} != binary && -v KDE_GCC_MINIMAL ]] && tc-is-gcc; then local version=$(gcc-version) @@ -445,6 +455,25 @@ ecm_punt_bogus_dep() { fi } +# @FUNCTION: _ecm_punt_kdoctools_install +# @INTERNAL +# @DESCRIPTION: +# Disables kdoctools_install(po) call. +_ecm_punt_kdoctools_install() { + sed -e "s/^ *kdoctools_install.*(po.*)/#& # disabled by ecm.eclass/" \ + -i CMakeLists.txt || die +} + +# @FUNCTION: ecm_punt_po_install +# @DESCRIPTION: +# Disables handling of po subdirectories, typically when the package +# is outsourcing common files to a ${PN}-common split package. +ecm_punt_po_install() { + _ecm_punt_kdoctools_install + sed -e "s/^ *ki18n_install.*(po.*)/#& # disabled by ecm.eclass/" \ + -i CMakeLists.txt || die +} + # @FUNCTION: ecm_pkg_pretend # @DESCRIPTION: # Checks if the active compiler meets the minimum version requirements. @@ -477,13 +506,16 @@ ecm_src_prepare() { fi # only enable handbook when required - if in_iuse handbook && ! use handbook ; then + if [[ ${ECM_HANDBOOK} == forceoff ]] || + { [[ ${ECM_HANDBOOK} = forceoptional ]] && in_iuse handbook && ! use handbook; } + then + ecm_punt_kf_module DocTools + _ecm_punt_kdoctools_install + fi + if [[ ${ECM_HANDBOOK} == forceoff ]] || + { in_iuse handbook && ! use handbook; } + then cmake_comment_add_subdirectory ${ECM_HANDBOOK_DIR} - - if [[ ${ECM_HANDBOOK} = forceoptional ]] ; then - ecm_punt_kf_module DocTools - sed -i -e "/kdoctools_install/I s/^/#DONT/" CMakeLists.txt || die - fi fi # drop translations when nls is not wanted @@ -584,6 +616,12 @@ ecm_src_configure() { # move handbook outside of doc dir, bug 667138 -DKDE_INSTALL_DOCBUNDLEDIR="${EPREFIX}/usr/share/help" ) + + # bug 928345 + # TODO: Eventually it should be put to upstream as to why LIBEXECDIR + # in KDEInstallDirsCommon.cmake is set to EXECROOTDIR/LIBDIR/libexec + [[ ${_KFSLOT} == 6 ]] && \ + cmakeargs+=( -DKDE_INSTALL_LIBEXECDIR="${EPREFIX}/usr/libexec" ) fi # allow the ebuild to override what we set here @@ -642,14 +680,17 @@ ecm_src_test() { # Wrapper for cmake_src_install. Drops executable bit from .desktop files # installed inside /usr/share/applications. This is set by cmake when install() # is called in PROGRAM form, as seen in many kde.org projects. +# In case kde.org.eclass is detected, in case KDE_ORG_NAME != PN, tries real +# hard to detect, then rename, metainfo.xml appdata files to something unique +# including SLOT if else than "0" (basically KDE_ORG_NAME -> PN+SLOT). ecm_src_install() { debug-print-function ${FUNCNAME} "$@" cmake_src_install + local f # bug 621970 if [[ -d "${ED}"/usr/share/applications ]]; then - local f for f in "${ED}"/usr/share/applications/*.desktop; do if [[ -x ${f} ]]; then einfo "Removing executable bit from ${f#${ED}}" @@ -657,6 +698,37 @@ ecm_src_install() { fi done fi + + mv_metainfo() { + if [[ -f ${1} ]]; then + mv -v ${1} ${1/${2}/${3}} || die + fi + } + + if [[ -n ${_KDE_ORG_ECLASS} && -d "${ED}"/usr/share/metainfo/ ]]; then + if [[ ${KDE_ORG_NAME} != ${PN} ]]; then + local ecm_metainfo + pushd "${ED}"/usr/share/metainfo/ > /dev/null || die + for ecm_metainfo in find * -type f -iname "*metainfo.xml"; do + case ${ecm_metainfo} in + *${KDE_ORG_NAME}*) + mv_metainfo ${ecm_metainfo} ${KDE_ORG_NAME} ${PN}${SLOT/0*/} + ;; + *${KDE_ORG_NAME/-/_}*) + mv_metainfo ${ecm_metainfo} ${KDE_ORG_NAME/-/_} ${PN}${SLOT/0*/} + ;; + org.kde.*) + mv_metainfo ${ecm_metainfo} "org.kde." "org.kde.${PN}${SLOT/0*/}-" + ;; + esac + done + popd > /dev/null || die + fi + fi + + for f in "${ECM_REMOVE_FROM_INSTALL[@]}"; do + rm -r "${ED}"${f} || die + done } # @FUNCTION: ecm_pkg_preinst diff --git a/eclass/epatch.eclass b/eclass/epatch.eclass deleted file mode 100644 index ff3fd13721fe..000000000000 --- a/eclass/epatch.eclass +++ /dev/null @@ -1,381 +0,0 @@ -# Copyright 1999-2024 Gentoo Authors -# Distributed under the terms of the GNU General Public License v2 - -# @DEAD -# @ECLASS: epatch.eclass -# @MAINTAINER: -# base-system@gentoo.org -# @SUPPORTED_EAPIS: 6 -# @BLURB: easy patch application functions -# @DEPRECATED: eapply from EAPI 7 -# @DESCRIPTION: -# An eclass providing epatch and epatch_user functions to easily apply -# patches to ebuilds. Mostly superseded by eapply* in EAPI 6. - -if [[ -z ${_EPATCH_ECLASS} ]]; then - -case ${EAPI} in - 6) ;; - *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; -esac - -inherit estack - -# @VARIABLE: EPATCH_SOURCE -# @DESCRIPTION: -# Default directory to search for patches. -EPATCH_SOURCE="${WORKDIR}/patch" -# @VARIABLE: EPATCH_SUFFIX -# @DESCRIPTION: -# Default extension for patches (do not prefix the period yourself). -EPATCH_SUFFIX="patch.bz2" -# @VARIABLE: EPATCH_OPTS -# @DESCRIPTION: -# Options to pass to patch. Meant for ebuild/package-specific tweaking -# such as forcing the patch level (-p#) or fuzz (-F#) factor. Note that -# for single patch tweaking, you can also pass flags directly to epatch. -EPATCH_OPTS="" -# @VARIABLE: EPATCH_COMMON_OPTS -# @DESCRIPTION: -# Common options to pass to `patch`. You probably should never need to -# change these. If you do, please discuss it with base-system first to -# be sure. -# @CODE -# -g0 - keep RCS, ClearCase, Perforce and SCCS happy #24571 -# --no-backup-if-mismatch - do not leave .orig files behind -# -E - automatically remove empty files -# @CODE -EPATCH_COMMON_OPTS="-g0 -E --no-backup-if-mismatch" -# @VARIABLE: EPATCH_EXCLUDE -# @DESCRIPTION: -# List of patches not to apply. Note this is only file names, -# and not the full path. Globs accepted. -EPATCH_EXCLUDE="" -# @VARIABLE: EPATCH_MULTI_MSG -# @DESCRIPTION: -# Change the printed message for multiple patches. -EPATCH_MULTI_MSG="Applying various patches (bugfixes/updates) ..." -# @VARIABLE: EPATCH_FORCE -# @DESCRIPTION: -# Only require patches to match EPATCH_SUFFIX rather than the extended -# arch naming style. -EPATCH_FORCE="no" -# @VARIABLE: EPATCH_USER_EXCLUDE -# @DEFAULT_UNSET -# @DESCRIPTION: -# List of patches not to apply. Note this is only file names, -# and not the full path. Globs accepted. - -# @FUNCTION: epatch -# @USAGE: [options] [patches] [dirs of patches] -# @DESCRIPTION: -# epatch is designed to greatly simplify the application of patches. It can -# process patch files directly, or directories of patches. The patches may be -# compressed (bzip/gzip/etc...) or plain text. You generally need not specify -# the -p option as epatch will automatically attempt -p0 to -p4 until things -# apply successfully. -# -# If you do not specify any patches/dirs, then epatch will default to the -# directory specified by EPATCH_SOURCE. -# -# Any options specified that start with a dash will be passed down to patch -# for this specific invocation. As soon as an arg w/out a dash is found, then -# arg processing stops. -# -# When processing directories, epatch will apply all patches that match: -# @CODE -# if ${EPATCH_FORCE} != "yes" -# ??_${ARCH}_foo.${EPATCH_SUFFIX} -# else -# *.${EPATCH_SUFFIX} -# @CODE -# The leading ?? are typically numbers used to force consistent patch ordering. -# The arch field is used to apply patches only for the host architecture with -# the special value of "all" means apply for everyone. Note that using values -# other than "all" is highly discouraged -- you should apply patches all the -# time and let architecture details be detected at configure/compile time. -# -# If EPATCH_SUFFIX is empty, then no period before it is implied when searching -# for patches to apply. -# -# Refer to the other EPATCH_xxx variables for more customization of behavior. -epatch() { - _epatch_draw_line() { - # create a line of same length as input string - [[ -z $1 ]] && set "$(printf "%65s" '')" - echo "${1//?/=}" - } - - unset P4CONFIG P4PORT P4USER # keep perforce at bay #56402 - - # First process options. We localize the EPATCH_OPTS setting - # from above so that we can pass it on in the loop below with - # any additional values the user has specified. - local EPATCH_OPTS=( ${EPATCH_OPTS[*]} ) - while [[ $# -gt 0 ]] ; do - case $1 in - -*) EPATCH_OPTS+=( "$1" ) ;; - *) break ;; - esac - shift - done - - # Let the rest of the code process one user arg at a time -- - # each arg may expand into multiple patches, and each arg may - # need to start off with the default global EPATCH_xxx values - if [[ $# -gt 1 ]] ; then - local m - for m in "$@" ; do - epatch "${m}" - done - return 0 - fi - - local SINGLE_PATCH="no" - # no args means process ${EPATCH_SOURCE} - [[ $# -eq 0 ]] && set -- "${EPATCH_SOURCE}" - - if [[ -f $1 ]] ; then - SINGLE_PATCH="yes" - set -- "$1" - # Use the suffix from the single patch (localize it); the code - # below will find the suffix for us - local EPATCH_SUFFIX=$1 - - elif [[ -d $1 ]] ; then - # We have to force sorting to C so that the wildcard expansion is consistent #471666. - evar_push_set LC_COLLATE C - # Some people like to make dirs of patches w/out suffixes (vim). - set -- "$1"/*${EPATCH_SUFFIX:+."${EPATCH_SUFFIX}"} - evar_pop - - elif [[ -f ${EPATCH_SOURCE}/$1 ]] ; then - # Re-use EPATCH_SOURCE as a search dir - epatch "${EPATCH_SOURCE}/$1" - return $? - - else - # sanity check ... if it isn't a dir or file, wtf man ? - [[ $# -ne 0 ]] && EPATCH_SOURCE=$1 - echo - eerror "Cannot find \$EPATCH_SOURCE! Value for \$EPATCH_SOURCE is:" - eerror - eerror " ${EPATCH_SOURCE}" - eerror " ( ${EPATCH_SOURCE##*/} )" - echo - die "Cannot find \$EPATCH_SOURCE!" - fi - - # Now that we know we're actually going to apply something, merge - # all of the patch options back in to a single variable for below. - EPATCH_OPTS="${EPATCH_COMMON_OPTS} ${EPATCH_OPTS[*]}" - - local PIPE_CMD - case ${EPATCH_SUFFIX##*\.} in - xz) PIPE_CMD="xz -dc" ;; - lzma) PIPE_CMD="lzma -dc" ;; - bz2) PIPE_CMD="bzip2 -dc" ;; - gz|Z|z) PIPE_CMD="gzip -dc" ;; - ZIP|zip) PIPE_CMD="unzip -p" ;; - *) ;; - esac - - [[ ${SINGLE_PATCH} == "no" ]] && einfo "${EPATCH_MULTI_MSG}" - - local x - for x in "$@" ; do - # If the patch dir given contains subdirs, or our EPATCH_SUFFIX - # didn't match anything, ignore continue on - [[ ! -f ${x} ]] && continue - - local patchname=${x##*/} - - # Apply single patches, or forced sets of patches, or - # patches with ARCH dependent names. - # ???_arch_foo.patch - # Else, skip this input altogether - local a=${patchname#*_} # strip the ???_ - a=${a%%_*} # strip the _foo.patch - if ! [[ ${SINGLE_PATCH} == "yes" || \ - ${EPATCH_FORCE} == "yes" || \ - ${a} == all || \ - ${a} == ${ARCH} ]] - then - continue - fi - - # Let people filter things dynamically - if [[ -n ${EPATCH_EXCLUDE}${EPATCH_USER_EXCLUDE} ]] ; then - # let people use globs in the exclude - eshopts_push -o noglob - - local ex - for ex in ${EPATCH_EXCLUDE} ; do - if [[ ${patchname} == ${ex} ]] ; then - einfo " Skipping ${patchname} due to EPATCH_EXCLUDE ..." - eshopts_pop - continue 2 - fi - done - - for ex in ${EPATCH_USER_EXCLUDE} ; do - if [[ ${patchname} == ${ex} ]] ; then - einfo " Skipping ${patchname} due to EPATCH_USER_EXCLUDE ..." - eshopts_pop - continue 2 - fi - done - - eshopts_pop - fi - - if [[ ${SINGLE_PATCH} == "yes" ]] ; then - ebegin "Applying ${patchname}" - else - ebegin " ${patchname}" - fi - - # Handle aliased patch command #404447 #461568 - local patch="patch" - eval $(alias patch 2>/dev/null | sed 's:^alias ::') - - # most of the time, there will only be one run per unique name, - # but if there are more, make sure we get unique log filenames - local STDERR_TARGET="${T}/${patchname}.out" - if [[ -e ${STDERR_TARGET} ]] ; then - STDERR_TARGET="${T}/${patchname}-$$.out" - fi - - printf "***** %s *****\nPWD: %s\nPATCH TOOL: %s -> %s\nVERSION INFO:\n%s\n\n" \ - "${patchname}" \ - "${PWD}" \ - "${patch}" \ - "$(type -P "${patch}")" \ - "$(${patch} --version)" \ - > "${STDERR_TARGET}" - - # Decompress the patch if need be - local count=0 - local PATCH_TARGET - if [[ -n ${PIPE_CMD} ]] ; then - PATCH_TARGET="${T}/$$.patch" - echo "PIPE_COMMAND: ${PIPE_CMD} ${x} > ${PATCH_TARGET}" >> "${STDERR_TARGET}" - - if ! (${PIPE_CMD} "${x}" > "${PATCH_TARGET}") >> "${STDERR_TARGET}" 2>&1 ; then - echo - eerror "Could not extract patch!" - #die "Could not extract patch!" - count=5 - break - fi - else - PATCH_TARGET=${x} - fi - - # Check for absolute paths in patches. If sandbox is disabled, - # people could (accidentally) patch files in the root filesystem. - # Or trigger other unpleasantries #237667. So disallow -p0 on - # such patches. - local abs_paths=$(grep -E -n '^[-+]{3} /' "${PATCH_TARGET}" | awk '$2 != "/dev/null" { print }') - if [[ -n ${abs_paths} ]] ; then - count=1 - printf "NOTE: skipping -p0 due to absolute paths in patch:\n%s\n" "${abs_paths}" >> "${STDERR_TARGET}" - fi - # Similar reason, but with relative paths. - local rel_paths=$(grep -E -n '^[-+]{3} [^ ]*[.][.]/' "${PATCH_TARGET}") - if [[ -n ${rel_paths} ]] ; then - echo - eerror "Rejected Patch: ${patchname}!" - eerror " ( ${PATCH_TARGET} )" - eerror - eerror "Your patch uses relative paths '../':" - eerror "${rel_paths}" - echo - die "you need to fix the relative paths in patch" - fi - - # Dynamically detect the correct -p# ... i'm lazy, so shoot me :/ - local patch_cmd - while [[ ${count} -lt 5 ]] ; do - patch_cmd="${patch} -p${count} ${EPATCH_OPTS}" - - # Generate some useful debug info ... - ( - _epatch_draw_line "***** ${patchname} *****" - echo - echo "PATCH COMMAND: ${patch_cmd} --dry-run -f < '${PATCH_TARGET}'" - echo - _epatch_draw_line "***** ${patchname} *****" - ${patch_cmd} --dry-run -f < "${PATCH_TARGET}" 2>&1 - ret=$? - echo - echo "patch program exited with status ${ret}" - exit ${ret} - ) >> "${STDERR_TARGET}" - - if [ $? -eq 0 ] ; then - ( - _epatch_draw_line "***** ${patchname} *****" - echo - echo "ACTUALLY APPLYING ${patchname} ..." - echo "PATCH COMMAND: ${patch_cmd} < '${PATCH_TARGET}'" - echo - _epatch_draw_line "***** ${patchname} *****" - ${patch_cmd} < "${PATCH_TARGET}" 2>&1 - ret=$? - echo - echo "patch program exited with status ${ret}" - exit ${ret} - ) >> "${STDERR_TARGET}" - - if [ $? -ne 0 ] ; then - echo - eerror "A dry-run of patch command succeeded, but actually" - eerror "applying the patch failed!" - #die "Real world sux compared to the dreamworld!" - count=5 - fi - break - fi - - : $(( count++ )) - done - - (( EPATCH_N_APPLIED_PATCHES++ )) - - # if we had to decompress the patch, delete the temp one - if [[ -n ${PIPE_CMD} ]] ; then - rm -f "${PATCH_TARGET}" - fi - - if [[ ${count} -ge 5 ]] ; then - echo - eerror "Failed patch: ${patchname}!" - eerror " ( ${PATCH_TARGET} )" - eerror - eerror "Include in your bug report the contents of:" - eerror - eerror " ${STDERR_TARGET}" - echo - die "Failed patch: ${patchname}!" - fi - - # if everything worked, delete the full debug patch log - rm -f "${STDERR_TARGET}" - - # then log away the exact stuff for people to review later - cat <<-EOF >> "${T}/epatch.log" - PATCH: ${x} - CMD: ${patch_cmd} - PWD: ${PWD} - - EOF - eend 0 - done - - [[ ${SINGLE_PATCH} == "no" ]] && einfo "Done with patching" - : # everything worked -} - -_EPATCH_ECLASS=1 -fi #_EPATCH_ECLASS diff --git a/eclass/eqawarn.eclass b/eclass/eqawarn.eclass index 288976182fb3..df6b13151d74 100644 --- a/eclass/eqawarn.eclass +++ b/eclass/eqawarn.eclass @@ -1,6 +1,7 @@ # Copyright 1999-2022 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 +# @DEAD # @ECLASS: eqawarn.eclass # @MAINTAINER: # base-system@gentoo.org diff --git a/eclass/eutils.eclass b/eclass/eutils.eclass deleted file mode 100644 index 1e36c78f7780..000000000000 --- a/eclass/eutils.eclass +++ /dev/null @@ -1,21 +0,0 @@ -# Copyright 1999-2024 Gentoo Authors -# Distributed under the terms of the GNU General Public License v2 - -# @DEAD -# @ECLASS: eutils.eclass -# @MAINTAINER: -# base-system@gentoo.org -# @SUPPORTED_EAPIS: 6 -# @BLURB: many extra (but common) functions that are used in ebuilds -# @DEPRECATED: native package manager functions, more specific eclasses - -if [[ -z ${_EUTILS_ECLASS} ]]; then -_EUTILS_ECLASS=1 - -# implicitly inherited (now split) eclasses -case ${EAPI} in - 6) inherit desktop edos2unix epatch eqawarn estack ltprune multilib \ - preserve-libs strip-linguas toolchain-funcs vcs-clean wrapper ;; - *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; -esac -fi diff --git a/eclass/findlib.eclass b/eclass/findlib.eclass index fdcaa0c1b77c..f0371ef00e10 100644 --- a/eclass/findlib.eclass +++ b/eclass/findlib.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: findlib.eclass @@ -68,6 +68,10 @@ findlib_src_preinst() { # @DESCRIPTION: # Install with a properly setup findlib findlib_src_install() { + # OCaml generates textrels on 32-bit arches + if use arm || use ppc || use x86 ; then + export QA_TEXTRELS='.*' + fi findlib_src_preinst make DESTDIR="${D}" "$@" install || die "make failed" } diff --git a/eclass/flag-o-matic.eclass b/eclass/flag-o-matic.eclass index ecac452aa0ef..02cd2dcfc592 100644 --- a/eclass/flag-o-matic.eclass +++ b/eclass/flag-o-matic.eclass @@ -10,14 +10,18 @@ # This eclass contains a suite of functions to help developers sanely # and safely manage toolchain flags in their builds. +if [[ -z ${_FLAG_O_MATIC_ECLASS} ]]; then +_FLAG_O_MATIC_ECLASS=1 + case ${EAPI} in - 6|7|8) ;; + 6) + ewarn "${CATEGORY}/${PF}: ebuild uses ${ECLASS} with deprecated EAPI ${EAPI}!" + ewarn "${CATEGORY}/${PF}: Support will be removed on 2024-10-08. Please port to newer EAPI." + ;; + 7|8) ;; *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; esac -if [[ -z ${_FLAG_O_MATIC_ECLASS} ]]; then -_FLAG_O_MATIC_ECLASS=1 - inherit toolchain-funcs [[ ${EAPI} == 6 ]] && inherit eqawarn @@ -129,6 +133,10 @@ _setup-allowed-flags() { # needed for arm64 (and in particular SCS) -ffixed-x18 + # needed for riscv (to prevent unaligned vector access) + # See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115789 + -mstrict-align -mvector-strict-align + # gcc 4.5 -mno-fma4 -mno-movbe -mno-xop -mno-lwp # gcc 4.6 diff --git a/eclass/fortran-2.eclass b/eclass/fortran-2.eclass index 855dcba59a39..5e2ce1fc68e4 100644 --- a/eclass/fortran-2.eclass +++ b/eclass/fortran-2.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: fortran-2.eclass @@ -26,14 +26,18 @@ # # FORTRAN_NEED_OPENMP=1 +if [[ -z ${_FORTRAN_2_ECLASS} ]]; then +_FORTRAN_2_ECLASS=1 + case ${EAPI} in - 6|7|8) ;; + 6) + ewarn "${CATEGORY}/${PF}: ebuild uses ${ECLASS} with deprecated EAPI ${EAPI}!" + ewarn "${CATEGORY}/${PF}: Support will be removed on 2024-10-08. Please port to newer EAPI." + ;; + 7|8) ;; *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; esac -if [[ -z ${_FORTRAN_2_ECLASS} ]]; then -_FORTRAN_2_ECLASS=1 - inherit toolchain-funcs # @ECLASS_VARIABLE: FORTRAN_NEED_OPENMP diff --git a/eclass/gear.kde.org.eclass b/eclass/gear.kde.org.eclass index e0d0a8640b5b..8089cbb53bf7 100644 --- a/eclass/gear.kde.org.eclass +++ b/eclass/gear.kde.org.eclass @@ -94,7 +94,6 @@ if $(ver_test -gt 24.01.75); then dragon | \ elisa | \ eventviews | \ - ffmpegthumbs | \ filelight | \ granatier | \ grantlee-editor | \ @@ -132,7 +131,6 @@ if $(ver_test -gt 24.01.75); then kde-dev-utils | \ kdebugsettings | \ kdeconnect | \ - kdegraphics-mobipocket | \ kdenetwork-filesharing | \ kdenlive | \ kdepim-addons | \ @@ -243,7 +241,6 @@ if $(ver_test -gt 24.01.75); then spectacle | \ svgpart | \ sweeper | \ - thumbnailers | \ yakuake | \ zanshin) RDEPEND+=" !${CATEGORY}/${PN}:5" ;; @@ -258,10 +255,34 @@ if $(ver_test -gt 24.04.75); then itinerary | \ kio-perldoc | \ kolourpaint | \ + libkcompactdisc | \ signon-kwallet-extension) RDEPEND+=" !${CATEGORY}/${PN}:5" ;; *) ;; esac fi +# list of applications ported to KF6 post-24.05 in SLOT=6 having to block SLOT=5 +if $(ver_test -gt 24.07.75); then + case ${PN} in + k3b | \ + kde-dev-scripts | \ + kdevelop | \ + kdevelop-php | \ + kdevelop-python | \ + kgraphviewer | \ + kimagemapeditor | \ + kmplot | \ + kompare | \ + krdc | \ + libkomparediff2 | \ + lokalize | \ + massif-visualizer | \ + poxml | \ + skanlite) + RDEPEND+=" !${CATEGORY}/${PN}:5" ;; + *) ;; + esac +fi + fi diff --git a/eclass/git-r3.eclass b/eclass/git-r3.eclass index 565f6ada8382..35ad6afe8e88 100644 --- a/eclass/git-r3.eclass +++ b/eclass/git-r3.eclass @@ -4,7 +4,7 @@ # @ECLASS: git-r3.eclass # @MAINTAINER: # Michał Górny <mgorny@gentoo.org> -# @SUPPORTED_EAPIS: 6 7 8 +# @SUPPORTED_EAPIS: 7 8 # @BLURB: Eclass for fetching and unpacking git repositories. # @DESCRIPTION: # Third generation eclass for easing maintenance of live ebuilds using @@ -26,7 +26,7 @@ # If non-empty, then the repo likely needs EGIT_LFS to clone properly. case ${EAPI} in - 6|7|8) ;; + 7|8) ;; *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; esac @@ -35,13 +35,8 @@ _GIT_R3_ECLASS=1 PROPERTIES+=" live" -if [[ ${EAPI} != 6 ]]; then - BDEPEND=">=dev-vcs/git-1.8.2.1[curl]" - [[ ${EGIT_LFS} ]] && BDEPEND+=" dev-vcs/git-lfs" -else - DEPEND=">=dev-vcs/git-1.8.2.1[curl]" - [[ ${EGIT_LFS} ]] && DEPEND+=" dev-vcs/git-lfs" -fi +BDEPEND=">=dev-vcs/git-1.8.2.1[curl]" +[[ ${EGIT_LFS} ]] && BDEPEND+=" dev-vcs/git-lfs" # @ECLASS_VARIABLE: EGIT_CLONE_TYPE # @USER_VARIABLE 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/gnuconfig.eclass b/eclass/gnuconfig.eclass index fb73087aeacf..afcb8feee04e 100644 --- a/eclass/gnuconfig.eclass +++ b/eclass/gnuconfig.eclass @@ -16,14 +16,18 @@ # other files that come with automake, e.g. depcomp, mkinstalldirs, etc. # -case ${EAPI:-0} in - 6|7|8) ;; - *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; -esac - if [[ -z ${_GNUCONFIG_ECLASS} ]] ; then _GNUCONFIG_CLASS=1 +case ${EAPI} in + 6) + ewarn "${CATEGORY}/${PF}: ebuild uses ${ECLASS} with deprecated EAPI ${EAPI}!" + ewarn "${CATEGORY}/${PF}: Support will be removed on 2024-10-08. Please port to newer EAPI." + ;; + 7|8) ;; + *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; +esac + # @ECLASS_VARIABLE: GNUCONFIG_DEPEND # @OUTPUT_VARIABLE # @DESCRIPTION: diff --git a/eclass/go-env.eclass b/eclass/go-env.eclass index 1a2c9787a146..11fdf943e774 100644 --- a/eclass/go-env.eclass +++ b/eclass/go-env.eclass @@ -6,11 +6,17 @@ # Flatcar Linux Maintainers <infra@flatcar-linux.org> # @AUTHOR: # Flatcar Linux Maintainers <infra@flatcar-linux.org> +# @SUPPORTED_EAPIS: 7 8 # @BLURB: Helper eclass for setting the Go compile environment. Required for cross-compiling. # @DESCRIPTION: # This eclass includes helper functions for setting the compile environment for Go ebuilds. # Intended to be called by other Go eclasses in an early build stage, e.g. src_unpack. +case ${EAPI} in + 7|8) ;; + *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; +esac + if [[ -z ${_GO_ENV_ECLASS} ]]; then _GO_ENV_ECLASS=1 @@ -34,19 +40,40 @@ go-env_set_compile_environment() { use x86 && export GO386=$(go-env_go386) # XXX: Hack for checking ICE (bug #912152, gcc PR113204) - case ${EAPI} in - 6) - has_version "sys-devel/gcc[debug]" && filter-lto - ;; - *) - has_version -b "sys-devel/gcc[debug]" && filter-lto - ;; - esac + has_version -b "sys-devel/gcc[debug]" && filter-lto export CGO_CFLAGS="${CGO_CFLAGS:-$CFLAGS}" export CGO_CPPFLAGS="${CGO_CPPFLAGS:-$CPPFLAGS}" export CGO_CXXFLAGS="${CGO_CXXFLAGS:-$CXXFLAGS}" export CGO_LDFLAGS="${CGO_LDFLAGS:-$LDFLAGS}" + + # bug #929219 + if tc-is-gcc ; then + CGO_CFLAGS=$( + CFLAGS=${CGO_CFLAGS} + replace-flags -g3 -g + replace-flags -ggdb3 -ggdb + printf %s "${CFLAGS}" + ) + fi +} + +# @FUNCTION: go-env_goos +# @USAGE: [toolchain prefix] +# @DESCRIPTION: +# Returns the appropriate GOOS setting for the target operating system. +go-env_goos() { + local target=${1:-${CHOST}} + case "${target}" in + *-linux*) echo linux ;; + *-darwin*) echo darwin ;; + *-freebsd*) echo freebsd ;; + *-netbsd*) echo netbsd ;; + *-openbsd*) echo openbsd ;; + *-solaris*) echo solaris ;; + *-cygwin*|*-interix*|*-winnt*) echo windows ;; + *) die "unknown GOOS for ${target}" ;; + esac } # @FUNCTION: go-env_goarch @@ -54,21 +81,23 @@ go-env_set_compile_environment() { # @DESCRIPTION: # Returns the appropriate GOARCH setting for the target architecture. go-env_goarch() { - # By chance most portage arch names match Go - local tc_arch=$(tc-arch $@) - case "${tc_arch}" in - x86) echo 386;; - x64-*) echo amd64;; - loong) echo loong64;; - mips) if use abi_mips_o32; then - [[ $(tc-endian $@) = big ]] && echo mips || echo mipsle - elif use abi_mips_n64; then - [[ $(tc-endian $@) = big ]] && echo mips64 || echo mips64le - fi ;; - ppc64) [[ $(tc-endian $@) = big ]] && echo ppc64 || echo ppc64le ;; - riscv) echo riscv64 ;; - s390) echo s390x ;; - *) echo "${tc_arch}";; + local target=${1:-${CHOST}} + # Some Portage arch names match Go. + local arch=$(tc-arch "${target}") cpu=${target%%-*} + case "${arch}" in + x86) echo 386 ;; + loong) echo loong64 ;; + *) case "${cpu}" in + aarch64*be) echo arm64be ;; + arm64) echo arm64 ;; + arm*b*) echo armbe ;; + mips64*l*) echo mips64le ;; + mips*l*) echo mipsle ;; + powerpc64le*) echo ppc64le ;; + arm64|s390x) echo "${cpu}" ;; + mips64*|riscv64*|sparc64*) echo "${arch}64" ;; + *) echo "${arch}" ;; + esac ;; esac } diff --git a/eclass/golang-base.eclass b/eclass/golang-base.eclass index 4bba00200cfc..a2996e3b0683 100644 --- a/eclass/golang-base.eclass +++ b/eclass/golang-base.eclass @@ -1,10 +1,10 @@ -# Copyright 1999-2022 Gentoo Authors +# Copyright 1999-2024 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 # @ECLASS: golang-base.eclass # @MAINTAINER: # William Hubbs <williamh@gentoo.org> -# @SUPPORTED_EAPIS: 5 6 7 +# @SUPPORTED_EAPIS: 7 # @BLURB: Eclass that provides base functions for Go packages. # @DEPRECATED: go-module.eclass # @DESCRIPTION: @@ -12,12 +12,9 @@ # programming language; it also provides the build-time dependency on # dev-lang/go. -case "${EAPI:-0}" in - 5|6|7) - ;; - *) - die "${ECLASS}: Unsupported EAPI (EAPI=${EAPI})" - ;; +case ${EAPI} in + 7) ;; + *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; esac if [[ -z ${_GOLANG_BASE} ]]; then diff --git a/eclass/golang-build.eclass b/eclass/golang-build.eclass index 235313bd70f5..b5218ce36572 100644 --- a/eclass/golang-build.eclass +++ b/eclass/golang-build.eclass @@ -1,10 +1,10 @@ -# Copyright 1999-2023 Gentoo Authors +# Copyright 1999-2024 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 # @ECLASS: golang-build.eclass # @MAINTAINER: # William Hubbs <williamh@gentoo.org> -# @SUPPORTED_EAPIS: 6 7 +# @SUPPORTED_EAPIS: 7 # @PROVIDES: golang-base # @BLURB: Eclass for compiling go packages. # @DEPRECATED: go-module.eclass @@ -13,7 +13,7 @@ # functions for software written in the Go programming language. case ${EAPI} in - 6|7) ;; + 7) ;; *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; esac diff --git a/eclass/golang-vcs-snapshot.eclass b/eclass/golang-vcs-snapshot.eclass index d34b8a6e913d..a91ddbbe3615 100644 --- a/eclass/golang-vcs-snapshot.eclass +++ b/eclass/golang-vcs-snapshot.eclass @@ -1,10 +1,10 @@ -# Copyright 1999-2023 Gentoo Authors +# Copyright 1999-2024 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 # @ECLASS: golang-vcs-snapshot.eclass # @MAINTAINER: # William Hubbs <williamh@gentoo.org> -# @SUPPORTED_EAPIS: 6 7 +# @SUPPORTED_EAPIS: 7 # @PROVIDES: golang-base # @BLURB: eclass to unpack VCS snapshot tarballs for Go software # @DEPRECATED: go-module.eclass @@ -45,7 +45,7 @@ # and add the vendored tarballs to ${WORKDIR}/src/${EGO_PN}/vendor case ${EAPI} in - 6|7) ;; + 7) ;; *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; esac diff --git a/eclass/golang-vcs.eclass b/eclass/golang-vcs.eclass index 6f7a837bc15f..dee040505d23 100644 --- a/eclass/golang-vcs.eclass +++ b/eclass/golang-vcs.eclass @@ -1,10 +1,10 @@ -# Copyright 1999-2023 Gentoo Authors +# Copyright 1999-2024 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 # @ECLASS: golang-vcs.eclass # @MAINTAINER: # William Hubbs <williamh@gentoo.org> -# @SUPPORTED_EAPIS: 6 7 +# @SUPPORTED_EAPIS: 7 # @PROVIDES: golang-base # @BLURB: Eclass for fetching and unpacking go repositories. # @DEPRECATED: go-module.eclass @@ -13,7 +13,7 @@ # of software written in the Go programming language. case ${EAPI} in - 6|7) ;; + 7) ;; *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; esac diff --git a/eclass/greadme.eclass b/eclass/greadme.eclass new file mode 100644 index 000000000000..38190becf91d --- /dev/null +++ b/eclass/greadme.eclass @@ -0,0 +1,251 @@ +# Copyright 1999-2024 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +# @ECLASS: greadme.eclass +# @MAINTAINER: +# Florian Schmaus <flow@gentoo.org> +# @SUPPORTED_EAPIS: 8 +# @BLURB: install a doc file, that will be conditionally shown via elog messages +# @DESCRIPTION: +# An eclass for installing a README.gentoo doc file with important +# information for the user. The content of README.gentoo will shown be +# via elog messages either on fresh installations or if the contents of +# the file have changed. Furthermore, the README.gentoo file will be +# installed under /usr/share/doc/${PF} for later consultation. +# +# This eclass was inspired by readme.gentoo-r1.eclass. The main +# differences are as follows. Firstly, it only displays the doc file +# contents if they have changed (unless GREADME_SHOW is set). +# Secondly, it provides a convenient API to install the doc file via +# stdin. +# +# @CODE +# inherit greadme +# +# src_install() { +# ... +# greadme_stdin <<-EOF +# This is the content of the created readme doc file. +# EOF +# ... +# if use foo; then +# greadme_stdin --append <<-EOF +# This is conditional readme content, based on USE=foo. +# EOF +# fi +# } +# @CODE +# +# If the ebuild overrides the default pkg_preinst or respectively +# pkg_postinst, then it must call greadme_pkg_preinst and +# greadme_pkg_postinst explicitly. + +if [[ -z ${_GREADME_ECLASS} ]]; then +_GREADME_ECLASS=1 + +case ${EAPI} in + 8) ;; + *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; +esac + +_GREADME_TMP_FILE="${T}/README.gentoo" +_GREADME_REL_PATH="/usr/share/doc/${PF}/README.gentoo" + +# @ECLASS_VARIABLE: GREADME_SHOW +# @DEFAULT_UNSET +# @DESCRIPTION: +# If set to "yes" then unconditionally show the contents of the readme +# file in pkg_postinst via elog. If set to "no", then do not show the +# contents of the readme file, even if they have changed. + +# @ECLASS_VARIABLE: GREADME_DISABLE_AUTOFORMAT +# @DEFAULT_UNSET +# @DESCRIPTION: +# If non-empty, the readme file will not be automatically formatted. + +# @FUNCTION: greadme_stdin +# @USAGE: [--append] +# @DESCRIPTION: +# Create the readme doc via stdin. You can use --append to append to an +# existing readme doc. +greadme_stdin() { + debug-print-function ${FUNCNAME} "${@}" + + local append + if [[ ${1} = --append ]]; then + append=1 + shift + fi + + [[ $# -eq 0 ]] || die "${FUNCNAME[0]}: Bad parameters: $*" + + if [[ -n ${append} ]]; then + if [[ ! -f ${_GREADME_TMP_FILE} ]]; then + die "Gentoo README does not exist when trying to append to it" + fi + + cat >> "${_GREADME_TMP_FILE}" || die + else + cat > "${_GREADME_TMP_FILE}" || die + fi + + _greadme_install_doc +} + +# @FUNCTION: greadme_file +# @USAGE: <file> +# @DESCRIPTION: +# Installs the provided file as readme doc. +greadme_file() { + debug-print-function ${FUNCNAME} "${@}" + + local input_doc_file="${1}" + if [[ -z ${input_doc_file} ]]; then + die "No file specified" + fi + + cp "${input_doc_file}" "${_GREADME_TMP_FILE}" || die + + _greadme_install_doc +} + +# @FUNCTION: _greadme_install_doc +# @INTERNAL +# @DESCRIPTION: +# Installs the readme file from the temp directory into the image. +_greadme_install_doc() { + debug-print-function ${FUNCNAME} "${@}" + + local greadme="${_GREADME_TMP_FILE}" + if [[ ! ${GREADME_DISABLE_AUTOFORMAT} ]]; then + greadme="${_GREADME_TMP_FILE}".formatted + + # Use fold, followed by a sed to strip trailing whitespace. + # https://bugs.gentoo.org/460050#c7 + fold -s -w 70 "${_GREADME_TMP_FILE}" | + sed 's/[[:space:]]*$//' > "${greadme}" + assert "failed to autoformat README.gentoo" + fi + + # Subshell to avoid pollution of calling environment. + ( + docinto . + newdoc "${greadme}" "README.gentoo" + ) + + # Exclude the readme file from compression, so that its contents can + # be easily compared. + docompress -x "${_GREADME_REL_PATH}" + + # Save the contents of the of the readme. Unfortunately we have to + # do this in src_* phase, because FEATURES=nodoc is applied right + # after src_install and not after pkg_preinst. + _GREADME_CONTENT=$(< "${greadme}") +} + +# @FUNCTION: greadme_pkg_preinst +# @DESCRIPTION: +# Performs checks like comparing the readme doc from the image with a +# potentially existing one in the live system. +greadme_pkg_preinst() { + debug-print-function ${FUNCNAME} "${@}" + + if [[ -z ${REPLACING_VERSIONS} ]]; then + _GREADME_SHOW="fresh-install" + return + fi + + if [[ -v GREADME_SHOW ]]; then + case ${GREADME_SHOW} in + yes) + _GREADME_SHOW="forced" + ;; + no) + _GREADME_SHOW="" + ;; + *) + die "Invalid argument of GREADME_SHOW: ${GREADME_SHOW}" + ;; + esac + return + fi + + local image_greadme_file="${ED}${_GREADME_REL_PATH}" + if [[ ! -f ${image_greadme_file} ]]; then + if [[ -v _GREADME_CONTENT ]]; then + # There is no greadme in the image but the ebuild created + # one. This is likely because FEATURES=nodoc is active. + # Unconditionally show greadme's contents. + _GREADME_SHOW="nodoc-active" + else + # No README file was created by the ebuild. + _GREADME_SHOW="" + fi + + return + fi + + check_live_doc_file() { + local cur_pvr=$1 + local live_greadme_file="${EROOT}/usr/share/doc/${PN}-${cur_pvr}/README.gentoo" + + if [[ ! -f ${live_greadme_file} ]]; then + _GREADME_SHOW="no-current-greadme" + return + fi + + cmp -s "${live_greadme_file}" "${image_greadme_file}" + case $? in + 0) + _GREADME_SHOW="" + ;; + 1) + _GREADME_SHOW="content-differs" + ;; + *) + die "cmp failed with $?" + ;; + esac + } + + local replaced_version + for replaced_version in ${REPLACING_VERSIONS}; do + check_live_doc_file ${replaced_version} + + # Once _GREADME_SHOW is non empty, we found a reason to show the + # readme and we can abort the loop. + if [[ -n ${_GREADME_SHOW} ]]; then + break + fi + done +} + +# @FUNCTION: greadme_pkg_postinst +# @DESCRIPTION: +# Conditionally shows the contents of the readme doc via elog. +greadme_pkg_postinst() { + debug-print-function ${FUNCNAME} "${@}" + + if [[ ! -v _GREADME_SHOW ]]; then + die "_GREADME_SHOW not set. Did you call greadme_pkg_preinst?" + fi + + if [[ -z ${_GREADME_SHOW} ]]; then + # If _GREADME_SHOW is empty, then there is no reason to show the contents. + return + fi + + local line + printf '%s\n' "${_GREADME_CONTENT}" | while read -r line; do + elog "${line}" + done + elog "" + elog "NOTE: Above message is only printed the first time package is" + elog "installed or if the message changed. Please look at" + elog "${EPREFIX}${_GREADME_REL_PATH}" + elog "for future reference." +} + +fi + +EXPORT_FUNCTIONS pkg_preinst pkg_postinst diff --git a/eclass/gstreamer-meson.eclass b/eclass/gstreamer-meson.eclass index a26b06ba4595..937c86a0f15b 100644 --- a/eclass/gstreamer-meson.eclass +++ b/eclass/gstreamer-meson.eclass @@ -393,7 +393,7 @@ use utf8; use JSON::PP; open(my $targets_file, '<:encoding(UTF-8)', 'meson-info/intro-targets.json') || die $!; -my $data = decode_json <$targets_file>; +my $data = decode_json (join '', <$targets_file>); close($targets_file) || die $!; if(!$ARGV[0]) { diff --git a/eclass/guile-single.eclass b/eclass/guile-single.eclass new file mode 100644 index 000000000000..91f6036139da --- /dev/null +++ b/eclass/guile-single.eclass @@ -0,0 +1,245 @@ +# Copyright 2024 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +# @ECLASS: guile-single.eclass +# @MAINTAINER: +# Gentoo Scheme project <scheme@gentoo.org> +# @AUTHOR: +# Author: Arsen Arsenović <arsen@gentoo.org> +# @SUPPORTED_EAPIS: 8 +# @PROVIDES: guile-utils +# @BLURB: Utilities for packages that build against a single Guile. +# @DESCRIPTION: +# This eclass facilitates packages building against a single slot of +# Guile, which is normally something that uses Guile for extending, like +# GNU Make, or for programs built in Guile, like Haunt. +# +# Inspired by prior work in the Gentoo Python ecosystem. +# +# These packages should use guile_gen_cond_dep to generate a dependency +# string for their Guile package dependencies (i.e. other Guile single- +# and multi-implementation packages). They should also utilize +# GUILE_DEPS and GUILE_REQUIRED_USE to specify a dependency on their +# Guile versions. +# +# They should also bump sources via guile_bump_sources during +# src_prepare, and unstrip ccache via guile_unstrip_ccache during +# src_install. +# +# If the user of the eclass needs some USE flag on Guile itself, they +# should provide it via GUILE_REQ_USE. +# +# This eclass provides a guile-single_pkg_setup that sets up environment +# variables needed for Guile and build systems using it. See the +# documentation for that function for more details. +# +# @EXAMPLE: +# A Guile program: +# +# @CODE +# # Copyright 2024 Gentoo Authors +# # Distributed under the terms of the GNU General Public License v2 +# +# EAPI=8 +# +# GUILE_COMPAT=( 2-2 3-0 ) +# inherit guile-single +# +# DESCRIPTION="Haunt is a simple, functional, hackable static site generator" +# HOMEPAGE="https://dthompson.us/projects/haunt.html" +# SRC_URI="https://files.dthompson.us/releases/${PN}/${P}.tar.gz" +# +# LICENSE="GPL-3+" +# SLOT="0" +# KEYWORDS="~amd64" +# REQUIRED_USE="${GUILE_REQUIRED_USE}" +# +# RDEPEND=" +# ${GUILE_DEPS} +# $(guile_gen_cond_dep ' +# dev-scheme/guile-reader[${GUILE_MULTI_USEDEP}] +# dev-scheme/guile-commonmark[${GUILE_MULTI_USEDEP}] +# ') +# " +# DEPEND="${RDEPEND}" +# @CODE +# +# A program utilizing Guile for extension (GNU make, irrelevant pieces +# elided): +# @CODE +# GUILE_COMPAT=( 1-8 2-0 2-2 3-0 ) +# inherit flag-o-matic unpacker verify-sig guile-single +# # ... +# REQUIRED_USE="guile? ( ${GUILE_REQUIRED_USE} )" +# DEPEND=" +# guile? ( ${GUILE_DEPS} ) +# " +# +# src_prepare() { +# # ... +# if use guile; then +# guile-single_src_prepare +# fi +# } +# +# pkg_setup() { +# if use guile; then +# guile-single_pkg_setup +# fi +# } +# +# src_configure() { +# # ... +# local myeconfargs=( +# $(use_with guile) +# ) +# econf "${myeconfargs[@]}" +# } +# +# src_install() { +# # ... +# if use guile; then +# guile_unstrip_ccache +# fi +# } +# @CODE + +case "${EAPI}" in + 8) ;; + *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; +esac + +if [[ ! "${_GUILE_SINGLE_ECLASS}" ]]; then +_GUILE_SINGLE_ECLASS=1 + +inherit guile-utils + +# @ECLASS_VARIABLE: GUILE_COMPAT +# @REQUIRED +# @PRE_INHERIT +# @DESCRIPTION: +# List of acceptable versions of Guile. For instance, setting this +# variable like below will allow the package to be built against either +# Guile 2.2 or 3.0: +# +# @CODE +# GUILE_COMPAT=( 2-2 3-0 ) +# @CODE +# +# Please keep in ascending order. + +_guile_setup() { + debug-print-function ${FUNCNAME} "${@}" + + # Inhibit generating the GUILE_USEDEP. This variable is not usable + # for single packages. + local GUILE_USEDEP + guile_generate_depstrings guile_single_target ^^ +} + +_guile_setup +unset -f _guile_setup + +# @FUNCTION: guile_gen_cond_dep +# @USAGE: <dependency> [<pattern>...] +# @DESCRIPTION: +# Takes a string that uses (quoted) ${GUILE_SINGLE_USEDEP} and +# ${GUILE_MULTI_USEDEP} markers as placeholders for the correct USE +# dependency strings for each compatible slot. +# +# If the pattern is provided, it is taken to be list of slots to +# generate the dependency string for, otherwise, ${GUILE_COMPAT[@]} is +# taken. +# +# @EXAMPLE: +# Note that the "inner" dependency string is in single quotes! +# @CODE +# RDEPEND=" +# $(guile_gen_cond_dep ' +# dev-scheme/guile-zstd[${GUILE_MULTI_USEDEP}] +# dev-scheme/guile-config[${GUILE_SINGLE_USEDEP}] +# ') +# " +# @CODE +guile_gen_cond_dep() { + debug-print-function ${FUNCNAME} "${@}" + + local deps="$1" + shift + + local candidates=( "$@" ) + if [[ ${#candidates[@]} -eq 0 ]]; then + candidates=( "${GUILE_COMPAT[@]}" ) + fi + + local candidate + for candidate in "${candidates[@]}"; do + local s="guile_single_target_${candidate}(-)" \ + m="guile_targets_${candidate}(-)" \ + subdeps=${deps//\$\{GUILE_SINGLE_USEDEP\}/${s}} + subdeps=${subdeps//\$\{GUILE_MULTI_USEDEP\}/${m}} + echo " + guile_single_target_${candidate}? ( + ${subdeps} + ) + " + done +} + +# @FUNCTION: guile-single_pkg_setup +# @DESCRIPTION: +# Sets up the PKG_CONFIG_PATH with the appropriate GUILE_SINGLE_TARGET, +# as well as setting up a guile-config and the GUILE, GUILD and +# GUILESNARF environment variables. Also sets GUILE_EFFECTIVE_VERSION +# to the same value as GUILE_SELECTED_TARGET, as build systems sometimes +# check that variable. +# +# For details on the latter three, see guile_export. +guile-single_pkg_setup() { + debug-print-function ${FUNCNAME} "${@}" + + guile_set_common_vars + + GUILE_SELECTED_TARGET= + for ver in "${GUILE_COMPAT[@]}"; do + debug-print "${FUNCNAME}: checking for ${ver}" + use "guile_single_target_${ver}" || continue + GUILE_SELECTED_TARGET="${ver/-/.}" + break + done + + [[ ${GUILE_SELECTED_TARGET} ]] \ + || die "No GUILE_SINGLE_TARGET specified." + + export PKG_CONFIG_PATH + guile_filter_pkgconfig_path "${GUILE_SELECTED_TARGET}" + guile_create_temporary_config "${GUILE_SELECTED_TARGET}" + local -x GUILE_EFFECTIVE_VERSION="${GUILE_SELECTED_TARGET}" + guile_export GUILE GUILD GUILESNARF +} + +# @FUNCTION: guile-single_src_prepare +# @DESCRIPTION: +# Runs the default prepare stage, and then bumps Guile sources via +# guile_bump_sources. +guile-single_src_prepare() { + debug-print-function ${FUNCNAME} "${@}" + + default + guile_bump_sources +} + +# @FUNCTION: guile-single_src_install +# @DESCRIPTION: +# Runs the default install stage, and then marks ccache files not to be +# stripped using guile_unstrip_ccache. +guile-single_src_install() { + debug-print-function ${FUNCNAME} "${@}" + + default + guile_unstrip_ccache +} + +EXPORT_FUNCTIONS pkg_setup src_prepare src_install + +fi # _GUILE_SINGLE_ECLASS diff --git a/eclass/guile-utils.eclass b/eclass/guile-utils.eclass new file mode 100644 index 000000000000..09ca5aabe502 --- /dev/null +++ b/eclass/guile-utils.eclass @@ -0,0 +1,276 @@ +# Copyright 2023-2024 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +# @ECLASS: guile-utils.eclass +# @MAINTAINER: +# Gentoo Scheme project <scheme@gentoo.org> +# @AUTHOR: +# Author: Arsen Arsenović <arsen@gentoo.org> +# @SUPPORTED_EAPIS: 8 +# @BLURB: Common code between GNU Guile-related eclasses and ebuilds. +# @DESCRIPTION: +# This eclass contains various bits of common code between +# dev-scheme/guile, Guile multi-implementation ebuilds and Guile +# single-implementation ebuilds. +# +# Inspired by prior work in the Gentoo Python ecosystem. + +case "${EAPI}" in + 8) ;; + *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; +esac + +if [[ ! "${_GUILE_UTILS_ECLASS}" ]]; then +_GUILE_UTILS_ECLASS=1 + +inherit toolchain-funcs + +BDEPEND="virtual/pkgconfig" + +# @ECLASS_VARIABLE: GUILE_COMPAT +# @REQUIRED +# @PRE_INHERIT +# @DESCRIPTION: +# List of acceptable versions of Guile. For instance, setting this +# variable like below will allow the package to be built against either +# Guile 2.2 or 3.0: +# +# @CODE +# GUILE_COMPAT=( 2-2 3-0 ) +# @CODE +# +# Please keep in ascending order. + +# @FUNCTION: guile_check_compat +# @DESCRIPTION: +# Checks that GUILE_COMPAT is set to an array, and has no invalid +# values. +guile_check_compat() { + debug-print-function ${FUNCNAME} "${@}" + + if ! [[ ${GUILE_COMPAT@a} == *a* ]]; then + die "GUILE_COMPAT not set to an array" + fi + + if [[ ${#GUILE_COMPAT[@]} -eq 0 ]]; then + die "GUILE_COMPAT is empty" + fi +} + +guile_check_compat + +# @ECLASS_VARIABLE: GUILE_REQ_USE +# @PRE_INHERIT +# @DEFAULT_UNSET +# @DESCRIPTION: +# Specifies a USE dependency string for all versions of Guile in +# GUILE_COMPAT. +# +# @EXAMPLE: +# GUILE_REQ_USE="deprecated" + +# @ECLASS_VARIABLE: GUILE_USEDEP +# @OUTPUT_VARIABLE +# @DESCRIPTION: +# This variable is populated with a USE-dependency string which can be +# used to depend on other Guile multi-implementation packages. +# This variable is not usable from guile-single packages. + +# @ECLASS_VARIABLE: GUILE_DEPS +# @OUTPUT_VARIABLE +# @DESCRIPTION: +# Contains the dependency string for the compatible Guile runtimes. + +# @FUNCTION: guile_set_common_vars +# @DESCRIPTION: +# Sets common variables that apply to all Guile packages, namely, +# QA_PREBUILT. +guile_set_common_vars() { + debug-print-function ${FUNCNAME} "${@}" + + # These aren't strictly speaking prebuilt. but they do generated a + # nonstandard ELF object. + if [[ -z ${QA_PREBUILT} ]]; then + QA_PREBUILT="usr/$(get_libdir)/guile/*/site-ccache/*" + fi +} + +# @FUNCTION: guile_filter_pkgconfig_path +# @USAGE: <acceptable slots>... +# @DESCRIPTION: +# Alters ${PKG_CONFIG_PATH} such that it does not contain any Guile +# slots besides the ones required by the caller. +guile_filter_pkgconfig_path() { + debug-print-function ${FUNCNAME} "${@}" + + local filtered_path= unfiltered_path path + IFS=: read -ra unfiltered_path <<<"${PKG_CONFIG_PATH}" + debug-print "Unfiltered PKG_CONFIG_PATH:" "${unfiltered_path[@]}" + for p in "${unfiltered_path[@]}"; do + for v in "$@"; do + debug-print "... considering '${p}' for ${v}" + # Exclude non-selected versions. + [[ ${p} == */usr/share/guile-data/${v}/pkgconfig* ]] \ + || continue + debug-print "... OK" + + # Add separator, if some data already exists. + [[ "${filtered_path}" ]] && filtered_path+=: + + filtered_path+="${p}" + break + done + done + + debug-print "${FUNCNAME}: Constructed PKG_CONFIG_PATH: ${filtered_path}" + PKG_CONFIG_PATH="$filtered_path" +} + +# @FUNCTION: guile_generate_depstrings +# @USAGE: <prefix> <depop> +# @DESCRIPTION: +# Generates GUILE_REQUIRED_USE/GUILE_DEPS/GUILE_USEDEP based on +# GUILE_COMPAT, and populates IUSE. +guile_generate_depstrings() { + debug-print-function ${FUNCNAME} "${@}" + + # Generate IUSE, REQUIRED_USE, GUILE_USEDEP + local prefix="$1" depop="$2" + GUILE_USEDEP="" + local ver uses=() + # TODO(arsen): enforce GUILE_COMPAT is in ascending order. + for ver in "${GUILE_COMPAT[@]}"; do + [[ -n ${GUILE_USEDEP} ]] && GUILE_USEDEP+="," + uses+=("${prefix}_${ver}") + GUILE_USEDEP+="${prefix}_${ver}" + done + GUILE_REQUIRED_USE="${depop} ( ${uses[@]} )" + IUSE="${uses[@]}" + debug-print "${FUNCNAME}: requse ${GUILE_REQUIRED_USE}" + debug-print "${FUNCNAME}: generated ${uses[*]}" + debug-print "${FUNCNAME}: iuse ${IUSE}" + + # Generate GUILE_DEPS + local base_deps=() + local requse="${GUILE_REQ_USE+[}${GUILE_REQ_USE:-}${GUILE_REQ_USE+]}" + for ver in "${GUILE_COMPAT[@]}"; do + base_deps+=" + ${prefix}_${ver}? ( + dev-scheme/guile:${ver/-/.}${requse} + ) + " + done + GUILE_DEPS="${base_deps[*]}" + debug-print "${FUNCNAME}: GUILE_DEPS=${GUILE_DEPS}" + debug-print "${FUNCNAME}: GUILE_USEDEP=${GUILE_USEDEP}" +} + +# @FUNCTION: guile_unstrip_ccache +# @DESCRIPTION: +# Marks site-ccache files not to be stripped. Operates on ${D}. +guile_unstrip_ccache() { + debug-print-function ${FUNCNAME} "${@}" + + local ccache + while read -r -d $'\0' ccache; do + debug-print "${FUNCNAME}: ccache found: ${ccache#.}" + dostrip -x "${ccache#.}" + done < <(cd "${ED}" || die; \ + find . \ + -name '*.go' \ + -path "*/usr/$(get_libdir)/guile/*/site-ccache/*" \ + -print0 || die) || die +} + +# @FUNCTION: guile_export +# @USAGE: [GUILE|GUILD|GUILE_SITECCACHEDIR|GUILE_SITEDIR]... +# @DESCRIPTION: +# Exports a given variable for the selected Guile variant. +# +# Supported variables are: +# +# - GUILE - Path to the guile executable, +# - GUILD - Path to the guild executable, +# - GUILESNARF - Path to the guile-snarf executable +# - GUILECONFIG - Path to the guile-config executable +# - GUILE_SITECCACHEDIR - Path to the site-ccache directory, +# - GUILE_SITEDIR - Path to the site Scheme directory +guile_export() { + debug-print-function ${FUNCNAME} "${@}" + + local gver + if [[ "${GUILE_CURRENT_VERSION}" ]]; then + gver="${GUILE_CURRENT_VERSION}" + elif [[ "${GUILE_SELECTED_TARGET}" ]]; then + gver="${GUILE_SELECTED_TARGET}" + else + die "Calling guile_export outside of a Guile build context?" + fi + + _guile_pcvar() { + local tip="Did you source /etc/profile after an update?" + $(tc-getPKG_CONFIG) --variable="$1" guile-"${gver}" \ + || die "Could not get $1 out of guile-${gver}. ${tip}" + } + + for var; do + case "${var}" in + GUILE) export GUILE="$(_guile_pcvar guile)" ;; + GUILD) export GUILD="$(_guile_pcvar guild)" ;; + GUILESNARF) + GUILESNARF="${EPREFIX}/usr/bin/guile-snarf-${gver}" + export GUILESNARF + ;; + GUILECONFIG) + GUILECONFIG="${EPREFIX}/usr/bin/guile-config-${gver}" + export GUILECONFIG + ;; + GUILE_SITECCACHEDIR) + GUILE_SITECCACHEDIR="$(_guile_pcvar siteccachedir)" + export GUILE_SITECCACHEDIR + ;; + GUILE_SITEDIR) + export GUILE_SITEDIR="$(_guile_pcvar sitedir)" + ;; + *) die "Unknown variable '${var}'" ;; + esac + done +} + +# @FUNCTION: guile_create_temporary_config +# @USAGE: <version> +# @DESCRIPTION: +# Creates a guile-config executable for a given Guile version, and +# inserts it into path. +guile_create_temporary_config() { + debug-print-function ${FUNCNAME} "${@}" + + [[ ${1} ]] || die "Must specify a Guile version" + + local cdir="${T}/guiles/${1}/" + mkdir -p "${cdir}" || die + + pushd "${cdir}" >/dev/null 2>&1 || die + cat >guile-config <<-EOF + #!/bin/sh + exec guile-config-${1} "\${@}" + EOF + chmod +x guile-config + popd >/dev/null 2>&1 || die + PATH="${cdir}:${PATH}" +} + +# @FUNCTION: guile_bump_sources +# @DESCRIPTION: +# Searches over ${S} for .scm files and bumps them to avoid Guile using +# the system ccache while trying to build packages. +# +# http://debbugs.gnu.org/cgi/bugreport.cgi?bug=38112 +guile_bump_sources() { + debug-print-function ${FUNCNAME} "${@}" + + einfo "bumping *.scm source files..." + find "${S}" -name "*.scm" -exec touch {} + || die +} + +fi # _GUILE_UTILS_ECLASS diff --git a/eclass/guile.eclass b/eclass/guile.eclass new file mode 100644 index 000000000000..9310cd060da9 --- /dev/null +++ b/eclass/guile.eclass @@ -0,0 +1,358 @@ +# Copyright 2023-2024 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +# @ECLASS: guile.eclass +# @MAINTAINER: +# Gentoo Scheme project <scheme@gentoo.org> +# @AUTHOR: +# Author: Arsen Arsenović <arsen@gentoo.org> +# Inspired by prior work in the Gentoo Python ecosystem. +# @SUPPORTED_EAPIS: 8 +# @PROVIDES: guile-utils +# @BLURB: Utilities for packages multi-implementation Guile packages. +# @DESCRIPTION: +# This eclass facilitates building against many Guile implementations, +# useful for Guile libraries. Each ebuild must set GUILE_COMPAT to a +# list of versions they support, which will be intersected with +# GUILE_TARGETS to pick which versions to install. The eclass will +# generate a GUILE_DEPS based on the configured GUILE_COMPAT, as well as +# a GUILE_REQUIRED_USE, that the user must use. +# +# If the user of the eclass needs some USE flag on Guile itself, they +# should provide it via GUILE_REQ_USE. +# +# This ebuild provides multibuild functionality. Use guile_foreach_impl +# to run a given command for each enabled Guile version. The command +# provided will be ran in a modified environment, see the description of +# that function for more details. +# +# This package provides some stage functions written assuming a +# conventional GNU Build System-based Guile library and may or may not +# work. +# +# For each Guile target, a Guile library should have at least compiled +# .go files in the ccache or %site-ccache-dir. It must also have +# corresponding sources installed in %site-dir. +# +# If your package has some steps that should only happen for one +# implementation (e.g. installing a program), you can utilize +# guile_for_best_impl. +# +# Due to http://debbugs.gnu.org/cgi/bugreport.cgi?bug=38112, Guile +# packages ought to bump their sources before building. To this end, +# the src_prepare this eclass provides will call guile_bump_sources of +# the guile-utils eclass. +# +# When installing, the packages using this eclass ought to use +# guile_foreach_impl and its SLOTTED_{,E}D, followed by merging roots +# via guile_merge_roots and unstripping ccache objects via +# guile_unstrip_ccache. See descriptions of those functions for +# details. +# +# Ebuild authors, please pay attention for potential conflicts between +# slots. As an example, dev-scheme/guile-lib installs a pkg-config file +# that depends on the Guile version it is installed for. This is not +# acceptable, as it means revdeps will only ever see the version of the +# file for the best Guile implementation in GUILE_TARGETS. +# +# @EXAMPLE: +# The following example demonstrates a simple package relying entirely +# on the setup of this eclass. For each enabled, compatible target, the +# ebuild will bump sources (see description), and run the default +# configure, compile and test stages (per PMS, meaning GNU Build +# System), and an install stage modified such that it installs each +# variant into SLOTTED_D followed by merging roots and unstripping. +# +# @CODE +# EAPI=8 +# +# GUILE_COMPAT=( 2-2 3-0 ) +# inherit guile +# +# DESCRIPTION="iCalendar/vCard parser for GNU Guile" +# HOMEPAGE="https://github.com/artyom-poptsov/guile-ics" +# SRC_URI="https://github.com/artyom-poptsov/${PN}/releases/download/v${PV}/${P}.tar.gz" +# +# LICENSE="GPL-3+" +# SLOT="0" +# KEYWORDS="~amd64" +# REQUIRED_USE="${GUILE_REQUIRED_USE}" +# +# RDEPEND=" +# ${GUILE_DEPS} +# dev-scheme/guile-smc[${GUILE_USEDEP}] +# " +# DEPEND="${RDEPEND}" +# @CODE + +case "${EAPI}" in + 8) ;; + *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; +esac + +if [[ ! "${_GUILE_ECLASS}" ]]; then +_GUILE_ECLASS=1 + +inherit guile-utils multibuild + +# @ECLASS_VARIABLE: GUILE_USEDEP +# @OUTPUT_VARIABLE +# @DESCRIPTION: +# USE dependency string that can be applied to Guile +# multi-implementation dependencies. +# +# @EXAMPLE: +# RDEPEND=" +# ${GUILE_DEPS} +# dev-scheme/bytestructures[${GUILE_USEDEP}] +# >=dev-libs/libgit2-1:= +# " +# DEPEND="${RDEPEND}" + +# @ECLASS_VARIABLE: GUILE_COMPAT +# @REQUIRED +# @PRE_INHERIT +# @DESCRIPTION: +# List of acceptable versions of Guile. For instance, setting this +# variable like below will allow the package to be built against both +# Guile 2.2 or 3.0: +# +# @CODE +# GUILE_COMPAT=( 2-2 3-0 ) +# @CODE +# +# Please keep in ascending order. + +_guile_setup() { + debug-print-function ${FUNCNAME} "${@}" + + guile_generate_depstrings guile_targets '||' +} + +_guile_setup +unset -f _guile_setup + +# @ECLASS_VARIABLE: GUILE_SELECTED_TARGETS +# @INTERNAL +# @DESCRIPTION: +# Contains the intersection of GUILE_TARGETS and GUILE_COMPAT. +# Generated in guile_pkg_setup. + +# @FUNCTION: guile_pkg_setup +# @DESCRIPTION: +# Sets up eclass-internal variables for this build. +guile_pkg_setup() { + debug-print-function ${FUNCNAME} "${@}" + + guile_set_common_vars + GUILE_SELECTED_TARGETS=() + for ver in "${GUILE_COMPAT[@]}"; do + debug-print "${FUNCNAME}: checking for ${ver}" + use "guile_targets_${ver}" || continue + GUILE_SELECTED_TARGETS+=("${ver/-/.}") + done + if [[ "${#GUILE_SELECTED_TARGETS[@]}" -eq 0 ]]; then + die "No GUILE_TARGETS specified." + fi +} + +# @FUNCTION: guile_copy_sources +# @DESCRIPTION: +# Create a single copy of the package sources for each selected Guile +# implementation. +guile_copy_sources() { + debug-print-function ${FUNCNAME} "${@}" + + local MULTIBUILD_VARIANTS + MULTIBUILD_VARIANTS=("${GUILE_SELECTED_TARGETS[@]}") + + multibuild_copy_sources +} + +# @FUNCTION: _guile_multibuild_wrapper +# @USAGE: <command> [<argv>...] +# @INTERNAL +# @DESCRIPTION: +# Initialize the environment for a single build variant. See +# guile_foreach_impl. +_guile_multibuild_wrapper() { + local GUILE_CURRENT_VERSION="${MULTIBUILD_VARIANT}" + debug-print-function ${FUNCNAME} "${@}" "on ${MULTIBUILD_VARIANT}" + + local -x PATH="${PATH}" + guile_create_temporary_config "${GUILE_CURRENT_VERSION}" + guile_export GUILE GUILD GUILESNARF + + local -x PKG_CONFIG_PATH="${PKG_CONFIG_PATH}" + guile_filter_pkgconfig_path "${MULTIBUILD_VARIANT}" + local ECONF_SOURCE="${S}" + local -x SLOTTED_D="${T}/dests/image${MULTIBUILD_ID}" + local -x SLOTTED_ED="${SLOTTED_D}${EPREFIX}/" + local -x GUILE_EFFECTIVE_VERSION="${GUILE_CURRENT_VERSION}" + mkdir -p "${BUILD_DIR}" || die + cd "${BUILD_DIR}" || die + "$@" +} + +# @VARIABLE: SLOTTED_D +# @DESCRIPTION: +# In functions ran by guile_foreach_impl, this variable is set to a new +# ${D} value that the variant being installed should use. + +# @VARIABLE: SLOTTED_ED +# @DESCRIPTION: +# In functions ran by guile_foreach_impl, this variable is set to a new +# ${ED} value that the variant being installed should use. It is +# equivalent to "${SLOTTED_D%/}${EPREFIX}/". + +# @VARIABLE: ECONF_SOURCE +# @DESCRIPTION: +# In functions ran by guile_foreach_impl, this variable is set to ${S}, +# for convenience. + +# @VARIABLE: PKG_CONFIG_PATH +# @DESCRIPTION: +# In functions ran by guile_foreach_impl, PKG_CONFIG_PATH is filtered to +# contain only the current ${MULTIBUILD_VARIANT}. + +# @VARIABLE: BUILD_DIR +# @DESCRIPTION: +# In functions ran by guile_foreach_impl, this variable is set to a +# newly-generated build directory for this variant. + +# @FUNCTION: guile_foreach_impl +# @USAGE: <command> [<argv>...] +# @DESCRIPTION: +# Runs the given command for each of the selected Guile implementations. +# +# The function will return 0 status if all invocations succeed. +# Otherwise, the return code from first failing invocation will +# be returned. +# +# Each invocation will have PKG_CONFIG_DIR altered to contain only one +# Guile implementation, as well as a SLOTTED_D, SLOTTED_ED for +# installation purposes, and a new BUILD_DIR, in which the wrapped +# function will be executed, with a pre-configured ECONF_SOURCE. A +# temporary program called 'guile-config' is generated and inserted into +# the PATH. +# +# Also automatically exported are GUILE, GUILD, and GUILESNARF - see +# guile_export for details - as well as GUILE_CURRENT_VERSION and +# GUILE_EFFECTIVE_VERSION, which are set to the same value (the current +# version). +# +# This combination should cover Guile detection of a large amount of +# packages out of the box. +guile_foreach_impl() { + debug-print-function ${FUNCNAME} "${@}" + + local MULTIBUILD_VARIANTS + MULTIBUILD_VARIANTS=("${GUILE_SELECTED_TARGETS[@]}") + + debug-print "${FUNCNAME}: Running for each of:" \ + "${GUILE_SELECTED_TARGETS[@]}" + + multibuild_foreach_variant _guile_multibuild_wrapper "${@}" +} + +# @FUNCTION: _guile_merge_single_root +# @INTERNAL +# @DESCRIPTION: +# Runs a single merge_root step for guile_merge_roots. +_guile_merge_single_root() { + debug-print-function ${FUNCNAME} "${@}" + + multibuild_merge_root "${SLOTTED_D}" "${D}" +} + +# @FUNCTION: guile_merge_roots +# @DESCRIPTION: +# Merges install roots from all slots, diagnosing conflicts. +guile_merge_roots() { + debug-print-function ${FUNCNAME} "${@}" + + guile_foreach_impl _guile_merge_single_root +} + +# @FUNCTION: guile_for_best_impl +# @DESCRIPTION: +# Runs the passed command once, for the best installed Guile +# implementation. +guile_for_best_impl() { + debug-print-function ${FUNCNAME} "${@}" + + multibuild_for_best_variant _guile_multibuild_wrapper "${@}" +} + +# Default implementations for a GNU Build System based Guile package. + +# @FUNCTION: guile_src_prepare +# @DESCRIPTION: +# Bumps SCM sources runs the default src_prepare and bumps all *.scm +# files. See guile_bump_sources of guile-utils.eclass. +guile_src_prepare() { + debug-print-function ${FUNCNAME} "${@}" + + default + guile_bump_sources +} + +# @FUNCTION: guile_src_configure +# @DESCRIPTION: +# Runs the default src_configure for each selected variant target. +guile_src_configure() { + debug-print-function ${FUNCNAME} "${@}" + + guile_foreach_impl default +} + +# @FUNCTION: guile_src_compile +# @DESCRIPTION: +# Runs the default src_compile for each selected variant target. +guile_src_compile() { + debug-print-function ${FUNCNAME} "${@}" + + guile_foreach_impl default +} + +# @FUNCTION: guile_src_test +# @DESCRIPTION: +# Runs the default src_test phase for each implementation. +guile_src_test() { + debug-print-function ${FUNCNAME} "${@}" + + guile_foreach_impl default +} + +# @FUNCTION: _guile_default_install_slot +# @INTERNAL +# @DESCRIPTION: +# Imitates the default build system install "substep", but for a given +# ${SLOTTED_D} rather than the usual ${D}. See guile_src_install. +_guile_default_install_slot() { + debug-print-function ${FUNCNAME} "${@}" + + if [[ -f Makefile ]] || [[ -f GNUmakefile ]] || [[ -f makefile ]]; then + emake DESTDIR="${SLOTTED_D}" install + fi +} + +# @FUNCTION: guile_src_install +# @DESCRIPTION: +# Runs the an imitation of the default src_install that does the right +# thing for a GNU Build System based Guile package, for each selected +# variant target. Merges roots after completing the installs. +guile_src_install() { + debug-print-function ${FUNCNAME} "${@}" + + guile_foreach_impl _guile_default_install_slot + guile_merge_roots + guile_unstrip_ccache + + einstalldocs +} + +EXPORT_FUNCTIONS pkg_setup src_prepare src_configure src_compile \ + src_install src_test + +fi # _GUILE_ECLASS diff --git a/eclass/java-ant-2.eclass b/eclass/java-ant-2.eclass index b0d2fb216b10..ef7d306dc9b1 100644 --- a/eclass/java-ant-2.eclass +++ b/eclass/java-ant-2.eclass @@ -10,6 +10,7 @@ # @SUPPORTED_EAPIS: 7 8 # @PROVIDES: java-utils-2 # @BLURB: eclass for ant based Java packages +# @DEPRECATED: none # @DESCRIPTION: # Eclass for Ant-based Java packages. Provides support for both automatic and # manual manipulation of build.xml files. Should be inherited after java-pkg-2 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/java-pkg-2.eclass b/eclass/java-pkg-2.eclass index c17a9db26b3b..6da4efd222c2 100644 --- a/eclass/java-pkg-2.eclass +++ b/eclass/java-pkg-2.eclass @@ -1,4 +1,4 @@ -# Copyright 2004-2023 Gentoo Authors +# Copyright 2004-2024 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 # @ECLASS: java-pkg-2.eclass @@ -13,14 +13,18 @@ # This eclass should be inherited for pure Java packages, or by packages which # need to use Java. +if [[ -z ${_JAVA_PKG_2_ECLASS} ]] ; then +_JAVA_PKG_2_ECLASS=1 + case ${EAPI} in - 6|7|8) ;; + 6) + ewarn "${CATEGORY}/${PF}: ebuild uses ${ECLASS} with deprecated EAPI ${EAPI}!" + ewarn "${CATEGORY}/${PF}: Support will be removed on 2024-10-08. Please port to newer EAPI." + ;; + 7|8) ;; *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; esac -if [[ -z ${_JAVA_PKG_2_ECLASS} ]] ; then -_JAVA_PKG_2_ECLASS=1 - inherit java-utils-2 # @ECLASS_VARIABLE: JAVA_PKG_IUSE @@ -39,12 +43,6 @@ DEPEND="${JAVA_PKG_E_DEPEND}" # Nothing special for RDEPEND... just the same as DEPEND. RDEPEND="${DEPEND}" -# Commons packages follow the same rules so do it here -if [[ ${CATEGORY} = dev-java && ${PN} = commons-* ]]; then - HOMEPAGE="http://commons.apache.org/${PN#commons-}/" - SRC_URI="mirror://apache/${PN/-///}/source/${P}-src.tar.gz" -fi - # @FUNCTION: java-pkg-2_pkg_setup # @DESCRIPTION: @@ -63,6 +61,7 @@ java-pkg-2_src_prepare() { # @FUNCTION: java-pkg-2_src_compile +# @DEPRECATED: none # @DESCRIPTION: # Default src_compile for java packages # @@ -98,6 +97,7 @@ java-pkg-2_src_compile() { } # @FUNCTION: java-pkg-2_src_test +# @DEPRECATED: none # @DESCRIPTION: # src_test, not exported. java-pkg-2_src_test() { diff --git a/eclass/java-pkg-simple.eclass b/eclass/java-pkg-simple.eclass index 6b473ed768ed..5ed7e3e5b78e 100644 --- a/eclass/java-pkg-simple.eclass +++ b/eclass/java-pkg-simple.eclass @@ -26,8 +26,12 @@ _JAVA_PKG_SIMPLE_ECLASS=1 inherit java-utils-2 -if ! has java-pkg-2 ${INHERITED}; then - eerror "java-pkg-simple eclass can only be inherited AFTER java-pkg-2" +if has java-pkg-2 ${INHERITED}; then + JAVA_PKG_OPT=0 +elif has java-pkg-opt-2 ${INHERITED}; then + JAVA_PKG_OPT=1 +else + eerror "java-pkg-simple eclass can only be inherited AFTER java-pkg-2 or java-pkg-opt-2" fi # We are only interested in finding all java source files, wherever they may be. @@ -50,7 +54,12 @@ if has test ${JAVA_PKG_IUSE}; then test_deps+=" dev-java/testng:0";; esac done - [[ ${test_deps} ]] && DEPEND="test? ( ${test_deps} )" + if [[ ${JAVA_PKG_OPT} == 1 ]]; then + [[ ${test_deps} ]] && DEPEND="test? ( ${JAVA_PKG_OPT_USE}? ( ${test_deps} ) )" + else + [[ ${test_deps} ]] && DEPEND="test? ( ${test_deps} )" + fi + unset test_deps fi @@ -347,6 +356,7 @@ java-pkg-simple_prepend_resources() { # If USE FLAG 'binary' exists and is set, it will just copy # ${JAVA_BINJAR_FILENAME} to ${S} and skip the rest of src_compile. java-pkg-simple_src_compile() { + [[ ${JAVA_PKG_OPT} == 1 ]] && ! use ${JAVA_PKG_OPT_USE} && return local sources=sources.lst classes=target/classes apidoc=target/api moduleinfo # do not compile if we decide to install binary jar @@ -461,6 +471,7 @@ java-pkg-simple_src_compile() { # ${JAVA_JAR_FILENAME}. It will also install a launcher if # ${JAVA_MAIN_CLASS} is set. Also invokes einstalldocs. java-pkg-simple_src_install() { + [[ ${JAVA_PKG_OPT} == 1 ]] && ! use ${JAVA_PKG_OPT_USE} && return local sources=sources.lst classes=target/classes apidoc=target/api # install the jar file that we need @@ -503,6 +514,7 @@ java-pkg-simple_src_install() { # in the "generated-test" directory as content of this directory is preserved, # whereas content of target/test-classes is removed. java-pkg-simple_src_test() { + [[ ${JAVA_PKG_OPT} == 1 ]] && ! use ${JAVA_PKG_OPT_USE} && return local test_sources=test_sources.lst classes=target/test-classes moduleinfo local tests_to_run classpath diff --git a/eclass/java-utils-2.eclass b/eclass/java-utils-2.eclass index 47123287ce70..43d9b749ba3d 100644 --- a/eclass/java-utils-2.eclass +++ b/eclass/java-utils-2.eclass @@ -17,14 +17,18 @@ # that have optional Java support. In addition you can inherit java-ant-2 for # Ant-based packages. +if [[ -z ${_JAVA_UTILS_2_ECLASS} ]] ; then +_JAVA_UTILS_2_ECLASS=1 + case ${EAPI} in - 6|7|8) ;; + 6) + ewarn "${CATEGORY}/${PF}: ebuild uses ${ECLASS} with deprecated EAPI ${EAPI}!" + ewarn "${CATEGORY}/${PF}: Support will be removed on 2024-10-08. Please port to newer EAPI." + ;; + 7|8) ;; *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; esac -if [[ -z ${_JAVA_UTILS_2_ECLASS} ]] ; then -_JAVA_UTILS_2_ECLASS=1 - # EAPI 7 has version functions built-in. Use eapi7-ver for all earlier EAPIs. # Keep versionator inheritance in case consumers are using it implicitly. [[ ${EAPI} == 6 ]] && inherit eapi7-ver eqawarn multilib versionator @@ -319,12 +323,15 @@ java-pkg_doexamples() { # arguments are passed through to find. # # @CODE +# Parameters: +# $1 - jar file +# $2 - resource tree directory +# $* - arguments to pass to find +# +# Example: # java-pkg_addres ${PN}.jar resources ! -name "*.html" # @CODE # -# @param $1 - jar file -# @param $2 - resource tree directory -# @param $* - arguments to pass to find java-pkg_addres() { debug-print-function ${FUNCNAME} $* @@ -1134,10 +1141,10 @@ java-pkg_jarfrom() { } # @FUNCTION: java-pkg_getjars -# @USAGE: [--build-only] [--with-dependencies] <package1>[,<package2>...] +# @USAGE: [--build-only] [--runtime-only] [--with-dependencies] <package1>[,<package2>...] # @DESCRIPTION: # Get the classpath provided by any number of packages -# Among other things, this can be passed to 'javac -classpath' or 'ant -lib'. +# Among other things, this can be passed to 'javac -classpath'. # The providing packages are recorded as dependencies into package.env DEPEND # line, unless "--build-only" is passed as the very first argument, for jars # that have to be present only at build time and are not needed on runtime @@ -1154,6 +1161,7 @@ java-pkg_jarfrom() { # Parameters: # --build-only - makes the jar(s) not added into package.env DEPEND line. # (assumed automatically when called inside src_test) +# --runtime-only - marks the jar(s) not added into package.env RDEPEND line. # --with-dependencies - get jars also from requested package's dependencies # transitively. # $1 - list of packages to get jars from @@ -1162,6 +1170,7 @@ java-pkg_jarfrom() { java-pkg_getjars() { debug-print-function ${FUNCNAME} $* + local dep_constraint local build_only="" local deep="" @@ -1170,6 +1179,9 @@ java-pkg_getjars() { while [[ "${1}" == --* ]]; do if [[ "${1}" = "--build-only" ]]; then build_only="build" + dep_constraint="build" + elif [[ "${1}" = "--runtime-only" ]]; then + dep_constraint="runtime" elif [[ "${1}" = "--with-dependencies" ]]; then deep="--with-dependencies" else @@ -1188,7 +1200,7 @@ java-pkg_getjars() { debug-print "${pkgs}:${jars}" for pkg in ${pkgs//,/ }; do - java-pkg_ensure-dep "${build_only}" "${pkg}" + java-pkg_ensure-dep "${dep_constraint}" "${pkg}" done for pkg in ${pkgs//,/ }; do @@ -1637,10 +1649,6 @@ java-pkg_set-current-vm() { export GENTOO_VM=${1} } -java-pkg_get-current-vm() { - echo ${GENTOO_VM} -} - java-pkg_current-vm-matches() { has $(java-pkg_get-current-vm) ${@} return $? @@ -1809,7 +1817,6 @@ java-pkg_ant-tasks-depend() { fi } - # @FUNCTION: ejunit_ # @INTERNAL # @DESCRIPTION: @@ -1835,7 +1842,7 @@ ejunit_() { local junit=${1} shift 1 - local cp=$(java-pkg_getjars --with-dependencies ${junit}${pkgs}) + local cp=$(java-pkg_getjars --build-only --with-dependencies ${junit}${pkgs}) if [[ ${1} = -cp || ${1} = -classpath ]]; then cp="${2}:${cp}" shift 2 @@ -1923,7 +1930,7 @@ etestng() { local runner=org.testng.TestNG if [[ ${PN} != testng ]]; then - local cp=$(java-pkg_getjars --with-dependencies testng) + local cp=$(java-pkg_getjars --build-only --with-dependencies testng) else local cp=testng.jar fi @@ -2030,13 +2037,23 @@ java-utils-2_pkg_preinst() { eant() { debug-print-function ${FUNCNAME} $* - if [[ ${EBUILD_PHASE} = compile ]]; then - java-ant-2_src_configure - fi + if [[ ${!JAVA_PKG_BSFIX*} ]] \ + || [[ ${JAVA_ANT_BSFIX_EXTRA_ARGS} ]] \ + || [[ ${JAVA_ANT_CLASSPATH_TAGS} ]] \ + || [[ ${JAVA_ANT_JAVADOC_INPUT_DIRS} ]] \ + || [[ ${JAVA_ANT_REWRITE_CLASSPATH} ]] \ + || [[ ${EANT_BUILD_XML} ]] \ + || [[ ${!EANT_GENTOO_CLASSPATH*} ]] \ + || [[ ${EANT_TEST_GENTOO_CLASSPATH} ]] + then + if [[ ${EBUILD_PHASE} = compile ]]; then + java-ant-2_src_configure + fi - if ! has java-ant-2 ${INHERITED}; then - local msg="You should inherit java-ant-2 when using eant" - java-pkg_announce-qa-violation "${msg}" + if ! has java-ant-2 ${INHERITED}; then + local msg="You should inherit java-ant-2 when using eant" + java-pkg_announce-qa-violation "${msg}" + fi fi local antflags="-Dnoget=true -Dmaven.mode.offline=true -Dbuild.sysclasspath=ignore" @@ -2237,29 +2254,6 @@ java-pkg_force-compiler() { JAVA_PKG_FORCE_COMPILER="$@" } -# @FUNCTION: use_doc -# @DESCRIPTION: -# -# Helper function for getting ant to build javadocs. If the user has USE=doc, -# then 'javadoc' or the argument are returned. Otherwise, there is no return. -# -# The output of this should be passed to ant. -# @CODE -# Parameters: -# $@ - Option value to return. Defaults to 'javadoc' -# -# Examples: -# build javadocs by calling 'javadoc' target -# eant $(use_doc) -# -# build javadocs by calling 'apidoc' target -# eant $(use_doc apidoc) -# @CODE -# @RETURN string - Name of the target to create javadocs -use_doc() { - use doc && echo ${@:-javadoc} -} - # @FUNCTION: java-pkg_init # @INTERNAL @@ -2710,7 +2704,13 @@ java-pkg_build-vm-from-handle() { fi for vm in ${JAVA_PKG_WANT_BUILD_VM}; do - if java-config-2 --select-vm=${vm} 2>/dev/null; then + local java_config + for java_config in java-config{,-2}; do + type -p ${java_config} >/dev/null && break + done + [[ -z ${java_config} ]] && die "No java-config binary in PATH" + + if ${java_config} --select-vm=${vm} 2>/dev/null; then echo ${vm} return 0 fi @@ -2813,7 +2813,7 @@ java-pkg_die() { echo "!!! When you file a bug report, please include the following information:" >&2 echo "GENTOO_VM=${GENTOO_VM} CLASSPATH=\"${CLASSPATH}\" JAVA_HOME=\"${JAVA_HOME}\"" >&2 echo "JAVACFLAGS=\"${JAVACFLAGS}\" COMPILER=\"${GENTOO_COMPILER}\"" >&2 - echo "and of course, the output of emerge --info =${P}" >&2 + echo "and of course, the output of emerge --info =${CATEGORY}/${PF}" >&2 } @@ -2931,7 +2931,7 @@ java-pkg_ensure-dep() { # if is-java-strict; then # die "${dev_error}" # else - eqawarn "java-pkg_ensure-dep: ${dev_error}" + eqawarn "QA Notice: java-pkg_ensure-dep: ${dev_error}" # eerror "Because you have ${target_pkg} installed," # eerror "the package will build without problems, but please" # eerror "report this to https://bugs.gentoo.org." @@ -2942,7 +2942,7 @@ java-pkg_ensure-dep() { # if is-java-strict; then # die "${dev_error}" # else - eqawarn "java-pkg_ensure-dep: ${dev_error}" + eqawarn "QA Notice: java-pkg_ensure-dep: ${dev_error}" # eerror "The package will build without problems, but may fail to run" # eerror "if you don't have ${target_pkg} installed," # eerror "so please report this to https://bugs.gentoo.org." diff --git a/eclass/java-vm-2.eclass b/eclass/java-vm-2.eclass index e5d3159f2854..c90cd8664f30 100644 --- a/eclass/java-vm-2.eclass +++ b/eclass/java-vm-2.eclass @@ -4,14 +4,14 @@ # @ECLASS: java-vm-2.eclass # @MAINTAINER: # java@gentoo.org -# @SUPPORTED_EAPIS: 7 8 +# @SUPPORTED_EAPIS: 8 # @BLURB: Java Virtual Machine eclass # @DESCRIPTION: # This eclass provides functionality which assists with installing # virtual machines, and ensures that they are recognized by java-config. case ${EAPI} in - 7|8) ;; + 8) ;; *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; esac @@ -164,58 +164,6 @@ get_system_arch() { } -# @FUNCTION: set_java_env -# @DESCRIPTION: -# Installs a vm env file. -# DEPRECATED, use java-vm_install-env instead. - -set_java_env() { - debug-print-function ${FUNCNAME} $* - - local platform="$(get_system_arch)" - local env_file="${ED}${JAVA_VM_CONFIG_DIR}/${VMHANDLE}" - - if [[ ${1} ]]; then - local source_env_file="${1}" - else - local source_env_file="${FILESDIR}/${VMHANDLE}.env" - fi - - if [[ ! -f ${source_env_file} ]]; then - die "Unable to find the env file: ${source_env_file}" - fi - - dodir ${JAVA_VM_CONFIG_DIR} - sed \ - -e "s/@P@/${P}/g" \ - -e "s/@PN@/${PN}/g" \ - -e "s/@PV@/${PV}/g" \ - -e "s/@PF@/${PF}/g" \ - -e "s/@SLOT@/${SLOT}/g" \ - -e "s/@PLATFORM@/${platform}/g" \ - -e "s/@LIBDIR@/$(get_libdir)/g" \ - -e "/^LDPATH=.*lib\\/\\\"/s|\"\\(.*\\)\"|\"\\1${platform}/:\\1${platform}/server/\"|" \ - < "${source_env_file}" \ - > "${env_file}" || die "sed failed" - - ( - echo "VMHANDLE=\"${VMHANDLE}\"" - echo "BUILD_ONLY=\"${JAVA_VM_BUILD_ONLY}\"" - ) >> "${env_file}" - - eprefixify ${env_file} - - [[ -n ${JAVA_PROVIDE} ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\"" >> ${env_file} - - local java_home=$(source "${env_file}"; echo ${JAVA_HOME}) - [[ -z ${java_home} ]] && die "No JAVA_HOME defined in ${env_file}" - - # Make the symlink - dodir "${JAVA_VM_DIR}" - dosym "${java_home}" "${JAVA_VM_DIR}/${VMHANDLE}" -} - - # @FUNCTION: java-vm_install-env # @DESCRIPTION: # diff --git a/eclass/kde.org.eclass b/eclass/kde.org.eclass index b9d68ccbf5c2..9be501ce9e3f 100644 --- a/eclass/kde.org.eclass +++ b/eclass/kde.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: kde.org.eclass @@ -55,6 +55,7 @@ declare -A KDE_ORG_CATEGORIES=( [games-board]=games [games-kids]=education [games-mud]=games + [games-puzzle]=games [kde-frameworks]=frameworks [kde-plasma]=plasma [mail-client]=pim diff --git a/eclass/kernel-2.eclass b/eclass/kernel-2.eclass index ffbe986f3e87..c60fcb04dd73 100644 --- a/eclass/kernel-2.eclass +++ b/eclass/kernel-2.eclass @@ -1332,7 +1332,7 @@ getfilevar() { unset ARCH echo -e "include ${basefname}\ne:\n\t@echo \$(${1})" | - make -C "${basedname}" ${BUILD_FIXES} -s -f - e 2>/dev/null + make -C "${basedname}" -s -f - e 2>/dev/null ARCH=${xarch} fi diff --git a/eclass/kernel-build.eclass b/eclass/kernel-build.eclass index 7922638be6e1..ce87fd72acdd 100644 --- a/eclass/kernel-build.eclass +++ b/eclass/kernel-build.eclass @@ -20,6 +20,14 @@ # the kernel and installing it along with its modules and subset # of sources needed to build external modules. +# @ECLASS_VARIABLE: KV_FULL +# @DEFAULT_UNSET +# @DESCRIPTION: +# A string containing the full kernel release version, e.g. +# '6.9.6-gentoo-dist'. This is used to ensure consistency between the +# kernel's release version and Gentoo's tooling. This is set by +# kernel-build_src_configure() once we have a kernel.release file. + case ${EAPI} in 8) ;; *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; @@ -28,7 +36,7 @@ esac if [[ ! ${_KERNEL_BUILD_ECLASS} ]]; then _KERNEL_BUILD_ECLASS=1 -PYTHON_COMPAT=( python3_{10..12} ) +PYTHON_COMPAT=( python3_{10..13} ) if [[ ${KERNEL_IUSE_MODULES_SIGN} ]]; then inherit secureboot fi @@ -39,6 +47,7 @@ BDEPEND=" ${PYTHON_DEPS} app-alternatives/cpio app-alternatives/bc + dev-lang/perl sys-devel/bison sys-devel/flex virtual/libelf @@ -123,13 +132,35 @@ fi # Call python-any-r1 and secureboot pkg_setup kernel-build_pkg_setup() { python-any-r1_pkg_setup - if [[ ${KERNEL_IUSE_MODULES_SIGN} ]]; then + if [[ ${KERNEL_IUSE_MODULES_SIGN} && ${MERGE_TYPE} != binary ]]; then secureboot_pkg_setup - if [[ -e ${MODULES_SIGN_KEY} && ${MODULES_SIGN_KEY} != pkcs11:* ]]; then - if [[ -e ${MODULES_SIGN_CERT} && ${MODULES_SIGN_CERT} != ${MODULES_SIGN_KEY} ]]; then - MODULES_SIGN_KEY_CONTENTS="$(cat "${MODULES_SIGN_CERT}" "${MODULES_SIGN_KEY}" || die)" + + if use modules-sign && [[ -n ${MODULES_SIGN_KEY} ]]; then + # Sanity check: fail early if key/cert in DER format or does not exist + local openssl_args=( + -noout -nocert + ) + if [[ -n ${MODULES_SIGN_CERT} ]]; then + openssl_args+=( -inform PEM -in "${MODULES_SIGN_CERT}" ) else - MODULES_SIGN_KEY_CONTENTS="$(< "${MODULES_SIGN_KEY}")" + # If no cert specified, we assume the pem key also contains the cert + openssl_args+=( -inform PEM -in "${MODULES_SIGN_KEY}" ) + fi + if [[ ${MODULES_SIGN_KEY} == pkcs11:* ]]; then + openssl_args+=( -engine pkcs11 -keyform ENGINE -key "${MODULES_SIGN_KEY}" ) + else + openssl_args+=( -keyform PEM -key "${MODULES_SIGN_KEY}" ) + fi + + openssl x509 "${openssl_args[@]}" || + die "Kernel module signing certificate or key not found or not PEM format." + + if [[ ${MODULES_SIGN_KEY} != pkcs11:* ]]; then + if [[ -n ${MODULES_SIGN_CERT} && ${MODULES_SIGN_CERT} != ${MODULES_SIGN_KEY} ]]; then + MODULES_SIGN_KEY_CONTENTS="$(cat "${MODULES_SIGN_CERT}" "${MODULES_SIGN_KEY}" || die)" + else + MODULES_SIGN_KEY_CONTENTS="$(< "${MODULES_SIGN_KEY}")" + fi fi fi fi @@ -137,8 +168,8 @@ kernel-build_pkg_setup() { # @FUNCTION: kernel-build_src_configure # @DESCRIPTION: -# Prepare the toolchain for building the kernel, get the default .config -# or restore savedconfig, and get build tree configured for modprep. +# Prepare the toolchain for building the kernel, get the .config file, +# and get build tree configured for modprep. kernel-build_src_configure() { debug-print-function ${FUNCNAME} "${@}" @@ -157,6 +188,10 @@ kernel-build_src_configure() { fi # force ld.bfd if we can find it easily + local HOSTLD="$(tc-getBUILD_LD)" + if type -P "${HOSTLD}.bfd" &>/dev/null; then + HOSTLD+=.bfd + fi local LD="$(tc-getLD)" if type -P "${LD}.bfd" &>/dev/null; then LD+=.bfd @@ -168,6 +203,8 @@ kernel-build_src_configure() { HOSTCC="$(tc-getBUILD_CC)" HOSTCXX="$(tc-getBUILD_CXX)" + HOSTLD="${HOSTLD}" + HOSTAR="$(tc-getBUILD_AR)" HOSTCFLAGS="${BUILD_CFLAGS}" HOSTLDFLAGS="${BUILD_LDFLAGS}" @@ -180,6 +217,7 @@ kernel-build_src_configure() { STRIP="$(tc-getSTRIP)" OBJCOPY="$(tc-getOBJCOPY)" OBJDUMP="$(tc-getOBJDUMP)" + READELF="$(tc-getREADELF)" # we need to pass it to override colliding Gentoo envvar ARCH=$(tc-arch-kernel) @@ -206,8 +244,7 @@ kernel-build_src_configure() { MAKEARGS+=( KBZIP2="lbzip2" ) fi - restore_config .config - [[ -f .config ]] || die "Ebuild error: please copy default config into .config" + [[ -f .config ]] || die "Ebuild error: No .config, kernel-build_merge_configs was not called." if [[ -z "${KV_LOCALVERSION}" ]]; then KV_LOCALVERSION=$(sed -n -e 's#^CONFIG_LOCALVERSION="\(.*\)"$#\1#p' \ @@ -223,6 +260,32 @@ kernel-build_src_configure() { mkdir -p "${WORKDIR}"/modprep || die mv .config "${WORKDIR}"/modprep/ || die emake O="${WORKDIR}"/modprep "${MAKEARGS[@]}" olddefconfig + + local k_release=$(emake -s O="${WORKDIR}"/modprep "${MAKEARGS[@]}" kernelrelease) + if [[ -z ${KV_FULL} ]]; then + KV_FULL=${k_release} + fi + + # Make sure we are about to build the correct kernel + if [[ ${PV} != *9999 ]]; then + local expected_ver=$(dist-kernel_PV_to_KV "${PV}") + + if [[ ${KV_FULL} != ${k_release} ]]; then + eerror "KV_FULL mismatch!" + eerror "KV_FULL: ${KV_FULL}" + eerror "Expected: ${k_release}" + die "KV_FULL mismatch: got ${KV_FULL}, expected ${k_release}" + fi + + if [[ ${KV_FULL} != ${expected_ver}* ]]; then + eerror "Kernel version does not match PV!" + eerror "Source version: ${KV_FULL}" + eerror "Expected (PV*): ${expected_ver}*" + eerror "Please ensure you are applying the correct patchset." + die "Kernel version mismatch: got ${KV_FULL}, expected ${expected_ver}*" + fi + fi + emake O="${WORKDIR}"/modprep "${MAKEARGS[@]}" modules_prepare cp -pR "${WORKDIR}"/modprep "${WORKDIR}"/build || die } @@ -233,7 +296,16 @@ kernel-build_src_configure() { kernel-build_src_compile() { debug-print-function ${FUNCNAME} "${@}" - emake O="${WORKDIR}"/build "${MAKEARGS[@]}" all + local targets=( all ) + + if grep -q "CONFIG_CTF=y" "${WORKDIR}/modprep/.config"; then + targets+=( ctf ) + fi + + local target + for target in "${targets[@]}" ; do + emake O="${WORKDIR}"/build "${MAKEARGS[@]}" "${target}" + done } # @FUNCTION: kernel-build_src_test @@ -243,6 +315,12 @@ kernel-build_src_compile() { kernel-build_src_test() { debug-print-function ${FUNCNAME} "${@}" + local targets=( modules_install ) + + if grep -q "CONFIG_CTF=y" "${WORKDIR}/modprep/.config"; then + targets+=( ctf_install ) + fi + # Use the kernel build system to strip, this ensures the modules # are stripped *before* they are signed or compressed. local strip_args @@ -250,24 +328,22 @@ kernel-build_src_test() { strip_args="--strip-unneeded" fi - emake O="${WORKDIR}"/build "${MAKEARGS[@]}" \ - INSTALL_MOD_PATH="${T}" INSTALL_MOD_STRIP="${strip_args}" \ - modules_install - - local dir_ver=${PV}${KV_LOCALVERSION} - local relfile=${WORKDIR}/build/include/config/kernel.release - local module_ver - module_ver=$(<"${relfile}") || die + local target + for target in "${targets[@]}" ; do + emake O="${WORKDIR}"/build "${MAKEARGS[@]}" \ + INSTALL_MOD_PATH="${T}" INSTALL_MOD_STRIP="${strip_args}" \ + "${target}" + done - kernel-install_test "${module_ver}" \ + kernel-install_test "${KV_FULL}" \ "${WORKDIR}/build/$(dist-kernel_get_image_path)" \ - "${T}/lib/modules/${module_ver}" + "${T}/lib/modules/${KV_FULL}" } # @FUNCTION: kernel-build_src_install # @DESCRIPTION: # Install the built kernel along with subset of sources -# into /usr/src/linux-${PV}. Install the modules. Save the config. +# into /usr/src/linux-${KV_FULL}. Install the modules. Save the config. kernel-build_src_install() { debug-print-function ${FUNCNAME} "${@}" @@ -279,6 +355,10 @@ kernel-build_src_install() { targets+=( dtbs_install ) fi + if grep -q "CONFIG_CTF=y" "${WORKDIR}/modprep/.config"; then + targets+=( ctf_install ) + fi + # Use the kernel build system to strip, this ensures the modules # are stripped *before* they are signed or compressed. local strip_args @@ -297,15 +377,17 @@ kernel-build_src_install() { ) fi - emake O="${WORKDIR}"/build "${MAKEARGS[@]}" \ - INSTALL_MOD_PATH="${ED}" INSTALL_MOD_STRIP="${strip_args}" \ - INSTALL_PATH="${ED}/boot" "${compress[@]}" "${targets[@]}" + local target + for target in "${targets[@]}" ; do + emake O="${WORKDIR}"/build "${MAKEARGS[@]}" \ + INSTALL_MOD_PATH="${ED}" INSTALL_MOD_STRIP="${strip_args}" \ + INSTALL_PATH="${ED}/boot" "${compress[@]}" "${target}" + done # note: we're using mv rather than doins to save space and time # install main and arch-specific headers first, and scripts local kern_arch=$(tc-arch-kernel) - local dir_ver=${PV}${KV_LOCALVERSION} - local kernel_dir=/usr/src/linux-${dir_ver} + local kernel_dir=/usr/src/linux-${KV_FULL} if use sparc ; then # We don't want tc-arch-kernel's sparc64, even though we do @@ -373,22 +455,37 @@ kernel-build_src_install() { mv "build/vmlinux" "${ED}${kernel_dir}/vmlinux" || die fi dostrip -x "${kernel_dir}/vmlinux" + dostrip -x "${kernel_dir}/vmlinux.ctfa" fi # strip empty directories find "${D}" -type d -empty -exec rmdir {} + || die - local relfile=${ED}${kernel_dir}/include/config/kernel.release - local module_ver - module_ver=$(<"${relfile}") || die + # warn when trying to "make" a dist-kernel + cat <<-EOF >> "${ED}${kernel_dir}/Makefile" || die + + _GENTOO_IS_USER_SHELL:=\$(shell [ -t 0 ] && echo 1) + ifdef _GENTOO_IS_USER_SHELL + \$(warning !!!! WARNING !!!!) + \$(warning This kernel was configured and installed by the package manager.) + \$(warning "make" should not be run manually here.) + \$(warning See also: https://wiki.gentoo.org/wiki/Project:Distribution_Kernel) + \$(warning See also: https://wiki.gentoo.org/wiki/Kernel/Configuration) + \$(warning !!!! WARNING !!!!) + endif + EOF + # add a dist-kernel identifier file + echo "${CATEGORY}/${PF}:${SLOT}" > "${ED}${kernel_dir}/dist-kernel" || die # fix source tree and build dir symlinks - dosym "../../../${kernel_dir}" "/lib/modules/${module_ver}/build" - dosym "../../../${kernel_dir}" "/lib/modules/${module_ver}/source" + dosym "../../../${kernel_dir}" "/lib/modules/${KV_FULL}/build" + dosym "../../../${kernel_dir}" "/lib/modules/${KV_FULL}/source" + dosym "../../../${kernel_dir}/.config" "/lib/modules/${KV_FULL}/config" + dosym "../../../${kernel_dir}/System.map" "/lib/modules/${KV_FULL}/System.map" if [[ "${image_path}" == *vmlinux* ]]; then - dosym "../../../${kernel_dir}/${image_path}" "/lib/modules/${module_ver}/vmlinux" + dosym "../../../${kernel_dir}/${image_path}" "/lib/modules/${KV_FULL}/vmlinux" else - dosym "../../../${kernel_dir}/${image_path}" "/lib/modules/${module_ver}/vmlinuz" + dosym "../../../${kernel_dir}/${image_path}" "/lib/modules/${KV_FULL}/vmlinuz" fi if [[ ${KERNEL_IUSE_MODULES_SIGN} ]]; then @@ -419,8 +516,8 @@ kernel-build_src_install() { --conf "${T}/empty-file" --confdir "${T}/empty-directory" --kernel-image "${image}" - --kmoddir "${ED}/lib/modules/${dir_ver}" - --kver "${dir_ver}" + --kmoddir "${ED}/lib/modules/${KV_FULL}" + --kver "${KV_FULL}" --verbose --compress="xz -9e --check=crc32" --no-hostonly @@ -446,11 +543,11 @@ kernel-build_src_install() { --linux="${image}" --initrd="${image%/*}/initrd" --cmdline="${KERNEL_GENERIC_UKI_CMDLINE}" - --uname="${dir_ver}" + --uname="${KV_FULL}" --output="${image%/*}/uki.efi" ) - if [[ ${KERNEL_IUSE_SECUREBOOT} ]] && use secureboot; then + if [[ ${KERNEL_IUSE_MODULES_SIGN} ]] && use secureboot; then ukify_args+=( --signtool=sbsign --secureboot-private-key="${SECUREBOOT_SIGN_KEY}" @@ -504,7 +601,7 @@ kernel-build_pkg_postinst() { ewarn ewarn "MODULES_SIGN_KEY was not set, this means the kernel build system" ewarn "automatically generated the signing key. This key was installed" - ewarn "in ${EROOT}/usr/src/linux-${PV}${KV_LOCALVERSION}/certs" + ewarn "in ${EROOT}/usr/src/linux-${KV_FULL}/certs" ewarn "and will also be included in any binary packages." ewarn "Please take appropriate action to protect the key!" ewarn @@ -523,15 +620,22 @@ kernel-build_pkg_postinst() { # @FUNCTION: kernel-build_merge_configs # @USAGE: [distro.config...] # @DESCRIPTION: -# Merge the config files specified as arguments (if any) into -# the '.config' file in the current directory, then merge -# any user-supplied configs from ${BROOT}/etc/kernel/config.d/*.config. -# The '.config' file must exist already and contain the base -# configuration. +# Merge kernel config files. The following is merged onto the '.config' +# file in the current directory, in order: +# +# 1. Config files specified as arguments. +# 2. Default module signing and compression configuration +# (if applicable). +# 3. Config saved via USE=savedconfig (if applicable). +# 4. Module signing key specified via MODULES_SIGN_KEY* variables. +# 5. User-supplied configs from ${BROOT}/etc/kernel/config.d/*.config. +# +# This function must be called by the ebuild in the src_prepare phase. kernel-build_merge_configs() { debug-print-function ${FUNCNAME} "${@}" - [[ -f .config ]] || die "${FUNCNAME}: .config does not exist" + [[ -f .config ]] || + die "${FUNCNAME}: No .config, please copy default config into .config" has .config "${@}" && die "${FUNCNAME}: do not specify .config as parameter" @@ -542,30 +646,16 @@ kernel-build_merge_configs() { local merge_configs=( "${@}" ) - if [[ ${KERNEL_IUSE_MODULES_SIGN} ]]; then - if use modules-sign; then - : "${MODULES_SIGN_HASH:=sha512}" - cat <<-EOF > "${WORKDIR}/modules-sign.config" || die - ## Enable module signing - CONFIG_MODULE_SIG=y - CONFIG_MODULE_SIG_ALL=y - CONFIG_MODULE_SIG_FORCE=y - CONFIG_MODULE_SIG_${MODULES_SIGN_HASH^^}=y - EOF - if [[ -n ${MODULES_SIGN_KEY_CONTENTS} ]]; then - (umask 066 && touch "${T}/kernel_key.pem" || die) - echo "${MODULES_SIGN_KEY_CONTENTS}" > "${T}/kernel_key.pem" || die - unset MODULES_SIGN_KEY_CONTENTS - export MODULES_SIGN_KEY="${T}/kernel_key.pem" - fi - if [[ ${MODULES_SIGN_KEY} == pkcs11:* || -r ${MODULES_SIGN_KEY} ]]; then - echo "CONFIG_MODULE_SIG_KEY=\"${MODULES_SIGN_KEY}\"" \ - >> "${WORKDIR}/modules-sign.config" - elif [[ -n ${MODULES_SIGN_KEY} ]]; then - die "MODULES_SIGN_KEY=${MODULES_SIGN_KEY} not found or not readable!" - fi - merge_configs+=( "${WORKDIR}/modules-sign.config" ) - fi + if [[ ${KERNEL_IUSE_MODULES_SIGN} ]] && use modules-sign; then + : "${MODULES_SIGN_HASH:=sha512}" + cat <<-EOF > "${WORKDIR}/modules-sign.config" || die + ## Enable module signing + CONFIG_MODULE_SIG=y + CONFIG_MODULE_SIG_ALL=y + CONFIG_MODULE_SIG_FORCE=y + CONFIG_MODULE_SIG_${MODULES_SIGN_HASH^^}=y + EOF + merge_configs+=( "${WORKDIR}/modules-sign.config" ) fi # Only semi-related but let's use that to avoid changing stable ebuilds. @@ -579,6 +669,27 @@ kernel-build_merge_configs() { merge_configs+=( "${WORKDIR}/module-compress.config" ) fi + restore_config "${WORKDIR}/savedconfig.config" + if [[ -f ${WORKDIR}/savedconfig.config ]]; then + merge_configs+=( "${WORKDIR}/savedconfig.config" ) + fi + + if [[ ${KERNEL_IUSE_MODULES_SIGN} ]] && use modules-sign; then + if [[ -n ${MODULES_SIGN_KEY_CONTENTS} ]]; then + (umask 066 && touch "${T}/kernel_key.pem" || die) + echo "${MODULES_SIGN_KEY_CONTENTS}" > "${T}/kernel_key.pem" || die + unset MODULES_SIGN_KEY_CONTENTS + export MODULES_SIGN_KEY="${T}/kernel_key.pem" + fi + if [[ ${MODULES_SIGN_KEY} == pkcs11:* || -r ${MODULES_SIGN_KEY} ]]; then + echo "CONFIG_MODULE_SIG_KEY=\"${MODULES_SIGN_KEY}\"" \ + >> "${WORKDIR}/modules-sign-key.config" + merge_configs+=( "${WORKDIR}/modules-sign-key.config" ) + elif [[ -n ${MODULES_SIGN_KEY} ]]; then + die "MODULES_SIGN_KEY=${MODULES_SIGN_KEY} not found or not readable!" + fi + fi + if [[ ${#user_configs[@]} -gt 0 ]]; then elog "User config files are being applied:" local x diff --git a/eclass/kernel-install.eclass b/eclass/kernel-install.eclass index f512d815fe09..930640188c26 100644 --- a/eclass/kernel-install.eclass +++ b/eclass/kernel-install.eclass @@ -17,9 +17,7 @@ # /usr/src/linux-${PV} containing the kernel image in its standard # location and System.map. # -# The eclass exports src_test, pkg_postinst and pkg_postrm. -# Additionally, the inherited mount-boot eclass exports pkg_pretend. -# It also stubs out pkg_preinst and pkg_prerm defined by mount-boot. +# The eclass exports src_test, pkg_preinst, pkg_postinst and pkg_postrm. # @ECLASS_VARIABLE: KERNEL_IUSE_GENERIC_UKI # @PRE_INHERIT @@ -28,6 +26,15 @@ # If set to a non-null value, adds IUSE=generic-uki and required # logic to install a generic unified kernel image. +# @ECLASS_VARIABLE: KV_FULL +# @DEFAULT_UNSET +# @DESCRIPTION: +# A string containing the full kernel release version, e.g. +# '6.9.6-gentoo-dist'. Defaults to ${PV}${KV_LOCALVERSION}, +# but can be set by the ebuild when this default value does +# not match the kernel release. kernel-build.eclass sets this +# to whatever is in the built kernel's kernel.release file. + # @ECLASS_VARIABLE: KV_LOCALVERSION # @DEFAULT_UNSET # @DESCRIPTION: @@ -50,7 +57,7 @@ case ${EAPI} in *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; esac -inherit dist-kernel-utils mount-boot multiprocessing toolchain-funcs +inherit dist-kernel-utils mount-boot-utils multiprocessing toolchain-funcs SLOT="${PV}" IUSE="+initramfs test" @@ -65,7 +72,10 @@ _IDEPEND_BASE=" >=sys-kernel/installkernel-14 ) initramfs? ( - >=sys-kernel/installkernel-14[dracut(-)] + || ( + >=sys-kernel/installkernel-14[dracut(-)] + >=sys-kernel/installkernel-14[ugrd(-)] + ) ) " @@ -192,7 +202,7 @@ if [[ ${KERNEL_IUSE_GENERIC_UKI} ]]; then " IDEPEND=" generic-uki? ( - >=sys-kernel/installkernel-14[-dracut(-),-ukify(-)] + >=sys-kernel/installkernel-14[-dracut(-),-ugrd(-),-ukify(-)] ) !generic-uki? ( ${_IDEPEND_BASE} @@ -526,6 +536,10 @@ kernel-install_test() { kernel-install_pkg_pretend() { debug-print-function ${FUNCNAME} "${@}" + # Check, but don't die because we can fix the problem and then + # emerge --config ... to re-run installation. + nonfatal mount-boot_check_status + if ! has_version -d sys-kernel/linux-firmware; then ewarn "sys-kernel/linux-firmware not found installed on your system." ewarn "This package provides various firmware files that may be needed" @@ -541,16 +555,26 @@ kernel-install_pkg_pretend() { if ! use initramfs && ! has_version "${CATEGORY}/${PN}[-initramfs]"; then ewarn - ewarn "WARNING: The standard configuration of the Gentoo distribution" - ewarn "kernels requires an initramfs! You have disabled the initramfs" - ewarn "USE flag and as a result dracut was not pulled in as a dependency." - ewarn "Please ensure that you are either overriding the standard" - ewarn "configuration or that an alternative initramfs generation plugin" - ewarn "is installed for your installkernel implementation!" + ewarn "WARNING: The default distribution kernel configuration is designed" + ewarn "to be used with an initramfs! Although possible, there is no guarantee" + ewarn "that distribution kernels will boot without an initramfs." + ewarn + ewarn "You have disabled the initramfs USE flag, and as a result the package manager" + ewarn "will not enforce the configuration of an initramfs generator in" + ewarn "sys-kernel/installkernel." ewarn - ewarn "This is an advanced use case, you are on your own to ensure" - ewarn "that your system is bootable!" + ewarn "If you wish to use a custom initramfs generator, then please ensure that" + ewarn "/sbin/installkernel is capable of calling it via a kernel installation hook," + ewarn "and is also configured to use it via /etc/kernel/install.conf." ewarn + ewarn "If you wish to boot without an initramfs, then please ensure that" + ewarn "all kernel drivers required to boot your system are built into the" + ewarn "kernel by modifying the default distribution kernel configuration" + ewarn "using /etc/kernel/config.d" + ewarn + ewarn "Please refer to the installkernel and distribution kernel documentation:" + ewarn " https://wiki.gentoo.org/wiki/Installkernel" + ewarn " https://wiki.gentoo.org/wiki/Project:Distribution_Kernel" fi } @@ -569,40 +593,47 @@ kernel-install_src_test() { kernel-install_pkg_preinst() { debug-print-function ${FUNCNAME} "${@}" - local dir_ver=${PV}${KV_LOCALVERSION} - local kernel_dir=${ED}/usr/src/linux-${dir_ver} - local relfile=${kernel_dir}/include/config/kernel.release + # Set KV_FULL to ${PV}${KV_LOCALVERSION} if it hasn't + # been set elsewhere for backward compatibility with existing + # bin-kernel packages + if [[ -z ${KV_FULL} ]]; then + KV_FULL=${PV}${KV_LOCALVERSION} + fi + + local kernel_dir=${ED}/usr/src/linux-${KV_FULL} local image_path=$(dist-kernel_get_image_path) [[ ! -d ${kernel_dir} ]] && die "Kernel directory ${kernel_dir} not installed!" - [[ ! -f ${relfile} ]] && - die "Release file ${relfile} not installed!" - local release - release="$(<"${relfile}")" || die - DIST_KERNEL_RELEASE="${release}" # perform the version check for release ebuilds only if [[ ${PV} != *9999 ]]; then local expected_ver=$(dist-kernel_PV_to_KV "${PV}") - if [[ ${release} != ${expected_ver}* ]]; then - eerror "Kernel release mismatch!" - eerror " expected (PV): ${expected_ver}*" - eerror " found: ${release}" - eerror "Please verify that you are applying the correct patches." - die "Kernel release mismatch (${release} instead of ${expected_ver}*)" + if [[ ${KV_FULL} != ${expected_ver}* ]]; then + eerror "Kernel version does not match PV!" + eerror "Source version: ${KV_FULL}" + eerror "Expected (PV*): ${expected_ver}*" + eerror "Please ensure you are applying the correct patchset." + die "Kernel version mismatch: got ${KV_FULL}, expected ${expected_ver}*" fi fi if [[ -L ${EROOT}/lib && ${EROOT}/lib -ef ${EROOT}/usr/lib ]]; then # Adjust symlinks for merged-usr. - rm "${ED}/lib/modules/${release}"/{build,source} || die - dosym "../../../src/linux-${dir_ver}" "/usr/lib/modules/${release}/build" - dosym "../../../src/linux-${dir_ver}" "/usr/lib/modules/${release}/source" + rm "${ED}/lib/modules/${KV_FULL}"/{build,source} || die + dosym "../../../src/linux-${KV_FULL}" "/usr/lib/modules/${KV_FULL}/build" + dosym "../../../src/linux-${KV_FULL}" "/usr/lib/modules/${KV_FULL}/source" + local file + for file in .config System.map; do + if [[ -L "${ED}/lib/modules/${KV_FULL}/${file#.}" ]]; then + rm "${ED}/lib/modules/${KV_FULL}/${file#.}" || die + dosym "../../../src/linux-${KV_FULL}/${file}" "/usr/lib/modules/${KV_FULL}/${file#.}" + fi + done for file in vmlinux vmlinuz; do - if [[ -L "${ED}/lib/modules/${release}/${file}" ]]; then - rm "${ED}/lib/modules/${release}/${file}" || die - dosym "../../../src/linux-${dir_ver}/${image_path}" "/usr/lib/modules/${release}/${file}" + if [[ -L "${ED}/lib/modules/${KV_FULL}/${file}" ]]; then + rm "${ED}/lib/modules/${KV_FULL}/${file}" || die + dosym "../../../src/linux-${KV_FULL}/${image_path}" "/usr/lib/modules/${KV_FULL}/${file}" fi done fi @@ -665,27 +696,8 @@ kernel-install_install_all() { fi fi - local success= - # not an actual loop but allows error handling with 'break' - while :; do - nonfatal mount-boot_check_status || break - - nonfatal dist-kernel_install_kernel "${module_ver}" \ - "${kernel_dir}/${image_path}" "${kernel_dir}/System.map" || break - - success=1 - break - done - - if [[ ! ${success} ]]; then - eerror - eerror "The kernel files were copied to disk successfully but the kernel" - eerror "was not deployed successfully. Once you resolve the problems," - eerror "please run the equivalent of the following command to try again:" - eerror - eerror " emerge --config ${CATEGORY}/${PN}:${SLOT}" - die "Kernel install failed, please fix the problems and run emerge --config ${CATEGORY}/${PN}:${SLOT}" - fi + dist-kernel_install_kernel "${module_ver}" "${kernel_dir}/${image_path}" \ + "${kernel_dir}/System.map" } # @FUNCTION: kernel-install_pkg_postinst @@ -695,13 +707,12 @@ kernel-install_install_all() { kernel-install_pkg_postinst() { debug-print-function ${FUNCNAME} "${@}" - local dir_ver=${PV}${KV_LOCALVERSION} - kernel-install_update_symlink "${EROOT}/usr/src/linux" "${dir_ver}" + kernel-install_update_symlink "${EROOT}/usr/src/linux" "${KV_FULL}" dist-kernel_compressed_module_cleanup \ - "${EROOT}/lib/modules/${DIST_KERNEL_RELEASE}" + "${EROOT}/lib/modules/${KV_FULL}" if [[ -z ${ROOT} ]]; then - kernel-install_install_all "${dir_ver}" + kernel-install_install_all "${KV_FULL}" fi if [[ ${KERNEL_IUSE_GENERIC_UKI} ]] && use generic-uki; then @@ -718,15 +729,6 @@ kernel-install_pkg_postinst() { fi } -# @FUNCTION: kernel-install_pkg_prerm -# @DESCRIPTION: -# Stub out mount-boot.eclass. -kernel-install_pkg_prerm() { - debug-print-function ${FUNCNAME} "${@}" - - # (no-op) -} - # @FUNCTION: kernel-install_pkg_postrm # @DESCRIPTION: # Clean up the generated initramfs from the removed kernel directory. @@ -734,8 +736,7 @@ kernel-install_pkg_postrm() { debug-print-function ${FUNCNAME} "${@}" if [[ -z ${ROOT} && ! ${KERNEL_IUSE_GENERIC_UKI} ]]; then - local dir_ver=${PV}${KV_LOCALVERSION} - local kernel_dir=${EROOT}/usr/src/linux-${dir_ver} + local kernel_dir=${EROOT}/usr/src/linux-${KV_FULL} local image_path=$(dist-kernel_get_image_path) ebegin "Removing initramfs" rm -f "${kernel_dir}/${image_path%/*}"/{initrd,uki.efi} && @@ -750,7 +751,11 @@ kernel-install_pkg_postrm() { kernel-install_pkg_config() { [[ -z ${ROOT} ]] || die "ROOT!=/ not supported currently" - kernel-install_install_all "${PV}${KV_LOCALVERSION}" + if [[ -z ${KV_FULL} ]]; then + KV_FULL=${PV}${KV_LOCALVERSION} + fi + + kernel-install_install_all "${KV_FULL}" } # @FUNCTION: kernel-install_compress_modules @@ -761,18 +766,43 @@ kernel-install_compress_modules() { if use modules-compress; then einfo "Compressing kernel modules ..." - # xz options taken from scripts/Makefile.modinst - # we don't do 'xz -T' because it applies multithreading per file, - # so it works only for big files, and we have lots of small files - # instead - find "${ED}/lib" -name '*.ko' -print0 | - xargs -0 -P "$(makeopts_jobs)" -n 128 \ - xz --check=crc32 --lzma2=dict=1MiB + if [[ -z ${KV_FULL} ]]; then + KV_FULL=${PV}${KV_LOCALVERSION} + fi + local suffix=$(dist-kernel_get_module_suffix "${ED}/usr/src/linux-${KV_FULL}/.config") + local compress=() + # Options taken from linux-mod-r1.eclass. + # We don't instruct the compressor to parallelize because it applies + # multithreading per file, so it works only for big files, and we have + # lots of small files instead. + case ${suffix} in + .ko) + return + ;; + .ko.gz) + compress+=( gzip ) + ;; + .ko.xz) + compress+=( xz --check=crc32 --lzma2=dict=1MiB ) + ;; + .ko.zst) + compress+=( zstd -q --rm ) + ;; + *) + die "Unknown compressor: ${suffix}" + ;; + esac + + find "${ED}/lib/modules/${KV_FULL}" -name '*.ko' -print0 | + xargs -0 -P "$(makeopts_jobs)" -n 128 "${compress[@]}" assert "Compressing kernel modules failed" + + # Module paths have changed, run depmod + depmod --all --basedir "${ED}" ${KV_FULL} || die fi } fi -EXPORT_FUNCTIONS src_test pkg_preinst pkg_postinst pkg_prerm pkg_postrm +EXPORT_FUNCTIONS src_test pkg_preinst pkg_postinst pkg_postrm EXPORT_FUNCTIONS pkg_config pkg_pretend diff --git a/eclass/libtool.eclass b/eclass/libtool.eclass index bd6141e1ede9..b36b1fd365d3 100644 --- a/eclass/libtool.eclass +++ b/eclass/libtool.eclass @@ -18,6 +18,15 @@ if [[ -z ${_LIBTOOL_ECLASS} ]]; then _LIBTOOL_ECLASS=1 case ${EAPI} in + 6) + ewarn "${CATEGORY}/${PF}: ebuild uses ${ECLASS} with deprecated EAPI ${EAPI}!" + ewarn "${CATEGORY}/${PF}: Support will be removed on 2024-10-08. Please port to newer EAPI." + ;; + 7|8) ;; + *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; +esac + +case ${EAPI} in 6) DEPEND=">=app-portage/elt-patches-20240116" ;; 7|8) BDEPEND=">=app-portage/elt-patches-20240116" ;; *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; diff --git a/eclass/linux-info.eclass b/eclass/linux-info.eclass index 9449a6359d2a..0f6138150144 100644 --- a/eclass/linux-info.eclass +++ b/eclass/linux-info.eclass @@ -6,7 +6,7 @@ # kernel@gentoo.org # @AUTHOR: # Original author: John Mylchreest <johnm@gentoo.org> -# @SUPPORTED_EAPIS: 6 7 8 +# @SUPPORTED_EAPIS: 7 8 # @BLURB: eclass used for accessing kernel related information # @DESCRIPTION: # This eclass is used as a central eclass for accessing kernel @@ -28,7 +28,7 @@ # get_running_version case ${EAPI} in - 6|7|8) ;; + 7|8) ;; *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; esac @@ -38,7 +38,6 @@ _LINUX_INFO_ECLASS=1 # A Couple of env vars are available to effect usage of this eclass # These are as follows: - # @ECLASS_VARIABLE: CHECKCONFIG_DONOTHING # @USER_VARIABLE # @DEFAULT_UNSET @@ -51,7 +50,7 @@ _LINUX_INFO_ECLASS=1 # @DESCRIPTION: # A string containing the directory of the target kernel sources. The default value is # "/usr/src/linux" -KERNEL_DIR="${KERNEL_DIR:-${ROOT%/}/usr/src/linux}" +KERNEL_DIR="${KERNEL_DIR:-${ROOT}/usr/src/linux}" # @ECLASS_VARIABLE: CONFIG_CHECK # @DEFAULT_UNSET @@ -88,7 +87,6 @@ KERNEL_DIR="${KERNEL_DIR:-${ROOT%/}/usr/src/linux}" # CONFIG_CHECK="~CFG" with ERROR_<CFG>="Error Message" calls eerror without dying # CONFIG_CHECK="~CFG" with WARNING_<CFG>="Warning Message" calls ewarn without dying - # @ECLASS_VARIABLE: KBUILD_OUTPUT # @DEFAULT_UNSET # @DESCRIPTION: @@ -168,13 +166,6 @@ KERNEL_DIR="${KERNEL_DIR:-${ROOT%/}/usr/src/linux}" # And to ensure all the weirdness with crosscompile inherit toolchain-funcs -[[ ${EAPI} == 6 ]] && inherit eapi7-ver - -# bug #75034 -case ${ARCH} in - ppc) BUILD_FIXES="${BUILD_FIXES} TOUT=${T}/.tmp_gas_check";; - ppc64) BUILD_FIXES="${BUILD_FIXES} TOUT=${T}/.tmp_gas_check";; -esac # @FUNCTION: set_arch_to_kernel # @DESCRIPTION: @@ -248,8 +239,7 @@ getfilevar() { # Pass dot-config=0 to avoid the config check in kernels prior to 5.4. echo -e "e:\\n\\t@echo \$(${1})\\ninclude ${basefname}" | \ nonfatal emake -C "${basedname}" --no-print-directory M="${T}" \ - dot-config=0 need-config= need-compiler= \ - ${BUILD_FIXES} -s -f - 2>/dev/null + dot-config=0 need-config= need-compiler= -s -f - 2>/dev/null ARCH=${myARCH} fi @@ -642,7 +632,7 @@ get_version() { # caught before this if they are. if [[ -z ${OUTPUT_DIR} ]] ; then # Try to locate a kernel that is most relevant for us. - for OUTPUT_DIR in "${SYSROOT}" "${ROOT%/}" "" ; do + for OUTPUT_DIR in "${SYSROOT}" "${ROOT}" "" ; do OUTPUT_DIR+="/lib/modules/${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${KV_EXTRA}${KV_LOCAL}/build" if [[ -e ${OUTPUT_DIR} ]] ; then break @@ -670,10 +660,10 @@ get_running_version() { local kv=$(uname -r) - if [[ -f ${ROOT%/}/lib/modules/${kv}/source/Makefile ]]; then - KERNEL_DIR=$(readlink -f "${ROOT%/}/lib/modules/${kv}/source") - if [[ -f ${ROOT%/}/lib/modules/${kv}/build/Makefile ]]; then - KBUILD_OUTPUT=$(readlink -f "${ROOT%/}/lib/modules/${kv}/build") + if [[ -f ${ROOT}/lib/modules/${kv}/source/Makefile ]]; then + KERNEL_DIR=$(readlink -f "${ROOT}/lib/modules/${kv}/source") + if [[ -f ${ROOT}/lib/modules/${kv}/build/Makefile ]]; then + KBUILD_OUTPUT=$(readlink -f "${ROOT}/lib/modules/${kv}/build") fi get_version && return 0 fi @@ -718,7 +708,6 @@ linux-info_get_any_version() { fi } - # ebuild check functions # --------------------------------------- diff --git a/eclass/linux-mod-r1.eclass b/eclass/linux-mod-r1.eclass index 43c5a7d7b140..120fb019d74a 100644 --- a/eclass/linux-mod-r1.eclass +++ b/eclass/linux-mod-r1.eclass @@ -121,6 +121,7 @@ DEPEND=" virtual/linux-sources " BDEPEND=" + dev-util/pahole sys-apps/kmod[tools] modules-sign? ( dev-libs/openssl @@ -132,6 +133,7 @@ IDEPEND=" " if [[ ${MODULES_INITRAMFS_IUSE} ]]; then + inherit mount-boot-utils IUSE+=" ${MODULES_INITRAMFS_IUSE}" IDEPEND+=" ${MODULES_INITRAMFS_IUSE#+}? ( @@ -328,9 +330,19 @@ fi # 3. perform various sanity checks to fail early on issues linux-mod-r1_pkg_setup() { debug-print-function ${FUNCNAME[0]} "${@}" - [[ ${MERGE_TYPE} != binary ]] || return 0 _MODULES_GLOBAL[ran:pkg_setup]=1 _modules_check_function ${#} 0 0 || return 0 + + if [[ -z ${ROOT} && ${MODULES_INITRAMFS_IUSE} ]] && + use dist-kernel && use ${MODULES_INITRAMFS_IUSE#+} + then + # Check, but don't die because we can fix the problem and then + # emerge --config ... to re-run installation. + nonfatal mount-boot_check_status + fi + + [[ ${MERGE_TYPE} != binary ]] || return 0 + _modules_check_migration _modules_prepare_kernel diff --git a/eclass/llvm-r1.eclass b/eclass/llvm-r1.eclass index 658946a1ecbd..0a53b9a3cb5e 100644 --- a/eclass/llvm-r1.eclass +++ b/eclass/llvm-r1.eclass @@ -31,8 +31,8 @@ # DEPEND=" # dev-libs/libfoo[${LLVM_USEDEP}] # $(llvm_gen_dep ' -# sys-devel/clang:${LLVM_SLOT} -# sys-devel/llvm:${LLVM_SLOT} +# sys-devel/clang:${LLVM_SLOT}= +# sys-devel/llvm:${LLVM_SLOT}= # ') # " # @CODE @@ -61,7 +61,7 @@ _LLVM_OLDEST_SLOT=15 # @DESCRIPTION: # The newest stable LLVM version. Versions newer than that won't # be automatically enabled via USE defaults. -_LLVM_NEWEST_STABLE=17 +_LLVM_NEWEST_STABLE=18 # == control variables == @@ -123,11 +123,16 @@ _llvm_set_globals() { fi if [[ ${stable[@]} ]]; then + # If there is at least one stable slot supported, then enable + # the newest stable slot by default. IUSE="+llvm_slot_${stable[-1]}" unset 'stable[-1]' else - IUSE="+llvm_slot_${unstable[-1]}" - unset 'unstable[-1]' + # Otherwise, enable the "oldest" ~arch slot. We really only + # expect a single ~arch version, so this primarily prevents + # defaulting to non-keyworded slots. + IUSE="+llvm_slot_${unstable[0]}" + unset 'unstable[0]' fi local nondefault=( "${stable[@]}" "${unstable[@]}" ) IUSE+=" ${nondefault[*]/#/llvm_slot_}" @@ -158,8 +163,8 @@ unset -f _llvm_set_globals # @CODE # DEPEND=" # $(llvm_gen_dep ' -# sys-devel/clang:${LLVM_SLOT} -# sys-devel/llvm:${LLVM_SLOT} +# sys-devel/clang:${LLVM_SLOT}= +# sys-devel/llvm:${LLVM_SLOT}= # ') # " # @CODE diff --git a/eclass/llvm.eclass b/eclass/llvm.eclass index e297fe992c9f..bb5ff5d78290 100644 --- a/eclass/llvm.eclass +++ b/eclass/llvm.eclass @@ -9,6 +9,7 @@ # @SUPPORTED_EAPIS: 7 8 # @PROVIDES: llvm-utils # @BLURB: Utility functions to build against slotted LLVM +# @DEPRECATED: llvm-r1.eclass # @DESCRIPTION: # The llvm.eclass provides utility functions that can be used to build # against specific version of slotted LLVM (with fallback to :0 for old diff --git a/eclass/llvm.org.eclass b/eclass/llvm.org.eclass index 6f932bb3aff3..f8953ec11826 100644 --- a/eclass/llvm.org.eclass +++ b/eclass/llvm.org.eclass @@ -57,7 +57,7 @@ LLVM_VERSION=$(ver_cut 1-3) # @DESCRIPTION: # The major version of current LLVM trunk. Used to determine # the correct branch to use. -_LLVM_MAIN_MAJOR=19 +_LLVM_MAIN_MAJOR=20 # @ECLASS_VARIABLE: _LLVM_SOURCE_TYPE # @INTERNAL @@ -72,17 +72,11 @@ if [[ -z ${_LLVM_SOURCE_TYPE+1} ]]; then _LLVM_SOURCE_TYPE=snapshot case ${PV} in - 19.0.0_pre20240518) - EGIT_COMMIT=702198fc9ac5dba392f9d9ba7c56467996343c0a + 20.0.0_pre20240910) + EGIT_COMMIT=bece0d7517bd0a036dc8a319514e4a8a5c497dee ;; - 19.0.0_pre20240509) - EGIT_COMMIT=a7ee81e8279e0bf6e05617a4a638e5f2f8e45022 - ;; - 19.0.0_pre20240504) - EGIT_COMMIT=76aa042dde6ba9ba57c680950f5818259ee02690 - ;; - 19.0.0_pre20240427) - EGIT_COMMIT=338561657685c1831a53563b1bc36ffc7470239e + 20.0.0_pre20240830) + EGIT_COMMIT=5500e21942f7047344b6fee62d3e08c0ba2f9182 ;; *) die "Unknown snapshot: ${PV}" @@ -244,12 +238,21 @@ llvm.org_set_globals() { EGIT_BRANCH="release/${LLVM_MAJOR}.x" ;; tar) - SRC_URI+=" - https://github.com/llvm/llvm-project/releases/download/llvmorg-${PV/_/-}/llvm-project-${PV/_/}.src.tar.xz - verify-sig? ( - https://github.com/llvm/llvm-project/releases/download/llvmorg-${PV/_/-}/llvm-project-${PV/_/}.src.tar.xz.sig - ) - " + if [[ ${LLVM_MAJOR} -ge 19 ]]; then + SRC_URI+=" + https://github.com/llvm/llvm-project/releases/download/llvmorg-${PV/_/-}/llvm-project-${PV/_/-}.src.tar.xz + verify-sig? ( + https://github.com/llvm/llvm-project/releases/download/llvmorg-${PV/_/-}/llvm-project-${PV/_/-}.src.tar.xz.sig + ) + " + else + SRC_URI+=" + https://github.com/llvm/llvm-project/releases/download/llvmorg-${PV/_/-}/llvm-project-${PV/_/}.src.tar.xz + verify-sig? ( + https://github.com/llvm/llvm-project/releases/download/llvmorg-${PV/_/-}/llvm-project-${PV/_/}.src.tar.xz.sig + ) + " + fi BDEPEND+=" verify-sig? ( >=sec-keys/openpgp-keys-llvm-18.1.6 @@ -362,7 +365,11 @@ llvm.org_src_unpack() { git-r3_checkout '' . '' "${components[@]}" ;; tar) - archive=llvm-project-${PV/_/}.src.tar.xz + if [[ ${LLVM_MAJOR} -ge 19 ]]; then + archive=llvm-project-${PV/_/-}.src.tar.xz + else + archive=llvm-project-${PV/_/}.src.tar.xz + fi if use verify-sig; then verify-sig_verify_detached \ "${DISTDIR}/${archive}" "${DISTDIR}/${archive}.sig" diff --git a/eclass/ltprune.eclass b/eclass/ltprune.eclass deleted file mode 100644 index 5a36647d1d1c..000000000000 --- a/eclass/ltprune.eclass +++ /dev/null @@ -1,176 +0,0 @@ -# Copyright 1999-2022 Gentoo Authors -# Distributed under the terms of the GNU General Public License v2 - -# @ECLASS: ltprune.eclass -# @MAINTAINER: -# Michał Górny <mgorny@gentoo.org> -# @SUPPORTED_EAPIS: 0 1 2 3 4 5 6 -# @BLURB: Smart .la file pruning -# @DEPRECATED: none -# @DESCRIPTION: -# A function to locate and remove unnecessary .la files. -# -# Discouraged. Whenever possible, please use much simpler: -# @CODE -# find "${ED}" -type f -name '*.la' -delete || die -# @CODE - -if [[ -z ${_LTPRUNE_ECLASS} ]]; then - -case ${EAPI:-0} in - 0|1|2|3|4|5|6) - ;; - *) - die "${ECLASS}: banned in EAPI=${EAPI}; use 'find' instead";; -esac - -inherit toolchain-funcs - -# @FUNCTION: prune_libtool_files -# @USAGE: [--all|--modules] -# @DESCRIPTION: -# Locate unnecessary libtool files (.la) and libtool static archives -# (.a) and remove them from installation image. -# -# By default, .la files are removed whenever the static linkage can -# either be performed using pkg-config or doesn't introduce additional -# flags. -# -# If '--modules' argument is passed, .la files for modules (plugins) are -# removed as well. This is usually useful when the package installs -# plugins and the plugin loader does not use .la files. -# -# If '--all' argument is passed, all .la files are removed without -# performing any heuristic on them. You shouldn't ever use that, -# and instead report a bug in the algorithm instead. -# -# The .a files are only removed whenever corresponding .la files state -# that they should not be linked to, i.e. whenever these files -# correspond to plugins. -# -# Note: if your package installs both static libraries and .pc files -# which use variable substitution for -l flags, you need to add -# pkg-config to your DEPEND. -prune_libtool_files() { - debug-print-function ${FUNCNAME} "$@" - - local removing_all removing_modules opt - for opt; do - case "${opt}" in - --all) - removing_all=1 - removing_modules=1 - ;; - --modules) - removing_modules=1 - ;; - *) - die "Invalid argument to ${FUNCNAME}(): ${opt}" - esac - done - - local f - local queue=() - while IFS= read -r -d '' f; do # for all .la files - local archivefile=${f/%.la/.a} - - # The following check is done by libtool itself. - # It helps us avoid removing random files which match '*.la', - # see bug #468380. - if ! sed -n -e '/^# Generated by .*libtool/q0;4q1' "${f}"; then - continue - fi - - [[ ${f} != ${archivefile} ]] || die 'regex sanity check failed' - local reason= pkgconfig_scanned= - local snotlink=$(sed -n -e 's:^shouldnotlink=::p' "${f}") - - if [[ ${snotlink} == yes ]]; then - - # Remove static libs we're not supposed to link against. - if [[ -f ${archivefile} ]]; then - einfo "Removing unnecessary ${archivefile#${D%/}} (static plugin)" - queue+=( "${archivefile}" ) - fi - - # The .la file may be used by a module loader, so avoid removing it - # unless explicitly requested. - if [[ ${removing_modules} ]]; then - reason='module' - fi - - else - - # Remove .la files when: - # - user explicitly wants us to remove all .la files, - # - respective static archive doesn't exist, - # - they are covered by a .pc file already, - # - they don't provide any new information (no libs & no flags). - - if [[ ${removing_all} ]]; then - reason='requested' - elif [[ ! -f ${archivefile} ]]; then - reason='no static archive' - elif [[ ! $(sed -nre \ - "s/^(dependency_libs|inherited_linker_flags)='(.*)'$/\2/p" \ - "${f}") ]]; then - reason='no libs & flags' - else - if [[ ! ${pkgconfig_scanned} ]]; then - # Create a list of all .pc-covered libs. - local pc_libs=() - if [[ ! ${removing_all} ]]; then - local pc - local tf=${T}/prune-lt-files.pc - local pkgconf=$(tc-getPKG_CONFIG) - - while IFS= read -r -d '' pc; do # for all .pc files - local arg libs - - # Use pkg-config if available (and works), - # fallback to sed. - if ${pkgconf} --exists "${pc}" &>/dev/null; then - sed -e '/^Requires:/d' "${pc}" > "${tf}" - libs=$(${pkgconf} --libs "${tf}") - else - libs=$(sed -ne 's/^Libs://p' "${pc}") - fi - - for arg in ${libs}; do - if [[ ${arg} == -l* ]]; then - if [[ ${arg} == '*$*' ]]; then - eerror "${FUNCNAME}: variable substitution likely failed in ${pc}" - eerror "(arg: ${arg})" - eerror "Most likely, you need to add virtual/pkgconfig to DEPEND." - die "${FUNCNAME}: unsubstituted variable found in .pc" - fi - - pc_libs+=( lib${arg#-l}.la ) - fi - done - done < <(find "${D}" -type f -name '*.pc' -print0) - - rm -f "${tf}" - fi - - pkgconfig_scanned=1 - fi # pkgconfig_scanned - - has "${f##*/}" "${pc_libs[@]}" && reason='covered by .pc' - fi # removal due to .pc - - fi # shouldnotlink==no - - if [[ ${reason} ]]; then - einfo "Removing unnecessary ${f#${D%/}} (${reason})" - queue+=( "${f}" ) - fi - done < <(find "${D}" -xtype f -name '*.la' -print0) - - if [[ ${queue[@]} ]]; then - rm -f "${queue[@]}" - fi -} - -_LTPRUNE_ECLASS=1 -fi #_LTPRUNE_ECLASS diff --git a/eclass/lua-single.eclass b/eclass/lua-single.eclass index 8432df0583bb..ad7075955153 100644 --- a/eclass/lua-single.eclass +++ b/eclass/lua-single.eclass @@ -1,10 +1,9 @@ -# Copyright 1999-2023 Gentoo Authors +# Copyright 1999-2024 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 # @ECLASS: lua-single.eclass # @MAINTAINER: # William Hubbs <williamh@gentoo.org> -# Marek Szuba <marecki@gentoo.org> # @AUTHOR: # Marek Szuba <marecki@gentoo.org> # Based on python-single-r1.eclass by Michał Górny <mgorny@gentoo.org> et al. diff --git a/eclass/lua-utils.eclass b/eclass/lua-utils.eclass index 0ff36734dc8f..7272f80d0370 100644 --- a/eclass/lua-utils.eclass +++ b/eclass/lua-utils.eclass @@ -1,10 +1,9 @@ -# Copyright 1999-2023 Gentoo Authors +# Copyright 1999-2024 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 # @ECLASS: lua-utils.eclass # @MAINTAINER: # William Hubbs <williamh@gentoo.org> -# Marek Szuba <marecki@gentoo.org> # @AUTHOR: # Marek Szuba <marecki@gentoo.org> # Based on python-utils-r1.eclass by Michał Górny <mgorny@gentoo.org> et al. @@ -144,18 +143,18 @@ _lua_wrapper_setup() { _lua_export "${impl}" ELUA LUA # Lua interpreter - ln -s "${EPREFIX}"/usr/bin/${ELUA} "${workdir}"/bin/lua || die + ln -s "${LUA}" "${workdir}"/bin/lua || die # Lua compiler, or a stub for it in case of luajit if [[ ${ELUA} == luajit ]]; then # Just in case - ln -s "${EPREFIX}"/bin/true "${workdir}"/bin/luac || die + ln -s "${BROOT}"/bin/true "${workdir}"/bin/luac || die else - ln -s "${EPREFIX}"/usr/bin/${ELUA/a/ac} "${workdir}"/bin/luac || die + ln -s "${BROOT}"/usr/bin/${ELUA/a/ac} "${workdir}"/bin/luac || die fi # pkg-config - ln -s "${EPREFIX}"/usr/$(get_libdir)/pkgconfig/${ELUA}.pc \ + ln -s "${ESYSROOT}"/usr/$(get_libdir)/pkgconfig/${ELUA}.pc \ "${workdir}"/pkgconfig/lua.pc || die fi @@ -264,7 +263,7 @@ _lua_export() { debug-print "${FUNCNAME}: ELUA = ${ELUA}" ;; LUA) - export LUA="${EPREFIX}"/usr/bin/${impl} + export LUA="${BROOT}"/usr/bin/${impl} debug-print "${FUNCNAME}: LUA = ${LUA}" ;; LUA_CFLAGS) diff --git a/eclass/lua.eclass b/eclass/lua.eclass index bb2e41ef1061..380ec274167c 100644 --- a/eclass/lua.eclass +++ b/eclass/lua.eclass @@ -1,10 +1,9 @@ -# Copyright 1999-2023 Gentoo Authors +# Copyright 1999-2024 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 # @ECLASS: lua.eclass # @MAINTAINER: # William Hubbs <williamh@gentoo.org> -# Marek Szuba <marecki@gentoo.org> # @AUTHOR: # Marek Szuba <marecki@gentoo.org> # Based on python-r1.eclass by Michał Górny <mgorny@gentoo.org> et al. diff --git a/eclass/meson.eclass b/eclass/meson.eclass index a22a85887584..a2bc5537e458 100644 --- a/eclass/meson.eclass +++ b/eclass/meson.eclass @@ -440,23 +440,11 @@ meson_src_compile() { pushd "${BUILD_DIR}" > /dev/null || die - local mesoncompileargs=( - --jobs "$(get_makeopts_jobs 0)" - --load-average "$(get_makeopts_loadavg 0)" - ) - case ${MESON_VERBOSE} in - OFF) ;; - *) mesoncompileargs+=( --verbose ) ;; + OFF) NINJA_VERBOSE=OFF eninja "$@" ;; + *) eninja "$@" ;; esac - - mesoncompileargs+=( "$@" ) - - set -- meson compile "${mesoncompileargs[@]}" - echo "$@" >&2 - "$@" local rv=$? - [[ ${rv} -eq 0 ]] || die -n "compile failed" popd > /dev/null || die return ${rv} diff --git a/eclass/mono-env.eclass b/eclass/mono-env.eclass index 48712587ff3e..02bd7e8dd9be 100644 --- a/eclass/mono-env.eclass +++ b/eclass/mono-env.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: mono-env.eclass @@ -9,14 +9,18 @@ # @DESCRIPTION: # Set environment variables commonly used by dotnet packages. +if [[ -z ${_MONO_ENV_ECLASS} ]] ; then +_MONO_ENV_ECLASS=1 + case ${EAPI} in - 6|7) ;; + 6) + ewarn "${CATEGORY}/${PF}: ebuild uses ${ECLASS} with deprecated EAPI ${EAPI}!" + ewarn "${CATEGORY}/${PF}: Support will be removed on 2024-10-08. Please port to newer EAPI." + ;; + 7|8) ;; *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; esac -if [[ -z ${_MONO_ENV_ECLASS} ]] ; then -_MONO_ENV_ECLASS=1 - SRC_URI="http://download.mono-project.com/sources/${PN}/${P}.tar.bz2" mono-env_pkg_setup() { diff --git a/eclass/mount-boot-utils.eclass b/eclass/mount-boot-utils.eclass new file mode 100644 index 000000000000..e24b4e0c0826 --- /dev/null +++ b/eclass/mount-boot-utils.eclass @@ -0,0 +1,109 @@ +# Copyright 1999-2024 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +# @ECLASS: mount-boot-utils.eclass +# @MAINTAINER: +# base-system@gentoo.org +# @SUPPORTED_EAPIS: 7 8 +# @BLURB: functions for packages that install files into /boot or the ESP +# @DESCRIPTION: +# This eclass is really only useful for bootloaders and kernel installation. +# +# If the live system has a separate /boot partition or ESP configured, then this +# function tries to ensure that it's mounted in rw mode, exiting with an error +# if it can't. It does nothing if /boot and ESP isn't a separate partition. +# +# This eclass provides the functions used by mount-boot.eclass in an "inherit- +# safe" way. This allows these functions to be used in other eclasses cleanly. + +case ${EAPI} in + 7|8) ;; + *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; +esac + +# @FUNCTION: mount-boot_is_disabled +# @INTERNAL +# @DESCRIPTION: +# Detect whether the current environment/build settings are such that we do not +# want to mess with any mounts. +mount-boot_is_disabled() { + # Since this eclass only deals with /boot, skip things when EROOT is active. + if [[ -n ${EROOT} ]]; then + return 0 + fi + + # If we're only building a package, then there's no need to check things. + if [[ ${MERGE_TYPE} == buildonly ]]; then + return 0 + fi + + # The user wants us to leave things be. + if [[ -n ${DONT_MOUNT_BOOT} ]]; then + return 0 + fi + + # OK, we want to handle things ourselves. + return 1 +} + +# @FUNCTION: mount-boot_check_status +# @INTERNAL +# @DESCRIPTION: +# Check if /boot and ESP is sane, i.e., mounted as read-write if on a separate +# partition. Die if conditions are not fulfilled. If nonfatal is used, +# the function will return a non-zero status instead. +mount-boot_check_status() { + # Get out fast if possible. + mount-boot_is_disabled && return 0 + + local partition= + local part_is_not_mounted= + local part_is_read_only= + local candidates=( /boot ) + + # If system is booted with UEFI, check for ESP as well + if [[ -d /sys/firmware/efi ]]; then + # Use same candidates for ESP as installkernel and eclean-kernel + candidates+=( /efi /boot/efi /boot/EFI ) + fi + + for partition in ${candidates[@]}; do + # note that /dev/BOOT is in the Gentoo default /etc/fstab file + local fstabstate=$(awk "!/^[[:blank:]]*#|^\/dev\/BOOT/ && \$2 == \"${partition}\" \ + { print 1; exit }" /etc/fstab || die "awk failed") + + if [[ -z ${fstabstate} ]]; then + einfo "Assuming you do not have a separate ${partition} partition." + else + local procstate=$(awk "\$2 == \"${partition}\" { split(\$4, a, \",\"); \ + for (i in a) if (a[i] ~ /^r[ow]\$/) { print a[i]; break }; exit }" \ + /proc/mounts || die "awk failed") + + if [[ -z ${procstate} ]]; then + eerror "Your ${partition} partition is not mounted" + eerror "Please mount it and retry." + die -n "${partition} not mounted" + part_is_not_mounted=1 + else + if [[ ${procstate} == ro ]]; then + eerror "Your ${partition} partition, was detected as being mounted," \ + "but is mounted read-only." + eerror "Please remount it as read-write and retry." + die -n "${partition} mounted read-only" + part_is_read_only=1 + else + einfo "Your ${partition} partition was detected as being mounted." + einfo "Files will be installed there for ${PN} to function correctly." + fi + fi + fi + done + + if [[ -n ${part_is_not_mounted} ]]; then + return 1 + elif [[ -n ${part_is_read_only} ]]; then + return 2 + else + return 0 + fi +} diff --git a/eclass/mount-boot.eclass b/eclass/mount-boot.eclass index 73beb9adea67..ce17026ffd2b 100644 --- a/eclass/mount-boot.eclass +++ b/eclass/mount-boot.eclass @@ -1,90 +1,27 @@ -# Copyright 1999-2023 Gentoo Authors +# Copyright 1999-2024 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 # @ECLASS: mount-boot.eclass # @MAINTAINER: # base-system@gentoo.org -# @SUPPORTED_EAPIS: 6 7 8 -# @BLURB: functions for packages that install files into /boot +# @SUPPORTED_EAPIS: 7 8 +# @BLURB: eclass for packages that install files into /boot or the ESP # @DESCRIPTION: -# This eclass is really only useful for bootloaders. +# This eclass is really only useful for bootloaders and kernel installation. # -# If the live system has a separate /boot partition configured, then this -# function tries to ensure that it's mounted in rw mode, exiting with an -# error if it can't. It does nothing if /boot isn't a separate partition. +# If the live system has a separate /boot partition or ESP configured, then this +# function tries to ensure that it's mounted in rw mode, exiting with an error +# if it can't. It does nothing if /boot and ESP isn't a separate partition. +# +# This eclass exports the functions provided by mount-boot-utils.eclass to +# the pkg_pretend and pkg_{pre,post}{inst,rm} phases. case ${EAPI} in - 6|7|8) ;; + 7|8) ;; *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; esac -# @FUNCTION: mount-boot_is_disabled -# @INTERNAL -# @DESCRIPTION: -# Detect whether the current environment/build settings are such that we do not -# want to mess with any mounts. -mount-boot_is_disabled() { - # Since this eclass only deals with /boot, skip things when EROOT is active. - if [[ ${EROOT:-/} != / ]] ; then - return 0 - fi - - # If we're only building a package, then there's no need to check things. - if [[ ${MERGE_TYPE} == buildonly ]] ; then - return 0 - fi - - # The user wants us to leave things be. - if [[ -n ${DONT_MOUNT_BOOT} ]] ; then - return 0 - fi - - # OK, we want to handle things ourselves. - return 1 -} - -# @FUNCTION: mount-boot_check_status -# @INTERNAL -# @DESCRIPTION: -# Check if /boot is sane, i.e., mounted as read-write if on a separate -# partition. Die if conditions are not fulfilled. If nonfatal is used, -# the function will return a non-zero status instead. -mount-boot_check_status() { - # Get out fast if possible. - mount-boot_is_disabled && return 0 - - # note that /dev/BOOT is in the Gentoo default /etc/fstab file - local fstabstate=$(awk '!/^[[:blank:]]*#|^\/dev\/BOOT/ && $2 == "/boot" \ - { print 1; exit }' /etc/fstab || die "awk failed") - - if [[ -z ${fstabstate} ]] ; then - einfo "Assuming you do not have a separate /boot partition." - return 0 - fi - - local procstate=$(awk '$2 == "/boot" { split($4, a, ","); \ - for (i in a) if (a[i] ~ /^r[ow]$/) { print a[i]; break }; exit }' \ - /proc/mounts || die "awk failed") - - if [[ -z ${procstate} ]] ; then - eerror "Your boot partition is not mounted at /boot." - eerror "Please mount it and retry." - die -n "/boot not mounted" - return 1 - fi - - if [[ ${procstate} == ro ]] ; then - eerror "Your boot partition, detected as being mounted at /boot," \ - "is read-only." - eerror "Please remount it as read-write and retry." - die -n "/boot mounted read-only" - return 2 - fi - - einfo "Your boot partition was detected as being mounted at /boot." - einfo "Files will be installed there for ${PN} to function correctly." - return 0 -} +inherit mount-boot-utils mount-boot_pkg_pretend() { mount-boot_check_status diff --git a/eclass/mozcoreconf-v6.eclass b/eclass/mozcoreconf-v6.eclass index 71dbc6802d71..e7cf85fca24a 100644 --- a/eclass/mozcoreconf-v6.eclass +++ b/eclass/mozcoreconf-v6.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: mozcoreconf-v6.eclass @@ -157,7 +157,7 @@ mozconfig_init() { mozconfig_annotate "less than -O2 causes a segfault on x86" --enable-optimize=-O2 elif [[ ${ARCH} == arm ]] && [[ $(gcc-major-version) -ge 6 ]]; then mozconfig_annotate "less than -O2 causes a breakage on arm with gcc-6" --enable-optimize=-O2 - elif use custom-optimization || [[ ${ARCH} =~ (alpha|ia64) ]]; then + elif use custom-optimization || [[ ${ARCH} == alpha ]]; then # Set optimization level based on CFLAGS if is-flag -O0; then mozconfig_annotate "from CFLAGS" --enable-optimize=-O0 @@ -204,10 +204,6 @@ mozconfig_init() { # operation append-flags -fPIC -mieee ;; - ia64) - # Historically we have needed to add this manually for 64-bit - append-flags -fPIC - ;; esac # We need to append flags for gcc-6 support diff --git a/eclass/multibuild.eclass b/eclass/multibuild.eclass index f15d3327c7dd..0677ea346e4c 100644 --- a/eclass/multibuild.eclass +++ b/eclass/multibuild.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: multibuild.eclass @@ -13,17 +13,21 @@ # multiple 'variants' of a package (e.g. multilib, Python # implementations). +if [[ ! ${_MULTIBUILD_ECLASS} ]]; then +_MULTIBUILD_ECLASS=1 + case ${EAPI} in - 6|7|8) + 6) + ewarn "${CATEGORY}/${PF}: ebuild uses ${ECLASS} with deprecated EAPI ${EAPI}!" + ewarn "${CATEGORY}/${PF}: Support will be removed on 2024-10-08. Please port to newer EAPI." + ;; + 7|8) # backwards compatibility for run_in_build_dir inherit out-of-source-utils ;; *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; esac -if [[ ! ${_MULTIBUILD_ECLASS} ]]; then -_MULTIBUILD_ECLASS=1 - # @ECLASS_VARIABLE: MULTIBUILD_VARIANTS # @REQUIRED # @DESCRIPTION: diff --git a/eclass/multilib-build.eclass b/eclass/multilib-build.eclass index 1774ad057430..22c4a8bb3048 100644 --- a/eclass/multilib-build.eclass +++ b/eclass/multilib-build.eclass @@ -1,4 +1,4 @@ -# Copyright 2013-2023 Gentoo Authors +# Copyright 2013-2024 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 # @ECLASS: multilib-build.eclass @@ -17,14 +17,18 @@ # dependencies shall use the USE dependency string in ${MULTILIB_USEDEP} # to properly request multilib enabled. +if [[ -z ${_MULTILIB_BUILD_ECLASS} ]]; then +_MULTILIB_BUILD_ECLASS=1 + case ${EAPI} in - 6|7|8) ;; + 6) + ewarn "${CATEGORY}/${PF}: ebuild uses ${ECLASS} with deprecated EAPI ${EAPI}!" + ewarn "${CATEGORY}/${PF}: Support will be removed on 2024-10-08. Please port to newer EAPI." + ;; + 7|8) ;; *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; esac -if [[ -z ${_MULTILIB_BUILD_ECLASS} ]]; then -_MULTILIB_BUILD_ECLASS=1 - inherit multibuild multilib # @ECLASS_VARIABLE: _MULTILIB_FLAGS diff --git a/eclass/multilib-minimal.eclass b/eclass/multilib-minimal.eclass index 92968b6cf213..c84fb3781a97 100644 --- a/eclass/multilib-minimal.eclass +++ b/eclass/multilib-minimal.eclass @@ -1,4 +1,4 @@ -# Copyright 1999-2022 Gentoo Authors +# Copyright 1999-2024 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 # @ECLASS: multilib-minimal.eclass @@ -23,16 +23,21 @@ # # If you need generic install rules, use multilib_src_install_all function. -case ${EAPI} in - 6|7|8) ;; - *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; -esac - inherit multilib-build if [[ ! ${_MULTILIB_MINIMAL_ECLASS} ]]; then _MULTILIB_MINIMAL_ECLASS=1 +case ${EAPI} in + 6) + ewarn "${CATEGORY}/${PF}: ebuild uses ${ECLASS} with deprecated EAPI ${EAPI}!" + ewarn "${CATEGORY}/${PF}: Support will be removed on 2024-10-08. Please port to newer EAPI." + ;; + 7|8) ;; + *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; +esac + + multilib-minimal_src_configure() { debug-print-function ${FUNCNAME} "$@" diff --git a/eclass/multilib.eclass b/eclass/multilib.eclass index bf9c88f7e6a4..eca8c02d8336 100644 --- a/eclass/multilib.eclass +++ b/eclass/multilib.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: multilib.eclass @@ -9,14 +9,18 @@ # @DESCRIPTION: # This eclass is for all functions pertaining to handling multilib configurations. +if [[ -z ${_MULTILIB_ECLASS} ]]; then +_MULTILIB_ECLASS=1 + case ${EAPI} in - 6|7|8) ;; + 6) + ewarn "${CATEGORY}/${PF}: ebuild uses ${ECLASS} with deprecated EAPI ${EAPI}!" + ewarn "${CATEGORY}/${PF}: Support will be removed on 2024-10-08. Please port to newer EAPI." + ;; + 7|8) ;; *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; esac -if [[ -z ${_MULTILIB_ECLASS} ]]; then -_MULTILIB_ECLASS=1 - inherit toolchain-funcs # Defaults: diff --git a/eclass/multiprocessing.eclass b/eclass/multiprocessing.eclass index 13d6a92f2f2e..f9627de26c3b 100644 --- a/eclass/multiprocessing.eclass +++ b/eclass/multiprocessing.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: multiprocessing.eclass @@ -24,14 +24,18 @@ # } # @CODE -case ${EAPI:-0} in - [5678]) ;; - *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; -esac - if [[ -z ${_MULTIPROCESSING_ECLASS} ]]; then _MULTIPROCESSING_ECLASS=1 +case ${EAPI} in + 5|6) + ewarn "${CATEGORY}/${PF}: ebuild uses ${ECLASS} with deprecated EAPI ${EAPI}!" + ewarn "${CATEGORY}/${PF}: Support will be removed on 2024-10-08. Please port to newer EAPI." + ;; + 7|8) ;; + *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; +esac + # @FUNCTION: get_nproc # @USAGE: [${fallback:-1}] # @DESCRIPTION: diff --git a/eclass/out-of-source-utils.eclass b/eclass/out-of-source-utils.eclass index d68b21088995..55a88127ca71 100644 --- a/eclass/out-of-source-utils.eclass +++ b/eclass/out-of-source-utils.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: out-of-source-utils.eclass @@ -12,14 +12,18 @@ # This eclass provides a run_in_build_dir() helper that can be used # to execute specified command inside BUILD_DIR. +if [[ ! ${_OUT_OF_SOURCE_UTILS_ECLASS} ]]; then +_OUT_OF_SOURCE_UTILS_ECLASS=1 + case ${EAPI} in - 6|7|8) ;; + 6) + ewarn "${CATEGORY}/${PF}: ebuild uses ${ECLASS} with deprecated EAPI ${EAPI}!" + ewarn "${CATEGORY}/${PF}: Support will be removed on 2024-10-08. Please port to newer EAPI." + ;; + 7|8) ;; *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; esac -if [[ ! ${_OUT_OF_SOURCE_UTILS_ECLASS} ]]; then -_OUT_OF_SOURCE_UTILS_ECLASS=1 - # @FUNCTION: run_in_build_dir # @USAGE: <argv>... # @DESCRIPTION: diff --git a/eclass/pax-utils.eclass b/eclass/pax-utils.eclass index 3830f03df341..a7144278fd9a 100644 --- a/eclass/pax-utils.eclass +++ b/eclass/pax-utils.eclass @@ -1,4 +1,4 @@ -# Copyright 1999-2021 Gentoo Authors +# Copyright 1999-2024 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 # @ECLASS: pax-utils.eclass @@ -21,14 +21,18 @@ # To control what markings are made, set PAX_MARKINGS in /etc/portage/make.conf # to contain either "PT", "XT" or "none". The default is none -case ${EAPI:-0} in - 5|6|7|8) ;; - *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; -esac - if [[ -z ${_PAX_UTILS_ECLASS} ]]; then _PAX_UTILS_ECLASS=1 +case ${EAPI} in + 5|6) + ewarn "${CATEGORY}/${PF}: ebuild uses ${ECLASS} with deprecated EAPI ${EAPI}!" + ewarn "${CATEGORY}/${PF}: Support will be removed on 2024-10-08. Please port to newer EAPI." + ;; + 7|8) ;; + *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; +esac + # @ECLASS_VARIABLE: PAX_MARKINGS # @DESCRIPTION: # Control which markings are made: diff --git a/eclass/perl-functions.eclass b/eclass/perl-functions.eclass index 142fdeb8cfbd..d2b6cfb85f73 100644 --- a/eclass/perl-functions.eclass +++ b/eclass/perl-functions.eclass @@ -1,4 +1,4 @@ -# Copyright 1999-2022 Gentoo Authors +# Copyright 1999-2024 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 # @ECLASS: perl-functions.eclass @@ -17,11 +17,12 @@ # global scope. case ${EAPI} in - 7|8) - ;; - *) - die "${ECLASS}: EAPI ${EAPI:-0} not supported" + 6) + ewarn "${CATEGORY}/${PF}: ebuild uses ${ECLASS} with deprecated EAPI ${EAPI}!" + ewarn "${CATEGORY}/${PF}: Support will be removed on 2024-10-08. Please port to newer EAPI." ;; + 7|8) ;; + *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; esac [[ ${CATEGORY} == "perl-core" ]] && inherit alternatives diff --git a/eclass/perl-module.eclass b/eclass/perl-module.eclass index f32c2c237d05..27cd053f0ea7 100644 --- a/eclass/perl-module.eclass +++ b/eclass/perl-module.eclass @@ -63,7 +63,7 @@ esac # @CODE PERL_USEDEP="perl_features_debug=,perl_features_ithreads=,perl_features_quadmath=" -GENTOO_PERL_DEPSTRING=" || ( >=dev-lang/perl-5.38.2-r3[${PERL_USEDEP}] <dev-lang/perl-5.38.2-r3 )" +GENTOO_PERL_DEPSTRING=">=dev-lang/perl-5.38.2-r3[${PERL_USEDEP}]" GENTOO_PERL_USESTRING="perl_features_debug perl_features_ithreads perl_features_quadmath" case ${EAPI} in @@ -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/php-pear-r2.eclass b/eclass/php-pear-r2.eclass index 9882c7dcc700..567aa9a8144f 100644 --- a/eclass/php-pear-r2.eclass +++ b/eclass/php-pear-r2.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: php-pear-r2.eclass @@ -14,14 +14,18 @@ # Note that this eclass doesn't handle dependencies of PEAR packages # on purpose; please use (R)DEPEND to define them correctly! +if [[ -z ${_PHP_PEAR_R2_ECLASS} ]]; then +_PHP_PEAR_R2_ECLASS=1 + case ${EAPI} in - 6|7|8) ;; + 6) + ewarn "${CATEGORY}/${PF}: ebuild uses ${ECLASS} with deprecated EAPI ${EAPI}!" + ewarn "${CATEGORY}/${PF}: Support will be removed on 2024-10-08. Please port to newer EAPI." + ;; + 7|8) ;; *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; esac -if [[ -z ${_PHP_PEAR_R2_ECLASS} ]]; then -_PHP_PEAR_R2_ECLASS=1 - RDEPEND=">=dev-php/pear-1.8.1" [[ ${EAPI} != [67] ]] && IDEPEND=">=dev-php/pear-1.8.1" diff --git a/eclass/plasma-mobile.kde.org.eclass b/eclass/plasma-mobile.kde.org.eclass index 9fd54100d24e..3349f90745bd 100644 --- a/eclass/plasma-mobile.kde.org.eclass +++ b/eclass/plasma-mobile.kde.org.eclass @@ -1,6 +1,7 @@ # Copyright 1999-2023 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 +# @DEAD # @ECLASS: plasma-mobile.kde.org.eclass # @MAINTAINER: # kde@gentoo.org 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/portability.eclass b/eclass/portability.eclass index 78da440e22dd..926ac8b8b825 100644 --- a/eclass/portability.eclass +++ b/eclass/portability.eclass @@ -9,14 +9,18 @@ # @SUPPORTED_EAPIS: 6 7 8 # @BLURB: This eclass is created to avoid using non-portable GNUisms inside ebuilds +if [[ -z ${_PORTABILITY_ECLASS} ]]; then +_PORTABILITY_ECLASS=1 + case ${EAPI} in - 6|7|8) ;; + 6) + ewarn "${CATEGORY}/${PF}: ebuild uses ${ECLASS} with deprecated EAPI ${EAPI}!" + ewarn "${CATEGORY}/${PF}: Support will be removed on 2024-10-08. Please port to newer EAPI." + ;; + 7|8) ;; *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; esac -if [[ -z ${_PORTABILITY_ECLASS} ]]; then -_PORTABILITY_ECLASS=1 - # @FUNCTION: treecopy # @USAGE: <orig1> [orig2 orig3 ....] <dest> # @DESCRIPTION: diff --git a/eclass/postgres-multi.eclass b/eclass/postgres-multi.eclass index d93df851cd24..92299b8cf34c 100644 --- a/eclass/postgres-multi.eclass +++ b/eclass/postgres-multi.eclass @@ -1,4 +1,4 @@ -# Copyright 1999-2022 Gentoo Authors +# Copyright 1999-2024 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 # @ECLASS: postgres-multi.eclass @@ -6,7 +6,7 @@ # PostgreSQL <pgsql-bugs@gentoo.org> # @AUTHOR: # Aaron W. Swenson <titanofold@gentoo.org> -# @SUPPORTED_EAPIS: 7 +# @SUPPORTED_EAPIS: 7 8 # @PROVIDES: multibuild postgres # @BLURB: An eclass to build PostgreSQL-related packages against multiple slots # @DESCRIPTION: @@ -15,7 +15,7 @@ # POSTGRES_TARGETS use flags. case ${EAPI} in - 7) ;; + 7|8) ;; *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; esac diff --git a/eclass/prefix.eclass b/eclass/prefix.eclass index 8d50d0ba7b6e..e968e8ae8bac 100644 --- a/eclass/prefix.eclass +++ b/eclass/prefix.eclass @@ -1,4 +1,4 @@ -# Copyright 1999-2021 Gentoo Authors +# Copyright 1999-2024 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 # @ECLASS: prefix.eclass @@ -12,14 +12,18 @@ # located somewhere in the filesystem. Prefix ebuilds require # additional functions and variables which are defined by this eclass. -case ${EAPI:-0} in - [5678]) ;; - *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; -esac - if [[ -z ${_PREFIX_ECLASS} ]]; then _PREFIX_ECLASS=1 +case ${EAPI} in + 5|6) + ewarn "${CATEGORY}/${PF}: ebuild uses ${ECLASS} with deprecated EAPI ${EAPI}!" + ewarn "${CATEGORY}/${PF}: Support will be removed on 2024-10-08. Please port to newer EAPI." + ;; + 7|8) ;; + *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; +esac + # @ECLASS_VARIABLE: EPREFIX # @DESCRIPTION: # The offset prefix of a Gentoo Prefix installation. When Gentoo Prefix diff --git a/eclass/preserve-libs.eclass b/eclass/preserve-libs.eclass index 35c65ef4436f..38571447b945 100644 --- a/eclass/preserve-libs.eclass +++ b/eclass/preserve-libs.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: preserve-libs.eclass @@ -7,14 +7,18 @@ # @SUPPORTED_EAPIS: 5 6 7 8 # @BLURB: preserve libraries after SONAME changes +if [[ -z ${_PRESERVE_LIBS_ECLASS} ]]; then +_PRESERVE_LIBS_ECLASS=1 + case ${EAPI} in - 5|6|7|8) ;; + 5|6) + ewarn "${CATEGORY}/${PF}: ebuild uses ${ECLASS} with deprecated EAPI ${EAPI}!" + ewarn "${CATEGORY}/${PF}: Support will be removed on 2024-10-08. Please port to newer EAPI." + ;; + 7|8) ;; *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; esac -if [[ -z ${_PRESERVE_LIBS_ECLASS} ]]; then -_PRESERVE_LIBS_ECLASS=1 - # @FUNCTION: preserve_old_lib # @USAGE: <libs to preserve> [more libs] # @DESCRIPTION: diff --git a/eclass/python-any-r1.eclass b/eclass/python-any-r1.eclass index a21df8e89498..c1f27cfbac0d 100644 --- a/eclass/python-any-r1.eclass +++ b/eclass/python-any-r1.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: python-any-r1.eclass @@ -272,6 +272,7 @@ python_gen_any_dep() { # This function will call python_check_deps() if defined. python_setup() { debug-print-function ${FUNCNAME} "${@}" + _python_sanity_checks # support developer override if [[ ${PYTHON_COMPAT_OVERRIDE} ]]; then diff --git a/eclass/python-r1.eclass b/eclass/python-r1.eclass index fbc6082a1d92..adf87c2c52f7 100644 --- a/eclass/python-r1.eclass +++ b/eclass/python-r1.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: python-r1.eclass @@ -594,6 +594,8 @@ _python_multibuild_wrapper() { local -x EPYTHON PYTHON local -x PATH=${PATH} PKG_CONFIG_PATH=${PKG_CONFIG_PATH} + local PYTHON_USEDEP="python_targets_${MULTIBUILD_VARIANT}(-)" + local PYTHON_SINGLE_USEDEP="python_single_target_${MULTIBUILD_VARIANT}(-)" _python_export "${MULTIBUILD_VARIANT}" EPYTHON PYTHON _python_wrapper_setup @@ -615,6 +617,7 @@ _python_multibuild_wrapper() { # locally, and the former two are exported to the command environment. python_foreach_impl() { debug-print-function ${FUNCNAME} "${@}" + _python_sanity_checks if [[ ${_DISTUTILS_R1_ECLASS} ]]; then if has "${EBUILD_PHASE}" prepare configure compile test install && @@ -706,6 +709,7 @@ python_foreach_impl() { # @CODE python_setup() { debug-print-function ${FUNCNAME} "${@}" + _python_sanity_checks local has_check_deps declare -f python_check_deps >/dev/null && has_check_deps=1 diff --git a/eclass/python-single-r1.eclass b/eclass/python-single-r1.eclass index 4d61f08c06f0..481b6cf91ba0 100644 --- a/eclass/python-single-r1.eclass +++ b/eclass/python-single-r1.eclass @@ -1,4 +1,4 @@ -# Copyright 1999-2022 Gentoo Authors +# Copyright 1999-2024 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 # @ECLASS: python-single-r1.eclass @@ -393,6 +393,7 @@ python_gen_impl_dep() { # the Python build environment up for it. python_setup() { debug-print-function ${FUNCNAME} "${@}" + _python_sanity_checks unset EPYTHON diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass index c47565fa1db2..45d3da6bb98c 100644 --- a/eclass/python-utils-r1.eclass +++ b/eclass/python-utils-r1.eclass @@ -332,6 +332,17 @@ _python_export() { export PYTHON=${BROOT-${EPREFIX}}/usr/bin/${impl} debug-print "${FUNCNAME}: PYTHON = ${PYTHON}" ;; + PYTHON_STDLIB) + [[ -n ${PYTHON} ]] || die "PYTHON needs to be set for ${var} to be exported, or requested before it" + PYTHON_STDLIB=$( + "${PYTHON}" - "${EPREFIX}/usr" <<-EOF || die + import sys, sysconfig + print(sysconfig.get_path("stdlib", vars={"installed_base": sys.argv[1]})) + EOF + ) + export PYTHON_STDLIB + debug-print "${FUNCNAME}: PYTHON_STDLIB = ${PYTHON_STDLIB}" + ;; PYTHON_SITEDIR) [[ -n ${PYTHON} ]] || die "PYTHON needs to be set for ${var} to be exported, or requested before it" PYTHON_SITEDIR=$( @@ -466,6 +477,18 @@ _python_export() { done } +# @FUNCTION: python_get_stdlib +# @USAGE: [<impl>] +# @DESCRIPTION: +# Obtain and print the 'stdlib' path for the given implementation. If no +# implementation is provided, ${EPYTHON} will be used. +python_get_stdlib() { + debug-print-function ${FUNCNAME} "${@}" + + _python_export "${@}" PYTHON_STDLIB + echo "${PYTHON_STDLIB}" +} + # @FUNCTION: python_get_sitedir # @USAGE: [<impl>] # @DESCRIPTION: @@ -1544,4 +1567,38 @@ python_has_version() { return 0 } +# @FUNCTION: _python_sanity_checks +# @INTERNAL +# @DESCRIPTION: +# Perform additional environment sanity checks. +_python_sanity_checks() { + debug-print-function ${FUNCNAME} "${@}" + + [[ ${_PYTHON_SANITY_CHECKED} ]] && return + + if [[ -v PYTHONPATH ]]; then + local x paths=() + mapfile -d ':' -t paths <<<${PYTHONPATH} + + for x in "${paths[@]}"; do + if [[ ${x} != /* ]]; then + eerror "Relative path found in PYTHONPATH:" + eerror + eerror " PYTHONPATH=${PYTHONPATH@Q}" + eerror + eerror "This is guaranteed to cause random breakage. Please make sure that" + eerror "your PYTHONPATH contains absolute paths only (and only if necessary)." + eerror "Note that empty values (including ':' at either end and an empty" + eerror "PYTHONPATH) count as the current directory. If no PYTHONPATH" + eerror "is intended, it needs to be unset instead." + die "Relative paths in PYTHONPATH are forbidden: ${x@Q}" + fi + done + + elog "PYTHONPATH=${PYTHONPATH@Q}" + fi + + _PYTHON_SANITY_CHECKED=1 +} + fi diff --git a/eclass/qt5-build.eclass b/eclass/qt5-build.eclass index 76a089b2908d..1a0335b9d2b6 100644 --- a/eclass/qt5-build.eclass +++ b/eclass/qt5-build.eclass @@ -126,11 +126,11 @@ fi if [[ ${QT5_MODULE} == qtbase ]]; then case ${PV} in - 5.15.11) - _QT5_GENTOOPATCHSET_REV=4 + 5.15.13) + _QT5_GENTOOPATCHSET_REV=5 ;; *) - _QT5_GENTOOPATCHSET_REV=5 + _QT5_GENTOOPATCHSET_REV=6 ;; esac SRC_URI+=" https://dev.gentoo.org/~asturm/distfiles/qtbase-5.15-gentoo-patchset-${_QT5_GENTOOPATCHSET_REV}.tar.xz" @@ -623,6 +623,9 @@ qt5_base_configure() { $(is-flagq -mno-dsp && echo -no-mips_dsp) $(is-flagq -mno-dspr2 && echo -no-mips_dspr2) + # bug #773199 and friends + $(tc-cpp-is-true "defined(__SSE2__)" ${CFLAGS} ${CXXFLAGS} || echo -no-feature-sse2) + # use pkg-config to detect include and library paths -pkg-config diff --git a/eclass/qt6-build.eclass b/eclass/qt6-build.eclass index 4fc838c478af..3cd8b606c235 100644 --- a/eclass/qt6-build.eclass +++ b/eclass/qt6-build.eclass @@ -122,7 +122,7 @@ qt6-build_src_prepare() { fi _qt6-build_prepare_env - _qt6-build_match_cpu_flags + _qt6-build_sanitize_cpu_flags # LTO cause test failures in several components (e.g. qtcharts, # multimedia, scxml, wayland, webchannel, ...). @@ -147,6 +147,9 @@ qt6-build_src_configure() { fi local defaultcmakeargs=( + # cmake defaults to "STATUS" but Qt changes that to "NOTICE" which + # hides a lot of information that is useful for bug reports + --log-level=STATUS # see _qt6-build_create_user_facing_links -DINSTALL_PUBLICBINDIR="${QT6_PREFIX}"/bin # note that if qtbase was built with tests, this is default ON @@ -235,34 +238,6 @@ _qt6-build_create_user_facing_links() { done < "${BUILD_DIR}"/user_facing_tool_links.txt || die } -# @FUNCTION: _qt6-build_match_cpu_flags -# @INTERNAL -# @DESCRIPTION: -# Try to adjust -m* cpu CXXFLAGS so that they match a configuration -# accepted by Qt's headers, see bug #908420. -_qt6-build_match_cpu_flags() { - use amd64 || use x86 || return 0 - - local flags=() intrin intrins - while IFS=' ' read -ra intrins; do - [[ ${intrins[*]} == *=[^_]* && ${intrins[*]} == *=_* ]] && - for intrin in "${intrins[@]%=*}"; do - [[ ${intrin} ]] && flags+=( -mno-${intrin} ) - done - done < <( - $(tc-getCXX) -E -P ${CXXFLAGS} ${CPPFLAGS} - <<-EOF | tail -n 2 - avx2=__AVX2__ =__BMI__ =__BMI2__ =__F16C__ =__FMA__ =__LZCNT__ =__POPCNT__ - avx512f=__AVX512F__ avx512bw=__AVX512BW__ avx512cd=__AVX512CD__ avx512dq=__AVX512DQ__ avx512vl=__AVX512VL__ - EOF - assert - ) - - if (( ${#flags[@]} )); then - einfo "Adjusting CXXFLAGS for https://bugs.gentoo.org/908420 with: ${flags[*]}" - append-cxxflags "${flags[@]}" - fi -} - # @FUNCTION: _qt6-build_prepare_env # @INTERNAL # @DESCRIPTION: @@ -289,6 +264,74 @@ _qt6-build_prepare_env() { readonly QT6_TRANSLATIONDIR=${QT6_DATADIR}/translations } +# @FUNCTION: _qt6-build_sanitize_cpu_flags +# @INTERNAL +# @DESCRIPTION: +# Qt hardly support use of -mno-* or -march=native for unusual CPUs +# (or VMs) that support incomplete x86-64 feature levels, and attempts +# to allow this anyway has worked poorly. This instead tries to detect +# unusual configurations and fallbacks to generic -march=x86-64* if so +# (bug #898644,#908420,#913400,#933374). +_qt6-build_sanitize_cpu_flags() { + # less of an issue with non-amd64, will revisit only if needed + use amd64 || return 0 + + local cpuflags=( + # list of checked cpu features by qtbase in configure.cmake + aes avx avx2 avx512{bw,cd,dq,er,f,ifma,pf,vbmi,vbmi2,vl} + f16c rdrnd rdseed sha sse2 sse3 sse4_1 sse4_2 ssse3 vaes + + # extras checked by qtbase's qsimd_p.h + bmi bmi2 f16c fma lzcnt popcnt + ) + + # extras only needed by chromium in qtwebengine + # (see also chromium's ebuild wrt bug #530248,#544702,#546984,#853646) + [[ ${PN} == qtwebengine ]] && cpuflags+=( + mmx xop + + # unclear if these two are really needed given (current) chromium + # does not pass these flags, albeit it may side-disable something + # else so keeping as a safety (like chromium's ebuild does) + fma4 sse4a + ) + + # check if any known problematic -mno-* C(XX)FLAGS + if ! is-flagq "@($(IFS='|'; echo "${cpuflags[*]/#/-mno-}"))"; then + # check if qsimd_p.h (search for "enable all") will accept -march + : "$($(tc-getCXX) -E -P ${CXXFLAGS} ${CPPFLAGS} - <<-EOF | tail -n 1 + #if (defined(__AVX2__) && (__BMI__ + __BMI2__ + __F16C__ + __FMA__ + __LZCNT__ + __POPCNT__) != 6) || \ + (defined(__AVX512F__) && (__AVX512BW__ + __AVX512CD__ + __AVX512DQ__ + __AVX512VL__) != 4) + bad + #endif + EOF + assert + )" + [[ ${_} == bad ]] || return 0 # *should* be fine as-is + fi + + # determine highest(known) usable x86-64 feature level + local march=$( + $(tc-getCXX) -E -P ${CXXFLAGS} ${CPPFLAGS} - <<-EOF | tail -n 1 + default + #if (__CRC32__ + __LAHF_SAHF__ + __POPCNT__ + __SSE3__ + __SSE4_1__ + __SSE4_2__ + __SSSE3__) == 7 + x86-64-v2 + # if (__AVX__ + __AVX2__ + __BMI__ + __BMI2__ + __F16C__ + __FMA__ + __LZCNT__ + __MOVBE__ + __XSAVE__) == 9 + x86-64-v3 + # if (__AVX512BW__ + __AVX512CD__ + __AVX512DQ__ + __AVX512F__ + __AVX512VL__ + __EVEX256__ + __EVEX512__) == 7 + x86-64-v4 + # endif + # endif + #endif + EOF + assert + ) + + filter-flags '-march=*' "${cpuflags[@]/#/-m}" "${cpuflags[@]/#/-mno-}" + [[ ${march} == x86-64* ]] && append-flags $(test-flags-CXX -march=${march}) + einfo "C(XX)FLAGS were adjusted due to Qt limitations: ${CXXFLAGS}" +} + fi EXPORT_FUNCTIONS src_unpack src_prepare src_configure src_test src_install diff --git a/eclass/readme.gentoo-r1.eclass b/eclass/readme.gentoo-r1.eclass index 202ba31f4f70..3d2d8244687c 100644 --- a/eclass/readme.gentoo-r1.eclass +++ b/eclass/readme.gentoo-r1.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: readme.gentoo-r1.eclass @@ -10,7 +10,7 @@ # @BLURB: install a doc file shown via elog messages # @DESCRIPTION: # An eclass for installing a README.gentoo doc file recording tips -# shown via elog messages. With this eclass, those elog messages will only be +# shown via elog messages. With this eclass, those elog messages will only be # shown at first package installation and a file for later reviewing will be # installed under /usr/share/doc/${PF} # @@ -21,7 +21,11 @@ if [[ -z ${_README_GENTOO_ECLASS} ]]; then _README_GENTOO_ECLASS=1 case ${EAPI} in - 6|7|8) ;; + 6) + ewarn "${CATEGORY}/${PF}: ebuild uses ${ECLASS} with deprecated EAPI ${EAPI}!" + ewarn "${CATEGORY}/${PF}: Support will be removed on 2024-10-08. Please port to newer EAPI." + ;; + 7|8) ;; *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; esac @@ -34,8 +38,8 @@ esac # @DEFAULT_UNSET # @DESCRIPTION: # If non-empty, DOC_CONTENTS information will be strictly respected, -# not getting it automatically formatted by fmt. If empty, it will -# rely on fmt for formatting and 'echo -e' options to tweak lines a bit. +# not getting it automatically formatted by fold. If empty, it will +# rely on fold for formatting and 'echo -e' options to tweak lines a bit. # @ECLASS_VARIABLE: FORCE_PRINT_ELOG # @DEFAULT_UNSET @@ -50,7 +54,7 @@ esac # @FUNCTION: readme.gentoo_create_doc # @DESCRIPTION: # Create doc file with ${DOC_CONTENTS} variable (preferred) and, if not set, -# look for "${FILESDIR}/README.gentoo" contents. You can use +# look for "${FILESDIR}/README.gentoo" contents. You can use # ${FILESDIR}/README.gentoo-${SLOT} also. # Usually called at src_install phase. readme.gentoo_create_doc() { @@ -84,7 +88,7 @@ readme.gentoo_create_doc() { # @FUNCTION: readme.gentoo_print_elog # @DESCRIPTION: -# Print elog messages with "${T}"/README.gentoo contents. They will be +# Print elog messages with "${T}"/README.gentoo contents. They will be # shown only when package is installed at first time. # Usually called at pkg_postinst phase. # 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 c1a3aca67b54..1e4e845a9adb 100644 --- a/eclass/rebar.eclass +++ b/eclass/rebar.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: rebar.eclass @@ -6,7 +6,8 @@ # maintainer-needed@gentoo.org # @AUTHOR: # Amadeusz Żołnowski <aidecoe@gentoo.org> -# @SUPPORTED_EAPIS: 6 7 8 +# @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 @@ -20,35 +21,21 @@ # installation in a generic way for Erlang/OTP structured projects. case ${EAPI} in - 6|7|8) ;; + 7|8) ;; *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; esac if [[ -z ${_REBAR_ECLASS} ]]; then _REBAR_ECLASS=1 +inherit rebar-utils + RDEPEND="dev-lang/erlang:=" DEPEND="${RDEPEND}" BDEPEND=" dev-util/rebar:0 >=sys-apps/gawk-4.1 " -if [[ ${EAPI} == 6 ]]; then - DEPEND+=" ${BDEPEND}" -fi - -# @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 @@ -63,7 +50,7 @@ _rebar_find_dep() { local p local result - pushd "${EPREFIX}/$(get_erl_libs)" >/dev/null || return 1 + 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. @@ -77,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: @@ -102,92 +73,12 @@ erebar() { (( $# > 0 )) || die "erebar: at least one target is required" - local -x ERL_LIBS="${EPREFIX}/$(get_erl_libs)" + local -x ERL_LIBS="${EPREFIX}$(get_erl_libs)" [[ ${1} == eunit ]] && local -x ERL_LIBS="." 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 @@ -212,7 +103,7 @@ rebar_src_prepare() { rebar_src_configure() { debug-print-function ${FUNCNAME} "${@}" - local -x ERL_LIBS="${EPREFIX}/$(get_erl_libs)" + local -x ERL_LIBS="${EPREFIX}$(get_erl_libs)" default } @@ -252,7 +143,7 @@ rebar_src_install() { [[ -d bin ]] && for bin in bin/*; do dobin "$bin"; done if [[ -d priv ]]; then - cp -pR priv "${ED%/}/${dest}/" || die "failed to install priv/" + cp -pR priv "${ED}${dest}/" || die "failed to install priv/" fi einstalldocs 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 diff --git a/eclass/rocm.eclass b/eclass/rocm.eclass index 7039455dec6b..cf501d5a8861 100644 --- a/eclass/rocm.eclass +++ b/eclass/rocm.eclass @@ -15,9 +15,13 @@ # edit USE flag to control which GPU architecture to compile. Using # ${ROCM_USEDEP} can ensure coherence among dependencies. Ebuilds can call the # function get_amdgpu_flag to translate activated target to GPU compile flags, -# passing it to configuration. Function check_amdgpu can help ebuild ensure +# passing it to configuration. Function rocm_use_hipcc switches active compiler +# to hipcc and cleans incompatible flags (useful for users with gcc-only flags +# in /etc/portage/make.conf). Function check_amdgpu can help ebuild ensure # read and write permissions to GPU device in src_test phase, throwing friendly -# error message if unavailable. +# error message if unavailable. However src_configure in general should not +# access any AMDGPU devices. If it does, it usually means that CMakeLists.txt +# ignores AMDGPU_TARGETS in favor of autodetected GPU, which is not desired. # # @EXAMPLE: # Example ebuild for ROCm library in https://github.com/ROCmSoftwarePlatform @@ -39,14 +43,12 @@ # " # # src_configure() { -# # avoid sandbox violation -# addpredict /dev/kfd -# addpredict /dev/dri/ +# rocm_use_hipcc # local mycmakeargs=( # -DAMDGPU_TARGETS="$(get_amdgpu_flags)" # -DBUILD_CLIENTS_TESTS=$(usex test ON OFF) # ) -# CXX=hipcc cmake_src_configure +# cmake_src_configure # } # # src_test() { @@ -90,6 +92,8 @@ esac if [[ ! ${_ROCM_ECLASS} ]]; then _ROCM_ECLASS=1 +inherit flag-o-matic + # @ECLASS_VARIABLE: ROCM_VERSION # @REQUIRED # @PRE_INHERIT @@ -231,3 +235,27 @@ check_amdgpu() { } fi + +# @FUNCTION: rocm_use_hipcc +# @USAGE: rocm_use_hipcc +# @DESCRIPTION: +# switch active C and C++ compilers to hipcc, clean unsupported flags and setup ROCM_TARGET_LST file. +rocm_use_hipcc() { + # During the configuration stage, CMake tests whether the compiler is able to compile a simple program. + # Since CMake checker does not specify --offload-arch=, hipcc enumerates devices using four methods + # until it finds at least one device. Last way is by accessing them (via rocminfo). + # To prevent potential sandbox violations, we set the ROCM_TARGET_LST variable (which is checked first). + local target_lst="${T}"/gentoo_rocm_target.lst + if [[ "${AMDGPU_TARGETS[@]}" = "" ]]; then + # Expected no GPU code; still need to calm down sandbox + echo "gfx000" > "${target_lst}" || die + else + printf "%s\n" ${AMDGPU_TARGETS[@]} > "${target_lst}" || die + fi + export ROCM_TARGET_LST="${target_lst}" + + # Export updated CC and CXX. Note that CC is needed even if no C code used, + # as CMake checks that C compiler can compile a simple test program. + export CC=hipcc CXX=hipcc + strip-unsupported-flags +} diff --git a/eclass/ruby-fakegem.eclass b/eclass/ruby-fakegem.eclass index 40ff76ce900e..04099a82ef4f 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 @@ -139,7 +139,11 @@ RUBY_FAKEGEM_BINDIR="${RUBY_FAKEGEM_BINDIR-bin}" RUBY_FAKEGEM_EXTENSION_LIBDIR="${RUBY_FAKEGEM_EXTENSION_LIBDIR-lib}" case ${EAPI} in - 5|6|7|8) ;; + 6) + ewarn "${CATEGORY}/${PF}: ebuild uses ${ECLASS} with deprecated EAPI ${EAPI}!" + ewarn "${CATEGORY}/${PF}: Support will be removed on 2024-10-08. Please port to newer EAPI." + ;; + 7|8) ;; *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; esac diff --git a/eclass/ruby-ng-gnome2.eclass b/eclass/ruby-ng-gnome2.eclass index e10f1e625993..c38c5f15904d 100644 --- a/eclass/ruby-ng-gnome2.eclass +++ b/eclass/ruby-ng-gnome2.eclass @@ -6,7 +6,7 @@ # Ruby herd <ruby@gentoo.org> # @AUTHOR: # Author: Hans de Graaff <graaff@gentoo.org> -# @SUPPORTED_EAPIS: 7 +# @SUPPORTED_EAPIS: 7 8 # @PROVIDES: ruby-ng # @BLURB: An eclass to simplify handling of various ruby-gnome2 parts. # @DESCRIPTION: @@ -14,7 +14,7 @@ # ruby-gnome2 since they share a very common installation procedure. case ${EAPI} in - 7) ;; + 7|8) ;; *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; esac @@ -44,17 +44,11 @@ BDEPEND="virtual/pkgconfig" ruby_add_bdepend " dev-ruby/pkg-config test? ( >=dev-ruby/test-unit-2 )" -SRC_URI="https://downloads.sourceforge.net/ruby-gnome2/ruby-gnome2-all-${PV}.tar.gz" HOMEPAGE="https://ruby-gnome.github.io/" LICENSE="LGPL-2.1+" SLOT="0" -if ver_test -ge "3.4.0"; then - SRC_URI="https://github.com/ruby-gnome/ruby-gnome/archive/${PV}.tar.gz -> ruby-gnome2-${PV}.tar.gz" - RUBY_S=ruby-gnome-${PV}/${RUBY_FAKEGEM_NAME} -else - SRC_URI="https://downloads.sourceforge.net/ruby-gnome2/ruby-gnome2-all-${PV}.tar.gz" - RUBY_S=ruby-gnome2-all-${PV}/${RUBY_FAKEGEM_NAME} -fi +SRC_URI="https://github.com/ruby-gnome/ruby-gnome/archive/${PV}.tar.gz -> ruby-gnome2-${PV}.tar.gz" +RUBY_S=ruby-gnome-${PV}/${RUBY_FAKEGEM_NAME} ruby-ng-gnome2_all_ruby_prepare() { # Avoid compilation of dependencies during test. diff --git a/eclass/ruby-ng.eclass b/eclass/ruby-ng.eclass index d80ae96dd40b..2ef6d2247435 100644 --- a/eclass/ruby-ng.eclass +++ b/eclass/ruby-ng.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-ng.eclass @@ -67,7 +67,11 @@ # passed to "grep -E" to remove reporting of these shared objects. case ${EAPI} in - 6|7|8) ;; + 6) + ewarn "${CATEGORY}/${PF}: ebuild uses ${ECLASS} with deprecated EAPI ${EAPI}!" + ewarn "${CATEGORY}/${PF}: Support will be removed on 2024-10-08. Please port to newer EAPI." + ;; + 7|8) ;; *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; esac diff --git a/eclass/ruby-utils.eclass b/eclass/ruby-utils.eclass index 789f57ce25f6..48a25114b396 100644 --- a/eclass/ruby-utils.eclass +++ b/eclass/ruby-utils.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-utils.eclass @@ -15,13 +15,17 @@ # This eclass does not set any metadata variables nor export any phase # functions. It can be inherited safely. -case ${EAPI:-0} in - [5678]) ;; +if [[ ! ${_RUBY_UTILS} ]]; then + +case ${EAPI} in + 5|6) + ewarn "${CATEGORY}/${PF}: ebuild uses ${ECLASS} with deprecated EAPI ${EAPI}!" + ewarn "${CATEGORY}/${PF}: Support will be removed on 2024-10-08. Please port to newer EAPI." + ;; + 7|8) ;; *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; esac -if [[ ! ${_RUBY_UTILS} ]]; then - # @ECLASS_VARIABLE: RUBY_TARGETS_PREFERENCE # @INTERNAL # @DESCRIPTION: diff --git a/eclass/rust-toolchain.eclass b/eclass/rust-toolchain.eclass index 5824a48734f9..89bca88b9e6b 100644 --- a/eclass/rust-toolchain.eclass +++ b/eclass/rust-toolchain.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: rust-toolchain.eclass @@ -7,17 +7,14 @@ # @SUPPORTED_EAPIS: 8 # @BLURB: helps map gentoo arches to rust ABIs # @DESCRIPTION: -# This eclass contains a src_unpack default phase function, and -# helper functions, to aid in proper rust-ABI handling for various -# gentoo arches. +# This eclass contains helper functions, to aid in proper rust-ABI handling for +# various gentoo arches. case ${EAPI} in 8) ;; *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; esac -inherit multilib-build - # @ECLASS_VARIABLE: RUST_TOOLCHAIN_BASEURL # @DESCRIPTION: # This variable specifies the base URL used by the @@ -34,46 +31,33 @@ inherit multilib-build rust_abi() { local CTARGET=${1:-${CHOST}} case ${CTARGET%%*-} in - aarch64*gnu) echo aarch64-unknown-linux-gnu;; - aarch64*musl) echo aarch64-unknown-linux-musl;; - armv6j*h*) echo arm-unknown-linux-gnueabihf;; - armv6j*s*) echo arm-unknown-linux-gnueabi;; - armv7a*h*) echo armv7-unknown-linux-gnueabihf;; - i?86*) echo i686-unknown-linux-gnu;; - loongarch64*) echo loongarch64-unknown-linux-gnu;; - mips64el*) echo mips64el-unknown-linux-gnuabi64;; - mips64*) echo mips64-unknown-linux-gnuabi64;; - mipsel*) echo mipsel-unknown-linux-gnu;; - mips*) echo mips-unknown-linux-gnu;; - powerpc64le*) echo powerpc64le-unknown-linux-gnu;; - powerpc64*) echo powerpc64-unknown-linux-gnu;; - powerpc*) echo powerpc-unknown-linux-gnu;; - riscv64*) echo riscv64gc-unknown-linux-gnu;; - s390x*) echo s390x-unknown-linux-gnu;; - x86_64*gnu) echo x86_64-unknown-linux-gnu;; - x86_64*musl) echo x86_64-unknown-linux-musl;; - *) echo ${CTARGET};; + aarch64*gnu) echo aarch64-unknown-linux-gnu;; + aarch64*musl) echo aarch64-unknown-linux-musl;; + armv6j*h*) echo arm-unknown-linux-gnueabihf;; + armv6j*s*) echo arm-unknown-linux-gnueabi;; + armv7a*h*) echo armv7-unknown-linux-gnueabihf;; + i?86*) echo i686-unknown-linux-gnu;; + loongarch64*) echo loongarch64-unknown-linux-gnu;; + mips64el*) echo mips64el-unknown-linux-gnuabi64;; + mips64*) echo mips64-unknown-linux-gnuabi64;; + mipsel*) echo mipsel-unknown-linux-gnu;; + mips*) echo mips-unknown-linux-gnu;; + powerpc64le*gnu) echo powerpc64le-unknown-linux-gnu;; + powerpc64le*musl) echo powerpc64le-unknown-linux-musl;; + powerpc64*gnu) echo powerpc64-unknown-linux-gnu;; + powerpc64*musl) echo powerpc64-unknown-linux-musl;; + powerpc*gnu) echo powerpc-unknown-linux-gnu;; + powerpc*musl) echo powerpc-unknown-linux-musl;; + riscv64*gnu) echo riscv64gc-unknown-linux-gnu;; + riscv64*musl) echo riscv64gc-unknown-linux-musl;; + s390x*) echo s390x-unknown-linux-gnu;; + sparc64*gnu) echo sparc64-unknown-linux-gnu;; + x86_64*gnu) echo x86_64-unknown-linux-gnu;; + x86_64*musl) echo x86_64-unknown-linux-musl;; + *) echo ${CTARGET};; esac } -# @FUNCTION: rust_all_abis -# @DESCRIPTION: -# Outputs a list of all the enabled Rust ABIs -rust_all_abis() { - if use multilib; then - local abi - local ALL_ABIS=() - for abi in $(multilib_get_enabled_abis); do - ALL_ABIS+=( $(rust_abi $(get_abi_CHOST ${abi})) ) - done - local abi_list - IFS=, eval 'abi_list=${ALL_ABIS[*]}' - echo ${abi_list} - else - rust_abi - fi -} - # @FUNCTION: rust_arch_uri # @USAGE: <rust-ABI> <base-uri> [alt-distfile-basename] # @DESCRIPTION: @@ -108,27 +92,27 @@ rust_arch_uri() { rust_all_arch_uris() { echo " - abi_x86_32? ( $(rust_arch_uri i686-unknown-linux-gnu "$@") ) + abi_x86_32? ( elibc_glibc? ( $(rust_arch_uri i686-unknown-linux-gnu "$@") ) ) abi_x86_64? ( elibc_glibc? ( $(rust_arch_uri x86_64-unknown-linux-gnu "$@") ) elibc_musl? ( $(rust_arch_uri x86_64-unknown-linux-musl "$@") ) ) - arm? ( + arm? ( elibc_glibc? ( $(rust_arch_uri arm-unknown-linux-gnueabi "$@") $(rust_arch_uri arm-unknown-linux-gnueabihf "$@") $(rust_arch_uri armv7-unknown-linux-gnueabihf "$@") - ) + ) ) arm64? ( elibc_glibc? ( $(rust_arch_uri aarch64-unknown-linux-gnu "$@") ) elibc_musl? ( $(rust_arch_uri aarch64-unknown-linux-musl "$@") ) ) - ppc? ( $(rust_arch_uri powerpc-unknown-linux-gnu "$@") ) + ppc? ( elibc_glibc? ( $(rust_arch_uri powerpc-unknown-linux-gnu "$@") ) ) ppc64? ( - big-endian? ( $(rust_arch_uri powerpc64-unknown-linux-gnu "$@") ) - !big-endian? ( $(rust_arch_uri powerpc64le-unknown-linux-gnu "$@") ) + big-endian? ( elibc_glibc? ( $(rust_arch_uri powerpc64-unknown-linux-gnu "$@") ) ) + !big-endian? ( elibc_glibc? ( $(rust_arch_uri powerpc64le-unknown-linux-gnu "$@") ) ) ) - riscv? ( $(rust_arch_uri riscv64gc-unknown-linux-gnu "$@") ) - s390? ( $(rust_arch_uri s390x-unknown-linux-gnu "$@") ) + riscv? ( elibc_glibc? ( $(rust_arch_uri riscv64gc-unknown-linux-gnu "$@") ) ) + s390? ( elibc_glibc? ( $(rust_arch_uri s390x-unknown-linux-gnu "$@") ) ) " # Upstream did not gain support for loong until v1.71.0. @@ -137,7 +121,7 @@ rust_all_arch_uris() local arg_version="${1##*-}" arg_version="${arg_version:-$PV}" if ver_test "${arg_version}" -ge 1.71.0; then - echo "loong? ( $(rust_arch_uri loongarch64-unknown-linux-gnu "$@") )" + echo "loong? ( elibc_glibc? ( $(rust_arch_uri loongarch64-unknown-linux-gnu "$@") ) )" fi # until https://github.com/rust-lang/rust/pull/113274 is resolved, there diff --git a/eclass/savedconfig.eclass b/eclass/savedconfig.eclass index cc5748543078..65a1f3bfd800 100644 --- a/eclass/savedconfig.eclass +++ b/eclass/savedconfig.eclass @@ -1,10 +1,10 @@ -# Copyright 1999-2023 Gentoo Authors +# Copyright 1999-2024 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 # @ECLASS: savedconfig.eclass # @MAINTAINER: # base-system@gentoo.org -# @SUPPORTED_EAPIS: 6 7 8 +# @SUPPORTED_EAPIS: 7 8 # @BLURB: common API for saving/restoring complex configuration files # @DESCRIPTION: # It is not uncommon to come across a package which has a very fine @@ -31,7 +31,7 @@ # build. case ${EAPI} in - 6|7|8) ;; + 7|8) ;; *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; esac @@ -60,12 +60,12 @@ save_config() { if [[ $# -eq 1 && -f $1 ]] ; then # Just one file, so have the ${configfile} be that config file dodir "${configfile%/*}" - cp "$@" "${ED%/}/${configfile}" || die "failed to save $*" + cp "$@" "${ED}/${configfile}" || die "failed to save $*" else # A dir, or multiple files, so have the ${configfile} be a dir # with all the saved stuff below it dodir "${configfile}" - treecopy "$@" "${ED%/}/${configfile}" || die "failed to save $*" + treecopy "$@" "${ED}/${configfile}" || die "failed to save $*" fi elog "Your configuration for ${CATEGORY}/${PF} has been saved in " @@ -150,7 +150,7 @@ savedconfig_pkg_postinst() { # are worse :/. if use savedconfig ; then - find "${EROOT%/}/etc/portage/savedconfig/${CATEGORY}/${PF}" \ + find "${EROOT}/etc/portage/savedconfig/${CATEGORY}/${PF}" \ -exec touch {} + 2>/dev/null fi } diff --git a/eclass/secureboot.eclass b/eclass/secureboot.eclass index a9ba514cb7a0..4459b0341845 100644 --- a/eclass/secureboot.eclass +++ b/eclass/secureboot.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: secureboot.eclass @@ -44,7 +44,12 @@ case ${EAPI} in esac IUSE="secureboot" -BDEPEND="secureboot? ( app-crypt/sbsigntools )" +BDEPEND=" + secureboot? ( + app-crypt/sbsigntools + dev-libs/openssl + ) +" # @ECLASS_VARIABLE: SECUREBOOT_SIGN_KEY # @USER_VARIABLE @@ -75,12 +80,19 @@ _secureboot_die_if_unset() { if [[ -z ${SECUREBOOT_SIGN_KEY} || -z ${SECUREBOOT_SIGN_CERT} ]]; then die "USE=secureboot enabled but SECUREBOOT_SIGN_KEY and/or SECUREBOOT_SIGN_CERT not set." fi - if [[ ! ${SECUREBOOT_SIGN_KEY} == pkcs11:* && ! -r ${SECUREBOOT_SIGN_KEY} ]]; then - die "SECUREBOOT_SIGN_KEY=${SECUREBOOT_SIGN_KEY} not found or not readable!" - fi - if [[ ! -r ${SECUREBOOT_SIGN_CERT} ]]; then - die "SECUREBOOT_SIGN_CERT=${SECUREBOOT_SIGN_CERT} not found or not readable!" + + # Sanity check: fail early if key/cert in DER format or does not exist + local openssl_args=( + -inform PEM -in "${SECUREBOOT_SIGN_CERT}" + -noout -nocert + ) + if [[ ${SECUREBOOT_SIGN_KEY} == pkcs11:* ]]; then + openssl_args+=( -engine pkcs11 -keyform ENGINE -key "${SECUREBOOT_SIGN_KEY}" ) + else + openssl_args+=( -keyform PEM -key "${SECUREBOOT_SIGN_KEY}" ) fi + openssl x509 "${openssl_args[@]}" || + die "Secure Boot signing certificate or key not found or not PEM format." } # @FUNCTION: secureboot_pkg_setup diff --git a/eclass/selinux-policy-2.eclass b/eclass/selinux-policy-2.eclass index ad760673cab1..e7d6cd9a9e5f 100644 --- a/eclass/selinux-policy-2.eclass +++ b/eclass/selinux-policy-2.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 for installing SELinux policy, and optionally @@ -260,13 +260,9 @@ selinux-policy-2_pkg_postinst() { local COMMAND for i in ${POLICY_TYPES}; do - if [[ "${MODS}" = "unconfined" ]]; then - case ${i} in - strict|mcs|mls) - einfo "Ignoring loading of unconfined module in ${i} module store."; - continue - ;; - esac + if [[ "${i}" == "strict" ]] && [[ "${MODS}" = "unconfined" ]]; then + einfo "Ignoring loading of unconfined module in strict module store."; + continue; fi einfo "Inserting the following modules into the $i module store: ${MODS}" diff --git a/eclass/strip-linguas.eclass b/eclass/strip-linguas.eclass index 718341b4a626..b31f414c87c3 100644 --- a/eclass/strip-linguas.eclass +++ b/eclass/strip-linguas.eclass @@ -1,4 +1,4 @@ -# Copyright 2004-2021 Gentoo Authors +# Copyright 2004-2024 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 # @ECLASS: strip-linguas.eclass @@ -9,15 +9,19 @@ # @SUPPORTED_EAPIS: 5 6 7 8 # @BLURB: convenience function for LINGUAS support +if [[ -z ${_STRIP_LINGUAS_ECLASS} ]]; then +_STRIP_LINGUAS_ECLASS=1 + case ${EAPI} in - 5|6|7|8) ;; + 5|6) + ewarn "${CATEGORY}/${PF}: ebuild uses ${ECLASS} with deprecated EAPI ${EAPI}!" + ewarn "${CATEGORY}/${PF}: Support will be removed on 2024-10-08. Please port to newer EAPI." + ;; + 7|8) ;; *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; esac -if [[ -z ${_STRIP_LINGUAS_ECLASS} ]]; then -_STRIP_LINGUAS_ECLASS=1 - -# @FUNCTION: strip-linguas +# FUNCTION: strip-linguas # @USAGE: [<allow LINGUAS>|<-i|-u> <directories of .po files>] # @DESCRIPTION: # Make sure that LINGUAS only contains languages that a package can diff --git a/eclass/systemd.eclass b/eclass/systemd.eclass index 03d6a82fd310..a5f0decde1e3 100644 --- a/eclass/systemd.eclass +++ b/eclass/systemd.eclass @@ -1,4 +1,4 @@ -# Copyright 2011-2023 Gentoo Authors +# Copyright 2011-2024 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 # @ECLASS: systemd.eclass @@ -25,7 +25,11 @@ # @CODE case ${EAPI} in - 5|6|7|8) ;; + 6) + ewarn "${CATEGORY}/${PF}: ebuild uses ${ECLASS} with deprecated EAPI ${EAPI}!" + ewarn "${CATEGORY}/${PF}: Support will be removed on 2024-10-08. Please port to newer EAPI." + ;; + 7|8) ;; *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; esac diff --git a/eclass/tests/Makefile b/eclass/tests/Makefile index ee4a454912c3..23027aed6b66 100644 --- a/eclass/tests/Makefile +++ b/eclass/tests/Makefile @@ -2,18 +2,20 @@ SH_FILES := $(wildcard *.sh) TEST_FILES := $(filter-out tests-common.sh, $(SH_FILES)) TEST_OK_FILES := $(patsubst %.sh, .%.sh.ok,$ $(TEST_FILES)) +# !!! _All_ recipe lines for each target will be provided to a single +# !!! invocation of the shell. +.ONESHELL: + # We cache a successful test result if the testfile itself did not # change (%.sh) and the contents of the eclass/ directory did not # change (.eclasssum). .%.sh.ok: %.sh .eclasssum - ./$< - touch $@ + ./$< && touch $@ .PHONY: test test: $(TEST_OK_FILES) .PHONY: force -.ONESHELL: .eclasssum: SHELL = /bin/bash .eclasssum: force set -euo pipefail diff --git a/eclass/tests/cargo-bench.sh b/eclass/tests/cargo-bench.sh index d30b04569905..9347fe339c12 100755 --- a/eclass/tests/cargo-bench.sh +++ b/eclass/tests/cargo-bench.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright 2023 Gentoo Authors +# Copyright 2023-2024 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 EAPI=8 @@ -39,7 +39,7 @@ timeit() { local xr avg for x in real user; do xr="${x}[*]" - avg=$(dc -S 3 -e "${ITERATIONS} ${RUNS} * ${!xr} + + / p") + avg=$(dc -e "3 k ${ITERATIONS} ${RUNS} * ${!xr} + + / p") printf '%s %4.0f it/s\n' "${x}" "${avg}" done diff --git a/eclass/tests/dist-kernel-utils.sh b/eclass/tests/dist-kernel-utils.sh index 7f04f55ce302..28c8f7213a53 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} @@ -20,9 +20,68 @@ test_PV_to_KV() { tend $? } +test_compressed_module_cleanup() { + mkdir -p "${tmpdir}/source" || die + pushd "${tmpdir}" >/dev/null || die + + local module option fail=0 + for option in NONE GZIP XZ ZSTD; do + tbegin "CONFIG_MODULE_COMPRESS_${option}" + echo "CONFIG_MODULE_COMPRESS_${option}=y" > source/.config + + touch a.ko b.ko.gz c.ko.xz d.ko.gz e.ko f.ko.xz || die + # ensure some files are older + touch -d "2 hours ago" d.ko e.ko.xz f.ko.gz || die + + IUSE=modules-compress dist-kernel_compressed_module_cleanup . + + local to_keep=( a.ko b.ko.gz c.ko.xz ) + local to_remove=() + + case ${option} in + NONE) + to_keep+=( d.ko e.ko f.ko.xz ) + to_remove+=( d.ko.gz e.ko.xz f.ko.gz ) + ;; + GZIP) + to_keep+=( d.ko.gz e.ko f.ko.gz ) + to_remove+=( d.ko e.ko.xz f.ko.xz ) + ;; + XZ) + to_keep+=( d.ko.gz e.ko.xz f.ko.xz ) + to_remove+=( d.ko e.ko f.ko.gz ) + ;; + ZSTD) + to_keep+=( d.ko.gz e.ko f.ko.xz ) + to_remove+=( d.ko e.ko.xz f.ko.gz ) + ;; + esac + + for module in "${to_keep[@]}"; do + if [[ ! -f ${module} ]]; then + eerror "Module ${module} was removed" + fail=1 + fi + done + + for module in "${to_remove[@]}"; do + if [[ -f ${module} ]]; then + eerror "Module ${module} was not removed" + fail=1 + fi + done + tend ${fail} + done + + popd >/dev/null || die +} + + test_PV_to_KV 6.0_rc1 6.0.0-rc1 test_PV_to_KV 6.0 6.0.0 test_PV_to_KV 6.0.1_rc1 6.0.1-rc1 test_PV_to_KV 6.0.1 6.0.1 +test_compressed_module_cleanup + texit diff --git a/eclass/tests/eapi7-ver.sh b/eclass/tests/eapi7-ver.sh deleted file mode 100755 index 13cd671e7158..000000000000 --- a/eclass/tests/eapi7-ver.sh +++ /dev/null @@ -1,177 +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 - -teq() { - local expected=${1}; shift - - tbegin "${*} -> ${expected}" - local got=$("${@}") - [[ ${got} == ${expected} ]] - tend ${?} "returned: ${got}" -} - -teqr() { - local expected=$1; shift - tbegin "$* -> ${expected}" - "$@" - local ret=$? - [[ ${ret} -eq ${expected} ]] - tend $? "returned: ${ret}" -} - -txf() { - tbegin "XFAIL: ${*}" - local got=$("${@}" 2>&1) - [[ ${got} == die:* ]] - tend ${?} "function did not die" -} - -teq 1 ver_cut 1 1.2.3 -teq 1 ver_cut 1-1 1.2.3 -teq 1.2 ver_cut 1-2 1.2.3 -teq 2.3 ver_cut 2- 1.2.3 -teq 1.2.3 ver_cut 1- 1.2.3 -teq 3b ver_cut 3-4 1.2.3b_alpha4 -teq alpha ver_cut 5 1.2.3b_alpha4 -teq 1.2 ver_cut 1-2 .1.2.3 -teq .1.2 ver_cut 0-2 .1.2.3 -teq 2.3 ver_cut 2-3 1.2.3. -teq 2.3. ver_cut 2- 1.2.3. -teq 2.3. ver_cut 2-4 1.2.3. - -teq 1-2.3 ver_rs 1 - 1.2.3 -teq 1.2-3 ver_rs 2 - 1.2.3 -teq 1-2-3.4 ver_rs 1-2 - 1.2.3.4 -teq 1.2-3-4 ver_rs 2- - 1.2.3.4 -teq 1.2.3 ver_rs 2 . 1.2-3 -teq 1.2.3.a ver_rs 3 . 1.2.3a -teq 1.2-alpha-4 ver_rs 2-3 - 1.2_alpha4 -teq 1.23-b_alpha4 ver_rs 3 - 2 "" 1.2.3b_alpha4 -teq a1b_2-c-3-d4e5 ver_rs 3-5 _ 4-6 - a1b2c3d4e5 -teq .1-2.3 ver_rs 1 - .1.2.3 -teq -1.2.3 ver_rs 0 - .1.2.3 - -# truncating range -teq 1.2 ver_cut 0-2 1.2.3 -teq 2.3 ver_cut 2-5 1.2.3 -teq "" ver_cut 4 1.2.3 -teq "" ver_cut 0 1.2.3 -teq "" ver_cut 4- 1.2.3 -teq 1.2.3 ver_rs 0 - 1.2.3 -teq 1.2.3 ver_rs 3 . 1.2.3 -teq 1.2.3 ver_rs 3- . 1.2.3 -teq 1.2.3 ver_rs 3-5 . 1.2.3 - -txf ver_cut foo 1.2.3 -txf ver_rs -3 _ a1b2c3d4e5 -txf ver_rs 5-3 _ a1b2c3d4e5 - -# Tests from Portage's test_vercmp.py -teqr 0 ver_test 6.0 -gt 5.0 -teqr 0 ver_test 5.0 -gt 5 -teqr 0 ver_test 1.0-r1 -gt 1.0-r0 -teqr 0 ver_test 999999999999999999 -gt 999999999999999998 # 18 digits -teqr 0 ver_test 1.0.0 -gt 1.0 -teqr 0 ver_test 1.0.0 -gt 1.0b -teqr 0 ver_test 1b -gt 1 -teqr 0 ver_test 1b_p1 -gt 1_p1 -teqr 0 ver_test 1.1b -gt 1.1 -teqr 0 ver_test 12.2.5 -gt 12.2b -teqr 0 ver_test 4.0 -lt 5.0 -teqr 0 ver_test 5 -lt 5.0 -teqr 0 ver_test 1.0_pre2 -lt 1.0_p2 -teqr 0 ver_test 1.0_alpha2 -lt 1.0_p2 -teqr 0 ver_test 1.0_alpha1 -lt 1.0_beta1 -teqr 0 ver_test 1.0_beta3 -lt 1.0_rc3 -teqr 0 ver_test 1.001000000000000001 -lt 1.001000000000000002 -teqr 0 ver_test 1.00100000000 -lt 1.001000000000000001 -teqr 0 ver_test 999999999999999998 -lt 999999999999999999 -teqr 0 ver_test 1.01 -lt 1.1 -teqr 0 ver_test 1.0-r0 -lt 1.0-r1 -teqr 0 ver_test 1.0 -lt 1.0-r1 -teqr 0 ver_test 1.0 -lt 1.0.0 -teqr 0 ver_test 1.0b -lt 1.0.0 -teqr 0 ver_test 1_p1 -lt 1b_p1 -teqr 0 ver_test 1 -lt 1b -teqr 0 ver_test 1.1 -lt 1.1b -teqr 0 ver_test 12.2b -lt 12.2.5 -teqr 0 ver_test 4.0 -eq 4.0 -teqr 0 ver_test 1.0 -eq 1.0 -teqr 0 ver_test 1.0-r0 -eq 1.0 -teqr 0 ver_test 1.0 -eq 1.0-r0 -teqr 0 ver_test 1.0-r0 -eq 1.0-r0 -teqr 0 ver_test 1.0-r1 -eq 1.0-r1 -teqr 1 ver_test 1 -eq 2 -teqr 1 ver_test 1.0_alpha -eq 1.0_pre -teqr 1 ver_test 1.0_beta -eq 1.0_alpha -teqr 1 ver_test 1 -eq 0.0 -teqr 1 ver_test 1.0-r0 -eq 1.0-r1 -teqr 1 ver_test 1.0-r1 -eq 1.0-r0 -teqr 1 ver_test 1.0 -eq 1.0-r1 -teqr 1 ver_test 1.0-r1 -eq 1.0 -teqr 1 ver_test 1.0 -eq 1.0.0 -teqr 1 ver_test 1_p1 -eq 1b_p1 -teqr 1 ver_test 1b -eq 1 -teqr 1 ver_test 1.1b -eq 1.1 -teqr 1 ver_test 12.2b -eq 12.2 - -# A subset of tests from Paludis -teqr 0 ver_test 1.0_alpha -gt 1_alpha -teqr 0 ver_test 1.0_alpha -gt 1 -teqr 0 ver_test 1.0_alpha -lt 1.0 -teqr 0 ver_test 1.2.0.0_alpha7-r4 -gt 1.2_alpha7-r4 -teqr 0 ver_test 0001 -eq 1 -teqr 0 ver_test 01 -eq 001 -teqr 0 ver_test 0001.1 -eq 1.1 -teqr 0 ver_test 01.01 -eq 1.01 -teqr 0 ver_test 1.010 -eq 1.01 -teqr 0 ver_test 1.00 -eq 1.0 -teqr 0 ver_test 1.0100 -eq 1.010 -teqr 0 ver_test 1-r00 -eq 1-r0 - -# Additional tests -teqr 0 ver_test 0_rc99 -lt 0 -teqr 0 ver_test 011 -eq 11 -teqr 0 ver_test 019 -eq 19 -teqr 0 ver_test 1.2 -eq 001.2 -teqr 0 ver_test 1.2 -gt 1.02 -teqr 0 ver_test 1.2a -lt 1.2b -teqr 0 ver_test 1.2_pre1 -gt 1.2_pre1_beta2 -teqr 0 ver_test 1.2_pre1 -lt 1.2_pre1_p2 -teqr 0 ver_test 1.00 -lt 1.0.0 -teqr 0 ver_test 1.010 -eq 1.01 -teqr 0 ver_test 1.01 -lt 1.1 -teqr 0 ver_test 1.2_pre08-r09 -eq 1.2_pre8-r9 -teqr 0 ver_test 0 -lt 576460752303423488 # 2**59 -teqr 0 ver_test 0 -lt 9223372036854775808 # 2**63 - -# Bad number or ordering of arguments -txf ver_test 1 -txf ver_test 1 -lt 2 3 -txf ver_test -lt 1 2 - -# Bad operators -txf ver_test 1 "<" 2 -txf ver_test 1 lt 2 -txf ver_test 1 -foo 2 - -# Malformed versions -txf ver_test "" -ne 1 -txf ver_test 1. -ne 1 -txf ver_test 1ab -ne 1 -txf ver_test b -ne 1 -txf ver_test 1-r1_pre -ne 1 -txf ver_test 1-pre1 -ne 1 -txf ver_test 1_foo -ne 1 -txf ver_test 1_pre1.1 -ne 1 -txf ver_test 1-r1.0 -ne 1 -txf ver_test cvs.9999 -ne 9999 - -texit 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/git-r3.sh b/eclass/tests/git-r3.sh deleted file mode 100755 index 02cbcbc59125..000000000000 --- a/eclass/tests/git-r3.sh +++ /dev/null @@ -1,208 +0,0 @@ -#!/bin/bash -# Copyright 1999-2019 Gentoo Authors -# Distributed under the terms of the GNU General Public License v2 - -# git no longer allows ext: protocol, meh -exit 0 - -EAPI=7 - -source tests-common.sh || exit - -inherit git-r3 - -testdir=${pkg_root}/git -mkdir "${testdir}" || die "unable to mkdir testdir" -cd "${testdir}" || die "unable to cd to testdir" - -EGIT3_STORE_DIR=store -mkdir "${EGIT3_STORE_DIR}" || die "unable to mkdir store" - -test_file() { - local fn=${1} - local expect=${2} - - if [[ ! -f ${fn} ]]; then - eerror "${fn} does not exist (not checked out?)" - else - local got=$(<"${fn}") - - if [[ ${got} != ${expect} ]]; then - eerror "${fn}, expected: ${expect}, got: ${got}" - else - return 0 - fi - fi - return 1 -} - -test_no_file() { - local fn=${1} - - if [[ -f ${fn} ]]; then - eerror "${fn} exists (wtf?!)" - else - return 0 - fi - return 1 -} - -test_repo_clean() { - local P=${P}_${FUNCNAME#test_} - - ( - mkdir repo - cd repo - git init -q - echo test > file - git add file - git commit -m 1 -q - echo other-text > file2 - git add file2 - git commit -m 2 -q - ) || die "unable to prepare repo" - - # we need to use an array to preserve whitespace - local EGIT_REPO_URI=( - "ext::git daemon --export-all --base-path=. --inetd %G/repo" - ) - - tbegin "fetching from a simple repo" - ( - git-r3_src_unpack - test_file "${WORKDIR}/${P}/file" test && \ - test_file "${WORKDIR}/${P}/file2" other-text - ) &>fetch.log - - eend ${?} || cat fetch.log -} - -test_repo_revert() { - local P=${P}_${FUNCNAME#test_} - - ( - cd repo - git revert -n HEAD^ - git commit -m r1 -q - ) || die "unable to prepare repo" - - # we need to use an array to preserve whitespace - local EGIT_REPO_URI=( - "ext::git daemon --export-all --base-path=. --inetd %G/repo" - ) - - tbegin "fetching revert" - ( - git-r3_src_unpack - test_no_file "${WORKDIR}/${P}/file" && \ - test_file "${WORKDIR}/${P}/file2" other-text - ) &>fetch.log - - eend ${?} || cat fetch.log -} - -test_repo_branch() { - local P=${P}_${FUNCNAME#test_} - - ( - cd repo - git branch -q other-branch HEAD^ - git checkout -q other-branch - echo one-more > file3 - git add file3 - git commit -m 3 -q - git checkout -q master - ) || die "unable to prepare repo" - - # we need to use an array to preserve whitespace - local EGIT_REPO_URI=( - "ext::git daemon --export-all --base-path=. --inetd %G/repo" - ) - local EGIT_BRANCH=other-branch - - tbegin "switching branches" - ( - git-r3_src_unpack - test_file "${WORKDIR}/${P}/file" test && \ - test_file "${WORKDIR}/${P}/file2" other-text && \ - test_file "${WORKDIR}/${P}/file3" one-more - ) &>fetch.log - - eend ${?} || cat fetch.log -} - -test_repo_merge() { - local P=${P}_${FUNCNAME#test_} - - ( - cd repo - git branch -q one-more-branch HEAD^ - git checkout -q one-more-branch - echo foobarbaz > file3 - git add file3 - git commit -m 3b -q - git checkout -q master - git merge -m 4 -q one-more-branch - ) || die "unable to prepare repo" - - # we need to use an array to preserve whitespace - local EGIT_REPO_URI=( - "ext::git daemon --export-all --base-path=. --inetd %G/repo" - ) - - tbegin "fetching a merge commit" - ( - git-r3_src_unpack - test_no_file "${WORKDIR}/${P}/file" && \ - test_file "${WORKDIR}/${P}/file2" other-text && \ - test_file "${WORKDIR}/${P}/file3" foobarbaz - ) &>fetch.log - - eend ${?} || cat fetch.log -} - -test_repo_revert_merge() { - local P=${P}_${FUNCNAME#test_} - - ( - cd repo - git branch -q to-be-reverted - git checkout -q to-be-reverted - echo trrm > file3 - git add file3 - git commit -m 5b -q - git checkout -q master - echo trrm > file2 - git add file2 - git commit -m 5 -q - git merge -m 6 -q to-be-reverted - echo trrm > file - git add file - git commit -m 7 -q - git revert -m 1 -n HEAD^ - git commit -m 7r -q - ) || die "unable to prepare repo" - - # we need to use an array to preserve whitespace - local EGIT_REPO_URI=( - "ext::git daemon --export-all --base-path=. --inetd %G/repo" - ) - - tbegin "fetching a revert of a merge commit" - ( - git-r3_src_unpack - test_file "${WORKDIR}/${P}/file" trrm && \ - test_file "${WORKDIR}/${P}/file2" trrm && \ - test_file "${WORKDIR}/${P}/file3" foobarbaz - ) &>fetch.log - - eend ${?} || cat fetch.log -} - -test_repo_clean -test_repo_revert -test_repo_branch -test_repo_merge -test_repo_revert_merge - -texit diff --git a/eclass/tests/linux-info_get_running_version.sh b/eclass/tests/linux-info_get_running_version.sh index 57aaf2fedcd4..b8ae8c4b85ae 100755 --- a/eclass/tests/linux-info_get_running_version.sh +++ b/eclass/tests/linux-info_get_running_version.sh @@ -1,12 +1,20 @@ #!/bin/bash -# Copyright 1999-2021 Gentoo Authors +# Copyright 1999-2024 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 -EAPI=6 +EAPI=8 source tests-common.sh || exit +source version-funcs.sh || exit inherit linux-info +use() { + case $1 in + kernel_linux) return 0 ;; + esac + die "${FUNCNAME[0]}: unknown flag" +} + test_get_running_version() { local test_kv=$1 major=$2 minor=$3 patch=$4 extra=$5 tbegin "get_running_version ${test_kv}" diff --git a/eclass/tests/llvm-r1.sh b/eclass/tests/llvm-r1.sh index 9958f5bba420..8583fd6c799b 100755 --- a/eclass/tests/llvm-r1.sh +++ b/eclass/tests/llvm-r1.sh @@ -121,22 +121,30 @@ test_fix_tool_path() { tend ${?} } +# full range +test_globals '14 15 16 17 18 19' \ + "+llvm_slot_18 llvm_slot_15 llvm_slot_16 llvm_slot_17 llvm_slot_19" \ + "^^ ( llvm_slot_15 llvm_slot_16 llvm_slot_17 llvm_slot_18 llvm_slot_19 )" \ + "llvm_slot_15(-)?,llvm_slot_16(-)?,llvm_slot_17(-)?,llvm_slot_18(-)?,llvm_slot_19(-)?" test_globals '14 15 16 17 18' \ - "+llvm_slot_17 llvm_slot_15 llvm_slot_16 llvm_slot_18" \ + "+llvm_slot_18 llvm_slot_15 llvm_slot_16 llvm_slot_17" \ "^^ ( llvm_slot_15 llvm_slot_16 llvm_slot_17 llvm_slot_18 )" \ "llvm_slot_15(-)?,llvm_slot_16(-)?,llvm_slot_17(-)?,llvm_slot_18(-)?" +# older than stable test_globals '14 15 16' \ "+llvm_slot_16 llvm_slot_15" \ "^^ ( llvm_slot_15 llvm_slot_16 )" \ "llvm_slot_15(-)?,llvm_slot_16(-)?" -test_globals '15 18' \ - "+llvm_slot_15 llvm_slot_18" \ - "^^ ( llvm_slot_15 llvm_slot_18 )" \ - "llvm_slot_15(-)?,llvm_slot_18(-)?" -test_globals '18' \ - "+llvm_slot_18" \ - "^^ ( llvm_slot_18 )" \ - "llvm_slot_18(-)?" +# old + newer than current stable +test_globals '15 19' \ + "+llvm_slot_15 llvm_slot_19" \ + "^^ ( llvm_slot_15 llvm_slot_19 )" \ + "llvm_slot_15(-)?,llvm_slot_19(-)?" +# newer than current stable +test_globals '19' \ + "+llvm_slot_19" \ + "^^ ( llvm_slot_19 )" \ + "llvm_slot_19(-)?" LLVM_COMPAT=( {14..18} ) inherit llvm-r1 diff --git a/eclass/tests/pypi-bench.sh b/eclass/tests/pypi-bench.sh index cce93527b729..02855563db3f 100755 --- a/eclass/tests/pypi-bench.sh +++ b/eclass/tests/pypi-bench.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright 2023 Gentoo Authors +# Copyright 2023-2024 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 EAPI=8 @@ -39,7 +39,7 @@ timeit() { local xr avg for x in real user; do xr="${x}[*]" - avg=$(dc -S 3 -e "${ITERATIONS} ${RUNS} * ${!xr} + + / p") + avg=$(dc -e "3 k ${ITERATIONS} ${RUNS} * ${!xr} + + / p") printf '%s %4.0f it/s\n' "${x}" "${avg}" done diff --git a/eclass/tests/python-utils-bench.sh b/eclass/tests/python-utils-bench.sh index 7f27adef5509..f718b9f125cb 100755 --- a/eclass/tests/python-utils-bench.sh +++ b/eclass/tests/python-utils-bench.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright 2023 Gentoo Authors +# Copyright 2023-2024 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 EAPI=8 @@ -38,7 +38,7 @@ timeit() { local xr avg for x in real user; do xr="${x}[*]" - avg=$(dc -S 3 -e "${ITERATIONS} ${RUNS} * ${!xr} + + / p") + avg=$(dc -e "3 k ${ITERATIONS} ${RUNS} * ${!xr} + + / p") printf '%s %4.0f it/s\n' "${x}" "${avg}" done diff --git a/eclass/tests/rebar_fix_include_path.sh b/eclass/tests/rebar_fix_include_path.sh index 339633e91e3a..46c5712104b1 100755 --- a/eclass/tests/rebar_fix_include_path.sh +++ b/eclass/tests/rebar_fix_include_path.sh @@ -1,16 +1,20 @@ #!/bin/bash -# Copyright 1999-2016 Gentoo Foundation +# Copyright 1999-2024 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 source tests-common.sh || exit -EAPI=6 +EAPI=8 inherit rebar EPREFIX="${tmpdir}/fakeroot" S="${WORKDIR}/${P}" +get_libdir() { + echo lib +} + setup() { mkdir -p "${S}" || die diff --git a/eclass/tests/rebar_remove_deps.sh b/eclass/tests/rebar_remove_deps.sh index b544a3078dbb..e2717b59eaf9 100755 --- a/eclass/tests/rebar_remove_deps.sh +++ b/eclass/tests/rebar_remove_deps.sh @@ -1,10 +1,10 @@ #!/bin/bash -# Copyright 1999-2016 Gentoo Foundation +# Copyright 1999-2024 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 source tests-common.sh || exit -EAPI=6 +EAPI=8 inherit rebar diff --git a/eclass/tests/rebar_set_vsn.sh b/eclass/tests/rebar_set_vsn.sh index c828732b0079..6cc4600695a6 100755 --- a/eclass/tests/rebar_set_vsn.sh +++ b/eclass/tests/rebar_set_vsn.sh @@ -1,10 +1,10 @@ #!/bin/bash -# Copyright 1999-2016 Gentoo Foundation +# Copyright 1999-2024 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 source tests-common.sh || exit -EAPI=6 +EAPI=8 inherit rebar diff --git a/eclass/tests/savedconfig.sh b/eclass/tests/savedconfig.sh index 16645fc05854..ad03ce2d2d94 100755 --- a/eclass/tests/savedconfig.sh +++ b/eclass/tests/savedconfig.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright 1999-2019 Gentoo Authors +# Copyright 1999-2024 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 EAPI=7 @@ -18,7 +18,13 @@ quiet() { sc() { EBUILD_PHASE=install quiet save_config "$@" ; } rc() { EBUILD_PHASE=prepare quiet restore_config "$@" ; } -cleanup() { rm -rf "${ED}"/* "${T}"/* "${WORKDIR}"/* ; } +cleanup() { + # make sure that these variables exist + [[ -n ${ED} && -n ${T} && -n ${WORKDIR} ]] \ + || { die "${FUNCNAME[0]}: undefined variable"; exit 1; } + rm -rf "${ED}"/* "${T}"/* "${WORKDIR}"/* +} + test-it() { local ret=0 tbegin "$@" @@ -26,7 +32,7 @@ test-it() { : $(( ret |= $? )) pushd "${WORKDIR}" >/dev/null : $(( ret |= $? )) - test + test_sc : $(( ret |= $? )) popd >/dev/null : $(( ret |= $? )) @@ -34,21 +40,21 @@ test-it() { cleanup } -test() { +test_sc() { touch f || return 1 sc f || return 1 [[ -f ${ED}/etc/portage/savedconfig/${CATEGORY}/${PF} ]] } test-it "simple save_config" -test() { +test_sc() { touch a b c || return 1 sc a b c || return 1 [[ -d ${ED}/etc/portage/savedconfig/${CATEGORY}/${PF} ]] } test-it "multi save_config" -test() { +test_sc() { mkdir dir || return 1 touch dir/{a,b,c} || return 1 sc dir || return 1 @@ -58,14 +64,14 @@ test-it "dir save_config" PORTAGE_CONFIGROOT=${D} -test() { +test_sc() { echo "ggg" > f || return 1 rc f || return 1 [[ $(<f) == "ggg" ]] } test-it "simple restore_config" -test() { +test_sc() { echo "ggg" > f || return 1 rc f || return 1 [[ $(<f) == "ggg" ]] || return 1 diff --git a/eclass/tests/tests-common.sh b/eclass/tests/tests-common.sh index 45b1e20b933a..f4e18f38fee9 100644 --- a/eclass/tests/tests-common.sh +++ b/eclass/tests/tests-common.sh @@ -55,6 +55,8 @@ has() { } use() { has "$1" ${IUSE} ; } +in_iuse() { use "$@" ; } + die() { echo "die: $*" 1>&2 exit 1 diff --git a/eclass/tests/toolchain-funcs.sh b/eclass/tests/toolchain-funcs.sh index 08cfd74611aa..0d6745862148 100755 --- a/eclass/tests/toolchain-funcs.sh +++ b/eclass/tests/toolchain-funcs.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright 1999-2021 Gentoo Authors +# Copyright 1999-2024 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 EAPI=7 @@ -28,7 +28,7 @@ test-tc-arch-kernel() { tbegin "tc-arch-kernel() (KV=2.6.30)" test-tc-arch-kernel 2.6.30 \ i{3..6}86:x86 x86_64:x86 \ - powerpc{,64}:powerpc i{3..6}86-gentoo-freebsd:i386 \ + powerpc{,64}:powerpc \ or1k:openrisc or1k-linux-musl:openrisc tend $? @@ -210,6 +210,36 @@ if type -P gcc &>/dev/null; then tbegin "tc-get-c-rtlib (gcc)" [[ $(CC=gcc tc-get-c-rtlib) == libgcc ]] tend $? + + tbegin "tc-is-lto (gcc, -fno-lto)" + CC=gcc CFLAGS=-fno-lto tc-is-lto + [[ $? -eq 1 ]] + tend $? + + tbegin "tc-is-lto (gcc, -flto)" + CC=gcc CFLAGS=-flto tc-is-lto + [[ $? -eq 0 ]] + tend $? + + case $(gcc -dumpmachine) in + i*86*-gnu*|arm*-gnu*|powerpc-*-gnu) + tbegin "tc-has-64bit-time_t (_TIME_BITS=32)" + CC=gcc CFLAGS="-U_TIME_BITS -D_TIME_BITS=32" tc-has-64bit-time_t + [[ $? -eq 1 ]] + tend $? + + tbegin "tc-has-64bit-time_t (_TIME_BITS=64)" + CC=gcc CFLAGS="-U_FILE_OFFSET_BITS -U_TIME_BITS -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64" tc-has-64bit-time_t + [[ $? -eq 0 ]] + tend $? + ;; + *) + tbegin "tc-has-64bit-time_t" + CC=gcc tc-has-64bit-time_t + [[ $? -eq 0 ]] + tend $? + ;; + esac fi if type -P clang &>/dev/null; then @@ -232,6 +262,16 @@ if type -P clang &>/dev/null; then [[ $(CC=clang CFLAGS="--rtlib=${rtlib}" tc-get-c-rtlib) == ${rtlib} ]] tend $? done + + tbegin "tc-is-lto (clang, -fno-lto)" + CC=clang CFLAGS=-fno-lto tc-is-lto + [[ $? -eq 1 ]] + tend $? + + tbegin "tc-is-lto (clang, -flto)" + CC=clang CFLAGS=-flto tc-is-lto + [[ $? -eq 0 ]] + tend $? fi 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 100755 index 000000000000..cb2a92342c65 --- /dev/null +++ b/eclass/tests/version-funcs.sh @@ -0,0 +1,476 @@ +#!/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 +} + +# Return if we are being sourced +return 2>/dev/null + + +source tests-common.sh || exit + +teq() { + local expected=${1}; shift + + tbegin "${*} -> ${expected}" + local got=$("${@}") + [[ ${got} == ${expected} ]] + tend ${?} "returned: ${got}" +} + +teqr() { + local expected=$1; shift + tbegin "$* -> ${expected}" + "$@" + local ret=$? + [[ ${ret} -eq ${expected} ]] + tend $? "returned: ${ret}" +} + +txf() { + tbegin "XFAIL: ${*}" + local got=$("${@}" 2>&1) + [[ ${got} == die:* ]] + tend ${?} "function did not die" +} + +teq 1 ver_cut 1 1.2.3 +teq 1 ver_cut 1-1 1.2.3 +teq 1.2 ver_cut 1-2 1.2.3 +teq 2.3 ver_cut 2- 1.2.3 +teq 1.2.3 ver_cut 1- 1.2.3 +teq 3b ver_cut 3-4 1.2.3b_alpha4 +teq alpha ver_cut 5 1.2.3b_alpha4 +teq 1.2 ver_cut 1-2 .1.2.3 +teq .1.2 ver_cut 0-2 .1.2.3 +teq 2.3 ver_cut 2-3 1.2.3. +teq 2.3. ver_cut 2- 1.2.3. +teq 2.3. ver_cut 2-4 1.2.3. + +teq 1-2.3 ver_rs 1 - 1.2.3 +teq 1.2-3 ver_rs 2 - 1.2.3 +teq 1-2-3.4 ver_rs 1-2 - 1.2.3.4 +teq 1.2-3-4 ver_rs 2- - 1.2.3.4 +teq 1.2.3 ver_rs 2 . 1.2-3 +teq 1.2.3.a ver_rs 3 . 1.2.3a +teq 1.2-alpha-4 ver_rs 2-3 - 1.2_alpha4 +teq 1.23-b_alpha4 ver_rs 3 - 2 "" 1.2.3b_alpha4 +teq a1b_2-c-3-d4e5 ver_rs 3-5 _ 4-6 - a1b2c3d4e5 +teq .1-2.3 ver_rs 1 - .1.2.3 +teq -1.2.3 ver_rs 0 - .1.2.3 + +# truncating range +teq 1.2 ver_cut 0-2 1.2.3 +teq 2.3 ver_cut 2-5 1.2.3 +teq "" ver_cut 4 1.2.3 +teq "" ver_cut 0 1.2.3 +teq "" ver_cut 4- 1.2.3 +teq 1.2.3 ver_rs 0 - 1.2.3 +teq 1.2.3 ver_rs 3 . 1.2.3 +teq 1.2.3 ver_rs 3- . 1.2.3 +teq 1.2.3 ver_rs 3-5 . 1.2.3 + +txf ver_cut foo 1.2.3 +txf ver_rs -3 _ a1b2c3d4e5 +txf ver_rs 5-3 _ a1b2c3d4e5 + +# Tests from Portage's test_vercmp.py +teqr 0 ver_test 6.0 -gt 5.0 +teqr 0 ver_test 5.0 -gt 5 +teqr 0 ver_test 1.0-r1 -gt 1.0-r0 +teqr 0 ver_test 999999999999999999 -gt 999999999999999998 # 18 digits +teqr 0 ver_test 1.0.0 -gt 1.0 +teqr 0 ver_test 1.0.0 -gt 1.0b +teqr 0 ver_test 1b -gt 1 +teqr 0 ver_test 1b_p1 -gt 1_p1 +teqr 0 ver_test 1.1b -gt 1.1 +teqr 0 ver_test 12.2.5 -gt 12.2b +teqr 0 ver_test 4.0 -lt 5.0 +teqr 0 ver_test 5 -lt 5.0 +teqr 0 ver_test 1.0_pre2 -lt 1.0_p2 +teqr 0 ver_test 1.0_alpha2 -lt 1.0_p2 +teqr 0 ver_test 1.0_alpha1 -lt 1.0_beta1 +teqr 0 ver_test 1.0_beta3 -lt 1.0_rc3 +teqr 0 ver_test 1.001000000000000001 -lt 1.001000000000000002 +teqr 0 ver_test 1.00100000000 -lt 1.001000000000000001 +teqr 0 ver_test 999999999999999998 -lt 999999999999999999 +teqr 0 ver_test 1.01 -lt 1.1 +teqr 0 ver_test 1.0-r0 -lt 1.0-r1 +teqr 0 ver_test 1.0 -lt 1.0-r1 +teqr 0 ver_test 1.0 -lt 1.0.0 +teqr 0 ver_test 1.0b -lt 1.0.0 +teqr 0 ver_test 1_p1 -lt 1b_p1 +teqr 0 ver_test 1 -lt 1b +teqr 0 ver_test 1.1 -lt 1.1b +teqr 0 ver_test 12.2b -lt 12.2.5 +teqr 0 ver_test 4.0 -eq 4.0 +teqr 0 ver_test 1.0 -eq 1.0 +teqr 0 ver_test 1.0-r0 -eq 1.0 +teqr 0 ver_test 1.0 -eq 1.0-r0 +teqr 0 ver_test 1.0-r0 -eq 1.0-r0 +teqr 0 ver_test 1.0-r1 -eq 1.0-r1 +teqr 1 ver_test 1 -eq 2 +teqr 1 ver_test 1.0_alpha -eq 1.0_pre +teqr 1 ver_test 1.0_beta -eq 1.0_alpha +teqr 1 ver_test 1 -eq 0.0 +teqr 1 ver_test 1.0-r0 -eq 1.0-r1 +teqr 1 ver_test 1.0-r1 -eq 1.0-r0 +teqr 1 ver_test 1.0 -eq 1.0-r1 +teqr 1 ver_test 1.0-r1 -eq 1.0 +teqr 1 ver_test 1.0 -eq 1.0.0 +teqr 1 ver_test 1_p1 -eq 1b_p1 +teqr 1 ver_test 1b -eq 1 +teqr 1 ver_test 1.1b -eq 1.1 +teqr 1 ver_test 12.2b -eq 12.2 + +# A subset of tests from Paludis +teqr 0 ver_test 1.0_alpha -gt 1_alpha +teqr 0 ver_test 1.0_alpha -gt 1 +teqr 0 ver_test 1.0_alpha -lt 1.0 +teqr 0 ver_test 1.2.0.0_alpha7-r4 -gt 1.2_alpha7-r4 +teqr 0 ver_test 0001 -eq 1 +teqr 0 ver_test 01 -eq 001 +teqr 0 ver_test 0001.1 -eq 1.1 +teqr 0 ver_test 01.01 -eq 1.01 +teqr 0 ver_test 1.010 -eq 1.01 +teqr 0 ver_test 1.00 -eq 1.0 +teqr 0 ver_test 1.0100 -eq 1.010 +teqr 0 ver_test 1-r00 -eq 1-r0 + +# Additional tests +teqr 0 ver_test 0_rc99 -lt 0 +teqr 0 ver_test 011 -eq 11 +teqr 0 ver_test 019 -eq 19 +teqr 0 ver_test 1.2 -eq 001.2 +teqr 0 ver_test 1.2 -gt 1.02 +teqr 0 ver_test 1.2a -lt 1.2b +teqr 0 ver_test 1.2_pre1 -gt 1.2_pre1_beta2 +teqr 0 ver_test 1.2_pre1 -lt 1.2_pre1_p2 +teqr 0 ver_test 1.00 -lt 1.0.0 +teqr 0 ver_test 1.010 -eq 1.01 +teqr 0 ver_test 1.01 -lt 1.1 +teqr 0 ver_test 1.2_pre08-r09 -eq 1.2_pre8-r9 +teqr 0 ver_test 0 -lt 576460752303423488 # 2**59 +teqr 0 ver_test 0 -lt 9223372036854775808 # 2**63 + +# Bad number or ordering of arguments +txf ver_test 1 +txf ver_test 1 -lt 2 3 +txf ver_test -lt 1 2 + +# Bad operators +txf ver_test 1 "<" 2 +txf ver_test 1 lt 2 +txf ver_test 1 -foo 2 + +# Malformed versions +txf ver_test "" -ne 1 +txf ver_test 1. -ne 1 +txf ver_test 1ab -ne 1 +txf ver_test b -ne 1 +txf ver_test 1-r1_pre -ne 1 +txf ver_test 1-pre1 -ne 1 +txf ver_test 1_foo -ne 1 +txf ver_test 1_pre1.1 -ne 1 +txf ver_test 1-r1.0 -ne 1 +txf ver_test cvs.9999 -ne 9999 + +texit diff --git a/eclass/texlive-common.eclass b/eclass/texlive-common.eclass index 072581dde78e..36b90a327fde 100644 --- a/eclass/texlive-common.eclass +++ b/eclass/texlive-common.eclass @@ -42,6 +42,13 @@ _TEXLIVE_COMMON_ECLASS=1 # @CODE : "${CTAN_MIRROR_URL:="https://mirrors.ctan.org"}" +# @ECLASS_VARIABLE: TEXLIVE_SCRIPTS_W_FILE_EXT +# @DEFAULT_UNSET +# @DESCRIPTION: +# If set, contains a space separated list of script names that should be +# linked including their file extensions, i.e., without stripping +# potentially existing filename extensions from the link's name. + # @FUNCTION: texlive-common_handle_config_files # @DESCRIPTION: # Has to be called in src_install after having installed the files in ${D} @@ -160,8 +167,17 @@ etexlinks() { # Called by app-text/epspdf and texlive-module.eclass. dobin_texmf_scripts() { while [[ ${#} -gt 0 ]] ; do - local trg - trg=$(basename "${1}" | sed 's,\.[^/]*$,,' | tr '[:upper:]' '[:lower:]') + # -l: TexLive target links are always lowercase. + local -l trg + + # Get the basename of the script. + trg="${1##*/}" + + # Only strip the filename extensions if trg is not listed in TEXLIVE_SCRIPTS_W_FILE_EXT. + if ! has "${trg}" ${TEXLIVE_SCRIPTS_W_FILE_EXT}; then + trg="${trg%.*}" + fi + einfo "Installing ${1} as ${trg} bin wrapper" [[ -x ${ED}/usr/share/${1} ]] || die "Trying to install a non existing or non executable symlink to /usr/bin: ${1}" dosym "../share/${1}" "/usr/bin/${trg}" diff --git a/eclass/texlive-module.eclass b/eclass/texlive-module.eclass index 0daca41961ff..d7ec59c25a8a 100644 --- a/eclass/texlive-module.eclass +++ b/eclass/texlive-module.eclass @@ -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/tmpfiles.eclass b/eclass/tmpfiles.eclass index 39650401a6a0..63889a275fef 100644 --- a/eclass/tmpfiles.eclass +++ b/eclass/tmpfiles.eclass @@ -1,4 +1,4 @@ -# Copyright 2016-2022 Gentoo Authors +# Copyright 2016-2024 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 # @ECLASS: tmpfiles.eclass @@ -55,9 +55,13 @@ if [[ -z ${_TMPFILES_ECLASS} ]]; then _TMPFILES_ECLASS=1 -case "${EAPI}" in -5|6|7|8) ;; -*) die "API is undefined for EAPI ${EAPI}" ;; +case ${EAPI} in + 5|6) + ewarn "${CATEGORY}/${PF}: ebuild uses ${ECLASS} with deprecated EAPI ${EAPI}!" + ewarn "${CATEGORY}/${PF}: Support will be removed on 2024-10-08. Please port to newer EAPI." + ;; + 7|8) ;; + *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; esac # @ECLASS_VARIABLE: TMPFILES_OPTIONAL diff --git a/eclass/toolchain-funcs.eclass b/eclass/toolchain-funcs.eclass index cde84e6f34c8..66819996ea33 100644 --- a/eclass/toolchain-funcs.eclass +++ b/eclass/toolchain-funcs.eclass @@ -1,4 +1,4 @@ -# Copyright 2002-2023 Gentoo Authors +# Copyright 2002-2024 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 # @ECLASS: toolchain-funcs.eclass @@ -13,14 +13,18 @@ # in such a way that you can rely on the function always returning # something sane. +if [[ -z ${_TOOLCHAIN_FUNCS_ECLASS} ]]; then +_TOOLCHAIN_FUNCS_ECLASS=1 + case ${EAPI} in - 6|7|8) ;; + 6) + ewarn "${CATEGORY}/${PF}: ebuild uses ${ECLASS} with deprecated EAPI ${EAPI}!" + ewarn "${CATEGORY}/${PF}: Support will be removed on 2024-10-08. Please port to newer EAPI." + ;; + 7|8) ;; *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; esac -if [[ -z ${_TOOLCHAIN_FUNCS_ECLASS} ]]; then -_TOOLCHAIN_FUNCS_ECLASS=1 - inherit multilib # tc-getPROG <VAR [search vars]> <default> [tuple] @@ -251,7 +255,7 @@ tc-detect-is-softfloat() { case ${CTARGET:-${CHOST}} in # Avoid autodetection for bare-metal targets. bug #666896 - *-newlib|*-elf|*-eabi) + *-newlib|*-elf|*-eabi|arm64-apple-darwin*) return 1 ;; # arm-unknown-linux-gnueabi is ambiguous. We used to treat it as @@ -295,6 +299,8 @@ tc-tuple-is-softfloat() { # bare-metal targets have their defaults. bug #666896 *-newlib|*-elf|*-eabi) echo "no" ;; + arm64-apple-darwin*) + echo "no" ;; arm*) echo "yes" ;; *) @@ -445,6 +451,41 @@ econf_build() { tc-env_build econf_env "$@" } +# @FUNCTION: tc-ld-is-bfd +# @USAGE: [toolchain prefix] +# @DESCRIPTION: +# Return true if the current linker is set to GNU bfd. +tc-ld-is-bfd() { + local out + + # Ensure ld output is in English. + local -x LC_ALL=C + + # First check the linker directly. + out=$($(tc-getLD "$@") --version 2>&1) + if [[ ${out} != "GNU ld"* ]] ; then + return 1 + fi + + # Then see if they're selecting bfd via compiler flags. + # Note: We're assuming they're using LDFLAGS to hold the + # options and not CFLAGS/CXXFLAGS. + local base="${T}/test-tc-linker" + cat <<-EOF > "${base}.c" + int main(void) { return 0; } + EOF + out=$($(tc-getCC "$@") ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} -Wl,--version "${base}.c" -o "${base}" 2>&1) + rm -f "${base}"* + if [[ ! ${out} =~ .*^"GNU ld".* ]] ; then + return 1 + fi + + # It's bfd! + # We use positive logic here unlike tc-ld-is-gold and tc-ld-is-mold + # because LD might be bfd even if *FLAGS isn't. + return 0 +} + # @FUNCTION: tc-ld-is-gold # @USAGE: [toolchain prefix] # @DESCRIPTION: @@ -464,7 +505,7 @@ tc-ld-is-gold() { # Then see if they're selecting gold via compiler flags. # Note: We're assuming they're using LDFLAGS to hold the # options and not CFLAGS/CXXFLAGS. - local base="${T}/test-tc-gold" + local base="${T}/test-tc-linker" cat <<-EOF > "${base}.c" int main(void) { return 0; } EOF @@ -497,7 +538,7 @@ tc-ld-is-lld() { # Then see if they're selecting lld via compiler flags. # Note: We're assuming they're using LDFLAGS to hold the # options and not CFLAGS/CXXFLAGS. - local base="${T}/test-tc-lld" + local base="${T}/test-tc-linker" cat <<-EOF > "${base}.c" int main(void) { return 0; } EOF @@ -511,8 +552,43 @@ tc-ld-is-lld() { return 1 } + +# @FUNCTION: tc-ld-is-mold +# @USAGE: [toolchain prefix] +# @DESCRIPTION: +# Return true if the current linker is set to mold. +tc-ld-is-mold() { + local out + + # Ensure ld output is in English. + local -x LC_ALL=C + + # First check the linker directly. + out=$($(tc-getLD "$@") --version 2>&1) + if [[ ${out} == *"mold"* ]] ; then + return 0 + fi + + # Then see if they're selecting mold via compiler flags. + # Note: We're assuming they're using LDFLAGS to hold the + # options and not CFLAGS/CXXFLAGS. + local base="${T}/test-tc-linker" + cat <<-EOF > "${base}.c" + int main(void) { return 0; } + EOF + out=$($(tc-getCC "$@") ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} -Wl,--version "${base}.c" -o "${base}" 2>&1) + rm -f "${base}"* + if [[ ${out} == *"mold"* ]] ; then + return 0 + fi + + # No mold here! + return 1 +} + # @FUNCTION: tc-ld-disable-gold # @USAGE: [toolchain prefix] +# @DEPRECATED: tc-ld-force-bfd # @DESCRIPTION: # If the gold linker is currently selected, configure the compilation # settings so that we use the older bfd linker instead. @@ -523,11 +599,12 @@ tc-ld-disable-gold() { # @FUNCTION: tc-ld-force-bfd # @USAGE: [toolchain prefix] # @DESCRIPTION: -# If the gold or lld linker is currently selected, configure the compilation -# settings so that we use the bfd linker instead. +# If a linker other than bfd is currently selected, configure the compilation +# settings so that we use the bfd linker instead. This function should not +# be used for simple underlinking problems. This function is intended for use +# when a package is fragile and/or relies on bfd internals. tc-ld-force-bfd() { - if ! tc-ld-is-gold "$@" && ! tc-ld-is-lld "$@" ; then - # They aren't using gold or lld, so nothing to do! + if tc-ld-is-bfd "$@" ; then return fi @@ -542,6 +619,8 @@ tc-ld-force-bfd() { # Set up LDFLAGS to select bfd based on the gcc / clang version. if tc-is-gcc || tc-is-clang ; then + export CFLAGS="${CFLAGS} -fuse-ld=bfd" + export CXXFLAGS="${CXXFLAGS} -fuse-ld=bfd" export LDFLAGS="${LDFLAGS} -fuse-ld=bfd" fi } @@ -559,8 +638,9 @@ _tc-has-openmp() { int nthreads, tid, ret = 0; #pragma omp parallel private(nthreads, tid) { - tid = omp_get_thread_num(); - nthreads = omp_get_num_threads(); ret += tid + nthreads; + tid = omp_get_thread_num(); + nthreads = omp_get_num_threads(); + ret += tid + nthreads; } return ret; } @@ -626,7 +706,14 @@ tc-has-tls() { -*) die "Usage: tc-has-tls [-c|-l] [toolchain prefix]";; esac - : "${flags:=-fPIC -shared -Wl,-z,defs}" + case "${CHOST}" in + *-darwin*) + # bug #612370 + : ${flags:=-dynamiclib} + ;; + *) + : ${flags:=-fPIC -shared -Wl,-z,defs} + esac [[ $1 == -* ]] && shift $(tc-getCC "$@") ${flags} "${base}.c" -o "${base}" >&/dev/null local ret=$? @@ -645,6 +732,7 @@ tc-ninja_magic_to_arch() { [[ -z ${host} ]] && host=${CTARGET:-${CHOST}} case ${host} in + arm64*) echo arm64;; aarch64*) echo arm64;; alpha*) echo alpha;; arc*) echo arc;; @@ -1032,6 +1120,7 @@ gen_usr_ldscript() { [[ -z ${ED+set} ]] && local ED=${D%/}${EPREFIX}/ tc-is-static-only && return + use prefix && return # We only care about stuffing / for the native ABI, bug #479448 if [[ $(type -t multilib_is_native_abi) == "function" ]] ; then @@ -1234,6 +1323,7 @@ tc-get-build-ptr-size() { # @RETURN: Shell true if we are using LTO, shell false otherwise tc-is-lto() { local f="${T}/test-lto.o" + local ret=1 case $(tc-get-compiler-type) in clang) @@ -1241,14 +1331,25 @@ tc-is-lto() { # If LTO is used, clang will output bytecode and llvm-bcanalyzer # will run successfully. Otherwise, it will output plain object # file and llvm-bcanalyzer will exit with error. - llvm-bcanalyzer "${f}" &>/dev/null && return 0 + llvm-bcanalyzer "${f}" &>/dev/null && ret=0 ;; gcc) $(tc-getCC) ${CFLAGS} -c -o "${f}" -x c - <<<"" || die - [[ $($(tc-getREADELF) -S "${f}") == *.gnu.lto* ]] && return 0 + [[ $($(tc-getREADELF) -S "${f}") == *.gnu.lto* ]] && ret=0 ;; esac - return 1 + rm -f "${f}" || die + return "${ret}" +} + +# @FUNCTION: tc-has-64bit-time_t +# @RETURN: Shell true if time_t is at least 64 bits long, false otherwise +tc-has-64bit-time_t() { + $(tc-getCC) ${CFLAGS} ${CPPFLAGS} -c -x c - -o /dev/null <<-EOF &>/dev/null + #include <sys/types.h> + int test[sizeof(time_t) >= 8 ? 1 : -1]; + EOF + return $? } fi diff --git a/eclass/toolchain.eclass b/eclass/toolchain.eclass index 7d69f3b90e91..c03312be43ad 100644 --- a/eclass/toolchain.eclass +++ b/eclass/toolchain.eclass @@ -353,6 +353,7 @@ fi BDEPEND=" app-alternatives/yacc + sys-devel/binutils:* >=sys-devel/flex-2.5.4 nls? ( sys-devel/gettext ) test? ( @@ -526,7 +527,7 @@ get_gcc_src_uri() { GCC_SRC_URI="mirror://gcc/snapshots/${SNAPSHOT}/gcc-${SNAPSHOT}.tar.xz" else GCC_SRC_URI=" - mirror://gcc/gcc-${GCC_PV}/gcc-${GCC_RELEASE_VER}.tar.xz + mirror://gcc/releases/gcc-${GCC_PV}/gcc-${GCC_RELEASE_VER}.tar.xz mirror://gnu/gcc/gcc-${GCC_PV}/gcc-${GCC_RELEASE_VER}.tar.xz " fi @@ -589,7 +590,7 @@ toolchain_fetch_git_patches() { mkdir "${WORKDIR}"/patch || die mv "${WORKDIR}"/patch.tmp/${PATCH_GCC_VER}/gentoo/* "${WORKDIR}"/patch || die - if [[ -n ${MUSL_VER} || -d "${WORKDIR}"/musl ]] && [[ ${CTARGET} == *musl* ]] ; then + if [[ -z ${MUSL_VER} || -d "${WORKDIR}"/musl ]] && [[ ${CTARGET} == *musl* ]] ; then mkdir "${WORKDIR}"/musl || die mv "${WORKDIR}"/patch.tmp/${PATCH_GCC_VER}/musl/* "${WORKDIR}"/musl || die fi @@ -1214,7 +1215,14 @@ toolchain_src_configure() { # - https://git.musl-libc.org/cgit/musl/tree/INSTALL # - bug #704784 # - https://gcc.gnu.org/PR93157 - [[ ${CTARGET} == powerpc64-*-musl ]] && confgcc+=( --with-abi=elfv2 ) + # musl additionally does not support libquadmath. See: + # - https://gcc.gnu.org/PR116007 + [[ ${CTARGET} == powerpc64-*-musl ]] && confgcc+=( + --with-abi=elfv2 + --disable-libquadmath + --disable-libquadmath-support + --with-long-double-128=no + ) if in_iuse ieee-long-double; then # musl requires 64-bit long double, not IBM double-double or IEEE quad. @@ -1654,9 +1662,6 @@ gcc_do_filter_flags() { # New in GCC 14. filter-flags -Walloc-size - else - # Makes things painfully slow and no real benefit for the compiler. - append-flags $(test-flags-CC -fno-harden-control-flow-redundancy) fi # Please use USE=lto instead (bug #906007). @@ -1894,7 +1899,6 @@ gcc_do_make() { #---->> src_test <<---- # TODO: add JIT testing -# TODO: add multilib testing toolchain_src_test() { # GCC's testsuite is a special case. # @@ -1917,11 +1921,79 @@ toolchain_src_test() { local -x LD_PRELOAD= # Controls running expensive tests in e.g. the torture testsuite. + # Note that 'TEST', not 'TESTS', is correct here as it's a GCC + # testsuite variable, not ours. local -x GCC_TEST_RUN_EXPENSIVE=1 - # nonfatal here as we die if the comparison below fails. Also, note that - # the exit code of targets other than 'check' may be unreliable. - nonfatal emake -C "${WORKDIR}"/build -k "${GCC_TESTS_CHECK_TARGET}" RUNTESTFLAGS="${GCC_TESTS_RUNTESTFLAGS}" + # Use a subshell to allow meddling with flags just for the testsuite + ( + # Workaround our -Wformat-security default which breaks + # various tests as it adds unexpected warning output. + GCC_TESTS_CFLAGS+=" -Wno-format-security -Wno-format" + GCC_TESTS_CXXFLAGS+=" -Wno-format-security -Wno-format" + + # Workaround our -Wtrampolines default which breaks + # tests too. + GCC_TESTS_CFLAGS+=" -Wno-trampolines" + GCC_TESTS_CXXFLAGS+=" -Wno-trampolines" + # A handful of Ada (and objc++?) tests need an executable stack + GCC_TESTS_LDFLAGS+=" -Wl,--no-warn-execstack" + # Avoid confusing tests like Fortran/C interop ones where + # CFLAGS are used. + GCC_TESTS_CFLAGS+=" -Wno-complain-wrong-lang" + GCC_TESTS_CXXFLAGS+=" -Wno-complain-wrong-lang" + + # Issues with Ada tests: + # gnat.dg/align_max.adb + # gnat.dg/trampoline4.adb + # + # A handful of Ada tests use -fstack-check and conflict + # with -fstack-clash-protection. + # + # TODO: This isn't ideal given it obv. affects codegen + # and we want to be sure it works. + GCC_TESTS_CFLAGS+=" -fno-stack-clash-protection" + GCC_TESTS_CXXFLAGS+=" -fno-stack-clash-protection" + + # configure defaults to '-O2 -g' and some tests expect it + # accordingly. + GCC_TESTS_CFLAGS+=" -g" + + # TODO: Does this handle s390 (-m31) correctly? + # TODO: What if there are multiple ABIs like x32 too? + # XXX: Disabled until validate_failures.py can handle 'variants' + # XXX: https://gcc.gnu.org/PR116260 + #is_multilib && GCC_TESTS_RUNTESTFLAGS+=" --target_board=unix{,-m32}" + + # nonfatal here as we die if the comparison below fails. Also, note that + # the exit code of targets other than 'check' may be unreliable. + # + # CFLAGS and so on are repeated here because of tests vs building test + # deps like libbacktrace. + # + # TODO: Should we try pass in the regular user flags for the non-RUNTESTFLAGS + # instances below for building e.g. libbacktrace? + nonfatal emake -C "${WORKDIR}"/build -k "${GCC_TESTS_CHECK_TARGET}" \ + RUNTESTFLAGS=" \ + ${GCC_TESTS_RUNTESTFLAGS} \ + CFLAGS_FOR_TARGET='${GCC_TESTS_CFLAGS_FOR_TARGET:-${GCC_TESTS_CFLAGS}}' \ + CXXFLAGS_FOR_TARGET='${GCC_TESTS_CXXFLAGS_FOR_TARGET:-${GCC_TESTS_CXXFLAGS}}' \ + LDFLAGS_FOR_TARGET='${TEST_LDFLAGS_FOR_TARGET:-${GCC_TESTS_LDFLAGS}}' \ + CFLAGS='${GCC_TESTS_CFLAGS}' \ + CXXFLAGS='${GCC_TESTS_CXXFLAGS}' \ + FCFLAGS='${GCC_TESTS_FCFLAGS}' \ + FFLAGS='${GCC_TESTS_FFLAGS}' \ + LDFLAGS='${GCC_TESTS_LDFLAGS}' \ + " \ + CFLAGS_FOR_TARGET="${GCC_TESTS_CFLAGS_FOR_TARGET:-${GCC_TESTS_CFLAGS}}" \ + CXXFLAGS_FOR_TARGET="${GCC_TESTS_CXXFLAGS_FOR_TARGET:-${GCC_TESTS_CXXFLAGS}}" \ + LDFLAGS_FOR_TARGET="${GCC_TESTS_LDFLAGS_FOR_TARGET:-${GCC_TESTS_LDFLAGS}}" \ + CFLAGS="${GCC_TESTS_CFLAGS}" \ + CXXFLAGS="${GCC_TESTS_CXXFLAGS}" \ + FCFLAGS="${GCC_TESTS_FCFLAGS}" \ + FFLAGS="${GCC_TESTS_FFLAGS}" \ + LDFLAGS="${GCC_TESTS_LDFLAGS}" + ) # Produce an updated failure manifest. einfo "Generating a new failure manifest ${T}/${CHOST}.xfail" @@ -1975,7 +2047,7 @@ toolchain_src_test() { eerror "GCC_TESTS_IGNORE_NO_BASELINE is set, ignoring test result and creating a new baseline..." elif [[ -n ${GCC_TESTS_REGEN_BASELINE} ]] ; then eerror "GCC_TESTS_REGEN_BASELINE is set, ignoring test result and creating using a new baseline..." - elif [[ ${ret} != 0 ]]; then + elif [[ ${ret} != 0 ]] ; then eerror "(Set GCC_TESTS_IGNORE_NO_BASELINE=1 to make this non-fatal and generate a baseline.)" die "Tests failed (failures occurred with no reference data)" fi diff --git a/eclass/tree-sitter-grammar.eclass b/eclass/tree-sitter-grammar.eclass index b5e020065547..10f29b8a0835 100644 --- a/eclass/tree-sitter-grammar.eclass +++ b/eclass/tree-sitter-grammar.eclass @@ -4,7 +4,6 @@ # @ECLASS: tree-sitter-grammar.eclass # @MAINTAINER: # Matthew Smith <matthew@gentoo.org> -# Nick Sarnie <sarnex@gentoo.org> # Arthur Zamarin <arthurzam@gentoo.org> # @AUTHOR: # Matthew Smith <matthew@gentoo.org> @@ -48,7 +47,7 @@ for _BINDING in "${TS_BINDINGS[@]}"; do DISTUTILS_EXT=1 DISTUTILS_OPTIONAL=1 DISTUTILS_USE_PEP517=setuptools - PYTHON_COMPAT=( python3_{10..12} ) + PYTHON_COMPAT=( python3_{10..13} ) inherit distutils-r1 IUSE+=" python" @@ -163,6 +162,8 @@ tree-sitter-grammar_src_compile() { if [[ -f "${S}/pyproject.toml" ]]; then sed -e "/SONAME_MINOR :=/s/:=.*$/:= $(_get_tsg_abi_ver)/" -i "${S}/Makefile" || die emake \ + CC="$(tc-getCC)" \ + AR="$(tc-getAR)" \ STRIP="" \ PREFIX="${EPREFIX}/usr" \ LIBDIR="${EPREFIX}/usr/$(get_libdir)" diff --git a/eclass/udev.eclass b/eclass/udev.eclass index ac94f98221aa..7fd99cbba8b0 100644 --- a/eclass/udev.eclass +++ b/eclass/udev.eclass @@ -1,4 +1,4 @@ -# Copyright 1999-2022 Gentoo Authors +# Copyright 1999-2024 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 # @ECLASS: udev.eclass @@ -36,14 +36,18 @@ # } # @CODE +if [[ -z ${_UDEV_ECLASS} ]]; then +_UDEV_ECLASS=1 + case ${EAPI} in - 5|6|7|8) ;; + 6) + ewarn "${CATEGORY}/${PF}: ebuild uses ${ECLASS} with deprecated EAPI ${EAPI}!" + ewarn "${CATEGORY}/${PF}: Support will be removed on 2024-10-08. Please port to newer EAPI." + ;; + 7|8) ;; *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; esac -if [[ -z ${_UDEV_ECLASS} ]]; then -_UDEV_ECLASS=1 - inherit toolchain-funcs if [[ ${EAPI} == [56] ]]; then diff --git a/eclass/unpacker.eclass b/eclass/unpacker.eclass index 2957ca02d3f4..91520a36d16a 100644 --- a/eclass/unpacker.eclass +++ b/eclass/unpacker.eclass @@ -4,7 +4,7 @@ # @ECLASS: unpacker.eclass # @MAINTAINER: # base-system@gentoo.org -# @SUPPORTED_EAPIS: 6 7 8 +# @SUPPORTED_EAPIS: 7 8 # @BLURB: helpers for extraneous file formats and consistent behavior across EAPIs # @DESCRIPTION: # Some extraneous file formats are not part of PMS, or are only in certain @@ -16,7 +16,7 @@ # - support partial unpacks? case ${EAPI} in - 6|7|8) ;; + 7|8) ;; *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; esac @@ -430,10 +430,7 @@ _unpacker_get_decompressor() { echo "xz -T$(makeopts_jobs) -dc" ;; *.lz) find_lz_unpacker() { - local has_version_arg="-b" - - [[ ${EAPI} == 6 ]] && has_version_arg="--host-root" - if has_version "${has_version_arg}" ">=app-arch/xz-utils-5.4.0" ; then + if has_version -b ">=app-arch/xz-utils-5.4.0" ; then echo xz return fi @@ -537,7 +534,7 @@ _unpacker() { esac # 7z, rar and lha/lzh are handled by package manager in EAPI < 8 - if [[ ${EAPI} != [67] ]]; then + if [[ ${EAPI} != 7 ]]; then case ${m} in *.7z) arch="unpack_7z" ;; diff --git a/eclass/vcs-clean.eclass b/eclass/vcs-clean.eclass index e4c61ac7164a..719bdec17676 100644 --- a/eclass/vcs-clean.eclass +++ b/eclass/vcs-clean.eclass @@ -1,4 +1,4 @@ -# Copyright 1999-2022 Gentoo Authors +# Copyright 1999-2024 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 # @ECLASS: vcs-clean.eclass @@ -9,14 +9,18 @@ # @SUPPORTED_EAPIS: 5 6 7 8 # @BLURB: helper functions to remove VCS directories +if [[ -z ${_VCS_CLEAN_ECLASS} ]] ; then +_VCS_CLEAN_ECLASS=1 + case ${EAPI} in - 5|6|7|8) ;; + 5|6) + ewarn "${CATEGORY}/${PF}: ebuild uses ${ECLASS} with deprecated EAPI ${EAPI}!" + ewarn "${CATEGORY}/${PF}: Support will be removed on 2024-10-08. Please port to newer EAPI." + ;; + 7|8) ;; *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; esac -if [[ -z ${_VCS_CLEAN_ECLASS} ]] ; then -_VCS_CLEAN_ECLASS=1 - # @FUNCTION: ecvs_clean # @USAGE: [list of dirs] # @DESCRIPTION: diff --git a/eclass/vcs-snapshot.eclass b/eclass/vcs-snapshot.eclass index 1b7299b92a3b..0279e89ec3ab 100644 --- a/eclass/vcs-snapshot.eclass +++ b/eclass/vcs-snapshot.eclass @@ -1,10 +1,10 @@ -# Copyright 1999-2022 Gentoo Authors +# Copyright 1999-2024 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 # @ECLASS: vcs-snapshot.eclass # @MAINTAINER: # mgorny@gentoo.org -# @SUPPORTED_EAPIS: 6 7 8 +# @SUPPORTED_EAPIS: 7 8 # @BLURB: support eclass for unpacking VCS snapshot tarballs # @DESCRIPTION: # THIS ECLASS IS NOT NECESSARY FOR MODERN GITHUB AND GITLAB SNAPSHOTS. @@ -43,7 +43,6 @@ # in ${WORKDIR}/${P} and ${WORKDIR}/${P}-otherstuff respectively. case ${EAPI} in - 6) inherit eqawarn ;; 7|8) ;; *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; esac @@ -103,13 +102,10 @@ vcs-snapshot_src_unpack() { done if [[ ! ${renamed_any} ]]; then - local w=eerror - [[ ${EAPI} == 6 ]] && w=eqawarn - "${w}" "${FUNCNAME} did not find any archives that needed renaming." - "${w}" "Please verify that its usage is really necessary, and remove" - "${w}" "the inherit if it is not." - - [[ ${w} == eerror ]] && die "${FUNCNAME}: Unnecessary usage detected" + eerror "${FUNCNAME} did not find any archives that needed renaming." + eerror "Please verify that its usage is really necessary, and remove" + eerror "the inherit if it is not." + die "${FUNCNAME}: Unnecessary usage detected" fi } diff --git a/eclass/vdr-plugin-2.eclass b/eclass/vdr-plugin-2.eclass index 8f56511032c8..dc70ca7c5761 100644 --- a/eclass/vdr-plugin-2.eclass +++ b/eclass/vdr-plugin-2.eclass @@ -160,7 +160,6 @@ vdr_create_header_checksum_file() { # Plugins failed on compile with wrong path of libsi includes, # this can be fixed by 'function + space separated list of files' fix_vdr_libsi_include() { - eqawarn "QA Notice: Fixing include of libsi-headers" local f for f; do sed -i "${f}" \ @@ -245,7 +244,7 @@ vdr_gettext_missing() { local GETTEXT_MISSING=$( grep xgettext Makefile ) if [[ -z ${GETTEXT_MISSING} ]]; then - eqawarn "QA Notice: Plugin isn't converted to gettext handling!" + einfo "Notice: Plugin isn't converted to gettext handling!" fi } @@ -287,7 +286,7 @@ vdr_linguas_support() { || die "sed failed for Linguas" done - strip-linguas ${PLUGIN_LINGUAS} en + strip-linguas ${PLUGIN_LINGUAS} } # @FUNCTION: vdr_i18n @@ -306,11 +305,11 @@ vdr_i18n() { if [[ -n ${I18N_OBJECT} ]]; then if [[ "${KEEP_I18NOBJECT:-no}" = "yes" ]]; then - eqawarn "QA Notice: Forced to keep i18n.o" + einfo "Notice: Forced to keep i18n.o" else sed -i "s:i18n.o::g" Makefile \ || die "sed failed to remove i18n from Makefile" - eqawarn "QA Notice: OBJECT i18n.o found, removed per sed" + einfo "Notice: OBJECT i18n.o found, removed per sed" fi fi @@ -318,7 +317,7 @@ vdr_i18n() { if [[ -n ${I18N_STRING} ]]; then sed -i "s:^extern[[:space:]]*const[[:space:]]*tI18nPhrase://static const tI18nPhrase:" i18n.h \ || die "sed failed to replace tI18nPhrase" - eqawarn "QA Notice: obsolete tI18nPhrase found, disabled per sed, please recheck" + einfo "Notice: obsolete tI18nPhrase found, disabled per sed" fi } @@ -337,7 +336,7 @@ vdr_remove_i18n_include() { || die "sed failed to remove i18n_include" done - eqawarn "QA Notice: removed i18n.h include in ${@}" + einfo "Notice: removed i18n.h include in ${@}" } # @FUNCTION: vdr-plugin-2_print_enable_command @@ -568,7 +567,7 @@ vdr-plugin-2_src_install() { DESTDIR="${D%/}" \ || die "emake install (makefile target) failed" else - eqawarn "QA Notice: Plugin use still the old Makefile handling" + einfo "Notice: Plugin use still the old Makefile handling" insinto "${VDR_PLUGIN_DIR}" doins libvdr-*.so.* fi diff --git a/eclass/versionator.eclass b/eclass/versionator.eclass index 8a1066a0fd30..1e491860b6ca 100644 --- a/eclass/versionator.eclass +++ b/eclass/versionator.eclass @@ -1,6 +1,7 @@ # Copyright 1999-2020 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 +# @DEAD # @ECLASS: versionator.eclass # @MAINTAINER: # Jonathan Callen <jcallen@gentoo.org> diff --git a/eclass/vim-doc.eclass b/eclass/vim-doc.eclass index 119ce793071d..f20f7397cf65 100644 --- a/eclass/vim-doc.eclass +++ b/eclass/vim-doc.eclass @@ -1,4 +1,4 @@ -# Copyright 1999-2022 Gentoo Authors +# Copyright 1999-2024 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 # @ECLASS: vim-doc.eclass @@ -16,13 +16,17 @@ # DEPEND in vim-plugin or by whatever version of vim is being # installed by the eclass. +if [[ ! ${_VIM_DOC_ECLASS} ]] ; then + case ${EAPI} in - 6|7|8) ;; + 6) + ewarn "${CATEGORY}/${PF}: ebuild uses ${ECLASS} with deprecated EAPI ${EAPI}!" + ewarn "${CATEGORY}/${PF}: Support will be removed on 2024-10-08. Please port to newer EAPI." + ;; + 7|8) ;; *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; esac -if [[ ! ${_VIM_DOC_ECLASS} ]] ; then - # @FUNCTION: update_vim_helptags # @USAGE: # @DESCRIPTION: diff --git a/eclass/vim-plugin.eclass b/eclass/vim-plugin.eclass index ee4f1b6e0f81..b2ae0cb9e4c3 100644 --- a/eclass/vim-plugin.eclass +++ b/eclass/vim-plugin.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: vim-plugin.eclass @@ -12,14 +12,18 @@ # which is read automatically by vim. The only exception is # documentation, for which we make a special case via vim-doc.eclass. +if [[ -z ${_VIM_PLUGIN_ECLASS} ]]; then +_VIM_PLUGIN_ECLASS=1 + case ${EAPI} in - 6|7|8) ;; + 6) + ewarn "${CATEGORY}/${PF}: ebuild uses ${ECLASS} with deprecated EAPI ${EAPI}!" + ewarn "${CATEGORY}/${PF}: Support will be removed on 2024-10-08. Please port to newer EAPI." + ;; + 7|8) ;; *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; esac -if [[ -z ${_VIM_PLUGIN_ECLASS} ]]; then -_VIM_PLUGIN_ECLASS=1 - inherit vim-doc [[ ${EAPI} != [67] ]] && _DEFINE_VIM_PLUGIN_SRC_PREPARE=true diff --git a/eclass/vim-spell.eclass b/eclass/vim-spell.eclass index 607771ae8035..57bcb0dc8021 100644 --- a/eclass/vim-spell.eclass +++ b/eclass/vim-spell.eclass @@ -62,14 +62,18 @@ # spell files. It's best to let upstream know if you've generated spell files # for another language rather than keeping them Gentoo-specific. +if [[ -z ${_VIM_SPELL_ECLASS} ]] ; then +_VIM_SPELL_ECLASS=1 + case ${EAPI} in - 6|7|8) ;; + 6) + ewarn "${CATEGORY}/${PF}: ebuild uses ${ECLASS} with deprecated EAPI ${EAPI}!" + ewarn "${CATEGORY}/${PF}: Support will be removed on 2024-10-08. Please port to newer EAPI." + ;; + 7|8) ;; *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; esac -if [[ -z ${_VIM_SPELL_ECLASS} ]] ; then -_VIM_SPELL_ECLASS=1 - SRC_URI="mirror://gentoo/${P}.tar.bz2" SLOT="0" diff --git a/eclass/virtualx.eclass b/eclass/virtualx.eclass index 6e77cd662bdd..07d303899582 100644 --- a/eclass/virtualx.eclass +++ b/eclass/virtualx.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: virtualx.eclass @@ -9,14 +9,18 @@ # @SUPPORTED_EAPIS: 6 7 8 # @BLURB: This eclass can be used for packages that need a working X environment to build. +if [[ -z ${_VIRTUALX_ECLASS} ]]; then +_VIRTUALX_ECLASS=1 + case ${EAPI} in - 6|7|8) ;; + 6) + ewarn "${CATEGORY}/${PF}: ebuild uses ${ECLASS} with deprecated EAPI ${EAPI}!" + ewarn "${CATEGORY}/${PF}: Support will be removed on 2024-10-08. Please port to newer EAPI." + ;; + 7|8) ;; *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; esac -if [[ -z ${_VIRTUALX_ECLASS} ]]; then -_VIRTUALX_ECLASS=1 - # @ECLASS_VARIABLE: VIRTUALX_REQUIRED # @PRE_INHERIT # @DESCRIPTION: @@ -113,6 +117,7 @@ virtx() { export XAUTHORITY= einfo "Starting Xvfb ..." + addpredict /dev/dri/ # Needed for Xvfb w/ >=mesa-24.2.0 debug-print "${FUNCNAME}: Xvfb -displayfd 1 ${xvfbargs[*]}" local logfile=${T}/Xvfb.log diff --git a/eclass/webapp.eclass b/eclass/webapp.eclass index 5b091c84851f..e8bc127e1b96 100644 --- a/eclass/webapp.eclass +++ b/eclass/webapp.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: webapp.eclass @@ -10,14 +10,18 @@ # The webapp eclass contains functions to handle web applications with # webapp-config. Part of the implementation of GLEP #11 +if [[ -z ${_WEBAPP_ECLASS} ]]; then +_WEBAPP_ECLASS=1 + case ${EAPI} in - 6|7|8) ;; + 6) + ewarn "${CATEGORY}/${PF}: ebuild uses ${ECLASS} with deprecated EAPI ${EAPI}!" + ewarn "${CATEGORY}/${PF}: Support will be removed on 2024-10-08. Please port to newer EAPI." + ;; + 7|8) ;; *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; esac -if [[ -z ${_WEBAPP_ECLASS} ]]; then -_WEBAPP_ECLASS=1 - # @ECLASS_VARIABLE: WEBAPP_DEPEND # @DESCRIPTION: # An ebuild should use WEBAPP_DEPEND if a custom DEPEND needs to be built, most diff --git a/eclass/wrapper.eclass b/eclass/wrapper.eclass index 8d3d273d81c6..a62bb51d0fe7 100644 --- a/eclass/wrapper.eclass +++ b/eclass/wrapper.eclass @@ -1,4 +1,4 @@ -# Copyright 1999-2022 Gentoo Authors +# Copyright 1999-2024 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 # @ECLASS: wrapper.eclass @@ -7,15 +7,19 @@ # @SUPPORTED_EAPIS: 5 6 7 8 # @BLURB: create a shell wrapper script +if [[ -z ${_WRAPPER_ECLASS} ]]; then +_WRAPPER_ECLASS=1 + case ${EAPI} in - 5|6|7|8) ;; + 5|6) + ewarn "${CATEGORY}/${PF}: ebuild uses ${ECLASS} with deprecated EAPI ${EAPI}!" + ewarn "${CATEGORY}/${PF}: Support will be removed on 2024-10-08. Please port to newer EAPI." + ;; + 7|8) ;; *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; esac -if [[ -z ${_WRAPPER_ECLASS} ]]; then -_WRAPPER_ECLASS=1 - -# @FUNCTION: make_wrapper +# FUNCTION: make_wrapper # @USAGE: <wrapper> <target> [chdir] [libpaths] [installpath] # @DESCRIPTION: # Create a shell wrapper script named wrapper in installpath diff --git a/eclass/xdg-utils.eclass b/eclass/xdg-utils.eclass index 34535a129e33..84f88eee18fc 100644 --- a/eclass/xdg-utils.eclass +++ b/eclass/xdg-utils.eclass @@ -1,4 +1,4 @@ -# Copyright 2004-2023 Gentoo Authors +# Copyright 2004-2024 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 # @ECLASS: xdg-utils.eclass @@ -18,7 +18,11 @@ # * XDG mime information database management case ${EAPI} in - 5|6|7|8) ;; + 5|6) + ewarn "${CATEGORY}/${PF}: ebuild uses ${ECLASS} with deprecated EAPI ${EAPI}!" + ewarn "${CATEGORY}/${PF}: Support will be removed on 2024-10-08. Please port to newer EAPI." + ;; + 7|8) ;; *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; esac diff --git a/eclass/xdg.eclass b/eclass/xdg.eclass index 14c56047af45..6af4b91875fc 100644 --- a/eclass/xdg.eclass +++ b/eclass/xdg.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: xdg.eclass @@ -13,14 +13,18 @@ # Utility eclass to update the desktop, icon and shared mime info as laid # out in the freedesktop specs & implementations +if [[ -z ${_XDG_ECLASS} ]]; then +_XDG_ECLASS=1 + case ${EAPI} in - 6|7|8) ;; + 6) + ewarn "${CATEGORY}/${PF}: ebuild uses ${ECLASS} with deprecated EAPI ${EAPI}!" + ewarn "${CATEGORY}/${PF}: Support will be removed on 2024-10-08. Please port to newer EAPI." + ;; + 7|8) ;; *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; esac -if [[ -z ${_XDG_ECLASS} ]]; then -_XDG_ECLASS=1 - inherit xdg-utils # Avoid dependency loop as both depend on glib-2 |