From 05d8d3b119ea949e871672d9448ab40ed5babf9f Mon Sep 17 00:00:00 2001 From: Terra Date: Sat, 6 Feb 2016 16:24:45 -0800 Subject: [PATCH 1/7] files/kexec.conf: copy 2.0.4 ==> 2.0.9-r3 --- sys-apps/kexec-tools/files/kexec.conf-2.0.9-r3 | 34 ++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 sys-apps/kexec-tools/files/kexec.conf-2.0.9-r3 diff --git a/sys-apps/kexec-tools/files/kexec.conf-2.0.9-r3 b/sys-apps/kexec-tools/files/kexec.conf-2.0.9-r3 new file mode 100644 index 0000000..b71ea2b --- /dev/null +++ b/sys-apps/kexec-tools/files/kexec.conf-2.0.9-r3 @@ -0,0 +1,34 @@ +# Load kexec kernel image into memory during shutdown instead of bootup +# (default: yes) +#LOAD_DURING_SHUTDOWN="yes" + +# Additional arguments passed to kexec (8) +#KEXEC_OPT_ARGS="" + +# Kernel image partition. Mounted automatically if not. +# (default: /boot) +#BOOTPART="/boot" + +# Root partition (should be autodetected) +#ROOTPART="/dev/hda3" + +# Kernel image pathname, relative from BOOTPART. +# If it's one of +# {kernel-genkernel,bzImage,vmlinuz,kernel}-, +# or bzImage, vmlinuz (without suffix), +# then it's automaticaly detected. +# Setting it to "-" will disable kexec. +#KNAME="vmlinuz-3.9.0" + +# Initrd +# Same automatic detection restriction as for KNAME apply. +# initramfs-genkernel-, +# initrd{,.img}-{,.img} +# will be detected. +#INITRD="/boot/fbsplash-emergence-1024x768" + +# Kernel parameters (should be autodetected) +#KPARAM="splash=silent,theme:emergence" + +# Do not try to mount /boot +# DONT_MOUNT_BOOT="yes" -- 2.4.10 From 891482916cac8a82643c110943141757334ae0ca Mon Sep 17 00:00:00 2001 From: Terra Date: Sat, 6 Feb 2016 16:26:06 -0800 Subject: [PATCH 2/7] files/kexec.conf-2.0.9-r3: Add new KEXEC_LOAD_FILE config option --- sys-apps/kexec-tools/files/kexec.conf-2.0.9-r3 | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sys-apps/kexec-tools/files/kexec.conf-2.0.9-r3 b/sys-apps/kexec-tools/files/kexec.conf-2.0.9-r3 index b71ea2b..78345fe 100644 --- a/sys-apps/kexec-tools/files/kexec.conf-2.0.9-r3 +++ b/sys-apps/kexec-tools/files/kexec.conf-2.0.9-r3 @@ -2,6 +2,10 @@ # (default: yes) #LOAD_DURING_SHUTDOWN="yes" +# Load kexec kernel image via kexec_load_file() instead of kexec_load() +# (default: no) +#KEXEC_LOAD_FILE="no" + # Additional arguments passed to kexec (8) #KEXEC_OPT_ARGS="" -- 2.4.10 From 371e06e9d3c0fe16074c79fe33a308d3315f79d0 Mon Sep 17 00:00:00 2001 From: Terra Date: Sat, 6 Feb 2016 16:29:02 -0800 Subject: [PATCH 3/7] files/kexec.init-2.0.9-r3: copy 2.0.4-r3 ==> 2.0.9-r3 --- sys-apps/kexec-tools/files/kexec.init-2.0.9-r3 | 165 +++++++++++++++++++++++++ 1 file changed, 165 insertions(+) create mode 100644 sys-apps/kexec-tools/files/kexec.init-2.0.9-r3 diff --git a/sys-apps/kexec-tools/files/kexec.init-2.0.9-r3 b/sys-apps/kexec-tools/files/kexec.init-2.0.9-r3 new file mode 100644 index 0000000..7aa55af --- /dev/null +++ b/sys-apps/kexec-tools/files/kexec.init-2.0.9-r3 @@ -0,0 +1,165 @@ +#!/sbin/runscript +# Copyright 1999-2015 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Id$ + +depend() { + need localmount +} + +image_path() { + local x= kver=$(uname -r) karch=$(uname -m) + BOOTPART="${BOOTPART:-/boot}" + KNAME="${KNAME:-bzImage}" + if [ -e "${KNAME}" ]; then + echo "${KNAME}" + return 0 + fi + for x in "${KNAME#${BOOTPART}}" vmlinuz \ + bzImage-${kver} vmlinuz-${kver} \ + kernel-genkernel-${karch}-${kver} \ + kernel-${kver} kernel-${karch}; do + if [ -e "${BOOTPART}/${x}" ]; then + echo "${BOOTPART}/${x}" + return 0 + fi + done + + return 1 +} + +initrd_path() { + local x= kver=$(uname -r) karch=$(uname -m) + BOOTPART="${BOOTPART:-/boot}" + INITRD="${INITRD:-initrd}" + if [ -e "${INITRD}" ]; then + echo "${INITRD}" + return 0 + fi + for x in "${INITRD#${BOOTPART}}" \ + initrd.img-${kver} initrd-${kver}.img \ + initrd-${kver} initramfs-${kver}.img \ + initramfs-genkernel-${karch}-${kver} ; do + if [ -e "${BOOTPART}/${x}" ]; then + echo "${BOOTPART}/${x}" + return 0 + fi + done + + return 1 +} + +mount_boot(){ + local ret + + [ "${DONT_MOUNT_BOOT:-no}" = "no" ] || return 1 + grep -q " ${BOOTPART:-/boot} " /proc/mounts && return 1 + + BOOTPART="${BOOTPART:-/boot}" + ebegin "Mounting ${BOOTPART}" + mount "${BOOTPART}"; ret=$? + eend ${ret} + return ${ret} +} + +load_image() { + local ret + if [ "${KNAME}" = "-" ]; then + ebegin "Disabling kexec" + kexec -u; ret=$? + eend ${ret} + return ${ret} + fi + + BOOTPART="${BOOTPART:-/boot}" + local img= initrd="$(initrd_path)" mounted=false initrdopt= + + if ! img="$(image_path)"; then + if mount_boot; then + if img="$(image_path)"; then + mounted=true + initrd="$(initrd_path)" + else + eerror "No kernel image found in ${BOOTPART}!" + umount "${BOOTPART}" + return 1 + fi + else + eerror "No kernel image found in ${BOOTPART}!" + return 1 + fi + fi + + if [ -n "${INITRD}" ] && \ + ! [ "${BOOTPART}/${INITRD#${BOOTPART}}" = "${initrd}" ]; then + eerror "Requested initrd: ${INITRD#${BOOTPART}}" + eerror "could not be found" + return 1 + fi + + [ -n "${ROOTPART}" ] || \ + ROOTPART="$(readlink -f "$(sed -n '/^\/[^ ]* \/ / s,^\([^ ]*\).*,\1,p' /proc/mounts)")" + + [ -n "${KPARAM}" ] || KEXEC_OPT_ARGS="${KEXEC_OPT_ARGS} --reuse-cmdline" + + [ -n "${initrd}" ] && [ -e "${initrd}" ] && initrdopt="--initrd=${initrd}" + + local msg= + [ -n "${initrd}" ] && \ + msg="with ${initrd}" + einfo "Using kernel image ${img} ${msg} for kexec" + + ebegin "Setting kexec with ${KEXEC_OPT_ARGS} -l ${img} root=${ROOTPART} ${KPARAM} ${initrdopt}" + kexec ${KEXEC_OPT_ARGS} -l "${img}" --append="root=${ROOTPART} ${KPARAM}" ${initrdopt} + local res=$? + + ${mounted} && umount "${BOOTPART}" + eend ${res} + return ${res} +} + +start() { + if [ "${LOAD_DURING_SHUTDOWN:-yes}" = "yes" ]; then + local ret=0 + BOOTPART="${BOOTPART:-/boot}" + if mount_boot; then + mounted=true + fi + if ! image_path > /dev/null; then + ewarn "Cannot find kernel image!" + ewarn "Please make sure a valid kernel image is present before reboot." + return 0 + fi + if [ -n "${mounted}" ]; then + ebegin "Unmounting ${BOOTPART}" + umount "${BOOTPART}"; ret=$? + eend ${ret} + fi + return ${ret} + else + ebegin "Configuring kexec" + load_image + eend $? + fi +} + +stop() { + if ! yesno $RC_REBOOT; then + einfo "Not rebooting, so disabling" + kexec -u + return 0 + fi + + if [ -f /nokexec ]; then + einfo "Not using kexec during reboot" + rm -f /nokexec + kexec -u + return 0 + fi + + [ "${LOAD_DURING_SHUTDOWN:-yes}" != "yes" ] && return 0 + + ebegin "Configuring kexec" + load_image + eend $? +} -- 2.4.10 From b117d49ec2fbe96639311fbf4d12931b3dbd4f63 Mon Sep 17 00:00:00 2001 From: Terra Date: Sat, 6 Feb 2016 16:35:23 -0800 Subject: [PATCH 4/7] files/kexec.init-2.0.4-r3: Fix comparison bug in load_image() # kexec -d start [snip] + '[' -n /boot/initramfs.cpio.gz ']' + '[' /boot//initramfs.cpio.gz = /boot/initramfs.cpio.gz ']' + eerror 'Requested initrd: /initramfs.cpio.gz' * Requested initrd: /initramfs.cpio.gz + eerror 'could not be found' * could not be found + return 1 --- sys-apps/kexec-tools/files/kexec.init-2.0.4-r3 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys-apps/kexec-tools/files/kexec.init-2.0.4-r3 b/sys-apps/kexec-tools/files/kexec.init-2.0.4-r3 index 7aa55af..fb154ca 100644 --- a/sys-apps/kexec-tools/files/kexec.init-2.0.4-r3 +++ b/sys-apps/kexec-tools/files/kexec.init-2.0.4-r3 @@ -91,7 +91,7 @@ load_image() { fi if [ -n "${INITRD}" ] && \ - ! [ "${BOOTPART}/${INITRD#${BOOTPART}}" = "${initrd}" ]; then + ! [ "${BOOTPART}/${INITRD#${BOOTPART}/}" = "${initrd}" ]; then eerror "Requested initrd: ${INITRD#${BOOTPART}}" eerror "could not be found" return 1 -- 2.4.10 From 36b6278e62b641879ef4236a65c3ac761cd2d6e8 Mon Sep 17 00:00:00 2001 From: Terra Date: Tue, 9 Feb 2016 11:56:01 -0800 Subject: [PATCH 5/7] sys-apps/kexec-tools: Bump release kexec-tools-2.0.4-r3.ebuild --- sys-apps/kexec-tools/kexec-tools-2.0.4-r3.ebuild | 73 ++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 sys-apps/kexec-tools/kexec-tools-2.0.4-r3.ebuild diff --git a/sys-apps/kexec-tools/kexec-tools-2.0.4-r3.ebuild b/sys-apps/kexec-tools/kexec-tools-2.0.4-r3.ebuild new file mode 100644 index 0000000..0ccc7b6 --- /dev/null +++ b/sys-apps/kexec-tools/kexec-tools-2.0.4-r3.ebuild @@ -0,0 +1,73 @@ +# Copyright 1999-2013 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Id$ + +EAPI=5 + +inherit autotools-utils flag-o-matic linux-info systemd + +DESCRIPTION="Load another kernel from the currently executing Linux kernel" +HOMEPAGE="https://kernel.org/pub/linux/utils/kernel/kexec/" +SRC_URI="mirror://kernel/linux/utils/kernel/kexec/${P}.tar.xz" + +LICENSE="GPL-2" +SLOT="0" +KEYWORDS="amd64 x86" +IUSE="booke lzma xen zlib" + +REQUIRED_USE="lzma? ( zlib )" + +DEPEND=" + lzma? ( app-arch/xz-utils ) + zlib? ( sys-libs/zlib )" +RDEPEND="${DEPEND}" + +CONFIG_CHECK="~KEXEC" + +PATCHES=( + "${FILESDIR}"/${PN}-2.0.0-respect-LDFLAGS.patch + "${FILESDIR}"/${P}-disable-kexec-test.patch + "${FILESDIR}"/${P}-out-of-source.patch + ) + +pkg_setup() { + # GNU Make's $(COMPILE.S) passes ASFLAGS to $(CCAS), CCAS=$(CC) + export ASFLAGS="${CCASFLAGS}" + # to disable the -fPIE -pie in the hardened compiler + if gcc-specs-pie ; then + filter-flags -fPIE + append-ldflags -nopie + fi +} + +src_configure() { + local myeconfargs=( + $(use_with booke) + $(use_with lzma) + $(use_with xen) + $(use_with zlib) + ) + autotools-utils_src_configure +} + +src_install() { + autotools-utils_src_install + + dodoc "${FILESDIR}"/README.Gentoo + + newinitd "${FILESDIR}"/kexec.init-${PVR} kexec + newconfd "${FILESDIR}"/kexec.conf-${PV} kexec + + insinto /etc + doins "${FILESDIR}"/kexec.conf + + 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 +} -- 2.4.10 From a74b2eafbfc0402de338990e708a0da0e2dd09c5 Mon Sep 17 00:00:00 2001 From: Terra Date: Tue, 9 Feb 2016 11:57:39 -0800 Subject: [PATCH 6/7] sys-apps/kexec-tools: Bump release kexec-tools-2.0.9-r3.ebuild --- sys-apps/kexec-tools/kexec-tools-2.0.9-r3.ebuild | 71 ++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 sys-apps/kexec-tools/kexec-tools-2.0.9-r3.ebuild diff --git a/sys-apps/kexec-tools/kexec-tools-2.0.9-r3.ebuild b/sys-apps/kexec-tools/kexec-tools-2.0.9-r3.ebuild new file mode 100644 index 0000000..40945a4 --- /dev/null +++ b/sys-apps/kexec-tools/kexec-tools-2.0.9-r3.ebuild @@ -0,0 +1,71 @@ +# Copyright 1999-2015 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Id$ + +EAPI=5 + +inherit autotools-utils linux-info systemd + +DESCRIPTION="Load another kernel from the currently executing Linux kernel" +HOMEPAGE="https://kernel.org/pub/linux/utils/kernel/kexec/" +SRC_URI="mirror://kernel/linux/utils/kernel/kexec/${P}.tar.xz" + +LICENSE="GPL-2" +SLOT="0" +KEYWORDS="~amd64 ~x86" +IUSE="booke lzma xen zlib" + +REQUIRED_USE="lzma? ( zlib )" + +DEPEND=" + lzma? ( app-arch/xz-utils ) + zlib? ( sys-libs/zlib )" +RDEPEND="${DEPEND}" + +CONFIG_CHECK="~KEXEC" + +PATCHES=( + "${FILESDIR}"/${PN}-2.0.4-disable-kexec-test.patch + "${FILESDIR}"/${PN}-2.0.4-out-of-source.patch + "${FILESDIR}"/${PN}-2.0.9-hardened.patch +) + +pkg_setup() { + # GNU Make's $(COMPILE.S) passes ASFLAGS to $(CCAS), CCAS=$(CC) + export ASFLAGS="${CCASFLAGS}" +} + +src_configure() { + local myeconfargs=( + $(use_with booke) + $(use_with lzma) + $(use_with xen) + $(use_with zlib) + ) + autotools-utils_src_configure +} + +src_install() { + autotools-utils_src_install + + dodoc "${FILESDIR}"/README.Gentoo + + newinitd "${FILESDIR}"/kexec.init-2.0.4-r3 kexec + newconfd "${FILESDIR}"/kexec.conf-2.0.4 kexec + + insinto /etc + doins "${FILESDIR}"/kexec.conf + + insinto /etc/kernel/postinst.d + doins "${FILESDIR}"/90_kexec + + 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 +} -- 2.4.10 From 3aac8cd4a6fa7fa6425258b3526e002396ea6528 Mon Sep 17 00:00:00 2001 From: Terra Date: Tue, 9 Feb 2016 11:58:18 -0800 Subject: [PATCH 7/7] sys-apps/kexec-tools: Use new initd and confd files that support KEXEC_FILE_LOAD --- sys-apps/kexec-tools/kexec-tools-2.0.9-r3.ebuild | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sys-apps/kexec-tools/kexec-tools-2.0.9-r3.ebuild b/sys-apps/kexec-tools/kexec-tools-2.0.9-r3.ebuild index 40945a4..2df1bc2 100644 --- a/sys-apps/kexec-tools/kexec-tools-2.0.9-r3.ebuild +++ b/sys-apps/kexec-tools/kexec-tools-2.0.9-r3.ebuild @@ -1,4 +1,4 @@ -# Copyright 1999-2015 Gentoo Foundation +# Copyright 1999-2016 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Id$ @@ -50,8 +50,8 @@ src_install() { dodoc "${FILESDIR}"/README.Gentoo - newinitd "${FILESDIR}"/kexec.init-2.0.4-r3 kexec - newconfd "${FILESDIR}"/kexec.conf-2.0.4 kexec + newinitd "${FILESDIR}"/kexec.init-2.0.9-r3 kexec + newconfd "${FILESDIR}"/kexec.conf-2.0.9-r3 kexec insinto /etc doins "${FILESDIR}"/kexec.conf -- 2.4.10