Move from "no-foo enabled" to "foo disabled" for consistency
[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         # Backup current kernel .config
33         if isTrue "${MRPROPER}" || [ ! -f "${KERNEL_DIR}/.config" ]
34         then
35                 print_info 1 "kernel: Using config from ${KERNEL_CONFIG}"
36                 if [ -f "${KERNEL_DIR}/.config" ]
37                 then
38                         NOW=`date +--%Y-%m-%d--%H-%M-%S`
39                         cp "${KERNEL_DIR}/.config" "${KERNEL_DIR}/.config${NOW}.bak" \
40                                         || gen_die "Could not backup kernel config (${KERNEL_DIR}/.config)"
41                         print_info 1 "        Previous config backed up to .config${NOW}.bak"
42                 fi
43         fi
44
45         if isTrue ${MRPROPER}
46         then
47                 print_info 1 'kernel: >> Running mrproper...'
48                 compile_generic mrproper kernel
49         else
50                 print_info 1 "kernel: --mrproper is disabled; not running 'make mrproper'."
51         fi
52
53         # If we're not cleaning a la mrproper, then we don't want to try to overwrite the configs
54         # or we might remove configurations someone is trying to test.
55         if isTrue "${MRPROPER}" || [ ! -f "${KERNEL_DIR}/.config" ]
56         then
57                 cp "${KERNEL_CONFIG}" "${KERNEL_DIR}/.config" || gen_die 'Could not copy configuration file!'
58         fi
59
60         if isTrue "${OLDCONFIG}"
61         then
62                 print_info 1 '        >> Running oldconfig...'
63                 yes '' 2>/dev/null | compile_generic oldconfig kernel 2>/dev/null
64         else
65                 print_info 1 "kernel: --oldconfig is disabled; not running 'make oldconfig'."
66         fi
67         if isTrue "${CLEAN}"
68         then
69                 print_info 1 'kernel: >> Cleaning...'
70                 compile_generic clean kernel
71         else
72                 print_info 1 "kernel: --clean is disabled; not running 'make clean'."
73         fi
74         
75         if isTrue ${MENUCONFIG}
76         then
77                 print_info 1 'kernel: >> Invoking menuconfig...'
78                 compile_generic menuconfig runtask
79                 [ "$?" ] || gen_die 'Error: menuconfig failed!'
80         elif isTrue ${CMD_GCONFIG}
81         then
82                 print_info 1 'kernel: >> Invoking gconfig...'
83                 compile_generic gconfig kernel
84                 [ "$?" ] || gen_die 'Error: gconfig failed!'
85
86                 CMD_XCONFIG=0
87         fi
88
89         if isTrue ${CMD_XCONFIG}
90         then
91                 print_info 1 'kernel: >> Invoking xconfig...'
92                 compile_generic xconfig kernel
93                 [ "$?" ] || gen_die 'Error: xconfig failed!'
94         fi
95
96         # Force this on if we are using --genzimage
97         if isTrue ${CMD_GENZIMAGE}
98         then
99                 # Make sure Ext2 support is on...
100                 sed -e 's/#\? \?CONFIG_EXT2_FS[ =].*/CONFIG_EXT2_FS=y/g' \
101                         -i ${KERNEL_DIR}/.config 
102         fi
103
104         # Make sure lvm modules are on if --lvm
105         if isTrue ${CMD_LVM}
106         then
107                 sed -i ${KERNEL_DIR}/.config -e 's/#\? \?CONFIG_BLK_DEV_DM is.*/CONFIG_BLK_DEV_DM=m/g'
108                 sed -i ${KERNEL_DIR}/.config -e 's/#\? \?CONFIG_DM_SNAPSHOT is.*/CONFIG_DM_SNAPSHOT=m/g'
109                 sed -i ${KERNEL_DIR}/.config -e 's/#\? \?CONFIG_DM_MIRROR is.*/CONFIG_DM_MIRROR=m/g'
110         fi
111
112         # Make sure dmraid modules are on if --dmraid
113         if isTrue ${CMD_DMRAID}
114         then
115                 sed -i ${KERNEL_DIR}/.config -e 's/#\? \?CONFIG_BLK_DEV_DM is.*/CONFIG_BLK_DEV_DM=m/g'
116         fi
117
118         # Make sure iSCSI modules are enabled in the kernel, if --iscsi
119         # CONFIG_SCSI_ISCSI_ATTRS
120         # CONFIG_ISCSI_TCP
121         if isTrue ${CMD_ISCSI}
122         then
123                 sed -i ${KERNEL_DIR}/.config -e 's/\# CONFIG_ISCSI_TCP is not set/CONFIG_ISCSI_TCP=m/g'
124                 sed -i ${KERNEL_DIR}/.config -e 's/\# CONFIG_SCSI_ISCSI_ATTRS is not set/CONFIG_SCSI_ISCSI_ATTRS=m/g'
125
126                 sed -i ${KERNEL_DIR}/.config -e 's/CONFIG_ISCSI_TCP=y/CONFIG_ISCSI_TCP=m/g'
127                 sed -i ${KERNEL_DIR}/.config -e 's/CONFIG_SCSI_ISCSI_ATTRS=y/CONFIG_SCSI_ISCSI_ATTRS=m/g'
128         fi
129
130         if isTrue ${SPLASH}
131         then
132                 sed -i ${KERNEL_DIR}/.config -e 's/#\? \?CONFIG_FB_SPLASH is.*/CONFIG_FB_SPLASH=y/g'
133         fi
134 }