Adding Id header.
[genkernel.git] / gen_configkernel.sh
1 #!/bin/bash
2 # $Id$
3
4 determine_config_file() {
5         if [ "${CMD_KERNEL_CONFIG}" != "" ]
6         then
7                 KERNEL_CONFIG="${CMD_KERNEL_CONFIG}"
8         elif [ -f "/etc/kernels/kernel-config-${ARCH}-${KV}" ]
9         then
10                 KERNEL_CONFIG="/etc/kernels/kernel-config-${ARCH}-${KV}"
11         elif [ -f "${GK_SHARE}/arch/${ARCH}/kernel-config-${KV}" ]
12         then
13                 KERNEL_CONFIG="${GK_SHARE}/arch/${ARCH}/kernel-config-${KV}"
14         elif [ "${DEFAULT_KERNEL_CONFIG}" != "" -a -f "${DEFAULT_KERNEL_CONFIG}" ]
15         then
16                 KERNEL_CONFIG="${DEFAULT_KERNEL_CONFIG}"
17         elif [ -f "${GK_SHARE}/arch/${ARCH}/kernel-config-${VER}.${PAT}" ]
18         then
19                 KERNEL_CONFIG="${GK_SHARE}/arch/${ARCH}/kernel-config-${VER}.${PAT}"
20         elif [ -f "${GK_SHARE}/arch/${ARCH}/kernel-config" ]
21         then
22                 KERNEL_CONFIG="${GK_SHARE}/arch/${ARCH}/kernel-config"
23         else
24                 gen_die 'Error: No kernel .config specified, or file not found!'
25         fi
26 }
27
28 config_kernel() {
29         determine_config_file
30         cd "${KERNEL_DIR}" || gen_die 'Could not switch to the kernel directory!'
31
32         isTrue "${CLEAN}" && cp "${KERNEL_DIR}/.config" "${KERNEL_DIR}/.config.bak" > /dev/null 2>&1
33         if isTrue ${MRPROPER}
34         then
35                 print_info 1 'kernel: >> Running mrproper...'
36                 compile_generic mrproper kernel
37         fi
38
39         # If we're not cleaning, then we don't want to try to overwrite the configs
40         # or we might remove configurations someone is trying to test.
41
42         if isTrue "${CLEAN}"
43         then
44                 print_info 1 "config: Using config from ${KERNEL_CONFIG}"
45                 print_info 1 '        Previous config backed up to .config.bak'
46                 cp "${KERNEL_CONFIG}" "${KERNEL_DIR}/.config" || gen_die 'Could not copy configuration file!'
47         fi
48         if isTrue "${OLDCONFIG}"
49         then
50                 print_info 1 '        >> Running oldconfig...'
51                 yes '' 2>/dev/null | compile_generic oldconfig kernel 2>/dev/null
52         fi
53         if isTrue "${CLEAN}"
54         then
55                 print_info 1 'kernel: >> Cleaning...'
56                 compile_generic clean kernel
57         else
58                 print_info 1 "config: --no-clean is enabled; leaving the .config alone."
59         fi
60         
61         if isTrue ${MENUCONFIG}
62         then
63                 print_info 1 'config: >> Invoking menuconfig...'
64                 compile_generic menuconfig runtask
65                 [ "$?" ] || gen_die 'Error: menuconfig failed!'
66         elif isTrue ${CMD_GCONFIG}
67         then
68                 print_info 1 'config: >> Invoking gconfig...'
69                 compile_generic gconfig kernel
70                 [ "$?" ] || gen_die 'Error: gconfig failed!'
71
72                 CMD_XCONFIG=0
73         fi
74
75         if isTrue ${CMD_XCONFIG}
76         then
77                 print_info 1 'config: >> Invoking xconfig...'
78                 compile_generic xconfig kernel
79                 [ "$?" ] || gen_die 'Error: xconfig failed!'
80         fi
81
82         # Force this on if we are using --genzimage
83         if isTrue ${CMD_GENZIMAGE}
84         then
85                 # Make sure Ext2 support is on...
86                 sed -e 's/#\? \?CONFIG_EXT2_FS[ =].*/CONFIG_EXT2_FS=y/g' \
87                         -i ${KERNEL_DIR}/.config 
88         fi
89
90         # Make sure lvm modules are on if --lvm
91         if isTrue ${CMD_LVM}
92         then
93                 sed -i ${KERNEL_DIR}/.config -e 's/#\? \?CONFIG_BLK_DEV_DM is.*/CONFIG_BLK_DEV_DM=m/g'
94                 sed -i ${KERNEL_DIR}/.config -e 's/#\? \?CONFIG_DM_SNAPSHOT is.*/CONFIG_DM_SNAPSHOT=m/g'
95                 sed -i ${KERNEL_DIR}/.config -e 's/#\? \?CONFIG_DM_MIRROR is.*/CONFIG_DM_MIRROR=m/g'
96         fi
97
98         # Make sure dmraid modules are on if --dmraid
99         if isTrue ${CMD_DMRAID}
100         then
101                 sed -i ${KERNEL_DIR}/.config -e 's/#\? \?CONFIG_BLK_DEV_DM is.*/CONFIG_BLK_DEV_DM=m/g'
102         fi
103
104         if isTrue ${SPLASH}
105         then
106                 sed -i ${KERNEL_DIR}/.config -e 's/#\? \?CONFIG_FB_SPLASH is.*/CONFIG_FB_SPLASH=y/g'
107         fi
108 }