#!/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
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
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"
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