• [gentoo-dev] [PATCH 1/3] dist-kernel-utils.eclass: Add dist-kernel_comp

    From =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?@21:1/5 to All on Thu Dec 28 13:30:01 2023
    Signed-off-by: Michał Górny <mgorny@gentoo.org>
    ---
    eclass/dist-kernel-utils.eclass | 37 +++++++++++++++++++++++++++++++++
    1 file changed, 37 insertions(+)

    diff --git a/eclass/dist-kernel-utils.eclass b/eclass/dist-kernel-utils.eclass index 67cb802151b2..8ccffd038474 100644
    --- a/eclass/dist-kernel-utils.eclass
    +++ b/eclass/dist-kernel-utils.eclass
    @@ -210,5 +210,42 @@ dist-kernel_PV_to_KV() {
    echo "${kv}"
    }

    +# @FUNCTION: dist-kernel_compressed_module_cleanup
    +# @USAGE: <path>
    +# @DESCRIPTION:
    +# Traverse path for duplicate (un)compressed modules and remove all
    +# but the newest variant.
    +dist-kernel_compressed_module_cleanup() {
    + debug-print-function ${FUNCNAME} "${@}"
    +
    + [[ ${#} -ne 1 ]] && die "${FUNCNAME}: invalid arguments"
    + local path=${1}
    + local basename f
    +
    + while read -r basename; do
    + local prev=
    + for f in "${path}/${basename}"{,.gz,.xz,.zst}; do
    + if [[ ! -e ${f} ]]; then
    + continue
    + elif [[ -z ${prev} ]]; then
    + prev=${f}
    + elif [[ ${f} -nt ${prev} ]]; then
    + rm -v "${prev}" || die
  • From =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?@21:1/5 to All on Thu Dec 28 13:30:01 2023
    Signed-off-by: Michał Górny <mgorny@gentoo.org>
    ---
    eclass/kernel-install.eclass | 3 +++
    1 file changed, 3 insertions(+)

    diff --git a/eclass/kernel-install.eclass b/eclass/kernel-install.eclass
    index af4f5d839b0e..b4c3d5fe7b4d 100644
    --- a/eclass/kernel-install.eclass
    +++ b/eclass/kernel-install.eclass
    @@ -592,6 +592,7 @@ kernel-install_pkg_preinst() {
    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
    @@ -706,6 +707,8 @@ kernel-install_pkg_postinst() {

    local dir_ver=${PV}${KV_LOCALVERSION}
    kernel-install_update_symlink "${EROOT}/usr/src/linux" "${dir_ver}"
    + dist-kernel_compressed_module_cleanup \
    + "${EROOT}/lib/modules/${DIST_KERNEL_RELEASE}"

    if [[ -z ${ROOT} ]]; then
    kernel-install_install_all "${dir_ver}"
    --
    2.43.0

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?@21:1/5 to All on Thu Dec 28 13:30:01 2023
    Signed-off-by: Michał Górny <mgorny@gentoo.org>
    ---
    eclass/linux-mod-r1.eclass | 3 ++-
    1 file changed, 2 insertions(+), 1 deletion(-)

    diff --git a/eclass/linux-mod-r1.eclass b/eclass/linux-mod-r1.eclass
    index 54df2406e5c7..67a4b64eb481 100644
    --- a/eclass/linux-mod-r1.eclass
    +++ b/eclass/linux-mod-r1.eclass
    @@ -109,7 +109,7 @@ esac
    if [[ ! ${_LINUX_MOD_R1_ECLASS} ]]; then
    _LINUX_MOD_R1_ECLASS=1

    -inherit edo linux-info multiprocessing toolchain-funcs
    +inherit dist-kernel-utils edo linux-info multiprocessing toolchain-funcs

    IUSE="dist-kernel modules-compress modules-sign +strip ${MODULES_OPTIONAL_IUSE}"

    @@ -468,6 +468,7 @@ linux-mod-r1_pkg_postinst() {
    debug-print-function ${FUNCNAME[0]} "${@}"
    _modules_check_function ${#} 0 0 || return 0

    + dist-kernel_compressed_module_cleanup "${EROOT}/lib/modules/${KV_FULL}"
    _modules_update_depmod

    # post_process ensures modules were installed and that the eclass' USE --
    2.43.0

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)