mirror of
https://github.com/flatcar/scripts.git
synced 2025-08-10 14:36:58 +02:00
sys-apps/kexec-tools: Sync with Gentoo
It's from Gentoo commit 4c27efd95d9164b3e6ff433c06cd767885d27b13.
This commit is contained in:
parent
23fe0fe6e2
commit
6eb3f8728b
95
sdk_container/src/third_party/portage-stable/sys-apps/kexec-tools/files/kexec-auto-load
vendored
Normal file
95
sdk_container/src/third_party/portage-stable/sys-apps/kexec-tools/files/kexec-auto-load
vendored
Normal file
@ -0,0 +1,95 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Defaults
|
||||
LAYOUT=compat
|
||||
BOOTPART=/boot
|
||||
KNAME=kernel
|
||||
INITRD=initramfs.img
|
||||
|
||||
instkern_state=/var/lib/misc/installkernel
|
||||
if [[ -s ${instkern_state} ]]; then
|
||||
# If we have a log file, set defaults from there.
|
||||
IFS=$'\t' read -r -a LastKernArray <<< "$(tail -n1 ${instkern_state})"
|
||||
LAYOUT="${LastKernArray[4]}"
|
||||
BOOTPART="${LastKernArray[7]}"
|
||||
KNAME="${LastKernArray[8]}"
|
||||
if [[ "${LastKernArray[9]}" != unknown && ${LAYOUT} != uki ]]; then
|
||||
INITRD="${LastKernArray[9]}"
|
||||
else
|
||||
INITRD=
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ ${LAYOUT} == uki ]]; then
|
||||
echo "WARNING: kexec currently does not support UKIs"
|
||||
KPARAM=
|
||||
else
|
||||
if [[ -f /etc/kernel/cmdline ]]; then
|
||||
KPARAM="$(tr -s "${IFS}" ' ' </etc/kernel/cmdline)"
|
||||
elif [[ -f /usr/lib/kernel/cmdline ]]; then
|
||||
KPARAM="$(tr -s "${IFS}" ' ' </usr/lib/kernel/cmdline)"
|
||||
else
|
||||
KPARAM=
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
# /etc/kexec.conf overrides installkernel.log
|
||||
kexec_conf=/etc/kexec.conf
|
||||
if [[ -f ${kexec_conf} ]]; then
|
||||
source ${kexec_conf}
|
||||
fi
|
||||
|
||||
if [[ -z ${DONT_MOUNT_BOOT} ]]; then
|
||||
# Borrowed from mount-boot-utils.eclass
|
||||
# note that /dev/BOOT is in the Gentoo default /etc/fstab file
|
||||
fstabstate=$(awk "!/^[[:blank:]]*#|^\/dev\/BOOT/ && \$2 == \"${BOOTPART}\" \
|
||||
{ print 1; exit }" /etc/fstab || die "awk failed")
|
||||
|
||||
if [[ -z ${fstabstate} ]]; then
|
||||
echo "Assuming you do not have a separate ${BOOTPART} partition."
|
||||
else
|
||||
procstate=$(awk "\$2 == \"${BOOTPART}\" { 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
|
||||
echo "ERROR: Your ${BOOTPART} partition is not mounted"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ ! -d ${BOOTPART} ]]; then
|
||||
echo "ERROR: BOOTPART=${BOOTPART} not found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
KEXEC_ARGS=()
|
||||
|
||||
if [[ -f ${BOOTPART}/${KNAME} ]]; then
|
||||
KEXEC_ARGS+=( --load "${BOOTPART}/${KNAME}" )
|
||||
else
|
||||
echo "ERROR: KNAME=${KNAME} not found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ -n ${INITRD} ]]; then
|
||||
if [[ -f ${BOOTPART}/${INITRD} ]]; then
|
||||
KEXEC_ARGS+=( --initrd "${BOOTPART}/${INITRD}" )
|
||||
else
|
||||
echo "WARNING: INITRD=${INITRD} not found"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ -n ${KPARAM} ]]; then
|
||||
KEXEC_ARGS+=( --command-line "${KPARAM}" )
|
||||
elif [[ ! -f /etc/kernel/cmdline && ! -f /usr/lib/kernel/cmdline ]]; then
|
||||
# If it is still empty and we did not intentionally set it empty then reuse.
|
||||
KEXEC_OPT_ARGS+=" --reuse-cmdline "
|
||||
fi
|
||||
|
||||
KEXEC_ARGS+=( ${KEXEC_OPT_ARGS} )
|
||||
|
||||
echo "Calling kexec with arguments: ${KEXEC_ARGS[@]}"
|
||||
exec kexec "${KEXEC_ARGS[@]}"
|
@ -1,16 +1,32 @@
|
||||
# Kernel image pathname, relative from /boot.
|
||||
KNAME="bzimage"
|
||||
# Kernel image partition.
|
||||
# Default: partition that last kernel image was installed on
|
||||
#BOOTPART="/boot"
|
||||
|
||||
# Path to (unified) kernel image, relative to BOOTPART.
|
||||
# Default: last installed kernel image
|
||||
#KNAME="kernel"
|
||||
|
||||
# Path to the initramfs image, relative to BOOTPART
|
||||
# Default: initramfs belonging to last kernel image, if any
|
||||
#INITRD="initramfs.img"
|
||||
|
||||
# Kernel cmdline to use,
|
||||
# Default: contents of {/etc,/usr/lib}/kernel/cmdline if exists, otherwise --reuse-cmdline is used
|
||||
#KPARAM="quiet"
|
||||
|
||||
# Additional arguments passed to kexec
|
||||
#KEXEC_OPT_ARGS=""
|
||||
|
||||
# Do not try to mount /boot
|
||||
#DONT_MOUNT_BOOT="yes"
|
||||
|
||||
# Additional arguments passed to kexec (8)
|
||||
# Following arguments are support:
|
||||
#
|
||||
# --reuse-cmdline
|
||||
# Use the current boot command line
|
||||
# The below is currently used by the OpenRC script only
|
||||
#
|
||||
# --command-line=string
|
||||
# Use a different command line
|
||||
#
|
||||
# --initrd=file
|
||||
# Specify an initrd to use
|
||||
#
|
||||
KEXEC_OPT_ARGS="--reuse-cmdline"
|
||||
|
||||
# Load kexec kernel image into memory during shutdown instead of bootup
|
||||
# (default: yes)
|
||||
#LOAD_DURING_SHUTDOWN="yes"
|
||||
|
||||
# Root partition (should be autodetected)
|
||||
#ROOTPART="/dev/hda3"
|
||||
|
@ -13,12 +13,12 @@
|
||||
#ROOTPART="/dev/hda3"
|
||||
|
||||
# Kernel image pathname, relative from BOOTPART.
|
||||
# If it's one of
|
||||
# If it's one of
|
||||
# {kernel-genkernel,bzImage,vmlinuz,kernel}-<currently running kernel version>,
|
||||
# or bzImage, vmlinuz (without suffix),
|
||||
# then it's automaticaly detected.
|
||||
# Setting it to "-" will disable kexec.
|
||||
#KNAME="vmlinuz-3.9.0"
|
||||
#KNAME="kernel"
|
||||
|
||||
# Initrd
|
||||
# Same automatic detection restriction as for KNAME apply.
|
||||
@ -31,4 +31,4 @@
|
||||
#KPARAM="splash=silent,theme:emergence"
|
||||
|
||||
# Do not try to mount /boot
|
||||
# DONT_MOUNT_BOOT="yes"
|
||||
#DONT_MOUNT_BOOT="yes"
|
||||
|
@ -9,8 +9,8 @@ ConditionPathExists=!/nokexec
|
||||
Type=oneshot
|
||||
RemainAfterExit=yes
|
||||
EnvironmentFile=/etc/kexec.conf
|
||||
ExecStart=/usr/sbin/kexec -l /boot/${KNAME} ${KEXEC_OPT_ARGS}
|
||||
ExecStop=/usr/sbin/kexec -l /boot/${KNAME} ${KEXEC_OPT_ARGS}
|
||||
ExecStart=/usr/sbin/kexec-auto-load
|
||||
ExecStop=/usr/sbin/kexec-auto-load
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
EAPI=8
|
||||
|
||||
inherit libtool linux-info optfeature systemd
|
||||
inherit libtool linux-info systemd
|
||||
|
||||
if [[ ${PV} == "9999" ]] ; then
|
||||
inherit git-r3 autotools
|
||||
@ -92,24 +92,16 @@ src_install() {
|
||||
dodoc "${FILESDIR}"/README.Gentoo
|
||||
|
||||
newinitd "${FILESDIR}"/kexec-r2.init kexec
|
||||
newconfd "${FILESDIR}"/kexec.conf-2.0.4 kexec
|
||||
|
||||
insinto /etc
|
||||
doins "${FILESDIR}"/kexec.conf
|
||||
dosym ../kexec.conf /etc/conf.d/kexec
|
||||
|
||||
insinto /etc/kernel/postinst.d
|
||||
doins "${FILESDIR}"/90_kexec
|
||||
|
||||
dosbin "${FILESDIR}"/kexec-auto-load
|
||||
systemd_dounit "${FILESDIR}"/kexec.service
|
||||
}
|
||||
|
||||
pkg_postinst() {
|
||||
if systemd_is_booted || has_version sys-apps/systemd; then
|
||||
elog "For systemd support the new config file is"
|
||||
elog " /etc/kexec.conf"
|
||||
elog "Please adopt it to your needs as there is no autoconfig anymore"
|
||||
fi
|
||||
|
||||
local n_root_args=$(grep -o -- '\<root=' /proc/cmdline 2>/dev/null | wc -l)
|
||||
local has_rootpart_set=no
|
||||
if [[ -f "${EROOT}/etc/conf.d/kexec" ]]; then
|
||||
@ -125,7 +117,4 @@ pkg_postinst() {
|
||||
ewarn "in case running system and initramfs do not agree on detected"
|
||||
ewarn "root device name!"
|
||||
fi
|
||||
|
||||
optfeature "automatically updating /etc/kexec.conf on each kernel installation" \
|
||||
"sys-kernel/installkernel[-systemd]"
|
||||
}
|
@ -3,7 +3,7 @@
|
||||
|
||||
EAPI=8
|
||||
|
||||
inherit libtool linux-info optfeature systemd
|
||||
inherit libtool linux-info systemd
|
||||
|
||||
if [[ ${PV} == "9999" ]] ; then
|
||||
inherit git-r3 autotools
|
||||
@ -92,24 +92,16 @@ src_install() {
|
||||
dodoc "${FILESDIR}"/README.Gentoo
|
||||
|
||||
newinitd "${FILESDIR}"/kexec-r2.init kexec
|
||||
newconfd "${FILESDIR}"/kexec.conf-2.0.4 kexec
|
||||
|
||||
insinto /etc
|
||||
doins "${FILESDIR}"/kexec.conf
|
||||
dosym ../kexec.conf /etc/conf.d/kexec
|
||||
|
||||
insinto /etc/kernel/postinst.d
|
||||
doins "${FILESDIR}"/90_kexec
|
||||
|
||||
dosbin "${FILESDIR}"/kexec-auto-load
|
||||
systemd_dounit "${FILESDIR}"/kexec.service
|
||||
}
|
||||
|
||||
pkg_postinst() {
|
||||
if systemd_is_booted || has_version sys-apps/systemd; then
|
||||
elog "For systemd support the new config file is"
|
||||
elog " /etc/kexec.conf"
|
||||
elog "Please adopt it to your needs as there is no autoconfig anymore"
|
||||
fi
|
||||
|
||||
local n_root_args=$(grep -o -- '\<root=' /proc/cmdline 2>/dev/null | wc -l)
|
||||
local has_rootpart_set=no
|
||||
if [[ -f "${EROOT}/etc/conf.d/kexec" ]]; then
|
||||
@ -125,7 +117,4 @@ pkg_postinst() {
|
||||
ewarn "in case running system and initramfs do not agree on detected"
|
||||
ewarn "root device name!"
|
||||
fi
|
||||
|
||||
optfeature "automatically updating /etc/kexec.conf on each kernel installation" \
|
||||
"sys-kernel/installkernel[-systemd]"
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user