diff options
| author | Liguros - Gitlab CI/CD [master] <gitlab@liguros.net> | 2021-01-17 23:35:33 +0000 |
|---|---|---|
| committer | Liguros - Gitlab CI/CD [master] <gitlab@liguros.net> | 2021-01-17 23:35:33 +0000 |
| commit | 8e8120eabdd28020aa69c7a60505cce2edd20adc (patch) | |
| tree | 061bf0acdc672720e0bc3a2d575f67d25aedb2d8 /eclass/kernel-install.eclass | |
| parent | c16790af2c9b4cbc38e565d4311252193ff85484 (diff) | |
| download | baldeagleos-repo-21.1.2.tar.gz baldeagleos-repo-21.1.2.tar.xz baldeagleos-repo-21.1.2.zip | |
Updating liguros repo21.1.2
Diffstat (limited to 'eclass/kernel-install.eclass')
| -rw-r--r-- | eclass/kernel-install.eclass | 144 |
1 files changed, 49 insertions, 95 deletions
diff --git a/eclass/kernel-install.eclass b/eclass/kernel-install.eclass index e826626e13f2..b8109f47d0bf 100644 --- a/eclass/kernel-install.eclass +++ b/eclass/kernel-install.eclass @@ -1,4 +1,4 @@ -# Copyright 2020 Gentoo Authors +# Copyright 2020-2021 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 # @ECLASS: kernel-install.eclass @@ -40,7 +40,7 @@ case "${EAPI:-0}" in ;; esac -inherit mount-boot toolchain-funcs +inherit dist-kernel-utils mount-boot toolchain-funcs SLOT="${PV}" IUSE="+initramfs test" @@ -70,70 +70,6 @@ BDEPEND=" x86? ( app-emulation/qemu[qemu_softmmu_targets_i386] ) )" -# @FUNCTION: kernel-install_build_initramfs -# @USAGE: <output> <version> -# @DESCRIPTION: -# Build an initramfs for the kernel. <output> specifies the absolute -# path where initramfs will be created, while <version> specifies -# the kernel version, used to find modules. -kernel-install_build_initramfs() { - debug-print-function ${FUNCNAME} "${@}" - - [[ ${#} -eq 2 ]] || die "${FUNCNAME}: invalid arguments" - local output=${1} - local version=${2} - - ebegin "Building initramfs via dracut" - dracut --force "${output}" "${version}" - eend ${?} || die "Building initramfs failed" -} - -# @FUNCTION: kernel-install_get_image_path -# @DESCRIPTION: -# Get relative kernel image path specific to the current ${ARCH}. -kernel-install_get_image_path() { - case ${ARCH} in - amd64|x86) - echo arch/x86/boot/bzImage - ;; - arm64) - echo arch/arm64/boot/Image.gz - ;; - arm) - echo arch/arm/boot/zImage - ;; - ppc64) - # ./ is required because of ${image_path%/*} - # substitutions in the code - echo ./vmlinux - ;; - *) - die "${FUNCNAME}: unsupported ARCH=${ARCH}" - ;; - esac -} - -# @FUNCTION: kernel-install_install_kernel -# @USAGE: <version> <image> <system.map> -# @DESCRIPTION: -# Install kernel using installkernel tool. <version> specifies -# the kernel version, <image> full path to the image, <system.map> -# full path to System.map. -kernel-install_install_kernel() { - debug-print-function ${FUNCNAME} "${@}" - - [[ ${#} -eq 3 ]] || die "${FUNCNAME}: invalid arguments" - local version=${1} - local image=${2} - local map=${3} - - ebegin "Installing the kernel via installkernel" - # note: .config is taken relatively to System.map; - # initrd relatively to bzImage - installkernel "${version}" "${image}" "${map}" - eend ${?} || die "Installing the kernel failed" -} - # @FUNCTION: kernel-install_update_symlink # @USAGE: <target> <version> # @DESCRIPTION: @@ -372,7 +308,7 @@ kernel-install_pkg_pretend() { elog "If you decide to install linux-firmware later, you can rebuild" elog "the initramfs via issuing a command equivalent to:" elog - elog " emerge --config ${CATEGORY}/${PN}" + elog " emerge --config ${CATEGORY}/${PN}:${SLOT}" fi fi } @@ -395,32 +331,64 @@ kernel-install_pkg_preinst() { # (no-op) } -# @FUNCTION: kernel-install_pkg_postinst +# @FUNCTION: kernel-install_install_all +# @USAGE: <ver> # @DESCRIPTION: -# Build an initramfs for the kernel, install it and update -# the /usr/src/linux symlink. -kernel-install_pkg_postinst() { +# Build an initramfs for the kernel and install the kernel. This is +# called from pkg_postinst() and pkg_config(). <ver> is the full +# kernel version. +kernel-install_install_all() { debug-print-function ${FUNCNAME} "${@}" - if [[ -z ${ROOT} ]]; then - mount-boot_pkg_preinst + [[ ${#} -eq 1 ]] || die "${FUNCNAME}: invalid arguments" + local ver=${1} - local ver="${PV}${KV_LOCALVERSION}" - local image_path=$(kernel-install_get_image_path) + local success= + # not an actual loop but allows error handling with 'break' + while :; do + nonfatal mount-boot_check_status || break + + local image_path=$(dist-kernel_get_image_path) if use initramfs; then # putting it alongside kernel image as 'initrd' makes # kernel-install happier - kernel-install_build_initramfs \ + nonfatal dist-kernel_build_initramfs \ "${EROOT}/usr/src/linux-${ver}/${image_path%/*}/initrd" \ - "${ver}" + "${ver}" || break fi - kernel-install_install_kernel "${ver}" \ + nonfatal dist-kernel_install_kernel "${ver}" \ "${EROOT}/usr/src/linux-${ver}/${image_path}" \ - "${EROOT}/usr/src/linux-${ver}/System.map" + "${EROOT}/usr/src/linux-${ver}/System.map" || break + + success=1 + break + done + + if [[ ! ${success} ]]; then + eerror + eerror "The kernel files were copied to disk successfully but the kernel" + eerror "was not deployed successfully. Once you resolve the problems," + eerror "please run the equivalent of the following command to try again:" + eerror + eerror " emerge --config ${CATEGORY}/${PN}:${SLOT}" + die "Kernel install failed, please fix the problems and run emerge --config ${CATEGORY}/${PN}:${SLOT}" fi +} +# @FUNCTION: kernel-install_pkg_postinst +# @DESCRIPTION: +# Build an initramfs for the kernel, install it and update +# the /usr/src/linux symlink. +kernel-install_pkg_postinst() { + debug-print-function ${FUNCNAME} "${@}" + + local ver="${PV}${KV_LOCALVERSION}" kernel-install_update_symlink "${EROOT}/usr/src/linux" "${ver}" + + if [[ -z ${ROOT} ]]; then + kernel-install_install_all "${ver}" + fi } # @FUNCTION: kernel-install_pkg_prerm @@ -441,7 +409,7 @@ kernel-install_pkg_postrm() { if [[ -z ${ROOT} ]] && use initramfs; then local ver="${PV}${KV_LOCALVERSION}" - local image_path=$(kernel-install_get_image_path) + local image_path=$(dist-kernel_get_image_path) ebegin "Removing initramfs" rm -f "${EROOT}/usr/src/linux-${ver}/${image_path%/*}/initrd" && find "${EROOT}/usr/src/linux-${ver}" -depth -type d -empty -delete @@ -455,21 +423,7 @@ kernel-install_pkg_postrm() { kernel-install_pkg_config() { [[ -z ${ROOT} ]] || die "ROOT!=/ not supported currently" - 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-${ver}/${image_path%/*}/initrd" \ - "${ver}" - fi - - kernel-install_install_kernel "${ver}" \ - "${EROOT}/usr/src/linux-${ver}/${image_path}" \ - "${EROOT}/usr/src/linux-${ver}/System.map" + kernel-install_install_all "${PV}${KV_LOCALVERSION}" } _KERNEL_INSTALL_ECLASS=1 |
