summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Lecher <jlec@gentoo.org>2011-03-27 08:31:50 +0000
committerJustin Lecher <jlec@gentoo.org>2011-03-27 08:31:50 +0000
commit52f13ff92a007f0c4790d508eebd306798eb4bf6 (patch)
tree2a67f9b37b0a4e54912a55c3722268983a4e6caf /sys-apps
parentMention removal (diff)
downloadgentoo-2-52f13ff92a007f0c4790d508eebd306798eb4bf6.tar.gz
gentoo-2-52f13ff92a007f0c4790d508eebd306798eb4bf6.tar.bz2
gentoo-2-52f13ff92a007f0c4790d508eebd306798eb4bf6.zip
Allow bypassing of kexec during reboot, #357095; Proper usage of ASFLAGS, #313611
(Portage version: 2.2.0_alpha28/cvs/Linux x86_64)
Diffstat (limited to 'sys-apps')
-rw-r--r--sys-apps/kexec-tools/ChangeLog11
-rw-r--r--sys-apps/kexec-tools/files/kexec.init-ng101
-rw-r--r--sys-apps/kexec-tools/kexec-tools-2.0.2-r1.ebuild47
3 files changed, 157 insertions, 2 deletions
diff --git a/sys-apps/kexec-tools/ChangeLog b/sys-apps/kexec-tools/ChangeLog
index 4bb717e27181..67237458792a 100644
--- a/sys-apps/kexec-tools/ChangeLog
+++ b/sys-apps/kexec-tools/ChangeLog
@@ -1,6 +1,13 @@
# ChangeLog for sys-apps/kexec-tools
-# Copyright 1999-2010 Gentoo Foundation; Distributed under the GPL v2
-# $Header: /var/cvsroot/gentoo-x86/sys-apps/kexec-tools/ChangeLog,v 1.38 2010/11/29 20:42:14 radhermit Exp $
+# Copyright 1999-2011 Gentoo Foundation; Distributed under the GPL v2
+# $Header: /var/cvsroot/gentoo-x86/sys-apps/kexec-tools/ChangeLog,v 1.39 2011/03/27 08:31:50 jlec Exp $
+
+*kexec-tools-2.0.2-r1 (27 Mar 2011)
+
+ 27 Mar 2011; Justin Lecher <jlec@gentoo.org> +kexec-tools-2.0.2-r1.ebuild,
+ +files/kexec.init-ng:
+ Allow bypassing of kexec during reboot, #357095; Proper usage of ASFLAGS,
+ #313611
29 Nov 2010; Tim Harder <radhermit@gentoo.org> kexec-tools-9999.ebuild:
Use the correct upstream git repository (bug #339600 by Pinky).
diff --git a/sys-apps/kexec-tools/files/kexec.init-ng b/sys-apps/kexec-tools/files/kexec.init-ng
new file mode 100644
index 000000000000..20a03e3a35bb
--- /dev/null
+++ b/sys-apps/kexec-tools/files/kexec.init-ng
@@ -0,0 +1,101 @@
+#!/sbin/runscript
+# Copyright 1999-2011 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-ng,v 1.1 2011/03/27 08:31:50 jlec Exp $
+
+depend() {
+ need localmount
+}
+
+image_path() {
+ local x= kver=$(uname -r)
+ for x in "${KNAME:-bzImage}" vmlinuz \
+ bzImage-"${kver}" vmlinuz-"${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)" mounted=false initrdopt=
+
+ if [ -z "${img}" ] ; 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)"
+ fi
+ fi
+
+ if [ -z "${img}" ] ; then
+ eerror "No kernel image found in ${BOOTPART}!"
+ ${mounted} && umount "${BOOTPART}"
+ return 1
+ fi
+
+ ebegin "Loading kernel image ${img} for kexec"
+ if [ -z "${ROOTPART}" ] ; then
+ ROOTPART="$(readlink -f "$(sed -n '/^\/[^ ]* \/ / s,^\([^ ]*\).*,\1,p' /etc/mtab)")"
+ fi
+ if [ -z "${KPARAM}" ] ; then
+ KPARAM="$(sed -e 's/ /\n/g' /proc/cmdline | grep -v -e "^root=" | tr '\n' ' ')"
+ fi
+
+ # Use the default initrd if it exists and none other given
+ if [ -z "${INITRD}" -a -e "${BOOTPART}"/initrd ] ; then
+ INITRD="${BOOTPART}/initrd"
+ fi
+ if [ -e "${INITRD}" ] ; then
+ initrdopt="--initrd=${INITRD}"
+ fi
+
+ kexec -l "${img}" --append="root=${ROOTPART} ${KPARAM}" ${initrdopt}
+ local res=$?
+
+ ${mounted} && umount "${BOOTPART}"
+ eend ${res}
+ return ${res}
+}
+
+start() {
+ [ "${LOAD_DURING_SHUTDOWN:-yes}" = "yes" ] && return 0
+
+ ebegin "Configuring kexec"
+ load_image
+ eend 0
+}
+
+stop() {
+ [ "${LOAD_DURING_SHUTDOWN:-yes}" != "yes" ] && return 0
+
+ ebegin "Configuring kexec"
+ if [ "`/sbin/runlevel|/bin/cut -c 3`" != "6" ]; then
+ einfo "Not rebooting, so disabling"
+ kexec -u
+ return 0
+ fi
+
+ if [ "`/sbin/runlevel|/bin/cut -c 3`" = "6" ] && [ -f /nokexec ]; then
+ einfo "Not using kexec during reboot"
+ rm -f /nokexec
+ kexec -u
+ return 0
+ fi
+
+ load_image
+ eend $?
+}
diff --git a/sys-apps/kexec-tools/kexec-tools-2.0.2-r1.ebuild b/sys-apps/kexec-tools/kexec-tools-2.0.2-r1.ebuild
new file mode 100644
index 000000000000..5fe6392e2fb4
--- /dev/null
+++ b/sys-apps/kexec-tools/kexec-tools-2.0.2-r1.ebuild
@@ -0,0 +1,47 @@
+# Copyright 1999-2011 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.2-r1.ebuild,v 1.1 2011/03/27 08:31:50 jlec Exp $
+
+EAPI=2
+
+inherit eutils flag-o-matic
+
+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.bz2"
+
+LICENSE="GPL-2"
+SLOT="0"
+KEYWORDS="~amd64 ~x86"
+IUSE="lzma xen zlib"
+
+DEPEND="
+ lzma? ( app-arch/xz-utils )
+ zlib? ( sys-libs/zlib )"
+RDEPEND="${DEPEND}"
+
+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)
+}
+
+src_install() {
+ emake DESTDIR="${D}" install || die "emake install failed"
+
+ doman kexec/kexec.8 || die "doman failed"
+ dodoc News AUTHORS TODO || die "dodoc failed"
+
+ newinitd "${FILESDIR}"/kexec.init-ng kexec || die
+ newconfd "${FILESDIR}"/kexec.conf kexec || die
+}