Magellan Linux

Contents of /trunk/grubby/installkernel

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3143 - (show annotations) (download)
Tue Jul 7 11:20:11 2020 UTC (3 years, 9 months ago) by niro
File size: 2963 byte(s)
Make installkernel to use kernel-install scripts on BLS configuration
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 [[ -f /etc/conf.d/grub ]] && . /etc/conf.d/grub
24
25 usage()
26 {
27 echo "Usage: $(basename $0) <kernel_version> <bootimage> <mapfile>" >&2
28 exit 1
29 }
30
31 cfgLoader=
32
33 if [[ -z ${INSTALL_PATH} ]] || [[ ${INSTALL_PATH} = /boot ]]
34 then
35 INSTALL_PATH=/boot
36 cfgLoader=1
37 fi
38
39 LINK_PATH=/boot
40 RELATIVE_PATH=$(echo "${INSTALL_PATH}/" | sed "s|^${LINK_PATH}/||")
41 KERNEL_VERSION=$1
42 BOOTIMAGE=$2
43 MAPFILE=$3
44 ARCH=$(uname -m)
45 if [[ ${ARCH} = ppc64 ]] || [[ ${ARCH} = ppc ]]
46 then
47 KERNEL_NAME=kernel
48 else
49 KERNEL_NAME=kernel
50 fi
51
52 if [[ -z ${KERNEL_VERSION} ]] || [[ -z ${BOOTIMAGE} ]] || [[ -z ${MAPFILE} ]]
53 then
54 usage
55 fi
56
57 if [[ -f ${INSTALL_PATH}/${KERNEL_NAME}-${KERNEL_VERSION} ]]
58 then
59 mv ${INSTALL_PATH}/${KERNEL_NAME}-${KERNEL_VERSION} \
60 ${INSTALL_PATH}/${KERNEL_NAME}-${KERNEL_VERSION}.old
61 fi
62
63 if [ ! -L ${INSTALL_PATH}/${KERNEL_NAME} ]
64 then
65 if [ -e ${INSTALLPATH}/${KERNEL_NAME} ]
66 then
67 mv ${INSTALL_PATH}/${KERNEL_NAME} ${INSTALL_PATH}/${KERNEL_NAME}.old
68 fi
69 fi
70
71 if [ -f ${INSTALL_PATH}/System.map-${KERNEL_VERSION} ]
72 then
73 mv ${INSTALL_PATH}/System.map-${KERNEL_VERSION} \
74 ${INSTALL_PATH}/System.map-${KERNEL_VERSION}.old
75 fi
76
77 if [ ! -L ${INSTALL_PATH}/System.map ]
78 then
79 if [ -e ${INSTALLPATH}/System.map ]
80 then
81 mv ${INSTALL_PATH}/System.map ${INSTALL_PATH}/System.map.old
82 fi
83 fi
84 ln -sf ${RELATIVE_PATH}${INSTALL_PATH}/System.map-${KERNEL_VERSION} ${LINK_PATH}/System.map
85
86 cat ${BOOTIMAGE} > ${INSTALL_PATH}/${KERNEL_NAME}-${KERNEL_VERSION}
87 cp ${MAPFILE} ${INSTALL_PATH}/System.map-${KERNEL_VERSION}
88
89 ln -fs ${RELATIVE_PATH}${INSTALL_PATH}/${KERNEL_NAME}-${KERNEL_VERSION} ${LINK_PATH}/${KERNEL_NAME}
90 ln -fs ${RELATIVE_PATH}${INSTALL_PATH}/System.map-${KERNEL_VERSION} ${LINK_PATH}/System.map
91
92 if [ "x${GRUB_ENABLE_BLSCFG}" = "xtrue" ] || [ ! -f /sbin/new-kernel-pkg ]; then
93 kernel-install add $KERNEL_VERSION $INSTALL_PATH/$KERNEL_NAME-$KERNEL_VERSION
94 exit $?
95 fi
96
97 if [[ -n ${cfgLoader} ]] && [[ -x /sbin/new-kernel-pkg ]]
98 then
99 if [ -n "$(which dracut 2>/dev/null)" ]
100 then
101 new-kernel-pkg --mkinitrd --dracut --host-only --depmod --install --kernel-name ${KERNEL_NAME} ${KERNEL_VERSION}
102 else
103 new-kernel-pkg --mkinitrd --depmod --install --kernel-name ${KERNEL_NAME} ${KERNEL_VERSION}
104 fi
105 fi

Properties

Name Value
svn:executable *