From 752d6256e5204b958b0ef7905675a940b5e9172f Mon Sep 17 00:00:00 2001 From: V3n3RiX Date: Thu, 12 May 2022 16:42:50 +0300 Subject: gentoo resync : 12.05.2022 --- eclass/Manifest.gz | Bin 35950 -> 36136 bytes eclass/acct-group.eclass | 4 +- eclass/acct-user.eclass | 53 +++- eclass/apache-2.eclass | 1 - eclass/autotools.eclass | 8 +- eclass/cmake-utils.eclass | 5 +- eclass/cmake.eclass | 5 +- eclass/dist-kernel-utils.eclass | 3 + eclass/distutils-r1.eclass | 370 ++++++++++++++++++-------- eclass/edo.eclass | 48 ++++ eclass/elisp-common.eclass | 19 +- eclass/elisp.eclass | 4 +- eclass/gnuconfig.eclass | 6 +- eclass/java-pkg-simple.eclass | 9 +- eclass/java-utils-2.eclass | 94 +++---- eclass/kernel-2.eclass | 28 +- eclass/kernel-build.eclass | 16 +- eclass/kernel-install.eclass | 5 +- eclass/llvm.org.eclass | 20 +- eclass/ltprune.eclass | 4 +- eclass/meson.eclass | 16 +- eclass/multiprocessing.eclass | 11 +- eclass/ninja-utils.eclass | 34 ++- eclass/python-utils-r1.eclass | 24 +- eclass/qmake-utils.eclass | 55 ++-- eclass/qt5-build.eclass | 60 +---- eclass/ruby-fakegem.eclass | 9 +- eclass/ruby-ng.eclass | 1 + eclass/tests/multiprocessing_makeopts_jobs.sh | 15 +- eclass/tests/python-utils-r1.sh | 142 +++++----- eclass/tests/qmail.sh | 3 +- eclass/toolchain.eclass | 58 ++-- eclass/tree-sitter-grammar.eclass | 4 +- eclass/user-info.eclass | 35 ++- eclass/user.eclass | 128 +++++++-- 35 files changed, 846 insertions(+), 451 deletions(-) create mode 100644 eclass/edo.eclass (limited to 'eclass') diff --git a/eclass/Manifest.gz b/eclass/Manifest.gz index b699e64294d3..87dc65282eb3 100644 Binary files a/eclass/Manifest.gz and b/eclass/Manifest.gz differ diff --git a/eclass/acct-group.eclass b/eclass/acct-group.eclass index 56b76ba1885b..3d02e4f713b4 100644 --- a/eclass/acct-group.eclass +++ b/eclass/acct-group.eclass @@ -1,4 +1,4 @@ -# Copyright 2019-2021 Gentoo Authors +# Copyright 2019-2022 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 # @ECLASS: acct-group.eclass @@ -77,7 +77,7 @@ readonly ACCT_GROUP_NAME # << Boilerplate ebuild variables >> : ${DESCRIPTION:="System group: ${ACCT_GROUP_NAME}"} : ${SLOT:=0} -: ${KEYWORDS:=alpha amd64 arm arm64 hppa ia64 m68k ~mips ppc ppc64 ~riscv s390 sparc x86 ~x64-cygwin ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris} +: ${KEYWORDS:=alpha amd64 arm arm64 hppa ia64 ~loong m68k ~mips ppc ppc64 ~riscv s390 sparc x86 ~x64-cygwin ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris} S=${WORKDIR} diff --git a/eclass/acct-user.eclass b/eclass/acct-user.eclass index f2aaefc2ee39..c87b27f3ccaa 100644 --- a/eclass/acct-user.eclass +++ b/eclass/acct-user.eclass @@ -141,7 +141,7 @@ readonly ACCT_USER_NAME # << Boilerplate ebuild variables >> : ${DESCRIPTION:="System user: ${ACCT_USER_NAME}"} : ${SLOT:=0} -: ${KEYWORDS:=alpha amd64 arm arm64 hppa ia64 m68k ~mips ppc ppc64 ~riscv s390 sparc x86 ~x64-cygwin ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris} +: ${KEYWORDS:=alpha amd64 arm arm64 hppa ia64 ~loong m68k ~mips ppc ppc64 ~riscv s390 sparc x86 ~x64-cygwin ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris} S=${WORKDIR} @@ -195,8 +195,15 @@ eislocked() { *) # NB: 'no password' and 'locked' are indistinguishable # but we also expire the account which is more clear - [[ $(getent shadow "$1" | cut -d: -f2) == '!'* ]] && - [[ $(getent shadow "$1" | cut -d: -f8) == 1 ]] + local shadow + if [[ -n "${ROOT}" ]]; then + shadow=$(grep "^$1:" "${ROOT}/etc/shadow") + else + shadow=$(getent shadow "$1") + fi + + [[ $( echo ${shadow} | cut -d: -f2) == '!'* ]] && + [[ $(echo ${shadow} | cut -d: -f8) == 1 ]] ;; esac } @@ -223,14 +230,22 @@ elockuser() { eislocked "$1" [[ $? -eq 0 ]] && return 0 + local opts + [[ -n ${ROOT} ]] && opts=( --prefix "${ROOT}" ) + case ${CHOST} in *-freebsd*|*-dragonfly*) - pw lock "$1" || die "Locking account $1 failed" - pw user mod "$1" -e 1 || die "Expiring account $1 failed" + pw lock "${opts[@]}" "$1" || die "Locking account $1 failed" + pw user mod "${opts[@]}" "$1" -e 1 || die "Expiring account $1 failed" ;; *-netbsd*) - usermod -e 1 -C yes "$1" || die "Locking account $1 failed" + if [[ -n "${ROOT}" ]]; then + ewarn "NetBSD's usermod does not support --prefix option." + ewarn "Please use: usermod ${opts[@]} -e 1 -C yes \"$1\" in a chroot" + else + usermod "${opts[@]}" -e 1 -C yes "$1" || die "Locking account $1 failed" + fi ;; *-openbsd*) @@ -238,7 +253,7 @@ elockuser() { ;; *) - usermod -e 1 -L "$1" || die "Locking account $1 failed" + usermod "${opts[@]}" -e 1 -L "$1" || die "Locking account $1 failed" ;; esac @@ -266,14 +281,22 @@ eunlockuser() { eislocked "$1" [[ $? -eq 1 ]] && return 0 + local opts + [[ -n ${ROOT} ]] && opts=( --prefix "${ROOT}" ) + case ${CHOST} in *-freebsd*|*-dragonfly*) - pw user mod "$1" -e 0 || die "Unexpiring account $1 failed" - pw unlock "$1" || die "Unlocking account $1 failed" + pw user mod "${opts[@]}" "$1" -e 0 || die "Unexpiring account $1 failed" + pw unlock "${opts[@]}" "$1" || die "Unlocking account $1 failed" ;; *-netbsd*) - usermod -e 0 -C no "$1" || die "Unlocking account $1 failed" + if [[ -n "${ROOT}" ]]; then + ewarn "NetBSD's usermod does not support --prefix option." + ewarn "Please use: \"usermod ${opts[@]} -e 0 -C no $1\" in a chroot" + else + usermod "${opts[@]}" -e 0 -C no "$1" || die "Unlocking account $1 failed" + fi ;; *-openbsd*) @@ -282,7 +305,7 @@ eunlockuser() { *) # silence warning if account does not have a password - usermod -e "" -U "$1" 2>/dev/null || die "Unlocking account $1 failed" + usermod "${opts[@]}" -e "" -U "$1" 2>/dev/null || die "Unlocking account $1 failed" ;; esac @@ -418,7 +441,13 @@ acct-user_pkg_preinst() { # default ownership to user:group if [[ -z ${_ACCT_USER_HOME_OWNER} ]]; then local group_array=( ${_ACCT_USER_GROUPS} ) - _ACCT_USER_HOME_OWNER=${ACCT_USER_NAME}:${group_array[0]} + if [[ -n "${ROOT}" ]]; then + local euid=$(egetent passwd ${ACCT_USER_NAME} | cut -d: -f3) + local egid=$(egetent passwd ${ACCT_USER_NAME} | cut -d: -f4) + _ACCT_USER_HOME_OWNER=${euid}:${egid} + else + _ACCT_USER_HOME_OWNER=${ACCT_USER_NAME}:${group_array[0]} + fi fi # Path might be missing due to INSTALL_MASK, etc. # https://bugs.gentoo.org/691478 diff --git a/eclass/apache-2.eclass b/eclass/apache-2.eclass index 2197b3d84cd8..f59030f926f5 100644 --- a/eclass/apache-2.eclass +++ b/eclass/apache-2.eclass @@ -650,7 +650,6 @@ apache-2_src_install() { mv -f "${ED%/}/var/www/localhost/icons" \ "${ED%/}/usr/share/apache2/icons" || die rm -rf "${ED%/}/var/www/localhost/" || die - eend $? # set some sane permissions for suexec if use suexec ; then diff --git a/eclass/autotools.eclass b/eclass/autotools.eclass index c275c83d55c2..b8eeb55fd8f2 100644 --- a/eclass/autotools.eclass +++ b/eclass/autotools.eclass @@ -393,8 +393,8 @@ eautoconf() { if [[ ${WANT_AUTOCONF} != "2.1" && -e configure.in ]] ; then - case ${EAPI:-0} in - 0|1|2|3|4|5|6|7) + case ${EAPI} in + 5|6|7) eqawarn "This package has a configure.in file which has long been deprecated. Please" eqawarn "update it to use configure.ac instead as newer versions of autotools will die" eqawarn "when it finds this file. See https://bugs.gentoo.org/426262 for details." @@ -519,11 +519,11 @@ autotools_env_setup() { 5|6) hv_args="--host-root" ;; - 7) + *) hv_args="-b" ;; esac - ROOT=/ has_version ${hv_args} "=sys-devel/automake-${pv}*" && export WANT_AUTOMAKE="${pv}" && break + has_version ${hv_args} "=sys-devel/automake-${pv}*" && export WANT_AUTOMAKE="${pv}" && break done [[ ${WANT_AUTOMAKE} == "latest" ]] && \ die "Cannot find the latest automake! Tried ${_LATEST_AUTOMAKE[*]}" diff --git a/eclass/cmake-utils.eclass b/eclass/cmake-utils.eclass index 85a9367b04b7..4ec3b900edaf 100644 --- a/eclass/cmake-utils.eclass +++ b/eclass/cmake-utils.eclass @@ -1,4 +1,4 @@ -# Copyright 1999-2021 Gentoo Authors +# Copyright 1999-2022 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 # @ECLASS: cmake-utils.eclass @@ -806,7 +806,8 @@ cmake-utils_src_test() { [[ -n ${TEST_VERBOSE} ]] && myctestargs+=( --extra-verbose --output-on-failure ) - set -- ctest -j "$(makeopts_jobs)" --test-load "$(makeopts_loadavg)" "${myctestargs[@]}" "$@" + set -- ctest -j "$(makeopts_jobs "${MAKEOPTS}" 999)" \ + --test-load "$(makeopts_loadavg)" "${myctestargs[@]}" "$@" echo "$@" >&2 if "$@" ; then einfo "Tests succeeded." diff --git a/eclass/cmake.eclass b/eclass/cmake.eclass index 3d4cc0bd7128..59e5b60957c2 100644 --- a/eclass/cmake.eclass +++ b/eclass/cmake.eclass @@ -1,4 +1,4 @@ -# Copyright 1999-2021 Gentoo Authors +# Copyright 1999-2022 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 # @ECLASS: cmake.eclass @@ -674,7 +674,8 @@ cmake_src_test() { [[ -n ${TEST_VERBOSE} ]] && myctestargs+=( --extra-verbose --output-on-failure ) - set -- ctest -j "$(makeopts_jobs)" --test-load "$(makeopts_loadavg)" "${myctestargs[@]}" "$@" + set -- ctest -j "$(makeopts_jobs "${MAKEOPTS}" 999)" \ + --test-load "$(makeopts_loadavg)" "${myctestargs[@]}" "$@" echo "$@" >&2 if "$@" ; then einfo "Tests succeeded." diff --git a/eclass/dist-kernel-utils.eclass b/eclass/dist-kernel-utils.eclass index 71c96a37e642..d192c31db273 100644 --- a/eclass/dist-kernel-utils.eclass +++ b/eclass/dist-kernel-utils.eclass @@ -78,6 +78,9 @@ dist-kernel_get_image_path() { # substitutions in the code echo ./vmlinux ;; + riscv) + echo arch/riscv/boot/Image.gz + ;; *) die "${FUNCNAME}: unsupported ARCH=${ARCH}" ;; diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass index 7a7bdb4a4d39..ed368da79896 100644 --- a/eclass/distutils-r1.eclass +++ b/eclass/distutils-r1.eclass @@ -98,16 +98,24 @@ esac # # - flit - flit_core backend # +# - flit_scm - flit_scm backend +# # - hatchling - hatchling backend (from hatch) # # - jupyter - jupyter_packaging backend # +# - maturin - maturin backend +# +# - pbr - pbr backend +# # - pdm - pdm.pep517 backend # # - poetry - poetry-core backend # # - setuptools - distutils or setuptools (incl. legacy mode) # +# - sip - sipbuild backend +# # - standalone - standalone build systems without external deps # (used for bootstrapping). # @@ -155,13 +163,6 @@ esac # ${DISTUTILS_DEPS}" # @CODE -# @ECLASS_VARIABLE: GPEP517_TESTING -# @USER_VARIABLE -# @DESCRIPTION: -# Enable in make.conf to test building via dev-python/gpep517 instead of -# inline Python snippets. dev-python/gpep517 needs to be installed -# first. - if [[ ! ${_DISTUTILS_R1} ]]; then [[ ${EAPI} == 6 ]] && inherit eutils xdg-utils @@ -188,16 +189,17 @@ _distutils_set_globals() { die "DISTUTILS_USE_SETUPTOOLS is not used in PEP517 mode" fi - # installer is used to install the wheel - # tomli is used to read build-backend from pyproject.toml bdep=' - >=dev-python/installer-0.4.0_p20220124[${PYTHON_USEDEP}] - >=dev-python/tomli-1.2.3[${PYTHON_USEDEP}]' + >=dev-python/gpep517-3[${PYTHON_USEDEP}]' case ${DISTUTILS_USE_PEP517} in flit) bdep+=' >=dev-python/flit_core-3.7.1[${PYTHON_USEDEP}]' ;; + flit_scm) + bdep+=' + dev-python/flit_scm[${PYTHON_USEDEP}]' + ;; hatchling) bdep+=' >=dev-python/hatchling-0.22.0[${PYTHON_USEDEP}]' @@ -206,6 +208,14 @@ _distutils_set_globals() { bdep+=' >=dev-python/jupyter_packaging-0.11.1[${PYTHON_USEDEP}]' ;; + maturin) + bdep+=' + >=dev-util/maturin-0.12.7[${PYTHON_USEDEP}]' + ;; + pbr) + bdep+=' + >=dev-python/pbr-5.8.0-r1[${PYTHON_USEDEP}]' + ;; pdm) bdep+=' >=dev-python/pdm-pep517-0.12.3[${PYTHON_USEDEP}]' @@ -219,6 +229,10 @@ _distutils_set_globals() { >=dev-python/setuptools-60.5.0[${PYTHON_USEDEP}] dev-python/wheel[${PYTHON_USEDEP}]' ;; + sip) + bdep+=' + >=dev-python/sip-6.5.0-r1[${PYTHON_USEDEP}]' + ;; standalone) ;; *) @@ -380,8 +394,19 @@ unset -f _distutils_set_globals # @ECLASS_VARIABLE: DISTUTILS_ARGS # @DEFAULT_UNSET # @DESCRIPTION: -# An array containing options to be passed to setup.py. They are passed -# before the default arguments, i.e. before the first command. +# An array containing options to be passed to the build system. +# Supported by a subset of build systems used by the eclass. +# +# For setuptools, the arguments will be passed as first parameters +# to setup.py invocations (via esetup.py), as well as to the PEP517 +# backend. For future compatibility, only global options should be used +# and specifying commands should be avoided. +# +# For sip, the options are passed to the PEP517 backend in a form +# resembling sip-build calls. Options taking arguments need to +# be specified in the "--key=value" form, while flag options as "--key". +# If an option takes multiple arguments, it can be specified multiple +# times, same as for sip-build. # # Example: # @CODE @@ -843,6 +868,102 @@ _distutils-r1_check_all_phase_mismatch() { fi } +# @FUNCTION: _distutils-r1_print_package_versions +# @INTERNAL +# @DESCRIPTION: +# Print the version of the relevant build system packages to aid +# debugging. +_distutils-r1_print_package_versions() { + local packages=() + + if [[ ${DISTUTILS_USE_PEP517} ]]; then + packages+=( + dev-python/gpep517 + dev-python/installer + ) + case ${DISTUTILS_USE_PEP517} in + flit) + packages+=( + dev-python/flit_core + ) + ;; + flit_scm) + packages+=( + dev-python/flit_core + dev-python/flit_scm + dev-python/setuptools_scm + ) + ;; + hatchling) + packages+=( + dev-python/hatchling + ) + ;; + jupyter) + packages+=( + dev-python/jupyter_packaging + dev-python/setuptools + dev-python/setuptools_scm + dev-python/wheel + ) + ;; + maturin) + packages+=( + dev-util/maturin + ) + ;; + pbr) + packages+=( + dev-python/pbr + dev-python/setuptools + dev-python/wheel + ) + ;; + pdm) + packages+=( + dev-python/pdm-pep517 + dev-python/setuptools + ) + ;; + poetry) + packages+=( + dev-python/poetry-core + ) + ;; + setuptools) + packages+=( + dev-python/setuptools + dev-python/setuptools_scm + dev-python/wheel + ) + ;; + sip) + packages+=( + dev-python/sip + ) + ;; + esac + else + case ${DISTUTILS_USE_SETUPTOOLS} in + manual|no) + return + ;; + *) + packages+=( + dev-python/setuptools + ) + ;; + esac + fi + + local pkg + einfo "Build system packages:" + for pkg in "${packages[@]}"; do + local installed=$(best_version "${pkg}") + einfo " $(printf '%-30s' "${pkg}"): ${installed#${pkg}-}" + done +} + # @FUNCTION: distutils-r1_python_prepare_all # @DESCRIPTION: # The default python_prepare_all(). It applies the patches from PATCHES @@ -886,6 +1007,10 @@ distutils-r1_python_prepare_all() { python_copy_sources fi + python_export_utf8_locale + [[ ${EAPI} == 6 ]] && xdg_environment_reset # Bug 577704 + _distutils-r1_print_package_versions + _DISTUTILS_DEFAULT_CALLED=1 } @@ -977,12 +1102,21 @@ _distutils-r1_backend_to_key() { flit_core.buildapi|flit.buildapi) echo flit ;; + flit_scm:buildapi) + echo flit_scm + ;; hatchling.build) echo hatchling ;; jupyter_packaging.build_api) echo jupyter ;; + maturin) + echo maturin + ;; + pbr.build) + echo pbr + ;; pdm.pep517.api) echo pdm ;; @@ -992,6 +1126,9 @@ _distutils-r1_backend_to_key() { setuptools.build_meta|setuptools.build_meta:__legacy__) echo setuptools ;; + sipbuild.api) + echo sip + ;; *) die "Unknown backend: ${backend}" ;; @@ -1010,20 +1147,7 @@ _distutils-r1_get_backend() { if [[ -f pyproject.toml ]]; then # if pyproject.toml exists, try getting the backend from it # NB: this could fail if pyproject.toml doesn't list one - if [[ ${GPEP517_TESTING} ]]; then - build_backend=$(gpep517 get-backend) - else - build_backend=$( - "${EPYTHON}" - 3>&1 <<-EOF - import os - import tomli - print(tomli.load(open("pyproject.toml", "rb")) - .get("build-system", {}) - .get("build-backend", ""), - file=os.fdopen(3, "w")) - EOF - ) - fi + build_backend=$(gpep517 get-backend) fi if [[ -z ${build_backend} && ${DISTUTILS_USE_PEP517} == setuptools && -f setup.py ]] @@ -1087,61 +1211,83 @@ distutils_pep517_install() { local -x WHEEL_BUILD_DIR=${BUILD_DIR}/wheel mkdir -p "${WHEEL_BUILD_DIR}" || die + if [[ -n ${mydistutilsargs[@]} ]]; then + die "mydistutilsargs are banned in PEP517 mode (use DISTUTILS_ARGS)" + fi + + local config_settings= + if [[ -n ${DISTUTILS_ARGS[@]} ]]; then + case ${DISTUTILS_USE_PEP517} in + setuptools) + config_settings=$( + "${EPYTHON}" - "${DISTUTILS_ARGS[@]}" <<-EOF || die + import json + import sys + print(json.dumps({"--global-option": sys.argv[1:]})) + EOF + ) + ;; + sip) + # NB: for practical reasons, we support only --foo=bar, + # not --foo bar + local arg + for arg in "${DISTUTILS_ARGS[@]}"; do + [[ ${arg} != -* ]] && + die "Bare arguments in DISTUTILS_ARGS unsupported: ${arg}" + done + + config_settings=$( + "${EPYTHON}" - "${DISTUTILS_ARGS[@]}" <<-EOF || die + import collections + import json + import sys + + args = collections.defaultdict(list) + for arg in (x.split("=", 1) for x in sys.argv[1:]): \ + args[arg[0]].extend( + [arg[1]] if len(arg) > 1 else []) + + print(json.dumps(args)) + EOF + ) + ;; + *) + die "DISTUTILS_ARGS are not supported by ${DISTUTILS_USE_PEP517}" + ;; + esac + fi + local build_backend=$(_distutils-r1_get_backend) einfo " Building the wheel for ${PWD#${WORKDIR}/} via ${build_backend}" - if [[ ${GPEP517_TESTING} ]]; then - local wheel=$( - gpep517 build-wheel --backend "${build_backend}" \ - --output-fd 3 \ - --wheel-dir "${WHEEL_BUILD_DIR}" 3>&1 >&2 || - die "Wheel build failed" - ) - else - local wheel=$( - "${EPYTHON}" - 3>&1 >&2 <<-EOF || die "Wheel build failed" - import ${build_backend%:*} - import os - print(${build_backend/:/.}.build_wheel(os.environ['WHEEL_BUILD_DIR']), - file=os.fdopen(3, 'w')) - EOF - ) - fi + local config_args=() + [[ -n ${config_settings} ]] && + config_args+=( --config-json "${config_settings}" ) + local wheel=$( + gpep517 build-wheel --backend "${build_backend}" \ + --output-fd 3 \ + --wheel-dir "${WHEEL_BUILD_DIR}" \ + "${config_args[@]}" 3>&1 >&2 || + die "Wheel build failed" + ) [[ -n ${wheel} ]] || die "No wheel name returned" einfo " Installing the wheel to ${root}" - if [[ ${GPEP517_TESTING} ]]; then - gpep517 install-wheel --destdir="${root}" --interpreter="${PYTHON}" \ - --prefix="${EPREFIX}/usr" "${WHEEL_BUILD_DIR}/${wheel}" || - die "Wheel install failed" - else - # NB: --compile-bytecode does not produce the correct paths, - # and python_optimize doesn't handle being called outside D, - # so we just defer compiling until the final merge - # NB: we override sys.prefix & sys.exec_prefix because otherwise - # installer would use virtualenv's prefix - local -x PYTHON_PREFIX=${EPREFIX}/usr - "${EPYTHON}" - -d "${root}" "${WHEEL_BUILD_DIR}/${wheel}" --no-compile-bytecode \ - <<-EOF || die "installer failed" - import os, sys - sys.prefix = sys.exec_prefix = os.environ["PYTHON_PREFIX"] - from installer.__main__ import main - main(sys.argv[1:]) - EOF - fi + gpep517 install-wheel --destdir="${root}" --interpreter="${PYTHON}" \ + --prefix="${EPREFIX}/usr" "${WHEEL_BUILD_DIR}/${wheel}" || + die "Wheel install failed" # remove installed licenses - find "${root}$(python_get_sitedir)" \ - '(' -path '*.dist-info/COPYING*' -o \ - -path '*.dist-info/LICENSE*' ')' -delete || die + find "${root}$(python_get_sitedir)" -depth \ + \( -path '*.dist-info/COPYING*' \ + -o -path '*.dist-info/LICENSE*' \ + -o -path '*.dist-info/license_files/*' \ + -o -path '*.dist-info/license_files' \ + \) -delete || die # clean the build tree; otherwise we may end up with PyPy3 # extensions duplicated into CPython dists if [[ ${DISTUTILS_USE_PEP517:-setuptools} == setuptools ]]; then - if [[ ${GPEP517_TESTING} ]]; then - rm -rf build || die - else - esetup.py clean -a - fi + rm -rf build || die fi } @@ -1159,48 +1305,55 @@ distutils-r1_python_compile() { _python_check_EPYTHON - # call setup.py build when using setuptools (either via PEP517 - # or in legacy mode) - if [[ ${DISTUTILS_USE_PEP517:-setuptools} == setuptools ]]; then - if [[ ${GPEP517_TESTING} ]]; then - if [[ -d build ]]; then - eqawarn "A 'build' directory exists already. Artifacts from this directory may" - eqawarn "be picked up by setuptools when building for another interpreter." - eqawarn "Please remove this directory prior to building." + case ${DISTUTILS_USE_PEP517:-setuptools} in + setuptools) + # call setup.py build when using setuptools (either via PEP517 + # or in legacy mode) + + if [[ ${DISTUTILS_USE_PEP517} ]]; then + if [[ -d build ]]; then + eqawarn "A 'build' directory exists already. Artifacts from this directory may" + eqawarn "be picked up by setuptools when building for another interpreter." + eqawarn "Please remove this directory prior to building." + fi + else + _distutils-r1_copy_egg_info fi - elif [[ ! ${DISTUTILS_USE_PEP517} ]]; then - _distutils-r1_copy_egg_info - fi - # distutils is parallel-capable since py3.5 - local jobs=$(makeopts_jobs "${MAKEOPTS}" INF) - if [[ ${jobs} == INF ]]; then - local nproc=$(get_nproc) - jobs=$(( nproc + 1 )) - fi + # distutils is parallel-capable since py3.5 + local jobs=$(makeopts_jobs "${MAKEOPTS} ${*}") - if [[ ${DISTUTILS_USE_PEP517} && ${GPEP517_TESTING} ]]; then - # issue build_ext only if it looks like we have something - # to build; setuptools is expensive to start - # see extension.py for list of suffixes - # .pyx is added for Cython - if [[ -n $( - find '(' -name '*.c' -o -name '*.cc' -o -name '*.cpp' \ - -o -name '*.cxx' -o -name '*.c++' -o -name '*.m' \ - -o -name '*.mm' -o -name '*.pyx' ')' -print -quit - ) ]]; then - esetup.py build_ext -j "${jobs}" "${@}" + if [[ ${DISTUTILS_USE_PEP517} ]]; then + # issue build_ext only if it looks like we have at least + # two source files to build; setuptools is expensive + # to start and parallel builds can only benefit us if we're + # compiling at least two files + # + # see extension.py for list of suffixes + # .pyx is added for Cython + if [[ 1 -ne ${jobs} && 2 -eq $( + find '(' -name '*.c' -o -name '*.cc' -o -name '*.cpp' \ + -o -name '*.cxx' -o -name '*.c++' -o -name '*.m' \ + -o -name '*.mm' -o -name '*.pyx' ')' -printf '\n' | + head -n 2 | wc -l + ) ]]; then + esetup.py build_ext -j "${jobs}" "${@}" + fi + else + esetup.py build -j "${jobs}" "${@}" fi - else - esetup.py build -j "${jobs}" "${@}" - fi - fi + ;; + maturin) + # auditwheel may attempt to auto-bundle libraries, bug #831171 + local -x MATURIN_PEP517_ARGS=--skip-auditwheel - if [[ ${DISTUTILS_USE_PEP517} ]]; then - if [[ -n ${DISTUTILS_ARGS[@]} || -n ${mydistutilsargs[@]} ]]; then - die "DISTUTILS_ARGS are not supported in PEP-517 mode" - fi + # support cargo.eclass' IUSE=debug if available + in_iuse debug && use debug && + MATURIN_PEP517_ARGS+=" --cargo-extra-args=--profile=dev" + ;; + esac + if [[ ${DISTUTILS_USE_PEP517} ]]; then # python likes to compile any module it sees, which triggers sandbox # failures if some packages haven't compiled their modules yet. addpredict "${EPREFIX}/usr/lib/${EPYTHON}" @@ -1617,9 +1770,6 @@ distutils-r1_src_configure() { debug-print-function ${FUNCNAME} "${@}" local ret=0 - python_export_utf8_locale - [[ ${EAPI} == 6 ]] && xdg_environment_reset # Bug 577704 - if declare -f python_configure >/dev/null; then _distutils-r1_run_foreach_impl python_configure || ret=${?} fi diff --git a/eclass/edo.eclass b/eclass/edo.eclass new file mode 100644 index 000000000000..c2e7ed60083f --- /dev/null +++ b/eclass/edo.eclass @@ -0,0 +1,48 @@ +# Copyright 2022 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +# @ECLASS: edo.eclass +# @MAINTAINER: +# QA Team +# @AUTHOR: +# Sam James +# @SUPPORTED_EAPIS: 7 8 +# @BLURB: Convenience function to run commands verbosely and die on failure +# @DESCRIPTION: +# This eclass provides the 'edo' command, and an 'edob' variant for ebegin/eend, +# which logs the command used verbosely and dies (exits) on failure. +# +# This eclass should be used only where needed to give a more verbose log, e.g. +# for invoking non-standard ./configure scripts, or building objects/binaries +# directly within ebuilds via compiler invocations. It is NOT to be used +# in place of generic 'command || die' where verbosity is unnecessary. +case ${EAPI} in + 7|8) ;; + *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; +esac + +if [[ -z ${_EDO_ECLASS} ]] ; then +_EDO_ECLASS=1 + +# @FUNCTION: edo +# @USAGE: [...] +# @DESCRIPTION: +# Executes a short 'command' with any given arguments and exits on failure +# unless called under 'nonfatal'. +edo() { + einfo "$@" + "$@" || die -n "Failed to run command: $@" +} + +# @FUNCTION: edob +# @USAGE: [...] +# @DESCRIPTION: +# Executes 'command' with ebegin & eend with any given arguments and exits +# on failure unless called under 'nonfatal'. +edob() { + ebegin "Running $@" + "$@" + eend $? || die -n "Failed to run command: $@" +} + +fi diff --git a/eclass/elisp-common.eclass b/eclass/elisp-common.eclass index 775bcbdb889c..47c8132192ca 100644 --- a/eclass/elisp-common.eclass +++ b/eclass/elisp-common.eclass @@ -1,4 +1,4 @@ -# Copyright 1999-2021 Gentoo Authors +# Copyright 1999-2022 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 # @ECLASS: elisp-common.eclass @@ -10,7 +10,7 @@ # Mamoru Komachi # Christian Faulhammer # Ulrich Müller -# @SUPPORTED_EAPIS: 5 6 7 8 +# @SUPPORTED_EAPIS: 6 7 8 # @BLURB: Emacs-related installation utilities # @DESCRIPTION: # @@ -165,8 +165,8 @@ # Again, with optional Emacs support, you should prepend "use emacs &&" # to above calls of elisp-site-regen(). -case ${EAPI:-0} in - 5|6) inherit eapi7-ver ;; +case ${EAPI} in + 6) inherit eapi7-ver ;; 7|8) ;; *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; esac @@ -360,10 +360,6 @@ elisp-install() { elisp-modules-install() { local subdir="$1" shift - # Don't bother inheriting multilib.eclass for get_libdir(), but - # error out in old EAPIs that don't support it natively. - [[ ${EAPI} == 5 ]] \ - && die "${ECLASS}: Dynamic modules not supported in EAPI ${EAPI}" ebegin "Installing dynamic modules for GNU Emacs support" ( # subshell to avoid pollution of calling environment exeinto "${EMACSMODULES//@libdir@/$(get_libdir)}/${subdir}" @@ -391,12 +387,7 @@ elisp-site-file-install() { sf="${T}/${sf}" ebegin "Installing site initialisation file for GNU Emacs" [[ $1 == "${sf}" ]] || cp "$1" "${sf}" - if [[ ${EAPI} == 5 ]]; then - grep -q "@EMACSMODULES@" "${sf}" \ - && die "${ECLASS}: Dynamic modules not supported in EAPI ${EAPI}" - else - modules=${EMACSMODULES//@libdir@/$(get_libdir)} - fi + modules=${EMACSMODULES//@libdir@/$(get_libdir)} sed -i -e "1{:x;/^\$/{n;bx;};/^;.*${PN}/I!s:^:${header}\n\n:;1s:^:\n:;}" \ -e "s:@SITELISP@:${EPREFIX}${SITELISP}/${my_pn}:g" \ -e "s:@SITEETC@:${EPREFIX}${SITEETC}/${my_pn}:g" \ diff --git a/eclass/elisp.eclass b/eclass/elisp.eclass index 2fea311305f1..6b6679df5c5d 100644 --- a/eclass/elisp.eclass +++ b/eclass/elisp.eclass @@ -1,4 +1,4 @@ -# Copyright 2002-2021 Gentoo Authors +# Copyright 2002-2022 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 # @ECLASS: elisp.eclass @@ -64,7 +64,7 @@ inherit elisp-common -case ${EAPI:-0} in +case ${EAPI} in 6|7|8) ;; *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; esac diff --git a/eclass/gnuconfig.eclass b/eclass/gnuconfig.eclass index 58bdcfd660a6..0791798632cd 100644 --- a/eclass/gnuconfig.eclass +++ b/eclass/gnuconfig.eclass @@ -1,4 +1,4 @@ -# Copyright 1999-2021 Gentoo Authors +# Copyright 1999-2022 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 # @ECLASS: gnuconfig.eclass @@ -84,9 +84,9 @@ gnuconfig_do_update() { if [[ -n ${targetlist} ]] ; then for target in ${targetlist} ; do [[ -L ${target} ]] && rm -f "${target}" - einfo " Updating ${target/$startdir\//}" + ebegin " Updating ${target/$startdir\//}" cp -f "${configsubs_dir}/${file}" "${target}" - eend $? + eend $? || die done else ewarn " No ${file} found in ${startdir}, skipping ..." diff --git a/eclass/java-pkg-simple.eclass b/eclass/java-pkg-simple.eclass index eab56460eef6..47499c7870a9 100644 --- a/eclass/java-pkg-simple.eclass +++ b/eclass/java-pkg-simple.eclass @@ -1,4 +1,4 @@ -# Copyright 2004-2021 Gentoo Authors +# Copyright 2004-2022 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 # @ECLASS: java-pkg-simple.eclass @@ -17,7 +17,8 @@ # directory before calling the src_compile function of this eclass. case ${EAPI:-0} in - [5678]) ;; + 5|6) inherit eutils ;; # eutils for eqawarn + 7|8) ;; *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; esac @@ -393,8 +394,8 @@ java-pkg-simple_src_compile() { JAVA_PKG_WANT_SOURCE=${tmp_source} JAVA_PKG_WANT_TARGET=${tmp_target} else - ewarn "Need at least JDK 9 to compile module-info.java in src_compile," - ewarn "see https://bugs.gentoo.org/796875" + eqawarn "Need at least JDK 9 to compile module-info.java in src_compile." + eqawarn "Please adjust DEPEND accordingly. See https://bugs.gentoo.org/796875#c3" fi fi diff --git a/eclass/java-utils-2.eclass b/eclass/java-utils-2.eclass index 2a649942550c..5b4783f350f2 100644 --- a/eclass/java-utils-2.eclass +++ b/eclass/java-utils-2.eclass @@ -43,21 +43,6 @@ has test ${JAVA_PKG_IUSE} && RESTRICT+=" !test? ( test )" JAVA_PKG_E_DEPEND=">=dev-java/java-config-2.2.0-r3" has source ${JAVA_PKG_IUSE} && JAVA_PKG_E_DEPEND="${JAVA_PKG_E_DEPEND} source? ( app-arch/zip )" -# @ECLASS_VARIABLE: JAVA_PKG_WANT_BOOTCLASSPATH -# @DEFAULT_UNSET -# @DESCRIPTION: -# The version of bootclasspath the package needs to work. Translates to a proper -# dependency. The bootclasspath can then be obtained by java-ant_rewrite-bootclasspath -if [[ -n "${JAVA_PKG_WANT_BOOTCLASSPATH}" ]]; then - if [[ "${JAVA_PKG_WANT_BOOTCLASSPATH}" == "1.5" ]]; then - JAVA_PKG_E_DEPEND="${JAVA_PKG_E_DEPEND} >=dev-java/gnu-classpath-0.98-r1:0.98" - else - eerror "Unknown value of JAVA_PKG_WANT_BOOTCLASSPATH" - # since die in global scope doesn't work, this will make repoman fail - JAVA_PKG_E_DEPEND="${JAVA_PKG_E_DEPEND} BAD_JAVA_PKG_WANT_BOOTCLASSPATH" - fi -fi - # @ECLASS_VARIABLE: JAVA_PKG_ALLOW_VM_CHANGE # @DESCRIPTION: # Allow this eclass to change the active VM? @@ -76,9 +61,9 @@ JAVA_PKG_ALLOW_VM_CHANGE=${JAVA_PKG_ALLOW_VM_CHANGE:="yes"} # # Should only be used for testing and debugging. # -# Example: use sun-jdk-1.5 to emerge foo: +# Example: use openjdk-11 to emerge foo: # @CODE -# JAVA_PKG_FORCE_VM=sun-jdk-1.5 emerge foo +# JAVA_PKG_FORCE_VM=openjdk-11 emerge foo # @CODE # @ECLASS_VARIABLE: JAVA_PKG_WANT_BUILD_VM @@ -103,9 +88,9 @@ JAVA_PKG_ALLOW_VM_CHANGE=${JAVA_PKG_ALLOW_VM_CHANGE:="yes"} # # Should generally only be used for testing and debugging. # -# Use 1.4 source to emerge baz +# Use 1.8 source to emerge baz # @CODE -# JAVA_PKG_WANT_SOURCE=1.4 emerge baz +# JAVA_PKG_WANT_SOURCE=1.8 emerge baz # @CODE # @ECLASS_VARIABLE: JAVA_PKG_WANT_TARGET @@ -118,9 +103,9 @@ JAVA_PKG_ALLOW_VM_CHANGE=${JAVA_PKG_ALLOW_VM_CHANGE:="yes"} # # Should generally only be used for testing and debugging. # -# emerge bar to be compatible with 1.3 +# emerge bar to be compatible with 1.8 # @CODE -# JAVA_PKG_WANT_TARGET=1.3 emerge bar +# JAVA_PKG_WANT_TARGET=1.8 emerge bar # @CODE # @ECLASS_VARIABLE: JAVA_TEST_EXTRA_ARGS @@ -139,6 +124,20 @@ JAVA_PKG_ALLOW_VM_CHANGE=${JAVA_PKG_ALLOW_VM_CHANGE:="yes"} # ) # @CODE +# @ECLASS-VARIABLE: JAVA_TEST_RUNNER_EXTRA_ARGS +# @DEFAULT_UNSET +# @DESCRIPTION: +# Array of extra arguments that should be passed to the test runner when running tests. +# It is useful when you need to pass an extra argument to the test runner. +# +# It is used only when running tests. +# +# @CODE +# JAVA_TEST_RUNNER_EXTRA_ARGS=( +# -verbose 3 +# ) +# @CODE + # @ECLASS_VARIABLE: JAVA_PKG_DEBUG # @DEFAULT_UNSET # @DESCRIPTION: @@ -1373,7 +1372,7 @@ java-pkg_register-environment-variable() { # @DESCRIPTION: # Returns classpath of a given bootclasspath-providing package version. # -# @param $1 - the version of bootclasspath (e.g. 1.5), 'auto' for bootclasspath +# @param $1 - the version of bootclasspath (e.g. 1.8), 'auto' for bootclasspath # of the current JDK java-pkg_get-bootclasspath() { local version="${1}" @@ -1383,9 +1382,6 @@ java-pkg_get-bootclasspath() { auto) bcp="$(java-config -g BOOTCLASSPATH)" ;; - 1.5) - bcp="$(java-pkg_getjars --build-only gnu-classpath-0.98)" - ;; *) eerror "unknown parameter of java-pkg_get-bootclasspath" die "unknown parameter of java-pkg_get-bootclasspath" @@ -1807,8 +1803,18 @@ ejunit_() { if [[ "${junit}" == "junit-4" ]] ; then runner=org.junit.runner.JUnitCore fi - debug-print "Calling: java -cp \"${cp}\" -Djava.io.tmpdir=\"${T}\" -Djava.awt.headless=true ${JAVA_TEST_EXTRA_ARGS[@]} ${runner} ${@}" - java -cp "${cp}" -Djava.io.tmpdir="${T}/" -Djava.awt.headless=true ${JAVA_TEST_EXTRA_ARGS[@]} ${runner} "${@}" || die "Running junit failed" + + local args=( + -cp ${cp} + -Djava.io.tmpdir="${T}" + -Djava.awt.headless=true + ${JAVA_TEST_EXTRA_ARGS[@]} + ${runner} + ${JAVA_TEST_RUNNER_EXTRA_ARGS[@]} + ${@} + ) + debug-print "Calling: java ${args[@]}" + java "${args[@]}" || die "Running junit failed" } # @FUNCTION: ejunit @@ -1886,12 +1892,21 @@ etestng() { tests+="${test}," done - debug-print "java -cp \"${cp}\" -Djava.io.tmpdir=\"${T}\""\ - "-Djava.awt.headless=true ${JAVA_TEST_EXTRA_ARGS[@]} ${runner}"\ - "-usedefaultlisteners false -testclass ${tests}" - java -cp "${cp}" -Djava.io.tmpdir=\"${T}\" -Djava.awt.headless=true ${JAVA_TEST_EXTRA_ARGS[@]}\ - ${runner} -usedefaultlisteners false -testclass ${tests}\ - || die "Running TestNG failed." + local args=( + -cp ${cp} + -Djava.io.tmpdir="${T}" + -Djava.awt.headless=true + ${JAVA_TEST_EXTRA_ARGS[@]} + ${runner} + ${JAVA_TEST_RUNNER_EXTRA_ARGS[@]} + ) + + [[ ! "${JAVA_TEST_RUNNER_EXTRA_ARGS[@]}" =~ "-usedefaultlisteners" ]] && args+=( -usedefaultlisteners false ) + + args+=( -testclass ${tests} ) + + debug-print "java ${args[@]}" + java ${args[@]} || die "Running TestNG failed." } # @FUNCTION: java-utils-2_src_prepare @@ -2547,20 +2562,9 @@ java-pkg_setup-vm() { debug-print-function ${FUNCNAME} $* local vendor="$(java-pkg_get-vm-vendor)" - if [[ "${vendor}" == "sun" ]] && java-pkg_is-vm-version-ge "1.5" ; then - addpredict "/dev/random" - elif [[ "${vendor}" == "ibm" ]]; then - addpredict "/proc/self/maps" - addpredict "/proc/cpuinfo" - addpredict "/proc/self/coredump_filter" - elif [[ "${vendor}" == "oracle" ]]; then - addpredict "/dev/random" - addpredict "/proc/self/coredump_filter" - elif [[ "${vendor}" == icedtea* ]] && java-pkg_is-vm-version-ge "1.7" ; then + if [[ "${vendor}" == icedtea* ]] && java-pkg_is-vm-version-ge "1.8" ; then addpredict "/dev/random" addpredict "/proc/self/coredump_filter" - elif [[ "${vendor}" == "jrockit" ]]; then - addpredict "/proc/cpuinfo" fi } diff --git a/eclass/kernel-2.eclass b/eclass/kernel-2.eclass index bd982d3a52ca..02c70422ee07 100644 --- a/eclass/kernel-2.eclass +++ b/eclass/kernel-2.eclass @@ -1,4 +1,4 @@ -# Copyright 1999-2021 Gentoo Authors +# Copyright 1999-2022 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 # @ECLASS: kernel-2.eclass @@ -8,7 +8,7 @@ # John Mylchreest # Mike Pagano # -# @SUPPORTED_EAPIS: 6 7 8 +# @SUPPORTED_EAPIS: 7 8 # @BLURB: Eclass for kernel packages # @DESCRIPTION: # This is the kernel.eclass rewrite for a clean base regarding the 2.6 @@ -282,10 +282,9 @@ # that of course does not mean we're not willing to help. inherit estack toolchain-funcs -[[ ${EAPI} == 6 ]] && inherit eapi7-ver case ${EAPI} in - 6|7|8) ;; + 7|8) ;; *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; esac @@ -657,7 +656,6 @@ kernel_is() { # Capture the sources type and set DEPENDs if [[ ${ETYPE} == sources ]]; then - [[ ${EAPI} == 6 ]] && DEPEND="!build? ( sys-apps/sed )" || BDEPEND="!build? ( sys-apps/sed )" RDEPEND="!build? ( app-arch/cpio @@ -672,7 +670,7 @@ if [[ ${ETYPE} == sources ]]; then )" SLOT="${PVR}" - DESCRIPTION="Sources based on the Linux Kernel." + DESCRIPTION="Sources based on the Linux Kernel" IUSE="symlink build" # Bug #266157, deblob for libre support @@ -863,10 +861,10 @@ install_headers() { local ddir=$(kernel_header_destdir) env_setup_xmakeopts - emake headers_install INSTALL_HDR_PATH="${ED%/}"${ddir}/.. ${xmakeopts} + emake headers_install INSTALL_HDR_PATH="${ED}"${ddir}/.. ${xmakeopts} # let other packages install some of these headers - rm -rf "${ED%/}"${ddir}/scsi || die #glibc/uclibc/etc... + rm -rf "${ED}"${ddir}/scsi || die #glibc/uclibc/etc... return 0 } @@ -893,7 +891,7 @@ install_sources() { done fi - mv "${WORKDIR}"/linux* "${ED%/}"/usr/src || die + mv "${WORKDIR}"/linux* "${ED}"/usr/src || die if [[ -n ${UNIPATCH_DOCS} ]]; then for i in ${UNIPATCH_DOCS}; do @@ -933,15 +931,15 @@ postinst_sources() { # if we are to forcably symlink, delete it if it already exists first. if [[ ${K_SYMLINK} -gt 0 ]]; then - if [[ -e ${EROOT%/}/usr/src/linux && ! -L ${EROOT%/}/usr/src/linux ]] ; then - die "${EROOT%/}/usr/src/linux exist and is not a symlink" + if [[ -e ${EROOT}/usr/src/linux && ! -L ${EROOT}/usr/src/linux ]] ; then + die "${EROOT}/usr/src/linux exists and is not a symlink" fi - ln -snf linux-${KV_FULL} "${EROOT%/}"/usr/src/linux || die + ln -snf linux-${KV_FULL} "${EROOT}"/usr/src/linux || die fi # Don't forget to make directory for sysfs - [[ ! -d ${EROOT%/}/sys ]] && kernel_is 2 6 && { mkdir "${EROOT%/}"/sys || die ; } + [[ ! -d ${EROOT}/sys ]] && kernel_is 2 6 && { mkdir "${EROOT}"/sys || die ; } elog "If you are upgrading from a previous kernel, you may be interested" elog "in the following document:" @@ -1537,10 +1535,10 @@ kernel-2_pkg_postrm() { [[ ${ETYPE} == headers ]] && return 0 # If there isn't anything left behind, then don't complain. - [[ -e ${EROOT%/}/usr/src/linux-${KV_FULL} ]] || return 0 + [[ -e ${EROOT}/usr/src/linux-${KV_FULL} ]] || return 0 ewarn "Note: Even though you have successfully unmerged " ewarn "your kernel package, directories in kernel source location: " - ewarn "${EROOT%/}/usr/src/linux-${KV_FULL}" + ewarn "${EROOT}/usr/src/linux-${KV_FULL}" ewarn "with modified files will remain behind. By design, package managers" ewarn "will not remove these modified files and the directories they reside in." ewarn "For more detailed kernel removal instructions, please see: " diff --git a/eclass/kernel-build.eclass b/eclass/kernel-build.eclass index 279649301087..0a49533e48d3 100644 --- a/eclass/kernel-build.eclass +++ b/eclass/kernel-build.eclass @@ -1,4 +1,4 @@ -# Copyright 2020-2021 Gentoo Authors +# Copyright 2020-2022 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 # @ECLASS: kernel-build.eclass @@ -52,6 +52,20 @@ BDEPEND=" kernel-build_src_configure() { debug-print-function ${FUNCNAME} "${@}" + if ! tc-is-cross-compiler && use hppa ; then + if [[ ${CHOST} == hppa2.0-* ]] ; then + # Only hppa2.0 can handle 64-bit anyway. + # Right now, hppa2.0 can run both 32-bit and 64-bit kernels, + # but it seems like most people do 64-bit kernels now + # (obviously needed for more RAM too). + + # TODO: What if they want a 32-bit kernel? + # Not too worried about this case right now. + elog "Forcing 64 bit (${CHOST/2.0/64}) build..." + export CHOST=${CHOST/2.0/64} + fi + fi + # force ld.bfd if we can find it easily local LD="$(tc-getLD)" if type -P "${LD}.bfd" &>/dev/null; then diff --git a/eclass/kernel-install.eclass b/eclass/kernel-install.eclass index 7f4ca654845f..08f631b5e865 100644 --- a/eclass/kernel-install.eclass +++ b/eclass/kernel-install.eclass @@ -1,4 +1,4 @@ -# Copyright 2020-2021 Gentoo Authors +# Copyright 2020-2022 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 # @ECLASS: kernel-install.eclass @@ -168,6 +168,9 @@ kernel-install_get_qemu_arch() { ppc64) echo ppc64 ;; + riscv) + echo riscv + ;; *) die "${FUNCNAME}: unsupported ARCH=${ARCH}" ;; diff --git a/eclass/llvm.org.eclass b/eclass/llvm.org.eclass index 0c47ec4aac0c..0ddd48b19e46 100644 --- a/eclass/llvm.org.eclass +++ b/eclass/llvm.org.eclass @@ -213,7 +213,6 @@ llvm.org_set_globals() { SRC_URI+=" !doc? ( https://dev.gentoo.org/~mgorny/dist/llvm/llvm-${PV}-manpages.tar.bz2 - https://dev.gentoo.org/~sam/distfiles/llvm/llvm-${PV}-manpages.tar.bz2 )" ;; *) @@ -222,8 +221,7 @@ llvm.org_set_globals() { if [[ -n ${LLVM_PATCHSET} ]]; then SRC_URI+=" - https://dev.gentoo.org/~mgorny/dist/llvm/llvm-gentoo-patchset-${LLVM_PATCHSET}.tar.xz - https://dev.gentoo.org/~sam/distfiles/llvm/llvm-gentoo-patchset-${LLVM_PATCHSET}.tar.xz" + https://dev.gentoo.org/~mgorny/dist/llvm/llvm-gentoo-patchset-${LLVM_PATCHSET}.tar.xz" fi local x @@ -323,17 +321,19 @@ llvm.org_src_prepare() { ) fi + pushd "${WORKDIR}" >/dev/null || die if declare -f cmake_src_prepare >/dev/null; then - # cmake eclasses force ${S} for default_src_prepare - # but use ${CMAKE_USE_DIR} for everything else - CMAKE_USE_DIR=${S} \ - S=${WORKDIR} \ + CMAKE_USE_DIR=${S} + if [[ ${EAPI} == 7 ]]; then + # cmake eclasses force ${S} for default_src_prepare in EAPI 7 + # but use ${CMAKE_USE_DIR} for everything else + local S=${WORKDIR} + fi cmake_src_prepare else - pushd "${WORKDIR}" >/dev/null || die default_src_prepare - popd >/dev/null || die fi + popd >/dev/null || die } @@ -351,7 +351,7 @@ llvm.org_src_prepare() { # Get the standard recommended lit flags for running tests, in CMake # list form (;-separated). get_lit_flags() { - echo "-vv;-j;${LIT_JOBS:-$(makeopts_jobs "${MAKEOPTS}" "$(get_nproc)")}" + echo "-vv;-j;${LIT_JOBS:-$(makeopts_jobs)}" } # @FUNCTION: llvm_are_manpages_built diff --git a/eclass/ltprune.eclass b/eclass/ltprune.eclass index e7d8cd2c4f92..5a36647d1d1c 100644 --- a/eclass/ltprune.eclass +++ b/eclass/ltprune.eclass @@ -1,4 +1,4 @@ -# Copyright 1999-2020 Gentoo Authors +# Copyright 1999-2022 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 # @ECLASS: ltprune.eclass @@ -12,7 +12,7 @@ # # Discouraged. Whenever possible, please use much simpler: # @CODE -# find "${ED}" -name '*.la' -delete || die +# find "${ED}" -type f -name '*.la' -delete || die # @CODE if [[ -z ${_LTPRUNE_ECLASS} ]]; then diff --git a/eclass/meson.eclass b/eclass/meson.eclass index c094f4683913..905c4d89f501 100644 --- a/eclass/meson.eclass +++ b/eclass/meson.eclass @@ -1,4 +1,4 @@ -# Copyright 2017-2021 Gentoo Authors +# Copyright 2017-2022 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 # @ECLASS: meson.eclass @@ -48,7 +48,7 @@ inherit multiprocessing ninja-utils python-utils-r1 toolchain-funcs EXPORT_FUNCTIONS src_configure src_compile src_test src_install _MESON_DEPEND=">=dev-util/meson-0.59.4 - >=dev-util/ninja-1.8.2 + ${NINJA_DEPEND} dev-util/meson-format-array " @@ -285,6 +285,8 @@ meson_feature() { meson_src_configure() { debug-print-function ${FUNCNAME} "$@" + [[ -n "${NINJA_DEPEND}" ]] || ewarn "Unknown value '${NINJA}' for \${NINJA}" + local BUILD_CFLAGS=${BUILD_CFLAGS} local BUILD_CPPFLAGS=${BUILD_CPPFLAGS} local BUILD_CXXFLAGS=${BUILD_CXXFLAGS} @@ -323,6 +325,16 @@ meson_src_configure() { --build.pkg-config-path "${BUILD_PKG_CONFIG_PATH}${BUILD_PKG_CONFIG_PATH:+:}${EPREFIX}/usr/share/pkgconfig" --pkg-config-path "${PKG_CONFIG_PATH}${PKG_CONFIG_PATH:+:}${EPREFIX}/usr/share/pkgconfig" --native-file "$(_meson_create_native_file)" + + # gcc[pch] is masked in profiles due to consistent bugginess + # without forcing this off, some packages may fail too (like gjs, + # bug #839549), but in any case, we don't want to bother attempting + # this. + -Db_pch=false + + # It's Gentoo policy to not have builds die on blanket -Werror, as it's + # an upstream development matter. bug #754279. + -Dwerror=false ) if [[ -n ${EMESON_BUILDTYPE} ]]; then diff --git a/eclass/multiprocessing.eclass b/eclass/multiprocessing.eclass index c32bfaac2e6b..e55be636a02c 100644 --- a/eclass/multiprocessing.eclass +++ b/eclass/multiprocessing.eclass @@ -1,4 +1,4 @@ -# Copyright 1999-2021 Gentoo Authors +# Copyright 1999-2022 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 # @ECLASS: multiprocessing.eclass @@ -65,22 +65,21 @@ get_nproc() { } # @FUNCTION: makeopts_jobs -# @USAGE: [${MAKEOPTS}] [${inf:-999}] +# @USAGE: [${MAKEOPTS}] [${inf:-$(( $(get_nproc) + 1 ))}] # @DESCRIPTION: # Searches the arguments (defaults to ${MAKEOPTS}) and extracts the jobs number # specified therein. Useful for running non-make tools in parallel too. # i.e. if the user has MAKEOPTS=-j9, this will echo "9" -- we can't return the # number as bash normalizes it to [0, 255]. If the flags haven't specified a -# -j flag, then "1" is shown as that is the default `make` uses. Since there's -# no way to represent infinity, we return ${inf} (defaults to 999) if the user -# has -j without a number. +# -j flag, then "1" is shown as that is the default `make` uses. If the flags +# specify -j without a number, ${inf} is returned (defaults to nproc). makeopts_jobs() { [[ $# -eq 0 ]] && set -- "${MAKEOPTS}" # This assumes the first .* will be more greedy than the second .* # since POSIX doesn't specify a non-greedy match (i.e. ".*?"). local jobs=$(echo " $* " | sed -r -n \ -e 's:.*[[:space:]](-[a-z]*j|--jobs[=[:space:]])[[:space:]]*([0-9]+).*:\2:p' \ - -e "s:.*[[:space:]](-[a-z]*j|--jobs)[[:space:]].*:${2:-999}:p") + -e "s:.*[[:space:]](-[a-z]*j|--jobs)[[:space:]].*:${2:-$(( $(get_nproc) + 1 ))}:p") echo ${jobs:-1} } diff --git a/eclass/ninja-utils.eclass b/eclass/ninja-utils.eclass index 9f6d2af6bdb2..0dffd2eb86ff 100644 --- a/eclass/ninja-utils.eclass +++ b/eclass/ninja-utils.eclass @@ -1,4 +1,4 @@ -# Copyright 1999-2021 Gentoo Authors +# Copyright 1999-2022 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 # @ECLASS: ninja-utils.eclass @@ -26,6 +26,21 @@ esac if [[ -z ${_NINJA_UTILS_ECLASS} ]]; then _NINJA_UTILS_ECLASS=1 +# @ECLASS_VARIABLE: NINJA +# @PRE_INHERIT +# @DESCRIPTION: +# Specify a compatible ninja implementation to be used by eninja(). +# At this point only "ninja" and "samu" are explicitly supported, +# but other values can be set where NINJA_DEPEND will then be set +# to a blank variable. +# The default is set to "ninja". +: ${NINJA:=ninja} + +# @ECLASS_VARIABLE: NINJA_DEPEND +# @OUTPUT_VARIABLE +# @DESCRIPTION: +# Contains a set of build-time depenendencies based on the NINJA setting. + # @ECLASS_VARIABLE: NINJAOPTS # @DEFAULT_UNSET # @DESCRIPTION: @@ -35,6 +50,18 @@ _NINJA_UTILS_ECLASS=1 inherit multiprocessing +case "${NINJA}" in + ninja) + NINJA_DEPEND=">=dev-util/ninja-1.8.2" + ;; + samu) + NINJA_DEPEND="dev-util/samurai" + ;; + *) + NINJA_DEPEND="" + ;; +esac + # @FUNCTION: eninja # @USAGE: [...] # @DESCRIPTION: @@ -46,9 +73,10 @@ eninja() { [[ ${EAPI} != 5 ]] && nonfatal_args+=( -n ) if [[ -z ${NINJAOPTS+set} ]]; then - NINJAOPTS="-j$(makeopts_jobs) -l$(makeopts_loadavg "${MAKEOPTS}" 0)" + NINJAOPTS="-j$(makeopts_jobs "${MAKEOPTS}" 999) -l$(makeopts_loadavg "${MAKEOPTS}" 0)" fi - set -- ninja -v ${NINJAOPTS} "$@" + [[ -n "${NINJA_DEPEND}" ]] || ewarn "Unknown value '${NINJA}' for \${NINJA}" + set -- "${NINJA}" -v ${NINJAOPTS} "$@" echo "$@" >&2 "$@" || die "${nonfatal_args[@]}" "${*} failed" } diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass index 98cb49c95fd7..67dc5bf754d6 100644 --- a/eclass/python-utils-r1.eclass +++ b/eclass/python-utils-r1.eclass @@ -43,7 +43,7 @@ inherit multiprocessing toolchain-funcs # All supported Python implementations, most preferred last. _PYTHON_ALL_IMPLS=( pypy3 - python3_{8..10} + python3_{8..11} ) readonly _PYTHON_ALL_IMPLS @@ -83,7 +83,7 @@ _python_verify_patterns() { local impl pattern for pattern; do case ${pattern} in - -[23]|3.[89]|3.10) + -[23]|3.[89]|3.1[01]) continue ;; esac @@ -132,7 +132,7 @@ _python_set_impls() { # please keep them in sync with _PYTHON_ALL_IMPLS # and _PYTHON_HISTORICAL_IMPLS case ${i} in - pypy3|python2_7|python3_[89]|python3_10) + pypy3|python2_7|python3_[89]|python3_1[01]) ;; jython2_7|pypy|pypy1_[89]|pypy2_0|python2_[5-6]|python3_[1-7]) obsolete+=( "${i}" ) @@ -240,12 +240,12 @@ _python_impl_matches() { fi return 0 ;; - 3.8) - # the only unmasked pypy3 version is pypy3.8 atm + 3.9) + # the only unmasked pypy3 version is pypy3.9 atm [[ ${impl} == python${pattern/./_} || ${impl} == pypy3 ]] && return 0 ;; - 3.9|3.10) + 3.8|3.1[01]) [[ ${impl} == python${pattern/./_} ]] && return 0 ;; *) @@ -461,6 +461,8 @@ _python_export() { PYTHON_PKG_DEP=">=dev-lang/python-3.9.9-r1:3.9";; python3.10) PYTHON_PKG_DEP=">=dev-lang/python-3.10.0_p1-r1:3.10";; + python3.11) + PYTHON_PKG_DEP=">=dev-lang/python-3.11.0_beta1-r1:3.11";; python*) PYTHON_PKG_DEP="dev-lang/python:${impl#python}";; pypy) @@ -631,9 +633,7 @@ python_optimize() { debug-print "${FUNCNAME}: using sys.path: ${*/%/;}" fi - local jobs=$(makeopts_jobs "${MAKEOPTS}" INF) - [[ ${jobs} == INF ]] && jobs=$(get_nproc) - + local jobs=$(makeopts_jobs) local d for d; do # make sure to get a nice path without // @@ -1288,6 +1288,9 @@ epytest() { -Wdefault # override color output "--color=${color}" + # count is more precise when we're dealing with a large number + # of tests + -o console_output_style=count # disable the undesirable-dependency plugins by default to # trigger missing argument strips. strip options that require # them from config files. enable them explicitly via "-p ..." @@ -1296,6 +1299,9 @@ epytest() { -p no:flake8 -p no:flakes -p no:pylint + # sterilize pytest-markdown as it runs code snippets from all + # *.md files found without any warning + -p no:markdown ) local x for x in "${EPYTEST_DESELECT[@]}"; do diff --git a/eclass/qmake-utils.eclass b/eclass/qmake-utils.eclass index 1f09cbd9ca77..a86ce1fbabb8 100644 --- a/eclass/qmake-utils.eclass +++ b/eclass/qmake-utils.eclass @@ -1,4 +1,4 @@ -# Copyright 1999-2021 Gentoo Authors +# Copyright 1999-2022 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 # @ECLASS: qmake-utils.eclass @@ -60,6 +60,33 @@ qt5_get_plugindir() { echo $(qt5_get_libdir)/qt5/plugins } +# @FUNCTION: qt5_get_qmake_args +# @DESCRIPTION: +# Echoes a multi-line string containing arguments to pass to qmake. +qt5_get_qmake_args() { + cat <<-EOF + QMAKE_AR="$(tc-getAR) cqs" + QMAKE_CC="$(tc-getCC)" + QMAKE_LINK_C="$(tc-getCC)" + QMAKE_LINK_C_SHLIB="$(tc-getCC)" + QMAKE_CXX="$(tc-getCXX)" + QMAKE_LINK="$(tc-getCXX)" + QMAKE_LINK_SHLIB="$(tc-getCXX)" + QMAKE_OBJCOPY="$(tc-getOBJCOPY)" + QMAKE_RANLIB= + QMAKE_STRIP= + QMAKE_CFLAGS="${CFLAGS}" + QMAKE_CFLAGS_RELEASE= + QMAKE_CFLAGS_DEBUG= + QMAKE_CXXFLAGS="${CXXFLAGS}" + QMAKE_CXXFLAGS_RELEASE= + QMAKE_CXXFLAGS_DEBUG= + QMAKE_LFLAGS="${LDFLAGS}" + QMAKE_LFLAGS_RELEASE= + QMAKE_LFLAGS_DEBUG= + EOF +} + # @FUNCTION: eqmake5 # @USAGE: [arguments for qmake] # @DESCRIPTION: @@ -75,28 +102,10 @@ eqmake5() { ebegin "Running qmake" - "$(qt5_get_bindir)"/qmake \ - -makefile \ - QMAKE_AR="$(tc-getAR) cqs" \ - QMAKE_CC="$(tc-getCC)" \ - QMAKE_LINK_C="$(tc-getCC)" \ - QMAKE_LINK_C_SHLIB="$(tc-getCC)" \ - QMAKE_CXX="$(tc-getCXX)" \ - QMAKE_LINK="$(tc-getCXX)" \ - QMAKE_LINK_SHLIB="$(tc-getCXX)" \ - QMAKE_OBJCOPY="$(tc-getOBJCOPY)" \ - QMAKE_RANLIB= \ - QMAKE_STRIP= \ - QMAKE_CFLAGS="${CFLAGS}" \ - QMAKE_CFLAGS_RELEASE= \ - QMAKE_CFLAGS_DEBUG= \ - QMAKE_CXXFLAGS="${CXXFLAGS}" \ - QMAKE_CXXFLAGS_RELEASE= \ - QMAKE_CXXFLAGS_DEBUG= \ - QMAKE_LFLAGS="${LDFLAGS}" \ - QMAKE_LFLAGS_RELEASE= \ - QMAKE_LFLAGS_DEBUG= \ - "$@" + local -a args + mapfile -t args <<<"$(qt5_get_qmake_args)" + # NB: we're passing literal quotes in but qmake doesn't seem to mind + "$(qt5_get_bindir)"/qmake -makefile "${args[@]}" "$@" if ! eend $? ; then echo diff --git a/eclass/qt5-build.eclass b/eclass/qt5-build.eclass index 279ece28e1dd..6da97387c1ab 100644 --- a/eclass/qt5-build.eclass +++ b/eclass/qt5-build.eclass @@ -98,20 +98,7 @@ inherit estack flag-o-matic toolchain-funcs virtualx if [[ ${PN} != qtwebengine ]]; then case ${PV} in *9999 ) - # kde/5.15 branch on invent.kde.org - inherit kde.org - ;; - 5.15.2* ) - if [[ -n ${KDE_ORG_COMMIT} ]]; then - # KDE Qt5PatchCollection snapshot based on Qt 5.15.2 - inherit kde.org - else - # official stable release - _QT5_P=${QT5_MODULE}-everywhere-src-${PV} - HOMEPAGE="https://www.qt.io/" - SRC_URI="https://download.qt.io/official_releases/qt/${PV%.*}/${PV}/submodules/${_QT5_P}.tar.xz" - S=${WORKDIR}/${_QT5_P} - fi + inherit kde.org # kde/5.15 branch ;; 5.15.[3-9]* ) # official stable release @@ -136,22 +123,15 @@ fi LICENSE="|| ( GPL-2 GPL-3 LGPL-3 ) FDL-1.3" -case ${PV} in - 5.15.2*) - SLOT=5/$(ver_cut 1-2) - ;; +case ${PN} in + assistant|linguist|qdbus|qdbusviewer|pixeltool) + SLOT=0 ;; + linguist-tools|qdoc|qtdiag|qtgraphicaleffects|qtimageformats| \ + qtpaths|qtplugininfo|qtquickcontrols|qtquicktimeline| \ + qttranslations|qtwaylandscanner|qtxmlpatterns) + SLOT=5 ;; *) - case ${PN} in - assistant|linguist|qdbus|qdbusviewer|pixeltool) - SLOT=0 ;; - linguist-tools|qdoc|qtdiag|qtgraphicaleffects|qtimageformats| \ - qtpaths|qtplugininfo|qtquickcontrols|qtquicktimeline| \ - qttranslations|qtwaylandscanner|qtxmlpatterns) - SLOT=5 ;; - *) - SLOT=5/$(ver_cut 1-2) ;; - esac - ;; + SLOT=5/$(ver_cut 1-2) ;; esac IUSE="debug test" @@ -185,10 +165,6 @@ qt5-build_src_prepare() { einfo "Preparing KDE Qt5PatchCollection snapshot at ${KDE_ORG_COMMIT}" mkdir -p .git || die # need to fake a git repository for configure fi - # Ensure our ${QT5_PV} is not contradicted by any upstream (Qt) commit - # bumping version in 5.15 branch after release (probably can be dropped - # after 5.15.2_p* are gone) - sed -e "/^MODULE_VERSION/s/5\.15\.[3456789]/${QT5_PV}/" -i .qmake.conf || die fi if [[ ${QT5_MODULE} == qtbase ]]; then @@ -300,24 +276,6 @@ qt5-build_src_install() { sed -i -e '1i #include \n' \ "${D}${QT5_HEADERDIR}"/QtCore/qconfig.h \ || die "sed failed (qconfig.h)" - - if ver_test -lt 5.15.2-r10; then - # install qtchooser configuration file - cat > "${T}/qt5-${CHOST}.conf" <<-_EOF_ || die - ${QT5_BINDIR} - ${QT5_LIBDIR} - _EOF_ - - ( - insinto /etc/xdg/qtchooser - doins "${T}/qt5-${CHOST}.conf" - ) - - # convenience symlinks - dosym qt5-"${CHOST}".conf /etc/xdg/qtchooser/5.conf - dosym qt5-"${CHOST}".conf /etc/xdg/qtchooser/qt5.conf - dosym qt5.conf /etc/xdg/qtchooser/default.conf - fi fi qt5_install_module_config diff --git a/eclass/ruby-fakegem.eclass b/eclass/ruby-fakegem.eclass index 690709f20752..41dbb1e16340 100644 --- a/eclass/ruby-fakegem.eclass +++ b/eclass/ruby-fakegem.eclass @@ -501,20 +501,17 @@ all_ruby_unpack() { # one .gem file, since we won't support that at all. [[ -d "${S}" ]] && die "Unable to unpack ${archive}, ${S} exists" - ebegin "Unpacking .gem file..." + einfo "Unpacking .gem file..." tar -mxf "${DISTDIR}"/${archive} || die - eend $? - ebegin "Uncompressing metadata" + einfo "Uncompressing metadata" gunzip metadata.gz || die - eend $? mkdir "${S}" pushd "${S}" &>/dev/null || die - ebegin "Unpacking data.tar.gz" + einfo "Unpacking data.tar.gz" tar -mxf "${my_WORKDIR}"/data.tar.gz || die - eend $? popd &>/dev/null || die ;; diff --git a/eclass/ruby-ng.eclass b/eclass/ruby-ng.eclass index 72e714129715..70cb5be74b87 100644 --- a/eclass/ruby-ng.eclass +++ b/eclass/ruby-ng.eclass @@ -412,6 +412,7 @@ _ruby_invoke_environment() { ebegin "Running ${_PHASE:-${EBUILD_PHASE}} phase for $environment" "$@" + eend $? popd &>/dev/null || die S=${old_S} diff --git a/eclass/tests/multiprocessing_makeopts_jobs.sh b/eclass/tests/multiprocessing_makeopts_jobs.sh index 70a6085d5362..37d5a7257775 100755 --- a/eclass/tests/multiprocessing_makeopts_jobs.sh +++ b/eclass/tests/multiprocessing_makeopts_jobs.sh @@ -16,14 +16,19 @@ test-makeopts_jobs() { tend 1 "Mismatch between MAKEOPTS/cli: '${indirect}' != '${direct}'" else [[ ${direct} == "${exp}" ]] - tend $? "Got back: ${act}" + tend $? "Got back: ${direct}" fi } +# override to avoid relying on a specific value +get_nproc() { + echo 41 +} + tests=( - 999 "-j" - 999 "--jobs" - 999 "-j -l9" + 42 "-j" + 42 "--jobs" + 42 "-j -l9" 1 "" 1 "-l9 -w" 1 "-l9 -w-j4" @@ -37,7 +42,7 @@ tests=( 7 "-l3 --jobs 7 -w" 4 "-j1 -j 2 --jobs 3 --jobs=4" 8 " -j 8 " - 999 "-kj" + 42 "-kj" 4 "-kj4" 5 "-kj 5" ) diff --git a/eclass/tests/python-utils-r1.sh b/eclass/tests/python-utils-r1.sh index ef7687b8a9cf..6abf10cadabd 100755 --- a/eclass/tests/python-utils-r1.sh +++ b/eclass/tests/python-utils-r1.sh @@ -64,6 +64,8 @@ tmpfile=$(mktemp) inherit python-utils-r1 +ebegin "Testing python2.7" +eindent test_var EPYTHON python2_7 python2.7 test_var PYTHON python2_7 /usr/bin/python2.7 if [[ -x /usr/bin/python2.7 ]]; then @@ -76,77 +78,64 @@ if [[ -x /usr/bin/python2.7 ]]; then fi test_var PYTHON_PKG_DEP python2_7 '*dev-lang/python*:2.7' test_var PYTHON_SCRIPTDIR python2_7 /usr/lib/python-exec/python2.7 +eoutdent -test_var EPYTHON python3_6 python3.6 -test_var PYTHON python3_6 /usr/bin/python3.6 -if [[ -x /usr/bin/python3.6 ]]; then - abiflags=$(/usr/bin/python3.6 -c 'import sysconfig; print(sysconfig.get_config_var("ABIFLAGS"))') - test_var PYTHON_SITEDIR python3_6 "/usr/lib*/python3.6/site-packages" - test_var PYTHON_INCLUDEDIR python3_6 "/usr/include/python3.6${abiflags}" - test_var PYTHON_LIBPATH python3_6 "/usr/lib*/libpython3.6${abiflags}$(get_libname)" - test_var PYTHON_CONFIG python3_6 "/usr/bin/python3.6${abiflags}-config" - test_var PYTHON_CFLAGS python3_6 "*-I/usr/include/python3.6*" - test_var PYTHON_LIBS python3_6 "*-lpython3.6*" -fi -test_var PYTHON_PKG_DEP python3_6 '*dev-lang/python*:3.6' -test_var PYTHON_SCRIPTDIR python3_6 /usr/lib/python-exec/python3.6 - -test_var EPYTHON python3_7 python3.7 -test_var PYTHON python3_7 /usr/bin/python3.7 -if [[ -x /usr/bin/python3.7 ]]; then - abiflags=$(/usr/bin/python3.7 -c 'import sysconfig; print(sysconfig.get_config_var("ABIFLAGS"))') - test_var PYTHON_SITEDIR python3_7 "/usr/lib/python3.7/site-packages" - test_var PYTHON_INCLUDEDIR python3_7 "/usr/include/python3.7${abiflags}" - test_var PYTHON_LIBPATH python3_7 "/usr/lib*/libpython3.7${abiflags}$(get_libname)" - test_var PYTHON_CONFIG python3_7 "/usr/bin/python3.7${abiflags}-config" - test_var PYTHON_CFLAGS python3_7 "*-I/usr/include/python3.7*" - test_var PYTHON_LIBS python3_7 "*-lpython3.7*" -fi -test_var PYTHON_PKG_DEP python3_7 '*dev-lang/python*:3.7' -test_var PYTHON_SCRIPTDIR python3_7 /usr/lib/python-exec/python3.7 - -test_var EPYTHON python3_8 python3.8 -test_var PYTHON python3_8 /usr/bin/python3.8 -if [[ -x /usr/bin/python3.8 ]]; then - abiflags=$(/usr/bin/python3.8 -c 'import sysconfig; print(sysconfig.get_config_var("ABIFLAGS"))') - test_var PYTHON_SITEDIR python3_8 "/usr/lib/python3.8/site-packages" - test_var PYTHON_INCLUDEDIR python3_8 "/usr/include/python3.8${abiflags}" - test_var PYTHON_LIBPATH python3_8 "/usr/lib*/libpython3.8${abiflags}$(get_libname)" - test_var PYTHON_CONFIG python3_8 "/usr/bin/python3.8${abiflags}-config" - test_var PYTHON_CFLAGS python3_8 "*-I/usr/include/python3.8*" - test_var PYTHON_LIBS python3_8 "*-lpython3.8*" -fi -test_var PYTHON_PKG_DEP python3_8 '*dev-lang/python*:3.8' -test_var PYTHON_SCRIPTDIR python3_8 /usr/lib/python-exec/python3.8 - -test_var EPYTHON python3_9 python3.9 -test_var PYTHON python3_9 /usr/bin/python3.9 -if [[ -x /usr/bin/python3.9 ]]; then - abiflags=$(/usr/bin/python3.9 -c 'import sysconfig; print(sysconfig.get_config_var("ABIFLAGS"))') - test_var PYTHON_SITEDIR python3_9 "/usr/lib/python3.9/site-packages" - test_var PYTHON_INCLUDEDIR python3_9 "/usr/include/python3.9${abiflags}" - test_var PYTHON_LIBPATH python3_9 "/usr/lib*/libpython3.9${abiflags}$(get_libname)" - test_var PYTHON_CONFIG python3_9 "/usr/bin/python3.9${abiflags}-config" - test_var PYTHON_CFLAGS python3_9 "*-I/usr/include/python3.9*" - test_var PYTHON_LIBS python3_9 "*-lpython3.9*" -fi -test_var PYTHON_PKG_DEP python3_9 '*dev-lang/python*:3.9' -test_var PYTHON_SCRIPTDIR python3_9 /usr/lib/python-exec/python3.9 - -test_var EPYTHON python3_10 python3.10 -test_var PYTHON python3_10 /usr/bin/python3.10 -if [[ -x /usr/bin/python3.10 ]]; then - abiflags=$(/usr/bin/python3.10 -c 'import sysconfig; print(sysconfig.get_config_var("ABIFLAGS"))') - test_var PYTHON_SITEDIR python3_10 "/usr/lib/python3.10/site-packages" - test_var PYTHON_INCLUDEDIR python3_10 "/usr/include/python3.10${abiflags}" - test_var PYTHON_LIBPATH python3_10 "/usr/lib*/libpython3.10${abiflags}$(get_libname)" - test_var PYTHON_CONFIG python3_10 "/usr/bin/python3.10${abiflags}-config" - test_var PYTHON_CFLAGS python3_10 "*-I/usr/include/python3.10*" - test_var PYTHON_LIBS python3_10 "*-lpython3.10*" -fi -test_var PYTHON_PKG_DEP python3_10 '*dev-lang/python*:3.10' -test_var PYTHON_SCRIPTDIR python3_10 /usr/lib/python-exec/python3.10 +for minor in 6 7 8 9 10 11; do + ebegin "Testing python3.${minor}" + eindent + test_var EPYTHON "python3_${minor}" "python3.${minor}" + test_var PYTHON "python3_${minor}" "/usr/bin/python3.${minor}" + if [[ -x /usr/bin/python3.${minor} ]]; then + abiflags=$(/usr/bin/python3.${minor} -c 'import sysconfig; print(sysconfig.get_config_var("ABIFLAGS"))') + test_var PYTHON_SITEDIR "python3_${minor}" "/usr/lib*/python3.${minor}/site-packages" + test_var PYTHON_INCLUDEDIR "python3_${minor}" "/usr/include/python3.${minor}${abiflags}" + test_var PYTHON_LIBPATH "python3_${minor}" "/usr/lib*/libpython3.${minor}${abiflags}$(get_libname)" + test_var PYTHON_CONFIG "python3_${minor}" "/usr/bin/python3.${minor}${abiflags}-config" + test_var PYTHON_CFLAGS "python3_${minor}" "*-I/usr/include/python3.${minor}*" + test_var PYTHON_LIBS "python3_${minor}" "*-lpython3.${minor}*" + fi + test_var PYTHON_PKG_DEP "python3_${minor}" "*dev-lang/python*:3.${minor}" + test_var PYTHON_SCRIPTDIR "python3_${minor}" "/usr/lib/python-exec/python3.${minor}" + + tbegin "Testing that python3_${minor} is present in an impl array" + has "python3_${minor}" "${_PYTHON_ALL_IMPLS[@]}" + has_in_all=${?} + has "python3_${minor}" "${_PYTHON_HISTORICAL_IMPLS[@]}" + has_in_historical=${?} + if [[ ${has_in_all} -eq ${has_in_historical} ]]; then + if [[ ${has_in_all} -eq 1 ]]; then + eerror "python3_${minor} not found in _PYTHON_ALL_IMPLS or _PYTHON_HISTORICAL_IMPLS" + else + eerror "python3_${minor} listed both in _PYTHON_ALL_IMPLS and _PYTHON_HISTORICAL_IMPLS" + fi + fi + tend ${?} + + tbegin "Testing that PYTHON_COMPAT accepts the impl" + ( + # NB: we add pypy3 as we need to always have at least one + # non-historical impl + PYTHON_COMPAT=( pypy3 "python3_${minor}" ) + _python_set_impls + ) + tend ${?} + + # these tests apply to py3.8+ only + if [[ ${minor} -ge 8 ]]; then + tbegin "Testing that _python_verify_patterns accepts stdlib version" + ( _python_verify_patterns "3.${minor}" ) + tend ${?} + + tbegin "Testing _python_impl_matches on stdlib version" + _python_impl_matches "python3_${minor}" "3.${minor}" + tend ${?} + fi + + eoutdent +done +ebegin "Testing pypy3" +eindent test_var EPYTHON pypy3 pypy3 test_var PYTHON pypy3 /usr/bin/pypy3 if [[ -x /usr/bin/pypy3 ]]; then @@ -155,9 +144,10 @@ if [[ -x /usr/bin/pypy3 ]]; then fi test_var PYTHON_PKG_DEP pypy3 '*dev-python/pypy3*:0=' test_var PYTHON_SCRIPTDIR pypy3 /usr/lib/python-exec/pypy3 +eoutdent for EPREFIX in '' /foo; do - einfo "with EPREFIX=${EPREFIX@Q}" + einfo "Testing python_fix_shebang with EPREFIX=${EPREFIX@Q}" eindent # generic shebangs test_fix_shebang '#!/usr/bin/python' python3.6 \ @@ -212,6 +202,8 @@ for EPREFIX in '' /foo; do done # check _python_impl_matches behavior +einfo "Testing python_impl_matches" +eindent test_is "_python_impl_matches python3_6 -3" 0 test_is "_python_impl_matches python3_7 -3" 0 test_is "_python_impl_matches pypy3 -3" 0 @@ -223,6 +215,16 @@ test_is "_python_impl_matches python3_6 python*" 0 test_is "_python_impl_matches python3_7 python*" 0 test_is "_python_impl_matches pypy3 python*" 1 set +f +test_is "_python_impl_matches python3_8 3.8" 0 +test_is "_python_impl_matches python3_8 3.9" 1 +test_is "_python_impl_matches python3_8 3.10" 1 +test_is "_python_impl_matches python3_9 3.8" 1 +test_is "_python_impl_matches python3_9 3.9" 0 +test_is "_python_impl_matches python3_9 3.10" 1 +test_is "_python_impl_matches pypy3 3.8" 1 +test_is "_python_impl_matches pypy3 3.9" 0 +test_is "_python_impl_matches pypy3 3.10" 1 +eoutdent rm "${tmpfile}" diff --git a/eclass/tests/qmail.sh b/eclass/tests/qmail.sh index 8cf0abdae1a6..16e52741c23c 100755 --- a/eclass/tests/qmail.sh +++ b/eclass/tests/qmail.sh @@ -13,7 +13,8 @@ test_low_numbers() { for i in $(seq 0 6); do if is_prime ${i}; then - return tend 1 "${i} badly accepted" + tend 1 "${i} badly accepted" + return fi done diff --git a/eclass/toolchain.eclass b/eclass/toolchain.eclass index 8788e72efebb..1bbacfa2bdb4 100644 --- a/eclass/toolchain.eclass +++ b/eclass/toolchain.eclass @@ -83,15 +83,18 @@ GCCMICRO=$(ver_cut 3 ${GCC_PV}) # Ideally this variable should allow for custom gentoo versioning # of binary and gcc-config names not directly tied to upstream -# versioning. In practive it's hard to untangle from gcc/BASE-VER +# versioning. In practice it's hard to untangle from gcc/BASE-VER # (GCC_RELEASE_VER) value. GCC_CONFIG_VER=${GCC_RELEASE_VER} # Pre-release support. Versioning schema: # 1.0.0_pre9999: live ebuild -# 1.2.3_pYYYYMMDD: weekly snapshots +# 1.2.3_pYYYYMMDD (or 1.2.3_preYYYYMMDD for unreleased major versions): weekly snapshots # 1.2.3_rcYYYYMMDD: release candidates -if [[ ${GCC_PV} == *_p* ]] ; then +if [[ ${GCC_PV} == *_pre* ]] ; then + # weekly snapshots + SNAPSHOT=${GCCMAJOR}-${GCC_PV##*_pre} +elif [[ ${GCC_PV} == *_p* ]] ; then # weekly snapshots SNAPSHOT=${GCCMAJOR}-${GCC_PV##*_p} elif [[ ${GCC_PV} == *_rc* ]] ; then @@ -241,7 +244,7 @@ fi if tc_has_feature sanitize ; then # libsanitizer relies on 'crypt.h' to be present # on target. glibc user to provide it unconditionally. - # Nowadays it's a standalone library: #802648 + # Nowadays it's a standalone library: bug #802648 DEPEND+=" sanitize? ( virtual/libcrypt )" fi @@ -251,7 +254,8 @@ if tc_has_feature systemtap ; then fi if tc_has_feature zstd ; then - DEPEND+=" zstd? ( app-arch/zstd )" + DEPEND+=" zstd? ( app-arch/zstd:= )" + RDEPEND+=" zstd? ( app-arch/zstd:= )" fi if tc_has_feature valgrind; then @@ -262,17 +266,21 @@ PDEPEND=">=sys-devel/gcc-config-2.3" #---->> S + SRC_URI essentials <<---- +: ${TOOLCHAIN_SET_S:=yes} + # Set the source directory depending on whether we're using # a live git tree, snapshot, or release tarball. -S=$( - if tc_is_live ; then - echo ${EGIT_CHECKOUT_DIR} - elif [[ -n ${SNAPSHOT} ]] ; then - echo ${WORKDIR}/gcc-${SNAPSHOT} - else - echo ${WORKDIR}/gcc-${GCC_RELEASE_VER} - fi -) +if [[ ${TOOLCHAIN_SET_S} == yes ]] ; then + S=$( + if tc_is_live ; then + echo ${EGIT_CHECKOUT_DIR} + elif [[ -n ${SNAPSHOT} ]] ; then + echo ${WORKDIR}/gcc-${SNAPSHOT} + else + echo ${WORKDIR}/gcc-${GCC_RELEASE_VER} + fi + ) +fi gentoo_urls() { local devspace=" @@ -309,7 +317,7 @@ gentoo_urls() { # PATCH_GCC_VER # This should be set to the version of the gentoo patch tarball. # The resulting filename of this tarball will be: -# gcc-${PATCH_GCC_VER:-${GCC_RELEASE_VER}}-patches-${PATCH_VER}.tar.bz2 +# gcc-${PATCH_GCC_VER:-${GCC_RELEASE_VER}}-patches-${PATCH_VER}.tar.xz # # PIE_VER # PIE_GCC_VER @@ -321,7 +329,7 @@ gentoo_urls() { # PIE_VER="8.7.6.5" # PIE_GCC_VER="3.4.0" # The resulting filename of this tarball will be: -# gcc-${PIE_GCC_VER:-${GCC_RELEASE_VER}}-piepatches-v${PIE_VER}.tar.bz2 +# gcc-${PIE_GCC_VER:-${GCC_RELEASE_VER}}-piepatches-v${PIE_VER}.tar.xz # # SPECS_VER # SPECS_GCC_VER @@ -333,7 +341,7 @@ gentoo_urls() { # SPECS_VER="8.7.6.5" # SPECS_GCC_VER="3.4.0" # The resulting filename of this tarball will be: -# gcc-${SPECS_GCC_VER:-${GCC_RELEASE_VER}}-specs-${SPECS_VER}.tar.bz2 +# gcc-${SPECS_GCC_VER:-${GCC_RELEASE_VER}}-specs-${SPECS_VER}.tar.xz # # CYGWINPORTS_GITREV # If set, this variable signals that we should apply additional patches @@ -366,18 +374,26 @@ get_gcc_src_uri() { fi fi + local PATCH_SUFFIX="xz" + if ! tc_version_is_at_least 9.4.1_p20220317 || tc_version_is_between 9 9.5 \ + || tc_version_is_between 10 10.4 || tc_version_is_between 11 11.4 \ + || tc_version_is_between 12 12.0.1_pre20220424 ; then + # These are versions before we started to use .xz + PATCH_SUFFIX="bz2" + fi + [[ -n ${PATCH_VER} ]] && \ - GCC_SRC_URI+=" $(gentoo_urls gcc-${PATCH_GCC_VER}-patches-${PATCH_VER}.tar.bz2)" + GCC_SRC_URI+=" $(gentoo_urls gcc-${PATCH_GCC_VER}-patches-${PATCH_VER}.tar.${PATCH_SUFFIX})" [[ -n ${MUSL_VER} ]] && \ - GCC_SRC_URI+=" $(gentoo_urls gcc-${MUSL_GCC_VER}-musl-patches-${MUSL_VER}.tar.bz2)" + GCC_SRC_URI+=" $(gentoo_urls gcc-${MUSL_GCC_VER}-musl-patches-${MUSL_VER}.tar.${PATCH_SUFFIX})" [[ -n ${PIE_VER} ]] && \ - PIE_CORE=${PIE_CORE:-gcc-${PIE_GCC_VER}-piepatches-v${PIE_VER}.tar.bz2} && \ + PIE_CORE=${PIE_CORE:-gcc-${PIE_GCC_VER}-piepatches-v${PIE_VER}.tar.${PATCH_SUFFIX}} && \ GCC_SRC_URI+=" $(gentoo_urls ${PIE_CORE})" # gcc minispec for the hardened gcc 4 compiler [[ -n ${SPECS_VER} ]] && \ - GCC_SRC_URI+=" $(gentoo_urls gcc-${SPECS_GCC_VER}-specs-${SPECS_VER}.tar.bz2)" + GCC_SRC_URI+=" $(gentoo_urls gcc-${SPECS_GCC_VER}-specs-${SPECS_VER}.tar.${PATCH_SUFFIX})" if tc_has_feature gcj ; then if tc_version_is_at_least 4.5 ; then diff --git a/eclass/tree-sitter-grammar.eclass b/eclass/tree-sitter-grammar.eclass index f1ec619be02c..69ad467f8be7 100644 --- a/eclass/tree-sitter-grammar.eclass +++ b/eclass/tree-sitter-grammar.eclass @@ -10,6 +10,8 @@ # @SUPPORTED_EAPIS: 8 # @BLURB: Common functions and variables for Tree Sitter grammars +inherit edo + if [[ -z ${_TREE_SITTER_GRAMMAR_ECLASS} ]]; then _TREE_SITTER_GRAMMAR_ECLASS=1 @@ -74,7 +76,7 @@ tree-sitter-grammar_src_compile() { fi local soname=lib${PN}$(get_libname $(_get_tsg_abi_ver)) - ${link} ${LDFLAGS} \ + edo ${link} ${LDFLAGS} \ -shared \ *.o \ -Wl,--soname=${soname} \ diff --git a/eclass/user-info.eclass b/eclass/user-info.eclass index 3838585ab6c1..5550e4f08eeb 100644 --- a/eclass/user-info.eclass +++ b/eclass/user-info.eclass @@ -23,6 +23,7 @@ _USER_INFO_ECLASS=1 # dscl (Mac OS X 10.5), and pw (FreeBSD) used in enewuser()/enewgroup(). # # Supported databases: group passwd +# Warning: This function can be used only in pkg_* phases when ROOT is valid. egetent() { local db=$1 key=$2 @@ -43,18 +44,31 @@ egetent() { # lookup by uid/gid local opts if [[ ${key} == [[:digit:]]* ]] ; then - [[ ${db} == "user" ]] && opts="-u" || opts="-g" + [[ ${db} == "user" ]] && opts=( -u ) || opts=( -g ) fi + # Handle different ROOT + [[ -n ${ROOT} ]] && opts+=( -R "${ROOT}" ) + pw show ${db} ${opts} "${key}" -q ;; *-openbsd*) - grep "${key}:\*:" /etc/${db} + grep "${key}:\*:" "${EROOT}/etc/${db}" ;; *) - # ignore nscd output if we're not running as root - type -p nscd >/dev/null && nscd -i "${db}" 2>/dev/null - getent "${db}" "${key}" + # getent does not support -R option, if we are working on a different + # ROOT than /, fallback to grep technique. + if [[ -z ${ROOT} ]]; then + # ignore nscd output if we're not running as root + type -p nscd >/dev/null && nscd -i "${db}" 2>/dev/null + getent "${db}" "${key}" + else + if [[ ${key} =~ ^[[:digit:]]+$ ]]; then + grep -E "^([^:]*:){2}${key}" "${ROOT}/etc/${db}" + else + grep "^${key}:" "${ROOT}/etc/${db}" + fi + fi ;; esac } @@ -151,7 +165,16 @@ egetgroups() { [[ $# -eq 1 ]] || die "usage: egetgroups " local egroups_arr - read -r -a egroups_arr < <(id -G -n "$1") + if [[ -n "${ROOT}" ]]; then + local pgroup=$(egetent passwd "$1" | cut -d: -f1) + local sgroups=( $(grep -E ":([^:]*,)?$1(,[^:]*)?$" "${ROOT}/etc/group" | cut -d: -f1) ) + + # Remove primary group from list + sgroups=${sgroups#${pgroup}} + egroups_arr=( ${pgroup} ${sgroups[@]} ) + else + read -r -a egroups_arr < <(id -G -n "$1") + fi local g groups=${egroups_arr[0]} # sort supplementary groups to make comparison possible diff --git a/eclass/user.eclass b/eclass/user.eclass index ff69be81c1ec..aab549d0c473 100644 --- a/eclass/user.eclass +++ b/eclass/user.eclass @@ -117,6 +117,9 @@ enewuser() { # options to pass to useradd local opts=() + # handle for ROOT != / + [[ -n ${ROOT} ]] && opts+=( --prefix "${ROOT}" ) + # handle uid local euid=${1}; shift if [[ -n ${euid} && ${euid} != -1 ]] ; then @@ -207,13 +210,24 @@ enewuser() { ;; *-netbsd*) - useradd "${opts[@]}" "${euser}" || die + if [[ -n "${ROOT}" ]]; then + ewarn "NetBSD's usermod does not support --prefix option." + ewarn "Please use: \"useradd ${opts[@]} ${euser}\" in a chroot" + else + useradd "${opts[@]}" "${euser}" || die + fi ;; *-openbsd*) - # all ops the same, except the -g vs -g/-G ... - useradd -u ${euid} -s "${eshell}" \ - -d "${ehome}" -g "${egroups}" "${euser}" || die + if [[ -n "${ROOT}" ]]; then + ewarn "OpenBSD's usermod does not support --prefix option." + ewarn "Please use: \"useradd ${opts[@]} ${euser}\" in a chroot" + else + # all ops the same, except the -g vs -g/-G ... + useradd -u ${euid} -s "${eshell}" \ + -d "${ehome}" -g "${egroups}" "${euser}" || die + fi + ;; *) @@ -224,6 +238,10 @@ enewuser() { if [[ -n ${create_home} && ! -e ${ROOT}/${ehome} ]] ; then elog " - Creating ${ehome} in ${ROOT}" mkdir -p "${ROOT}/${ehome}" + # Use UID if we are in another ROOT than / + if [[ -n "${ROOT}" ]]; then + euser=$(egetent passwd ${euser} | cut -d: -f3) + fi chown "${euser}" "${ROOT}/${ehome}" chmod 755 "${ROOT}/${ehome}" fi @@ -286,6 +304,10 @@ enewgroup() { fi elog " - Groupid: ${egid}" + # handle different ROOT + local opts + [[ -n ${ROOT} ]] && opts=( --prefix "${ROOT}" ) + # handle extra if [[ $# -gt 0 ]] ; then die "extra arguments no longer supported; please file a bug" @@ -306,24 +328,29 @@ enewgroup() { case ${CHOST} in *-freebsd*|*-dragonfly*) _enewgroup_next_gid - pw groupadd "${egroup}" -g ${egid} || die + pw groupadd "${opts[@]}" "${egroup}" -g ${egid} || die ;; *-netbsd*) - _enewgroup_next_gid - groupadd -g ${egid} "${egroup}" || die + if [[ -n "${ROOT}" ]]; then + ewarn "NetBSD's usermod does not support --prefix option." + ewarn "Please use: \"groupadd -g ${egid} ${opts[@]} ${egroup}\" in a chroot" + else + _enewgroup_next_gid + groupadd -g ${egid} "${opts[@]}" "${egroup}" || die + fi ;; *) - local opts if [[ ${egid} == *[!0-9]* ]] ; then # Non numeric; let groupadd figure out a GID for us - opts="" + # + true # Do nothing but keep the previous comment. else - opts="-g ${egid}" + opts+=( -g ${egid} ) fi # We specify -r so that we get a GID in the system range from login.defs - groupadd -r ${opts} "${egroup}" || die + groupadd -r "${opts[@]}" "${egroup}" || die ;; esac } @@ -353,6 +380,10 @@ esethome() { return 1 fi + # Handle different ROOT + local opts + [[ -n ${ROOT} ]] && opts=( --prefix "${ROOT}" ) + # handle homedir local ehome=${1}; shift if [[ -z ${ehome} ]] ; then @@ -383,15 +414,28 @@ esethome() { # update the home directory case ${CHOST} in *-freebsd*|*-dragonfly*) - pw usermod "${euser}" -d "${ehome}" && return 0 + pw usermod "${opts[@]}" "${euser}" -d "${ehome}" && return 0 [[ $? == 8 ]] && eerror "${euser} is in use, cannot update home" eerror "There was an error when attempting to update the home directory for ${euser}" eerror "Please update it manually on your system:" eerror "\t pw usermod \"${euser}\" -d \"${ehome}\"" ;; + *-netbsd*) + if [[ -n "${ROOT}" ]]; then + ewarn "NetBSD's usermod does not support --prefix option." + ewarn "Please use: \"usermod ${opts[@]} -d ${ehome} ${euser}\" in a chroot" + else + usermod "${opts[@]}" -d "${ehome}" "${euser}" && return 0 + [[ $? == 8 ]] && eerror "${euser} is in use, cannot update home" + eerror "There was an error when attempting to update the home directory for ${euser}" + eerror "Please update it manually on your system (as root):" + eerror "\t usermod -d \"${ehome}\" \"${euser}\"" + fi + ;; + *) - usermod -d "${ehome}" "${euser}" && return 0 + usermod "${opts[@]}" -d "${ehome}" "${euser}" && return 0 [[ $? == 8 ]] && eerror "${euser} is in use, cannot update home" eerror "There was an error when attempting to update the home directory for ${euser}" eerror "Please update it manually on your system (as root):" @@ -422,6 +466,10 @@ esetshell() { return 1 fi + # Handle different ROOT + local opts + [[ -n ${ROOT} ]] && opts=( --prefix "${ROOT}" ) + # handle shell local eshell=${1}; shift if [[ -z ${eshell} ]] ; then @@ -444,15 +492,28 @@ esetshell() { # update the shell case ${CHOST} in *-freebsd*|*-dragonfly*) - pw usermod "${euser}" -s "${eshell}" && return 0 + pw usermod "${opts[@]}" "${euser}" -s "${eshell}" && return 0 [[ $? == 8 ]] && eerror "${euser} is in use, cannot update shell" eerror "There was an error when attempting to update the shell for ${euser}" eerror "Please update it manually on your system:" eerror "\t pw usermod \"${euser}\" -s \"${eshell}\"" ;; + *-netbsd*) + if [[ -n "${ROOT}" ]]; then + ewarn "NetBSD's usermod does not support --prefix option." + ewarn "Please use: \"usermod ${opts[@]} -s ${eshell} ${euser}\" in a chroot" + else + usermod "${opts[@]}" -s "${eshell}" "${euser}" && return 0 + [[ $? == 8 ]] && eerror "${euser} is in use, cannot update shell" + eerror "There was an error when attempting to update the shell for ${euser}" + eerror "Please update it manually on your system (as root):" + eerror "\t usermod -s \"${eshell}\" \"${euser}\"" + fi + ;; + *) - usermod -s "${eshell}" "${euser}" && return 0 + usermod "${opts[@]}" -s "${eshell}" "${euser}" && return 0 [[ $? == 8 ]] && eerror "${euser} is in use, cannot update shell" eerror "There was an error when attempting to update the shell for ${euser}" eerror "Please update it manually on your system (as root):" @@ -482,6 +543,10 @@ esetcomment() { return 1 fi + # Handle different ROOT + local opts + [[ -n ${ROOT} ]] && opts=( --prefix "${ROOT}" ) + # handle comment local ecomment=${1}; shift if [[ -z ${ecomment} ]] ; then @@ -500,15 +565,28 @@ esetcomment() { # update the comment case ${CHOST} in *-freebsd*|*-dragonfly*) - pw usermod "${euser}" -c "${ecomment}" && return 0 + pw usermod "${opts[@]}" "${euser}" -c "${ecomment}" && return 0 [[ $? == 8 ]] && eerror "${euser} is in use, cannot update comment" eerror "There was an error when attempting to update the comment for ${euser}" eerror "Please update it manually on your system:" eerror "\t pw usermod \"${euser}\" -c \"${ecomment}\"" ;; + *-netbsd*) + if [[ -n "${ROOT}" ]]; then + ewarn "NetBSD's usermod does not support --prefix option." + ewarn "Please use: \"usermod ${opts[@]} -c ${ecomment} ${euser}\" in a chroot" + else + usermod "${opts[@]}" -c "${ecomment}" "${euser}" && return 0 + [[ $? == 8 ]] && eerror "${euser} is in use, cannot update shell" + eerror "There was an error when attempting to update the shell for ${euser}" + eerror "Please update it manually on your system (as root):" + eerror "\t usermod -s \"${eshell}\" \"${euser}\"" + fi + ;; + *) - usermod -c "${ecomment}" "${euser}" && return 0 + usermod "${opts[@]}" -c "${ecomment}" "${euser}" && return 0 [[ $? == 8 ]] && eerror "${euser} is in use, cannot update comment" eerror "There was an error when attempting to update the comment for ${euser}" eerror "Please update it manually on your system (as root):" @@ -567,6 +645,9 @@ esetgroups() { elog "Updating groups for user '${euser}' ..." elog " - Groups: ${egroups}" + # Handle different ROOT + [[ -n ${ROOT} ]] && opts+=( --prefix "${ROOT}" ) + # update the group case ${CHOST} in *-freebsd*|*-dragonfly*) @@ -577,6 +658,19 @@ esetgroups() { eerror "\t pw usermod \"${euser}\" ${opts[*]}" ;; + *-netbsd*) + if [[ -n "${ROOT}" ]]; then + ewarn "NetBSD's usermod does not support --prefix option." + ewarn "Please use: \"usermod ${opts[@]} ${euser}\" in a chroot" + else + usermod "${opts[@]}" "${euser}" && return 0 + [[ $? == 8 ]] && eerror "${euser} is in use, cannot update shell" + eerror "There was an error when attempting to update the shell for ${euser}" + eerror "Please update it manually on your system (as root):" + eerror "\t usermod -s \"${eshell}\" \"${euser}\"" + fi + ;; + *) usermod "${opts[@]}" "${euser}" && return 0 [[ $? == 8 ]] && eerror "${euser} is in use, cannot update groups" -- cgit v1.2.3