From: Frank Brehm Date: Wed, 6 Nov 2013 20:53:34 +0000 (+0100) Subject: Changes for GRUB2 only X-Git-Url: https://git.uhu-banane.de/?a=commitdiff_plain;h=16da0c20a5903e51d9a53d47f9a22a234b69ab84;p=scripts%2Froot-bin.git Changes for GRUB2 only --- diff --git a/installkernel b/installkernel index b797482..92dc9c8 100755 --- a/installkernel +++ b/installkernel @@ -4,22 +4,29 @@ set -e ME=installkernel -VERSION="2011-10-26" +VERSION="2013-11-06" + +KERNEL_VERSION=$1 +shift +KERNEL_IMAGE=$1 +shift +KERNEL_MAPFILE=$1 +shift +DEF_INSTALL_PATH=$1 +shift echo -e "\n$ME:\nFrank Brehm's installkernel script, $VERSION" echo "* Arguments: -kernel version: $1 -kernel image file: $2 -kernel map file: $3 -default install path: $4 +kernel version: ${KERNEL_VERSION} +kernel image file: ${KERNEL_IMAGE} +kernel map file: ${KERNEL_MAPFILE} +default install path: ${DEF_INSTALL_PATH} " +export VERBOSE="${V:-0}" + #B="/mnt/misc/boot" BOOT_DIR="/boot" -KERNEL_VERSION=$1 -KERNEL_IMAGE=$2 -KERNEL_MAPFILE=$3 -DEF_INSTALL_PATH=$4 was_mounted='y' @@ -42,10 +49,16 @@ fi # where to find .config, based on kernel series if [ -f '.config' ] ; then - echo "* 2.6/3.x kernel" + if [ "${VERBOSE}" != "0" ] ; then + echo "* 2.6/3.x kernel" + echo + fi DOT_CONFIG=".config" else - echo "* 2.4 kernel" + if [ "${VERBOSE}" != "0" ] ; then + echo "* 2.4 kernel" + echo + fi DOT_CONFIG="../../../.config" fi @@ -57,11 +70,19 @@ while [ -f "${TARGET_CONFIG_BOOT}" ] ; do done echo " CP ${DOT_CONFIG} -> ${TARGET_CONFIG_BOOT}" -cp -p "${DOT_CONFIG}" "${TARGET_CONFIG_BOOT}" +if [ "${VERBOSE}" = "0" ] ; then + cp -p "${DOT_CONFIG}" "${TARGET_CONFIG_BOOT}" +else + cp -pv "${DOT_CONFIG}" "${TARGET_CONFIG_BOOT}" +fi if [ ! -d /etc/kernel-config ] ; then echo " MKDIR /etc/kernel-config" - mkdir -p /etc/kernel-config + if [ "${VERBOSE}" = "0" ] ; then + mkdir -p /etc/kernel-config + else + mkdir -pv /etc/kernel-config + fi fi i=0 @@ -72,14 +93,18 @@ while [ -f "${TARGET_CONFIG_ETC}" ] ; do done echo " CP ${DOT_CONFIG} -> ${TARGET_CONFIG_ETC}" -cp -p "${DOT_CONFIG}" "${TARGET_CONFIG_ETC}" +if [ "${VERBOSE}" = "0" ] ; then + cp -p "${DOT_CONFIG}" "${TARGET_CONFIG_ETC}" +else + cp -pv "${DOT_CONFIG}" "${TARGET_CONFIG_ETC}" +fi if [ -n "$KBUILD_OUTPUT_PREFIX" -a -d $KBUILD_OUTPUT_PREFIX/$KERNEL_VERSION ] ; then LINUX_SRC_DIR=$KBUILD_OUTPUT_PREFIX/$KERNEL_VERSION else LINUX_SRC_DIR="/usr/src/linux-$KERNEL_VERSION" fi -echo " INSTALL $BOOT_DIR/bzImage-$KERNEL_VERSION" +echo " INSTALL $BOOT_DIR/kernel-$KERNEL_VERSION" if [ ! -f $LINUX_SRC_DIR/$KERNEL_IMAGE ] ; then if [ -f $LINUX_SRC_DIR/arch/i386/boot/$KERNEL_IMAGE ] ; then @@ -89,49 +114,46 @@ if [ ! -f $LINUX_SRC_DIR/$KERNEL_IMAGE ] ; then fi fi -if [ -f $LINUX_SRC_DIR/$KERNEL_MAPFILE ] ; then - KERNEL_MAPFILE=$LINUX_SRC_DIR/$KERNEL_MAPFILE +# Install kernel ... +if [ "${VERBOSE}" = "0" ] ; then + cp -p $LINUX_SRC_DIR$EX/$KERNEL_IMAGE $BOOT_DIR/kernel-$KERNEL_VERSION else - test -f $KERNEL_MAPFILE || exit 1 + cp -pv $LINUX_SRC_DIR$EX/$KERNEL_IMAGE $BOOT_DIR/kernel-$KERNEL_VERSION fi -cp -p $LINUX_SRC_DIR$EX/$KERNEL_IMAGE $BOOT_DIR/bzImage-$KERNEL_VERSION -ln $BOOT_DIR/bzImage-$KERNEL_VERSION $BOOT_DIR/kernel-$KERNEL_VERSION -echo " INSTALL $BOOT_DIR/System.map-$KERNEL_VERSION" -cp -p $KERNEL_MAPFILE $BOOT_DIR/System.map-$KERNEL_VERSION - -case $KERNEL_VERSION in - *-gentoo*) - TARG="-gentoo" - ;; - *) - TARG="" - ;; -esac - -TARG_CUR=${TARG}-cur -TARG_LAST=${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} +if [ ! -d $BOOT_DIR/.old ] ; then + echo " MKDIR $BOOT_DIR/.old" + if [ "${VERBOSE}" = "0" ] ; then + mkdir -p $BOOT_DIR/.old + else + mkdir -pv $BOOT_DIR/.old + fi fi -echo " LN $BOOT_DIR/bzImage${TARG_CUR}" -ln -sf bzImage-$KERNEL_VERSION $BOOT_DIR/bzImage${TARG_CUR} - -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 +if [ -f $BOOT_DIR/.old/kernel-$KERNEL_VERSION ] ; then + echo " RM $BOOT_DIR/.old/kernel-$KERNEL_VERSION" + if [ "${VERBOSE}" = "0" ] ; then + rm -f $BOOT_DIR/.old/kernel-$KERNEL_VERSION + else + rm -fv $BOOT_DIR/.old/kernel-$KERNEL_VERSION + fi +fi +echo " LN $BOOT_DIR/.old/kernel-$KERNEL_VERSION -> $BOOT_DIR/kernel-$KERNEL_VERSION" +if [ "${VERBOSE}" = "0" ] ; then + ln -f $BOOT_DIR/kernel-$KERNEL_VERSION $BOOT_DIR/.old/kernel-$KERNEL_VERSION +else + ln -fv $BOOT_DIR/kernel-$KERNEL_VERSION $BOOT_DIR/.old/kernel-$KERNEL_VERSION fi -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} +if [ -f $LINUX_SRC_DIR/$KERNEL_MAPFILE ] ; then + KERNEL_MAPFILE=$LINUX_SRC_DIR/$KERNEL_MAPFILE +else + test -f $KERNEL_MAPFILE || exit 1 +fi +echo " INSTALL $BOOT_DIR/System.map-$KERNEL_VERSION" +if [ "${VERBOSE}" = "0" ] ; then + cp -p $KERNEL_MAPFILE $BOOT_DIR/System.map-$KERNEL_VERSION +else + cp -pv $KERNEL_MAPFILE $BOOT_DIR/System.map-$KERNEL_VERSION fi # vim: ts=4 expandtab