Updated the keymap-handling code so it will be installed and displayed without using...
[genkernel.git] / gen_determineargs.sh
1 #!/bin/bash
2
3 get_KV() {
4         if [ "${NO_KERNEL_SOURCES}" = '1' -a -e "${KERNCACHE}" ]
5         then
6                 /bin/tar -xj -C ${TEMP} -f ${KERNCACHE} kerncache.config 
7                 if [ -e ${TEMP}/kerncache.config ]
8                 then
9                         KERN_24=0
10                         VER=`grep ^VERSION\ \= ${TEMP}/kerncache.config | awk '{ print $3 };'`
11                         PAT=`grep ^PATCHLEVEL\ \= ${TEMP}/kerncache.config | awk '{ print $3 };'`
12                         SUB=`grep ^SUBLEVEL\ \= ${TEMP}/kerncache.config | awk '{ print $3 };'`
13                         EXV=`grep ^EXTRAVERSION\ \= ${TEMP}/kerncache.config | sed -e "s/EXTRAVERSION =//" -e "s/ //g"`
14                         if [ "${PAT}" -gt '4' -a "${VER}" -ge '2' ]
15                         then
16                                 LOV=`grep ^CONFIG_LOCALVERSION\= ${TEMP}/kerncache.config | sed -e "s/CONFIG_LOCALVERSION=\"\(.*\)\"/\1/"`
17                                 KV=${VER}.${PAT}.${SUB}${EXV}${LOV}
18                         else
19                                 KERN_24=1
20                                 KV=${VER}.${PAT}.${SUB}${EXV}
21                         fi
22
23                 else
24                         gen_die "Could not find kerncache.config in the kernel cache! Exiting."
25                 fi
26
27         else
28                 # Configure the kernel
29                 # If BUILD_KERNEL=0 then assume --no-clean, menuconfig is cleared
30
31                 VER=`grep ^VERSION\ \= ${KERNEL_DIR}/Makefile | awk '{ print $3 };'`
32                 PAT=`grep ^PATCHLEVEL\ \= ${KERNEL_DIR}/Makefile | awk '{ print $3 };'`
33                 SUB=`grep ^SUBLEVEL\ \= ${KERNEL_DIR}/Makefile | awk '{ print $3 };'`
34                 EXV=`grep ^EXTRAVERSION\ \= ${KERNEL_DIR}/Makefile | sed -e "s/EXTRAVERSION =//" -e "s/ //g" -e 's/\$([a-z]*)//gi'`
35                 if [ "${PAT}" -gt '4' -a "${VER}" -ge '2' -a -e ${KERNEL_DIR}/.config ]
36                 then
37                         KERN_24=0
38                         cd ${KERNEL_DIR}
39                         #compile_generic prepare kernel > /dev/null 2>&1
40                         cd - > /dev/null 2>&1
41                         [ -f "${KERNEL_DIR}/include/linux/version.h" ] && \
42                                 VERSION_SOURCE="${KERNEL_DIR}/include/linux/version.h"
43                         [ -f "${KERNEL_DIR}/include/linux/utsrelease.h" ] && \
44                                 VERSION_SOURCE="${KERNEL_DIR}/include/linux/utsrelease.h"
45                         # Handle new-style releases where version.h doesn't have UTS_RELEASE
46                         if [ -f ${KERNEL_DIR}/include/config/kernel.release ]
47                         then
48                                 UTS_RELEASE=`cat ${KERNEL_DIR}/include/config/kernel.release`
49                                 LOV=`echo ${UTS_RELEASE}|sed -e "s/${VER}.${PAT}.${SUB}${EXV}//"`
50                                 KV=${VER}.${PAT}.${SUB}${EXV}${LOV}
51                         elif [ -n "${VERSION_SOURCE}" ]
52                         then
53                                 UTS_RELEASE=`grep UTS_RELEASE ${VERSION_SOURCE} | sed -e 's/#define UTS_RELEASE "\(.*\)"/\1/'`
54                                 LOV=`echo ${UTS_RELEASE}|sed -e "s/${VER}.${PAT}.${SUB}${EXV}//"`
55                                 KV=${VER}.${PAT}.${SUB}${EXV}${LOV}
56                         else
57                                 LCV=`grep ^CONFIG_LOCALVERSION= ${KERNEL_DIR}/.config | sed -r -e "s/.*=\"(.*)\"/\1/"`
58                                 KV=${VER}.${PAT}.${SUB}${EXV}${LCV}
59                         fi
60                 else
61                         KERN_24=1
62                         KV=${VER}.${PAT}.${SUB}${EXV}
63                 fi
64         fi
65 }
66
67 determine_real_args() {
68         print_info 4 "Resolving config file, command line, and arch default settings."
69
70         #                          Config File          Command Line             Arch Default
71         #                          -----------          ------------             ------------
72         set_config_with_override 2 DEBUGFILE            CMD_DEBUGFILE
73         set_config_with_override 2 KERNEL_DIR           CMD_KERNEL_DIR           "${DEFAULT_KERNEL_SOURCE}"
74         set_config_with_override 1 NO_KERNEL_SOURCES    CMD_NO_KERNEL_SOURCES
75         set_config_with_override 2 KNAME                CMD_KERNNAME             "genkernel"
76
77         set_config_with_override 2 MAKEOPTS             CMD_MAKEOPTS             "$DEFAULT_MAKEOPTS"
78         set_config_with_override 2 KERNEL_MAKE          CMD_KERNEL_MAKE          "$DEFAULT_KERNEL_MAKE"
79         set_config_with_override 2 UTILS_MAKE           CMD_UTILS_MAKE           "$DEFAULT_UTILS_MAKE"
80         set_config_with_override 2 KERNEL_CC            CMD_KERNEL_CC            "$DEFAULT_KERNEL_CC"
81         set_config_with_override 2 KERNEL_LD            CMD_KERNEL_LD            "$DEFAULT_KERNEL_LD"
82         set_config_with_override 2 KERNEL_AS            CMD_KERNEL_AS            "$DEFAULT_KERNEL_AS"
83         set_config_with_override 2 UTILS_CC             CMD_UTILS_CC             "$DEFAULT_UTILS_CC"
84         set_config_with_override 2 UTILS_LD             CMD_UTILS_LD             "$DEFAULT_UTILS_LD"
85         set_config_with_override 2 UTILS_AS             CMD_UTILS_AS             "$DEFAULT_UTILS_AS"
86
87         set_config_with_override 2 KERNEL_CROSS_COMPILE CMD_KERNEL_CROSS_COMPILE
88         set_config_with_override 2 UTILS_CROSS_COMPILE  CMD_UTILS_CROSS_COMPILE
89         set_config_with_override 2 BOOTDIR              CMD_BOOTDIR              "/boot"
90
91         set_config_with_override 1 SPLASH               CMD_SPLASH
92         set_config_with_override 1 POSTCLEAR            CMD_POSTCLEAR
93         set_config_with_override 1 MRPROPER             CMD_MRPROPER
94         set_config_with_override 1 MENUCONFIG           CMD_MENUCONFIG
95         set_config_with_override 1 CLEAN                CMD_CLEAN
96
97         set_config_with_override 2 MINKERNPACKAGE       CMD_MINKERNPACKAGE
98         set_config_with_override 2 MODULESPACKAGE       CMD_MODULESPACKAGE
99         set_config_with_override 2 KERNCACHE            CMD_KERNCACHE
100         set_config_with_override 1 NOINITRDMODULES      CMD_NOINITRDMODULES
101         set_config_with_override 1 ALLINITRDMODULES     CMD_ALLINITRDMODULES
102         set_config_with_override 2 INITRAMFS_OVERLAY    CMD_INITRAMFS_OVERLAY
103         set_config_with_override 1 MOUNTBOOT            CMD_MOUNTBOOT
104         set_config_with_override 1 BUILD_STATIC         CMD_STATIC
105         set_config_with_override 1 SAVE_CONFIG          CMD_SAVE_CONFIG
106         set_config_with_override 1 SYMLINK              CMD_SYMLINK
107         set_config_with_override 2 INSTALL_MOD_PATH     CMD_INSTALL_MOD_PATH
108         set_config_with_override 1 OLDCONFIG            CMD_OLDCONFIG
109         set_config_with_override 1 LVM                  CMD_LVM
110         set_config_with_override 1 EVMS                 CMD_EVMS
111         set_config_with_override 1 DMRAID               CMD_DMRAID
112         set_config_with_override 1 BUSYBOX              CMD_BUSYBOX              "yes"
113         set_config_with_override 1 DISKLABEL            CMD_DISKLABEL
114         set_config_with_override 1 LUKS                 CMD_LUKS
115         set_config_with_override 1 MDADM                CMD_MDADM
116         set_config_with_override 1 FIRMWARE             CMD_FIRMWARE
117         set_config_with_override 2 FIRMWARE_DIR         CMD_FIRMWARE_DIR         "/lib/firmware"
118         set_config_with_override 2 FIRMWARE_FILES       CMD_FIRMWARE_FILES
119         set_config_with_override 1 INTEGRATED_INITRAMFS CMD_INTEGRATED_INITRAMFS
120         set_config_with_override 1 GENZIMAGE            CMD_GENZIMAGE
121         set_config_with_override 1 KEYMAP               CMD_KEYMAP               "yes"
122         set_config_with_override 1 DOKEYMAPAUTO         CMD_DOKEYMAPAUTO
123
124         BOOTDIR=`arch_replace "${BOOTDIR}"`
125         BOOTDIR=${BOOTDIR%/}    # Remove any trailing slash
126
127         CACHE_DIR=`arch_replace "${CACHE_DIR}"`
128         BUSYBOX_BINCACHE=`cache_replace "${BUSYBOX_BINCACHE}"`
129         DEVICE_MAPPER_BINCACHE=`cache_replace "${DEVICE_MAPPER_BINCACHE}"`
130         LVM_BINCACHE=`cache_replace "${LVM_BINCACHE}"`
131         DMRAID_BINCACHE=`cache_replace "${DMRAID_BINCACHE}"`
132         BLKID_BINCACHE=`cache_replace "${BLKID_BINCACHE}"`
133   
134         DEFAULT_KERNEL_CONFIG=`arch_replace "${DEFAULT_KERNEL_CONFIG}"`
135         BUSYBOX_CONFIG=`arch_replace "${BUSYBOX_CONFIG}"`
136         BUSYBOX_BINCACHE=`arch_replace "${BUSYBOX_BINCACHE}"`
137         DEVICE_MAPPER_BINCACHE=`arch_replace "${DEVICE_MAPPER_BINCACHE}"`
138         LVM_BINCACHE=`arch_replace "${LVM_BINCACHE}"`
139         DMRAID_BINCACHE=`arch_replace "${DMRAID_BINCACHE}"`
140         BLKID_BINCACHE=`arch_replace "${BLKID_BINCACHE}"`
141         
142
143         if [ "${CMD_BOOTLOADER}" != '' ]
144         then
145                 BOOTLOADER="${CMD_BOOTLOADER}"
146
147                 if [ "${CMD_BOOTLOADER}" != "${CMD_BOOTLOADER/:/}" ]
148         then
149                         BOOTFS=`echo "${CMD_BOOTLOADER}" | cut -f2- -d:`
150                         BOOTLOADER=`echo "${CMD_BOOTLOADER}" | cut -f1 -d:`
151         fi
152         fi
153
154         if [ "${NO_KERNEL_SOURCES}" != "1" ]
155         then
156                 if [ ! -d ${KERNEL_DIR} ]
157                 then
158                         gen_die "kernel source directory \"${KERNEL_DIR}\" was not found!"
159                 fi
160         fi
161
162         if [ -z "${KERNCACHE}" ]
163         then
164                 if [ "${KERNEL_DIR}" = '' -a "${NO_KERNEL_SOURCES}" != "1" ]
165                 then
166                         gen_die 'No kernel source directory!'
167                 fi
168                 if [ ! -e "${KERNEL_DIR}" -a "${NO_KERNEL_SOURCES}" != "1" ]
169                 then
170                         gen_die 'No kernel source directory!'
171                 fi
172         else
173                 if [ "${KERNEL_DIR}" = '' ]
174                 then
175                         gen_die 'Kernel Cache specified but no kernel tree to verify against!'
176                 fi
177         fi
178
179         # Special case:  If --no-clean is specified on the command line, 
180         # imply --no-mrproper.
181         if [ "${CMD_CLEAN}" != '' ]
182         then
183                 if ! isTrue ${CLEAN}
184                 then
185                         MRPROPER=0
186                 fi
187         fi
188         
189         if [ -n "${MINKERNPACKAGE}" ]
190         then
191                 mkdir -p `dirname ${MINKERNPACKAGE}`
192         fi
193         
194         if [ -n "${MODULESPACKAGE}" ]
195         then
196                 mkdir -p `dirname ${MODULESPACKAGE}`
197         fi
198
199         if [ -n "${KERNCACHE}" ]
200         then
201                 mkdir -p `dirname ${KERNCACHE}`
202         fi
203
204         if ! isTrue "${BUILD_INITRD}"
205         then
206                 INTEGRATED_INITRAMFS=0
207         fi
208         
209         get_KV
210 }