From 05985da28c33be6f1555eb576c05c3449abd67ce Mon Sep 17 00:00:00 2001 From: Frank Brehm Date: Wed, 26 Oct 2011 23:18:56 +0200 Subject: [PATCH] Modification for 3.x kernel --- installkernel | 59 ++++++++++++++++++++++++++++++--------------------- 1 file changed, 35 insertions(+), 24 deletions(-) diff --git a/installkernel b/installkernel index 61f483e..0e98866 100755 --- a/installkernel +++ b/installkernel @@ -1,14 +1,13 @@ #!/bin/bash -#echo $@ #set -x +set -e ME=installkernel -VERSION="2010-12-02" +VERSION="2011-10-26" echo -e "\n$ME:\nFrank Brehm's installkernel script, $VERSION" -[ $DEBUG ] && echo " -* Arguments: +echo "* Arguments: kernel version: $1 kernel image file: $2 kernel map file: $3 @@ -22,6 +21,8 @@ KERNEL_IMAGE=$2 KERNEL_MAPFILE=$3 DEF_INSTALL_PATH=$4 +was_mounted='y' + # check we have a valid kernel target directory if [ -n "$DEF_INSTALL_PATH" ] && [ "$DEF_INSTALL_PATH" != "$BOOT_DIR" ] ; then if [ -d "$DEF_INSTALL_PATH" ] ; then @@ -33,9 +34,15 @@ if [ -n "$DEF_INSTALL_PATH" ] && [ "$DEF_INSTALL_PATH" != "$BOOT_DIR" ] ; then fi fi +if [ ! -d ${BOOT_DIR}/grub ] ; then + was_mounted='n' + echo " MOUNT ${BOOT_DIR}" + mount ${BOOT_DIR} +fi + # where to find .config, based on kernel series if [ -f '.config' ] ; then - echo "* 2.6 kernel" + echo "* 2.6/3.x kernel" DOT_CONFIG=".config" else echo "* 2.4 kernel" @@ -87,39 +94,43 @@ if [ -f $LINUX_SRC_DIR/$KERNEL_MAPFILE ] ; then else test -f $KERNEL_MAPFILE || exit 1 fi -cp $LINUX_SRC_DIR$EX/$KERNEL_IMAGE $BOOT_DIR/bzImage-$KERNEL_VERSION +cp -p $LINUX_SRC_DIR$EX/$KERNEL_IMAGE $BOOT_DIR/bzImage-$KERNEL_VERSION echo " INSTALL $BOOT_DIR/System.map-$KERNEL_VERSION" -cp $KERNEL_MAPFILE $BOOT_DIR/System.map-$KERNEL_VERSION +cp -p $KERNEL_MAPFILE $BOOT_DIR/System.map-$KERNEL_VERSION case $KERNEL_VERSION in - 2.6.*-gentoo*) - TARG="-gentoo-2.6" - ;; - 2.6*) - TARG="-2.6" + *-gentoo*) + TARG="-gentoo" ;; *) TARG="" ;; esac +TARG_CUR=${TARG}-cur TARG_LAST=${TARG}-last -if [ -L $BOOT_DIR/bzImage$TARG ] ; then - IMG_LAST=$(readlink $BOOT_DIR/bzImage$TARG) - echo " LN $BOOT_DIR/bzImage$TARG_LAST" - ln -sf $IMG_LAST $BOOT_DIR/bzImage$TARG_LAST +if [ -L $BOOT_DIR/bzImage${TARG_CUR} ] ; then + IMG_LAST=$(readlink $BOOT_DIR/bzImage${TARG_CUR}) + echo " LN $BOOT_DIR/bzImage${TARG_LAST}" + ln -sf ${IMG_LAST} $BOOT_DIR/bzImage${TARG_LAST} fi -echo " LN $BOOT_DIR/bzImage$TARG" -ln -sf bzImage-$KERNEL_VERSION $BOOT_DIR/bzImage$TARG +echo " LN $BOOT_DIR/bzImage${TARG_CUR}" +ln -sf bzImage-$KERNEL_VERSION $BOOT_DIR/bzImage${TARG_CUR} -if [ -L $BOOT_DIR/System$TARG.map ] ; then - IMG_LAST=$(readlink $BOOT_DIR/System$TARG.map) - echo " LN $BOOT_DIR/System$TARG_LAST.map" - ln -sf $IMG_LAST $BOOT_DIR/System$TARG_LAST.map +if [ -L $BOOT_DIR/System${TARG_CUR}.map ] ; then + IMG_LAST=$(readlink $BOOT_DIR/System${TARG_CUR}.map) + echo " LN $BOOT_DIR/System${TARG_LAST}.map" + ln -sf $IMG_LAST $BOOT_DIR/System${TARG_LAST}.map fi -echo " LN $BOOT_DIR/System$TARG.map" -ln -sf System.map-$KERNEL_VERSION $BOOT_DIR/System$TARG.map +echo " LN $BOOT_DIR/System${TARG_CUR}.map" +ln -sf System.map-$KERNEL_VERSION $BOOT_DIR/System${TARG_CUR}.map + +if [ "${was_mounted}" = "n" ] ; then + echo " UMOUNT ${BOOT_DIR}" + umount ${BOOT_DIR} +fi +# vim: ts=4 expandtab -- 2.39.5