aboutsummaryrefslogtreecommitdiff
blob: 9cd4be8e350d1955b2ca58faa20297d7b5846465 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
#!/bin/bash
# $Id$

get_KV() {
	if [ "${NO_KERNEL_SOURCES}" = '1' -a -e "${KERNCACHE}" ]
	then
		/bin/tar -xj -C ${TEMP} -f ${KERNCACHE} kerncache.config 
		if [ -e ${TEMP}/kerncache.config ]
		then
			VER=`grep ^VERSION\ \= ${TEMP}/kerncache.config | awk '{ print $3 };'`
			PAT=`grep ^PATCHLEVEL\ \= ${TEMP}/kerncache.config | awk '{ print $3 };'`
			SUB=`grep ^SUBLEVEL\ \= ${TEMP}/kerncache.config | awk '{ print $3 };'`
			EXV=`grep ^EXTRAVERSION\ \= ${TEMP}/kerncache.config | sed -e "s/EXTRAVERSION =//" -e "s/ //g"`
			LOV=`grep ^CONFIG_LOCALVERSION\= ${TEMP}/kerncache.config | sed -e "s/CONFIG_LOCALVERSION=\"\(.*\)\"/\1/"`
			KV=${VER}.${PAT}.${SUB}${EXV}${LOV}
		else
			gen_die "Could not find kerncache.config in the kernel cache! Exiting."
		fi
	else
		# Configure the kernel
		# If BUILD_KERNEL=0 then assume --no-clean, menuconfig is cleared

		if [ ! -f "${KERNEL_DIR}"/Makefile ]
		then
			gen_die "Kernel Makefile (${KERNEL_DIR}/Makefile) missing.  Maybe re-install the kernel sources."
		fi

		VER=`grep ^VERSION\ \= ${KERNEL_DIR}/Makefile | awk '{ print $3 };'`
		PAT=`grep ^PATCHLEVEL\ \= ${KERNEL_DIR}/Makefile | awk '{ print $3 };'`
		SUB=`grep ^SUBLEVEL\ \= ${KERNEL_DIR}/Makefile | awk '{ print $3 };'`
		EXV=`grep ^EXTRAVERSION\ \= ${KERNEL_DIR}/Makefile | sed -e "s/EXTRAVERSION =//" -e "s/ //g" -e 's/\$([a-z]*)//gi'`

		if [ -z "${SUB}" ]; 
		then
			# Handle O= build directories
			KERNEL_SOURCE_DIR=`grep ^MAKEARGS\ \:\=  ${KERNEL_DIR}/Makefile | awk '{ print $4 };'`
			[ -z "${KERNEL_SOURCE_DIR}" ] && gen_die "Deriving \${KERNEL_SOURCE_DIR} failed"
			SUB=`grep ^SUBLEVEL\ \= ${KERNEL_SOURCE_DIR}/Makefile | awk '{ print $3 };'`
			EXV=`grep ^EXTRAVERSION\ \= ${KERNEL_SOURCE_DIR}/Makefile | sed -e "s/EXTRAVERSION =//" -e "s/ //g" -e 's/\$([a-z]*)//gi'`
		fi

		# Extract local version suffix from .config
		# Not, that we explicitly do not look at generated files like
		# - include/config/kernel.release
		# - include/linux/version.h
		# - include/linux/utsrelease.h
		# as they require "make prepare" to be up to date (bug #263927)
		local future_config="${KERNEL_DIR}"/.config
		if isTrue "${MRPROPER}" || [ ! -f "${future_config}" ]
		then
			determine_config_file
			future_config=${KERNEL_CONFIG}
		fi
		LOV=`grep ^CONFIG_LOCALVERSION= "${future_config}" | sed -r -e "s/.*=\"(.*)\"/\1/"`
		KV=${VER}.${PAT}.${SUB}${EXV}${LOV}
	fi
}

determine_real_args() {
	print_info 4 "Resolving config file, command line, and arch default settings."

	#                          Config File          Command Line             Arch Default
	#                          -----------          ------------             ------------
	set_config_with_override 2 DEBUGFILE            CMD_DEBUGFILE
	set_config_with_override 2 KERNEL_DIR           CMD_KERNEL_DIR           "${DEFAULT_KERNEL_SOURCE}"
	set_config_with_override 1 NO_KERNEL_SOURCES    CMD_NO_KERNEL_SOURCES
	set_config_with_override 2 KNAME                CMD_KERNNAME             "genkernel"

	set_config_with_override 2 MAKEOPTS             CMD_MAKEOPTS             "$DEFAULT_MAKEOPTS"
	set_config_with_override 2 KERNEL_MAKE          CMD_KERNEL_MAKE          "$DEFAULT_KERNEL_MAKE"
	set_config_with_override 2 UTILS_MAKE           CMD_UTILS_MAKE           "$DEFAULT_UTILS_MAKE"
	set_config_with_override 2 KERNEL_CC            CMD_KERNEL_CC            "$DEFAULT_KERNEL_CC"
	set_config_with_override 2 KERNEL_LD            CMD_KERNEL_LD            "$DEFAULT_KERNEL_LD"
	set_config_with_override 2 KERNEL_AS            CMD_KERNEL_AS            "$DEFAULT_KERNEL_AS"
	set_config_with_override 2 UTILS_CC             CMD_UTILS_CC             "$DEFAULT_UTILS_CC"
	set_config_with_override 2 UTILS_LD             CMD_UTILS_LD             "$DEFAULT_UTILS_LD"
	set_config_with_override 2 UTILS_AS             CMD_UTILS_AS             "$DEFAULT_UTILS_AS"

	set_config_with_override 2 KERNEL_CROSS_COMPILE CMD_KERNEL_CROSS_COMPILE
	set_config_with_override 2 UTILS_CROSS_COMPILE  CMD_UTILS_CROSS_COMPILE
	set_config_with_override 2 BOOTDIR              CMD_BOOTDIR              "/boot"

	set_config_with_override 1 SPLASH               CMD_SPLASH
	set_config_with_override 1 POSTCLEAR            CMD_POSTCLEAR
	set_config_with_override 1 MRPROPER             CMD_MRPROPER
	set_config_with_override 1 MENUCONFIG           CMD_MENUCONFIG
	set_config_with_override 1 CLEAN                CMD_CLEAN

	set_config_with_override 2 MINKERNPACKAGE       CMD_MINKERNPACKAGE
	set_config_with_override 2 MODULESPACKAGE       CMD_MODULESPACKAGE
	set_config_with_override 2 KERNCACHE            CMD_KERNCACHE
	set_config_with_override 1 NORAMDISKMODULES     CMD_NORAMDISKMODULES
	set_config_with_override 1 ALLRAMDISKMODULES    CMD_ALLRAMDISKMODULES
	set_config_with_override 2 INITRAMFS_OVERLAY    CMD_INITRAMFS_OVERLAY
	set_config_with_override 1 MOUNTBOOT            CMD_MOUNTBOOT
	set_config_with_override 1 BUILD_STATIC         CMD_STATIC
	set_config_with_override 1 SAVE_CONFIG          CMD_SAVE_CONFIG
 	set_config_with_override 1 SYMLINK              CMD_SYMLINK
	set_config_with_override 2 INSTALL_MOD_PATH     CMD_INSTALL_MOD_PATH
	set_config_with_override 1 OLDCONFIG            CMD_OLDCONFIG
	set_config_with_override 1 LVM                  CMD_LVM
	set_config_with_override 1 EVMS                 CMD_EVMS
	set_config_with_override 1 DMRAID               CMD_DMRAID
	set_config_with_override 1 ISCSI                CMD_ISCSI
	set_config_with_override 1 BUSYBOX              CMD_BUSYBOX              "yes"
	set_config_with_override 1 UNIONFS				CMD_UNIONFS
	set_config_with_override 1 NETBOOT				CMD_NETBOOT
	set_config_with_override 2 REAL_ROOT			CMD_REAL_ROOT
	set_config_with_override 1 DISKLABEL            CMD_DISKLABEL
	set_config_with_override 1 LUKS                 CMD_LUKS
	set_config_with_override 1 GPG                  CMD_GPG
	set_config_with_override 1 MDADM                CMD_MDADM
	set_config_with_override 1 MULTIPATH            CMD_MULTIPATH
	set_config_with_override 1 FIRMWARE             CMD_FIRMWARE
	set_config_with_override 2 FIRMWARE_DIR         CMD_FIRMWARE_DIR         "/lib/firmware"
	set_config_with_override 2 FIRMWARE_FILES       CMD_FIRMWARE_FILES
	set_config_with_override 1 INTEGRATED_INITRAMFS CMD_INTEGRATED_INITRAMFS
	set_config_with_override 1 GENZIMAGE            CMD_GENZIMAGE
	set_config_with_override 1 KEYMAP               CMD_KEYMAP               "yes"
	set_config_with_override 1 DOKEYMAPAUTO         CMD_DOKEYMAPAUTO
	set_config_with_override 2 BUSYBOX_CONFIG       CMD_BUSYBOX_CONFIG

	BOOTDIR=`arch_replace "${BOOTDIR}"`
	BOOTDIR=${BOOTDIR%/}    # Remove any trailing slash

	CACHE_DIR=`arch_replace "${CACHE_DIR}"`
	BUSYBOX_BINCACHE=`cache_replace "${BUSYBOX_BINCACHE}"`
	DEVICE_MAPPER_BINCACHE=`cache_replace "${DEVICE_MAPPER_BINCACHE}"`
	LVM_BINCACHE=`cache_replace "${LVM_BINCACHE}"`
	MDADM_BINCACHE=`cache_replace "${MDADM_BINCACHE}"`
	DMRAID_BINCACHE=`cache_replace "${DMRAID_BINCACHE}"`
	ISCSI_BINCACHE=`cache_replace "${ISCSI_BINCACHE}"`
	BLKID_BINCACHE=`cache_replace "${BLKID_BINCACHE}"`
	FUSE_BINCACHE=`cache_replace "${FUSE_BINCACHE}"`
	UNIONFS_FUSE_BINCACHE=`cache_replace "${UNIONFS_FUSE_BINCACHE}"`
	GPG_BINCACHE=`cache_replace "${GPG_BINCACHE}"`
  
	DEFAULT_KERNEL_CONFIG=`arch_replace "${DEFAULT_KERNEL_CONFIG}"`
	BUSYBOX_CONFIG=`arch_replace "${BUSYBOX_CONFIG}"`
	BUSYBOX_BINCACHE=`arch_replace "${BUSYBOX_BINCACHE}"`
	DEVICE_MAPPER_BINCACHE=`arch_replace "${DEVICE_MAPPER_BINCACHE}"`
	LVM_BINCACHE=`arch_replace "${LVM_BINCACHE}"`
	MDADM_BINCACHE=`arch_replace "${MDADM_BINCACHE}"`
	DMRAID_BINCACHE=`arch_replace "${DMRAID_BINCACHE}"`
	ISCSI_BINCACHE=`arch_replace "${ISCSI_BINCACHE}"`
	BLKID_BINCACHE=`arch_replace "${BLKID_BINCACHE}"`
	FUSE_BINCACHE=`arch_replace "${FUSE_BINCACHE}"`
	UNIONFS_FUSE_BINCACHE=`arch_replace "${UNIONFS_FUSE_BINCACHE}"`
	GPG_BINCACHE=`arch_replace "${GPG_BINCACHE}"`

	if [ -n "${CMD_BOOTLOADER}" ]
	then
		BOOTLOADER="${CMD_BOOTLOADER}"
		if [ "${CMD_BOOTLOADER}" != "${CMD_BOOTLOADER/:/}" ]
		then
			BOOTFS=`echo "${CMD_BOOTLOADER}" | cut -f2- -d:`
			BOOTLOADER=`echo "${CMD_BOOTLOADER}" | cut -f1 -d:`
		fi
	fi
	
	if [ "${NO_KERNEL_SOURCES}" != "1" ]
	then
		if [ ! -d ${KERNEL_DIR} ]
		then
			gen_die "kernel source directory \"${KERNEL_DIR}\" was not found!"
		fi
	fi

	if [ -z "${KERNCACHE}" ]
	then
		if [ "${KERNEL_DIR}" = '' -a "${NO_KERNEL_SOURCES}" != "1" ]
		then
			gen_die 'No kernel source directory!'
		fi
		if [ ! -e "${KERNEL_DIR}" -a "${NO_KERNEL_SOURCES}" != "1" ]
		then
			gen_die 'No kernel source directory!'
		fi
	else
		if [ "${KERNEL_DIR}" = '' ]
		then
			gen_die 'Kernel Cache specified but no kernel tree to verify against!'
		fi
	fi

	# Special case:  If --no-clean is specified on the command line, 
	# imply --no-mrproper.
	if [ "${CMD_CLEAN}" != '' ]
	then
		if ! isTrue ${CLEAN}
		then
			MRPROPER=0
		fi
	fi
	
	if [ -n "${MINKERNPACKAGE}" ]
	then
		mkdir -p `dirname ${MINKERNPACKAGE}`
	fi
	
	if [ -n "${MODULESPACKAGE}" ]
	then
		mkdir -p `dirname ${MODULESPACKAGE}`
	fi

	if [ -n "${KERNCACHE}" ]
	then
		mkdir -p `dirname ${KERNCACHE}`
	fi

	if ! isTrue "${BUILD_RAMDISK}"
	then
		INTEGRATED_INITRAMFS=0
	fi
	
	get_KV
}