diff options
author | Justin Lecher <jlec@gentoo.org> | 2012-03-18 07:46:02 +0000 |
---|---|---|
committer | Justin Lecher <jlec@gentoo.org> | 2012-03-18 07:46:02 +0000 |
commit | a27c16410984458fc66a2a1a7cfcc56cef83b82b (patch) | |
tree | 61e9b1134d67f5e8d824a779757bfb31a3a507b2 /sys-apps | |
parent | Pass -Os in TARGET_CFLAGS for efi-64 on x86. Don't clobber TARGET variables i... (diff) | |
download | gentoo-2-a27c16410984458fc66a2a1a7cfcc56cef83b82b.tar.gz gentoo-2-a27c16410984458fc66a2a1a7cfcc56cef83b82b.tar.bz2 gentoo-2-a27c16410984458fc66a2a1a7cfcc56cef83b82b.zip |
Use $RC_REBOOT instead of /sbin/runlevel, #401231 thanks William Hubbs for the patch; usability enhancements including better detection of the kernel image, additional option parsing, better descriptions in the config file, #392229, thanks teika for those things; better detection of genkernel, #370207, thanks Łukasz Stelmach & Dennis Schridde for their contributions
(Portage version: 2.2.0_alpha90/cvs/Linux x86_64)
Diffstat (limited to 'sys-apps')
-rw-r--r-- | sys-apps/kexec-tools/ChangeLog | 12 | ||||
-rw-r--r-- | sys-apps/kexec-tools/files/README.Gentoo | 33 | ||||
-rw-r--r-- | sys-apps/kexec-tools/files/kexec.conf-2.0.3 | 31 | ||||
-rw-r--r-- | sys-apps/kexec-tools/files/kexec.init-2.0.3 | 119 | ||||
-rw-r--r-- | sys-apps/kexec-tools/kexec-tools-2.0.3-r1.ebuild | 48 |
5 files changed, 242 insertions, 1 deletions
diff --git a/sys-apps/kexec-tools/ChangeLog b/sys-apps/kexec-tools/ChangeLog index 0f670e2ba6e0..e2fdfc7144de 100644 --- a/sys-apps/kexec-tools/ChangeLog +++ b/sys-apps/kexec-tools/ChangeLog @@ -1,6 +1,16 @@ # ChangeLog for sys-apps/kexec-tools # Copyright 1999-2012 Gentoo Foundation; Distributed under the GPL v2 -# $Header: /var/cvsroot/gentoo-x86/sys-apps/kexec-tools/ChangeLog,v 1.45 2012/02/16 22:13:00 jlec Exp $ +# $Header: /var/cvsroot/gentoo-x86/sys-apps/kexec-tools/ChangeLog,v 1.46 2012/03/18 07:46:02 jlec Exp $ + +*kexec-tools-2.0.3-r1 (18 Mar 2012) + + 18 Mar 2012; Justin Lecher <jlec@gentoo.org> +files/kexec.conf-2.0.3, + +files/kexec.init-2.0.3, +kexec-tools-2.0.3-r1.ebuild, +files/README.Gentoo: + Use $RC_REBOOT instead of /sbin/runlevel, #401231 thanks William Hubbs for + the patch; usability enhancements including better detection of the kernel + image, additional option parsing, better descriptions in the config file, + #392229, thanks teika for those things; better detection of genkernel, + #370207, thanks Łukasz Stelmach & Dennis Schridde for their contributions *kexec-tools-2.0.3 (16 Feb 2012) diff --git a/sys-apps/kexec-tools/files/README.Gentoo b/sys-apps/kexec-tools/files/README.Gentoo new file mode 100644 index 000000000000..ad88924cbb23 --- /dev/null +++ b/sys-apps/kexec-tools/files/README.Gentoo @@ -0,0 +1,33 @@ +Usage +===== + +Do + $ man 8 kexec +for full understanding of the underlying kexec command. +Gentoo offers a wrapper to the bare kexec command through +/etc/init.d/kexec. + +Configuration +------------- + +Configuration is done in /etc/conf.d/kexec, which is self-documented. + +Usage +----- + +In Gentoo, kexec is invoked, i.e., the new kernel will be booted when +rebooting, by reboot (8) command or by pressing Ctrl+Alt+Del. + +If you want to use kexec once, just run + $ /etc/init.d/kexec start + +It'll reserve kexec call at reboot. Later on, you can reboot anytime, +letting kexec starts another (or the same) kernel. When all is done in +the runlevel 6 - killing processes, unmounting volumes, etc - kexec +starts the new kernel instead of doing the normal hardware reboot. + +If you want kexec to be run every time you reboot, add it to a runlevel: + $ rc-update add kexec <runlevel> + +If you want to reboot in the normal way this time, do: + $ touch /nokexec diff --git a/sys-apps/kexec-tools/files/kexec.conf-2.0.3 b/sys-apps/kexec-tools/files/kexec.conf-2.0.3 new file mode 100644 index 000000000000..a1d409edabc6 --- /dev/null +++ b/sys-apps/kexec-tools/files/kexec.conf-2.0.3 @@ -0,0 +1,31 @@ +# 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}-<currently running kernel version>, +# or bzImage, vmlinuz (without suffix), +# then it's automaticaly detected. +# Setting it to "-" will disable kexec. +#KNAME="vmlinuz-2.6.10" + +# Initrd +# Same automatic detection restriction as for KNAME apply. +# initramfs-genkernel-<currently running kernel version>, +# initrd{,.img}-<currently running kernel version>{,.img} +# will be detected. +#INITRD="/boot/fbsplash-emergence-1024x768" + +# Kernel parameters (should be autodetected) +#KPARAM="splash=silent,theme:emergence" diff --git a/sys-apps/kexec-tools/files/kexec.init-2.0.3 b/sys-apps/kexec-tools/files/kexec.init-2.0.3 new file mode 100644 index 000000000000..6ae811291133 --- /dev/null +++ b/sys-apps/kexec-tools/files/kexec.init-2.0.3 @@ -0,0 +1,119 @@ +#!/sbin/runscript +# Copyright 1999-2012 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: /var/cvsroot/gentoo-x86/sys-apps/kexec-tools/files/kexec.init-2.0.3,v 1.1 2012/03/18 07:46:02 jlec Exp $ + +depend() { + need localmount +} + +image_path() { + local x= kver=$(uname -r) karch=$(uname -m) + BOOTPART="${BOOTPART:-/boot}" + for x in "${KNAME:-bzImage}" 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}" + for x in "${INITRD:-initrd}" \ + 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 +} + +load_image() { + if [[ "${KNAME}" = "-" ]]; then + ebegin "Disabling kexec" + kexec -u + eend $? + return $? + fi + + BOOTPART="${BOOTPART:-/boot}" + local img="$(image_path)" initrd="$(initrd_path)" mounted=false initrdopt= + + if [[ -z "${img}" ]] || [[ -z "${initrd}" ]]; then + # If we cannot find our image, try mounting ${BOOTPART} + if ! grep -q " ${BOOTPART} " /proc/mounts; then + ebegin "Mounting ${BOOTPART}" + mount "${BOOTPART}" && mounted=true + eend $? || return $? + img="$(image_path)" + initrd="$(initrd_path)" + fi + fi + + if [[ -z "${img}" ]]; then + eerror "No kernel image found in ${BOOTPART}!" + ${mounted} && umount "${BOOTPART}" + return 1 + else + ebegin "Loading kernel image ${img} for kexec" + fi + + [[ -n "${ROOTPART}" ]] || \ + ROOTPART="$(readlink -f "$(sed -n '/^\/[^ ]* \/ / s,^\([^ ]*\).*,\1,p' /proc/mounts)")" + + [[ -n "${KPARAM}" ]] || KEXEC_OPT_ARGS+=" --reuse-cmdline" + + [[ -n "${initrd}" ]] && [[ -e "${initrd}" ]] && initrdopt="--initrd=${initrd}" + + einfo " 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 + image_path > /dev/null || \ + ewarn "Cannot find kernel image. Please make sure a valid kernel image is present before reboot." + return 0 + else + ebegin "Configuring kexec" + load_image + eend $? + fi +} + +stop() { + [[ "${LOAD_DURING_SHUTDOWN:-yes}" != "yes" ]] && return 0 + + 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 + + ebegin "Configuring kexec" + load_image + eend $? +} diff --git a/sys-apps/kexec-tools/kexec-tools-2.0.3-r1.ebuild b/sys-apps/kexec-tools/kexec-tools-2.0.3-r1.ebuild new file mode 100644 index 000000000000..5197273fa2b6 --- /dev/null +++ b/sys-apps/kexec-tools/kexec-tools-2.0.3-r1.ebuild @@ -0,0 +1,48 @@ +# Copyright 1999-2012 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: /var/cvsroot/gentoo-x86/sys-apps/kexec-tools/kexec-tools-2.0.3-r1.ebuild,v 1.1 2012/03/18 07:46:02 jlec Exp $ + +EAPI=4 + +inherit eutils flag-o-matic linux-info + +DESCRIPTION="Load another kernel from the currently executing Linux kernel" +HOMEPAGE="http://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" + +DEPEND=" + lzma? ( app-arch/xz-utils ) + zlib? ( sys-libs/zlib )" +RDEPEND="${DEPEND}" + +CONFIG_CHECK="~KEXEC" + +src_prepare() { + epatch "${FILESDIR}/${PN}-2.0.0-respect-LDFLAGS.patch" + + # to disable the -fPIE -pie in the hardened compiler + if gcc-specs-pie ; then + filter-flags -fPIE + append-ldflags -nopie + fi +} + +src_configure() { + # GNU Make's $(COMPILE.S) passes ASFLAGS to $(CCAS), CCAS=$(CC) + export ASFLAGS="${CCASFLAGS}" + econf $(use_with lzma) $(use_with xen) $(use_with zlib) $(use_with booke) +} + +src_install() { + default + + dodoc "${FILESDIR}"/README.Gentoo + + newinitd "${FILESDIR}"/kexec.init-${PV} kexec + newconfd "${FILESDIR}"/kexec.conf-${PV} kexec +} |