Magellan Linux

Annotation of /trunk/grubby/installkernel

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3143 - (hide annotations) (download)
Tue Jul 7 11:20:11 2020 UTC (3 years, 10 months ago) by niro
File size: 2963 byte(s)
Make installkernel to use kernel-install scripts on BLS configuration
1 niro 1311 #! /bin/bash
2 niro 532 #
3 niro 1311 # /sbin/installkernel
4 niro 532 #
5 niro 1311 # 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 niro 532
23 niro 3143 [[ -f /etc/conf.d/grub ]] && . /etc/conf.d/grub
24    
25 niro 1311 usage()
26     {
27     echo "Usage: $(basename $0) <kernel_version> <bootimage> <mapfile>" >&2
28     exit 1
29 niro 532 }
30    
31     cfgLoader=
32    
33 niro 1311 if [[ -z ${INSTALL_PATH} ]] || [[ ${INSTALL_PATH} = /boot ]]
34     then
35     INSTALL_PATH=/boot
36     cfgLoader=1
37 niro 532 fi
38    
39 niro 1311 LINK_PATH=/boot
40     RELATIVE_PATH=$(echo "${INSTALL_PATH}/" | sed "s|^${LINK_PATH}/||")
41 niro 532 KERNEL_VERSION=$1
42     BOOTIMAGE=$2
43     MAPFILE=$3
44     ARCH=$(uname -m)
45 niro 1311 if [[ ${ARCH} = ppc64 ]] || [[ ${ARCH} = ppc ]]
46     then
47     KERNEL_NAME=kernel
48 niro 532 else
49 niro 1311 KERNEL_NAME=kernel
50 niro 532 fi
51    
52 niro 1311 if [[ -z ${KERNEL_VERSION} ]] || [[ -z ${BOOTIMAGE} ]] || [[ -z ${MAPFILE} ]]
53     then
54     usage
55 niro 532 fi
56    
57 niro 1311 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 niro 532 fi
62    
63 niro 1311 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 niro 532 fi
70    
71 niro 1311 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 niro 532 fi
76    
77 niro 1311 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 niro 532 fi
84 niro 1311 ln -sf ${RELATIVE_PATH}${INSTALL_PATH}/System.map-${KERNEL_VERSION} ${LINK_PATH}/System.map
85 niro 532
86 niro 1311 cat ${BOOTIMAGE} > ${INSTALL_PATH}/${KERNEL_NAME}-${KERNEL_VERSION}
87     cp ${MAPFILE} ${INSTALL_PATH}/System.map-${KERNEL_VERSION}
88 niro 532
89 niro 1311 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 niro 532
92 niro 3143 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 niro 1311 if [[ -n ${cfgLoader} ]] && [[ -x /sbin/new-kernel-pkg ]]
98     then
99 niro 1749 if [ -n "$(which dracut 2>/dev/null)" ]
100 niro 1340 then
101 niro 2965 new-kernel-pkg --mkinitrd --dracut --host-only --depmod --install --kernel-name ${KERNEL_NAME} ${KERNEL_VERSION}
102 niro 1340 else
103 niro 2965 new-kernel-pkg --mkinitrd --depmod --install --kernel-name ${KERNEL_NAME} ${KERNEL_VERSION}
104 niro 1340 fi
105 niro 532 fi

Properties

Name Value
svn:executable *