summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'private/sys-kernel/kernelinstall/files/kernelinstall-1.2.sh')
-rw-r--r--private/sys-kernel/kernelinstall/files/kernelinstall-1.2.sh137
1 files changed, 137 insertions, 0 deletions
diff --git a/private/sys-kernel/kernelinstall/files/kernelinstall-1.2.sh b/private/sys-kernel/kernelinstall/files/kernelinstall-1.2.sh
new file mode 100644
index 0000000..cffb030
--- /dev/null
+++ b/private/sys-kernel/kernelinstall/files/kernelinstall-1.2.sh
@@ -0,0 +1,137 @@
+#!/bin/bash
+
+source /sbin/functions.sh
+source /etc/make.globals
+esyslog() {
+ echo &> /dev/null
+}
+echo ""
+
+## runs with UID=0 ?
+if [[ `id -u` -ne 0 ]] ; then
+ eerror "This script requires root privileges"
+ eerror "Exiting!"
+ echo ""
+ exit 1
+fi
+
+## check if we are in the kernel root-dir
+if [[ ! -f ${PWD}/Makefile ]] ; then
+ eerror "You are either in a subdirectory of your kernel dir or not in any kernel dir."
+ eerror "You better change to your kernel top level directory and run this script again,"
+ eerror "or the kernel will not get installed ...."
+ echo ""
+ exit 1
+fi
+
+if [[ -z "${KERNEL_ARCH}" ]] ; then
+ ARCH="$( uname -m )"
+fi
+
+case "${ARCH}" in
+ i*86)
+ KERNEL_ARCH="i386"
+ ;;
+ x86_64)
+ KERNEL_ARCH="${ARCH}"
+ ;;
+ alpha*)
+ KERNEL_ARCH="${ARCH}"
+ ;;
+esac
+
+if [[ ! -e ${PWD}/arch/${KERNEL_ARCH}/boot/bzImage ]] ; then
+ eerror "${PWD}/arch/${KERNEL_ARCH}/boot does not contain an compressed kernel image."
+ eerror "If you are in the top-level directory of your kernel, please run"
+ eerror "'make' first. Otherwise, if you are not in /usr/src/linux"
+ eerror "change into your top-level kerneldirectory!"
+ exit 1
+fi
+
+if [[ -n "${ROOT}" && ! -d "${ROOT}" ]] ; then
+ eerror "The given ROOT does not exist. Please create it first."
+ exit 1
+fi
+
+if [[ "$1" == "-p" ]] ; then
+ PRETEND="true"
+fi
+
+getmakefilevar() {
+ grep $1 $2 | head -n 1 | cut -d = -f 2- | awk '{ print $1 }'
+}
+
+# to get a version number out of the Makefile
+KV_MAJOR="`getmakefilevar VERSION Makefile`"
+KV_MINOR="`getmakefilevar PATCHLEVEL Makefile`"
+KV_PATCH="`getmakefilevar SUBLEVEL Makefile`"
+KV_TYPE="`getmakefilevar EXTRAVERSION Makefile`"
+KV_CONFIG="`grep CONFIG_LOCALVERSION .config | head -n 1 | cut -d'"' -f 2`"
+
+einfo "\033[01mPhase 1:\033[0m"
+ebegin " [1/2] Gathering kernel version"
+KV_FULL="$KV_MAJOR.$KV_MINOR.$KV_PATCH$KV_TYPE$KV_CONFIG"
+eend $?
+
+if [[ -z "`grep /boot /etc/mtab`" && -z "${ROOT}" ]] ; then
+ ebegin " [2/2] Mounting /boot"
+ mount /boot 2> /dev/null
+ eend $?
+else
+ einfo " [2/2] Skipping 'mount /boot', already mounted ..."
+fi
+echo
+
+einfo "\033[01mPhase 2:\033[0m"
+einfo " You're going to install the following files:"
+einfo " ${ROOT}/boot/kernel-${KV_FULL}"
+einfo " ${ROOT}/boot/config-${KV_FULL}"
+einfo " ${ROOT}/boot/System.map-${KV_FULL}"
+einfo " ${ROOT}/lib/modules/${KV_FULL}"
+
+if [[ -z "${PRETEND}" ]] ; then
+ echo
+ ewarn "You are going to install kernel-${KV_FULL}."
+ ewarn "If this is not desired, then hit \033[01;31mCTRL+C\033[0m now!"
+ echo
+ echo -ne "\033[01m Waiting ${EMERGE_WARNING_DELAY} seconds: "
+
+ for i in `seq ${EMERGE_WARNING_DELAY} -1 1`; do
+ echo -en "\033[01;31m${i}\033[0m "
+ sleep 1
+ done
+ echo
+ echo
+
+ einfo "\033[01mPhase 3:\033[0m"
+
+ ebegin " [1/4] bzImage"
+ cp -pf arch/${KERNEL_ARCH}/boot/bzImage ${ROOT}/boot/kernel-${KV_FULL} 2>/dev/null
+ eend $?
+
+ ebegin " [2/4] .config"
+ cp -pf .config ${ROOT}/boot/config-${KV_FULL} 2> /dev/null
+ eend $?
+
+ ebegin " [3/4] System.map"
+ cp -pf System.map ${ROOT}/boot/System.map-${KV_FULL} 2> /dev/null
+ eend $?
+
+ ebegin " [4/4] modules"
+ if [[ -z "${ROOT}" ]] ; then
+ make modules_install &> /dev/null
+ elif [[ -n "${ROOT}" && -d "${ROOT}" ]] ; then
+ INSTALL_MOD_PATH="${ROOT}" make modules_install &> /dev/null
+ fi
+
+ echo
+ ewarn "Please add the following lines to your grub.conf:"
+ echo " title GNU/Linux ${KV_FULL}"
+ echo " root (hd0,0)"
+ echo " kernel (hd0,0)/kernel-${KV_FULL} `cat /proc/cmdline`"
+ echo
+ ewarn "Don't forget to remerge \033[01mdepending packages\033[0m (e.g. \033[01mipw2100\033[0m, \033[01malsa-driver\033[0m, \033[01mnvidia-kernel\033[0m, \033[01mqemu\033[0m, ...)"
+ ewarn "since you changed to a new kernel. This requires you to rebuild those modules."
+ ewarn "To do so, type '\033[01memerge DRIVER-NAME\033[0m' and you should be fine."
+fi
+echo