summaryrefslogtreecommitdiff
path: root/eclass
diff options
context:
space:
mode:
authorV3n3RiX <venerix@koprulu.sector>2024-06-30 08:00:51 +0100
committerV3n3RiX <venerix@koprulu.sector>2024-06-30 08:00:51 +0100
commitd5ee59790ee8298b8599b0aa0fa21a98b972a44d (patch)
tree2cc4393cdcfae28879cee110e5975f6e6b798f91 /eclass
parentd855918b46ba8714cf1320fe63b55fd0ed1748a6 (diff)
gentoo auto-resync : 30:06:2024 - 08:00:50
Diffstat (limited to 'eclass')
-rw-r--r--eclass/Manifest.gzbin39057 -> 39205 bytes
-rw-r--r--eclass/dist-kernel-utils.eclass39
-rw-r--r--eclass/kernel-install.eclass44
-rw-r--r--eclass/linux-mod-r1.eclass13
-rw-r--r--eclass/llvm.org.eclass6
-rw-r--r--eclass/mount-boot-utils.eclass109
-rw-r--r--eclass/mount-boot.eclass85
7 files changed, 174 insertions, 122 deletions
diff --git a/eclass/Manifest.gz b/eclass/Manifest.gz
index 35b2bd313e94..418df026cf65 100644
--- a/eclass/Manifest.gz
+++ b/eclass/Manifest.gz
Binary files differ
diff --git a/eclass/dist-kernel-utils.eclass b/eclass/dist-kernel-utils.eclass
index 13137f8c863c..4bc3fab44aae 100644
--- a/eclass/dist-kernel-utils.eclass
+++ b/eclass/dist-kernel-utils.eclass
@@ -26,7 +26,7 @@ case ${EAPI} in
*) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
esac
-inherit toolchain-funcs
+inherit mount-boot-utils toolchain-funcs
# @FUNCTION: dist-kernel_get_image_path
# @DESCRIPTION:
@@ -79,11 +79,38 @@ dist-kernel_install_kernel() {
local image=${2}
local map=${3}
- ebegin "Installing the kernel via installkernel"
- # note: .config is taken relatively to System.map;
- # initrd relatively to bzImage
- ARCH=$(tc-arch-kernel) installkernel "${version}" "${image}" "${map}"
- eend ${?} || die -n "Installing the kernel failed"
+ local success=
+ # not an actual loop but allows error handling with 'break'
+ while true; do
+ nonfatal mount-boot_check_status || break
+
+ ebegin "Installing the kernel via installkernel"
+ # note: .config is taken relatively to System.map;
+ # initrd relatively to bzImage
+ ARCH=$(tc-arch-kernel) installkernel "${version}" "${image}" "${map}" || break
+ eend ${?} || die -n "Installing the kernel failed"
+
+ success=1
+ break
+ done
+
+ if [[ ! ${success} ]]; then
+ # Fallback string, if the identifier file is not found
+ local kernel="<name of your kernel pakcage>:<kernel version>"
+ # Try to read dist-kernel identifier to more accurately instruct users
+ local k_id_file=${image%$(dist-kernel_get_image_path)}/dist-kernel
+ if [[ -f ${k_id_file} ]]; then
+ kernel=\'\=$(<${k_id_file})\'
+ fi
+
+ eerror
+ eerror "The kernel was not deployed successfully. Inspect the failure"
+ eerror "in the logs above and once you resolve the problems please"
+ eerror "run the equivalent of the following command to try again:"
+ eerror
+ eerror " emerge --config ${kernel}"
+ die "Kernel install failed, please fix the problems and run emerge --config"
+ fi
}
# @FUNCTION: dist-kernel_reinstall_initramfs
diff --git a/eclass/kernel-install.eclass b/eclass/kernel-install.eclass
index f512d815fe09..77570a905ce1 100644
--- a/eclass/kernel-install.eclass
+++ b/eclass/kernel-install.eclass
@@ -17,9 +17,7 @@
# /usr/src/linux-${PV} 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.
+# The eclass exports src_test, pkg_preinst, pkg_postinst and pkg_postrm.
# @ECLASS_VARIABLE: KERNEL_IUSE_GENERIC_UKI
# @PRE_INHERIT
@@ -50,7 +48,7 @@ case ${EAPI} in
*) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
esac
-inherit dist-kernel-utils mount-boot multiprocessing toolchain-funcs
+inherit dist-kernel-utils mount-boot-utils multiprocessing toolchain-funcs
SLOT="${PV}"
IUSE="+initramfs test"
@@ -526,6 +524,10 @@ kernel-install_test() {
kernel-install_pkg_pretend() {
debug-print-function ${FUNCNAME} "${@}"
+ # Check, but don't die because we can fix the problem and then
+ # emerge --config ... to re-run installation.
+ nonfatal mount-boot_check_status
+
if ! has_version -d sys-kernel/linux-firmware; then
ewarn "sys-kernel/linux-firmware not found installed on your system."
ewarn "This package provides various firmware files that may be needed"
@@ -665,27 +667,8 @@ kernel-install_install_all() {
fi
fi
- local success=
- # not an actual loop but allows error handling with 'break'
- while :; do
- nonfatal mount-boot_check_status || break
-
- nonfatal dist-kernel_install_kernel "${module_ver}" \
- "${kernel_dir}/${image_path}" "${kernel_dir}/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
+ dist-kernel_install_kernel "${module_ver}" "${kernel_dir}/${image_path}" \
+ "${kernel_dir}/System.map"
}
# @FUNCTION: kernel-install_pkg_postinst
@@ -718,15 +701,6 @@ kernel-install_pkg_postinst() {
fi
}
-# @FUNCTION: kernel-install_pkg_prerm
-# @DESCRIPTION:
-# Stub out mount-boot.eclass.
-kernel-install_pkg_prerm() {
- debug-print-function ${FUNCNAME} "${@}"
-
- # (no-op)
-}
-
# @FUNCTION: kernel-install_pkg_postrm
# @DESCRIPTION:
# Clean up the generated initramfs from the removed kernel directory.
@@ -774,5 +748,5 @@ kernel-install_compress_modules() {
fi
-EXPORT_FUNCTIONS src_test pkg_preinst pkg_postinst pkg_prerm pkg_postrm
+EXPORT_FUNCTIONS src_test pkg_preinst pkg_postinst pkg_postrm
EXPORT_FUNCTIONS pkg_config pkg_pretend
diff --git a/eclass/linux-mod-r1.eclass b/eclass/linux-mod-r1.eclass
index 43c5a7d7b140..9911a6ddee12 100644
--- a/eclass/linux-mod-r1.eclass
+++ b/eclass/linux-mod-r1.eclass
@@ -132,6 +132,7 @@ IDEPEND="
"
if [[ ${MODULES_INITRAMFS_IUSE} ]]; then
+ inherit mount-boot-utils
IUSE+=" ${MODULES_INITRAMFS_IUSE}"
IDEPEND+="
${MODULES_INITRAMFS_IUSE#+}? (
@@ -328,9 +329,19 @@ fi
# 3. perform various sanity checks to fail early on issues
linux-mod-r1_pkg_setup() {
debug-print-function ${FUNCNAME[0]} "${@}"
- [[ ${MERGE_TYPE} != binary ]] || return 0
_MODULES_GLOBAL[ran:pkg_setup]=1
_modules_check_function ${#} 0 0 || return 0
+
+ if [[ -z ${ROOT} && ${MODULES_INITRAMFS_IUSE} ]] &&
+ use dist-kernel && use ${MODULES_INITRAMFS_IUSE#+}
+ then
+ # Check, but don't die because we can fix the problem and then
+ # emerge --config ... to re-run installation.
+ nonfatal mount-boot_check_status
+ fi
+
+ [[ ${MERGE_TYPE} != binary ]] || return 0
+
_modules_check_migration
_modules_prepare_kernel
diff --git a/eclass/llvm.org.eclass b/eclass/llvm.org.eclass
index af5ee26b652e..79d6da0ad622 100644
--- a/eclass/llvm.org.eclass
+++ b/eclass/llvm.org.eclass
@@ -75,12 +75,6 @@ if [[ -z ${_LLVM_SOURCE_TYPE+1} ]]; then
19.0.0_pre20240623)
EGIT_COMMIT=3ae6755719c6dfc07761b4e9bdac8c86bcb41734
;;
- 19.0.0_pre20240615)
- EGIT_COMMIT=cddb9ce04e68d876de895d39d60b6af34d569012
- ;;
- 19.0.0_pre20240608)
- EGIT_COMMIT=5aabbf0602c48b67bb89fd37f95bf97c95ded488
- ;;
*)
die "Unknown snapshot: ${PV}"
;;
diff --git a/eclass/mount-boot-utils.eclass b/eclass/mount-boot-utils.eclass
new file mode 100644
index 000000000000..39f8e94b84ec
--- /dev/null
+++ b/eclass/mount-boot-utils.eclass
@@ -0,0 +1,109 @@
+# Copyright 1999-2024 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+# @ECLASS: mount-boot-utils.eclass
+# @MAINTAINER:
+# base-system@gentoo.org
+# @SUPPORTED_EAPIS: 6 7 8
+# @BLURB: functions for packages that install files into /boot or the ESP
+# @DESCRIPTION:
+# This eclass is really only useful for bootloaders and kernel installation.
+#
+# If the live system has a separate /boot partition or ESP configured, then this
+# function tries to ensure that it's mounted in rw mode, exiting with an error
+# if it can't. It does nothing if /boot and ESP isn't a separate partition.
+#
+# This eclass provides the functions used by mount-boot.eclass in an "inherit-
+# safe" way. This allows these functions to be used in other eclasses cleanly.
+
+case ${EAPI} in
+ 7|8) ;;
+ *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
+esac
+
+# @FUNCTION: mount-boot_is_disabled
+# @INTERNAL
+# @DESCRIPTION:
+# Detect whether the current environment/build settings are such that we do not
+# want to mess with any mounts.
+mount-boot_is_disabled() {
+ # Since this eclass only deals with /boot, skip things when EROOT is active.
+ if [[ -n ${EROOT} ]]; then
+ return 0
+ fi
+
+ # If we're only building a package, then there's no need to check things.
+ if [[ ${MERGE_TYPE} == buildonly ]]; then
+ return 0
+ fi
+
+ # The user wants us to leave things be.
+ if [[ -n ${DONT_MOUNT_BOOT} ]]; then
+ return 0
+ fi
+
+ # OK, we want to handle things ourselves.
+ return 1
+}
+
+# @FUNCTION: mount-boot_check_status
+# @INTERNAL
+# @DESCRIPTION:
+# Check if /boot and ESP is sane, i.e., mounted as read-write if on a separate
+# partition. Die if conditions are not fulfilled. If nonfatal is used,
+# the function will return a non-zero status instead.
+mount-boot_check_status() {
+ # Get out fast if possible.
+ mount-boot_is_disabled && return 0
+
+ local partition=
+ local part_is_not_mounted=
+ local part_is_read_only=
+ local candidates=( /boot )
+
+ # If system is booted with UEFI, check for ESP as well
+ if [[ -d /sys/firmware/efi ]]; then
+ # Use same candidates for ESP as installkernel and eclean-kernel
+ candidates+=( /efi /boot/efi /boot/EFI )
+ fi
+
+ for partition in ${candidates[@]}; do
+ # note that /dev/BOOT is in the Gentoo default /etc/fstab file
+ local fstabstate=$(awk "!/^[[:blank:]]*#|^\/dev\/BOOT/ && \$2 == \"${partition}\" \
+ { print 1; exit }" /etc/fstab || die "awk failed")
+
+ if [[ -z ${fstabstate} ]]; then
+ einfo "Assuming you do not have a separate ${partition} partition."
+ else
+ local procstate=$(awk "\$2 == \"${partition}\" { split(\$4, a, \",\"); \
+ for (i in a) if (a[i] ~ /^r[ow]\$/) { print a[i]; break }; exit }" \
+ /proc/mounts || die "awk failed")
+
+ if [[ -z ${procstate} ]]; then
+ eerror "Your ${partition} partition is not mounted"
+ eerror "Please mount it and retry."
+ die -n "${partition} not mounted"
+ part_is_not_mounted=1
+ else
+ if [[ ${procstate} == ro ]]; then
+ eerror "Your ${partition} partition, was detected as being mounted," \
+ "but is mounted read-only."
+ eerror "Please remount it as read-write and retry."
+ die -n "${partition} mounted read-only"
+ part_is_read_only=1
+ else
+ einfo "Your ${partition} partition was detected as being mounted."
+ einfo "Files will be installed there for ${PN} to function correctly."
+ fi
+ fi
+ fi
+ done
+
+ if [[ -n ${part_is_not_mounted} ]]; then
+ return 1
+ elif [[ -n ${part_is_read_only} ]]; then
+ return 2
+ else
+ return 0
+ fi
+}
diff --git a/eclass/mount-boot.eclass b/eclass/mount-boot.eclass
index 73beb9adea67..ab02b39d6141 100644
--- a/eclass/mount-boot.eclass
+++ b/eclass/mount-boot.eclass
@@ -1,90 +1,27 @@
-# Copyright 1999-2023 Gentoo Authors
+# Copyright 1999-2024 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
# @ECLASS: mount-boot.eclass
# @MAINTAINER:
# base-system@gentoo.org
# @SUPPORTED_EAPIS: 6 7 8
-# @BLURB: functions for packages that install files into /boot
+# @BLURB: eclass for packages that install files into /boot or the ESP
# @DESCRIPTION:
-# This eclass is really only useful for bootloaders.
+# This eclass is really only useful for bootloaders and kernel installation.
#
-# If the live system has a separate /boot partition configured, then this
-# function tries to ensure that it's mounted in rw mode, exiting with an
-# error if it can't. It does nothing if /boot isn't a separate partition.
+# If the live system has a separate /boot partition or ESP configured, then this
+# function tries to ensure that it's mounted in rw mode, exiting with an error
+# if it can't. It does nothing if /boot and ESP isn't a separate partition.
+#
+# This eclass exports the functions provided by mount-boot-utils.eclass to
+# the pkg_pretend and pkg_{pre,post}{inst,rm} phases.
case ${EAPI} in
- 6|7|8) ;;
+ 7|8) ;;
*) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
esac
-# @FUNCTION: mount-boot_is_disabled
-# @INTERNAL
-# @DESCRIPTION:
-# Detect whether the current environment/build settings are such that we do not
-# want to mess with any mounts.
-mount-boot_is_disabled() {
- # Since this eclass only deals with /boot, skip things when EROOT is active.
- if [[ ${EROOT:-/} != / ]] ; then
- return 0
- fi
-
- # If we're only building a package, then there's no need to check things.
- if [[ ${MERGE_TYPE} == buildonly ]] ; then
- return 0
- fi
-
- # The user wants us to leave things be.
- if [[ -n ${DONT_MOUNT_BOOT} ]] ; then
- return 0
- fi
-
- # OK, we want to handle things ourselves.
- return 1
-}
-
-# @FUNCTION: mount-boot_check_status
-# @INTERNAL
-# @DESCRIPTION:
-# Check if /boot is sane, i.e., mounted as read-write if on a separate
-# partition. Die if conditions are not fulfilled. If nonfatal is used,
-# the function will return a non-zero status instead.
-mount-boot_check_status() {
- # Get out fast if possible.
- mount-boot_is_disabled && return 0
-
- # note that /dev/BOOT is in the Gentoo default /etc/fstab file
- local fstabstate=$(awk '!/^[[:blank:]]*#|^\/dev\/BOOT/ && $2 == "/boot" \
- { print 1; exit }' /etc/fstab || die "awk failed")
-
- if [[ -z ${fstabstate} ]] ; then
- einfo "Assuming you do not have a separate /boot partition."
- return 0
- fi
-
- local procstate=$(awk '$2 == "/boot" { split($4, a, ","); \
- for (i in a) if (a[i] ~ /^r[ow]$/) { print a[i]; break }; exit }' \
- /proc/mounts || die "awk failed")
-
- if [[ -z ${procstate} ]] ; then
- eerror "Your boot partition is not mounted at /boot."
- eerror "Please mount it and retry."
- die -n "/boot not mounted"
- return 1
- fi
-
- if [[ ${procstate} == ro ]] ; then
- eerror "Your boot partition, detected as being mounted at /boot," \
- "is read-only."
- eerror "Please remount it as read-write and retry."
- die -n "/boot mounted read-only"
- return 2
- fi
-
- einfo "Your boot partition was detected as being mounted at /boot."
- einfo "Files will be installed there for ${PN} to function correctly."
- return 0
-}
+inherit mount-boot-utils
mount-boot_pkg_pretend() {
mount-boot_check_status