Renamed gensplash to splash and marked gensplash as deprecated. This is 3.4.9_pre3...
[genkernel.git] / gen_configkernel.sh
1 #!/bin/bash
2
3 determine_config_file() {
4         if [ "${CMD_KERNEL_CONFIG}" != "" ]
5         then
6                 KERNEL_CONFIG="${CMD_KERNEL_CONFIG}"
7         elif [ -f "/etc/kernels/kernel-config-${ARCH}-${KV}" ]
8         then
9                 KERNEL_CONFIG="/etc/kernels/kernel-config-${ARCH}-${KV}"
10         elif [ -f "${GK_SHARE}/${ARCH}/kernel-config-${KV}" ]
11         then
12                 KERNEL_CONFIG="${GK_SHARE}/${ARCH}/kernel-config-${KV}"
13         elif [ "${DEFAULT_KERNEL_CONFIG}" != "" -a -f "${DEFAULT_KERNEL_CONFIG}" ]
14         then
15                 KERNEL_CONFIG="${DEFAULT_KERNEL_CONFIG}"
16         elif [ -f "${GK_SHARE}/${ARCH}/kernel-config-${VER}.${PAT}" ]
17         then
18                 KERNEL_CONFIG="${GK_SHARE}/${ARCH}/kernel-config-${VER}.${PAT}"
19         elif [ -f "${GK_SHARE}/${ARCH}/kernel-config" ]
20         then
21                 KERNEL_CONFIG="${GK_SHARE}/${ARCH}/kernel-config"
22         else
23                 gen_die 'Error: No kernel .config specified, or file not found!'
24         fi
25 }
26
27 config_kernel() {
28         determine_config_file
29         cd "${KERNEL_DIR}" || gen_die 'Could not switch to the kernel directory!'
30
31         isTrue "${CLEAN}" && cp "${KERNEL_DIR}/.config" "${KERNEL_DIR}/.config.bak" > /dev/null 2>&1
32         if isTrue ${MRPROPER}
33         then
34                 print_info 1 'kernel: >> Running mrproper...'
35                 compile_generic mrproper kernel
36         fi
37
38         # If we're not cleaning, then we don't want to try to overwrite the configs there
39         # or we might remove configurations someone is trying to test.
40
41         if isTrue "${CLEAN}"
42         then
43                 print_info 1 "config: Using config from ${KERNEL_CONFIG}"
44                 print_info 1 '        Previous config backed up to .config.bak'
45                 cp "${KERNEL_CONFIG}" "${KERNEL_DIR}/.config" || gen_die 'Could not copy configuration file!'
46         fi
47         if isTrue "${CLEAN}" || isTrue "${OLDCONFIG}"
48         then
49                 if ! isTrue "${CLEAN}"
50                 then
51                         print_info 1 'config: >> Running oldconfig...'
52                 else
53                         print_info 1 '        >> Running oldconfig...'
54                 fi
55                 yes '' 2>/dev/null | compile_generic oldconfig kernel 2>/dev/null # Nullify to stop broken pipe messages
56         fi
57         if isTrue "${CLEAN}"
58         then
59                 print_info 1 'kernel: >> Cleaning...'
60                 compile_generic clean kernel
61         else
62                 print_info 1 "config: --no-clean is enabled; leaving the .config alone."
63         fi
64         
65         if isTrue ${MENUCONFIG}
66         then
67                 print_info 1 'config: >> Invoking menuconfig...'
68                 compile_generic menuconfig runtask
69                 [ "$?" ] || gen_die 'Error: menuconfig failed!'
70         elif isTrue ${CMD_GCONFIG}
71         then
72                 if [ "${VER}" == '2' ] && [ "${PAT}" -lt '6' ]
73                 then
74                         print_warning 1 'config: gconfig is not available in 2.4 series kernels. Running xconfig'
75                         print_warning 1 '        instead...'
76
77                         CMD_GCONFIG=0
78                         CMD_XCONFIG=1
79                 else
80                         print_info 1 'config: >> Invoking gconfig...'
81                         compile_generic gconfig kernel
82                         [ "$?" ] || gen_die 'Error: gconfig failed!'
83
84                         CMD_XCONFIG=0
85                 fi
86         fi
87
88         if isTrue ${CMD_XCONFIG}
89         then
90                 print_info 1 'config: >> Invoking xconfig...'
91                 compile_generic xconfig kernel
92                 [ "$?" ] || gen_die 'Error: xconfig failed!'
93         fi
94
95         # Force this on if we are a 2.4 kernel or less
96         # This is required for initrd support
97         # Initramfs doesn't require this
98         # TODO: force on with --genzimage
99         if [ "${KERN_24}" -eq '1' ]
100         then
101             # Make sure Ext2 support is on...
102             sed -i ${KERNEL_DIR}/.config -e 's/#\? \?CONFIG_EXT2_FS[ =].*/CONFIG_EXT2_FS=y/g'
103         fi
104
105         # Make sure lvm modules are on if --lvm/--lvm
106         if isTrue ${CMD_LVM}
107         then
108                 sed -i ${KERNEL_DIR}/.config -e 's/#\? \?CONFIG_BLK_DEV_DM is.*/CONFIG_BLK_DEV_DM=m/g'
109                 sed -i ${KERNEL_DIR}/.config -e 's/#\? \?CONFIG_DM_SNAPSHOT is.*/CONFIG_DM_SNAPSHOT=m/g'
110                 sed -i ${KERNEL_DIR}/.config -e 's/#\? \?CONFIG_DM_MIRROR is.*/CONFIG_DM_MIRROR=m/g'
111         fi
112
113         # Make sure dmraid modules are on if --dmraid
114         if isTrue ${CMD_DMRAID}
115         then
116                 sed -i ${KERNEL_DIR}/.config -e 's/#\? \?CONFIG_BLK_DEV_DM is.*/CONFIG_BLK_DEV_DM=m/g'
117         fi
118
119         if isTrue ${SPLASH}
120         then
121                 sed -i ${KERNEL_DIR}/.config -e 's/#\? \?CONFIG_FB_SPLASH is.*/CONFIG_FB_SPLASH=y/g'
122         fi
123
124         # This check isn't complete: SOFTWARE_SUSPEND has extra deps on some systems such as CPU hotplug
125 #       if isTrue ${CMD_SUSPEND}
126 #       then
127 #               sed -i ${KERNEL_DIR}/.config -e 's/#\? \?CONFIG_SOFTWARE_SUSPEND is.*/CONFIG_SOFTWARE_SUSPEND=y/g'
128 #       fi
129
130 }