Apply fix to deference links for gentoo bug #269603
[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/${ARCH}/kernel-config-${KV}" ]
11         then
12                 KERNEL_CONFIG="${GK_SHARE}/arch/${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/${ARCH}/kernel-config-${VER}.${PAT}" ]
17         then
18                 KERNEL_CONFIG="${GK_SHARE}/arch/${ARCH}/kernel-config-${VER}.${PAT}"
19         elif [ -f "${GK_SHARE}/arch/${ARCH}/kernel-config" ]
20         then
21                 KERNEL_CONFIG="${GK_SHARE}/arch/${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
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 "${OLDCONFIG}"
48         then
49                 print_info 1 '        >> Running oldconfig...'
50                 yes '' 2>/dev/null | compile_generic oldconfig kernel 2>/dev/null
51         fi
52         if isTrue "${CLEAN}"
53         then
54                 print_info 1 'kernel: >> Cleaning...'
55                 compile_generic clean kernel
56         else
57                 print_info 1 "config: --no-clean is enabled; leaving the .config alone."
58         fi
59         
60         if isTrue ${MENUCONFIG}
61         then
62                 print_info 1 'config: >> Invoking menuconfig...'
63                 compile_generic menuconfig runtask
64                 [ "$?" ] || gen_die 'Error: menuconfig failed!'
65         elif isTrue ${CMD_GCONFIG}
66         then
67                 print_info 1 'config: >> Invoking gconfig...'
68                 compile_generic gconfig kernel
69                 [ "$?" ] || gen_die 'Error: gconfig failed!'
70
71                 CMD_XCONFIG=0
72         fi
73
74         if isTrue ${CMD_XCONFIG}
75         then
76                 print_info 1 'config: >> Invoking xconfig...'
77                 compile_generic xconfig kernel
78                 [ "$?" ] || gen_die 'Error: xconfig failed!'
79         fi
80
81         # Force this on if we are using --genzimage
82         if isTrue ${CMD_GENZIMAGE}
83         then
84                 # Make sure Ext2 support is on...
85                 sed -e 's/#\? \?CONFIG_EXT2_FS[ =].*/CONFIG_EXT2_FS=y/g' \
86                         -i ${KERNEL_DIR}/.config 
87         fi
88
89         # Make sure lvm modules are on if --lvm
90         if isTrue ${CMD_LVM}
91         then
92                 sed -i ${KERNEL_DIR}/.config -e 's/#\? \?CONFIG_BLK_DEV_DM is.*/CONFIG_BLK_DEV_DM=m/g'
93                 sed -i ${KERNEL_DIR}/.config -e 's/#\? \?CONFIG_DM_SNAPSHOT is.*/CONFIG_DM_SNAPSHOT=m/g'
94                 sed -i ${KERNEL_DIR}/.config -e 's/#\? \?CONFIG_DM_MIRROR is.*/CONFIG_DM_MIRROR=m/g'
95         fi
96
97         # Make sure dmraid modules are on if --dmraid
98         if isTrue ${CMD_DMRAID}
99         then
100                 sed -i ${KERNEL_DIR}/.config -e 's/#\? \?CONFIG_BLK_DEV_DM is.*/CONFIG_BLK_DEV_DM=m/g'
101         fi
102
103         if isTrue ${SPLASH}
104         then
105                 sed -i ${KERNEL_DIR}/.config -e 's/#\? \?CONFIG_FB_SPLASH is.*/CONFIG_FB_SPLASH=y/g'
106         fi
107 }