Magellan Linux

Contents of /tags/grubby-8_21/installkernel

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2062 - (show annotations) (download)
Wed Feb 20 14:30:04 2013 UTC (11 years, 1 month ago) by niro
File size: 2683 byte(s)
tagged 'grubby-8_21'
1 #! /bin/bash
2 #
3 # /sbin/installkernel
4 #
5 # Copyright 2007-2008 Red Hat, Inc. All rights reserved.
6 #
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
11 #
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 #
20 # Author(s): tyson@rwii.com
21 #
22
23 usage()
24 {
25 echo "Usage: $(basename $0) <kernel_version> <bootimage> <mapfile>" >&2
26 exit 1
27 }
28
29 cfgLoader=
30
31 if [[ -z ${INSTALL_PATH} ]] || [[ ${INSTALL_PATH} = /boot ]]
32 then
33 INSTALL_PATH=/boot
34 cfgLoader=1
35 fi
36
37 LINK_PATH=/boot
38 RELATIVE_PATH=$(echo "${INSTALL_PATH}/" | sed "s|^${LINK_PATH}/||")
39 KERNEL_VERSION=$1
40 BOOTIMAGE=$2
41 MAPFILE=$3
42 ARCH=$(uname -m)
43 if [[ ${ARCH} = ppc64 ]] || [[ ${ARCH} = ppc ]]
44 then
45 KERNEL_NAME=kernel
46 else
47 KERNEL_NAME=kernel
48 fi
49
50 if [[ -z ${KERNEL_VERSION} ]] || [[ -z ${BOOTIMAGE} ]] || [[ -z ${MAPFILE} ]]
51 then
52 usage
53 fi
54
55 if [[ -f ${INSTALL_PATH}/${KERNEL_NAME}-${KERNEL_VERSION} ]]
56 then
57 mv ${INSTALL_PATH}/${KERNEL_NAME}-${KERNEL_VERSION} \
58 ${INSTALL_PATH}/${KERNEL_NAME}-${KERNEL_VERSION}.old
59 fi
60
61 if [ ! -L ${INSTALL_PATH}/${KERNEL_NAME} ]
62 then
63 if [ -e ${INSTALLPATH}/${KERNEL_NAME} ]
64 then
65 mv ${INSTALL_PATH}/${KERNEL_NAME} ${INSTALL_PATH}/${KERNEL_NAME}.old
66 fi
67 fi
68
69 if [ -f ${INSTALL_PATH}/System.map-${KERNEL_VERSION} ]
70 then
71 mv ${INSTALL_PATH}/System.map-${KERNEL_VERSION} \
72 ${INSTALL_PATH}/System.map-${KERNEL_VERSION}.old
73 fi
74
75 if [ ! -L ${INSTALL_PATH}/System.map ]
76 then
77 if [ -e ${INSTALLPATH}/System.map ]
78 then
79 mv ${INSTALL_PATH}/System.map ${INSTALL_PATH}/System.map.old
80 fi
81 fi
82 ln -sf ${RELATIVE_PATH}${INSTALL_PATH}/System.map-${KERNEL_VERSION} ${LINK_PATH}/System.map
83
84 cat ${BOOTIMAGE} > ${INSTALL_PATH}/${KERNEL_NAME}-${KERNEL_VERSION}
85 cp ${MAPFILE} ${INSTALL_PATH}/System.map-${KERNEL_VERSION}
86
87 ln -fs ${RELATIVE_PATH}${INSTALL_PATH}/${KERNEL_NAME}-${KERNEL_VERSION} ${LINK_PATH}/${KERNEL_NAME}
88 ln -fs ${RELATIVE_PATH}${INSTALL_PATH}/System.map-${KERNEL_VERSION} ${LINK_PATH}/System.map
89
90 if [[ -n ${cfgLoader} ]] && [[ -x /sbin/new-kernel-pkg ]]
91 then
92 if [ -n "$(which dracut 2>/dev/null)" ]
93 then
94 new-kernel-pkg --mkinitrd --dracut --host-only --depmod --install ${KERNEL_VERSION}
95 else
96 new-kernel-pkg --mkinitrd --depmod --install ${KERNEL_VERSION}
97 fi
98 fi

Properties

Name Value
svn:executable *