• [gentoo-dev] [PATCH 1/3] eclass/kernel-{build,install}.eclass: link to

    From Andrew Ammerlaan@21:1/5 to All on Wed Jul 24 12:00:01 2024
    The kernels 'make rpm-pkg' and 'make deb-pkg' install the config
    and System.map into the modules directory for easy access. Let's
    do the same here so our gpkg's are more symetric to rpm's and
    deb's and tools that look for these files there can find it.

    This also provides an easy location for the user to access the
    config. Considering that /boot/config-x.y.z does not always
    exist (the config instalation via /sbin/installkernel depends
    on layout and +/-systemd configuration).

    Signed-off-by: Andrew Ammerlaan <andrewammerlaan@gentoo.org>
    Closes: https://github.com/gentoo/gentoo/pull/37684
    Signed-off-by: Andrew Ammerlaan <andrewammerlaan@gentoo.org>
    ---
    eclass/kernel-build.eclass | 2 ++
    eclass/kernel-install.eclass | 7 +++++++
    2 files changed, 9 insertions(+)

    diff --git a/eclass/kernel-build.eclass b/eclass/kernel-build.eclass
    index be0256c21102..29719609b912 100644
    --- a/eclass/kernel-build.eclass
    +++ b/eclass/kernel-build.eclass
    @@ -448,6 +448,8 @@ kernel-build_src_install() {
    # fix source tree and build dir symlinks
    dosym "../../../${kernel_dir}" "/lib/modules/${KV_FULL}/build"
    dosym "../../../${kernel_dir}" "/lib/modules/${KV_FULL}/source"
    + dosym "../../../${kernel_dir}/.config" "/lib/modules/${KV_FULL}/config" + dosym "../../../${kernel_dir}/System.map" "/lib/modules/${KV_FULL}/System.map"
    if [[ "${image_path}" == *vmlinux* ]]; then
    dosym "../../../${kernel_dir}/${image_path}" "/lib/modules/${KV_FULL}/vmlinux"
    else
    diff --git a/eclass/kernel-install.eclass b/eclass/kernel-install.eclass
    index e6f0b404dcaa..0a85bfb8629d 100644
    --- a/eclass/kernel-install.eclass
    +++ b/eclass/kernel-install.eclass
    @@ -623,6 +62
  • From Andrew Ammerlaan@21:1/5 to All on Wed Jul 24 12:00:01 2024
    For module-less kernels 'make modules_prepare' does nothing, we only get kernel.release after running src_compile. Luckily the kernel has the "kernelrelease" target which we can use for this purpose.

    Note, in kernel-install.eclass we still read the kernel release directly from the file since a) kernel.release will always exist and b) calling make there again would require duplicating (some subset off) ${MAKEARGS[@]}.

    The "make help" page specifies that this target should be called with "-s".

    The version check is moved up, before 'make modules_prepare' so we quit earlier if the KV_FULL is wrong. Note it should be run after we have completed the config in 'make olddefconfig'.

    Signed-off-by: Andrew Ammerlaan <andrewammerlaan@gentoo.org>
    Closes: https://github.com/gentoo/gentoo/pull/37694
    Signed-off-by: Andrew Ammerlaan <andrewammerlaan@gentoo.org>
    ---
    eclass/kernel-build.eclass | 17 ++++++++---------
    1 file changed, 8 insertions(+), 9 deletions(-)

    diff --git a/eclass/kernel-build.eclass b/eclass/kernel-build.eclass
    index 29719609b912..f478cf636a27 100644
    --- a/eclass/kernel-build.eclass
    +++ b/eclass/kernel-build.eclass
    @@ -253,25 +253,21 @@ kernel-build_src_configure() {
    mkdir -p "${WORKDIR}"/modprep || die
    mv .config "${WORKDIR}"/modprep/ || die
    emake O="${WORKDIR}"/modprep "${MAKEARGS[@]}" olddefconfig
    - emake O="${WORKDIR}"/modprep "${MAKEARGS[@]}" modules_prepare
    - cp -pR "${WORKDIR}"/modprep "${WORKDIR}"/build || die

    - # Now that we have a release file, set KV_FULL
    - local relfile=${WORKDIR}/build/include/config/kernel.release
    + local k_release=$(emake -s O="${WORKDIR}"/modprep "${MAKEARGS[@]}" kernelrelease)
    if [[ -z ${KV_FULL} ]]; then
    - KV_FULL=$(<"${relfile}") || die
    + KV_FULL=${k_release}
    fi

    # Make sure we are about to build the correct kernel
    if [[ ${PV} != *9999 ]]; then
    local expected_ver=$(