diff options
author | David GUGLIELMI <david.guglielmi@gmail.com> | 2020-06-28 16:25:30 +0200 |
---|---|---|
committer | Michał Górny <mgorny@gentoo.org> | 2020-06-29 09:16:08 +0200 |
commit | 1ddeca37606e5b752735d8c96c6a50a2e44d07e0 (patch) | |
tree | 1be0004936e65fbfc25099611dd2bec3965a5831 /eclass | |
parent | media-gfx/scrot: Update live ebuild (diff) | |
download | gentoo-1ddeca37606e5b752735d8c96c6a50a2e44d07e0.tar.gz gentoo-1ddeca37606e5b752735d8c96c6a50a2e44d07e0.tar.bz2 gentoo-1ddeca37606e5b752735d8c96c6a50a2e44d07e0.zip |
kernel-{build,install}.eclass: support Kconfig LOCALVERSION
Signed-off-by: David GUGLIELMI <david.guglielmi@gmail.com>
Closes: https://bugs.gentoo.org/720930
Signed-off-by: Michał Górny <mgorny@gentoo.org>
Diffstat (limited to 'eclass')
-rw-r--r-- | eclass/kernel-build.eclass | 29 | ||||
-rw-r--r-- | eclass/kernel-install.eclass | 36 |
2 files changed, 41 insertions, 24 deletions
diff --git a/eclass/kernel-build.eclass b/eclass/kernel-build.eclass index 298e3aed7374..9f7a8e3296f0 100644 --- a/eclass/kernel-build.eclass +++ b/eclass/kernel-build.eclass @@ -79,6 +79,11 @@ kernel-build_src_configure() { restore_config .config [[ -f .config ]] || die "Ebuild error: please copy default config into .config" + if [[ -z "${KV_LOCALVERSION}" ]]; then + KV_LOCALVERSION=$(sed -n -e 's#^CONFIG_LOCALVERSION="\(.*\)"$#\1#p' \ + .config) + fi + mkdir -p "${WORKDIR}"/modprep || die mv .config "${WORKDIR}"/modprep/ || die emake O="${WORKDIR}"/modprep "${MAKEARGS[@]}" olddefconfig @@ -110,9 +115,10 @@ kernel-build_src_test() { emake O="${WORKDIR}"/build "${MAKEARGS[@]}" \ INSTALL_MOD_PATH="${T}" INSTALL_PATH="${ED}/boot" "${targets[@]}" - kernel-install_test "${PV}" \ + local ver="${PV}${KV_LOCALVERSION}" + kernel-install_test "${ver}" \ "${WORKDIR}/build/$(kernel-install_get_image_path)" \ - "${T}/lib/modules/${PV}" + "${T}/lib/modules/${ver}" } # @FUNCTION: kernel-build_src_install @@ -136,16 +142,17 @@ 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) - dodir "/usr/src/linux-${PV}/arch/${kern_arch}" - mv include scripts "${ED}/usr/src/linux-${PV}/" || die + local ver="${PV}${KV_LOCALVERSION}" + dodir "/usr/src/linux-${ver}/arch/${kern_arch}" + mv include scripts "${ED}/usr/src/linux-${ver}/" || die mv "arch/${kern_arch}/include" \ - "${ED}/usr/src/linux-${PV}/arch/${kern_arch}/" || die + "${ED}/usr/src/linux-${ver}/arch/${kern_arch}/" || die # remove everything but Makefile* and Kconfig* find -type f '!' '(' -name 'Makefile*' -o -name 'Kconfig*' ')' \ -delete || die find -type l -delete || die - cp -p -R * "${ED}/usr/src/linux-${PV}/" || die + cp -p -R * "${ED}/usr/src/linux-${ver}/" || die cd "${WORKDIR}" || die # strip out-of-source build stuffs from modprep @@ -156,20 +163,20 @@ kernel-build_src_install() { '(' -name '.*' -a -not -name '.config' ')' \ ')' -delete || die rm modprep/source || die - cp -p -R modprep/. "${ED}/usr/src/linux-${PV}"/ || die + cp -p -R modprep/. "${ED}/usr/src/linux-${ver}"/ || die # install the kernel and files needed for module builds - insinto "/usr/src/linux-${PV}" + insinto "/usr/src/linux-${ver}" doins build/{System.map,Module.symvers} local image_path=$(kernel-install_get_image_path) - cp -p "build/${image_path}" "${ED}/usr/src/linux-${PV}/${image_path}" || die + cp -p "build/${image_path}" "${ED}/usr/src/linux-${ver}/${image_path}" || die # strip empty directories find "${D}" -type d -empty -exec rmdir {} + || die # fix source tree and build dir symlinks - dosym ../../../usr/src/linux-${PV} /lib/modules/${PV}/build - dosym ../../../usr/src/linux-${PV} /lib/modules/${PV}/source + dosym ../../../usr/src/linux-${ver} /lib/modules/${ver}/build + dosym ../../../usr/src/linux-${ver} /lib/modules/${ver}/source save_config build/.config } diff --git a/eclass/kernel-install.eclass b/eclass/kernel-install.eclass index 8065a8f5638e..ab886d28faf0 100644 --- a/eclass/kernel-install.eclass +++ b/eclass/kernel-install.eclass @@ -20,6 +20,13 @@ # 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:-0}" in @@ -311,21 +318,22 @@ kernel-install_pkg_postinst() { if [[ -z ${ROOT} ]]; then mount-boot_pkg_preinst + local ver="${PV}${KV_LOCALVERSION}" local image_path=$(kernel-install_get_image_path) if use initramfs; then # putting it alongside kernel image as 'initrd' makes # kernel-install happier kernel-install_build_initramfs \ - "${EROOT}/usr/src/linux-${PV}/${image_path%/*}/initrd" \ - "${PV}" + "${EROOT}/usr/src/linux-${ver}/${image_path%/*}/initrd" \ + "${ver}" fi - kernel-install_install_kernel "${PV}" \ - "${EROOT}/usr/src/linux-${PV}/${image_path}" \ - "${EROOT}/usr/src/linux-${PV}/System.map" + kernel-install_install_kernel "${ver}" \ + "${EROOT}/usr/src/linux-${ver}/${image_path}" \ + "${EROOT}/usr/src/linux-${ver}/System.map" fi - kernel-install_update_symlink "${EROOT}/usr/src/linux" "${PV}" + kernel-install_update_symlink "${EROOT}/usr/src/linux" "${ver}" } # @FUNCTION: kernel-install_pkg_prerm @@ -345,10 +353,11 @@ kernel-install_pkg_postrm() { debug-print-function ${FUNCNAME} "${@}" if [[ -z ${ROOT} ]] && use initramfs; then + local ver="${PV}${KV_LOCALVERSION}" local image_path=$(kernel-install_get_image_path) ebegin "Removing initramfs" - rm -f "${EROOT}/usr/src/linux-${PV}/${image_path%/*}/initrd" && - find "${EROOT}/usr/src/linux-${PV}" -depth -type d -empty -delete + rm -f "${EROOT}/usr/src/linux-${ver}/${image_path%/*}/initrd" && + find "${EROOT}/usr/src/linux-${ver}" -depth -type d -empty -delete eend ${?} fi } @@ -361,18 +370,19 @@ kernel-install_pkg_config() { mount-boot_pkg_preinst + local ver="${PV}${KV_LOCALVERSION}" local image_path=$(kernel-install_get_image_path) if use initramfs; then # putting it alongside kernel image as 'initrd' makes # kernel-install happier kernel-install_build_initramfs \ - "${EROOT}/usr/src/linux-${PV}/${image_path%/*}/initrd" \ - "${PV}" + "${EROOT}/usr/src/linux-${ver}/${image_path%/*}/initrd" \ + "${ver}" fi - kernel-install_install_kernel "${PV}" \ - "${EROOT}/usr/src/linux-${PV}/${image_path}" \ - "${EROOT}/usr/src/linux-${PV}/System.map" + kernel-install_install_kernel "${ver}" \ + "${EROOT}/usr/src/linux-${ver}/${image_path}" \ + "${EROOT}/usr/src/linux-${ver}/System.map" } _KERNEL_INSTALL_ECLASS=1 |