diff options
author | V3n3RiX <venerix@koprulu.sector> | 2022-10-19 13:58:24 +0100 |
---|---|---|
committer | V3n3RiX <venerix@koprulu.sector> | 2022-10-19 13:58:24 +0100 |
commit | 12652841746da7ae2f03b8b0c571a9bd5033e15c (patch) | |
tree | 17ba3a2b3f142284453d0e9109be1765200f643b /eclass | |
parent | 27f7ac2204449d9fc2137f442522b4fb10327d90 (diff) |
gentoo auto-resync : 19:10:2022 - 13:58:24
Diffstat (limited to 'eclass')
-rw-r--r-- | eclass/Manifest.gz | bin | 37493 -> 37643 bytes | |||
-rw-r--r-- | eclass/dist-kernel-utils.eclass | 16 | ||||
-rw-r--r-- | eclass/kernel-build.eclass | 6 | ||||
-rw-r--r-- | eclass/kernel-install.eclass | 40 | ||||
-rw-r--r-- | eclass/llvm.eclass | 63 | ||||
-rwxr-xr-x | eclass/tests/dist-kernel-utils.sh | 28 |
6 files changed, 133 insertions, 20 deletions
diff --git a/eclass/Manifest.gz b/eclass/Manifest.gz Binary files differindex 8d8d0da0c692..d92e53e79768 100644 --- a/eclass/Manifest.gz +++ b/eclass/Manifest.gz diff --git a/eclass/dist-kernel-utils.eclass b/eclass/dist-kernel-utils.eclass index 8c1b56f41506..439bdc87695d 100644 --- a/eclass/dist-kernel-utils.eclass +++ b/eclass/dist-kernel-utils.eclass @@ -155,5 +155,21 @@ dist-kernel_reinstall_initramfs() { "${kernel_dir}/System.map" } +# @FUNCTION: dist-kernel_PV_to_KV +# @USAGE: <pv> +# @DESCRIPTION: +# Convert a Gentoo-style ebuild version to kernel "x.y.z[-rcN]" version. +dist-kernel_PV_to_KV() { + debug-print-function ${FUNCNAME} "${@}" + + [[ ${#} -ne 1 ]] && die "${FUNCNAME}: invalid arguments" + local pv=${1} + + local kv=${pv%%_*} + [[ -z $(ver_cut 3- "${kv}") ]] && kv+=".0" + [[ ${pv} == *_* ]] && kv+=-${pv#*_} + echo "${kv}" +} + _DIST_KERNEL_UTILS=1 fi diff --git a/eclass/kernel-build.eclass b/eclass/kernel-build.eclass index 7cada85e79fe..a77a24534c11 100644 --- a/eclass/kernel-build.eclass +++ b/eclass/kernel-build.eclass @@ -150,7 +150,7 @@ kernel-build_src_test() { emake O="${WORKDIR}"/build "${MAKEARGS[@]}" \ INSTALL_MOD_PATH="${T}" "${targets[@]}" - local ver="${PV}${KV_LOCALVERSION}" + local ver="${KV_FULL}${KV_LOCALVERSION}" kernel-install_test "${ver}" \ "${WORKDIR}/build/$(dist-kernel_get_image_path)" \ "${T}/lib/modules/${ver}" @@ -159,7 +159,7 @@ kernel-build_src_test() { # @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} "${@}" @@ -177,7 +177,7 @@ kernel-build_src_install() { # 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 ver="${PV}${KV_LOCALVERSION}" + local ver="${KV_FULL}${KV_LOCALVERSION}" dodir "/usr/src/linux-${ver}/arch/${kern_arch}" mv include scripts "${ED}/usr/src/linux-${ver}/" || die mv "arch/${kern_arch}/include" \ diff --git a/eclass/kernel-install.eclass b/eclass/kernel-install.eclass index dc77cb514b1a..06260ed61f23 100644 --- a/eclass/kernel-install.eclass +++ b/eclass/kernel-install.eclass @@ -14,20 +14,13 @@ # kinds of Distribution Kernel packages, including both kernels built # from source and distributed as binaries. The eclass relies on the # ebuild installing a subset of built kernel tree into -# /usr/src/linux-${PV} containing the kernel image in its standard -# location and System.map. +# /usr/src/linux-${KV_FULL}${KV_LOCALVERSION} 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. -# @ECLASS_VARIABLE: KV_LOCALVERSION -# @DEFAULT_UNSET -# @DESCRIPTION: -# A string containing the kernel LOCALVERSION, e.g. '-gentoo'. -# Needs to be set only when installing binary kernels, -# kernel-build.eclass obtains it from kernel config. - if [[ ! ${_KERNEL_INSTALL_ECLASS} ]]; then case ${EAPI} in @@ -37,6 +30,19 @@ esac inherit dist-kernel-utils mount-boot toolchain-funcs +# @ECLASS_VARIABLE: KV_FULL +# @DESCRIPTION: +# The "x.y.z[-rcN]" kernel version. The default is derived from PV +# following upstream kernel versioning rules. +: "${KV_FULL:=$(dist-kernel_PV_to_KV "${PV}")}" + +# @ECLASS_VARIABLE: KV_LOCALVERSION +# @DEFAULT_UNSET +# @DESCRIPTION: +# A string containing the kernel LOCALVERSION, e.g. '-gentoo'. +# Needs to be set only when installing binary kernels, +# kernel-build.eclass obtains it from kernel config. + SLOT="${PV}" IUSE="+initramfs test" RESTRICT+=" @@ -403,18 +409,18 @@ kernel-install_src_test() { kernel-install_pkg_preinst() { debug-print-function ${FUNCNAME} "${@}" - local ver="${PV}${KV_LOCALVERSION}" + local ver="${KV_FULL}${KV_LOCALVERSION}" local kdir="${ED}/usr/src/linux-${ver}" local relfile="${kdir}/include/config/kernel.release" [[ ! -d ${kdir} ]] && die "Kernel directory ${kdir} not installed!" [[ ! -f ${relfile} ]] && die "Release file ${relfile} not installed!" local release="$(<"${relfile}")" - if [[ ${release} != ${PV}* ]]; then + if [[ ${release} != ${KV_FULL}* ]]; then eerror "Kernel release mismatch!" - eerror " expected (PV): ${PV}*" - eerror " found: ${release}" + eerror " expected (KV_FULL): ${KV_FULL}*" + eerror " found: ${release}" eerror "Please verify that you are applying the correct patches." - die "Kernel release mismatch (${release} instead of ${PV}*)" + die "Kernel release mismatch (${release} instead of ${KV_FULL}*)" fi if [[ -L ${EROOT}/lib && ${EROOT}/lib -ef ${EROOT}/usr/lib ]]; then # Adjust symlinks for merged-usr. @@ -476,7 +482,7 @@ kernel-install_install_all() { kernel-install_pkg_postinst() { debug-print-function ${FUNCNAME} "${@}" - local ver="${PV}${KV_LOCALVERSION}" + local ver="${KV_FULL}${KV_LOCALVERSION}" kernel-install_update_symlink "${EROOT}/usr/src/linux" "${ver}" if [[ -z ${ROOT} ]]; then @@ -500,7 +506,7 @@ kernel-install_pkg_postrm() { debug-print-function ${FUNCNAME} "${@}" if [[ -z ${ROOT} ]] && use initramfs; then - local ver="${PV}${KV_LOCALVERSION}" + local ver="${KV_FULL}${KV_LOCALVERSION}" local image_path=$(dist-kernel_get_image_path) ebegin "Removing initramfs" rm -f "${EROOT}/usr/src/linux-${ver}/${image_path%/*}"/initrd{,.uefi} && @@ -515,7 +521,7 @@ kernel-install_pkg_postrm() { kernel-install_pkg_config() { [[ -z ${ROOT} ]] || die "ROOT!=/ not supported currently" - kernel-install_install_all "${PV}${KV_LOCALVERSION}" + kernel-install_install_all "${KV_FULL}${KV_LOCALVERSION}" } _KERNEL_INSTALL_ECLASS=1 diff --git a/eclass/llvm.eclass b/eclass/llvm.eclass index 1effcc555905..16596ec2ea66 100644 --- a/eclass/llvm.eclass +++ b/eclass/llvm.eclass @@ -180,6 +180,64 @@ get_llvm_prefix() { die "No LLVM slot${1:+ <= ${1}} satisfying the package's dependencies found installed!" } +# @FUNCTION: llvm_fix_clang_version +# @USAGE: <variable-name>... +# @DESCRIPTION: +# Fix the clang compiler name in specified variables to include +# the major version, to prevent PATH alterations from forcing an older +# clang version being used. +llvm_fix_clang_version() { + debug-print-function ${FUNCNAME} "${@}" + + local shopt_save=$(shopt -p -o noglob) + set -f + local var + for var; do + local split=( ${!var} ) + case ${split[0]} in + *clang|*clang++|*clang-cpp) + local version=() + read -r -a version < <("${split[0]}" --version) + local major=${version[-1]%%.*} + if [[ -n ${major//[0-9]} ]]; then + die "${var}=${!var} produced invalid --version: ${version[*]}" + fi + + split[0]+=-${major} + if ! type -P "${split[0]}" &>/dev/null; then + die "${split[0]} does not seem to exist" + fi + declare -g "${var}=${split[*]}" + ;; + esac + done + ${shopt_save} +} + +# @FUNCTION: llvm_fix_tool_path +# @USAGE: <variable-name>... +# @DESCRIPTION: +# Fix the LLVM tools referenced in the specified variables to their +# current location, to prevent PATH alterations from forcing older +# versions being used. +llvm_fix_tool_path() { + debug-print-function ${FUNCNAME} "${@}" + + local shopt_save=$(shopt -p -o noglob) + set -f + local var + for var; do + local split=( ${!var} ) + local path=$(type -P ${split[0]} 2>/dev/null) + # if it resides in one of the LLVM prefixes, it's an LLVM tool! + if [[ ${path} == "${BROOT}/usr/lib/llvm"* ]]; then + split[0]=${path} + declare -g "${var}=${split[*]}" + fi + done + ${shopt_save} +} + # @FUNCTION: llvm_pkg_setup # @DESCRIPTION: # Prepend the appropriate executable directory for the newest @@ -198,6 +256,11 @@ llvm_pkg_setup() { debug-print-function ${FUNCNAME} "${@}" if [[ ${MERGE_TYPE} != binary ]]; then + llvm_fix_clang_version CC CPP CXX + # keep in sync with profiles/features/llvm/make.defaults! + llvm_fix_tool_path ADDR2LINE AR AS LD NM OBJCOPY OBJDUMP RANLIB + llvm_fix_tool_path READELF STRINGS STRIP + local llvm_path=$(get_llvm_prefix "${LLVM_MAX_SLOT}")/bin local IFS=: local split_path=( ${PATH} ) diff --git a/eclass/tests/dist-kernel-utils.sh b/eclass/tests/dist-kernel-utils.sh new file mode 100755 index 000000000000..7f04f55ce302 --- /dev/null +++ b/eclass/tests/dist-kernel-utils.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash +# Copyright 2022 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +source tests-common.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} + local exp_PV=${2} + + tbegin "dist-kernel_PV_to_KV ${kv} -> ${exp_PV}" + local val=$(dist-kernel_PV_to_KV "${kv}") + [[ ${val} == ${exp_PV} ]] + tend $? +} + +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 + +texit |